List of usage examples for org.eclipse.jdt.internal.core.util CodeSnippetParsingUtil parseStatements
public ConstructorDeclaration parseStatements(char[] source, int offset, int length, Map<String, String> settings, boolean recordParsingInformation, boolean enabledStatementRecovery)
From source file:org.jboss.forge.roaster.spi.impl.JavaParserImpl.java
License:Open Source License
@Override public List<Problem> validateSnippet(String snippet) { CodeSnippetParsingUtil codeSnippetParsingUtil = new CodeSnippetParsingUtil(false); ConstructorDeclaration constructorDeclaration = codeSnippetParsingUtil.parseStatements( snippet.toCharArray(), 0, snippet.length(), JDTOptions.getJDTOptions(), true, false); CompilationResult compilationResult = constructorDeclaration.compilationResult(); List<Problem> problems = new ArrayList<>(); if (compilationResult.hasErrors()) { for (CategorizedProblem problem : compilationResult.getErrors()) { Problem p = new Problem(problem.getMessage(), problem.getSourceStart(), problem.getSourceEnd(), problem.getSourceLineNumber()); problems.add(p);//from www . ja va 2 s. c om } } return problems; }