Package com.sonar.sslr.squid

Examples of com.sonar.sslr.squid.SourceCodeBuilderCallback


                : comment.substring(2);
          }
        });

    /* Functions */
    builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<Grammar>(new SourceCodeBuilderCallback() {
      public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) {
        StringBuilder sb = new StringBuilder();
        for (Token token : astNode.getFirstDescendant(CxxGrammarImpl.declaratorId).getTokens()) {
          sb.append(token.getValue());
        }
        String functionName = sb.toString();
        SourceFunction function = new SourceFunction(functionName + ":" + astNode.getToken().getLine());
        function.setStartAtLine(astNode.getTokenLine());
        return function;
      }
    }, CxxGrammarImpl.functionDefinition));

    builder.withSquidAstVisitor(CounterVisitor.<Grammar> builder()
        .setMetricDef(CxxMetric.FUNCTIONS)
        .subscribeTo(CxxGrammarImpl.functionDefinition)
        .build());

    /* Classes */
    builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<Grammar>(new SourceCodeBuilderCallback() {
      public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) {
        AstNode classNameAst = astNode.getFirstDescendant(CxxGrammarImpl.className);
        String className = classNameAst == null ? "" : classNameAst.getFirstChild().getTokenValue();
        SourceClass cls = new SourceClass(className + ":" + astNode.getToken().getLine(), className);
        cls.setStartAtLine(astNode.getTokenLine());
View Full Code Here

TOP

Related Classes of com.sonar.sslr.squid.SourceCodeBuilderCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.