This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a69b8ca
commit 537f33c
Showing
10 changed files
with
1,345 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
plugin_ide.ui/src-lang/_org/eclipse/jdt/internal/ui/javaeditor/JavaAnnotationIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
Oops, something went wrong.