You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NewSymbolTable.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.api.batch.sensor.symbol;
  21. import org.sonar.api.batch.fs.InputFile;
  22. import org.sonar.api.batch.fs.TextRange;
  23. /**
  24. * This builder is used to define symbol references on files.
  25. *
  26. * Example:
  27. *
  28. * <pre>
  29. * NewSymbolTable symbolTable = sensorContext.newSymbolTable().onFile(inputFile);
  30. * symbolTable.newSymbol(1, 10, 1, 15)
  31. * .newReference(10, 12, 10, 17)
  32. * .newReference(11, 11, 11, 16);
  33. *
  34. * // Add more symbols if needed
  35. *
  36. * symbolTable.save();
  37. *
  38. * </pre>
  39. *
  40. * @since 5.6
  41. */
  42. public interface NewSymbolTable {
  43. /**
  44. * The file the symbol table belongs to.
  45. */
  46. NewSymbolTable onFile(InputFile inputFile);
  47. /**
  48. * Register a new symbol declaration.
  49. * @param range Range of text for the symbol declaration. See for example {@link InputFile#newRange(int, int, int, int)}.
  50. */
  51. NewSymbol newSymbol(TextRange range);
  52. /**
  53. * Shortcut to avoid calling {@link InputFile#newRange(int, int, int, int)}
  54. */
  55. NewSymbol newSymbol(int startLine, int startLineOffset, int endLine, int endLineOffset);
  56. /**
  57. * Call this method only once when your are done with defining all symbols of the file. It is not permitted to save a symbol table twice for the same file.
  58. * @throws IllegalStateException if you have defined overlapping symbols
  59. */
  60. void save();
  61. }