當前位置: 首頁>>代碼示例>>Java>>正文


Java IAnnotationModel類代碼示例

本文整理匯總了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);
		});
	}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:20,代碼來源:OwnResourceValidatorAwareValidatingEditorCallback.java

示例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;
}
 
開發者ID:angelozerr,項目名稱:ec4e,代碼行數:27,代碼來源:EditorConfigTextHover.java

示例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;
}
 
開發者ID:Imhotup,項目名稱:LibertyEiffel-Eclipse-Plugin,代碼行數:22,代碼來源:EiffelAnnotationHOver.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:DwprofileQuickAssistProcessor.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:HyexpressionQuickAssistProcessor.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:HyvalidityformulaQuickAssistProcessor.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:HydatavalueQuickAssistProcessor.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:HymappingQuickAssistProcessor.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:HyconstraintsQuickAssistProcessor.java

示例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;
}
 
開發者ID:DarwinSPL,項目名稱:DarwinSPL,代碼行數:25,代碼來源:HymanifestQuickAssistProcessor.java

示例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);
  }
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:28,代碼來源:CoverageAnnotationModel.java

示例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);
				}
			}
		}
	}
}
 
開發者ID:curiosag,項目名稱:ftc,代碼行數:18,代碼來源:TweakedLinkedModeUI.java

示例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;
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:31,代碼來源:SpellChecker.java

示例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;
            }
    };
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:29,代碼來源:TexlipseAnnotationUpdater.java

示例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);
        }

    }
 
開發者ID:roundrop,項目名稱:ermasterr,代碼行數:23,代碼來源:TestEditor.java


注:本文中的org.eclipse.jface.text.source.IAnnotationModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。