protected void addEdits(IDocument doc, TextEdit rootEdit) throws CoreException { super.addEdits(doc, rootEdit); TextEdit edit= new ReplaceEdit(fOffset, fLength, fReplacementString); rootEdit.addChild(edit); }
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException { super.addEdits(document, editRoot); ASTRewrite rewrite= getRewrite(); if (rewrite != null) { try { TextEdit edit= rewrite.rewriteAST(); editRoot.addChild(edit); } catch (IllegalArgumentException e) { throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e)); } } if (fImportRewrite != null) { editRoot.addChild(fImportRewrite.rewriteImports(new NullProgressMonitor())); } }
protected void addEdits(IDocument document, TextEdit rootEdit) throws CoreException { super.addEdits(document, rootEdit); try { Position pos= getUpdatedPosition(document); if (pos != null) { rootEdit.addChild(new ReplaceEdit(pos.getOffset(), pos.getLength(), "")); //$NON-NLS-1$ } else { rootEdit.addChild(new ReplaceEdit(fLocation.getOffset(), fLocation.getLength(), "")); //$NON-NLS-1$ } } catch (BadLocationException e) { throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e)); } }
addEdits(document, rootEdit); return change;
protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); // build a full AST CompilationUnit unit= JavaPlugin.getDefault().getASTProvider().getAST(getCompilationUnit(), ASTProvider.WAIT_YES, null); ASTNode name= NodeFinder.perform(unit, fOffset, fLength); if (name instanceof SimpleName) { SimpleName[] names= LinkedNodeFinder.findByProblems(unit, (SimpleName) name); if (names != null) { for (int i= 0; i < names.length; i++) { SimpleName curr= names[i]; root.addChild(new ReplaceEdit(curr.getStartPosition(), curr.getLength(), fNewName)); } return; } } root.addChild(new ReplaceEdit(fOffset, fLength, fNewName)); } }
protected void addEdits(IDocument doc, TextEdit root) throws CoreException { super.addEdits(doc, root); ICompilationUnit cu= getCompilationUnit(); IPackageFragment parentPack= (IPackageFragment) cu.getParent(); IPackageDeclaration[] decls= cu.getPackageDeclarations(); if (parentPack.isDefaultPackage() && decls.length > 0) { for (int i= 0; i < decls.length; i++) { ISourceRange range= decls[i].getSourceRange(); root.addChild(new DeleteEdit(range.getOffset(), range.getLength())); } return; } if (!parentPack.isDefaultPackage() && decls.length == 0) { String lineDelim= StubUtility.getLineDelimiterUsed(cu); String str= "package " + parentPack.getElementName() + ';' + lineDelim + lineDelim; //$NON-NLS-1$ root.addChild(new InsertEdit(0, str)); return; } root.addChild(new ReplaceEdit(fLocation.getOffset(), fLocation.getLength(), parentPack.getElementName())); }