org.eclipse.jdt.internal.compiler.problem.ProblemReporter Java Examples
The following examples show how to use
org.eclipse.jdt.internal.compiler.problem.ProblemReporter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaDerivedStateComputer.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public void installStubs(Resource resource) { if (isInfoFile(resource)) { return; } CompilationUnit compilationUnit = getCompilationUnit(resource); ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), getCompilerOptions(resource), new DefaultProblemFactory()); Parser parser = new Parser(problemReporter, true); CompilationResult compilationResult = new CompilationResult(compilationUnit, 0, 1, -1); CompilationUnitDeclaration result = parser.dietParse(compilationUnit, compilationResult); if (result.types != null) { for (TypeDeclaration type : result.types) { ImportReference currentPackage = result.currentPackage; String packageName = null; if (currentPackage != null) { char[][] importName = currentPackage.getImportName(); if (importName != null) { packageName = CharOperation.toString(importName); } } JvmDeclaredType jvmType = createType(type, packageName); resource.getContents().add(jvmType); } } }
Example #2
Source File: LookupEnvironment.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public LookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions globalOptions, ProblemReporter problemReporter, INameEnvironment nameEnvironment) { this.typeRequestor = typeRequestor; this.globalOptions = globalOptions; this.problemReporter = problemReporter; this.defaultPackage = new PackageBinding(this); // assume the default package always exists this.defaultImports = null; this.nameEnvironment = nameEnvironment; this.knownPackages = new HashtableOfPackage(); this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); this.uniquePolymorphicMethodBindings = new SimpleLookupTable(3); this.missingTypes = null; this.accessRestrictions = new HashMap(3); this.classFilePool = ClassFilePool.newInstance(); this.typesBeingConnected = new HashSet(); this.typeSystem = this.globalOptions.sourceLevel >= ClassFileConstants.JDK1_8 && this.globalOptions.storeAnnotations ? new AnnotatableTypeSystem(this) : new TypeSystem(this); }
Example #3
Source File: CompilationUnitDeclaration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public boolean isSuppressed(CategorizedProblem problem) { if (this.suppressWarningsCount == 0) return false; int irritant = ProblemReporter.getIrritant(problem.getID()); if (irritant == 0) return false; int start = problem.getSourceStart(); int end = problem.getSourceEnd(); nextSuppress: for (int iSuppress = 0, suppressCount = this.suppressWarningsCount; iSuppress < suppressCount; iSuppress++) { long position = this.suppressWarningScopePositions[iSuppress]; int startSuppress = (int) (position >>> 32); int endSuppress = (int) position; if (start < startSuppress) continue nextSuppress; if (end > endSuppress) continue nextSuppress; if (this.suppressWarningIrritants[iSuppress].isSet(irritant)) return true; } return false; }
Example #4
Source File: SourceTypeConverter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static CompilationUnitDeclaration buildCompilationUnit( ISourceType[] sourceTypes, int flags, ProblemReporter problemReporter, CompilationResult compilationResult) { // long start = System.currentTimeMillis(); SourceTypeConverter converter = new SourceTypeConverter(flags, problemReporter); try { return converter.convert(sourceTypes, compilationResult); } catch (JavaModelException e) { return null; /* } finally { System.out.println("Spent " + (System.currentTimeMillis() - start) + "ms to convert " + ((JavaElement) converter.cu).toStringWithAncestors()); */ } }
Example #5
Source File: CompilationUnitDeclaration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public CompilationUnitDeclaration(ProblemReporter problemReporter, CompilationResult compilationResult, int sourceLength) { this.problemReporter = problemReporter; this.compilationResult = compilationResult; //by definition of a compilation unit.... this.sourceStart = 0; this.sourceEnd = sourceLength - 1; }
Example #6
Source File: CodeSnippetParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new code snippet parser. */ public CodeSnippetParser(ProblemReporter problemReporter, EvaluationContext evaluationContext, boolean optimizeStringLiterals, int codeSnippetStart, int codeSnippetEnd) { super(problemReporter, optimizeStringLiterals); this.codeSnippetStart = codeSnippetStart; this.codeSnippetEnd = codeSnippetEnd; this.evaluationContext = evaluationContext; this.reportOnlyOneSyntaxError = true; this.javadocParser.checkDocComment = false; }
Example #7
Source File: CodeSnippetParsingUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Expression parseExpression(char[] source, int offset, int length, Map settings, boolean recordParsingInformation) { if (source == null) { throw new IllegalArgumentException(); } CompilerOptions compilerOptions = new CompilerOptions(settings); // in this case we don't want to ignore method bodies since we are parsing only an expression final ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory(Locale.getDefault())); CommentRecorderParser parser = new CommentRecorderParser(problemReporter, false); ICompilationUnit sourceUnit = new CompilationUnit( source, "", //$NON-NLS-1$ compilerOptions.defaultEncoding); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); CompilationUnitDeclaration unit = new CompilationUnitDeclaration(problemReporter, compilationResult, source.length); Expression result = parser.parseExpression(source, offset, length, unit, true /* record line separators */); if (recordParsingInformation) { this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, unit.comments); } return result; }
Example #8
Source File: Main.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @param problem * the given problem to log * @param unitSource * the given unit source */ private void logXmlProblem(CategorizedProblem problem, char[] unitSource) { final int sourceStart = problem.getSourceStart(); final int sourceEnd = problem.getSourceEnd(); final int id = problem.getID(); this.parameters.put(Logger.ID, getFieldName(id)); // ID as field name this.parameters.put(Logger.PROBLEM_ID, new Integer(id)); // ID as numeric value boolean isError = problem.isError(); int severity = isError ? ProblemSeverities.Error : ProblemSeverities.Warning; this.parameters.put(Logger.PROBLEM_SEVERITY, isError ? Logger.ERROR : Logger.WARNING); this.parameters.put(Logger.PROBLEM_LINE, new Integer(problem.getSourceLineNumber())); this.parameters.put(Logger.PROBLEM_SOURCE_START, new Integer(sourceStart)); this.parameters.put(Logger.PROBLEM_SOURCE_END, new Integer(sourceEnd)); String problemOptionKey = getProblemOptionKey(id); if (problemOptionKey != null) { this.parameters.put(Logger.PROBLEM_OPTION_KEY, problemOptionKey); } int categoryID = ProblemReporter.getProblemCategory(severity, id); this.parameters.put(Logger.PROBLEM_CATEGORY_ID, new Integer(categoryID)); printTag(Logger.PROBLEM_TAG, this.parameters, true, false); this.parameters.put(Logger.VALUE, problem.getMessage()); printTag(Logger.PROBLEM_MESSAGE, this.parameters, true, true); extractContext(problem, unitSource); String[] arguments = problem.getArguments(); final int length = arguments.length; if (length != 0) { printTag(Logger.PROBLEM_ARGUMENTS, null, true, false); for (int i = 0; i < length; i++) { this.parameters.put(Logger.PROBLEM_ARGUMENT_VALUE, arguments[i]); printTag(Logger.PROBLEM_ARGUMENT, this.parameters, true, true); } endTag(Logger.PROBLEM_ARGUMENTS); } endTag(Logger.PROBLEM_TAG); }
Example #9
Source File: CodeSnippetParsingUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public ASTNode[] parseClassBodyDeclarations( char[] source, int offset, int length, Map settings, boolean recordParsingInformation, boolean enabledStatementRecovery) { if (source == null) { throw new IllegalArgumentException(); } CompilerOptions compilerOptions = new CompilerOptions(settings); compilerOptions.ignoreMethodBodies = this.ignoreMethodBodies; final ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory(Locale.getDefault())); CommentRecorderParser parser = new CommentRecorderParser(problemReporter, false); parser.setMethodsFullRecovery(false); parser.setStatementsRecovery(enabledStatementRecovery); ICompilationUnit sourceUnit = new CompilationUnit( source, "", //$NON-NLS-1$ compilerOptions.defaultEncoding); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); final CompilationUnitDeclaration compilationUnitDeclaration = new CompilationUnitDeclaration(problemReporter, compilationResult, source.length); ASTNode[] result = parser.parseClassBodyDeclarations(source, offset, length, compilationUnitDeclaration); if (recordParsingInformation) { this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, compilationUnitDeclaration.comments); } return result; }
Example #10
Source File: HierarchyResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, HierarchyBuilder builder, IProblemFactory problemFactory) { // create a problem handler with the 'exit after all problems' handling policy this.options = new CompilerOptions(settings); IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems(); ProblemReporter problemReporter = new ProblemReporter(policy, this.options, problemFactory); LookupEnvironment environment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment); environment.mayTolerateMissingType = true; setEnvironment(environment, builder); }
Example #11
Source File: BasicSearchEngine.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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); } return this.parser; }
Example #12
Source File: MatchLocatorParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
protected MatchLocatorParser(ProblemReporter problemReporter, MatchLocator locator) { super(problemReporter, true); this.reportOnlyOneSyntaxError = true; this.patternLocator = locator.patternLocator; if ((locator.matchContainer & PatternLocator.CLASS_CONTAINER) != 0) { this.localDeclarationVisitor = (locator.matchContainer & PatternLocator.METHOD_CONTAINER) != 0 ? new ClassAndMethodDeclarationVisitor() : new ClassButNoMethodDeclarationVisitor(); } else { this.localDeclarationVisitor = (locator.matchContainer & PatternLocator.METHOD_CONTAINER) != 0 ? new MethodButNoClassDeclarationVisitor() : new NoClassNoMethodDeclarationVisitor(); } this.patternFineGrain = this.patternLocator.fineGrain(); }
Example #13
Source File: SourceIndexer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resolveDocument() { try { IPath path = new Path(this.document.getPath()); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); JavaProject javaProject = (JavaProject) model.getJavaProject(project); this.options = new CompilerOptions(javaProject.getOptions(true)); ProblemReporter problemReporter = new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.options, new DefaultProblemFactory()); // Re-parse using normal parser, IndexingParser swallows several nodes, see comment above class. this.basicParser = new Parser(problemReporter, false); this.basicParser.reportOnlyOneSyntaxError = true; this.basicParser.scanner.taskTags = null; this.cud = this.basicParser.parse(this.compilationUnit, new CompilationResult(this.compilationUnit, 0, 0, this.options.maxProblemsPerUnit)); // Use a non model name environment to avoid locks, monitors and such. INameEnvironment nameEnvironment = new JavaSearchNameEnvironment(javaProject, JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, true/*add primary WCs*/)); this.lookupEnvironment = new LookupEnvironment(this, this.options, problemReporter, nameEnvironment); reduceParseTree(this.cud); this.lookupEnvironment.buildTypeBindings(this.cud, null); this.lookupEnvironment.completeTypeBindings(); this.cud.scope.faultInTypes(); this.cud.resolve(); } catch (Exception e) { if (JobManager.VERBOSE) { e.printStackTrace(); } } }
Example #14
Source File: AssistParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public AssistParser(ProblemReporter problemReporter) { super(problemReporter, true); this.javadocParser.checkDocComment = false; setMethodsFullRecovery(false); setStatementsRecovery(false); }
Example #15
Source File: FakedTrackingVariable.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public int reportError(ProblemReporter problemReporter, ASTNode location, int nullStatus) { if ((this.globalClosingState & OWNED_BY_OUTSIDE) != 0) { return 0; // TODO: should we still propagate some flags?? } // which degree of problem? boolean isPotentialProblem = false; if (nullStatus == FlowInfo.NULL) { if ((this.globalClosingState & CLOSED_IN_NESTED_METHOD) != 0) isPotentialProblem = true; } else if ((nullStatus & (FlowInfo.POTENTIALLY_NULL|FlowInfo.POTENTIALLY_NON_NULL)) != 0) { isPotentialProblem = true; } // report: if (isPotentialProblem) { if ((this.globalClosingState & (REPORTED_POTENTIAL_LEAK|REPORTED_DEFINITIVE_LEAK)) != 0) return 0; problemReporter.potentiallyUnclosedCloseable(this, location); } else { if ((this.globalClosingState & (REPORTED_DEFINITIVE_LEAK)) != 0) return 0; problemReporter.unclosedCloseable(this, location); } // propagate flag to inners: int reportFlag = isPotentialProblem ? REPORTED_POTENTIAL_LEAK : REPORTED_DEFINITIVE_LEAK; if (location == null) { // if location != null flags will be set after the loop over locations FakedTrackingVariable current = this; do { current.globalClosingState |= reportFlag; } while ((current = current.innerTracker) != null); } return reportFlag; }
Example #16
Source File: PatchExtensionMethod.java From EasyMPermission with MIT License | 5 votes |
private static Method getMethod(String name, Class<?>... types) { try { Method m = ProblemReporter.class.getMethod(name, types); m.setAccessible(true); return m; } catch (Exception e) { return null; } }
Example #17
Source File: CompilationUtils.java From steady with Apache License 2.0 | 5 votes |
/** * Create a CommentRecorderParser * @param options - compiler options * @return */ private static Parser createCommentRecorderParser(CompilerOptions options) { Parser parser = new CommentRecorderParser(new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), options, new DefaultProblemFactory()), false); return parser; }
Example #18
Source File: PatchFixesHider.java From EasyMPermission with MIT License | 4 votes |
public static void errorNoMethodFor(ProblemReporter problemReporter, MessageSend messageSend, TypeBinding recType, TypeBinding[] params) { Util.invokeMethod(ERROR_NO_METHOD_FOR, problemReporter, messageSend, recType, params); }
Example #19
Source File: PatchExtensionMethod.java From EasyMPermission with MIT License | 4 votes |
PostponedNoMethodError(ProblemReporter problemReporter, MessageSend messageSend, TypeBinding recType, TypeBinding[] params) { this.problemReporter = problemReporter; this.messageSendRef = new WeakReference<MessageSend>(messageSend); this.recType = recType; this.params = params; }
Example #20
Source File: FakedTrackingVariable.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void reportExplicitClosing(ProblemReporter problemReporter) { if ((this.globalClosingState & (OWNED_BY_OUTSIDE|REPORTED_EXPLICIT_CLOSE)) == 0) { // can't use t-w-r for OWNED_BY_OUTSIDE this.globalClosingState |= REPORTED_EXPLICIT_CLOSE; problemReporter.explicitlyClosedAutoCloseable(this); } }
Example #21
Source File: MethodVerifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
ProblemReporter problemReporter() { return this.type.scope.problemReporter(); }
Example #22
Source File: DiagnoseParser.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private ProblemReporter problemReporter(){ return this.parser.problemReporter(); }
Example #23
Source File: MethodVerifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
ProblemReporter problemReporter(MethodBinding currentMethod) { ProblemReporter reporter = problemReporter(); if (TypeBinding.equalsEquals(currentMethod.declaringClass, this.type) && currentMethod.sourceMethod() != null) // only report against the currentMethod if its implemented by the type reporter.referenceContext = currentMethod.sourceMethod(); return reporter; }
Example #24
Source File: BlockScope.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public ProblemReporter problemReporter() { return methodScope().problemReporter(); }
Example #25
Source File: Main.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private String getProblemOptionKey(int problemID) { int irritant = ProblemReporter.getIrritant(problemID); return CompilerOptions.optionKeyFromIrritant(irritant); }
Example #26
Source File: CompilationUnitResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static CompilationUnitDeclaration parse( org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, NodeSearcher nodeSearcher, Map settings, int flags) { if (sourceUnit == null) { throw new IllegalStateException(); } CompilerOptions compilerOptions = new CompilerOptions(settings); boolean statementsRecovery = (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0; compilerOptions.performMethodsFullRecovery = statementsRecovery; compilerOptions.performStatementsRecovery = statementsRecovery; compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; Parser parser = new CommentRecorderParser( new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory()), false); CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); if (compilationUnitDeclaration.ignoreMethodBodies) { compilationUnitDeclaration.ignoreFurtherInvestigation = true; // if initial diet parse did not work, no need to dig into method bodies. return compilationUnitDeclaration; } if (nodeSearcher != null) { char[] source = parser.scanner.getSource(); int searchPosition = nodeSearcher.position; if (searchPosition < 0 || searchPosition > source.length) { // the position is out of range. There is no need to search for a node. return compilationUnitDeclaration; } compilationUnitDeclaration.traverse(nodeSearcher, compilationUnitDeclaration.scope); org.eclipse.jdt.internal.compiler.ast.ASTNode node = nodeSearcher.found; if (node == null) { return compilationUnitDeclaration; } org.eclipse.jdt.internal.compiler.ast.TypeDeclaration enclosingTypeDeclaration = nodeSearcher.enclosingType; if (node instanceof AbstractMethodDeclaration) { ((AbstractMethodDeclaration)node).parseStatements(parser, compilationUnitDeclaration); } else if (enclosingTypeDeclaration != null) { if (node instanceof org.eclipse.jdt.internal.compiler.ast.Initializer) { ((org.eclipse.jdt.internal.compiler.ast.Initializer) node).parseStatements(parser, enclosingTypeDeclaration, compilationUnitDeclaration); } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) { ((org.eclipse.jdt.internal.compiler.ast.TypeDeclaration)node).parseMethods(parser, compilationUnitDeclaration); } } } else { //fill the methods bodies in order for the code to be generated //real parse of the method.... org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; if (types != null) { for (int j = 0, typeLength = types.length; j < typeLength; j++) { types[j].parseMethods(parser, compilationUnitDeclaration); } } } return compilationUnitDeclaration; }
Example #27
Source File: CompilationUnitResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static void parse( String[] sourceUnits, String[] encodings, FileASTRequestor astRequestor, int apiLevel, Map options, int flags, IProgressMonitor monitor) { try { CompilerOptions compilerOptions = new CompilerOptions(options); compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; Parser parser = new CommentRecorderParser( new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory()), false); int unitLength = sourceUnits.length; if (monitor != null) monitor.beginTask("", unitLength); //$NON-NLS-1$ for (int i = 0; i < unitLength; i++) { char[] contents = null; String encoding = encodings != null ? encodings[i] : null; try { contents = Util.getFileCharContent(new File(sourceUnits[i]), encoding); } catch(IOException e) { // go to the next unit continue; } if (contents == null) { // go to the next unit continue; } org.eclipse.jdt.internal.compiler.batch.CompilationUnit compilationUnit = new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(contents, sourceUnits[i], encoding); org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = compilationUnit; CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); if (compilationUnitDeclaration.ignoreMethodBodies) { compilationUnitDeclaration.ignoreFurtherInvestigation = true; // if initial diet parse did not work, no need to dig into method bodies. continue; } //fill the methods bodies in order for the code to be generated //real parse of the method.... org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; if (types != null) { for (int j = 0, typeLength = types.length; j < typeLength; j++) { types[j].parseMethods(parser, compilationUnitDeclaration); } } // convert AST CompilationUnit node = convert(compilationUnitDeclaration, parser.scanner.getSource(), apiLevel, options, false/*don't resolve binding*/, null/*no owner needed*/, null/*no binding table needed*/, flags /* flags */, monitor, true); node.setTypeRoot(null); // accept AST astRequestor.acceptAST(sourceUnits[i], node); if (monitor != null) monitor.worked(1); } } finally { if (monitor != null) monitor.done(); } }
Example #28
Source File: CompilationUnitResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static void parse(ICompilationUnit[] compilationUnits, ASTRequestor astRequestor, int apiLevel, Map options, int flags, IProgressMonitor monitor) { try { CompilerOptions compilerOptions = new CompilerOptions(options); compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; Parser parser = new CommentRecorderParser( new ProblemReporter( DefaultErrorHandlingPolicies.proceedWithAllProblems(), compilerOptions, new DefaultProblemFactory()), false); int unitLength = compilationUnits.length; if (monitor != null) monitor.beginTask("", unitLength); //$NON-NLS-1$ for (int i = 0; i < unitLength; i++) { org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnits[i]; CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); CompilationUnitDeclaration compilationUnitDeclaration = parser.dietParse(sourceUnit, compilationResult); if (compilationUnitDeclaration.ignoreMethodBodies) { compilationUnitDeclaration.ignoreFurtherInvestigation = true; // if initial diet parse did not work, no need to dig into method bodies. continue; } //fill the methods bodies in order for the code to be generated //real parse of the method.... org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types; if (types != null) { for (int j = 0, typeLength = types.length; j < typeLength; j++) { types[j].parseMethods(parser, compilationUnitDeclaration); } } // convert AST CompilationUnit node = convert(compilationUnitDeclaration, parser.scanner.getSource(), apiLevel, options, false/*don't resolve binding*/, null/*no owner needed*/, null/*no binding table needed*/, flags /* flags */, monitor, true); node.setTypeRoot(compilationUnits[i]); // accept AST astRequestor.acceptAST(compilationUnits[i], node); if (monitor != null) monitor.worked(1); } } finally { if (monitor != null) monitor.done(); } }
Example #29
Source File: PatchFixesHider.java From EasyMPermission with MIT License | 4 votes |
public static void invalidMethod(ProblemReporter problemReporter, MessageSend messageSend, MethodBinding method) { Util.invokeMethod(INVALID_METHOD, problemReporter, messageSend, method); }
Example #30
Source File: SourceTypeConverter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private SourceTypeConverter(int flags, ProblemReporter problemReporter) { super(problemReporter, Signature.C_DOT); this.flags = flags; }