private void performTextEdit(TextEdit textEdit, IFile file, IProgressMonitor pm) throws CoreException { TextFileChange textFileChange = new TextFileChange("Add import for " + fQualifiedTypeToImport, file); //$NON-NLS-1$ textFileChange.setSaveMode(TextFileChange.KEEP_SAVE_STATE); textFileChange.setEdit(textEdit); textFileChange.perform(pm); }
private TextFileChange getChangeForFile(IFile file, CompositeChange parentChange) { if (fFileChanges.containsKey(file)) return fFileChanges.get(file); MultiTextEdit edit = new MultiTextEdit(); TextFileChange change = new TextFileChange(file.getName(), file); change.setEdit(edit); // mark a plugin.xml or a fragment.xml as PLUGIN2 type so they will be compared // with the PluginContentMergeViewer String textType = file.getName().equals(ICoreConstants.PLUGIN_FILENAME_DESCRIPTOR) || file.getName().equals(ICoreConstants.FRAGMENT_FILENAME_DESCRIPTOR) ? "PLUGIN2" //$NON-NLS-1$ : file.getFileExtension(); change.setTextType(textType); parentChange.add(change); fFileChanges.put(file, change); return change; }
@Override protected TextChange createTextChange() throws CoreException { init(fRefactoring); fRefactoringStatus= fRefactoring.checkFinalConditions(new NullProgressMonitor()); if (fRefactoringStatus.hasFatalError()) { TextFileChange dummyChange= new TextFileChange("fatal error", (IFile) getCompilationUnit().getResource()); //$NON-NLS-1$ dummyChange.setEdit(new InsertEdit(0, "")); //$NON-NLS-1$ return dummyChange; } return (TextChange) fRefactoring.createChange(new NullProgressMonitor()); }
change = new TextFileChange(MessageFormat.format(WizardMessages.JavadocTagRefactoring_2, new String[] {file.getName()}), file); multiedit = new MultiTextEdit(); change.setEdit(multiedit); alledits = (HashSet) entry.getValue(); if(alledits != null) {
@Override protected TextChange createTextChange() throws CoreException { init(fRefactoring); fRefactoringStatus = fRefactoring.checkFinalConditions(new NullProgressMonitor()); if (fRefactoringStatus.hasFatalError()) { TextFileChange dummyChange = new TextFileChange("fatal error", (IFile) getCompilationUnit().getResource()); //$NON-NLS-1$ dummyChange.setEdit(new InsertEdit(0, "")); //$NON-NLS-1$ return dummyChange; } return (TextChange) fRefactoring.createChange(new NullProgressMonitor()); }
@Override protected TextChange createTextChange() throws CoreException { init(fRefactoring); fRefactoringStatus= fRefactoring.checkFinalConditions(new NullProgressMonitor()); if (fRefactoringStatus.hasFatalError()) { TextFileChange dummyChange= new TextFileChange("fatal error", (IFile) getCompilationUnit().getResource()); //$NON-NLS-1$ dummyChange.setEdit(new InsertEdit(0, "")); //$NON-NLS-1$ return dummyChange; } return (TextChange) fRefactoring.createChange(new NullProgressMonitor()); }
@Override public Change createChange(String name, TextEdit textEdit) { TextFileChange textFileChange = new TextFileChange(name, redirectedFile); textFileChange.setSaveMode(TextFileChange.FORCE_SAVE); textFileChange.setEdit(textEdit); textFileChange.setTextType(getURI().fileExtension()); return textFileChange; } }
private TextFileChange getTextChange(BundleTextChangeListener listener, IFile manifest) { TextEdit[] edits = listener.getTextOperations(); if (edits.length == 0) return null; MultiTextEdit edit = new MultiTextEdit(); edit.addChildren(edits); TextFileChange change = new TextFileChange("", manifest); //$NON-NLS-1$ change.setEdit(edit); PDEModelUtility.setChangeTextType(change, manifest); return change; } }
private static Change createChange(BundleTextChangeListener listener, IFile file) { TextEdit[] operations = listener.getTextOperations(); if (operations.length > 0) { TextFileChange change = new TextFileChange("", file); //$NON-NLS-1$ MultiTextEdit edit = new MultiTextEdit(); edit.addChildren(operations); change.setEdit(edit); PDEModelUtility.setChangeTextType(change, file); return change; } return null; }
@Override public Change createChange(String name, TextEdit textEdit) { TextFileChange textFileChange = new TextFileChange(name, file); textFileChange.setSaveMode(TextFileChange.FORCE_SAVE); textFileChange.setEdit(textEdit); textFileChange.setTextType(getURI().fileExtension()); return textFileChange; }
change = new TextFileChange(MessageFormat.format(WizardMessages.JavadocTagRefactoring_2, file.getName()), file); multiedit = new MultiTextEdit(); change.setEdit(multiedit); alledits = entry.getValue(); if (alledits != null) {
classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents)); result.add(classpathUndo);
classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents)); result.add(classpathUndo);
change = new TextFileChange(MessageFormat.format(WizardMessages.JavadocConversionPage_convert_javadoc_tags_in, file.getName()), file); multiedit = new MultiTextEdit(); change.setEdit(multiedit); alledits = entry.getValue(); if (alledits != null) {
classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents)); result.add(classpathUndo);
classpathUndo.setEdit(new ReplaceEdit(0, getFileLength(file), contents)); result.add(classpathUndo);
private Change createChange(IResource resource) { TextFileChange result = null; // creation of DOM/AST from a ICompilationUnit ASTParser parser = ASTParser.newParser(AST.JLS3); // We need the binding to be able to retrieve the types of the expressions in // the visitor (this is used to determine whether the assert() and fail() method // invocations can be found on the AssertJUnit class or not. If not, we don't // rewrite them since they are probably defined on the super class. parser.setResolveBindings(true); parser.setSource((ICompilationUnit) JavaCore.create(resource)); CompilationUnit astRoot = (CompilationUnit) parser.createAST(null); // AST ast = context.getASTRoot().getAST(); AST ast = astRoot.getAST(); ASTRewrite rewriter = new AnnotationRewriter().createRewriter(astRoot, ast); try { TextEdit edit = rewriter.rewriteAST(); result = new TextFileChange(resource.getName(), (IFile) resource); result.setEdit(edit); } catch (JavaModelException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } return result; } }
} else { TextFileChange change = new TextFileChange(MarkerMessages.UnknownAnnotationResolution_2, build); change.setEdit(new MultiTextEdit()); IPath filepath = build.getFullPath(); ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
fChange.setEdit(edit);
change.setEdit(new MultiTextEdit());