aboutsummaryrefslogtreecommitdiff
path: root/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-11-30 00:49:42 +0100
committerReinier Zwitserloot <reinier@tipit.to>2009-11-30 00:49:42 +0100
commitdfa401018d0eff370b34f1e9d7bb1d5fd498a631 (patch)
tree109c13994d6aaffce600fd300af88578bd892313 /src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
parent29c2ba1bbba7393423463b6c92da2068b6fea7bb (diff)
downloadlombok-dfa401018d0eff370b34f1e9d7bb1d5fd498a631.tar.gz
lombok-dfa401018d0eff370b34f1e9d7bb1d5fd498a631.tar.bz2
lombok-dfa401018d0eff370b34f1e9d7bb1d5fd498a631.zip
All basic elements of netbeans support are here except the actual agent part.
Diffstat (limited to 'src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java')
-rw-r--r--src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java55
1 files changed, 50 insertions, 5 deletions
diff --git a/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java b/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
index c12e6dad..aea01b1a 100644
--- a/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
+++ b/src/netbeansAgent/lombok/netbeans/agent/PatchFixes.java
@@ -2,10 +2,13 @@ package lombok.netbeans.agent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
import javax.lang.model.element.Element;
import org.netbeans.api.java.source.ClasspathInfo;
+import org.openide.util.Lookup;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Tree;
@@ -13,6 +16,7 @@ import com.sun.source.util.SourcePositions;
import com.sun.source.util.TaskListener;
import com.sun.source.util.Trees;
import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.Context;
public class PatchFixes {
@@ -65,13 +69,54 @@ public class PatchFixes {
//Contributed by Jan Lahoda (jlahoda@netbeans.org)
//Turned into a patch script by rzwitserloot.
//see http://code.google.com/p/projectlombok/issues/detail?id=20#c3
- public static void addTaskListenerWhenCallingJavac(Context context, ClasspathInfo cpInfo) {
- TaskListenerProvider p = /* Lookup.getDefault().lookup(TaskListenerProvider.class) */;
+ public static void addTaskListenerWhenCallingJavac(JavacTaskImpl task, ClasspathInfo cpInfo) {
+ TaskListenerProvider p = Lookup.getDefault().lookup(TaskListenerProvider.class);
if (p != null) {
- TaskListener l = p.create(context, cpInfo);
+ TaskListener l = p.create(task.getContext(), cpInfo);
task.setTaskListener(l);
}
-
- return;
+ }
+
+ //Contributed by Jan Lahoda (jlahoda@netbeans.org)
+ //Turned into a patch script by rzwitserloot.
+ //see http://code.google.com/p/projectlombok/issues/detail?id=20#c3
+ public static Iterator<JCTree> filterGenerated(final Iterator<JCTree> it) {
+ return new Iterator<JCTree>() {
+ private JCTree next;
+ private boolean hasNext;
+
+ {
+ calc();
+ }
+
+ private void calc() {
+ while (it.hasNext()) {
+ JCTree n = it.next();
+ if (n.pos != -1) {
+ hasNext = true;
+ next = n;
+ return;
+ }
+ }
+
+ hasNext = false;
+ next = null;
+ }
+
+ @Override public boolean hasNext() {
+ return hasNext;
+ }
+
+ @Override public JCTree next() {
+ if (!hasNext) throw new NoSuchElementException();
+ JCTree n = next;
+ calc();
+ return n;
+ }
+
+ @Override public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
}
}