com.sonar.sslr.impl.Parser.parse()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中com.sonar.sslr.impl.Parser.parse()方法的一些代码示例,展示了Parser.parse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.parse()方法的具体详情如下:
包路径:com.sonar.sslr.impl.Parser
类名称:Parser
方法名:parse

Parser.parse介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.sonar.sslr/sslr-toolkit

  1. public void setSourceCode(File source, Charset charset) {
  2. this.astNode = configurationModel.getParser().parse(source);
  3. try {
  4. this.sourceCode = Files.toString(source, charset);
  5. } catch (IOException e) {
  6. Throwables.propagate(e);
  7. }
  8. }

代码示例来源:origin: org.sonarsource.sslr/sslr-toolkit

  1. public void setSourceCode(File source, Charset charset) {
  2. this.astNode = configurationModel.getParser().parse(source);
  3. try {
  4. this.sourceCode = new String(Files.readAllBytes(Paths.get(source.getPath())), charset);
  5. } catch (IOException e) {
  6. throw new RuntimeException(e);
  7. }
  8. }

代码示例来源:origin: uartois/sonar-golang

  1. public static AstNode parseFile(String filePath) {
  2. final File file = FileUtils.toFile(GoParser.class.getResource(filePath));
  3. if (file == null || !file.exists()) {
  4. throw new AssertionError("The file \"" + filePath + "\" does not exist.");
  5. }
  6. return P.parse(file);
  7. }

代码示例来源:origin: org.sonarsource.sslr/sslr-testing-harness

  1. public static AstNode parseFile(String filePath) {
  2. File file = FileUtils.toFile(MiniCParser.class.getResource(filePath));
  3. if (file == null || !file.exists()) {
  4. throw new AssertionError("The file \"" + filePath + "\" does not exist.");
  5. }
  6. return P.parse(file);
  7. }

代码示例来源:origin: SonarSource/sslr

  1. public void setSourceCode(File source, Charset charset) {
  2. this.astNode = configurationModel.getParser().parse(source);
  3. try {
  4. this.sourceCode = new String(Files.readAllBytes(Paths.get(source.getPath())), charset);
  5. } catch (IOException e) {
  6. throw new RuntimeException(e);
  7. }
  8. }

代码示例来源:origin: org.sonarsource.sslr/sslr-toolkit

  1. public void setSourceCode(String sourceCode) {
  2. this.astNode = configurationModel.getParser().parse(sourceCode);
  3. this.sourceCode = sourceCode;
  4. }

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-squid

  1. public static String printFile(String file, String bytecodePath) {
  2. final Parser p = JavaParser.createParser(Charsets.UTF_8);
  3. CompilationUnitTree cut = (CompilationUnitTree) p.parse(new File(file));
  4. List<File> bytecodeFiles = Lists.newArrayList();
  5. if (!bytecodePath.isEmpty()) {
  6. bytecodeFiles.add(new File(bytecodePath));
  7. }
  8. SemanticModel semanticModel = SemanticModel.createFor(cut, bytecodeFiles);
  9. return PrinterVisitor.print(cut, semanticModel);
  10. }
  11. }

代码示例来源:origin: org.codehaus.sonar.sslr/sslr-core

  1. public AstNode parse(File file) {
  2. try {
  3. lexer.lex(file);
  4. } catch (LexerException e) {
  5. throw new RecognitionException(e);
  6. }
  7. return parse(lexer.getTokens());
  8. }

代码示例来源:origin: org.codehaus.sonar-plugins.python/python-checks

  1. private boolean isTextParsedAsCode(String text) {
  2. try {
  3. AstNode astNode = parser.parse(text);
  4. List<AstNode> expressions = astNode.getDescendants(PythonGrammar.EXPRESSION_STMT);
  5. return astNode.getNumberOfChildren() > 1 && !isSimpleExpression(expressions);
  6. } catch (Exception e) {
  7. return false;
  8. }
  9. }

代码示例来源:origin: SonarSource/sslr

  1. public AstNode parse(String source) {
  2. try {
  3. lexer.lex(source);
  4. } catch (LexerException e) {
  5. throw new RecognitionException(e);
  6. }
  7. return parse(lexer.getTokens());
  8. }

代码示例来源:origin: SonarSource/sslr

  1. public AstNode parse(File file) {
  2. try {
  3. lexer.lex(file);
  4. } catch (LexerException e) {
  5. throw new RecognitionException(e);
  6. }
  7. return parse(lexer.getTokens());
  8. }

代码示例来源:origin: org.sonarsource.sslr/sslr-core

  1. public AstNode parse(String source) {
  2. try {
  3. lexer.lex(source);
  4. } catch (LexerException e) {
  5. throw new RecognitionException(e);
  6. }
  7. return parse(lexer.getTokens());
  8. }

代码示例来源:origin: org.sonarsource.python/python-checks

  1. private static boolean isTextParsedAsCode(String text) {
  2. try {
  3. AstNode astNode = parser.parse(text);
  4. List<AstNode> expressions = astNode.getDescendants(PythonGrammar.EXPRESSION_STMT);
  5. return astNode.getNumberOfChildren() > 1 && !isSimpleExpression(expressions);
  6. } catch (Exception e) {
  7. return false;
  8. }
  9. }

代码示例来源:origin: org.codehaus.sonar.sslr/sslr-core

  1. public AstNode parse(String source) {
  2. try {
  3. lexer.lex(source);
  4. } catch (LexerException e) {
  5. throw new RecognitionException(e);
  6. }
  7. return parse(lexer.getTokens());
  8. }

代码示例来源:origin: org.sonarsource.sslr/sslr-core

  1. public AstNode parse(File file) {
  2. try {
  3. lexer.lex(file);
  4. } catch (LexerException e) {
  5. throw new RecognitionException(e);
  6. }
  7. return parse(lexer.getTokens());
  8. }

代码示例来源:origin: felipebz/sonar-plsql

  1. public static PlSqlVisitorContext createContext(File file, FormsMetadata metadata) {
  2. Parser<Grammar> parser = PlSqlParser.create(new PlSqlConfiguration(StandardCharsets.UTF_8));
  3. TestPlSqlFile pythonFile = new TestPlSqlFile(file);
  4. AstNode rootTree = parser.parse(pythonFile.content());
  5. return new PlSqlVisitorContext(rootTree, pythonFile, metadata);
  6. }

代码示例来源:origin: SonarSource/sonar-python

  1. public static PythonVisitorContext createContext(File file) {
  2. Parser<Grammar> parser = PythonParser.create(new PythonConfiguration(StandardCharsets.UTF_8));
  3. TestPythonFile pythonFile = new TestPythonFile(file);
  4. AstNode rootTree = parser.parse(pythonFile.content());
  5. return new PythonVisitorContext(rootTree, pythonFile);
  6. }

代码示例来源:origin: org.sonarsource.python/python-squid

  1. public static PythonVisitorContext createContext(File file) {
  2. Parser<Grammar> parser = PythonParser.create(new PythonConfiguration(StandardCharsets.UTF_8));
  3. TestPythonFile pythonFile = new TestPythonFile(file);
  4. AstNode rootTree = parser.parse(pythonFile.content());
  5. return new PythonVisitorContext(rootTree, pythonFile);
  6. }

代码示例来源:origin: sonar-perl/sonar-perl

  1. public static PerlVisitorContext createContext(File file) {
  2. Parser<Grammar> parser = PerlParser.create(new PerlConfiguration(StandardCharsets.UTF_8));
  3. TestPerlFile perlFile = new TestPerlFile(file);
  4. AstNode rootTree = parser.parse(perlFile.content());
  5. return new PerlVisitorContext(rootTree, perlFile);
  6. }

代码示例来源:origin: sonar-perl/sonar-perl

  1. public static PerlVisitorContext createContext(File file) {
  2. Parser<Grammar> parser = PerlParser.create(new PerlConfiguration(StandardCharsets.UTF_8));
  3. TestPerlFile pythonFile = new TestPerlFile(file);
  4. AstNode rootTree = parser.parse(pythonFile.content());
  5. return new PerlVisitorContext(rootTree, pythonFile);
  6. }

相关文章