List of usage examples for org.eclipse.jdt.core.dom StructuralPropertyDescriptor getId
public final String getId()
From source file:de.ovgu.cide.language.jdt.ASTBridge.java
License:Open Source License
private void bridgeFakeParentNodes(ASTNode c_node, org.eclipse.jdt.core.dom.ASTNode e_node) { while (e_node.getParent() != null) { org.eclipse.jdt.core.dom.ASTNode e_parent = e_node.getParent(); IToken c_firstToken = new PosToken(e_parent.getStartPosition()); IToken c_lastToken = new PosToken(e_parent.getStartPosition() + e_node.getLength()); StructuralPropertyDescriptor e_prop = e_node.getLocationInParent(); List<Property> c_props = new ArrayList<Property>(); // fake a property with a single child c_props.add(new PropertyZeroOrOne<ASTNode>(e_prop.getId(), c_node)); c_node = new UnifiedASTNode(getDisplayName(e_parent), ASTID.id(e_parent), c_props, c_firstToken, c_lastToken, null, getKind(e_parent)); e_node = e_parent;/*from w w w .j a v a 2 s. c om*/ } }
From source file:de.ovgu.cide.language.jdt.ASTBridge.java
License:Open Source License
private Property bridgeOneChildProperty(org.eclipse.jdt.core.dom.ASTNode e_node, StructuralPropertyDescriptor prop) { Object o = e_node.getStructuralProperty(prop); ASTNode child;/*from www .ja v a2s . com*/ assert o != null; if (o instanceof org.eclipse.jdt.core.dom.ASTNode) child = bridgeASTNode((org.eclipse.jdt.core.dom.ASTNode) o); else if (e_node instanceof Modifier || e_node instanceof PrimitiveType || e_node instanceof SimpleName || e_node instanceof NumberLiteral || e_node instanceof CharacterLiteral || e_node instanceof StringLiteral || e_node instanceof TextElement) child = new ASTTextNode(o.toString(), new SimpleToken(e_node.getStartPosition(), e_node.getLength())); else return null; return new PropertyOne<ASTNode>(prop.getId(), child); }
From source file:de.ovgu.cide.language.jdt.ASTBridge.java
License:Open Source License
private Property bridgeOptionalChildProperty(org.eclipse.jdt.core.dom.ASTNode e_node, StructuralPropertyDescriptor prop) { Object o = e_node.getStructuralProperty(prop); ASTNode child;//from w w w .ja v a 2 s . com if (o == null) child = null; else if (o instanceof org.eclipse.jdt.core.dom.ASTNode) child = bridgeASTNode((org.eclipse.jdt.core.dom.ASTNode) o); else child = new ASTTextNode(o.toString(), new SimpleToken(e_node.getStartPosition(), e_node.getLength())); return new PropertyZeroOrOne<ASTNode>(prop.getId(), child); }
From source file:org.eclipse.jet.internal.xpath.inspectors.jdt.InspectASTNode.java
License:Open Source License
/** * Return the named property descriptor for the given node. * @param node// w w w . j a v a 2 s .co m * @param id * @return the property descriptor or null, if id is not know property */ private StructuralPropertyDescriptor getPropertyDescriptor(final ASTNode node, final String id) { final List propsList = getPropertyDescriptors(node); for (final Iterator i = propsList.iterator(); i.hasNext();) { final StructuralPropertyDescriptor spd = (StructuralPropertyDescriptor) i.next(); if (spd.getId().equals(id)) { return spd; } } return null; }
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 w w w . ja v a 2 s. c om 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(); } }