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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom ConstructorInvocation 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 ConstructorInvocation pNode) {
    this.addCallRelation(pNode, pNode.resolveConstructorBinding(), true);
    return true;/*from w w  w . j ava  2s.c  o  m*/
}

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

License:Open Source License

@Override
public boolean visit(ConstructorInvocation node) {
    if (!(message instanceof ICall))
        return false;
    if (containsMessage(node)) {
        ICall call = (ICall) message;//from   ww  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(ConstructorInvocation node) {
    IMethodBinding mmtb = node.resolveConstructorBinding();
    if (this.mtbStack.isEmpty()) {
        return true;
    }/*from w  ww. ja v a  2  s. co  m*/
    try {
        this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding) this.mtbStack.peek()),
                getQualifiedName(mmtb)));
    } catch (Exception localException) {
        System.err.println("Cannot resolve constructor invocation in \"\"");
    }
    return true;
}

From source file:com.google.dart.java2dart.SyntaxTranslator.java

License:Open Source License

/**
 * We generate invocation of "impl" method instead of redirecting constructor invocation. The
 * reason is that in Java it is possible to have "redirecting constructor invocation" as first
 * statement of constructor and then any other statement. But in Dart redirection should be only
 * clause./*w ww .ja va2s. c  o m*/
 */
@Override
public boolean visit(org.eclipse.jdt.core.dom.ConstructorInvocation node) {
    IMethodBinding binding = node.resolveConstructorBinding();
    SimpleIdentifier nameNode = identifier("jtdTmp");
    context.getConstructorDescription(binding).implInvocations.add(nameNode);
    // invoke "impl"
    List<Expression> arguments = translateArguments(binding, node.arguments());
    MethodInvocation invocation = methodInvocation(nameNode, arguments);
    context.putNodeBinding(invocation, binding);
    return done(expressionStatement(invocation));
}

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

License:Open Source License

@Override
public boolean visit(ConstructorInvocation 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(ConstructorInvocation n, WalkContext context) {
    // GENERICS getMethodDeclaration()
    return createConstructorInvocation(n.resolveConstructorBinding().getMethodDeclaration(), n.arguments(), n,
            context, false);/*from ww  w .  j  av  a2s .com*/
}

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

License:Open Source License

@Override
public boolean visit(ConstructorInvocation 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:/*ww  w . j  a v  a  2  s. c o  m*/
 *<ul>
 *  <li>For constructor invocations (not instantiations):
 *  <ul>
 *    <li>Calls relation to <code>IRelationWriter</code>.</li>
 *  </ul></li>
 *</ul>
 */
@SuppressWarnings("unchecked")
@Override
public boolean visit(ConstructorInvocation node) {
    // Get the fqn
    String fqn = null;
    IMethodBinding binding = node.resolveConstructorBinding();
    if (binding == null) {
        fqn = fqnStack.getFqn() + ".<init>" + getFuzzyMethodArgs(node.arguments());
    } else {
        fqn = getMethodFqn(binding, false);
    }

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

    return true;
}

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

License:Open Source License

/**
 * This method writes://from www.ja va  2 s  .c  om
 *<ul>
 *  <li>For constructor invocations (not instantiations):
 *  <ul>
 *    <li>Calls relation to <code>IRelationWriter</code>.</li>
 *  </ul></li>
 *</ul>
 */
@Override
public boolean visit(ConstructorInvocation node) {
    // Get the fqn
    String fqn = null;
    IMethodBinding binding = node.resolveConstructorBinding();
    if (binding == null) {
        fqn = fqnStack.getFqn() + ".<init>" + getFuzzyMethodArgs(node.arguments());
    } else {
        fqn = getMethodName(binding, false) + getMethodArgs(binding);
    }

    // Write the calls 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(ConstructorInvocation ci) {
    IMethodBinding mb = ci.resolveConstructorBinding();

    if (currentJavaMethod != null && mb != null) {
        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);
    }/*from   w  w w. j a va 2  s .com*/

    return true;
}