本文整理汇总了Java中com.sonar.sslr.impl.Parser类的典型用法代码示例。如果您正苦于以下问题:Java Parser类的具体用法?Java Parser怎么用?Java Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parser类属于com.sonar.sslr.impl包,在下文中一共展示了Parser类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
/**
* Returns a scanner from configuration and visitors.
*
* @param config apex configuration.
* @param visitors list of visitors.
* @return a scanner.
*/
public static AstScanner<Grammar> create(ApexConfiguration config, SquidAstVisitor<Grammar>... visitors) {
final SourceProject sourceProject = new SourceProject(PROJECT_NAME);
final SquidAstVisitorContextImpl<Grammar> context = new SquidAstVisitorContextImpl<>(sourceProject);
final Parser<Grammar> parser = ApexParser.create(config);
AstScanner.Builder<Grammar> builder = AstScanner.<Grammar>builder(context).setBaseParser(parser);
builder.withMetrics(ApexMetric.values());
builder.setFilesMetric(ApexMetric.FILES);
setCommentAnalyser(builder);
setClassesAnalyser(builder);
setMethodAnalyser(builder);
setMetrics(config, builder);
for (SquidAstVisitor<Grammar> visitor : visitors) {
builder.withSquidAstVisitor(visitor);
}
return builder.build();
}
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:27,代码来源:ApexAstScanner.java
示例2: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static AstScanner<Grammar> create(FlowConfiguration conf, SquidAstVisitor<Grammar>... visitors) {
final SquidAstVisitorContextImpl<Grammar> context = new SquidAstVisitorContextImpl<Grammar>(new SourceProject("Flow Project"));
final Parser<Grammar> parser = NodeParser.create(conf);
AstScanner.Builder<Grammar> builder = AstScanner.<Grammar>builder(context).setBaseParser(parser);
/* Required */
builder.setFilesMetric(FlowMetric.FILES);
setCommentAnalyser(builder);
/* External visitors (typically Check ones) */
for (SquidAstVisitor<Grammar> visitor : visitors) {
builder.withSquidAstVisitor(visitor);
}
return builder.build();
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:18,代码来源:NodeAstScanner.java
示例3: getParser
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
/**
* Get a Sonar {@link Parser} from this factory
*
* @return a new parser instance
*/
public Parser<Grammar> getParser()
{
final GrappaChannel channel = new GrappaChannel(rule);
suppliers.forEach(channel::addListenerSupplier);
final LexerfulGrammarBuilder builder = getGrammarBuilder();
builder.setRootRule(entryPoint);
final Lexer lexer = Lexer.builder()
.withFailIfNoChannelToConsumeOneCharacter(true)
.withChannel(channel)
.build();
return Parser.builder(builder.build())
.withLexer(lexer)
.build();
}
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:24,代码来源:GrappaSslrFactory.java
示例4: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
/**
* Creates a Parser integrated with Grammar and Lexer.
*
* @param config apex configuration.
* @return a parser
* @throws IllegalArgumentException when configuration is null.
*/
public static Parser<Grammar> create(ApexConfiguration config) {
if (config == null) {
throw new IllegalArgumentException(ERROR_MESSAGE);
}
return Parser.builder(ApexGrammar.create())
.withLexer(ApexLexer.create(config)).build();
}
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:15,代码来源:ApexParser.java
示例5: parseQuery
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
/**
* Re-parses a query that was retrieved as a String.
*
* @param astNode The String's node.
* @return The query as a new QUERY_EXPRESSION node.
*/
public static AstNode parseQuery(AstNode astNode) {
AstNode parsedQuery = null;
try {
String string = astNode.getTokenOriginalValue();
String queryAsString = StringUtils.substringBetween(string, "'", "'");
Parser<Grammar> queryParser = ApexParser.create(new ApexConfiguration(Charsets.UTF_8));
queryParser.setRootRule(queryParser.getGrammar().rule(ApexGrammarRuleKey.QUERY_EXPRESSION));
parsedQuery = queryParser.parse(queryAsString);
} catch (Exception e) {
ChecksLogger.logCheckError(CLASS_TO_LOG, METHOD_TO_LOG, e.toString());
}
return parsedQuery;
}
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:20,代码来源:SoqlParser.java
示例6: doGetParser
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
@Override
public Parser doGetParser() {
return null;
}
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:5,代码来源:ApexConfigurationModel.java
示例7: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static AstScanner<Grammar> create(FlowConfiguration conf, SquidAstVisitor<Grammar>... visitors) {
final SquidAstVisitorContextImpl<Grammar> context = new SquidAstVisitorContextImpl<Grammar>(new SourceProject("Flow Project"));
final Parser<Grammar> parser = FlowParser.create(conf);
AstScanner.Builder<Grammar> builder = AstScanner.<Grammar>builder(context).setBaseParser(parser);
setCommentAnalyser(builder);
/* Metrics */
setMetrics(conf, builder);
/* External visitors (typically Check ones) */
for (SquidAstVisitor<Grammar> visitor : visitors) {
builder.withSquidAstVisitor(visitor);
}
return builder.build();
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:20,代码来源:FlowAstScanner.java
示例8: getParser
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
@Override
public Parser<Grammar> getParser() {
return FlowParser.create(getConfiguration());
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:5,代码来源:FlowConfigurationModel.java
示例9: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static Parser<Grammar> create(FlowConfiguration conf) {
NodeParser.conf=conf;
return Parser.builder(NodeGrammar.create()).withLexer(FlowLexer.create(conf)).build();
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:5,代码来源:NodeParser.java
示例10: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static Parser<Grammar> create(FlowConfiguration conf) {
FlowParser.conf=conf;
return Parser.builder(FlowGrammar.create()).withLexer(FlowLexer.create(conf)).build();
}
开发者ID:I8C,项目名称:sonar-flow-plugin,代码行数:5,代码来源:FlowParser.java
示例11: doGetParser
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
@Override
public Parser<Grammar> doGetParser() {
return PuppetParser.create(getConfiuration());
}
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:5,代码来源:PuppetConfigurationModel.java
示例12: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static AstScanner<Grammar> create(PuppetConfiguration conf, SquidAstVisitor<Grammar>... visitors) {
final SquidAstVisitorContextImpl<Grammar> context = new SquidAstVisitorContextImpl<>(new SourceProject("Puppet Project"));
final Parser<Grammar> parser = PuppetParser.create(conf);
AstScanner.Builder<Grammar> builder = AstScanner.<Grammar>builder(context).setBaseParser(parser);
builder.withMetrics(PuppetMetric.values());
builder.setFilesMetric(PuppetMetric.FILES);
builder.setCommentAnalyser(new PuppetCommentAnalyser());
builder.withSquidAstVisitor(new LinesVisitor<Grammar>(PuppetMetric.LINES));
builder.withSquidAstVisitor(new PuppetLinesOfCodeVisitor<Grammar>(PuppetMetric.LINES_OF_CODE));
builder.withSquidAstVisitor(new FunctionVisitor());
builder.withSquidAstVisitor(new ComplexityVisitor());
builder.withSquidAstVisitor(CommentsVisitor.<Grammar>builder().withCommentMetric(PuppetMetric.COMMENT_LINES)
.withNoSonar(true)
.withIgnoreHeaderComment(conf.getIgnoreHeaderComments())
.build());
builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<Grammar>(
new ClassSourceCodeBuilderCallback(),
PuppetGrammar.CLASSDEF,
PuppetGrammar.DEFINITION));
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(PuppetMetric.CLASSES)
.subscribeTo(PuppetGrammar.CLASSDEF, PuppetGrammar.DEFINITION)
.build());
// TODO: To be discussed with the mapping of FUNCTIONS
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(PuppetMetric.RESOURCES)
.subscribeTo(PuppetGrammar.RESOURCE)
.build());
builder.withSquidAstVisitor(CounterVisitor.<Grammar>builder()
.setMetricDef(PuppetMetric.STATEMENTS)
.subscribeTo(PuppetGrammar.STATEMENT)
.build());
for (SquidAstVisitor<Grammar> visitor : visitors) {
if (visitor instanceof CharsetAwareVisitor) {
((CharsetAwareVisitor) visitor).setCharset(conf.getCharset());
}
builder.withSquidAstVisitor(visitor);
}
return builder.build();
}
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:51,代码来源:PuppetAstScanner.java
示例13: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static Parser<Grammar> create(PuppetConfiguration conf) {
return Parser.builder(PuppetGrammar.create().build())
.withLexer(PuppetLexer.create(conf)).build();
}
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:5,代码来源:PuppetParser.java
示例14: DummyConfigurationModel
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
private DummyConfigurationModel(final Parser<Grammar> parser)
{
this.parser = parser;
}
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:5,代码来源:SampleToolkit.java
示例15: doGetParser
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
@Override
public Parser doGetParser()
{
return parser;
}
开发者ID:litesolutions,项目名称:sonar-sslr-grappa,代码行数:6,代码来源:SampleToolkit.java
示例16: doGetParser
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
@Override
public Parser<? extends Grammar> doGetParser() {
return PlSQLParser.create(getConfiguration());
}
开发者ID:Ne0s,项目名称:sonar-plsql,代码行数:5,代码来源:PlSQLConfigurationModel.java
示例17: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static Parser<LexerlessGrammar> create(PlSQLConfiguration conf, ParsingEventListener... parsingEventListeners) {
return new ParserAdapter<LexerlessGrammar>(conf.getCharset(), PlSQLGrammar.createGrammar());
}
开发者ID:Ne0s,项目名称:sonar-plsql,代码行数:4,代码来源:PlSQLParser.java
示例18: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static AstScanner<LexerlessGrammar> create(PlSQLConfiguration conf, SquidAstVisitor<LexerlessGrammar>... visitors) {
final SquidAstVisitorContextImpl<LexerlessGrammar> context = new SquidAstVisitorContextImpl<LexerlessGrammar>(new SourceProject("PlSQL Project"));
final Parser<LexerlessGrammar> parser = PlSQLParser.create(conf);
AstScanner.Builder<LexerlessGrammar> builder = AstScanner.<LexerlessGrammar> builder(context).setBaseParser(parser);
/* Metrics */
builder.withMetrics(PlSQLMetric.values());
/* Comments */
builder.setCommentAnalyser(new PlSQLCommentAnalyser());
/* Files */
builder.setFilesMetric(PlSQLMetric.FILES);
/* Functions */
builder.withSquidAstVisitor(CounterVisitor.<LexerlessGrammar> builder()
.setMetricDef(PlSQLMetric.FUNCTIONS)
.subscribeTo(PlSQLGrammar.FUNCTION_DECLARATION, PlSQLGrammar.FUNCTION_BODY)
.build());
builder.withSquidAstVisitor(new SourceCodeBuilderVisitor<LexerlessGrammar>(new SourceCodeBuilderCallback() {
public SourceCode createSourceCode(SourceCode parentSourceCode, AstNode astNode) {
AstNode identifier = astNode.getFirstChild(PlSQLGrammar.IDENTIFIER_NAME);
final String functionName = identifier == null ? "anonymous" : identifier.getTokenValue();
final String fileKey = parentSourceCode.isType(SourceFile.class) ? parentSourceCode.getKey() : parentSourceCode.getParent(SourceFile.class).getKey();
SourceFunction function = new SourceFunction(fileKey + ":" + functionName + ":" + astNode.getToken().getLine() + ":" + astNode.getToken().getColumn());
function.setStartAtLine(astNode.getTokenLine());
return function;
}
}, PlSQLGrammar.FUNCTION_BODY));
/* Metrics */
builder.withSquidAstVisitor(new LinesVisitor<LexerlessGrammar>(PlSQLMetric.LINES));
builder.withSquidAstVisitor(new LinesOfCodeVisitor<LexerlessGrammar>(PlSQLMetric.LINES_OF_CODE));
builder.withSquidAstVisitor(CommentsVisitor.<LexerlessGrammar> builder().withCommentMetric(PlSQLMetric.COMMENT_LINES)
.withNoSonar(true)
.withIgnoreHeaderComment(conf.getIgnoreHeaderComments())
.build());
builder.withSquidAstVisitor(CounterVisitor.<LexerlessGrammar> builder()
.setMetricDef(PlSQLMetric.STATEMENTS)
.subscribeTo(
PlSQLGrammar.INSERT_STATEMENT,
PlSQLGrammar.RETURN_STATEMENT,
PlSQLGrammar.ASSIGNMENT_STATEMENT,
PlSQLGrammar.IF_STATEMENT,
PlSQLGrammar.CALL_STATEMENT,
PlSQLGrammar.LOOP_STATEMENT,
PlSQLGrammar.CASE_STATEMENT,
PlSQLGrammar.BLOCK_STATEMENT
// PlSQLGrammar.WITH_STATEMENT,
// PlSQLGrammar.SWITCH_STATEMENT,
// PlSQLGrammar.THROW_STATEMENT,
// PlSQLGrammar.TRY_STATEMENT,
// PlSQLGrammar.DEBUGGER_STATEMENT
)
.build());
builder.withSquidAstVisitor(new ComplexityVisitor());
/* External visitors (typically Check ones) */
for (SquidAstVisitor<LexerlessGrammar> visitor : visitors) {
if (visitor instanceof CharsetAwareVisitor) {
((CharsetAwareVisitor) visitor).setCharset(conf.getCharset());
}
builder.withSquidAstVisitor(visitor);
}
return builder.build();
}
开发者ID:Ne0s,项目名称:sonar-plsql,代码行数:73,代码来源:PlSQLAstScanner.java
示例19: create
import com.sonar.sslr.impl.Parser; //导入依赖的package包/类
public static Parser<LexerlessGrammar> create(LuaConfiguration conf) {
return new ParserAdapter<LexerlessGrammar>(conf.getCharset(), LuaGrammar.createGrammar());
}
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:4,代码来源:LuaParser.java
注:本文中的com.sonar.sslr.impl.Parser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论