当前位置: 首页>>代码示例>>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;未经允许,请勿转载。