Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the number of symbols retrieved by SymbolReferenceAnalyzer #4220

Closed
costin-zaharia-sonarsource opened this issue Apr 9, 2021 · 2 comments · Fixed by #5548 or #5550
Closed
Assignees
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Performance It takes too long.
Milestone

Comments

@costin-zaharia-sonarsource
Copy link
Member

Get the symbols only for those identifiers which appear multiple times in file (SonarQube has support only for in file highlighting).

One possible way to implement this is to register for symbols and keep a list of identifier names per file. Then, in the utility analyzers, before retrieving the symbol, check first if the identifier name is in the list of known identifiers.

@pavel-mikula-sonarsource
Copy link
Contributor

Similar approach, more isolated:

  • Walk the syntax tree
  • Collect names that can be translated into declared symbols (classes, members, parameters, variable declarations)
  • Use this set to filter possible candidates for symbols and don't ask for symbol, if not present in the set

@pavel-mikula-sonarsource
Copy link
Contributor

Going further:

  • Walk the syntax tree
  • Track declared symbols
  • Directly use tracked symbols for standalone identifier usages
// Track triviaLines
var triviaLines = triviaContent.Split(MetricsBase.LineTerminators, StringSplitOptions.None); 

// Track triviaLineNumber
for (var triviaLineNumber = 0; triviaLineNumber < triviaLines.Length; triviaLineNumber++)
{
    // Don't ask for triviaLines symbol
    // Don't ask for triviaLineNumber symbol
    if (!IsCode(triviaLines[triviaLineNumber]))

@csaba-sagi-sonarsource csaba-sagi-sonarsource added this to the 8.38 milestone Apr 4, 2022
@costin-zaharia-sonarsource costin-zaharia-sonarsource changed the title Reduce the number of symbols retrieved by TokenTypeAnalyzer and SymbolReferenceAnalyzer Reduce the number of symbols retrieved by SymbolReferenceAnalyzer Apr 13, 2022
@costin-zaharia-sonarsource costin-zaharia-sonarsource added Area: VB.NET VB.NET rules related issues. Area: C# C# rules related issues. labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Performance It takes too long.
Projects
None yet
3 participants