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

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

Introduction

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

Prototype

ChildListPropertyDescriptor ARGUMENTS_PROPERTY

To view the source code for org.eclipse.jdt.core.dom ConstructorInvocation ARGUMENTS_PROPERTY.

Click Source Link

Document

The "arguments" structural property of this node type (element type: Expression ).

Usage

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

License:Open Source License

@Override
public boolean visit(org.eclipse.jdt.core.dom.SimpleName node) {
    IBinding binding = node.resolveBinding();
    SimpleIdentifier result = identifier(node.getIdentifier());
    putReference(binding, result);//from  w  w w.j  a  v  a  2 s  . c o m
    // may be statically imported field, generate PropertyAccess
    {
        org.eclipse.jdt.core.dom.StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
        if (binding instanceof IVariableBinding) {
            org.eclipse.jdt.core.dom.IVariableBinding variableBinding = (org.eclipse.jdt.core.dom.IVariableBinding) binding;
            org.eclipse.jdt.core.dom.ASTNode parent = node.getParent();
            if (locationInParent == org.eclipse.jdt.core.dom.EnumConstantDeclaration.ARGUMENTS_PROPERTY
                    || locationInParent == org.eclipse.jdt.core.dom.ClassInstanceCreation.ARGUMENTS_PROPERTY
                    || locationInParent == org.eclipse.jdt.core.dom.MethodInvocation.ARGUMENTS_PROPERTY
                    || locationInParent == org.eclipse.jdt.core.dom.ConstructorInvocation.ARGUMENTS_PROPERTY
                    || locationInParent == org.eclipse.jdt.core.dom.SuperConstructorInvocation.ARGUMENTS_PROPERTY
                    || locationInParent == org.eclipse.jdt.core.dom.Assignment.RIGHT_HAND_SIDE_PROPERTY
                    || locationInParent == org.eclipse.jdt.core.dom.SwitchCase.EXPRESSION_PROPERTY
                    || parent instanceof org.eclipse.jdt.core.dom.InfixExpression
                    || parent instanceof org.eclipse.jdt.core.dom.ConditionalExpression
                    || parent instanceof org.eclipse.jdt.core.dom.ReturnStatement) {
                ITypeBinding declaringBinding = variableBinding.getDeclaringClass();
                ITypeBinding enclosingBinding = getEnclosingTypeBinding(node);
                if (declaringBinding != null && enclosingBinding != declaringBinding
                        && org.eclipse.jdt.core.dom.Modifier.isStatic(variableBinding.getModifiers())) {
                    SimpleIdentifier target = identifier(declaringBinding.getName());
                    putReference(declaringBinding, target);
                    return done(propertyAccess(target, result));
                }
            }
        }
    }
    // may be statically imported method, generate PrefixedIdentifier
    {
        org.eclipse.jdt.core.dom.StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
        if (binding instanceof IMethodBinding) {
            IMethodBinding methodBinding = (IMethodBinding) binding;
            if (locationInParent == org.eclipse.jdt.core.dom.MethodInvocation.NAME_PROPERTY
                    && ((org.eclipse.jdt.core.dom.MethodInvocation) node.getParent()).getExpression() == null) {
                ITypeBinding declaringBinding = methodBinding.getDeclaringClass();
                ITypeBinding enclosingBinding = getEnclosingTypeBinding(node);
                if (declaringBinding != null && enclosingBinding != declaringBinding
                        && org.eclipse.jdt.core.dom.Modifier.isStatic(methodBinding.getModifiers())) {
                    SimpleIdentifier prefix = identifier(declaringBinding.getName());
                    putReference(declaringBinding, prefix);
                    return done(identifier(prefix, result));
                }
            }
        }
    }
    // done
    return done(result);
}

From source file:de.ovgu.cide.language.jdt.ASTID.java

License:Open Source License

public static String calculateId(ASTNode node) {
    if (node == null)
        return "/";
    String id = calculateId(node.getParent());

    if (node.getParent() instanceof Block) {
        Block block = (Block) node.getParent();
        int idx = block.statements().indexOf(node);
        id += "[" + idx + "]";
    }//from   w  w w  .  j av  a  2s .  com
    if (node.getParent() instanceof ArrayInitializer) {
        ArrayInitializer block = (ArrayInitializer) node.getParent();
        int idx = block.expressions().indexOf(node);
        id += "[" + idx + "]";
    }
    if (node.getLocationInParent() != null && node.getParent() != null) {
        id += ":" + node.getLocationInParent().getId();
    }
    if (node.getParent() instanceof TryStatement) {
        TryStatement trystmt = (TryStatement) node.getParent();
        if (trystmt.getBody() == node)
            id += "[body]";
    }
    // if (node.getLocationInParent() instanceof
    // ChildListPropertyDescriptor) {
    // List children = (List) node.getParent().getStructuralProperty(
    // node.getLocationInParent());
    // id += "[" + children.indexOf(node) + "]";
    // }

    id += "/" + clean(node.getClass().getSimpleName());

    if (node instanceof TypeDeclaration) {
        id += ":" + clean(((TypeDeclaration) node).getName().toString());
    }
    if (node instanceof FieldDeclaration) {
        for (Object fragment : ((FieldDeclaration) node).fragments()) {
            id += ":" + clean(((VariableDeclarationFragment) fragment).getName().toString());
        }
    }
    if (node instanceof Type) {
        ITypeBinding b = ((Type) node).resolveBinding();
        id += "::" + (b == null ? "null" : b.getQualifiedName());
    }
    if (node instanceof VariableDeclaration)
        id += ":" + clean(((VariableDeclaration) node).getName().toString());
    if (node instanceof Name)
        id += ":" + clean(((Name) node).getFullyQualifiedName());
    if (node instanceof ImportDeclaration)
        id += ":" + clean(((ImportDeclaration) node).getName().toString());
    if (node instanceof MethodDeclaration) {
        Type rt = ((MethodDeclaration) node).getReturnType2();
        id += ":" + clean(rt == null ? "void" : rt.toString());
        id += ":" + clean(((MethodDeclaration) node).getName().toString());
        id += ":" + clean(getParameterTypes(((MethodDeclaration) node).parameters()));
    }

    ChildListPropertyDescriptor[] enumLists = new ChildListPropertyDescriptor[] {
            SwitchStatement.STATEMENTS_PROPERTY, InfixExpression.EXTENDED_OPERANDS_PROPERTY,
            TryStatement.CATCH_CLAUSES_PROPERTY, MethodInvocation.ARGUMENTS_PROPERTY,
            ConstructorInvocation.ARGUMENTS_PROPERTY, ClassInstanceCreation.ARGUMENTS_PROPERTY,
            SuperConstructorInvocation.ARGUMENTS_PROPERTY, SuperMethodInvocation.ARGUMENTS_PROPERTY };
    for (ChildListPropertyDescriptor prop : enumLists) {
        if (node.getLocationInParent() == prop) {
            List<?> childList = (List<?>) node.getParent().getStructuralProperty(prop);
            int idx = childList.indexOf(node);
            id += "[" + idx + "]";
        }
    }

    if (node instanceof CompilationUnit) {
        // IJavaElement je = ((CompilationUnit) node).getJavaElement();
        CompilationUnit cu = ((CompilationUnit) node);
        id += "[";
        if (cu.getPackage() != null && cu.getPackage().getName() != null)
            id += clean(cu.getPackage().getName().getFullyQualifiedName() + ".");
        if (cu.types() != null && cu.types().size() >= 1
                && ((AbstractTypeDeclaration) cu.types().get(0)).getName() != null)
            id += ((AbstractTypeDeclaration) cu.types().get(0)).getName().getFullyQualifiedName();
        id += "]";
        // id += "[" + clean(je.getPath().toPortableString()) + "]";
    }
    return id;
}

From source file:org.eclipse.wb.internal.rcp.parser.ParseFactory.java

License:Open Source License

@Override
public JavaInfo create(AstEditor editor, MethodInvocation invocation, IMethodBinding methodBinding,
        Expression[] arguments, JavaInfo expressionInfo, JavaInfo[] argumentInfos,
        IJavaInfoParseResolver javaInfoResolver) throws Exception {
    if (!hasRCP(editor)) {
        return null;
    }/*  ww  w  .  ja  v a 2 s  . c  om*/
    // check "super"
    {
        JavaInfo javaInfo = super.create(editor, invocation, methodBinding, arguments, expressionInfo,
                argumentInfos, javaInfoResolver);
        if (javaInfo != null) {
            return javaInfo;
        }
    }
    // support for org.eclipse.ui.IPerspectiveFactory
    if (expressionInfo instanceof PageLayoutInfo) {
        PageLayoutInfo pageLayout = (PageLayoutInfo) expressionInfo;
        String signature = AstNodeUtils.getMethodSignature(methodBinding);
        if (signature.equals("addView(java.lang.String,int,float,java.lang.String)")
                || signature.equals("addPlaceholder(java.lang.String,int,float,java.lang.String)")
                || signature.equals("addStandaloneView(java.lang.String,boolean,int,float,java.lang.String)")
                || signature.equals(
                        "addStandaloneViewPlaceholder(java.lang.String,int,float,java.lang.String,boolean)")) {
            return new PageLayoutAddViewInfo(pageLayout, invocation);
        }
        if (signature.equals("createFolder(java.lang.String,int,float,java.lang.String)")
                || signature.equals("createPlaceholderFolder(java.lang.String,int,float,java.lang.String)")) {
            return new PageLayoutCreateFolderInfo(pageLayout, invocation);
        }
        if (signature.equals("addFastView(java.lang.String)")
                || signature.equals("addFastView(java.lang.String,float)")) {
            return new FastViewInfo(pageLayout, pageLayout.getFastViewContainer(), invocation);
        }
        if (signature.equals("addShowViewShortcut(java.lang.String)")) {
            return new ViewShortcutInfo(pageLayout, pageLayout.getViewShortcutContainer(), invocation);
        }
        if (signature.equals("addPerspectiveShortcut(java.lang.String)")) {
            return new PerspectiveShortcutInfo(pageLayout, pageLayout.getPerspectiveShortcutContainer(),
                    invocation);
        }
        return null;
    } else if (expressionInfo instanceof PageLayoutCreateFolderInfo) {
        PageLayoutCreateFolderInfo folder = (PageLayoutCreateFolderInfo) expressionInfo;
        String signature = AstNodeUtils.getMethodSignature(methodBinding);
        if (signature.equals("addView(java.lang.String)")
                || signature.equals("addPlaceholder(java.lang.String)")) {
            return new FolderViewInfo(folder, invocation);
        }
    }
    // Action from org.eclipse.ui.actions.ActionFactory
    if (invocation.getExpression() instanceof QualifiedName) {
        QualifiedName qualifiedName = (QualifiedName) invocation.getExpression();
        if (AstNodeUtils.getFullyQualifiedName(qualifiedName.getQualifier(), false)
                .equals("org.eclipse.ui.actions.ActionFactory")) {
            CreationSupport creationSupport = new ActionFactoryCreationSupport(invocation,
                    qualifiedName.getName().getIdentifier());
            JavaInfo component = JavaInfoUtils.createJavaInfo(editor,
                    getClass(editor, methodBinding.getReturnType()), creationSupport);
            return component;
        }
    }
    // special support for IManagedForm.getToolkit()
    if (invocation.getLocationInParent() == ConstructorInvocation.ARGUMENTS_PROPERTY && AstNodeUtils
            .isMethodInvocation(invocation, "org.eclipse.ui.forms.IManagedForm", "getToolkit()")) {
        CreationSupport creationSupport = new OpaqueCreationSupport(invocation);
        InstanceFactoryInfo toolkit = InstanceFactoryInfo.createFactory(editor,
                getClass(editor, methodBinding.getReturnType()), creationSupport);
        EditorState.get(editor).getTmp_Components().add(toolkit);
        return toolkit;
    }
    // no JavaInfo for MethodInvocation
    return null;
}