Example usage for org.eclipse.jdt.core.dom IBinding isEqualTo

List of usage examples for org.eclipse.jdt.core.dom IBinding isEqualTo

Introduction

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

Prototype

public boolean isEqualTo(IBinding binding);

Source Link

Document

Returns whether this binding has the same key as that of the given binding.

Usage

From source file:cideplus.ui.astview.TrayContentProvider.java

License:Open Source License

private void addBindingComparisons(ArrayList result, Binding trayElement) {
    class IsEqualToProperty extends DynamicBindingProperty {
        public IsEqualToProperty(Binding parent) {
            super(parent);
        }//  w  w w . jav  a  2s.c  om

        protected String getName() {
            return "*.isEqualTo(this): "; //$NON-NLS-1$
        }

        protected String executeQuery(IBinding viewerBinding, IBinding trayBinding) {
            if (viewerBinding != null)
                return Boolean.toString(viewerBinding.isEqualTo(trayBinding));
            else
                return "* is null"; //$NON-NLS-1$
        }
    }
    result.add(new IsEqualToProperty(trayElement));

    class KeysEqualProperty extends DynamicBindingProperty {
        public KeysEqualProperty(Binding parent) {
            super(parent);
        }

        protected String getName() {
            return "*.getKey().equals(this.getKey()): "; //$NON-NLS-1$
        }

        protected String executeQuery(IBinding viewerBinding, IBinding trayBinding) {
            if (viewerBinding == null)
                return "* is null"; //$NON-NLS-1$
            else if (viewerBinding.getKey() == null)
                return "*.getKey() is null"; //$NON-NLS-1$
            else if (trayBinding.getKey() == null)
                return "this.getKey() is null"; //$NON-NLS-1$
            else
                return Boolean.toString(viewerBinding.getKey().equals(trayBinding.getKey()));
        }
    }
    result.add(new KeysEqualProperty(trayElement));
}

From source file:net.sf.j2s.core.astvisitors.Bindings.java

License:Open Source License

/**
 * Checks if the two bindings are equals. First an identity check is
 * made an then the key of the bindings are compared. 
 * @param b1 first binding treated as <code>this</code>. So it must
 *  not be <code>null</code>
 * @param b2 the second binding.//from w  w  w.ja  v  a 2 s. c  o m
 * @return boolean
 */
public static boolean equals(IBinding b1, IBinding b2) {
    boolean isEqualTo = b1.isEqualTo(b2);
    if (!isEqualTo && b1 instanceof ITypeBinding && b2 instanceof ITypeBinding) {
        ITypeBinding bb1 = (ITypeBinding) b1;
        ITypeBinding bb2 = (ITypeBinding) b2;
        String bb1Name = bb1.getBinaryName();
        if (bb1Name != null) {
            isEqualTo = bb1Name.equals(bb2.getBinaryName());
        }
    }
    if (CHECK_CORE_BINDING_IS_EQUAL_TO) {
        boolean originalEquals = originalEquals(b1, b2);
        if (originalEquals != isEqualTo) {
            //String message= "Unexpected difference between Bindings.equals(..) and IBinding#isEqualTo(..)"; //$NON-NLS-1$
            String detail = "\nb1 == " + b1.getKey() + ",\nb2 == " //$NON-NLS-1$//$NON-NLS-2$
                    + (b2 == null ? "null binding" : b2.getKey()); //$NON-NLS-1$
            try {
                detail += "\nb1.getJavaElement() == " + b1.getJavaElement() + ",\nb2.getJavaElement() == " //$NON-NLS-1$//$NON-NLS-2$
                        + (b2 == null ? "null binding" : b2.getJavaElement().toString()); //$NON-NLS-1$
            } catch (Exception e) {
                detail += "\nException in getJavaElement():\n" + e; //$NON-NLS-1$
            }
            //JavaPlugin.logRepeatedMessage(message, detail);
        }
    }
    return isEqualTo;
}

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

License:Open Source License

private static boolean areVariableBindingsEqual(ASTNode node1, ASTNode node2) {
    final IBinding b1 = varBinding(node1);
    final IBinding b2 = varBinding(node2);
    return b1 != null && b2 != null && b1.isEqualTo(b2);
}

From source file:org.incha.core.jswingripples.parser.BindingSupport.java

License:Open Source License

/**
 * Checks if the two bindings are equals. Also works across binding environments.
 * @param b1 first binding treated as <code>this. So it must
 *  not be <code>null//  w  w w  .j  a  va 2s .  co  m
 * @param b2 the second binding.
 * @return boolean
 */
public boolean equals(final IBinding b1, final IBinding b2) {
    return b1.isEqualTo(b2);
}