Example usage for org.eclipse.jdt.core.dom SuperConstructorInvocation resolveConstructorBinding

List of usage examples for org.eclipse.jdt.core.dom SuperConstructorInvocation resolveConstructorBinding

Introduction

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

Prototype

public IMethodBinding resolveConstructorBinding() 

Source Link

Document

Resolves and returns the binding for the constructor invoked by this expression.

Usage

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final SuperConstructorInvocation pNode) {
    final Object obj = pNode.resolveConstructorBinding();
    if (obj == null) {
        System.out.println("uh oh");
        return true;
    }/*  w  w w.  j av  a 2  s.c o  m*/
    this.addCallRelation(pNode, pNode.resolveConstructorBinding(), true);
    return true;
}

From source file:ca.uvic.chisel.javasketch.internal.ast.ASTMessageFinder.java

License:Open Source License

public boolean visit(SuperConstructorInvocation node) {
    if (!(message instanceof ICall))
        return false;
    if (containsMessage(node)) {
        ICall call = (ICall) message;/*from w  w  w .j  a v  a  2 s. c o  m*/
        IMethodBinding binding = node.resolveConstructorBinding();
        if (binding != null) {
            binding = binding.getMethodDeclaration();
            if (binding != null) {
                IJavaElement element = binding.getJavaElement();
                if (element instanceof IMethod) {
                    try {
                        IMethod jm = (IMethod) element;
                        //get the target method.
                        ITraceClassMethod am = call.getTarget().getActivation().getMethod();
                        if (JavaSearchUtils.getFullyQualifiedName(jm.getDeclaringType(), true)
                                .equals(am.getTraceClass().getName())) {
                            String types[] = Signature.getParameterTypes(am.getSignature());
                            IMethod testMethod = jm.getDeclaringType().getMethod(am.getName(), types);
                            if (jm.isSimilar(testMethod)) {
                                this.node = node;
                                try {
                                    if (document
                                            .getLineOfOffset(node.getStartPosition()) != (call.codeLine() - 1))
                                        //look for a better match.
                                        return true;
                                } catch (BadLocationException e) {
                                }
                                return false;
                            }
                        }
                    } catch (NullPointerException e) {
                        return false;
                    }
                }
            }
        }
        return true;
    }

    return false;
}

From source file:changetypes.ASTVisitorAtomicChange.java

License:Open Source License

public boolean visit(SuperConstructorInvocation node) {
    IMethodBinding mmtb = node.resolveConstructorBinding();
    if (this.mtbStack.isEmpty()) {
        return true;
    }/*from w w  w.  j a  v  a  2s .  c  o  m*/
    try {
        this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding) this.mtbStack.peek()),
                getQualifiedName(mmtb)));
    } catch (Exception localException) {
        System.err.println("Cannot resolve super constructor invocation in \"\"");
    }
    return true;
}

From source file:com.google.devtools.j2cpp.types.BindingMapBuilder.java

License:Open Source License

@Override
public boolean visit(SuperConstructorInvocation node) {
    put(node, node.resolveConstructorBinding());
    return true;
}

From source file:com.ibm.wala.cast.java.translator.jdt.JDTJava2CAstTranslator.java

License:Open Source License

private CAstNode visit(SuperConstructorInvocation n, WalkContext context) {
    // FIXME: use expression?! polyglot doesn't handle it and it seems to be a very rare case.
    // class E { class X {} }
    // class Y extends E.X { Y(E e) { e.super(); } }
    // GENERICS getMethodDeclaration()
    return createConstructorInvocation(n.resolveConstructorBinding().getMethodDeclaration(), n.arguments(), n,
            context, true);//from  w w w  .ja va 2 s.  c o m
}

From source file:de.ovgu.cide.typing.jdt.JDTCheckGenerator.java

License:Open Source License

@Override
public boolean visit(SuperConstructorInvocation node) {
    IMethodBinding binding = node.resolveConstructorBinding();
    List args = node.arguments();
    handleMethodCall(node, binding, args);
    return super.visit(node);
}

From source file:edu.uci.ics.sourcerer.extractor.ast.ReferenceExtractorVisitor.java

License:Open Source License

/**
 * This method writes://  w w  w.  j av  a2 s  .c  om
 *<ul>
 *  <li>For superconstructor invocations (not instantiations):
 *  <ul>
 *    <li>Calls relation to <code>IRelationWriter</code>.</li>
 *  </ul></li>
 *</ul>
 */
@SuppressWarnings("unchecked")
@Override
public boolean visit(SuperConstructorInvocation node) {
    // Get the fqn
    String fqn = null;
    IMethodBinding binding = node.resolveConstructorBinding();
    if (binding == null) {
        fqn = getUnknownSuperFqn("<init>") + getFuzzyMethodArgs(node.arguments());
    } else {
        fqn = getMethodFqn(binding, false);
    }

    // Write the call relation
    relationWriter.writeCalls(fqnStack.getFqn(), fqn, getLocation(node));

    fqnStack.reportSuperInvocation();
    return true;
}

From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.ReferenceExtractorVisitor.java

License:Open Source License

/**
 * This method writes:/*from ww  w  .  j a  v  a  2  s. c  o  m*/
 *<ul>
 *  <li>For superconstructor invocations (not instantiations):
 *  <ul>
 *    <li>Calls relation to <code>IRelationWriter</code>.</li>
 *  </ul></li>
 *</ul>
 */
@Override
public boolean visit(SuperConstructorInvocation node) {
    // Get the fqn
    String fqn = null;
    IMethodBinding binding = node.resolveConstructorBinding();
    if (binding == null) {
        fqn = createUnknownSuperFqn("<init>") + getFuzzyMethodArgs(node.arguments());
    } else {
        fqn = getMethodName(binding, false) + getMethodArgs(binding);
    }

    // Write the call relation
    relationWriter.writeRelation(Relation.CALLS, fqnStack.getFqn(), fqn, createLocation(node));

    fqnStack.peek(EnclosingConstructor.class).reportSuperInvocation();
    return true;
}

From source file:fr.labri.harmony.rta.junit.jdt.JDTVisitorRTA.java

License:Open Source License

public boolean visit(SuperConstructorInvocation ci) {
    IMethodBinding mb = ci.resolveConstructorBinding();
    if (currentJavaMethod != null && mb != null) {
        superInvocation = true;/*from w w  w.j a va2s .c  o m*/
        String signature = getShortDeclaration(mb);
        String type = getStaticType(mb);

        String isIntern = "false";
        if (Modifier.isStatic(mb.getModifiers()) || Modifier.isPrivate(mb.getModifiers())
                || Modifier.isFinal(mb.getModifiers()) || mb.isConstructor())
            isIntern = "true";
        //System.err.println("Add "+type+"::"+signature+"::"+isIntern);
        if (!currentJavaMethod.getCallsSite().contains(type + "::" + signature + "::" + isIntern))
            currentJavaMethod.getCallsSite().add(type + "::" + signature + "::" + isIntern);
        if (!classCreated.contains(mb.getDeclaringClass().getQualifiedName()))
            ;
        classCreated.add(mb.getDeclaringClass().getQualifiedName());
    }

    return true;
}

From source file:java5totext.input.binding.JDTDelegateBindingFactory.java

License:Open Source License

public Binding getBindingForSuperConstructorInvocation(SuperConstructorInvocation constructorCall) {
    Binding result = null;/*from   ww w  .  j a  v  a2 s.com*/
    IMethodBinding binding = constructorCall.resolveConstructorBinding();
    if (binding == null) {
        System.out.println("*** WARNING : binding '" + constructorCall.toString() + "' unresolved.");
        result = new UnresolvedBinding(constructorCall.toString());
    } else {
        result = this.getMethodBinding(binding);
    }
    return result;
}