List of usage examples for org.eclipse.jdt.core.compiler ReconcileContext isResolvingBindings
public boolean isResolvingBindings()
From source file:org.springframework.ide.eclipse.quickfix.jdt.AnnotationCompilationParticipant.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// w w w . j a v a2s . c o m public void reconcile(ReconcileContext context) { if (context.getDelta() == null) { return; } CompilationUnit cuAST = context.getDelta().getCompilationUnitAST(); ICompilationUnit cu = context.getWorkingCopy(); IFile file = (IFile) cu.getResource(); List<MissingPathVariableWarning> problems = new ArrayList<MissingPathVariableWarning>(); if (cuAST != null) { List<AbstractTypeDeclaration> typeDecls = cuAST.types(); for (AbstractTypeDeclaration typeDecl : typeDecls) { List<BodyDeclaration> bodyDecls = typeDecl.bodyDeclarations(); for (BodyDeclaration bodyDecl : bodyDecls) { if (bodyDecl instanceof MethodDeclaration) { MethodDeclaration methodDecl = (MethodDeclaration) bodyDecl; List<String> currentPathVariables = findPathVariables(methodDecl); Set<Annotation> annotations = ProposalCalculatorUtil.findAnnotations("RequestMapping", methodDecl); for (Annotation annotation : annotations) { List<UriTemplateVariable> variables = ProposalCalculatorUtil .getUriTemplatVariables(annotation); for (UriTemplateVariable variable : variables) { boolean found = false; for (String currentPathVariable : currentPathVariables) { if (Pattern.matches(variable.getVariableName(), currentPathVariable)) { found = true; break; } } if (!found) { problems.add(new MissingPathVariableWarning(annotation, variable, file, cuAST.getLineNumber(variable.getOffset()))); } } } } } List<String> pathVariables; if (context.isResolvingBindings()) { pathVariables = new ArrayList<String>(); ITypeBinding typeBinding = typeDecl.resolveBinding(); while (typeBinding != null && !typeDecl.getAST().resolveWellKnownType("java.lang.Object").equals(typeBinding)) { pathVariables.addAll(findPathVariables(typeBinding)); typeBinding = typeBinding.getSuperclass(); } } else { pathVariables = findPathVariables(typeDecl); } Set<Annotation> annotations = ProposalCalculatorUtil.findAnnotations("RequestMapping", typeDecl); for (Annotation annotation : annotations) { List<UriTemplateVariable> variables = ProposalCalculatorUtil.getUriTemplatVariables(annotation); for (UriTemplateVariable variable : variables) { if (!pathVariables.contains(variable.getVariableName())) { problems.add(new MissingPathVariableWarning(annotation, variable, file, cuAST.getLineNumber(variable.getOffset()))); } } } } } context.putProblems(MissingPathVariableWarning.MARKER_TYPE, problems.toArray(new CategorizedProblem[problems.size()])); }