org.eclipse.ui.texteditor.SimpleMarkerAnnotation Java Examples

The following examples show how to use org.eclipse.ui.texteditor.SimpleMarkerAnnotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaCorrectionProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static boolean hasCorrections(Annotation annotation) {
	if (annotation instanceof IJavaAnnotation) {
		IJavaAnnotation javaAnnotation= (IJavaAnnotation) annotation;
		int problemId= javaAnnotation.getId();
		if (problemId != -1) {
			ICompilationUnit cu= javaAnnotation.getCompilationUnit();
			if (cu != null) {
				return hasCorrections(cu, problemId, javaAnnotation.getMarkerType());
			}
		}
	}
	if (annotation instanceof SimpleMarkerAnnotation) {
		return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker());
	}
	return false;
}
 
Example #2
Source File: CommonAnnotationHover.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public int compare(Annotation o1, Annotation o2)
{
	if (o1 instanceof SimpleMarkerAnnotation && o2 instanceof SimpleMarkerAnnotation)
	{
		// Compare the marker offset first. In case it was not set with an offset, compare via the line numbers.
		IMarker m1 = ((SimpleMarkerAnnotation) o1).getMarker();
		IMarker m2 = ((SimpleMarkerAnnotation) o2).getMarker();
		if (m1 != null && m2 != null)
		{
			// try comparing by offset
			int pos1 = m1.getAttribute(IMarker.CHAR_START, -1);
			int pos2 = m2.getAttribute(IMarker.CHAR_START, -1);
			if (pos1 > -1 && pos2 > -1)
			{
				return pos1 - pos2;
			}
			// in case one of the char-start values was not set, try comparing using the line number
			pos1 = m1.getAttribute(IMarker.LINE_NUMBER, -1);
			pos2 = m2.getAttribute(IMarker.LINE_NUMBER, -1);
			if (pos1 > -1 && pos2 > -1)
			{
				return pos1 - pos2;
			}
		}
	}
	// just return 0, as we can't really compare those.
	return 0;
}
 
Example #3
Source File: JavaCorrectionProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<IJavaCompletionProposal> proposals) {
	IMarker marker= annotation.getMarker();
	IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
	if (res.length > 0) {
		for (int i= 0; i < res.length; i++) {
			proposals.add(new MarkerResolutionProposal(res[i], marker));
		}
	}
}
 
Example #4
Source File: JavaCorrectionProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isQuickFixableType(Annotation annotation) {
	return (annotation instanceof IJavaAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
}
 
Example #5
Source File: MarkerAnnotationAndPosition.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public MarkerAnnotationAndPosition(SimpleMarkerAnnotation markerAnnotation, Position position) {
    this.markerAnnotation = markerAnnotation;
    this.position = position;
}