本文整理汇总了Java中org.eclipse.ui.texteditor.MarkerAnnotation类的典型用法代码示例。如果您正苦于以下问题:Java MarkerAnnotation类的具体用法?Java MarkerAnnotation怎么用?Java MarkerAnnotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MarkerAnnotation类属于org.eclipse.ui.texteditor包,在下文中一共展示了MarkerAnnotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasProblem
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的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;
}
示例2: getManagedImage
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
@Override
public Image getManagedImage(Annotation annotation) {
if (!(annotation instanceof MarkerAnnotation)) {
return null;
}
try {
MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
IMarker marker = markerAnnotation.getMarker();
if (!BookmarksMarkers.MARKER_TYPE.equals(marker.getType())) {
return null;
}
String attributeBookmarkId = (String) marker.getAttribute(BookmarksMarkers.BOOKMARK_ID);
Optional<BookmarkNumber> bookmarkNumber = numberedBookmarks
.getBookmarkNumber(new BookmarkId(attributeBookmarkId));
return getBookmarkAnnotationImage(bookmarkNumber);
} catch (CoreException e) {
return null;
}
}
示例3: getAnnotationsToRemove
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
protected List<Annotation> getAnnotationsToRemove(IProgressMonitor monitor) {
if (monitor.isCanceled() || annotationModel == null) {
return Lists.newArrayList();
}
@SuppressWarnings("unchecked")
Iterator<Annotation> annotationIterator = annotationModel.getAnnotationIterator();
List<Annotation> toBeRemoved = Lists.newArrayList();
while (annotationIterator.hasNext()) {
if (monitor.isCanceled()) {
return toBeRemoved;
}
Annotation annotation = annotationIterator.next();
String type = annotation.getType();
if (isRelevantAnnotationType(type)) {
if (!(annotation instanceof MarkerAnnotation)) {
toBeRemoved.add(annotation);
}
}
}
return toBeRemoved;
}
示例4: canFix
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
public boolean canFix(Annotation annotation) {
if (annotation.isMarkedDeleted())
return false;
// non-persisted annotation
if (annotation instanceof XtextAnnotation) {
XtextAnnotation a = (XtextAnnotation) annotation;
return getResolutionProvider().hasResolutionFor(a.getIssueCode());
}
// persisted markerAnnotation
if (annotation instanceof MarkerAnnotation) {
MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
if (!markerAnnotation.isQuickFixableStateSet())
markerAnnotation.setQuickFixable(getResolutionProvider().hasResolutionFor(
issueUtil.getCode(markerAnnotation)));
return markerAnnotation.isQuickFixable();
}
if (annotation instanceof SpellingAnnotation) {
return true;
}
return false;
}
示例5: getMarkerForLine
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
/**
* Returns one marker which includes the ruler's line of activity.
*/
protected IMarker getMarkerForLine(ISourceViewer aViewer, int aLine)
{
IMarker marker = null;
IAnnotationModel model = aViewer.getAnnotationModel();
if (model != null)
{
Iterator e = model.getAnnotationIterator();
while (e.hasNext())
{
Object o = e.next();
if (o instanceof MarkerAnnotation)
{
MarkerAnnotation a = (MarkerAnnotation) o;
if (compareRulerLine(model.getPosition(a), aViewer.getDocument(), aLine) != 0)
{
marker = a.getMarker();
}
}
}
}
return marker;
}
示例6: addProblemMarker
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
/**
* DOCUMENT ME!
*
* @param aMessage
* DOCUMENT ME!
* @param aLine
* DOCUMENT ME!
*/
public void addProblemMarker(String aMessage, int aLine, int severity)
{
IFile file = ((IFileEditorInput) getEditorInput()).getFile();
try
{
IMarker marker = file.createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.MESSAGE, aMessage);
marker.setAttribute(IMarker.LINE_NUMBER, aLine);
Position pos = new Position(getDocument().getLineOffset(aLine - 1));
getSourceViewer().getAnnotationModel().addAnnotation(new MarkerAnnotation(marker), pos);
}
catch (Exception e)
{
VelocityPlugin.log(e);
}
}
示例7: getMarkerForLine
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
/**
* Returns one marker which includes the ruler's line of activity.
*/
protected IMarker getMarkerForLine(ISourceViewer aViewer, int aLine) {
IMarker marker = null;
IAnnotationModel model = aViewer.getAnnotationModel();
if (model != null) {
Iterator e = model.getAnnotationIterator();
while (e.hasNext()) {
Object o = e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a = (MarkerAnnotation)o;
if (compareRulerLine(model.getPosition(a),
aViewer.getDocument(), aLine) != 0) {
marker = a.getMarker();
}
}
}
}
return marker;
}
示例8: getMarkersFor
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
protected List<IMarker> getMarkersFor(ISourceViewer sourceViewer, int lineOffset, int lineLength) {
List<IMarker> result = Lists.newArrayList();
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
Iterator annotationIter = annotationModel.getAnnotationIterator();
while (annotationIter.hasNext()) {
Object annotation = annotationIter.next();
if (annotation instanceof MarkerAnnotation) {
MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation;
IMarker marker = markerAnnotation.getMarker();
Position markerPosition = annotationModel.getPosition(markerAnnotation);
if (markerPosition != null && markerPosition.overlapsWith(lineOffset, lineLength)) {
result.add(marker);
}
}
}
return result;
}
示例9: updateMarkerViews
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
@Override
protected void updateMarkerViews(Annotation annotation) {
if (annotation instanceof IJavaAnnotation) {
Iterator<IJavaAnnotation> e= ((IJavaAnnotation) annotation).getOverlaidIterator();
if (e != null) {
while (e.hasNext()) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
super.updateMarkerViews((MarkerAnnotation)o);
return;
}
}
}
return;
}
super.updateMarkerViews(annotation);
}
示例10: testIfProblemMarker
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
private void testIfProblemMarker(Annotation annotation) {
if (fIncludesProblemMarkerAnnotations) {
return;
}
if (annotation instanceof JavaMarkerAnnotation) {
fIncludesProblemMarkerAnnotations= ((JavaMarkerAnnotation) annotation).isProblem();
} else if (annotation instanceof MarkerAnnotation) {
try {
IMarker marker= ((MarkerAnnotation) annotation).getMarker();
if (!marker.exists() || marker.isSubtypeOf(IMarker.PROBLEM)) {
fIncludesProblemMarkerAnnotations= true;
}
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:CompilationUnitAnnotationModelEvent.java
示例11: findAndDeleteUnusedImports
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
private void findAndDeleteUnusedImports(PySelection ps, PyEdit edit, IDocumentExtension4 doc, IFile f)
throws Exception {
Iterator<MarkerAnnotationAndPosition> it;
if (edit != null) {
it = edit.getPySourceViewer().getMarkerIterator();
} else {
IMarker markers[] = f.findMarkers(IMiscConstants.PYDEV_ANALYSIS_PROBLEM_MARKER, true, IResource.DEPTH_ZERO);
MarkerAnnotationAndPosition maap[] = new MarkerAnnotationAndPosition[markers.length];
int ix = 0;
for (IMarker m : markers) {
int start = (Integer) m.getAttribute(IMarker.CHAR_START);
int end = (Integer) m.getAttribute(IMarker.CHAR_END);
maap[ix++] =
new MarkerAnnotationAndPosition(new MarkerAnnotation(m), new Position(start, end - start));
}
it = Arrays.asList(maap).iterator();
}
ArrayList<MarkerAnnotationAndPosition> unusedImportsMarkers = getUnusedImports(it);
sortInReverseDocumentOrder(unusedImportsMarkers);
deleteImports(doc, ps, unusedImportsMarkers);
}
示例12: updateMarkerAnnotation
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
protected void updateMarkerAnnotation(IMarker marker) {
Iterator<Annotation> iter = annotationModel.getAnnotationIterator();
for (Annotation ann : (Iterable<Annotation>) () -> iter) {
if(ann instanceof MarkerAnnotation) {
MarkerAnnotation markerAnnotation = (MarkerAnnotation) ann;
if(markerAnnotation.getMarker().equals(marker)) {
Position position = annotationModel.getPosition(markerAnnotation);
// Trigger a model update.
annotationModelExt.modifyAnnotationPosition(markerAnnotation, position);
return;
}
}
}
}
示例13: isIncluded
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
@Override
protected boolean isIncluded(Annotation annotation) {
if (annotation instanceof MarkerAnnotation) {
return true;
}
/* we do not support other annotations */
return false;
}
示例14: getHoverInfo
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
/**
* Find a problem marker from the given line and return its error message.
*
* @param sourceViewer the source viewer
* @param lineNumber line number in the file, starting from zero
* @return the message of the marker of null, if no marker at the specified line
*/
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IDocument document= sourceViewer.getDocument();
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model == null)
return null;
List<String> lineMarkers = null;
Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Annotation o= e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
if (isRulerLine(model.getPosition(a), document, lineNumber)) {
if (lineMarkers == null)
lineMarkers = new LinkedList<String>();
lineMarkers.add(a.getMarker().getAttribute(IMarker.MESSAGE, null));
}
}
}
if (lineMarkers != null)
return getMessage(lineMarkers);
return null;
}
示例15: getIssueFromAnnotation
import org.eclipse.ui.texteditor.MarkerAnnotation; //导入依赖的package包/类
public Issue getIssueFromAnnotation(Annotation annotation) {
if (annotation instanceof XtextAnnotation) {
XtextAnnotation xtextAnnotation = (XtextAnnotation) annotation;
return xtextAnnotation.getIssue();
} else if(annotation instanceof MarkerAnnotation) {
MarkerAnnotation markerAnnotation = (MarkerAnnotation)annotation;
return createIssue(markerAnnotation.getMarker());
} else
return null;
}