Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
LANG: Fix missing annotation hover.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed May 28, 2015
1 parent a69b8ca commit 537f33c
Show file tree
Hide file tree
Showing 10 changed files with 1,345 additions and 38 deletions.
Expand Up @@ -20,14 +20,12 @@
*/
//BM: adapted to ILangEditorTextHover
// TODO: try to find a way to restrict the hover to relevant launches only?
public class DelegatingDebugTextHover implements ILangEditorTextHover<Object>, ITextHoverExtension, ITextHoverExtension2 {
public class DelegatingDebugTextHover
implements ILangEditorTextHover<Object>, ITextHoverExtension, ITextHoverExtension2 {

private IEditorPart fEditor;
private ICEditorTextHover fDelegate;

/*
* @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
*/
@Override
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
fDelegate = getDelegate();
Expand All @@ -37,9 +35,6 @@ public IRegion getHoverRegion(ITextViewer viewer, int offset) {
return null;
}

/*
* @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
*/
@Override
@SuppressWarnings("deprecation")
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
Expand All @@ -50,9 +45,6 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
return null;
}

/*
* @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
*/
@Override
@SuppressWarnings("deprecation")
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
Expand All @@ -67,14 +59,6 @@ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
return null;
}

@Override
public Object getHoverInfo2_do(ITextViewer textViewer, IRegion hoverRegion) {
return getHoverInfo2(textViewer, hoverRegion);
}

/*
* @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
*/
@Override
public IInformationControlCreator getHoverControlCreator() {
if (fDelegate instanceof ITextHoverExtension) {
Expand All @@ -83,9 +67,6 @@ public IInformationControlCreator getHoverControlCreator() {
return null;
}

/*
* @see org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover#setEditor(org.eclipse.ui.IEditorPart)
*/
@Override
public final void setEditor(IEditorPart editor) {
fEditor = editor;
Expand Down
@@ -0,0 +1,88 @@
/*******************************************************************************
* Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package _org.eclipse.jdt.internal.ui.javaeditor;

import java.util.Iterator;

import org.eclipse.core.runtime.CoreException;

import org.eclipse.core.resources.IMarker;

import org.eclipse.jface.text.source.Annotation;

import org.eclipse.ui.texteditor.MarkerAnnotation;


/**
* Filters problems based on their types.
*/
public class JavaAnnotationIterator implements Iterator<Annotation> {

private Iterator<Annotation> fIterator;
private Annotation fNext;
private boolean fReturnAllAnnotations;


/**
* Returns a new JavaAnnotationIterator.
* @param parent the parent iterator to iterate over annotations
* @param returnAllAnnotations whether to return all annotations or just problem annotations
*/
public JavaAnnotationIterator(Iterator<Annotation> parent, boolean returnAllAnnotations) {
fReturnAllAnnotations= returnAllAnnotations;
fIterator= parent;
skip();
}

private void skip() {
while (fIterator.hasNext()) {
Annotation next= fIterator.next();

if (next.isMarkedDeleted())
continue;

if (fReturnAllAnnotations || /*next instanceof IJavaAnnotation ||*/ isProblemMarkerAnnotation(next)) {
fNext= next;
return;
}
}
fNext= null;
}

private static boolean isProblemMarkerAnnotation(Annotation annotation) {
if (!(annotation instanceof MarkerAnnotation))
return false;
try {
return(((MarkerAnnotation)annotation).getMarker().isSubtypeOf(IMarker.PROBLEM));
} catch (CoreException e) {
return false;
}
}

@Override
public boolean hasNext() {
return fNext != null;
}

@Override
public Annotation next() {
try {
return fNext;
} finally {
skip();
}
}

@Override
public void remove() {
throw new UnsupportedOperationException();
}
}

0 comments on commit 537f33c

Please sign in to comment.