use of org.eclipse.ui.texteditor.MarkerAnnotation in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonQuickAssistProcessor method getMarkersFor.
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;
}
use of org.eclipse.ui.texteditor.MarkerAnnotation in project bndtools by bndtools.
the class BndMarkerQuickAssistProcessor method computeQuickAssistProposals.
@Override
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext context) {
List<ICompletionProposal> proposals = new LinkedList<ICompletionProposal>();
ISourceViewer viewer = context.getSourceViewer();
@SuppressWarnings("unused") IDocument document = viewer.getDocument();
IAnnotationModel model = viewer.getAnnotationModel();
@SuppressWarnings("rawtypes") Iterator iter = model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation = (Annotation) iter.next();
if (annotation instanceof MarkerAnnotation && canFix(annotation)) {
Position position = model.getPosition(annotation);
if (isAtPosition(context.getOffset(), position)) {
IMarker marker = ((MarkerAnnotation) annotation).getMarker();
String errorType = marker.getAttribute("$bndType", null);
if (errorType != null) {
BuildErrorDetailsHandler handler = BuildErrorDetailsHandlers.INSTANCE.findHandler(errorType);
if (handler != null) {
proposals.addAll(handler.getProposals(marker));
}
}
}
}
}
if (proposals.isEmpty()) {
proposals.add(new NoCompletionsProposal());
}
return proposals.toArray(new ICompletionProposal[0]);
}
use of org.eclipse.ui.texteditor.MarkerAnnotation in project bndtools by bndtools.
the class BndMarkerAnnotationHover method getHoverInfo.
public String getHoverInfo(ISourceViewer sourceViewer, int lineNum) {
@SuppressWarnings("rawtypes") Iterator iter = sourceViewer.getAnnotationModel().getAnnotationIterator();
while (iter.hasNext()) {
Object annotation = iter.next();
if (annotation instanceof MarkerAnnotation) {
IMarker marker = ((MarkerAnnotation) annotation).getMarker();
int markerLine = marker.getAttribute(IMarker.LINE_NUMBER, 0);
// Hover line is zero-based and marker line is one-based. FML.
if (markerLine == lineNum + 1) {
return marker.getAttribute(IMarker.MESSAGE, null);
}
}
}
return null;
}
use of org.eclipse.ui.texteditor.MarkerAnnotation in project bndtools by bndtools.
the class BndResourceMarkerAnnotationModel method createMarkerAnnotation.
@Override
protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
MarkerAnnotation annotation = super.createMarkerAnnotation(marker);
boolean fixable = marker.getAttribute(BuildErrorDetailsHandler.PROP_HAS_RESOLUTIONS, false);
annotation.setQuickFixable(fixable);
return annotation;
}
Aggregations