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

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

Introduction

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

Prototype

public String getKey();

Source Link

Document

Returns the key for this binding.

Usage

From source file:byke.DependencyAnalysis.java

License:Open Source License

@Override
public Node<IBinding> produceNode(IBinding binding, JavaType kind) {
    String key = binding.getKey();
    return produceNode(key, binding, kind);
}

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

License:Open Source License

public void setViewerElement(Binding viewerElement) {
    if (fViewerElement == viewerElement)
        return;//from w w  w .  ja v  a  2 s.c o  m

    fViewerElement = viewerElement;
    fException = null;
    IBinding trayBinding = fParent.getBinding();
    StringBuffer buf = new StringBuffer(getName());
    if (viewerElement != null) {
        IBinding viewerBinding = viewerElement.getBinding();
        try {
            String queryResult = executeQuery(viewerBinding, trayBinding);
            buf.append(queryResult);
        } catch (RuntimeException e) {
            fException = e;
            buf.append(e.getClass().getName());
            buf.append(" for \""); //$NON-NLS-1$
            if (viewerBinding == null)
                buf.append("null"); //$NON-NLS-1$
            else
                buf.append('"').append(viewerBinding.getKey());
            buf.append("\" and "); //$NON-NLS-1$
            buf.append(trayBinding.getKey()).append('"');
        }
    } else {
        buf.append(N_A);
    }
    fLabel = buf.toString();
}

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);
        }//  www . jav a  2  s .  c o  m

        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:com.architexa.diagrams.jdt.builder.ReloASTExtractor.java

License:Open Source License

private static final String getNodeKey(ASTNode node) {
    try {/*  w w  w  .  j  ava2 s  .  com*/
        Method m = node.getClass().getMethod("resolveBinding");
        if (m != null) {
            IBinding nodeBinding = (IBinding) m.invoke(node);
            if (nodeBinding != null)
                return nodeBinding.getKey();
        }
    } catch (Throwable t) {
    }
    return "";
}

From source file:com.google.dart.java2dart.util.JavaUtils.java

License:Open Source License

/**
 * @return the JDT method or field signature without return type.
 *///from w w  w  . ja v  a 2 s .c om
public static String getJdtSignature(IBinding binding) {
    if (binding != null) {
        String signature = binding.getKey();
        return JavaUtils.getJdtSignature(signature);
    }
    return null;
}

From source file:com.halware.nakedide.eclipse.ext.annot.utils.AstUtils.java

License:Open Source License

/**
* Finds the declaration node within the supplied {@link CompilationUnit}, 
* using a stale declaration (from an earlier AST) as the search.
* 
* @param compilationUnit//  w  w  w .  ja va  2  s. com
* @param searchDeclaration - the declaration from an earlier AST.
* @return
*/
public static <T extends ASTNode> T findDeclaration(CompilationUnit compilationUnit, T searchDeclaration) {
    if (searchDeclaration == null) {
        return null;
    }

    // no need to do a search if this is the same AST.
    if (compilationUnit.getAST() == searchDeclaration.getAST()) {
        return searchDeclaration;
    }

    IBinding binding = null;
    if (searchDeclaration instanceof MethodDeclaration) {
        binding = ((MethodDeclaration) searchDeclaration).resolveBinding();
    }
    if (searchDeclaration instanceof TypeDeclaration) {
        binding = ((TypeDeclaration) searchDeclaration).resolveBinding();
    }
    if (searchDeclaration instanceof SingleVariableDeclaration) {
        binding = ((SingleVariableDeclaration) searchDeclaration).resolveBinding();
    }

    return Generics.asT(binding != null ? findDeclaration(compilationUnit, binding.getKey()) : null);
}

From source file:de.ovgu.cide.mining.database.model.AFlyweightElementFactory.java

License:Open Source License

public AElement getElement(IBinding binding) {
    return (AElement) javaElements.get(binding.getKey());
}

From source file:de.ovgu.cide.mining.database.model.AFlyweightElementFactory.java

License:Open Source License

/**
 * Returns a flyweight object representing a program element.
 * /*from  w  w  w  .j av a 2 s. c o  m*/
 * @param pCategory
 *            The category of element. Must be a value declared in
 *            ICategories.
 * @param pId
 *            The id for the element. For example, a field Id for
 *            ICategories.FIELD.
 * @see <a
 *      href="http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.1">
 *      Java Specification, Third Section, 13.1 Section for the binary name
 *      convention</a>
 * @return A flyweight IElement.
 * @exception AInternalProblemException
 *                if an invalid category is passed as parameter.
 */
// public AIElement createNonBindingElement( AICategories pCategory, int
// compUnitHash, ASTNode node) {
// return createBindingElement(pCategory, null, compUnitHash, node);
// }

public AElement createElement(AICategories pCategory, IBinding binding, int compUnitHash, ASTNode node) {
    AElement lReturn = null;
    String bindingKey = null;
    String nodeId = null;

    if (binding != null) {
        bindingKey = binding.getKey();
        lReturn = (AElement) javaElements.get(bindingKey);
        if (lReturn != null) {
            if (!lReturn.getCategory().equals(pCategory)) {
                lReturn.addSubcategory(pCategory);
            }
            return lReturn;
        }

    }

    UnifiedASTNode uniNode = (UnifiedASTNode) bridge(node);
    nodeId = uniNode.getId();
    lReturn = (AElement) javaElements.get(nodeId);
    if (lReturn != null) {
        if (!lReturn.getCategory().equals(pCategory)) {
            lReturn.addSubcategory(pCategory);
        }
        return lReturn;
    }

    lReturn = new AElement(uniNode, compUnitHash, pCategory);

    if (bindingKey != null)
        javaElements.put(bindingKey, lReturn);
    else
        javaElements.put(nodeId, lReturn);

    return lReturn;
}

From source file:de.ovgu.cide.typing.jdt.checks.resolutions.ASTBindingFinder.java

License:Open Source License

public boolean visit(TypeDeclaration node) {
    if (result != null)
        return false;
    IBinding binding = node.resolveBinding();
    if (binding != null && binding.getKey().equals(target))
        result = node;//from  w  ww .j av a2 s .  co  m
    return super.visit(node);
}

From source file:de.ovgu.cide.typing.jdt.checks.resolutions.ASTBindingFinder.java

License:Open Source License

public boolean visit(MethodDeclaration node) {
    if (result != null)
        return false;
    IBinding binding = node.resolveBinding();
    if (binding != null && binding.getKey().equals(target))
        result = node;/* w  ww . ja  va 2s.  com*/
    return super.visit(node);
}