Java Code Examples for org.eclipse.jdt.core.dom.rewrite.ListRewrite#getOriginalList()
The following examples show how to use
org.eclipse.jdt.core.dom.rewrite.ListRewrite#getOriginalList() .
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: StubUtility2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Evaluates the insertion position of a new node. * * @param listRewrite The list rewriter to which the new node will be added * @param sibling The Java element before which the new element should be added. * @return the AST node of the list to insert before or null to insert as last. * @throws JavaModelException thrown if accessing the Java element failed */ public static ASTNode getNodeToInsertBefore(ListRewrite listRewrite, IJavaElement sibling) throws JavaModelException { if (sibling instanceof IMember) { ISourceRange sourceRange= ((IMember) sibling).getSourceRange(); if (sourceRange == null) { return null; } int insertPos= sourceRange.getOffset(); List<? extends ASTNode> members= listRewrite.getOriginalList(); for (int i= 0; i < members.size(); i++) { ASTNode curr= members.get(i); if (curr.getStartPosition() >= insertPos) { return curr; } } } return null; }
Example 2
Source File: ModifierRewrite.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public void copyAllAnnotations(ASTNode otherDecl, TextEditGroup editGroup) { ListRewrite modifierList = evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl); List<IExtendedModifier> originalList = modifierList.getOriginalList(); for (Iterator<IExtendedModifier> iterator = originalList.iterator(); iterator.hasNext();) { IExtendedModifier modifier = iterator.next(); if (modifier.isAnnotation()) { fModifierRewrite.insertLast(fModifierRewrite.getASTRewrite().createCopyTarget((Annotation) modifier), editGroup); } } }
Example 3
Source File: ReorgPolicyFactory.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void insertRelative(ASTNode newNode, ASTNode relativeNode, ListRewrite listRewrite) { final List<?> list= listRewrite.getOriginalList(); final int index= list.indexOf(relativeNode); if (getLocation() == IReorgDestination.LOCATION_BEFORE) { listRewrite.insertBefore(newNode, (ASTNode) list.get(index), null); } else if (index + 1 < list.size()) { listRewrite.insertBefore(newNode, (ASTNode) list.get(index + 1), null); } else { listRewrite.insertLast(newNode, null); } }
Example 4
Source File: ReorgPolicyFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void insertRelative(ASTNode newNode, ASTNode relativeNode, ListRewrite listRewrite) { final List<?> list= listRewrite.getOriginalList(); final int index= list.indexOf(relativeNode); if (getLocation() == IReorgDestination.LOCATION_BEFORE) { listRewrite.insertBefore(newNode, (ASTNode) list.get(index), null); } else if (index + 1 < list.size()) { listRewrite.insertBefore(newNode, (ASTNode) list.get(index + 1), null); } else { listRewrite.insertLast(newNode, null); } }
Example 5
Source File: ModifierRewrite.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void copyAllAnnotations(ASTNode otherDecl, TextEditGroup editGroup) { ListRewrite modifierList= evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl); List<IExtendedModifier> originalList= modifierList.getOriginalList(); for (Iterator<IExtendedModifier> iterator= originalList.iterator(); iterator.hasNext();) { IExtendedModifier modifier= iterator.next(); if (modifier.isAnnotation()) { fModifierRewrite.insertLast(fModifierRewrite.getASTRewrite().createCopyTarget((Annotation) modifier), editGroup); } } }
Example 6
Source File: AddUnimplementedConstructorsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private ASTNode getNodeToInsertBefore(ListRewrite rewriter) { if (fInsertPos != -1) { List<?> members= rewriter.getOriginalList(); for (int i= 0; i < members.size(); i++) { ASTNode curr= (ASTNode) members.get(i); if (curr.getStartPosition() >= fInsertPos) { return curr; } } } return null; }
Example 7
Source File: AddUnimplementedMethodsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private ASTNode getNodeToInsertBefore(ListRewrite rewriter) { if (fInsertPos != -1) { List<?> members= rewriter.getOriginalList(); for (int i= 0; i < members.size(); i++) { ASTNode curr= (ASTNode) members.get(i); if (curr.getStartPosition() >= fInsertPos) { return curr; } } } return null; }