List of usage examples for org.eclipse.jdt.core.dom SuperMethodInvocation ARGUMENTS_PROPERTY
ChildListPropertyDescriptor ARGUMENTS_PROPERTY
To view the source code for org.eclipse.jdt.core.dom SuperMethodInvocation ARGUMENTS_PROPERTY.
Click Source Link
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 + "]"; }/* w w w . ja va2s. co 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 w w . ja v a2 s .c om*/ 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; }