use of org.eclipse.ltk.core.refactoring.TextChange in project webtools.sourceediting by eclipse.
the class TextChangeManager method get.
/**
* 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;
}
use of org.eclipse.ltk.core.refactoring.TextChange in project webtools.sourceediting by eclipse.
the class MakeTypeGlobalChange method getChange.
public TextChange getChange(IFile file) {
TextChange result = (TextChange) fChanges.get(file);
if (result == null) {
result = new TextFileChange(file.getName(), file);
fChanges.put(file, result);
}
return result;
}
use of org.eclipse.ltk.core.refactoring.TextChange in project flux by eclipse.
the class CUCorrectionProposal method createTextChange.
protected TextChange createTextChange() throws CoreException {
ICompilationUnit cu = getCompilationUnit();
String name = getName();
TextChange change;
if (!cu.getResource().exists()) {
String source;
try {
source = cu.getSource();
} catch (JavaModelException e) {
JavaPlugin.log(e);
// empty
source = new String();
}
Document document = new Document(source);
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu));
change = new DocumentChange(name, document);
} else {
CompilationUnitChange cuChange = new CompilationUnitChange(name, cu);
cuChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
change = cuChange;
}
TextEdit rootEdit = new MultiTextEdit();
change.setEdit(rootEdit);
// initialize text change
IDocument document = change.getCurrentDocument(new NullProgressMonitor());
addEdits(document, rootEdit);
return change;
}
use of org.eclipse.ltk.core.refactoring.TextChange in project flux by eclipse.
the class CUCorrectionProposal method getAdditionalProposalInfo.
@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);
// Final pre-existing region
ea.unchangedUntil(previewDocument.getLength());
} catch (CoreException e) {
JavaPlugin.log(e);
}
return buf.toString();
}
use of org.eclipse.ltk.core.refactoring.TextChange in project xtext-eclipse by eclipse.
the class TextChangeCombiner method createTextChange.
protected TextChange createTextChange(Object key, String textType) {
TextChange change = null;
if (key instanceof ICompilationUnit)
change = new CompilationUnitChange("Combined CompilationUnitChange", (ICompilationUnit) key);
else if (key instanceof IFile)
change = new TextFileChange("Combined TextFileChange", (IFile) key);
else if (key instanceof ITextEditor)
change = new EditorDocumentChange("Combined DocumentChange", (ITextEditor) key, false);
else
LOG.error("Error creating change for " + key.getClass().getName());
if (change != null) {
MultiTextEdit edits = new MultiTextEdit();
change.setEdit(edits);
change.setTextType(textType);
}
return change;
}
Aggregations