Example usage for org.eclipse.jdt.core.dom ASTNode nodeClassForType

List of usage examples for org.eclipse.jdt.core.dom ASTNode nodeClassForType

Introduction

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

Prototype

public static Class nodeClassForType(int nodeType) 

Source Link

Document

Returns the node class for the corresponding node type.

Usage

From source file:edu.cmu.cs.crystal.flow.MotherFlowAnalysis.java

License:Open Source License

private String getNodeDebugInfo(ASTNode node) {
    return node.toString() + " type: " + ASTNode.nodeClassForType(node.getNodeType()).getName()
            + (node.getParent() != null/* ww w  .j  a  va 2 s.c o m*/
                    ? " parent type: " + ASTNode.nodeClassForType(node.getParent().getNodeType()).getName()
                    : "");
}

From source file:org.eclipse.jet.internal.xpath.inspectors.jdt.InspectASTNode.java

License:Open Source License

public String nameOf(final Object node) {
    final ASTNode astNode = (ASTNode) node;
    final StructuralPropertyDescriptor locationInParent = astNode.getLocationInParent();
    if (locationInParent != null) {
        return locationInParent.getId();
    } else {/*from   www. j  a va2s .c  o  m*/
        final String fullyQualifiedName = ASTNode.nodeClassForType(astNode.getNodeType()).getName();
        final int lastDot = fullyQualifiedName.lastIndexOf('.');
        final StringBuffer simpleName = new StringBuffer(
                lastDot >= 0 ? fullyQualifiedName.substring(lastDot + 1) : fullyQualifiedName);
        simpleName.setCharAt(0, Character.toLowerCase(simpleName.charAt(0)));
        return simpleName.toString();
    }
}

From source file:org.eclipse.xtend.core.javaconverter.JavaASTFlattener.java

License:Open Source License

@Override
public boolean visit(final Initializer it) {
    Javadoc _javadoc = it.getJavadoc();/* ww  w .  jav a2  s  . c o m*/
    boolean _tripleNotEquals = (_javadoc != null);
    if (_tripleNotEquals) {
        it.getJavadoc().accept(this);
    }
    this.appendModifiers(it, it.modifiers());
    boolean _isStatic = this._aSTFlattenerUtils.isStatic(it.modifiers());
    if (_isStatic) {
        if (((it.getParent() instanceof TypeDeclaration)
                && IterableExtensions.<FieldDeclaration>forall(IterableExtensions.<FieldDeclaration>filter(
                        ((Iterable<FieldDeclaration>) Conversions
                                .doWrapArray(((TypeDeclaration) it.getParent()).getFields())),
                        ((Function1<FieldDeclaration, Boolean>) (FieldDeclaration it_1) -> {
                            return Boolean.valueOf((this._aSTFlattenerUtils.isStatic(it_1.modifiers())
                                    && this._aSTFlattenerUtils.isFinal(it_1.modifiers())));
                        })), ((Function1<FieldDeclaration, Boolean>) (FieldDeclaration f) -> {
                            final Function1<VariableDeclarationFragment, Boolean> _function = (
                                    VariableDeclarationFragment fragment) -> {
                                Boolean _isAssignedInBody = this._aSTFlattenerUtils
                                        .isAssignedInBody(it.getBody(), fragment);
                                return Boolean.valueOf((!(_isAssignedInBody).booleanValue()));
                            };
                            return Boolean.valueOf(IterableExtensions
                                    .<VariableDeclarationFragment>forall(f.fragments(), _function));
                        })))) {
            this.appendToBuffer(" final Void static_initializer = {");
            this.appendLineWrapToBuffer();
            it.getBody().accept(this);
            this.appendToBuffer("null }");
            this.appendLineWrapToBuffer();
        } else {
            this.addProblem(it, "Static initializer is not fully supported");
            this.appendToBuffer("{/*FIXME ");
            it.getBody().accept(this);
            this.appendToBuffer("*/}");
        }
    } else {
        ASTNode _parent = it.getParent();
        if ((_parent instanceof AnonymousClassDeclaration)) {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("Initializer is not supported in ");
            String _simpleName = ASTNode.nodeClassForType(it.getParent().getNodeType()).getSimpleName();
            _builder.append(_simpleName);
            this.addProblem(it, _builder.toString());
        }
        it.getBody().accept(this);
    }
    return false;
}

From source file:simpack.util.tree.visitor.ast.SourceCodeEntity.java

License:LGPL

public static String getSourceCodeEntityKeyword(int keyword) {
    switch (keyword) {
    case THEN_STATEMENT:
        return "ThenBlock";
    case ELSE_STATEMENT:
        return "ElseBlock";
    case ARRAY_DIMENSION:
        return "ArrayDimension";
    case TYPE_ARGUMENTS:
        return "TypeArguments";
    case ARGUMENTS:
        return "Arguments";
    case BODY://from ww  w . j  a  v a 2 s.  co m
        return "Body";
    case MODIFIERS:
        return "Modifiers";
    case SUPER_INTERFACE_TYPES:
        return "SuperInterfaces";
    case ENUM_CONSTANTS:
        return "EnumConstants";
    case BODY_DECLARATIONS:
        return "BodyDeclarations";
    case FRAGMENTS:
        return "Fragments";
    case INITIALIZERS:
        return "Initializers";
    case UPDATERS:
        return "Updaters";
    case EXTENDED_OPERANDS:
        return "ExtendedOperands";
    case PARAMETERS:
        return "Parameters";
    case CATCH_CLAUSES:
        return "CatchClauses";
    case FINALLY:
        return "FinallyBlock";
    case THROW:
        return "Throw";
    case CLASS:
        return "Class";
    case METHOD:
        return "Method";
    case ATTRIBUTE:
        return "Attribute";
    default:
        String type = ASTNode.nodeClassForType(keyword).toString();
        return type.substring(type.lastIndexOf('.') + 1);
    }
}