本文整理汇总了Java中org.eclipse.jface.text.source.IAnnotationModel类的典型用法代码示例。如果您正苦于以下问题:Java IAnnotationModel类的具体用法?Java IAnnotationModel怎么用?Java IAnnotationModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAnnotationModel类属于org.eclipse.jface.text.source包,在下文中一共展示了IAnnotationModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newValidationJob
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private ValidationJob newValidationJob(final XtextEditor editor) {
final IXtextDocument document = editor.getDocument();
final IAnnotationModel annotationModel = editor.getInternalSourceViewer().getAnnotationModel();
final IssueResolutionProvider issueResolutionProvider = getService(editor, IssueResolutionProvider.class);
final MarkerTypeProvider markerTypeProvider = getService(editor, MarkerTypeProvider.class);
final MarkerCreator markerCreator = getService(editor, MarkerCreator.class);
final IValidationIssueProcessor issueProcessor = new CompositeValidationIssueProcessor(
new AnnotationIssueProcessor(document, annotationModel, issueResolutionProvider),
new MarkerIssueProcessor(editor.getResource(), markerCreator, markerTypeProvider));
return editor.getDocument().modify(resource -> {
final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
return new ValidationJob(resourceValidator, editor.getDocument(), issueProcessor, ALL);
});
}
示例2: hasProblem
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
/***
* Returns true if it exists a marker annotation in the given offset and false
* otherwise.
*
* @param textViewer
* @param offset
* @return true if it exists a marker annotation in the given offset and false
* otherwise.
*/
private static boolean hasProblem(ITextViewer textViewer, int offset) {
if (!(textViewer instanceof ISourceViewer)) {
return false;
}
IAnnotationModel annotationModel = ((ISourceViewer) textViewer).getAnnotationModel();
Iterator<Annotation> iter = (annotationModel instanceof IAnnotationModelExtension2)
? ((IAnnotationModelExtension2) annotationModel).getAnnotationIterator(offset, 1, true, true)
: annotationModel.getAnnotationIterator();
while (iter.hasNext()) {
Annotation ann = iter.next();
if (ann instanceof MarkerAnnotation) {
return true;
}
}
return false;
}
示例3: getHoverInfo
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IAnnotationModel model = sourceViewer.getAnnotationModel();
Iterator iterator = model.getAnnotationIterator();
while (iterator.hasNext()) {
Annotation annotation = (Annotation) iterator.next();
Position position = model.getPosition(annotation);
try {
int lineOfAnnotation = sourceViewer.getDocument().
getLineOfOffset(position.getOffset());
if (lineNumber == lineOfAnnotation) {
return annotation.getText();
}
} catch (BadLocationException e) {
// TODO: handle exception
}
}
return null;
}
示例4: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> foundFixes = new ArrayList<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<de.darwinspl.preferences.resource.dwprofile.IDwprofileQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例5: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例6: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> foundFixes = new ArrayList<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例7: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> foundFixes = new ArrayList<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例8: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.feature.mapping.resource.hymapping.IHymappingQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例9: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> foundFixes = new ArrayList<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例10: getQuickFixes
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> getQuickFixes(ISourceViewer sourceViewer, int offset, int length) {
List<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> foundFixes = new ArrayList<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix>();
IAnnotationModel model = annotationModelProvider.getAnnotationModel();
if (model == null) {
return foundFixes;
}
Iterator<?> iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
Position position = model.getPosition(annotation);
if (offset >= 0) {
if (!position.overlapsWith(offset, length)) {
continue;
}
}
Collection<eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestQuickFix> quickFixes = getQuickFixes(annotation);
if (quickFixes != null) {
foundFixes.addAll(quickFixes);
}
}
return foundFixes;
}
示例11: attach
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
/**
* 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 attach a annotation model to
*/
public static void attach(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
// there may be text editors without document providers (SF #1725100)
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());
CoverageAnnotationModel coveragemodel = (CoverageAnnotationModel) modelex
.getAnnotationModel(KEY);
if (coveragemodel == null) {
coveragemodel = new CoverageAnnotationModel(editor, document);
modelex.addAnnotationModel(KEY, coveragemodel);
}
}
示例12: ensureAnnotationModelInstalled
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private void ensureAnnotationModelInstalled() {
LinkedPositionAnnotations lpa = fCurrentTarget.fAnnotationModel;
if (lpa != null) {
ITextViewer viewer = fCurrentTarget.getViewer();
if (viewer instanceof ISourceViewer) {
ISourceViewer sv = (ISourceViewer) viewer;
IAnnotationModel model = sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext = (IAnnotationModelExtension) model;
IAnnotationModel ourModel = ext.getAnnotationModel(getUniqueKey());
if (ourModel == null) {
ext.addAnnotationModel(getUniqueKey(), lpa);
}
}
}
}
}
示例13: getMarkerPosition
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
/**
* Returns the actual position of <i>marker</i> or null if the marker was
* deleted. Code inspired by
* @param marker
* @param sourceViewer
* @return
*/
private static int[] getMarkerPosition(IMarker marker, ISourceViewer sourceViewer) {
int[] p = new int[2];
p[0] = marker.getAttribute(IMarker.CHAR_START, -1);
p[1] = marker.getAttribute(IMarker.CHAR_END, -1);
// look up the current range of the marker when the document has been edited
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model instanceof AbstractMarkerAnnotationModel) {
AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
Position pos= markerModel.getMarkerPosition(marker);
if (pos != null && !pos.isDeleted()) {
// use position instead of marker values
p[0] = pos.getOffset();
p[1] = pos.getOffset() + pos.getLength();
}
if (pos != null && pos.isDeleted()) {
// do nothing if position has been deleted
return null;
}
}
return p;
}
示例14: createMatchReferenceJob
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
/**
* Creates and returns a background job which searches and highlights all \label and \*ref.
* @param document
* @param model
* @param refName The name of the reference
* @return The job
*/
private Job createMatchReferenceJob(final IDocument document, final IAnnotationModel model, final String refName) {
return
new Job("Update Annotations") {
public IStatus run(IProgressMonitor monitor) {
String text = document.get();
String refNameRegExp = refName.replaceAll("\\*", "\\\\*");
final String simpleRefRegExp = "\\\\([a-zA-Z]*ref|label)\\s*\\{" + refNameRegExp + "\\}";
Matcher m = (Pattern.compile(simpleRefRegExp)).matcher(text);
while (m.find()) {
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
IRegion match = LatexParserUtils.getCommand(text, m.start());
//Test if it is a real LaTeX command
if (match != null) {
IRegion fi = new Region(m.start(), m.end()-m.start());
createNewAnnotation(fi, "References", model);
}
}
return Status.OK_STATUS;
}
};
}
示例15: initializeSourceViewer
import org.eclipse.jface.text.source.IAnnotationModel; //导入依赖的package包/类
private void initializeSourceViewer(final IEditorInput input) {
final IDocumentProvider documentProvider = getDocumentProvider();
final IAnnotationModel model = documentProvider.getAnnotationModel(input);
final IDocument document = documentProvider.getDocument(input);
if (document != null) {
fSourceViewer.setDocument(document, model);
fSourceViewer.setEditable(isEditable());
fSourceViewer.showAnnotations(model != null);
}
if (fElementStateListener instanceof IElementStateListenerExtension) {
boolean isStateValidated = false;
if (documentProvider instanceof IDocumentProviderExtension)
isStateValidated = ((IDocumentProviderExtension) documentProvider).isStateValidated(input);
final IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
extension.elementStateValidationChanged(input, isStateValidated);
}
}