fabriciocolombo / sonar-delphi

SonarQube Delphi Plugin
91 stars 46 forks source link

XX is not a valid line for pointer #42

Open jbabijczuk opened 8 years ago

jbabijczuk commented 8 years ago

There is a problem with nested functions.

Scenario

Example in attached file.

I added this code

if ((activeFunction != null) && (activeFunction.getUnit() != results.getActiveUnit()))
        activeFunction = null;

in method FunctionInterface createFunction(CodeAnalysisResults results, ClassInterface currentClass)

It solved this problem but it is not a good solution :(

. Desktop.zip

jbabijczuk commented 8 years ago

Better solution:

private FunctionInterface getCachedFunction(CodeAnalysisResults results)
  {
      FunctionInterface activeFunction = results.getCachedFunction(functionName);
      if (activeFunction == null)
          return null;
      if (activeFunction.getUnit() != results.getActiveUnit())
          return null;
      if ((results.getParseStatus() == LexerMetrics.IMPLEMENTATION) && (!activeFunction.isDeclaration()))
          return null;
      return activeFunction;
  }

  private FunctionInterface createFunction(CodeAnalysisResults results, ClassInterface currentClass) 
  {
    FunctionInterface activeFunction = getCachedFunction(results);

    if (activeFunction == null)
panga commented 8 years ago

@jbabijczuk thanks for the fix, I think it worked, but I found another annoying bug!