List of usage examples for org.eclipse.jdt.internal.compiler.problem ProblemReporter ProblemReporter
public ProblemReporter(IErrorHandlingPolicy policy, CompilerOptions options, IProblemFactory problemFactory)
From source file:ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilationUtils.java
License:Apache License
private static Parser createCommentRecorderParser(CompilerOptions options) { return new CommentRecorderParser(new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), options, new DefaultProblemFactory()), false); }
From source file:ch.uzh.ifi.seal.changedistiller.util.CompilationUtils.java
License:Apache License
private static Parser createCommentRecorderParser(CompilerOptions options) { Parser parser = new CommentRecorderParser( new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), options, new DefaultProblemFactory()), false);/*from w ww . j a va 2s . co m*/ return parser; }
From source file:com.android.tools.idea.lint.LombokPsiConverterTest.java
License:Apache License
@Nullable private static Node parse(String code) { CompilerOptions options = new CompilerOptions(); options.complianceLevel = options.sourceLevel = options.targetJDK = ClassFileConstants.JDK1_7; options.parseLiteralExpressionsAsConstants = true; ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.exitOnFirstError(), options, new DefaultProblemFactory()); Parser parser = new Parser(problemReporter, options.parseLiteralExpressionsAsConstants); parser.javadocParser.checkDocComment = false; EcjTreeConverter converter = new EcjTreeConverter(); org.eclipse.jdt.internal.compiler.batch.CompilationUnit sourceUnit = new org.eclipse.jdt.internal.compiler.batch.CompilationUnit( code.toCharArray(), "unitTest", "UTF-8"); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, 0); CompilationUnitDeclaration unit = parser.parse(sourceUnit, compilationResult); if (unit == null) { return null; }/*from ww w. ja v a2s. c o m*/ converter.visit(code, unit); List<? extends Node> nodes = converter.getAll(); for (lombok.ast.Node node : nodes) { if (node instanceof lombok.ast.CompilationUnit) { return node; } } return null; }
From source file:com.android.tools.lint.EcjParser.java
License:Apache License
private Parser getParser() { if (mParser == null) { CompilerOptions options = createCompilerOptions(); ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.exitOnFirstError(), options, new DefaultProblemFactory()); mParser = new Parser(problemReporter, options.parseLiteralExpressionsAsConstants); mParser.javadocParser.checkDocComment = false; }//from www . jav a 2 s. c o m return mParser; }
From source file:com.codenvy.ide.ext.java.server.internal.codeassist.SelectionEngine.java
License:Open Source License
/** * The SelectionEngine is responsible for computing the selected object. * * It requires a searchable name environment, which supports some * specific search APIs, and a requestor to feed back the results to a UI. * * @param nameEnvironment org.eclipse.jdt.internal.core.SearchableEnvironment * used to resolve type/package references and search for types/packages * based on partial names.//from w ww .j a v a 2s . c om * * @param requestor org.eclipse.jdt.internal.codeassist.ISelectionRequestor * since the engine might produce answers of various forms, the engine * is associated with a requestor able to accept all possible completions. * * @param settings java.util.Map * set of options used to configure the code assist engine. */ public SelectionEngine(SearchableEnvironment nameEnvironment, ISelectionRequestor requestor, Map settings, WorkingCopyOwner owner, IndexManager indexManager, JavaProject javaProject) { super(settings); this.requestor = requestor; this.indexManager = indexManager; this.javaProject = javaProject; this.nameEnvironment = nameEnvironment; ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.compilerOptions, new DefaultProblemFactory(Locale.getDefault())) { public CategorizedProblem createProblem(char[] fileName, int problemId, String[] problemArguments, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition, int lineNumber, int columnNumber) { CategorizedProblem pb = super.createProblem(fileName, problemId, problemArguments, messageArguments, severity, problemStartPosition, problemEndPosition, lineNumber, columnNumber); if (SelectionEngine.this.problem == null && pb.isError() && (pb.getID() & IProblem.Syntax) == 0) { SelectionEngine.this.problem = pb; } return pb; } }; this.lookupEnvironment = new LookupEnvironment(this, this.compilerOptions, problemReporter, nameEnvironment); this.parser = new SelectionParser(problemReporter); this.owner = owner; }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.BasicSearchEngine.java
License:Open Source License
private Parser getParser() { if (this.parser == null) { this.compilerOptions = new CompilerOptions(JavaCore.getOptions()); ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.compilerOptions, new DefaultProblemFactory()); this.parser = new Parser(problemReporter, true); }/*from w w w . jav a 2 s . com*/ return this.parser; }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocator.java
License:Open Source License
protected Parser basicParser() { if (this.basicParser == null) { ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.options, new DefaultProblemFactory()); this.basicParser = new Parser(problemReporter, false); this.basicParser.reportOnlyOneSyntaxError = true; }// w w w. j ava2s . co m return this.basicParser; }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocator.java
License:Open Source License
/** * Create a new parser for the given project, as well as a lookup environment. *//*from ww w. j ava2s . com*/ public void initialize(JavaProject project, int possibleMatchSize) throws JavaModelException { // clean up name environment only if there are several possible match as it is reused // when only one possible match (bug 58581) if (this.nameEnvironment != null && possibleMatchSize != 1) this.nameEnvironment.cleanup(); SearchableEnvironment searchableEnvironment = project.newSearchableNameEnvironment(this.workingCopies); // if only one possible match, a file name environment costs too much, // so use the existing searchable environment which will populate the java model // only for this possible match and its required types. this.nameEnvironment = possibleMatchSize == 1 ? (INameEnvironment) searchableEnvironment : (INameEnvironment) new JavaSearchNameEnvironment(project, this.workingCopies); // create lookup environment Map map = project.getOptions(true); map.put(CompilerOptions.OPTION_TaskTags, org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING); this.options = new CompilerOptions(map); ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.options, new DefaultProblemFactory()); this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, this.nameEnvironment); this.lookupEnvironment.mayTolerateMissingType = true; this.parser = MatchLocatorParser.createParser(problemReporter, this); // basic parser needs also to be reset as project options may have changed // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=163072 this.basicParser = null; // remember project's name lookup this.nameLookup = searchableEnvironment.nameLookup; // initialize queue of units this.numberOfMatches = 0; this.matchesToProcess = new PossibleMatch[possibleMatchSize]; }
From source file:com.redhat.ceylon.eclipse.core.model.JDTModelLoader.java
License:Open Source License
public JDTModelLoader(final JDTModuleManager moduleManager, final Modules modules) { this.moduleManager = moduleManager; this.modules = modules; javaProject = moduleManager.getJavaProject(); if (javaProject != null) { compilerOptions = new CompilerOptions(javaProject.getOptions(true)); compilerOptions.ignoreMethodBodies = true; compilerOptions.storeAnnotations = true; problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory()); }//w ww .ja v a 2 s . c om this.timer = new Timer(false); internalCreate(); if (javaProject != null) { modelLoaders.put(javaProject.getProject(), new WeakReference<JDTModelLoader>(this)); } }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTModelLoader.java
License:Open Source License
public JDTModelLoader(final ModuleManager moduleManager, final Modules modules) { this.moduleManager = moduleManager; this.modules = modules; javaProject = ((JDTModuleManager) moduleManager).getJavaProject(); compilerOptions = new CompilerOptions(javaProject.getOptions(true)); compilerOptions.ignoreMethodBodies = true; compilerOptions.storeAnnotations = true; problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory()); this.timer = new Timer(false); internalCreate();// ww w . j a v a2 s . c o m }