Java Code Examples for org.eclipse.ltk.core.refactoring.TextChange#addTextEditGroup()
The following examples show how to use
org.eclipse.ltk.core.refactoring.TextChange#addTextEditGroup() .
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: SelfEncapsulateFieldRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void createEdits(ICompilationUnit unit, ASTRewrite rewriter, List<TextEditGroup> groups, ImportRewrite importRewrite) throws CoreException { TextChange change = fChangeManager.get(unit); MultiTextEdit root = new MultiTextEdit(); change.setEdit(root); root.addChild(importRewrite.rewriteImports(null)); root.addChild(rewriter.rewriteAST()); for (Iterator<TextEditGroup> iter = groups.iterator(); iter.hasNext();) { change.addTextEditGroup(iter.next()); } }
Example 2
Source File: AccessorClassModifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void removeKey(NLSSubstitution sub, TextChange change) { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_remove_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); change.addTextEditGroup(editGroup); fFields.remove(node); }
Example 3
Source File: AccessorClassModifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void renameKey(NLSSubstitution sub, TextChange change) { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_replace_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); fFields.remove(node); addKey(sub, editGroup); change.addTextEditGroup(editGroup); }
Example 4
Source File: SelfEncapsulateFieldRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void createEdits(ICompilationUnit unit, ASTRewrite rewriter, List<TextEditGroup> groups, ImportRewrite importRewrite) throws CoreException { TextChange change= fChangeManager.get(unit); MultiTextEdit root= new MultiTextEdit(); change.setEdit(root); root.addChild(importRewrite.rewriteImports(null)); root.addChild(rewriter.rewriteAST()); for (Iterator<TextEditGroup> iter= groups.iterator(); iter.hasNext();) { change.addTextEditGroup(iter.next()); } }
Example 5
Source File: TextEditCreation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Puts the edits found in a doc change, tak * @param fChange * @param editsAlreadyCreatedLst * @param docChange * @param rootEdit * @param renameEdits */ private void fillEditsInDocChange(TextChange docChange, MultiTextEdit rootEdit, List<Tuple<List<TextEdit>, String>> renameEdits) { Assert.isTrue(renameEdits.size() > 0); try { for (Tuple<List<TextEdit>, String> t : renameEdits) { TextEdit[] arr = t.o1.toArray(new TextEdit[t.o1.size()]); rootEdit.addChildren(arr); docChange.addTextEditGroup(new TextEditGroup(t.o2, arr)); } } catch (RuntimeException e) { //StringBuffer buf = new StringBuffer("Found occurrences:"); //for (Tuple<TextEdit, String> t : renameEdits) { // buf.append("Offset: "); // buf.append(t.o1.getOffset()); // buf.append("Len: "); // buf.append(t.o1.getLength()); // buf.append("Str: "); // buf.append(t.o2); // buf.append("\n"); //} // //don't bother reporting this to the user (usually happens if we have it the file changes during the analysis). //PydevPlugin.log(buf.toString(), e); throw e; } }
Example 6
Source File: AccessorClassModifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void addKey(NLSSubstitution sub, TextChange change) { String name= Messages.format(NLSMessages.AccessorClassModifier_add_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); change.addTextEditGroup(editGroup); addKey(sub, editGroup); }