Java Code Examples for org.eclipse.jdt.core.dom.ASTNode#getProperty()
The following examples show how to use
org.eclipse.jdt.core.dom.ASTNode#getProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseTranslator.java From junion with BSD 3-Clause "New" or "Revised" License | 6 votes |
public ASTNode copySubtree(Object o) { ASTNode n = (ASTNode)o; MethodTmp m = null; if(tmpTranslator != null) { m = getMethodTmp(n); if(m != null) { n.setProperty(TYPEBIND_METHOD_TMP, null); } n = tmpTranslator.translate(n); } ASTNode copy = ASTNode.copySubtree(ast, n); Object t = n.getProperty(TYPEBIND_PROP); if(t != null) copy.setProperty(TYPEBIND_PROP, t); if(m != null) copy.setProperty(TYPEBIND_METHOD_TMP, m); // Object t2 = n.getProperty(TYPEBIND_METHOD_TMP); // if(t2 != null) copy.setProperty(TYPEBIND_METHOD_TMP, t2); return copy; }
Example 2
Source File: BaseTranslator.java From junion with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ASTNode copy(ASTNode node) { // copyStack.add(node); node.accept(this); // ASTNode n = copyStack.remove(copyStack.size()-1); ASTNode n = getReplace(node); if(n != node) { err("Different"); if(n.getProperty(TYPEBIND_PROP) == null) throw new CompilerError("Differnet null type: " + node); return n; //throw new CompilerError("different"); } return copySubtree(node); }
Example 3
Source File: BaseTranslator.java From junion with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ASTNode translate(ASTNode node) { // copyStack.add(node); node.accept(this); // ASTNode n = copyStack.remove(copyStack.size()-1); ASTNode n = getReplace(node); if(n != node) { err("Different"); if(n.getProperty(TYPEBIND_PROP) == null) throw new CompilerError("Differnet null type"); return n; //throw new CompilerError("different"); } return node; }
Example 4
Source File: TreedMapper.java From compiler with Apache License 2.0 | 5 votes |
private void markAstN(ASTNode node) { if (node.getProperty(PROPERTY_STATUS) == null) { node.setProperty(PROPERTY_STATUS, ChangeKind.ADDED); numOfChanges++; numOfUnmaps++; if (!(node instanceof SimpleName)) numOfNonNameUnMaps++; } ArrayList<ASTNode> children = tree.get(node); for (ASTNode child : children) markAstN(child); }
Example 5
Source File: BaseTranslator.java From junion with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void replace(ASTNode old, ASTNode neww) { // if(!copyStack.isEmpty()) { // if(copyStack.get(copyStack.size()-1) == old) { // copyStack.set(copyStack.size()-1, neww); // Log.err("COPY STACK REPLACE"); // Object oldProp = old.getProperty(TYPEBIND_PROP); // if(oldProp != null && neww.getProperty(TYPEBIND_PROP) == null) { // Log.err(" copy old prop"); // neww.setProperty(TYPEBIND_PROP, oldProp); // } // Object oldProp2 = old.getProperty(TYPEBIND_METHOD_TMP); // if(oldProp2 != null && neww.getProperty(TYPEBIND_METHOD_TMP) == null) { // Log.err(" copy old prop2"); // neww.setProperty(TYPEBIND_METHOD_TMP, oldProp2); // } // return; // } // } old.setProperty(IS_REPLACE, neww); ASTNode parent = old.getParent(); StructuralPropertyDescriptor desc = old.getLocationInParent(); if(desc instanceof ChildListPropertyDescriptor) { ChildListPropertyDescriptor ch = (ChildListPropertyDescriptor)desc; List<ASTNode> list = (List)parent.getStructuralProperty(ch); int index = list.indexOf(old); list.set(index, neww); } else { if(parent instanceof QualifiedName && QualifiedName.QUALIFIER_PROPERTY.getId().equals(desc.getId()) && !(neww instanceof SimpleName)) { if(!(neww instanceof Expression))throw new IllegalArgumentException(); //QualifiedName has to be changed to FieldAccess // throw new IllegalArgumentException("qual name expression"); FieldAccess fa = ast.newFieldAccess(); fa.setExpression((Expression)neww); fa.setName((SimpleName)copySubtreeIfHasParent(((QualifiedName)parent).getName())); // for(Map.Entry ee : (Set<Map.Entry>)parent.properties().entrySet()) { // Log.err("ee " + ee.getKey()); // } if(parent.getProperty(TYPEBIND_PROP) == null) fa.setProperty(TYPEBIND_PROP, parent.getProperty(TYPEBIND_PROP)); replace(parent, fa); return; } parent.setStructuralProperty(desc, neww); } }
Example 6
Source File: BaseTranslator.java From junion with BSD 3-Clause "New" or "Revised" License | 4 votes |
public MethodTmp getMethodTmp(ASTNode n) { Object o = n.getProperty(TYPEBIND_METHOD_TMP); if(o != null) return (MethodTmp)o; return null; }
Example 7
Source File: TreedMapper.java From compiler with Apache License 2.0 | 4 votes |
private boolean isUnchanged(ArrayList<ASTNode> children) { for (ASTNode child : children) if ((ChangeKind) child.getProperty(PROPERTY_STATUS) != ChangeKind.UNCHANGED) return false; return true; }
Example 8
Source File: SortElementsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
boolean checkMalformedNodes(ASTNode node) { Object property = node.getProperty(CONTAINS_MALFORMED_NODES); if (property == null) return false; return ((Boolean) property).booleanValue(); }
Example 9
Source File: RewriteEventStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public final boolean isRangeCopyPlaceholder(ASTNode node) { return node.getProperty(INTERNAL_PLACEHOLDER_PROPERTY) != null; }
Example 10
Source File: InferTypeArgumentsConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * @param node the ASTNode * @return the {@link ConstraintVariable2} associated with the node, or <code>null</code> */ protected static ConstraintVariable2 getConstraintVariable(ASTNode node) { return (ConstraintVariable2) node.getProperty(CV_PROP); }
Example 11
Source File: BaseTranslator.java From junion with BSD 3-Clause "New" or "Revised" License | votes |
public boolean isReplace(ASTNode n) { return n.getProperty(IS_REPLACE) != null;}