Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-4001

Compute the end position of multi-line token only once

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.3
    • Component/s: Parser
    • Labels:
      None

      Description

      Currently, we have different components in the java analyzer that compute the end position of a token, and each time in a different way (SonarComponents, InternalSyntaxToken, SyntaxHighlighterVisitor):

      • the majority does not support tokens on multiple lines
      • some support tokens on multiple lines but the result is not consistent with others

      The improvement is:

      • compute only once the end position (line, column) of a token and expose its value on the SyntaxToken public API
      • try to be more explicit in the code about columns. Currently, SyntaxToken#column() start at 0 instead of 1 and there's often a mess of "+ 1" or "- 1" around. SonarJava's developers should be encouraged to always use the column number (starting at 1, the only one understood by our users) and should have access to the column offset (starting at 0, used for external integration like sonar-plugin-api) without computation.

        Attachments

          Activity

            People

            Assignee:
            alban.auzeill Alban Auzeill
            Reporter:
            alban.auzeill Alban Auzeill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: