Example usage for org.eclipse.jdt.core.compiler ReconcileContext getDelta

List of usage examples for org.eclipse.jdt.core.compiler ReconcileContext getDelta

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler ReconcileContext getDelta.

Prototype

public IJavaElementDelta getDelta() 

Source Link

Document

Returns the delta describing the change to the working copy being reconciled.

Usage

From source file:at.bestsolution.efxclipse.tooling.model.internal.ModelUpdater.java

License:Open Source License

@Override
public void reconcile(ReconcileContext context) {
    IJavaElementDelta delta = context.getDelta();
    if (delta != null) {
        if (delta.getElement() instanceof ICompilationUnit) {

            ICompilationUnit u = (ICompilationUnit) delta.getElement();
            try {
                for (IType t : u.getTypes()) {
                    FXPlugin.getClassmodel().clearCache(t);
                }//from  w w  w  .j  ava 2 s .  c o  m
            } catch (JavaModelException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    super.reconcile(context);
}

From source file:org.springframework.ide.eclipse.quickfix.jdt.AnnotationCompilationParticipant.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/* ww w  .  java  2s  . 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()]));
}