/** * @param node the ASTNode * @param constraintVariable the {@link ConstraintVariable2} to be associated with node */ protected static void setConstraintVariable(ASTNode node, ConstraintVariable2 constraintVariable) { node.setProperty(CV_PROP, constraintVariable); }
/** * @param node the ASTNode * @param constraintVariable the {@link ConstraintVariable2} to be associated with node */ protected static void setConstraintVariable(ASTNode node, ConstraintVariable2 constraintVariable) { node.setProperty(CV_PROP, constraintVariable); }
public void registerRemovedNode(ASTNode removed) { fHasRemovedNodes= true; removed.setProperty(PROPERTY_KEY, REMOVED); }
/** * @param node the ASTNode * @param constraintVariable the {@link ConstraintVariable2} to be associated with node */ protected static void setConstraintVariable(ASTNode node, ConstraintVariable2 constraintVariable) { node.setProperty(CV_PROP, constraintVariable); }
public void registerRemovedNode(ASTNode removed) { fHasRemovedNodes= true; removed.setProperty(PROPERTY_KEY, REMOVED); }
public void registerRetainedNode(ASTNode retained) { retained.setProperty(PROPERTY_KEY, RETAINED); }
public void registerRetainedNode(ASTNode retained) { retained.setProperty(PROPERTY_KEY, RETAINED); }
/** * Removes the provided node from the AST leaving the leading comment. * * @param node the node to remove * @see ASTRewrite#remove(ASTNode, org.eclipse.text.edits.TextEditGroup) */ public void removeButKeepComment(ASTNode node) { node.setProperty(UNTOUCH_COMMENT, Boolean.TRUE); remove(node); }
/** * Replaces the provided node from the AST with the provided replacement node. * * @param node the node to remove * @param replacement the replacement node * @see ASTRewrite#replace(ASTNode, ASTNode, org.eclipse.text.edits.TextEditGroup) */ public void replace(ASTNode node, ASTNode replacement) { node.setProperty(UNTOUCH_COMMENT, Boolean.TRUE); rewrite.replace(node, replacement, null); addRefactoredNodes(node); }
@Override public void preVisit(ASTNode node) { Object property= node.getProperty(PROPERTY_KEY); if (property == REMOVED) { if (fRemovingStart == -1) { fRemovingStart= node.getStartPosition(); } else { /* * Bug in client code: REMOVED node should not be nested inside another REMOVED node without * an intermediate RETAINED node. * Drop REMOVED property to prevent problems later (premature end of REMOVED section). */ node.setProperty(PROPERTY_KEY, null); } } else if (property == RETAINED) { if (fRemovingStart != -1) { removedStartsEnds.add(new int[] { fRemovingStart, node.getStartPosition() }); fRemovingStart= -1; } else { /* * Bug in client code: RETAINED node should not be nested inside another RETAINED node without * an intermediate REMOVED node and must have an enclosing REMOVED node. * Drop RETAINED property to prevent problems later (premature restart of REMOVED section). */ node.setProperty(PROPERTY_KEY, null); } } super.preVisit(node); } @Override
@Override public void preVisit(ASTNode node) { Object property= node.getProperty(PROPERTY_KEY); if (property == REMOVED) { if (fRemovingStart == -1) { fRemovingStart= node.getStartPosition(); } else { /* * Bug in client code: REMOVED node should not be nested inside another REMOVED node without * an intermediate RETAINED node. * Drop REMOVED property to prevent problems later (premature end of REMOVED section). */ node.setProperty(PROPERTY_KEY, null); } } else if (property == RETAINED) { if (fRemovingStart != -1) { removedStartsEnds.add(new int[] { fRemovingStart, node.getStartPosition() }); fRemovingStart= -1; } else { /* * Bug in client code: RETAINED node should not be nested inside another RETAINED node without * an intermediate REMOVED node and must have an enclosing REMOVED node. * Drop RETAINED property to prevent problems later (premature restart of REMOVED section). */ node.setProperty(PROPERTY_KEY, null); } } super.preVisit(node); } @Override
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) { CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove); internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder); NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup); ListRewriteEvent listEvent= getListEvent(parent, childProperty, true); int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD); if (indexFirst == -1) { throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$ } int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD); if (indexLast == -1) { throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$ } if (indexFirst > indexLast) { throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$ } if (this.nodeRangeInfos == null) { this.nodeRangeInfos= new HashMap(); } PropertyLocation loc= new PropertyLocation(parent, childProperty); List innerList= (List) this.nodeRangeInfos.get(loc); if (innerList == null) { innerList= new ArrayList(2); this.nodeRangeInfos.put(loc, innerList); } else { assertNoOverlap(listEvent, indexFirst, indexLast, innerList); } innerList.add(copyRangeInfo); return copyInfo; }
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) { CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove); internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder); NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup); ListRewriteEvent listEvent= getListEvent(parent, childProperty, true); int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD); if (indexFirst == -1) { throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$ } int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD); if (indexLast == -1) { throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$ } if (indexFirst > indexLast) { throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$ } if (this.nodeRangeInfos == null) { this.nodeRangeInfos= new HashMap(); } PropertyLocation loc= new PropertyLocation(parent, childProperty); List innerList= (List) this.nodeRangeInfos.get(loc); if (innerList == null) { innerList= new ArrayList(2); this.nodeRangeInfos.put(loc, innerList); } else { assertNoOverlap(listEvent, indexFirst, indexLast, innerList); } innerList.add(copyRangeInfo); return copyInfo; }
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) { CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove); internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder); NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup); ListRewriteEvent listEvent= getListEvent(parent, childProperty, true); int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD); if (indexFirst == -1) { throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$ } int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD); if (indexLast == -1) { throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$ } if (indexFirst > indexLast) { throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$ } if (this.nodeRangeInfos == null) { this.nodeRangeInfos= new HashMap(); } PropertyLocation loc= new PropertyLocation(parent, childProperty); List innerList= (List) this.nodeRangeInfos.get(loc); if (innerList == null) { innerList= new ArrayList(2); this.nodeRangeInfos.put(loc, innerList); } else { assertNoOverlap(listEvent, indexFirst, indexLast, innerList); } innerList.add(copyRangeInfo); return copyInfo; }
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) { CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove); internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder); NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup); ListRewriteEvent listEvent= getListEvent(parent, childProperty, true); int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD); if (indexFirst == -1) { throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$ } int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD); if (indexLast == -1) { throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$ } if (indexFirst > indexLast) { throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$ } if (this.nodeRangeInfos == null) { this.nodeRangeInfos= new HashMap(); } PropertyLocation loc= new PropertyLocation(parent, childProperty); List innerList= (List) this.nodeRangeInfos.get(loc); if (innerList == null) { innerList= new ArrayList(2); this.nodeRangeInfos.put(loc, innerList); } else { assertNoOverlap(listEvent, indexFirst, indexLast, innerList); } innerList.add(copyRangeInfo); return copyInfo; }
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) { CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove); internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder); NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup); ListRewriteEvent listEvent= getListEvent(parent, childProperty, true); int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD); if (indexFirst == -1) { throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$ } int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD); if (indexLast == -1) { throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$ } if (indexFirst > indexLast) { throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$ } if (this.nodeRangeInfos == null) { this.nodeRangeInfos= new HashMap(); } PropertyLocation loc= new PropertyLocation(parent, childProperty); List innerList= (List) this.nodeRangeInfos.get(loc); if (innerList == null) { innerList= new ArrayList(2); this.nodeRangeInfos.put(loc, innerList); } else { assertNoOverlap(listEvent, indexFirst, indexLast, innerList); } innerList.add(copyRangeInfo); return copyInfo; }
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) { CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove); internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder); NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup); ListRewriteEvent listEvent= getListEvent(parent, childProperty, true); int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD); if (indexFirst == -1) { throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$ } int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD); if (indexLast == -1) { throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$ } if (indexFirst > indexLast) { throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$ } if (this.nodeRangeInfos == null) { this.nodeRangeInfos= new HashMap(); } PropertyLocation loc= new PropertyLocation(parent, childProperty); List innerList= (List) this.nodeRangeInfos.get(loc); if (innerList == null) { innerList= new ArrayList(2); this.nodeRangeInfos.put(loc, innerList); } else { assertNoOverlap(listEvent, indexFirst, indexLast, innerList); } innerList.add(copyRangeInfo); return copyInfo; }
/** * End of visit the variable declaration fragment list. * * @param fragments the fragments (element type: <code>VariableDeclarationFragment</code>) * @param type the type of the fragments * @param parent the parent of the fragment list */ private void endVisit(final List<VariableDeclarationFragment> fragments, final Type type, final ASTNode parent) { final ConstraintVariable2 ancestor= (ConstraintVariable2) type.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (ancestor != null) { IVariableBinding binding= null; ConstraintVariable2 descendant= null; VariableDeclarationFragment fragment= null; for (int index= 0; index < fragments.size(); index++) { fragment= fragments.get(index); descendant= (ConstraintVariable2) fragment.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (descendant != null) fModel.createSubtypeConstraint(descendant, ancestor); binding= fragment.resolveBinding(); if (binding != null) { descendant= fModel.createVariableVariable(binding); if (descendant != null) fModel.createEqualityConstraint(ancestor, descendant); } } parent.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor); } }
/** * End of visit the variable declaration fragment list. * * @param fragments the fragments (element type: <code>VariableDeclarationFragment</code>) * @param type the type of the fragments * @param parent the parent of the fragment list */ private void endVisit(final List fragments, final Type type, final ASTNode parent) { final ConstraintVariable2 ancestor= (ConstraintVariable2) type.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (ancestor != null) { IVariableBinding binding= null; ConstraintVariable2 descendant= null; VariableDeclarationFragment fragment= null; for (int index= 0; index < fragments.size(); index++) { fragment= (VariableDeclarationFragment) fragments.get(index); descendant= (ConstraintVariable2) fragment.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (descendant != null) fModel.createSubtypeConstraint(descendant, ancestor); binding= fragment.resolveBinding(); if (binding != null) { descendant= fModel.createVariableVariable(binding); if (descendant != null) fModel.createEqualityConstraint(ancestor, descendant); } } parent.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor); } }
/** * End of visit the variable declaration fragment list. * * @param fragments the fragments (element type: <code>VariableDeclarationFragment</code>) * @param type the type of the fragments * @param parent the parent of the fragment list */ private void endVisit(final List<VariableDeclarationFragment> fragments, final Type type, final ASTNode parent) { final ConstraintVariable2 ancestor= (ConstraintVariable2) type.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (ancestor != null) { IVariableBinding binding= null; ConstraintVariable2 descendant= null; VariableDeclarationFragment fragment= null; for (int index= 0; index < fragments.size(); index++) { fragment= fragments.get(index); descendant= (ConstraintVariable2) fragment.getProperty(PROPERTY_CONSTRAINT_VARIABLE); if (descendant != null) fModel.createSubtypeConstraint(descendant, ancestor); binding= fragment.resolveBinding(); if (binding != null) { descendant= fModel.createVariableVariable(binding); if (descendant != null) fModel.createEqualityConstraint(ancestor, descendant); } } parent.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor); } }