Example usage for org.eclipse.jdt.core.dom BodyDeclaration equals

List of usage examples for org.eclipse.jdt.core.dom BodyDeclaration equals

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom BodyDeclaration equals.

Prototype

@Override
public final boolean equals(Object obj) 

Source Link

Document

The ASTNode implementation of this Object method uses object identity (==).

Usage

From source file:org.autorefactor.refactoring.ASTHelper.java

License:Open Source License

private static BodyDeclaration getSibling(BodyDeclaration node, List<BodyDeclaration> bodyDeclarations,
        boolean lookForPrevious) {
    final TreeSet<BodyDeclaration> children = new TreeSet<BodyDeclaration>(new NodeStartPositionComparator());
    children.addAll(bodyDeclarations);//from ww w .  java 2s  .c  o m

    BodyDeclaration previous = null;
    boolean returnNext = false;
    for (BodyDeclaration child : children) {
        if (lookForPrevious) {
            if (child.equals(node)) {
                return previous;
            }
        } else {
            if (returnNext) {
                return child;
            }
        }
        previous = child;
        returnNext = child.equals(node);
    }
    return null;
}

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

License:Open Source License

/**
 * @param declToMatch/*from  w  w  w . j a  v a  2  s  .  c om*/
 * @param problemType
 * @param cu
 * @param typeNameToMatch problem marker should match this typeName, set to
 * Null if it should match any types
 * @return
 */
public static ValidationProblem findProblem(BodyDeclaration declToMatch, String problemType,
        ICompilationUnit cu, String typeNameToMatch) {
    IBeansModel model = BeansCorePlugin.getModel();
    IBeansProject springProject = model.getProject(cu.getJavaProject().getProject());
    Set<IBeansConfig> configs = springProject.getConfigs();
    for (IBeansConfig config : configs) {
        AutowireDependencyProvider provider = new AutowireDependencyProvider(config, config);
        provider.resolveAutowiredDependencies();
        List<ValidationProblem> problems = provider.getValidationProblems();
        for (ValidationProblem problem : problems) {
            ValidationProblemAttribute[] problemAttributes = problem.getAttributes();
            boolean matched = false;
            BodyDeclaration problemDecl = null;
            String typeName = null;

            for (ValidationProblemAttribute problemAttribute : problemAttributes) {

                if (AutowireDependencyProvider.AUTOWIRE_PROBLEM_TYPE.equals(problemAttribute.getKey())) {
                    if (problemType.equals(problemAttribute.getValue())) {
                        matched = true;
                    }
                } else if ("JAVA_HANDLE".equals(problemAttribute.getKey())) {
                    problemDecl = getBodyDeclaration(JavaCore.create((String) problemAttribute.getValue()));
                } else if (AutowireDependencyProvider.BEAN_TYPE.equals(problemAttribute.getKey())) {
                    typeName = (String) problemAttribute.getValue();
                }
            }

            if (matched && problemDecl != null && problemDecl.equals(declToMatch)) {
                if (typeNameToMatch == null || (typeName != null && typeName.equals(typeNameToMatch))) {
                    return problem;
                }
            }
        }
    }
    return null;
}