List of usage examples for org.eclipse.jdt.core ICompilationUnit ENABLE_BINDINGS_RECOVERY
int ENABLE_BINDINGS_RECOVERY
To view the source code for org.eclipse.jdt.core ICompilationUnit ENABLE_BINDINGS_RECOVERY.
Click Source Link
From source file:cideplus.ui.astview.ASTView.java
License:Open Source License
private CompilationUnit createAST(ITypeRoot input, int astLevel, int offset) throws JavaModelException, CoreException { long startTime; long endTime; CompilationUnit root;//from w w w . ja v a2 s.c om if ((getCurrentInputKind() == ASTInputKindAction.USE_RECONCILE)) { final IProblemRequestor problemRequestor = new IProblemRequestor() { //strange: don't get bindings when supplying null as problemRequestor public void acceptProblem(IProblem problem) { /*not interested*/} public void beginReporting() { /*not interested*/} public void endReporting() { /*not interested*/} public boolean isActive() { return true; } }; WorkingCopyOwner workingCopyOwner = new WorkingCopyOwner() { @Override public IProblemRequestor getProblemRequestor(ICompilationUnit workingCopy) { return problemRequestor; } }; ICompilationUnit wc = input.getWorkingCopy(workingCopyOwner, null); try { int reconcileFlags = ICompilationUnit.FORCE_PROBLEM_DETECTION; if (fStatementsRecovery) reconcileFlags |= ICompilationUnit.ENABLE_STATEMENTS_RECOVERY; if (fBindingsRecovery) reconcileFlags |= ICompilationUnit.ENABLE_BINDINGS_RECOVERY; if (fIgnoreMethodBodies) reconcileFlags |= ICompilationUnit.IGNORE_METHOD_BODIES; startTime = System.currentTimeMillis(); root = wc.reconcile(getCurrentASTLevel(), reconcileFlags, null, null); endTime = System.currentTimeMillis(); } finally { wc.discardWorkingCopy(); } } else if (input instanceof ICompilationUnit && (getCurrentInputKind() == ASTInputKindAction.USE_CACHE)) { ICompilationUnit cu = (ICompilationUnit) input; startTime = System.currentTimeMillis(); root = SharedASTProvider.getAST(cu, SharedASTProvider.WAIT_NO, null); endTime = System.currentTimeMillis(); } else { ASTParser parser = ASTParser.newParser(astLevel); parser.setResolveBindings(fCreateBindings); if (input instanceof ICompilationUnit) { parser.setSource((ICompilationUnit) input); } else { parser.setSource((IClassFile) input); } parser.setStatementsRecovery(fStatementsRecovery); parser.setBindingsRecovery(fBindingsRecovery); parser.setIgnoreMethodBodies(fIgnoreMethodBodies); if (getCurrentInputKind() == ASTInputKindAction.USE_FOCAL) { parser.setFocalPosition(offset); } startTime = System.currentTimeMillis(); root = (CompilationUnit) parser.createAST(null); endTime = System.currentTimeMillis(); } if (root != null) { updateContentDescription(input, root, endTime - startTime); } return root; }
From source file:org.eclipse.ajdt.core.tests.problemfinding.AbstractProblemFindingTests.java
License:Apache License
/** * @throws JavaModelException//from www . j av a2 s .c o m */ private void assertNoProblems(CompilationUnit unit) throws JavaModelException { HashMap<String, CategorizedProblem[]> problems = new HashMap<String, CategorizedProblem[]>(); AJCompilationUnitProblemFinder.processAJ( unit, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null); MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should not have any problems in " + unit + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 0, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.Bug273691Reconciling.java
License:Open Source License
private HashMap doFind(ICompilationUnit unit) throws JavaModelException { HashMap problems = new HashMap(); if (unit instanceof AJCompilationUnit) { AJCompilationUnitProblemFinder.processAJ((AJCompilationUnit) unit, AJWorkingCopyOwner.INSTANCE, problems, true,//from w w w . j ava 2 s. com ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null); } else { // Requires JDT Weaving CompilationUnitProblemFinder.process((CompilationUnit) unit, null, DefaultWorkingCopyOwner.PRIMARY, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null); } return problems; }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
/** * project should have no problems at first * @throws Exception//from w w w. j ava 2s .c om */ public void testNoProblemsMyAspect() throws Exception { HashMap problems = new HashMap(); AJCompilationUnitProblemFinder.processAJ( myAspectCU, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null); MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should not have any problems in " + myAspectCU + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 0, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
public void testNoProblemsOtherClass() throws Exception { HashMap problems = new HashMap(); AJCompilationUnitProblemFinder.processAJ( otherClassCU, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null);/*from www. jav a 2 s .c o m*/ MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should not have any problems in " + otherClassCU + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 0, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
public void testNoProblemsDemo() throws Exception { HashMap problems = new HashMap(); AJCompilationUnitProblemFinder.processAJ( demoCU, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null);/*from w w w . j av a 2s . c o m*/ MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should not have any problems in " + demoCU + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 0, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
public void testNoProblemsMyAspectCU() throws Exception { HashMap problems = new HashMap(); // these next two test super classes and interfaces AJCompilationUnitProblemFinder.processAJ( myAspectCU2, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null);// ww w .j a v a2 s . c o m MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should not have any problems in " + myAspectCU2 + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 0, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
public void testNoProblemsOtherClass2() throws Exception { HashMap problems = new HashMap(); AJCompilationUnitProblemFinder.processAJ(otherClassCU2, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null);//from www.j a va2 s . co m MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should not have any problems in " + otherClassCU2 + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 0, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
/** * project should have no problems at first * @throws Exception/*from ww w. j a va2 s.c o m*/ */ public void testSyntaxError() throws Exception { otherClassCU.getBuffer().setContents(otherClassCU.getBuffer().getContents() + "gggg"); //$NON-NLS-1$ joinBackgroudActivities(); HashMap problems = new HashMap(); AJCompilationUnitProblemFinder.processAJ( otherClassCU, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null); MockProblemRequestor.filterAllWarningProblems(problems); assertEquals("Should have 1 syntax error in " + otherClassCU + " but found:\n" //$NON-NLS-1$ + MockProblemRequestor.printProblems(problems), 1, problems.size()); }
From source file:org.eclipse.ajdt.core.tests.problemfinding.ProblemFinderTests.java
License:Open Source License
public void testNoReturnTypeError() throws Exception { String contents = otherClassCU.getBuffer().getContents(); try {//from w w w . j ava 2s .c o m otherClassCU.getBuffer().setContents(contents.substring(0, contents.length() - 2) + "t() { } }\n"); //$NON-NLS-1$ joinBackgroudActivities(); HashMap problems = new HashMap(); AJCompilationUnitProblemFinder.processAJ(otherClassCU, AJWorkingCopyOwner.INSTANCE, problems, true, ICompilationUnit.ENABLE_BINDINGS_RECOVERY | ICompilationUnit.ENABLE_STATEMENTS_RECOVERY | ICompilationUnit.FORCE_PROBLEM_DETECTION, null); assertEquals("Should have one syntax error.", 1, MockProblemRequestor.filterProblems(problems).size()); //$NON-NLS-1$ CategorizedProblem prob = ((CategorizedProblem[]) problems.values().iterator().next())[0]; assertEquals("Return type for the method is missing", prob.getMessage()); //$NON-NLS-1$ } finally { // reset contents otherClassCU.getBuffer().setContents(contents); } }