use of org.eclipse.jface.text.source.IAnnotationModel in project linuxtools by eclipse.
the class RpmMacroOccurrencesUpdater method update.
/**
* Updates the drawn annotations.
*
* @param viewer
* The viewer to get the document and annotation model from
*/
public void update(ISourceViewer viewer) {
try {
IDocument document = viewer.getDocument();
IAnnotationModel model = viewer.getAnnotationModel();
if (document == null || model == null) {
return;
}
removeOldAnnotations(model);
String currentSelectedWord = getWordAtSelection(fEditor.getSelectionProvider().getSelection(), document);
if (isMacro(currentSelectedWord)) {
Specfile spec = fEditor.getSpecfile();
SpecfileDefine define = spec.getDefine(currentSelectedWord);
// $NON-NLS-1$
String word = currentSelectedWord + ": ";
if (define != null) {
word += define.getStringValue();
} else {
// If there's no such define we try to see if it corresponds
// to
// a Source or Patch declaration
String retrivedValue = RPMUtils.getSourceOrPatchValue(spec, currentSelectedWord.toLowerCase());
if (retrivedValue != null) {
word += retrivedValue;
} else {
// If it does not correspond to a Patch or Source macro,
// try to find it
// in the macro proposals list.
retrivedValue = RPMUtils.getMacroValueFromMacroList(currentSelectedWord);
if (retrivedValue != null) {
word += retrivedValue;
}
}
}
createNewAnnotations(currentSelectedWord, word, document, model);
}
} catch (BadLocationException e) {
SpecfileLog.logError(e);
}
}
use of org.eclipse.jface.text.source.IAnnotationModel in project linuxtools by eclipse.
the class GcovAnnotationModel method clear.
public static void clear(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
if (provider == null) {
return;
}
IAnnotationModel model = provider.getAnnotationModel(editor.getEditorInput());
if (!(model instanceof IAnnotationModelExtension)) {
return;
}
IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;
IAnnotationModel coverageModel = modelex.getAnnotationModel(KEY);
if (coverageModel instanceof GcovAnnotationModel) {
((GcovAnnotationModel) coverageModel).clear();
}
}
use of org.eclipse.jface.text.source.IAnnotationModel in project linuxtools by eclipse.
the class GcovAnnotationModel method attach.
/**
* Attaches a coverage annotation model for the given editor if the editor
* can be annotated. Does nothing if the model is already attached.
*
* @param editor Editor to which an annotation model should be attached
*/
public static void attach(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
if (provider == null) {
return;
}
IAnnotationModel model = provider.getAnnotationModel(editor.getEditorInput());
if (!(model instanceof IAnnotationModelExtension)) {
return;
}
IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;
IDocument document = provider.getDocument(editor.getEditorInput());
GcovAnnotationModel coveragemodel = (GcovAnnotationModel) modelex.getAnnotationModel(KEY);
if (coveragemodel == null) {
coveragemodel = new GcovAnnotationModel(editor, document);
modelex.addAnnotationModel(KEY, coveragemodel);
} else {
coveragemodel.updateAnnotations(false);
}
}
use of org.eclipse.jface.text.source.IAnnotationModel in project linuxtools by eclipse.
the class FileTestCase method getFailures.
protected ArrayList<SpecfileTestFailure> getFailures() {
ArrayList<SpecfileTestFailure> failures = new ArrayList<>();
IAnnotationModel model = SpecfileEditor.getSpecfileDocumentProvider().getAnnotationModel(fei);
for (Iterator<Annotation> i = model.getAnnotationIterator(); i.hasNext(); ) {
Annotation annotation = i.next();
Position p = model.getPosition(annotation);
SpecfileTestFailure t = new SpecfileTestFailure(annotation, p);
failures.add(t);
}
return failures;
}
use of org.eclipse.jface.text.source.IAnnotationModel in project liferay-ide by liferay.
the class InputContext method dispose.
public void dispose() {
IAnnotationModel amodel = _fDocumentProvider.getAnnotationModel(_fEditorInput);
if (amodel != null) {
amodel.disconnect(_fDocumentProvider.getDocument(_fEditorInput));
}
_fDocumentProvider.removeElementStateListener(_fElementListener);
_fDocumentProvider.disconnect(_fEditorInput);
if ((_fModelListener != null) && _fModel instanceof IModelChangeProvider) {
((IModelChangeProvider) _fModel).removeModelChangedListener(_fModelListener);
}
if (_fModel != null) {
_fModel.dispose();
}
}
Aggregations