Example usage for org.eclipse.jdt.core.dom InfixExpression EXTENDED_OPERANDS_PROPERTY

List of usage examples for org.eclipse.jdt.core.dom InfixExpression EXTENDED_OPERANDS_PROPERTY

Introduction

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

Prototype

ChildListPropertyDescriptor EXTENDED_OPERANDS_PROPERTY

To view the source code for org.eclipse.jdt.core.dom InfixExpression EXTENDED_OPERANDS_PROPERTY.

Click Source Link

Document

The "extendedOperands" 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 + "]";
    }/* www  .j av  a 2s. 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:de.ovgu.cide.language.jdt.ASTID.java

License:Open Source License

public static String calculateId_old(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 + "]";
    }// w w w.  j  ava 2  s. c om
    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 };
    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;
}