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

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

Introduction

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

Prototype

ChildListPropertyDescriptor ARGUMENTS_PROPERTY

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

Click Source Link

Document

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

Usage

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 + "]";
    }//ww  w. j a va2s  . c  o m
    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.core.model.JavaInfo.java

License:Open Source License

/**
 * @return the {@link ASTNode} that should be used to display given related {@link ASTNode}.
 */// w ww .  j  a  v a2  s .c o m
public static ASTNode getRelatedNodeForSource(ASTNode node) {
    ASTNode sourceNode = node;
    // part of invocation
    if (node.getLocationInParent() == MethodInvocation.EXPRESSION_PROPERTY) {
        sourceNode = node.getParent();
    }
    if (node.getLocationInParent() == MethodInvocation.ARGUMENTS_PROPERTY) {
        sourceNode = node.getParent();
    }
    if (node.getLocationInParent() == SuperConstructorInvocation.ARGUMENTS_PROPERTY) {
        sourceNode = node.getParent();
    }
    if (node.getLocationInParent() == SuperMethodInvocation.ARGUMENTS_PROPERTY) {
        sourceNode = node.getParent();
    }
    if (node.getLocationInParent() == ClassInstanceCreation.ARGUMENTS_PROPERTY) {
        sourceNode = node.getParent();
    }
    // javaInfo.foo = something
    if (node.getLocationInParent() == QualifiedName.QUALIFIER_PROPERTY) {
        QualifiedName qualifiedName = (QualifiedName) node.getParent();
        sourceNode = qualifiedName;
        if (qualifiedName.getLocationInParent() == Assignment.LEFT_HAND_SIDE_PROPERTY) {
            sourceNode = qualifiedName.getParent();
        }
    }
    // done
    return sourceNode;
}

From source file:org.moe.natjgen.ConstructorEditor.java

License:Apache License

public void setBodyAsSuperInitWithClassAsArg() {
    Block block = getAST().newBlock();/*  w  w  w  .  ja  va2 s.c o  m*/
    getRewrite().set(methodDecl, MethodDeclaration.BODY_PROPERTY, block, getEditGroup());
    ListRewrite block_stmts = getRewrite().getListRewrite(block, Block.STATEMENTS_PROPERTY);
    SuperConstructorInvocation invoke = getAST().newSuperConstructorInvocation();
    block_stmts.insertLast(invoke, getEditGroup());
    ListRewrite invoke_args = getRewrite().getListRewrite(invoke,
            SuperConstructorInvocation.ARGUMENTS_PROPERTY);
    TypeLiteral literal = getAST().newTypeLiteral();
    invoke_args.insertLast(literal, getEditGroup());
    getRewrite().set(literal, TypeLiteral.TYPE_PROPERTY,
            getAST().newSimpleType(getAST().newName(getManager().getUnitName())), getEditGroup());
}

From source file:org.moe.natjgen.ConstructorEditor.java

License:Apache License

public void setBodyAsSuperInitWithPointerAsArg(String varname) {
    Block block = getAST().newBlock();//w  w w. ja v  a2s  .c o  m
    getRewrite().set(methodDecl, MethodDeclaration.BODY_PROPERTY, block, getEditGroup());
    ListRewrite block_stmts = getRewrite().getListRewrite(block, Block.STATEMENTS_PROPERTY);
    SuperConstructorInvocation invoke = getAST().newSuperConstructorInvocation();
    block_stmts.insertLast(invoke, getEditGroup());
    ListRewrite invoke_args = getRewrite().getListRewrite(invoke,
            SuperConstructorInvocation.ARGUMENTS_PROPERTY);
    invoke_args.insertLast(getAST().newSimpleName(varname), getEditGroup());
}

From source file:org.moe.natjgen.ConstructorEditor.java

License:Apache License

public void setBodyAsSuperInitWithFieldSetters(String[] setters, String[] getters) {
    if (setters == null || getters == null || setters.length != getters.length) {
        throw new IllegalArgumentException();
    }//from w  w w  .java 2 s. c  o  m

    Block block = getAST().newBlock();
    getRewrite().set(methodDecl, MethodDeclaration.BODY_PROPERTY, block, getEditGroup());
    ListRewrite block_stmts = getRewrite().getListRewrite(block, Block.STATEMENTS_PROPERTY);
    SuperConstructorInvocation invoke = getAST().newSuperConstructorInvocation();
    block_stmts.insertLast(invoke, getEditGroup());
    ListRewrite invoke_args = getRewrite().getListRewrite(invoke,
            SuperConstructorInvocation.ARGUMENTS_PROPERTY);
    TypeLiteral literal = getAST().newTypeLiteral();
    invoke_args.insertLast(literal, getEditGroup());
    getRewrite().set(literal, TypeLiteral.TYPE_PROPERTY,
            getAST().newSimpleType(getAST().newName(getManager().getUnitName())), getEditGroup());

    for (int i = 0; i < setters.length; i++) {
        MethodInvocation setfieldinvoke = getAST().newMethodInvocation();
        Statement stmt = getAST().newExpressionStatement(setfieldinvoke);
        block_stmts.insertLast(stmt, getEditGroup());
        getRewrite().set(setfieldinvoke, MethodInvocation.NAME_PROPERTY, getAST().newSimpleName(setters[i]),
                getEditGroup());
        ListRewrite arglrw = getRewrite().getListRewrite(setfieldinvoke, MethodInvocation.ARGUMENTS_PROPERTY);
        arglrw.insertLast(getAST().newSimpleName(getters[i]), getEditGroup());
    }
}