List of usage examples for org.eclipse.jdt.core.compiler ReconcileContext getAST3
public org.eclipse.jdt.core.dom.CompilationUnit getAST3() throws JavaModelException
From source file:com.google.appengine.eclipse.core.validators.java.JavaCompilationParticipant.java
License:Open Source License
@Override public void reconcile(ReconcileContext context) { ICompilationUnit cu = context.getWorkingCopy(); try {//from w ww. j a va 2s .co m CompilationUnit ast = null; try { ast = context.getAST3(); } catch (JavaModelException e) { // Fall through to null check below } if (ast == null) { AppEngineCorePluginLog.logError("Could not get AST for " + cu.getPath()); return; } // Add existing Java problems to the list of all problems ArrayList<CategorizedProblem> finalProblemSet = new ArrayList<CategorizedProblem>(); CategorizedProblem[] currentProblems = context.getProblems(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); if (currentProblems != null) { finalProblemSet.addAll(Arrays.asList(currentProblems)); } // Find and add GAE-specific problems List<? extends CategorizedProblem> newProblems = validateCompilationUnit(ast); finalProblemSet.addAll(newProblems); context.putProblems(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, finalProblemSet.isEmpty() ? null : finalProblemSet.toArray(EMPTY_PROBLEMS)); } catch (OperationCanceledException e) { // Thrown by Eclipse to abort long-running processes throw e; } catch (Exception e) { // Don't want to allow any unexpected exceptions to escape AppEngineCorePluginLog.logError(e, "Unexpected error while validating {0}", cu.getElementName()); } }
From source file:com.google.gdt.eclipse.appengine.rpc.validators.JavaCompilationParticipant.java
License:Open Source License
@Override public void reconcile(ReconcileContext context) { ICompilationUnit cu = context.getWorkingCopy(); IType requestContext = null;//from w w w . j a v a2 s .c o m try { if (!cu.isConsistent()) { cu.reconcile(AST.JLS3, true, null, null); assert (cu.isConsistent()); } // find the requestfactory classes, once per project if (javaProject == null || javaProject.getProject() != cu.getJavaProject().getProject()) { javaProject = cu.getJavaProject(); projectEntities.clear(); proxies.clear(); requestMap.clear(); RequestFactoryUtils.findAllTypes(javaProject, projectEntities, proxies, requestMap); } if (cu.findPrimaryType() == null) { return; } if (cuName == null || !cuName.equals(cu.findPrimaryType().getFullyQualifiedName())) { cuName = cu.findPrimaryType().getFullyQualifiedName(); if (requestMap.containsKey(cuName)) { requestContext = requestMap.get(cuName); } else { requestContext = null; } // if there is no requestfactory implementation, no need to validate } if (requestContext != null) { CompilationUnit ast = context.getAST3(); ArrayList<CategorizedProblem> finalProblemSet = new ArrayList<CategorizedProblem>(); CategorizedProblem[] currentProblems = context.getProblems(GWTJavaProblem.MARKER_ID); if (currentProblems != null) { finalProblemSet.addAll(Arrays.asList(currentProblems)); } RequestFactoryValidator validator = new RequestFactoryValidator(requestContext, projectEntities, proxies); List<CategorizedProblem> reqFactoryProblems = validator.validate(ast); finalProblemSet.addAll(reqFactoryProblems); context.putProblems(GWTJavaProblem.MARKER_ID, (finalProblemSet.size() > 0 ? finalProblemSet.toArray(EMPTY_PROBLEMS) : null)); } } catch (JavaModelException e) { AppEngineRPCPlugin.log(e); } }
From source file:jmockit.assist.JMockitCompilationParticipant.java
License:Open Source License
@Override public void reconcile(final ReconcileContext context) { if (getCheckScope() == CheckScope.Disabled) { return;//from w w w . java2s. com } try { ICompilationUnit cunit = context.getWorkingCopy(); if (cunit.isStructureKnown()) { MockASTVisitor visitor = new MockASTVisitor(cunit); context.getAST3().accept(visitor); CategorizedProblem[] probs = visitor.getProblems(); if (probs.length != 0) { context.putProblems(probs[0].getMarkerType(), probs); } } } catch (JavaModelException e) { Activator.log(e); } }
From source file:org.springframework.ide.eclipse.data.jdt.core.SpringDataCompilationParticipant.java
License:Open Source License
@Override public void reconcile(ReconcileContext context) { try {//from w w w . j a v a 2 s .c om CompilationUnit compilationUnit = context.getAST3(); ITypeRoot typeRoot = compilationUnit.getTypeRoot(); IType type = typeRoot.findPrimaryType(); // Skip non-interfaces if (type == null || !type.isInterface() || type.isAnnotation()) { super.reconcile(context); return; } // Skip non-spring-data repositories if (!RepositoryInformation.isSpringDataRepository(type)) { super.reconcile(context); return; } // resolve repository information and generate problem markers RepositoryInformation information = new RepositoryInformation(type); Class<?> domainClass = information.getManagedDomainClass(); if (domainClass == null) { super.reconcile(context); return; } List<CategorizedProblem> problems = new ArrayList<CategorizedProblem>(); for (IMethod method : information.getMethodsToValidate()) { String methodName = method.getElementName(); try { new PartTree(methodName, domainClass); } catch (PropertyReferenceException e) { problems.add(new InvalidDerivedQueryProblem(method, e.getMessage())); } } context.putProblems("org.eclipse.jdt.core.problem", problems.toArray(new CategorizedProblem[problems.size()])); } catch (JavaModelException e) { SpringCore.log(e); } catch (Exception e) { SpringCore.log(e); } catch (Error e) { SpringCore.log(e); } super.reconcile(context); }