/** * Returns the <code>TextChange</code> associated with the given compilation unit. * If the manager does not already manage an association it creates a one. * * @param cu the compilation unit for which the text buffer change is requested * @return the text change associated with the given compilation unit. */ public TextChange get(ICompilationUnit cu) { TextChange result= fMap.get(cu); if (result == null) { result= new CompilationUnitChange(cu.getElementName(), cu); result.setKeepPreviewEdits(fKeepExecutedTextEdits); fMap.put(cu, result); } return result; }
/** * Returns the <code>TextChange</code> associated with the given file. * If the manager does not already manage an association it creates a one. * * @param file the file for which the text buffer change is requested * @return the text change associated with the given file. */ public TextChange get(IFile file) { TextChange result= (TextChange)fMap.get(file); if (result == null) { result= new TextFileChange(file.toString(), file); result.setKeepPreviewEdits(fKeepExecutedTextEdits); result.initializeValidationData(new NullProgressMonitor()); fMap.put(file, result); } return result; }
/** * Returns the <code>TextChange</code> associated with the given compilation * unit. If the manager does not already manage an association it creates a one. * * @param cu * the compilation unit for which the text buffer change is requested * @return the text change associated with the given compilation unit. */ public TextChange get(ICompilationUnit cu) { TextChange result = fMap.get(cu); if (result == null) { result = new CompilationUnitChange(cu.getElementName(), cu); result.setKeepPreviewEdits(fKeepExecutedTextEdits); fMap.put(cu, result); } return result; }
/** * Returns the <code>TextChange</code> associated with the given compilation unit. * If the manager does not already manage an association it creates a one. * * @param cu the compilation unit for which the text buffer change is requested * @return the text change associated with the given compilation unit. */ public TextChange get(ICompilationUnit cu) { TextChange result= fMap.get(cu); if (result == null) { result= new CompilationUnitChange(cu.getElementName(), cu); result.setKeepPreviewEdits(fKeepExecutedTextEdits); fMap.put(cu, result); } return result; }
/** * Returns the <code>TextChange</code> associated with the given compilation unit. * If the manager does not already manage an association it creates a one. * * @param cu the compilation unit for which the text buffer change is requested * @return the text change associated with the given compilation unit. */ public TextChange get(ICompilationUnit cu) { TextChange result= fMap.get(cu); if (result == null) { result= new CompilationUnitChange(cu.getElementName(), cu); result.setKeepPreviewEdits(fKeepExecutedTextEdits); fMap.put(cu, result); } return result; }
/** * Returns the <code>TextChange</code> associated with the given compilation unit. * If the manager does not already manage an association it creates a one. * * @param cu the compilation unit for which the text buffer change is requested * @return the text change associated with the given compilation unit. */ public TextChange get(ICompilationUnit cu) { TextChange result= (TextChange)fMap.get(cu); if (result == null) { result= new CompilationUnitChange(cu.getElementName(), cu); result.setKeepPreviewEdits(fKeepExecutedTextEdits); fMap.put(cu, result); } return result; }
buf.append("<br>"); //$NON-NLS-1$ change.setKeepPreviewEdits(true); IDocument currentContent= change.getCurrentDocument(monitor);
private void checkCUCompleteConditions(final RefactoringStatus status, CompilationUnit currentResolvedCU, ICompilationUnit currentCU, List<RefactoringProcessor> processors) throws CoreException { // check local variable conditions List<RefactoringProcessor> locals = getProcessorsOfType(processors, RenameLocalVariableProcessor.class); if (!locals.isEmpty()) { RenameAnalyzeUtil.LocalAnalyzePackage[] analyzePackages = new RenameAnalyzeUtil.LocalAnalyzePackage[locals.size()]; TextChangeManager manager = new TextChangeManager(); int current = 0; TextChange textChange = manager.get(currentCU); textChange.setKeepPreviewEdits(true); for (Iterator<RefactoringProcessor> iterator = locals.iterator(); iterator.hasNext();) { RenameLocalVariableProcessor localProcessor = (RenameLocalVariableProcessor) iterator.next(); RenameAnalyzeUtil.LocalAnalyzePackage analyzePackage = localProcessor.getLocalAnalyzePackage(); analyzePackages[current] = analyzePackage; for (int i = 0; i < analyzePackage.fOccurenceEdits.length; i++) { TextChangeCompatibility.addTextEdit(textChange, "", analyzePackage.fOccurenceEdits[i], GroupCategorySet.NONE); //$NON-NLS-1$ } current++; } status.merge(RenameAnalyzeUtil.analyzeLocalRenames(analyzePackages, textChange, currentResolvedCU, false)); } /* * There is room for performance improvement here: One could move * shadowing analyzes out of the field and method processors and perform * it here, thus saving on working copy creation. Drawback is increased * heap consumption. */ }
buf.append("<br>"); //$NON-NLS-1$ change.setKeepPreviewEdits(true); IDocument currentContent= change.getCurrentDocument(monitor);
private void checkCUCompleteConditions(final RefactoringStatus status, CompilationUnit currentResolvedCU, ICompilationUnit currentCU, List processors) throws CoreException { // check local variable conditions List locals= getProcessorsOfType(processors, RenameLocalVariableProcessor.class); if (!locals.isEmpty()) { RenameAnalyzeUtil.LocalAnalyzePackage[] analyzePackages= new RenameAnalyzeUtil.LocalAnalyzePackage[locals.size()]; TextChangeManager manager= new TextChangeManager(); int current= 0; TextChange textChange= manager.get(currentCU); textChange.setKeepPreviewEdits(true); for (Iterator iterator= locals.iterator(); iterator.hasNext();) { RenameLocalVariableProcessor localProcessor= (RenameLocalVariableProcessor) iterator.next(); RenameAnalyzeUtil.LocalAnalyzePackage analyzePackage= localProcessor.getLocalAnalyzePackage(); analyzePackages[current]= analyzePackage; for (int i= 0; i < analyzePackage.fOccurenceEdits.length; i++) { TextChangeCompatibility.addTextEdit(textChange, "", analyzePackage.fOccurenceEdits[i], GroupCategorySet.NONE); //$NON-NLS-1$ } current++; } status.merge(RenameAnalyzeUtil.analyzeLocalRenames(analyzePackages, textChange, currentResolvedCU, false)); } /* * There is room for performance improvement here: One could move * shadowing analyzes out of the field and method processors and perform * it here, thus saving on working copy creation. Drawback is increased * heap consumption. */ }
private void checkCUCompleteConditions(final RefactoringStatus status, CompilationUnit currentResolvedCU, ICompilationUnit currentCU, List<RefactoringProcessor> processors) throws CoreException { // check local variable conditions List<RefactoringProcessor> locals= getProcessorsOfType(processors, RenameLocalVariableProcessor.class); if (!locals.isEmpty()) { RenameAnalyzeUtil.LocalAnalyzePackage[] analyzePackages= new RenameAnalyzeUtil.LocalAnalyzePackage[locals.size()]; TextChangeManager manager= new TextChangeManager(); int current= 0; TextChange textChange= manager.get(currentCU); textChange.setKeepPreviewEdits(true); for (Iterator<RefactoringProcessor> iterator= locals.iterator(); iterator.hasNext();) { RenameLocalVariableProcessor localProcessor= (RenameLocalVariableProcessor) iterator.next(); RenameAnalyzeUtil.LocalAnalyzePackage analyzePackage= localProcessor.getLocalAnalyzePackage(); analyzePackages[current]= analyzePackage; for (int i= 0; i < analyzePackage.fOccurenceEdits.length; i++) { TextChangeCompatibility.addTextEdit(textChange, "", analyzePackage.fOccurenceEdits[i], GroupCategorySet.NONE); //$NON-NLS-1$ } current++; } status.merge(RenameAnalyzeUtil.analyzeLocalRenames(analyzePackages, textChange, currentResolvedCU, false)); } /* * There is room for performance improvement here: One could move * shadowing analyzes out of the field and method processors and perform * it here, thus saving on working copy creation. Drawback is increased * heap consumption. */ }
private void checkCUCompleteConditions(final RefactoringStatus status, CompilationUnit currentResolvedCU, ICompilationUnit currentCU, List<RefactoringProcessor> processors) throws CoreException { // check local variable conditions List<RefactoringProcessor> locals= getProcessorsOfType(processors, RenameLocalVariableProcessor.class); if (!locals.isEmpty()) { RenameAnalyzeUtil.LocalAnalyzePackage[] analyzePackages= new RenameAnalyzeUtil.LocalAnalyzePackage[locals.size()]; TextChangeManager manager= new TextChangeManager(); int current= 0; TextChange textChange= manager.get(currentCU); textChange.setKeepPreviewEdits(true); for (Iterator<RefactoringProcessor> iterator= locals.iterator(); iterator.hasNext();) { RenameLocalVariableProcessor localProcessor= (RenameLocalVariableProcessor) iterator.next(); RenameAnalyzeUtil.LocalAnalyzePackage analyzePackage= localProcessor.getLocalAnalyzePackage(); analyzePackages[current]= analyzePackage; for (int i= 0; i < analyzePackage.fOccurenceEdits.length; i++) { TextChangeCompatibility.addTextEdit(textChange, "", analyzePackage.fOccurenceEdits[i], GroupCategorySet.NONE); //$NON-NLS-1$ } current++; } status.merge(RenameAnalyzeUtil.analyzeLocalRenames(analyzePackages, textChange, currentResolvedCU, false)); } /* * There is room for performance improvement here: One could move * shadowing analyzes out of the field and method processors and perform * it here, thus saving on working copy creation. Drawback is increased * heap consumption. */ }
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException { fChange= createTextChange(pm); RefactoringStatus result= new RefactoringStatus(); if (Arrays.asList(getExcludedVariableNames()).contains(fTempName)) result.addWarning(Messages.format(RefactoringCoreMessages.ExtractTempRefactoring_another_variable, fTempName)); result.merge(checkMatchingFragments()); fChange.setKeepPreviewEdits(true); checkNewSource(result); return result; }
@Override public String getAdditionalProposalInfo(IProgressMonitor monitor) throws CoreException { StringBuffer buf= new StringBuffer(); TextChange change = getTextChange(); change.setKeepPreviewEdits(true); IDocument previewDocument = change.getPreviewDocument(monitor); TextEdit rootEdit = change.getPreviewEdit(change.getEdit()); EditAnnotator ea = new EditAnnotator(buf, previewDocument); rootEdit.accept(ea); ea.unchangedUntil(previewDocument.getLength()); // Final pre-existing // region return buf.toString(); }
private PreviewAndRegion getPreviewDocument(TextEditBasedChangeGroup[] changes, IProgressMonitor pm) throws CoreException { IDocument document= new Document(getCurrentDocument(pm).get()); boolean trackChanges= getKeepPreviewEdits(); setKeepPreviewEdits(true); TextEditProcessor processor= changes == ALL_EDITS ? createTextEditProcessor(document, TextEdit.NONE, true) : createTextEditProcessor(document, TextEdit.NONE, changes); try { processor.performEdits(); return new PreviewAndRegion(document, getNewRegion(changes)); } catch (BadLocationException e) { throw Changes.asCoreException(e); } finally { setKeepPreviewEdits(trackChanges); } }
@Override public Object getAdditionalProposalInfo(IProgressMonitor monitor) { StringBuffer buf= new StringBuffer(); try { TextChange change= getTextChange(); change.setKeepPreviewEdits(true); IDocument previewDocument= change.getPreviewDocument(monitor); TextEdit rootEdit= change.getPreviewEdit(change.getEdit()); EditAnnotator ea= new EditAnnotator(buf, previewDocument); rootEdit.accept(ea); ea.unchangedUntil(previewDocument.getLength()); // Final pre-existing region } catch (CoreException e) { JavaPlugin.log(e); } return buf.toString(); }
private PreviewAndRegion getPreviewDocument(TextEditBasedChangeGroup[] changes, IProgressMonitor pm) throws CoreException { IDocument document= new Document(getCurrentDocument(pm).get()); boolean trackChanges= getKeepPreviewEdits(); setKeepPreviewEdits(true); TextEditProcessor processor= changes == ALL_EDITS ? createTextEditProcessor(document, TextEdit.NONE, true) : createTextEditProcessor(document, TextEdit.NONE, changes); try { processor.performEdits(); return new PreviewAndRegion(document, getNewRegion(changes)); } catch (BadLocationException e) { throw Changes.asCoreException(e); } finally { setKeepPreviewEdits(trackChanges); } }
private PreviewAndRegion getPreviewDocument(TextEditBasedChangeGroup[] changes, IProgressMonitor pm) throws CoreException { IDocument document= new Document(getCurrentDocument(pm).get()); boolean trackChanges= getKeepPreviewEdits(); setKeepPreviewEdits(true); TextEditProcessor processor= changes == ALL_EDITS ? createTextEditProcessor(document, TextEdit.NONE, true) : createTextEditProcessor(document, TextEdit.NONE, changes); try { processor.performEdits(); return new PreviewAndRegion(document, getNewRegion(changes)); } catch (BadLocationException e) { throw Changes.asCoreException(e); } finally { setKeepPreviewEdits(trackChanges); } }
@Override public Object getAdditionalProposalInfo(IProgressMonitor monitor) { StringBuffer buf= new StringBuffer(); try { TextChange change= fCUProposal.getTextChange(); change.setKeepPreviewEdits(true); IDocument previewDocument= change.getPreviewDocument(monitor); TextEdit rootEdit= change.getPreviewEdit(change.getEdit()); EditAnnotator ea= new EditAnnotator(buf, previewDocument); rootEdit.accept(ea); ea.unchangedUntil(previewDocument.getLength()); // Final pre-existing region } catch (CoreException e) { JavaManipulationPlugin.log(e); } return buf.toString(); }
MultiTextEdit rootEdit= new MultiTextEdit(); fChange.setEdit(rootEdit); fChange.setKeepPreviewEdits(true);