2020package org .sonar .cxx .visitors ;
2121
2222import com .sonar .sslr .api .AstNode ;
23- import com .sonar .sslr .api .AstVisitor ;
2423import com .sonar .sslr .api .GenericTokenType ;
2524import com .sonar .sslr .api .Grammar ;
2625import com .sonar .sslr .api .TokenType ;
3029import org .sonar .cxx .api .CxxPunctuator ;
3130import org .sonar .cxx .parser .CxxGrammarImpl ;
3231import org .sonar .squidbridge .SquidAstVisitor ;
33- import org .sonar .squidbridge .SquidAstVisitorContext ;
3432
35- public class CxxParseErrorLoggerVisitor <GRAMMAR extends Grammar >
36- extends SquidAstVisitor <GRAMMAR > implements AstVisitor {
33+ public class CxxParseErrorLoggerVisitor <GRAMMAR extends Grammar > extends SquidAstVisitor <GRAMMAR > {
3734
3835 private static final String SYNTAX_ERROR_MSG
3936 = "Source code parser: {} syntax error(s) detected. Syntax errors could cause invalid software metric values."
4037 + " Root cause are typically missing includes, missing macros or compiler specific extensions." ;
4138 private static final Logger LOG = Loggers .get (CxxParseErrorLoggerVisitor .class );
4239 private static int errors = 0 ;
4340
44- private final SquidAstVisitorContext <?> context ;
45-
46- public CxxParseErrorLoggerVisitor (SquidAstVisitorContext <?> context ) {
47- this .context = context ;
48- }
49-
5041 public static void finalReport () {
5142 if (errors != 0 ) {
5243 LOG .warn (SYNTAX_ERROR_MSG , errors );
@@ -85,7 +76,7 @@ public void visitNode(AstNode node) {
8576 // part with CURLBR_LEFT is typically an ignored declaration
8677 if (identifierLine != -1 ) {
8778 LOG .debug ("[{}:{}]: skip declaration: {}" ,
88- context .getFile (), identifierLine , sb .toString ());
79+ getContext () .getFile (), identifierLine , sb .toString ());
8980 sb .setLength (0 );
9081 identifierLine = -1 ;
9182 }
@@ -100,7 +91,7 @@ public void visitNode(AstNode node) {
10091 if (identifierLine != -1 && sb .length () > 0 ) {
10192 // part without CURLBR_LEFT is typically a syntax error
10293 LOG .debug ("[{}:{}]: syntax error: {}" ,
103- context .getFile (), identifierLine , sb .toString ());
94+ getContext () .getFile (), identifierLine , sb .toString ());
10495 }
10596 }
10697
0 commit comments