You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2017/10/04 19:41:13 UTC

[01/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Repository: incubator-netbeans
Updated Branches:
  refs/heads/jdk-javac [created] ffc0de5a1


http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
index 92cd8a2..ef76535 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
@@ -51,7 +51,7 @@ import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -73,7 +73,8 @@ public abstract class BulkSearchTestPerformer extends NbTestCase {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        //XXX:
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
     }
 
 //    public static TestSuite suite() {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java b/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
index 2719b1e..2d22c39 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.util.Arrays;
 import java.util.Collection;
@@ -1565,7 +1565,7 @@ public class CopyFinderTest extends NbTestCase {
 
         for (final String name : remappableVariables.split(",")) {
             if (name.isEmpty()) continue;
-            new TreePathScanner<Object, Object>() {
+            new ErrorAwareTreePathScanner<Object, Object>() {
                 @Override
                 public Object visitVariable(VariableTree node, Object p) {
                     if (node.getName().contentEquals(name)) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/testng.ui/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/testng.ui/nbproject/project.properties b/testng.ui/nbproject/project.properties
index 7f641b7..375b088 100644
--- a/testng.ui/nbproject/project.properties
+++ b/testng.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/websvc.saas.codegen.java/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/websvc.saas.codegen.java/nbproject/project.properties b/websvc.saas.codegen.java/nbproject/project.properties
index 6de45e1..7fb2198 100644
--- a/websvc.saas.codegen.java/nbproject/project.properties
+++ b/websvc.saas.codegen.java/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.autoload=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
----------------------------------------------------------------------
diff --git a/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java b/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
index 660239d..ae254f4 100644
--- a/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
+++ b/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.NewClassTree;
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayDeque;
 import java.util.HashMap;
@@ -92,7 +92,7 @@ public final class WhiteListSupport {
     }
 
     //<editor-fold defaultstate="collapsed" desc="Private implementation">
-    private static class WhiteListScanner extends TreePathScanner<Void, Map<Tree,WhiteListQuery.Result>> {
+    private static class WhiteListScanner extends ErrorAwareTreePathScanner<Void, Map<Tree,WhiteListQuery.Result>> {
 
         private final Trees trees;
         private final Callable<Boolean> cancel;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/xml.jaxb/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/xml.jaxb/nbproject/project.properties b/xml.jaxb/nbproject/project.properties
index 1dcd75d..8f48df1 100644
--- a/xml.jaxb/nbproject/project.properties
+++ b/xml.jaxb/nbproject/project.properties
@@ -28,3 +28,4 @@ disable.qa-functional.tests=true
 
 test.config.stableBTD.includes=**/*Test.class
 test.config.stableBTD.excludes=org/netbeans/test/**/*
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/xml.tools.java/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/xml.tools.java/nbproject/project.properties b/xml.tools.java/nbproject/project.properties
index a25463a..450b8b0 100644
--- a/xml.tools.java/nbproject/project.properties
+++ b/xml.tools.java/nbproject/project.properties
@@ -17,3 +17,4 @@
 javac.compilerargs=-Xlint -Xlint:-serial
 disable.qa-functional.tests=true
 javac.source=1.5
+requires.nb.javac=true


[12/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java b/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
index 936eaef..9b98b86 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.LabeledStatementTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 import java.awt.Color;
 import java.awt.event.KeyEvent;
@@ -413,7 +413,7 @@ public class InstantRenamePerformer implements DocumentListener, KeyListener {
         if (labeledStatement.getLeaf().getKind() == Kind.LABELED_STATEMENT) {
             result.add(org.netbeans.modules.java.editor.base.semantic.Utilities.findIdentifierSpan(info, document, labeledStatement));
             final Name label = ((LabeledStatementTree)labeledStatement.getLeaf()).getLabel();
-            new TreePathScanner <Void, Void>() {
+            new ErrorAwareTreePathScanner <Void, Void>() {
                 @Override
                 public Void visitBreak(BreakTree node, Void p) {
                     if (node.getLabel() != null && label.contentEquals(node.getLabel())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
----------------------------------------------------------------------
diff --git a/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java b/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
index 2f28db2..bf44269 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
@@ -38,12 +38,13 @@ import org.netbeans.api.java.source.CompilationController;
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.editor.java.GoToSupport.UiUtilsCaller;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.parsing.JavacParser;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
@@ -68,7 +69,7 @@ public class GoToSupportTest extends NbTestCase {
     protected void setUp() throws Exception {
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
         org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = false;
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
----------------------------------------------------------------------
diff --git a/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java b/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
index 0887c79..9c0181a 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
@@ -22,7 +22,7 @@ package org.netbeans.modules.editor.java;
 import java.util.ArrayList;
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.NewClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
@@ -226,7 +226,7 @@ public class UtilitiesTest extends NbTestCase {
             public void run(final CompilationController cc) throws Exception {
                 cc.toPhase(Phase.RESOLVED);
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (!cc.getTreeUtilities().isSynthetic(getCurrentPath())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
----------------------------------------------------------------------
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
index cb5cfdb..ef07d10 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
@@ -53,7 +53,7 @@ import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.java.source.WorkingCopy;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.editor.codegen.ui.ElementNode;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 
@@ -68,7 +68,7 @@ public class DelegateMethodGeneratorTest extends NbTestCase {
     }
 
     protected void setUp() throws Exception {
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
     }
 
     public void testFindUsableFields() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
----------------------------------------------------------------------
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
index 502e583..843a367 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
@@ -51,6 +51,7 @@ import org.netbeans.api.java.lexer.JavaTokenId;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.CompilationController;
 import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.gen.WhitespaceIgnoringDiff;
 import org.netbeans.api.lexer.Language;
@@ -60,7 +61,7 @@ import org.netbeans.modules.editor.completion.CompletionItemComparator;
 import org.netbeans.modules.editor.java.JavaCompletionProvider;
 import org.netbeans.modules.editor.java.JavaKit;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.netbeans.modules.java.source.parsing.JavacParserFactory;
 import org.netbeans.modules.java.source.usages.BinaryAnalyser;
@@ -100,7 +101,7 @@ public class CompletionTestBase extends NbTestCase {
         System.setProperty("org.openide.util.Lookup", Lkp.class.getName());
         Assert.assertEquals(Lkp.class, Lookup.getDefault().getClass());
 
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
 
     static final int FINISH_OUTTIME = 5 * 60 * 1000;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
----------------------------------------------------------------------
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
index 39a0994..c689e06 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
@@ -32,9 +32,10 @@ import org.netbeans.api.java.source.CompilationInfo;
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.source.TestUtil;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -120,8 +121,8 @@ public class IsOverriddenAnnotationCreatorTest extends NbTestCase {
 
         ComputeOverriders.dependenciesOverride = Collections.singletonMap(sourceRoot.getURL(), Collections.<URL>emptyList());
         ComputeOverriders.reverseSourceRootsInOrderOverride = Arrays.asList(sourceRoot.getURL());
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
     
     //does not work as recursive lookup does not work:

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
----------------------------------------------------------------------
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
index 3a31049..79d8a5b 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
@@ -419,13 +419,14 @@ public class DeclarativeHintsParser {
         if (javacApiJar != null) {
             Logger.getLogger(DeclarativeHintsParser.class.getName()).log(Level.FINE, "javacApiJar={0}", javacApiJar);
             File aj = FileUtil.archiveOrDirForURL(javacApiJar);
-            res = ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(aj));
-            javacApiClasspath = new WeakReference<>(res);
-            return res;
-        } else {
-            javacApiClasspath = NONE;
-            return null;
+            if (aj != null) {
+                res = ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(aj));
+                javacApiClasspath = new WeakReference<>(res);
+                return res;
+            }
         }
+        javacApiClasspath = NONE;
+        return null;
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
----------------------------------------------------------------------
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
index abe2cab..46f8391 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.java.hints.declarative.conditionapi;
 
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collection;
 import java.util.LinkedList;
 import javax.lang.model.element.Element;
@@ -69,7 +69,7 @@ public final class Matcher {
 
         for (TreePath toSearch : paths) {
             //XXX:
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override
                 public Void scan(Tree tree, Void p) {
                     if (tree == null) return null;
@@ -98,7 +98,7 @@ public final class Matcher {
         }
 
         for (TreePath tp : ctx.getVariable(in)) {
-            boolean occurs = new TreePathScanner<Boolean, Void>() {
+            boolean occurs = new ErrorAwareTreePathScanner<Boolean, Void>() {
                 @Override
                 public Boolean scan(Tree tree, Void p) {
                     if (tree == null) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
----------------------------------------------------------------------
diff --git a/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java b/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
index c94dc22..df3d3ff 100644
--- a/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
+++ b/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
@@ -37,7 +37,7 @@ import org.netbeans.api.java.source.SourceUtilsTestUtil;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -57,7 +57,8 @@ public class EvaluationSpanTaskTest extends NbTestCase {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        //XXX:
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
     }
 
     public void testHintConditions() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
----------------------------------------------------------------------
diff --git a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
index 6e285e0..b792027 100644
--- a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
+++ b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
@@ -99,7 +99,6 @@ import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker;
 import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
 import org.netbeans.modules.java.hints.test.Utilities.TestLookup;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.parsing.api.indexing.IndexingManager;
 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
 import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
@@ -224,7 +223,6 @@ public class HintTest {
         MimeTypes.setAllMimeTypes(amt);
         org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
 
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         testPreferences = new TempPreferences();
         hintSettings = new HintsSettings() {
             @Override public boolean isEnabled(HintMetadata hint) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints.ui/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.hints.ui/nbproject/project.properties b/java.hints.ui/nbproject/project.properties
index 59289f0..84013ec 100644
--- a/java.hints.ui/nbproject/project.properties
+++ b/java.hints.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 javac.source=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
 spec.version.base=1.19.0
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java b/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
index ef797e9..a2b0eee 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.TypeCastTree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
@@ -194,7 +194,7 @@ public class ArithmeticUtilities {
         
     }
 
-    private static final class VisitorImpl extends TreePathScanner<Object, Void> {
+    private static final class VisitorImpl extends ErrorAwareTreePathScanner<Object, Void> {
         // PENDING: instanceof String could be handled
 	private static final Set<Kind> ACCEPTED_KINDS = EnumSet.of(
 		MULTIPLY, DIVIDE, REMAINDER, PLUS, MINUS,

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java b/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
index f0ff80a..c666e92 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.CompoundAssignmentTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.LinkedList;
@@ -169,7 +169,7 @@ public class AssignmentIssues {
                 new ReplaceAssignmentFix(NbBundle.getMessage(AssignmentIssues.class, "FIX_ReplaceAssignmentWithOperatorAssignment", path.getLeaf()), TreePathHandle.create(path, context.getInfo())).toEditorFix()); //NOI18N
     }
 
-    private static final class AssignmentFinder extends TreePathScanner<Void, List<TreePath>> {
+    private static final class AssignmentFinder extends ErrorAwareTreePathScanner<Void, List<TreePath>> {
 
         private final Trees trees;
         private final Element param;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java b/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
index 6a49054..b3a60ba 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
@@ -33,7 +33,7 @@ import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -233,7 +233,7 @@ public class ConvertAnonymousToInner extends AbstractHint {
         }
     }
 
-    private static final class DetectUsedVars extends TreePathScanner<Void, Set<VariableElement>> {
+    private static final class DetectUsedVars extends ErrorAwareTreePathScanner<Void, Set<VariableElement>> {
         private CompilationInfo info;
         private TreePath newClassToConvert;
         
@@ -258,7 +258,7 @@ public class ConvertAnonymousToInner extends AbstractHint {
 
     }
     
-    private static final class DetectUseOfNonStaticMembers extends TreePathScanner<Boolean, Void> {
+    private static final class DetectUseOfNonStaticMembers extends ErrorAwareTreePathScanner<Boolean, Void> {
         private CompilationInfo info;
         private TreePath newClassToConvert;
         
@@ -546,7 +546,7 @@ public class ConvertAnonymousToInner extends AbstractHint {
     }
 
     private static TreePath findSuperConstructorCall(final CompilationInfo info, TreePath nct) {
-        class FindSuperConstructorCall extends TreePathScanner<TreePath, Void> {
+        class FindSuperConstructorCall extends ErrorAwareTreePathScanner<TreePath, Void> {
 
             private boolean stop;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java b/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
index b1027ac..27a60b0 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -393,7 +393,7 @@ public class DoubleCheck {
         }
     }
     
-    private static final class VariableAccessWalker extends TreePathScanner {
+    private static final class VariableAccessWalker extends ErrorAwareTreePathScanner {
         private final VariableElement originalVariable;
         private final ExpressionTree  fieldAccessTree;
         /**

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java b/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
index cea42d6..b5a3e45 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import org.netbeans.api.java.source.CompilationInfo;
@@ -69,7 +69,7 @@ public class EqualsMethodHint {
                 NbBundle.getMessage(EqualsMethodHint.class, "ERR_EQUALS_NOT_CHECKING_TYPE"));
     }
 
-    private static final class VisitorImpl extends TreePathScanner<Void, Void> {
+    private static final class VisitorImpl extends ErrorAwareTreePathScanner<Void, Void> {
         
         private CompilationInfo info;
         private Element parameter;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java b/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
index 4ce6ad9..a577005 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
@@ -46,7 +46,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol;
@@ -232,7 +232,7 @@ public class OrganizeImports {
         final Set<Element> ret = new HashSet<Element>();
         final Trees trees = info.getTrees();
         final Types types = info.getTypes();
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java b/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
index d241aba..40f5139 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -93,7 +93,7 @@ public class WrongPackageSuggestion extends AbstractHint {
         boolean hasPackageClause = tree.getPackageName() != null;
         
         if (hasPackageClause) {
-            new TreeScanner<Void, StringBuffer>() {
+            new ErrorAwareTreeScanner<Void, StringBuffer>() {
                 @Override
                 public Void visitIdentifier(IdentifierTree node, StringBuffer p) {
                     p.append(node.getName().toString());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
index 56dfd1f..99e6d44 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
@@ -29,7 +29,7 @@ import com.sun.source.tree.NewClassTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Deque;
 import java.util.LinkedList;
 import javax.lang.model.element.Element;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
index 5e8d3bd..3475195 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ExecutableElement;
@@ -93,7 +93,7 @@ public class CloneAndCloneable {
      * Finder provides true, if it finds a call to 'superClone' method element passed
      * in the constructor.
      */
-    private static final class SuperCloneFinder extends TreePathScanner<Boolean, Void> {
+    private static final class SuperCloneFinder extends ErrorAwareTreePathScanner<Boolean, Void> {
         private final CompilationInfo info;
         private final ExecutableElement superClone;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
index 1352b21..082b73c 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
@@ -23,7 +23,7 @@ import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.text.Collator;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -58,7 +58,7 @@ import static org.netbeans.modules.java.hints.bugs.Bundle.*;
     "# {0} - parameter name",
     "TEXT_ComparatorParameterNotUsed=Comparator.comparable does not use parameter ''{0}''"
 })
-public class ComparatorParameterNotUsed extends TreePathScanner {
+public class ComparatorParameterNotUsed extends ErrorAwareTreePathScanner {
     private final CompilationInfo   ci;
     private final Set<VariableElement>    unusedVars;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
index 399d3d0..0365e93 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
@@ -41,7 +41,7 @@ import com.sun.source.tree.SwitchTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.Deque;
 import java.util.EnumSet;
@@ -224,7 +224,7 @@ public class InfiniteRecursion {
      * only in the speculative for loop evaluation, otherwise for/while bodies incl any continue statements do not count.
      * 
      */
-    private static class RecursionVisitor extends TreePathScanner<State, Void> {
+    private static class RecursionVisitor extends ErrorAwareTreePathScanner<State, Void> {
         private final CompilationInfo ci;
         private final ExecutableElement checkMethod;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
index 5be0b91..87d35bb 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 import javax.lang.model.element.Element;
@@ -97,7 +97,7 @@ public class Regexp {
         final StringBuilder regexp = new StringBuilder();
         final boolean[] accept = {true};
         TreePath pattern = ctx.getVariables().get("$pattern");
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override
             public Void visitLiteral(LiteralTree node, Void p) {
                 if (node.getValue() instanceof String) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
index 6cc965a..ca9d9f1 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
@@ -37,8 +37,8 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -342,7 +342,7 @@ public class Tiny {
         final LabeledStatementTree lt = (LabeledStatementTree)lPath.getLeaf();
         final Name l = lt.getLabel();
         final CompilationInfo info = ctx.getInfo();
-        Boolean b = new TreePathScanner<Boolean, Void>() {
+        Boolean b = new ErrorAwareTreePathScanner<Boolean, Void>() {
 
             @Override
             public Boolean reduce(Boolean r1, Boolean r2) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
index 5aac965..010b799 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
@@ -28,7 +28,7 @@ import com.sun.source.tree.ThrowTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -226,7 +226,7 @@ public class TryCatchFinally {
         return errs;
     }
     
-    private static final class ExitsFromBranches extends TreePathScanner<Void, Collection<TreePath>> {
+    private static final class ExitsFromBranches extends ErrorAwareTreePathScanner<Void, Collection<TreePath>> {
         private final  boolean analyzeThrows;
         private final CompilationInfo info;
         private final Set<Tree> seenTrees = new HashSet<Tree>();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java b/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
index e7658ed..b5626a4 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
@@ -44,7 +44,7 @@ import com.sun.source.tree.TryTree;
 import com.sun.source.tree.TypeCastTree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.List;
@@ -260,7 +260,7 @@ public class RemoveUnnecessary {
      * Transforms expression tree into series of statements.
      * 
      */
-    static class ExpressionToStatement extends TreePathScanner {
+    static class ExpressionToStatement extends ErrorAwareTreePathScanner {
         private boolean remove = true;
         private List<StatementTree>    statements = new ArrayList<>(); 
         private final TreeMaker mk;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java b/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
index 995e61c..c92b3b0 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
@@ -30,7 +30,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.EnumSet;
@@ -264,7 +264,7 @@ public class AddParameterOrLocalFix implements EnhancedFix {
             return;
         }
         
-        class FirstUsage extends TreePathScanner<TreePath, Void> {
+        class FirstUsage extends ErrorAwareTreePathScanner<TreePath, Void> {
             public @Override TreePath visitIdentifier(IdentifierTree tree, Void v) {
                 if (tree.getName().contentEquals(el.getSimpleName()) && isError(wc, wc.getTrees().getElement(getCurrentPath()))) {
                     return findStatement(getCurrentPath());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java b/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
index ba538f9..778331d 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
@@ -29,7 +29,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -198,7 +198,7 @@ public final class ImplementAllAbstractMethods implements ErrorRule<Object>, Ove
             //(missing '()' for constructor)
             //do not propose the hint in this case:
             final boolean[] parentError = new boolean[] {false};
-            new TreePathScanner() {
+            new ErrorAwareTreePathScanner() {
                 @Override
                 public Object visitNewClass(NewClassTree nct, Object o) {
                     if (leaf == nct) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java b/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
index c21f6f6..69b0ff7 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -187,7 +187,7 @@ final class MagicSurroundWithTryCatchFix implements Fix {
         return null;
     }
     
-    private final class TransformerImpl extends TreePathScanner<Void, Void> {
+    private final class TransformerImpl extends ErrorAwareTreePathScanner<Void, Void> {
         
         private WorkingCopy info;
         private List<TypeMirrorHandle> thandles;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java b/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
index a1a6a41..27e8bda 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
@@ -27,7 +27,7 @@ import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import java.util.ArrayList;
 import java.util.Arrays;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java b/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
index 337d5f0..ccf8998 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
@@ -29,7 +29,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -171,7 +171,7 @@ class OrigSurroundWithTryCatchFix implements Fix {
         return path;
     }
     
-    private static final class FindUsages extends TreePathScanner<Boolean, VariableElement> {
+    private static final class FindUsages extends ErrorAwareTreePathScanner<Boolean, VariableElement> {
 
         private Tree ignore;
         private CompilationInfo info;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java b/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
index df1babc..a634619 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
@@ -55,7 +55,7 @@ import com.sun.source.tree.ContinueTree;
 import com.sun.source.tree.IfTree;
 import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.TryTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.java.source.TreeUtilities;
 import org.openide.filesystems.FileUtil;
 import org.openide.util.NbBundle;
@@ -97,7 +97,7 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -865,7 +865,7 @@ public class Utilities {
     @NbBundle.Messages({
         "DisplayName_Unknown=<missing>"
     })
-    private static class HintDisplayNameVisitor extends TreeScanner<String, Void> {
+    private static class HintDisplayNameVisitor extends ErrorAwareTreeScanner<String, Void> {
 
         private CompilationInfo info;
 
@@ -1258,7 +1258,7 @@ public class Utilities {
      * {@link #seenTrees} before processing, so if a break/continue targets such a node, such jump is not considered an exit.
      * Jumps can register the target Tree in {@link #targetTrees} which causes false to be returned from that tree's inspection.
      */
-    private static final class ExitsFromAllBranches extends TreePathScanner<Boolean, Void> {
+    private static final class ExitsFromAllBranches extends ErrorAwareTreePathScanner<Boolean, Void> {
 
         private CompilationInfo info;
         private final Set<Tree> seenTrees = new HashSet<Tree>();
@@ -1876,10 +1876,10 @@ public class Utilities {
                 }
             }            
         };
-        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
-        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
         try {
-            enter.shadowTypeEnvs(true);
+//            enter.shadowTypeEnvs(true);
             Attr attr = Attr.instance(jti.getContext());
             Env<AttrContext> env = ((JavacScope) scope).getEnv();
             if (tree instanceof JCTree.JCExpression) {
@@ -1887,10 +1887,10 @@ public class Utilities {
             }
             return attr.attribStat((JCTree) tree,env);
         } finally {
-            cacheContext.leave();
+//            cacheContext.leave();
             log.useSource(prev);
             log.popDiagnosticHandler(discardHandler);
-            enter.shadowTypeEnvs(false);
+//            enter.shadowTypeEnvs(false);
         }
     }
     // -------------------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java b/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
index 6dd6d26..0bdad2d 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -77,7 +77,7 @@ public class FinalizeDoesNotCallSuper {
                 new FixImpl(TreePathHandle.create(ctx.getPath(), ctx.getInfo())).toEditorFix());
     }
 
-    static final class FindSuper extends TreeScanner<Void, Void> {
+    static final class FindSuper extends ErrorAwareTreeScanner<Void, Void> {
 
         boolean found;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
index 348508c..99681c6 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
@@ -73,7 +73,7 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -243,7 +243,7 @@ public class Flow {
 
     }
     
-    private static class PathFinder extends TreePathScanner {
+    private static class PathFinder extends ErrorAwareTreePathScanner {
         final Map<Tree, TreePath> node2Path;
         final Set<Tree> interestingNodes;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
index 3232480..36cece3 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.NewClassTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -47,7 +47,7 @@ import org.netbeans.api.java.source.CompilationInfo;
  *
  * @author sdedic
  */
-public class InstanceRefFinder extends TreePathScanner {
+public class InstanceRefFinder extends ErrorAwareTreePathScanner {
     /**
      * The initial path for analysis
      */

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
index ce66a79..6beaef7 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
@@ -35,8 +35,8 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.awt.Color;
 import java.awt.Rectangle;
 import java.util.ArrayList;
@@ -441,7 +441,7 @@ public class IntroduceHint implements CancellableTask<CompilationInfo> {
             }
 
         }
-        class ReferencesLocalVariable extends TreePathScanner<Void, Void> {
+        class ReferencesLocalVariable extends ErrorAwareTreePathScanner<Void, Void> {
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 Element e = info.getTrees().getElement(getCurrentPath());
@@ -550,7 +550,7 @@ public class IntroduceHint implements CancellableTask<CompilationInfo> {
         return formalArguments;
     }
     
-    static class VariableRenamer extends TreePathScanner {
+    static class VariableRenamer extends ErrorAwareTreePathScanner {
         private final Map<VariableElement, CharSequence> renamedVars;
         private final Set<Name> changedNames;
         private final WorkingCopy info;
@@ -750,7 +750,7 @@ public class IntroduceHint implements CancellableTask<CompilationInfo> {
     static ClassTree insertField(final WorkingCopy parameter, ClassTree clazz, VariableTree fieldToAdd, Set<Tree> allNewUses, int offset) {
         ClassTree nueClass = INSERT_CLASS_MEMBER.insertClassMember(parameter, clazz, fieldToAdd, offset);
 
-        class Contains extends TreeScanner<Boolean, Set<Tree>> {
+        class Contains extends ErrorAwareTreeScanner<Boolean, Set<Tree>> {
             @Override public Boolean reduce(Boolean r1, Boolean r2) {
                 return r1 == Boolean.TRUE || r2 == Boolean.TRUE;
             }
@@ -809,7 +809,7 @@ public class IntroduceHint implements CancellableTask<CompilationInfo> {
         final Set<Element> used = Collections.newSetFromMap(new IdentityHashMap<Element, Boolean>());
         final boolean statik = fieldToAdd.getModifiers().getFlags().contains(Modifier.STATIC);
         
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                 handleCurrentPath();
                 return super.visitIdentifier(node, p); //To change body of generated methods, choose Tools | Templates.

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
index 95d4e48..afd6cca 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
@@ -22,7 +22,7 @@ import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.Modifier;
@@ -35,7 +35,7 @@ import org.netbeans.api.java.source.WorkingCopy;
  *
  * @author sdedic
  */
-final class ReferenceTransformer extends TreePathScanner {
+final class ReferenceTransformer extends ErrorAwareTreePathScanner {
     private final ElementKind kind;
     private final String name;
     private final WorkingCopy copy;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
index 74929cf..b2bbfbe 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -53,7 +53,7 @@ import org.netbeans.api.java.source.TreePathHandle;
  *
  * @author sdedic
  */
-final class ScanStatement extends TreePathScanner<Void, Void> {
+final class ScanStatement extends ErrorAwareTreePathScanner<Void, Void> {
     private static final int PHASE_BEFORE_SELECTION = 1;
     private static final int PHASE_INSIDE_SELECTION = 2;
     private static final int PHASE_AFTER_SELECTION = 3;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
index 4832b96..b0ddf35 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
@@ -32,8 +32,8 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -841,7 +841,7 @@ public class ConvertToARM {
             }
         }
         final Set<VariableTree> result = new HashSet<VariableTree>();
-        final TreeScanner<Void,Void> scanner = new TreeScanner<Void,Void>(){
+        final ErrorAwareTreeScanner<Void,Void> scanner = new ErrorAwareTreeScanner<Void,Void>(){
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 final Element elm = trees.getElement(trees.getPath(cu, node));
@@ -863,7 +863,7 @@ public class ConvertToARM {
             final Trees trees) {
         final List<TreePath> usages = new LinkedList<>();
         if (statements != null) {
-            final TreePathScanner<List<TreePath>,List<TreePath>> scanner = new TreePathScanner<List<TreePath>, List<TreePath>>() {
+            final ErrorAwareTreePathScanner<List<TreePath>,List<TreePath>> scanner = new ErrorAwareTreePathScanner<List<TreePath>, List<TreePath>>() {
                 @Override
                 public List<TreePath> visitIdentifier(IdentifierTree node, List<TreePath> p) {
                     final TreePath path = getCurrentPath();
@@ -910,7 +910,7 @@ public class ConvertToARM {
             final Element what,
             final Iterable<? extends TreePath> where,
             final Trees trees) {
-        TreePathScanner<Boolean, Void> scanner = new TreePathScanner<Boolean, Void>() {
+        ErrorAwareTreePathScanner<Boolean, Void> scanner = new ErrorAwareTreePathScanner<Boolean, Void>() {
             @Override public Boolean visitAssignment(AssignmentTree node, Void p) {
                 if (trees.getElement(new TreePath(getCurrentPath(), node.getVariable())) == what) {
                     return true;
@@ -955,7 +955,7 @@ public class ConvertToARM {
             usedAfterCloseVarNames.add(vt.getName().toString());
         }
         
-        TreeScanner<Boolean, Void> scanner = new TreeScanner<Boolean, Void>() {
+        ErrorAwareTreeScanner<Boolean, Void> scanner = new ErrorAwareTreeScanner<Boolean, Void>() {
             @Override public Boolean visitVariable(VariableTree node, Void p) {
                 if (usedAfterCloseVarNames.contains(node.getName().toString()) && !usedAfterCloseVarDecls.contains(node)) {
                     return true;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
index 9e15fe5..e5d6661 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.Collection;
 import java.util.Collections;
@@ -223,7 +223,7 @@ public class ConvertToLambdaConverter {
         return make.TypeCast(expectedType, tree);
     }
 
-    private class ShadowedVariableRenameScanner extends TreePathScanner<Tree, Trees> {
+    private class ShadowedVariableRenameScanner extends ErrorAwareTreePathScanner<Tree, Trees> {
 
         private final Map<Element, CharSequence> originalToNewName = new HashMap<Element, CharSequence>();
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
index 56930ea..1731bd8 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.EnumSet;
@@ -235,7 +235,7 @@ public class ConvertToLambdaPreconditionChecker {
         foundOverloadWhichMakesLambdaAmbiguous = doesOverloadMakeLambdaAmbiguous();
     }
 
-    private class PreconditionScanner extends TreePathScanner<Tree, Trees> {
+    private class PreconditionScanner extends ErrorAwareTreePathScanner<Tree, Trees> {
 
         @Override
         public Tree visitClass(ClassTree node, Trees p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
index 2b9c99f..6b57474 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
@@ -35,7 +35,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
@@ -269,7 +269,7 @@ public class IteratorToFor {
             return false;
         }
         for (TreePath tp : statements) {
-            boolean occurs = Boolean.TRUE.equals(new TreePathScanner<Boolean, Void>() {
+            boolean occurs = Boolean.TRUE.equals(new ErrorAwareTreePathScanner<Boolean, Void>() {
                 @Override public Boolean scan(Tree tree, Void p) {
                     if (tree == null) {
                         return false;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
index 0fd6c0f..b36959e 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -262,7 +262,7 @@ public class UseSpecificCatch implements CustomizerProvider {
         final boolean[] result = new boolean[1];
 
         for (TreePath tp : statements) {
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override
                 public Void visitAssignment(AssignmentTree node, Void p) {
                     if (tEl.equals(ctx.getInfo().getTrees().getElement(new TreePath(getCurrentPath(), node.getVariable())))) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
index a4c29e1..579fcf2 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
@@ -34,8 +34,8 @@ import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -189,7 +189,7 @@ public class PreconditionsChecker {
         return false;
     }
 
-    public static class VariablesVisitor extends TreeScanner<Tree, Trees> {
+    public static class VariablesVisitor extends ErrorAwareTreeScanner<Tree, Trees> {
 
         private Set<Name> innerVariables = new HashSet<Name>();
         private Set<Name> allLocalVariables = new HashSet<Name>();
@@ -234,7 +234,7 @@ public class PreconditionsChecker {
     /*
      * This class visits the loop to check if there are any failed preconditions.
      */
-    private static class ForLoopTreeVisitor extends TreePathScanner<Tree, Trees> {
+    private static class ForLoopTreeVisitor extends ErrorAwareTreePathScanner<Tree, Trees> {
 
         private Set<Name> inners;
         private CompilationInfo workingCopy;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java b/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
index 0bf749e..2b3a4b3 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.java.hints.perf;
 
 import com.sun.source.tree.IdentifierTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -79,7 +79,7 @@ public class ManualArrayCopy {
         
         if (i != null) {
             final boolean[] used = new boolean[1];
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                     Element use = ctx.getInfo().getTrees().getElement(getCurrentPath());
                     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java b/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
index 564ff4c..bb00c2d 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
@@ -33,7 +33,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -119,7 +119,7 @@ public class ReplaceBufferByString {
     /**
      * The scanner determines, if the expression is just a series of new SB().append().append()...
      */
-    private static class NewAppendScanner extends TreePathScanner<Boolean, Void> {
+    private static class NewAppendScanner extends ErrorAwareTreePathScanner<Boolean, Void> {
         private final CompilationInfo ci;
         private boolean hasContents;
         
@@ -386,7 +386,7 @@ public class ReplaceBufferByString {
      * Translates rest of references in the method so that .toString() is stripped, as the variable is going
      * to change type to String.
      */
-    private static class ToStringTranslator extends TreePathScanner {
+    private static class ToStringTranslator extends ErrorAwareTreePathScanner {
         private final WorkingCopy wc;
         private final Element varElement;
         private final GeneratorUtilities gu;
@@ -442,7 +442,7 @@ public class ReplaceBufferByString {
      * its value must NOT be assigned to another variable, field, passed to another method call or returned from the method.
      * Only String-compatible methods may be called on the variable.
      */
-    private static class StringBufferUsageScanner extends TreePathScanner<Boolean, Void> {
+    private static class StringBufferUsageScanner extends ErrorAwareTreePathScanner<Boolean, Void> {
         private final CompilationInfo ci;
         private final VariableElement var;
         

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java b/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
index e588545..bc7b8a2 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
@@ -23,7 +23,7 @@ import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -53,7 +53,7 @@ public class StringBuffer2Builder {
             return null;
         }
 
-        class EscapeFinder extends TreePathScanner<Boolean, Boolean> {
+        class EscapeFinder extends ErrorAwareTreePathScanner<Boolean, Boolean> {
             @Override
             public Boolean reduce(Boolean r1, Boolean r2) {
                 return r1 == Boolean.TRUE || r2 == Boolean.TRUE;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/suggestions/ExpectedTypeResolver.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/ExpectedTypeResolver.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/ExpectedTypeResolver.java
index 9642652..92faa9c 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/ExpectedTypeResolver.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/ExpectedTypeResolver.java
@@ -122,7 +122,7 @@ import org.netbeans.modules.java.hints.errors.Utilities;
  * it is not possible to determine a type which the expression must be <i>assignable to</i>. But it is known that the
  * expression must be <i>castable</i> to the typecast's target type so that compiler error does not occur.
  * <p/>
- * As the class iterates "upwards", it was derived from TreeVisitor rather than from TreeScanner to prevent accidental 
+ * As the class iterates "upwards", it was derived from TreeVisitor rather than from ErrorAwareTreeScanner to prevent accidental 
  * StackOverflows if execution accidentally fall to the default implementation with top-down traversal.
  * 
  * @author sdedic

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
index b928ecb..1e9ae94 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
@@ -32,8 +32,8 @@ import com.sun.source.tree.SwitchTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -585,7 +585,7 @@ public class IfToSwitchSupport {
             TreePath topLevelMethod = Utilities.findTopLevelBlock(it);
             final Set<String> seenLabels = new HashSet<String>();
 
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override public Void visitLabeledStatement(LabeledStatementTree node, Void p) {
                     seenLabels.add(node.getLabel().toString());
                     return super.visitLabeledStatement(node, p);
@@ -764,7 +764,7 @@ public class IfToSwitchSupport {
                 above.add(t);
             }
 
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                     if (declared.contains(info.getTrees().getElement(getCurrentPath())))
                         return null;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
index d24c7d7..70f84c0 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
@@ -42,8 +42,8 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -438,7 +438,7 @@ public class Lambda {
             }
             types.put(samTypeElement.getSimpleName(), samTypeElement);
             
-            new TreePathScanner<Void, Boolean>() {
+            new ErrorAwareTreePathScanner<Void, Boolean>() {
                 @Override public Void visitIdentifier(final IdentifierTree node, Boolean p) {
                     boolean rewrite = false;
                     boolean statRef = false;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
index eb3d87b..8757ab5 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
@@ -35,7 +35,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -374,7 +374,7 @@ public class Tiny {
                 Scope s = ctx.getWorkingCopy().getTrees().getScope(tp);
                 ctx.getWorkingCopy().getTreeUtilities().attributeTree(stmt, s);
                 st = GeneratorUtilities.get(ctx.getWorkingCopy()).importFQNs(make.addSwitchCase(st, make.Case(null, Collections.singletonList(stmt))));
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("$expression")) {
                             ExpressionTree expression = ((SwitchTree) tp.getLeaf()).getExpression();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
----------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java b/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
index 9d494e5..1aef771 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
@@ -195,7 +195,7 @@ public class Tiny {
 
         if (!report) {
             try {
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         return null;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
----------------------------------------------------------------------
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
index d921317..5e57a88 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.java.hints;
 
 import com.sun.source.tree.NewClassTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.regex.Pattern;
 import org.netbeans.api.java.source.JavaSource;
@@ -50,7 +50,7 @@ public class ConvertAnonymousToInnerTest extends NbTestCase {
         SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
     }
 
-    private static final class FindNewClassTree extends TreePathScanner<TreePath, Void> {
+    private static final class FindNewClassTree extends ErrorAwareTreePathScanner<TreePath, Void> {
         @Override
         public TreePath visitNewClass(NewClassTree node, Void p) {
             return getCurrentPath();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
----------------------------------------------------------------------
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
index 02dccfd..657bea0 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.java.hints;
 
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.beans.PropertyVetoException;
 import java.io.File;
 import java.io.IOException;
@@ -146,7 +146,7 @@ public class SuspiciousNamesCombinationTest extends NbTestCase {
         final SuspiciousNamesCombination snc = new SuspiciousNamesCombination();
         final List<ErrorDescription> errors = new ArrayList<ErrorDescription>();
         
-        class ScannerImpl extends TreePathScanner {
+        class ScannerImpl extends ErrorAwareTreePathScanner {
             @Override
             public Object scan(Tree tree, Object p) {
                 if (tree != null && snc.getTreeKinds().contains(tree.getKind())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
----------------------------------------------------------------------
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
index 04a3782..f50b987 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
@@ -45,7 +45,7 @@ import org.netbeans.junit.NbTestCase;
 import org.netbeans.junit.RandomlyFails;
 import org.netbeans.modules.java.hints.legacy.spi.RulesManager;
 import org.netbeans.modules.java.hints.legacy.spi.RulesManager.LegacyHintConfiguration;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.spi.editor.hints.ErrorDescription;
 import org.netbeans.spi.editor.hints.Fix;
 import org.openide.LifecycleManager;
@@ -74,7 +74,8 @@ public abstract class TreeRuleTestBase extends NbTestCase {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        //XXX:
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
     }
 
     private void prepareTest(String fileName, String code) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
----------------------------------------------------------------------
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
index d1ff90e..b923bcf 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.j2semodule/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.j2semodule/nbproject/project.properties b/java.j2semodule/nbproject/project.properties
index 4aa6121..be95b98 100644
--- a/java.j2semodule/nbproject/project.properties
+++ b/java.j2semodule/nbproject/project.properties
@@ -18,3 +18,4 @@
 javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
 javadoc.arch=${basedir}/arch.xml
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.j2seprofiles/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.j2seprofiles/nbproject/project.properties b/java.j2seprofiles/nbproject/project.properties
index ab06b41..7b21974 100644
--- a/java.j2seprofiles/nbproject/project.properties
+++ b/java.j2seprofiles/nbproject/project.properties
@@ -16,3 +16,5 @@
 # under the License.
 javac.source=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
+cp.extra=${tools.jar}
+requires.nb.javac=true



[04/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java
new file mode 100644
index 0000000..a3c7975
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java
@@ -0,0 +1,226 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.parser.LazyDocCommentTable;
+import com.sun.tools.javac.tree.EndPosTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.CouplingAbort;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.Position.LineMapImpl;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaFileObject;
+import org.netbeans.api.java.source.JavaSource.Phase;
+import org.netbeans.modules.*;
+import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
+import org.netbeans.modules.java.source.parsing.JavacFlowListener;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.PartialReparser;
+import org.netbeans.modules.parsing.api.Snapshot;
+import org.openide.filesystems.FileObject;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service = PartialReparser.class, position = 100)
+public class PartialReparserImpl implements PartialReparser {
+    private static final Logger LOGGER = Logger.getLogger(PartialReparserImpl.class.getName());
+
+    @Override
+    public boolean reparseMethod (final CompilationInfoImpl ci,
+            final Snapshot snapshot,
+            final MethodTree orig,
+            final String newBody) throws IOException {
+        assert ci != null;
+        final FileObject fo = ci.getFileObject();
+        if (LOGGER.isLoggable(Level.FINER)) {
+            LOGGER.log(Level.FINER, "Reparse method in: {0}", fo);          //NOI18N
+        }
+        final Phase currentPhase = ci.getPhase();
+        if (Phase.PARSED.compareTo(currentPhase) > 0) {
+            return false;
+        }
+        try {
+            final CompilationUnitTree cu = ci.getCompilationUnit();
+            if (cu == null || newBody == null) {
+                return false;
+            }
+            final JavacTaskImpl task = ci.getJavacTask();
+            if (Options.instance(task.getContext()).isSet(JavacParser.LOMBOK_DETECTED)) {
+                return false;
+            }
+            PartialReparserService pr = PartialReparserService.instance(task.getContext());
+            if (((JCTree.JCMethodDecl)orig).localEnv == null) {
+                //We are seeing interface method or abstract or native method with body.
+                //Don't do any optimalization of this broken code - has no attr env.
+                return false;
+            }
+            final JavacTrees jt = JavacTrees.instance(task);
+            final int origStartPos = (int) jt.getSourcePositions().getStartPosition(cu, orig.getBody());
+            final int origEndPos = (int) jt.getSourcePositions().getEndPosition(cu, orig.getBody());
+            if (origStartPos < 0) {
+                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} < 0", new Object[]{origStartPos});  //NOI18N
+                return false;
+            }
+            if (origStartPos > origEndPos) {
+                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} > endpos: {1}", new Object[]{origStartPos, origEndPos});  //NOI18N
+                return false;
+            }
+            final FindAnonymousVisitor fav = new FindAnonymousVisitor();
+            fav.scan(orig.getBody(), null);
+            if (fav.hasLocalClass) {
+                if (LOGGER.isLoggable(Level.FINER)) {
+                    LOGGER.log(Level.FINER, "Skeep reparse method (old local classes): {0}", fo);   //NOI18N
+                }
+                return false;
+            }
+            final int firstInner = fav.firstInner;
+            final int noInner = fav.noInner;
+            final Context ctx = task.getContext();
+//            final TreeLoader treeLoader = TreeLoader.instance(ctx);
+//            if (treeLoader != null) {
+//                treeLoader.startPartialReparse();
+//            }
+            try {
+                final Log l = Log.instance(ctx);
+                l.startPartialReparse();
+                final JavaFileObject prevLogged = l.useSource(cu.getSourceFile());
+                JCTree.JCBlock block;
+                try {
+                    DiagnosticListener dl = ci.getDiagnosticListener();
+                    assert dl instanceof CompilationInfoImpl.DiagnosticListenerImpl;
+                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).startPartialReparse(origStartPos, origEndPos);
+                    long start = System.currentTimeMillis();
+                    Map<JCTree,LazyDocCommentTable.Entry> docComments = new HashMap<>();
+                    block = pr.reparseMethodBody(cu, orig, newBody + " ", firstInner, docComments);
+                    LOGGER.log(Level.FINER, "Reparsed method in: {0}", fo);     //NOI18N
+                    if (block == null) {
+                        LOGGER.log(
+                            Level.FINER,
+                            "Skeep reparse method, invalid position, newBody: ",       //NOI18N
+                            newBody);
+                        return false;
+                    }
+                    final int newEndPos = (int) jt.getSourcePositions().getEndPosition(cu, block);
+                    if (newEndPos != origStartPos + newBody.length()) {
+                        return false;
+                    }
+                    fav.reset();
+                    fav.scan(block, null);
+                    final int newNoInner = fav.noInner;
+                    if (fav.hasLocalClass || noInner != newNoInner) {
+                        if (LOGGER.isLoggable(Level.FINER)) {
+                            LOGGER.log(Level.FINER, "Skeep reparse method (new local classes): {0}", fo);   //NOI18N
+                        }
+                        return false;
+                    }
+                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.keySet().removeAll(fav.docOwners);
+                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.putAll(docComments);
+                    long end = System.currentTimeMillis();
+                    if (fo != null) {
+                        JavacParser.logTime (fo,Phase.PARSED,(end-start));
+                    }
+                    final int delta = newEndPos - origEndPos;
+                    final EndPosTable endPos = ((JCTree.JCCompilationUnit)cu).endPositions;
+                    final TranslatePositionsVisitor tpv = new TranslatePositionsVisitor(orig, endPos, delta);
+                    tpv.scan(cu, null);
+                    ((JCTree.JCMethodDecl)orig).body = block;
+                    if (Phase.RESOLVED.compareTo(currentPhase)<=0) {
+                        start = System.currentTimeMillis();
+                        pr.reattrMethodBody(orig, block);
+                        if (LOGGER.isLoggable(Level.FINER)) {
+                            LOGGER.log(Level.FINER, "Resolved method in: {0}", fo);     //NOI18N
+                        }
+                        if (!((CompilationInfoImpl.DiagnosticListenerImpl)dl).hasPartialReparseErrors()) {
+                            final JavacFlowListener fl = JavacFlowListener.instance(ctx);
+                            if (fl != null && fl.hasFlowCompleted(fo)) {
+                                if (LOGGER.isLoggable(Level.FINER)) {
+                                    final List<? extends Diagnostic> diag = ci.getDiagnostics();
+                                    if (!diag.isEmpty()) {
+                                        LOGGER.log(Level.FINER, "Reflow with errors: {0} {1}", new Object[]{fo, diag});     //NOI18N
+                                    }
+                                }
+                                TreePath tp = TreePath.getPath(cu, orig);       //todo: store treepath in changed method => improve speed
+                                Tree t = tp.getParentPath().getLeaf();
+                                pr.reflowMethodBody(cu, (ClassTree) t, orig);
+                                if (LOGGER.isLoggable(Level.FINER)) {
+                                    LOGGER.log(Level.FINER, "Reflowed method in: {0}", fo); //NOI18N
+                                }
+                            }
+                        }
+                        end = System.currentTimeMillis();
+                        if (fo != null) {
+                            JavacParser.logTime (fo, Phase.ELEMENTS_RESOLVED,0L);
+                            JavacParser.logTime (fo,Phase.RESOLVED,(end-start));
+                        }
+                    }
+
+                    //fix CompilationUnitTree.getLineMap:
+                    long startM = System.currentTimeMillis();
+                    char[] chars = snapshot.getText().toString().toCharArray();
+                    ((LineMapImpl) cu.getLineMap()).build(chars, chars.length);
+                    LOGGER.log(Level.FINER, "Rebuilding LineMap took: {0}", System.currentTimeMillis() - startM);
+
+                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).endPartialReparse (delta);
+                } finally {
+                    l.endPartialReparse();
+                    l.useSource(prevLogged);
+                }
+                ci.update(snapshot);
+            } finally {
+//              if (treeLoader != null) {
+//                  treeLoader.endPartialReparse();
+//              }
+            }
+        } catch (CouplingAbort ca) {
+            //Needs full reparse
+            return false;
+        } catch (Throwable t) {
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            }
+            boolean a = false;
+            assert a = true;
+            if (a) {
+                JavacParser.dumpSource(ci, t);
+            }
+            return false;
+        }
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java
new file mode 100644
index 0000000..7bb407b
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java
@@ -0,0 +1,187 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Flow;
+import com.sun.tools.javac.comp.TypeEnter;
+import com.sun.tools.javac.parser.JavacParser;
+import com.sun.tools.javac.parser.LazyDocCommentTable;
+import com.sun.tools.javac.parser.Scanner;
+import com.sun.tools.javac.parser.ScannerFactory;
+import com.sun.tools.javac.tree.EndPosTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCBlock;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCStatement;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.tree.TreeMaker;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Names;
+import java.nio.CharBuffer;
+import java.util.Map;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import org.netbeans.lib.nbjavac.services.NBParserFactory;
+
+/**
+ *
+ * @author Tomas Zezula
+ */
+public class PartialReparserService {
+    
+    protected static final Context.Key<PartialReparserService> partialReparserKey = new Context.Key<PartialReparserService>();
+    
+    public static PartialReparserService instance(Context ctx) {
+        PartialReparserService res = ctx.get(partialReparserKey);
+        
+        if (res == null) {
+            ctx.put(partialReparserKey, res = new PartialReparserService(ctx));
+        }
+        
+        return res;
+    }
+
+    private final Context context;
+
+    public PartialReparserService(Context context) {
+        this.context = context;
+    }
+
+    public JCBlock reparseMethodBody(CompilationUnitTree topLevel, MethodTree methodToReparse, String newBodyText, int annonIndex,
+            final Map<? super JCTree,? super LazyDocCommentTable.Entry> docComments) {
+        CharBuffer buf = CharBuffer.wrap((newBodyText+"\u0000").toCharArray(), 0, newBodyText.length());
+        JavacParser parser = newParser(context, buf, ((JCBlock)methodToReparse.getBody()).pos, ((JCCompilationUnit)topLevel).endPositions);
+        final JCStatement statement = parser.parseStatement();
+        NBParserFactory.assignAnonymousClassIndices(Names.instance(context), statement, Names.instance(context).empty, annonIndex);
+        if (statement.getKind() == Tree.Kind.BLOCK) {
+            if (docComments != null) {
+                docComments.putAll(((LazyDocCommentTable) parser.getDocComments()).table);
+            }
+            return (JCBlock) statement;
+        }
+        return null;
+    }
+
+    public JavacParser newParser(Context context, CharSequence input, int startPos, final EndPosTable endPos) {
+        NBParserFactory parserFactory = (NBParserFactory) NBParserFactory.instance(context); //TODO: eliminate the cast
+        ScannerFactory scannerFactory = ScannerFactory.instance(context);
+        CancelService cancelService = CancelService.instance(context);
+        Scanner lexer = scannerFactory.newScanner(input, true);
+        lexer.seek(startPos);
+        ((NBParserFactory.NBJavacParser.EndPosTableImpl)endPos).resetErrorEndPos();
+        return new NBParserFactory.NBJavacParser(parserFactory, lexer, true, false, true, false, cancelService) {
+            @Override protected JavacParser.AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
+                return new JavacParser.AbstractEndPosTable(this) {
+
+                    @Override
+                    public void storeEnd(JCTree tree, int endpos) {
+                        ((NBParserFactory.NBJavacParser.EndPosTableImpl)endPos).storeEnd(tree, endpos);
+                    }
+
+                    @Override
+                    protected <T extends JCTree> T to(T t) {
+                        storeEnd(t, token.endPos);
+                        return t;
+                    }
+
+                    @Override
+                    protected <T extends JCTree> T toP(T t) {
+                        storeEnd(t, S.prevToken().endPos);
+                        return t;
+                    }
+
+                    @Override
+                    public int getEndPos(JCTree tree) {
+                        return endPos.getEndPos(tree);
+                    }
+
+                    @Override
+                    public int replaceTree(JCTree oldtree, JCTree newtree) {
+                        return endPos.replaceTree(oldtree, newtree);
+                    }
+
+                    @Override
+                    public void setErrorEndPos(int errPos) {
+                        super.setErrorEndPos(errPos);
+                        ((NBParserFactory.NBJavacParser.EndPosTableImpl)endPos).setErrorEndPos(errPos);
+                    }
+                };
+            }
+        };
+    }
+
+    public BlockTree reattrMethodBody(MethodTree methodToReparse, BlockTree block) {
+        Attr attr = Attr.instance(context);
+        assert ((JCMethodDecl)methodToReparse).localEnv != null;
+        JCMethodDecl tree = (JCMethodDecl) methodToReparse;
+        final Names names = Names.instance(context);
+        final Symtab syms = Symtab.instance(context);
+        final TypeEnter typeEnter = TypeEnter.instance(context);
+        final Log log = Log.instance(context);
+        final TreeMaker make = TreeMaker.instance(context);
+        final Env<AttrContext> env = attr.dupLocalEnv(((JCMethodDecl) methodToReparse).localEnv);
+        final ClassSymbol owner = env.enclClass.sym;
+        if (tree.name == names.init && !owner.type.isErroneous() && owner.type != syms.objectType) {
+            JCBlock body = tree.body;
+            if (body.stats.isEmpty() || !TreeInfo.isSelfCall(body.stats.head)) {
+                body.stats = body.stats.
+                prepend(typeEnter.SuperCall(make.at(body.pos),
+                    List.<Type>nil(),
+                    List.<JCVariableDecl>nil(),
+                    false));
+            } else if ((env.enclClass.sym.flags() & Flags.ENUM) != 0 &&
+                (tree.mods.flags & Flags.GENERATEDCONSTR) == 0 &&
+                TreeInfo.isSuperCall(body.stats.head)) {
+                // enum constructors are not allowed to call super
+                // directly, so make sure there aren't any super calls
+                // in enum constructors, except in the compiler
+                // generated one.
+                log.error(tree.body.stats.head.pos(),
+                          "call.to.super.not.allowed.in.enum.ctor",
+                          env.enclClass.sym);
+                    }
+                }
+        attr.attribStat((JCBlock)block, env);
+        return block;
+    }
+
+    public BlockTree reflowMethodBody(CompilationUnitTree topLevel, ClassTree ownerClass, MethodTree methodToReparse) {
+        Flow flow = Flow.instance(context);
+        TreeMaker make = TreeMaker.instance(context);
+        flow.reanalyzeMethod(make.forToplevel((JCCompilationUnit)topLevel),
+                (JCClassDecl)ownerClass);
+        return methodToReparse.getBody();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java
new file mode 100644
index 0000000..a30b6a2
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import java.io.IOException;
+import javax.tools.JavaFileObject;
+import org.netbeans.modules.java.source.parsing.JavacParser.SequentialParsing;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service=SequentialParsing.class)
+public class SequentialParsingImpl implements SequentialParsing {
+
+    @Override
+    public Iterable<? extends CompilationUnitTree> parse(JavacTask task, JavaFileObject file) throws IOException {
+        return ((JavacTaskImpl) task).parse(file);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java
new file mode 100644
index 0000000..fb9c261
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
+import com.sun.tools.javac.tree.EndPosTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+
+/**
+ * Helper visitor for partial reparse.
+ * Updates tree positions by the given delta.
+ * @author Tomas Zezula
+ */
+class TranslatePositionsVisitor extends ErrorAwareTreeScanner<Void,Void> {
+
+    private final MethodTree changedMethod;
+    private final EndPosTable endPos;
+    private final int delta;
+    boolean active;
+    boolean inMethod;
+
+    public TranslatePositionsVisitor (final MethodTree changedMethod, final EndPosTable endPos, final int delta) {
+        assert changedMethod != null;
+        assert endPos != null;
+        this.changedMethod = changedMethod;
+        this.endPos = endPos;
+        this.delta = delta;
+    }
+
+
+    @Override
+    public Void scan(Tree node, Void p) {
+        if (active && node != null) {
+            if (((JCTree)node).pos >= 0) {                    
+                ((JCTree)node).pos+=delta;
+            }                
+        }
+        Void result = super.scan(node, p);            
+        if (inMethod && node != null) {
+            endPos.replaceTree((JCTree) node, null);//remove
+        }
+        if (active && node != null) {
+            Integer pos = endPos.replaceTree((JCTree) node, null);//remove
+            if (pos != null) {
+                int newPos;
+                if (pos < 0) {
+                    newPos = pos;
+                }
+                else {
+                    newPos = pos+delta;
+                }
+                endPos.storeEnd((JCTree)node,newPos);
+            }                
+        }
+        return result;
+    }
+
+    @Override
+    public Void visitCompilationUnit(CompilationUnitTree node, Void p) {
+        return scan (node.getTypeDecls(), p);
+    }
+
+
+    @Override
+    public Void visitMethod(MethodTree node, Void p) {    
+        if (active || inMethod) {
+            scan(node.getModifiers(), p);
+            scan(node.getReturnType(), p);
+            scan(node.getTypeParameters(), p);
+            scan(node.getParameters(), p);
+            scan(node.getThrows(), p);
+        }
+        if (node == changedMethod) {
+            inMethod = true;
+        }
+        if (active || inMethod) {
+            scan(node.getBody(), p);
+        }
+        if (inMethod) {
+            active = inMethod;
+            inMethod = false;                
+        }
+        if (active || inMethod) {
+            scan(node.getDefaultValue(), p);
+        }
+        return null;
+    }
+
+    @Override
+    public Void visitVariable(VariableTree node, Void p) {
+        JCVariableDecl varDecl = (JCVariableDecl) node;
+        if (varDecl.sym != null && active && varDecl.sym.pos >= 0) {
+            varDecl.sym.pos += delta;
+        }
+        return super.visitVariable(node, p);
+    }
+    
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java
new file mode 100644
index 0000000..bcece76
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java
@@ -0,0 +1,814 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.PackageTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.TypeParameterTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.DuplicateClassChecker;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Scope;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.model.LazyTreeLoader;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.CouplingAbort;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Log.DiscardDiagnosticHandler;
+import java.awt.EventQueue;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.InterruptedIOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Pattern;
+import javax.lang.model.element.Name;
+import javax.swing.text.ChangedCharSetException;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTML.Tag;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.HTMLEditorKit.ParserCallback;
+import javax.swing.text.html.parser.ParserDelegator;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.ElementUtilities;
+import org.netbeans.api.java.source.SourceUtils;
+import org.netbeans.modules.java.source.JavaSourceAccessor;
+import org.netbeans.modules.java.source.JavadocHelper;
+import org.netbeans.modules.java.source.indexing.FQN2Files;
+import org.netbeans.modules.java.source.indexing.JavaBinaryIndexer;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
+import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.DuplicateClassRegistry;
+import org.netbeans.modules.java.source.parsing.JavacParser.TreeLoaderRegistry;
+import org.netbeans.modules.java.source.parsing.OutputFileManager.InvalidSourcePath;
+import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
+import org.netbeans.modules.parsing.impl.indexing.IndexingUtils;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.Exceptions;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author Dusan Balek
+ */
+public class TreeLoader extends LazyTreeLoader {
+
+    private static final String OPTION_OUTPUT_ROOT = "output-root"; //NOI18N
+    private static final Pattern ctor_summary_name = Pattern.compile("constructor[_.]summary"); //NOI18N
+    private static final Pattern method_summary_name = Pattern.compile("method[_.]summary"); //NOI18N
+    private static final Pattern field_detail_name = Pattern.compile("field[_.]detail"); //NOI18N
+    private static final Pattern ctor_detail_name = Pattern.compile("constructor[_.]detail"); //NOI18N
+    private static final Pattern method_detail_name = Pattern.compile("method[_.]detail"); //NOI18N
+    private static final ThreadLocal<Boolean> isTreeLoading = new ThreadLocal<Boolean>();
+
+    public static void preRegister(final Context context, final ClasspathInfo cpInfo, final boolean detached) {
+        context.put(lazyTreeLoaderKey, new TreeLoader(context, cpInfo, detached));
+    }
+    
+    public static TreeLoader instance (final Context ctx) {
+        final LazyTreeLoader tl = LazyTreeLoader.instance(ctx);
+        return (tl instanceof TreeLoader) ? (TreeLoader)tl : null;
+    }
+
+    public static boolean isTreeLoading() {
+        return isTreeLoading.get() == Boolean.TRUE;
+    }
+
+    private static final Logger LOGGER = Logger.getLogger(TreeLoader.class.getName());
+    private static final boolean ALWAYS_ALLOW_JDOC_ARG_NAMES = Boolean.getBoolean("java.source.args.from.http.jdoc");  //NOI18N
+    public  static boolean DISABLE_CONFINEMENT_TEST = false; //Only for tests!
+    public  static boolean DISABLE_ARTIFICAL_PARAMETER_NAMES = false; //Only for tests!
+
+    private Context context;
+    private ClasspathInfo cpInfo;
+    private Map<ClassSymbol, StringBuilder> couplingErrors;
+    private boolean partialReparse;
+    //@GuardedBy("this")
+    private Thread owner;
+    //@GuardedBy("this")
+    private int depth;
+    private final boolean checkContention;
+
+    private TreeLoader(Context context, ClasspathInfo cpInfo, boolean detached) {
+        this.context = context;
+        this.cpInfo = cpInfo;
+        this.checkContention = detached;
+    }
+    
+    @Override
+    public boolean loadTreeFor(final ClassSymbol clazz, boolean persist) {
+        boolean contended = !attachTo(Thread.currentThread());
+        try {
+            assert DISABLE_CONFINEMENT_TEST || JavaSourceAccessor.getINSTANCE().isJavaCompilerLocked() || !contended;
+            if (clazz != null) {
+                if (Enter.instance(context).getEnv(clazz) != null) {
+                    return true;
+                }
+                try {
+                    FileObject fo = SourceUtils.getFile(clazz, cpInfo);
+                    final JavacTaskImpl jti = (JavacTaskImpl) context.get(JavacTask.class);
+                    JavaCompiler jc = JavaCompiler.instance(context);
+                    if (fo != null && jti != null) {
+                        final Log log = Log.instance(context);
+                        log.nerrors = 0;
+                        final JavaFileManager jfm = context.get(JavaFileManager.class);
+                        final Symtab syms = Symtab.instance(context);
+                        JavaFileObject jfo = FileObjects.sourceFileObject(fo, null);
+                        Map<ClassSymbol, StringBuilder> oldCouplingErrors = couplingErrors;
+                        boolean oldSkipAPT = jc.skipAnnotationProcessing;
+                        try {
+                            couplingErrors = new HashMap<ClassSymbol, StringBuilder>();
+                            jc.skipAnnotationProcessing = true;
+                            Iterable<? extends CompilationUnitTree> cuts = jti.parse(jfo);
+                            for (CompilationUnitTree cut : cuts) {
+                                ((JCTree.JCCompilationUnit)cut).modle = clazz.packge().modle;
+                            }
+                            jti.analyze(jti.enter(cuts));
+                            if (persist && log.nerrors == 0) {
+                                final File classFolder = getClassFolder(jfm, clazz);
+                                if (classFolder != null) {
+                                    jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList(classFolder.getPath()).iterator()); //NOI18N
+                                    try {
+                                        if (jfm.hasLocation(StandardLocation.CLASS_OUTPUT) && canWrite(cpInfo)) {
+                                            Env<AttrContext> env = Enter.instance(context).getEnv(clazz);
+                                            HashMap<ClassSymbol, JCClassDecl> syms2trees;
+                                            if (env != null && pruneTree(env.tree, Symtab.instance(context), syms2trees = new HashMap<>())) {
+                                                isTreeLoading.set(Boolean.TRUE);
+                                                try {
+                                                    dumpSymFile(jti, clazz, syms2trees);
+                                                } finally {
+                                                    isTreeLoading.remove();
+                                                }
+                                            }
+                                        } else {
+                                            final JavaFileObject cfo = clazz.classfile;
+                                            final FileObject cFileObject = URLMapper.findFileObject(cfo.toUri().toURL());
+                                            FileObject root = null;
+                                            if (cFileObject != null) {
+                                                root = cFileObject;
+                                                for (String pathElement : ElementUtilities.getBinaryName(clazz).split("\\.")) {
+                                                    root = root.getParent();
+                                                }
+                                            }
+                                            if (root != null) {
+                                                final FileObject rootFin = root;
+                                                IndexingUtils.runAsScanWork(new Runnable() {
+                                                    @Override
+                                                    public void run() {
+                                                        try {
+                                                            JavaBinaryIndexer.preBuildArgs(rootFin,cFileObject);
+                                                        } catch (IOException ioe) {
+                                                            Exceptions.printStackTrace(ioe);
+                                                        }
+                                                    }
+                                                });
+                                            }
+                                        }
+                                    } finally {
+                                        jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList("").iterator()); //NOI18N
+                                    }
+                                }
+                            }
+                            return true;
+                        } finally {
+                            jc.skipAnnotationProcessing = oldSkipAPT;
+                            log.nerrors = 0;
+                            for (Map.Entry<ClassSymbol, StringBuilder> e : couplingErrors.entrySet()) {
+                                dumpCouplingAbort(new CouplingAbort(e.getKey(), null), e.getValue().toString());
+                            }
+                            couplingErrors = oldCouplingErrors;
+                        }
+                    }
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                }
+            }
+            return false;
+        } finally {
+            dettachFrom(Thread.currentThread());
+        }
+    }
+    
+    @Override
+    public boolean loadParamNames(ClassSymbol clazz) {
+        boolean contended = !attachTo(Thread.currentThread());
+        try {
+            assert DISABLE_CONFINEMENT_TEST || JavaSourceAccessor.getINSTANCE().isJavaCompilerLocked() || !contended;
+            if (clazz != null) {
+                JavadocHelper.TextStream page = JavadocHelper.getJavadoc(clazz, ALWAYS_ALLOW_JDOC_ARG_NAMES, null);
+                if (page != null && (!page.isRemote() || !EventQueue.isDispatchThread())) {
+                    if (getParamNamesFromJavadocText(page, clazz)) {
+                        return true;
+                    }
+                }
+                if (!DISABLE_ARTIFICAL_PARAMETER_NAMES) {
+                    fillArtificalParamNames(clazz);
+                    return true;
+                }
+            }
+
+            return false;
+        } finally {
+            dettachFrom(Thread.currentThread());
+        }
+    }
+
+    @Override
+    public void couplingError(ClassSymbol clazz, Tree t) {
+        if (this.partialReparse) {
+            super.couplingError(clazz, t);
+        }
+        if (clazz != null && couplingErrors != null) {
+            StringBuilder sb = couplingErrors.get(clazz);            
+            if (sb != null)
+                sb.append(getTreeInfo(t));
+            else
+                couplingErrors.put(clazz, getTreeInfo(t));
+        } else {
+            dumpCouplingAbort(new CouplingAbort(clazz, t), null);
+        }
+    }
+
+    @Override
+    public void updateContext(Context context) {
+        this.context = context;
+    }
+
+    public final void startPartialReparse () {
+        this.partialReparse = true;
+    }
+
+    public final void endPartialReparse () {
+        this.partialReparse = false;
+    }
+
+    public static boolean pruneTree(final JCTree tree, final Symtab syms, final HashMap<ClassSymbol, JCClassDecl> syms2trees) {
+        final AtomicBoolean ret = new AtomicBoolean(true);
+        new TreeScanner() {
+            @Override
+            public void visitMethodDef(JCMethodDecl tree) {
+                super.visitMethodDef(tree);
+                if (tree.sym == null || tree.type == null || tree.type == syms.unknownType)
+                    ret.set(false);
+                tree.body = null;
+            }
+            @Override
+            public void visitVarDef(JCVariableDecl tree) {
+                super.visitVarDef(tree);
+                if (tree.sym == null || tree.type == null || tree.type == syms.unknownType)
+                    ret.set(false);
+                tree.init = null;
+            }
+            @Override
+            public void visitClassDef(JCClassDecl tree) {
+                scan(tree.mods);
+                scan(tree.typarams);
+                scan(tree.extending);
+                scan(tree.implementing);
+                if (tree.defs != null) {
+                    List<JCTree> prev = null;
+                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                        scan(l.head);
+                        if (l.head.getTag() == JCTree.Tag.BLOCK) {
+                            if (prev != null)
+                                prev.tail = l.tail;
+                            else
+                                tree.defs = l.tail;
+                        }
+                        prev = l;
+                    }
+                }
+                if (tree.sym == null || tree.type == null || tree.type == syms.unknownType) {
+                    ret.set(false);
+                } else if (syms2trees != null) {
+                    syms2trees.put(tree.sym, tree);
+                }
+            }
+            @Override
+            public void visitModuleDef(JCTree.JCModuleDecl tree) {
+                ret.set(false);
+                super.visitModuleDef(tree);
+            }
+        }.scan(tree);
+        return ret.get();
+    }
+
+    public static void dumpSymFile(
+            @NonNull final JavaFileManager jfm,
+            @NonNull final JavacTaskImpl jti,
+            @NonNull final ClassSymbol clazz,
+            @NonNull final File classFolder,
+            @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
+        jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList(classFolder.getPath()).iterator()); //NOI18N
+        try {
+            dumpSymFile(jti, clazz, syms2trees);
+        } finally {
+            jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList("").iterator()); //NOI18N
+        }
+    }
+
+    @CheckForNull
+    private static File getClassFolder(
+        JavaFileManager jfm,
+        ClassSymbol clazz) throws IOException {
+        String binaryName = null;
+        String surl = null;
+        if (clazz.classfile != null) {
+            binaryName = jfm.inferBinaryName(StandardLocation.PLATFORM_CLASS_PATH, clazz.classfile);
+            if (binaryName == null)
+                binaryName = jfm.inferBinaryName(StandardLocation.CLASS_PATH, clazz.classfile);
+            surl = clazz.classfile.toUri().toURL().toExternalForm();
+        } else if (clazz.sourcefile != null) {
+            binaryName = jfm.inferBinaryName(StandardLocation.SOURCE_PATH, clazz.sourcefile);
+            surl = clazz.sourcefile.toUri().toURL().toExternalForm();
+        }
+        if (binaryName == null || surl == null) {
+            return null;
+        }
+        int index = surl.lastIndexOf(FileObjects.convertPackage2Folder(binaryName));
+        if (index > 0) {
+            return JavaIndex.getClassFolder(new URL(surl.substring(0, index)));
+        } else {
+            LOGGER.log(
+               Level.INFO,
+               "Invalid binary name when writing sym file for class: {0}, source: {1}, binary name {2}",    // NOI18N
+               new Object[] {
+                   clazz.flatname,
+                   surl,
+                   binaryName
+               });
+            return null;
+        }
+    }
+
+    private static void dumpSymFile(
+            @NonNull final JavacTaskImpl jti,
+            @NonNull final ClassSymbol clazz,
+            @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
+        Log log = Log.instance(jti.getContext());
+        JavaCompiler compiler = JavaCompiler.instance(jti.getContext());
+        JavaFileObject prevLogTo = log.useSource(null);
+        DiscardDiagnosticHandler discardDiagnosticHandler = new Log.DiscardDiagnosticHandler(log);
+        final TaskListener listener = new TaskListener() {
+            @Override
+            public void started(TaskEvent e) {
+                if (e != null && e.getKind() == TaskEvent.Kind.GENERATE) {
+                    JCClassDecl tree = syms2trees.get((ClassSymbol)e.getTypeElement());
+                    if (tree != null)
+                        pruneTree(tree, Symtab.instance(jti.getContext()), null);
+                }
+            }
+            @Override
+            public void finished(TaskEvent e) {
+            }
+        };
+        boolean oldSkipAP = compiler.skipAnnotationProcessing;
+        try {
+            compiler.skipAnnotationProcessing = true;
+            jti.addTaskListener(listener);
+            jti.generate(Collections.singletonList(clazz));
+        } catch (InvalidSourcePath isp) {
+            LOGGER.log(Level.INFO, "InvalidSourcePath reported when writing sym file for class: {0}", clazz.flatname); // NOI18N
+        } finally {
+            jti.removeTaskListener(listener);
+            compiler.skipAnnotationProcessing = oldSkipAP;
+            log.popDiagnosticHandler(discardDiagnosticHandler);
+            log.useSource(prevLogTo);
+        }
+    }
+
+    private static final int MAX_DUMPS = Integer.getInteger("org.netbeans.modules.java.source.parsing.JavacParser.maxDumps", 255);
+    
+    public static void dumpCouplingAbort(CouplingAbort couplingAbort, String treeInfo) {
+        if (treeInfo == null)
+            treeInfo = getTreeInfo(couplingAbort.getTree()).toString();
+        String dumpDir = System.getProperty("netbeans.user") + "/var/log/"; //NOI18N
+        JavaFileObject classFile = couplingAbort.getClassFile();
+        String cfURI = classFile != null ? classFile.toUri().toASCIIString() : "<unknown>"; //NOI18N
+        JavaFileObject sourceFile = couplingAbort.getSourceFile();
+        String sfURI = sourceFile != null ? sourceFile.toUri().toASCIIString() : "<unknown>"; //NOI18N
+        String origName = classFile != null ? classFile.getName() : "unknown"; //NOI18N
+        File f = new File(dumpDir + origName + ".dump"); // NOI18N
+        boolean dumpSucceeded = false;
+        int i = 1;
+        while (i < MAX_DUMPS) {
+            if (!f.exists())
+                break;
+            f = new File(dumpDir + origName + '_' + i + ".dump"); // NOI18N
+            i++;
+        }
+        if (!f.exists()) {
+            try {
+                f.getParentFile().mkdirs();
+                OutputStream os = new FileOutputStream(f);
+                PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF-8")); // NOI18N
+                try {
+                    writer.println("Coupling error:"); //NOI18N
+                    writer.println(String.format("class file %s", cfURI)); //NOI18N
+                    writer.println(String.format("source file %s", sfURI)); //NOI18N
+                    writer.println("----- Source file content: ----------------------------------------"); // NOI18N
+                    if (sourceFile != null) {
+                        try {
+                            writer.println(sourceFile.getCharContent(true));
+                        } catch (UnsupportedOperationException uoe) {
+                            writer.println("<unknown>"); //NOI18N
+                        }
+                    } else {
+                        writer.println("<unknown>"); //NOI18N
+                    }
+                    writer.print("----- Trees: -------------------------------------------------------"); // NOI18N
+                    writer.println(treeInfo);
+                    writer.println("----- Stack trace: ---------------------------------------------"); // NOI18N
+                    couplingAbort.printStackTrace(writer);
+                } finally {
+                    writer.close();
+                    dumpSucceeded = true;
+                }
+            } catch (IOException ioe) {
+                LOGGER.log(Level.INFO, "Error when writing coupling error dump file!", ioe); // NOI18N
+            }
+        }
+        LOGGER.log(Level.WARNING, "Coupling error:\nclass file: {0}\nsource file: {1}{2}\n", new Object[] {cfURI, sfURI, treeInfo}); //NOI18N
+        if (!dumpSucceeded) {
+            LOGGER.log(Level.WARNING,
+                    "Dump could not be written. Either dump file could not " + // NOI18N
+                    "be created or all dump files were already used. Please " + // NOI18N
+                    "check that you have write permission to '" + dumpDir + "' and " + // NOI18N
+                    "clean all *.dump files in that directory."); // NOI18N
+        }
+    }
+
+    private static StringBuilder getTreeInfo(Tree t) {
+        StringBuilder info = new StringBuilder("\n"); //NOI18N
+        if (t != null) {
+            switch (t.getKind()) {
+                case ANNOTATION_TYPE:
+                case CLASS:
+                case ENUM:
+                case INTERFACE:
+                    info.append("CLASS: ").append(((ClassTree) t).getSimpleName().toString()); //NOI18N
+                    break;
+                case VARIABLE:
+                    info.append("VARIABLE: ").append(((VariableTree) t).getName().toString()); //NOI18N
+                    break;
+                case METHOD:
+                    info.append("METHOD: ").append(((MethodTree) t).getName().toString()); //NOI18N
+                    break;
+                case TYPE_PARAMETER:
+                    info.append("TYPE_PARAMETER: ").append(((TypeParameterTree) t).getName().toString()); //NOI18N
+                    break;
+                default:
+                    info.append("TREE: <unknown>"); //NOI18N
+                    break;
+            }
+        }
+        return info;
+    }
+
+    private boolean getParamNamesFromJavadocText(final JavadocHelper.TextStream page, final ClassSymbol clazz) {
+        HTMLEditorKit.Parser parser;
+        InputStream is = null;        
+        String charset = null;
+        for (;;) {
+            try{
+                is = page.openStream();
+                Reader reader = charset == null ? new InputStreamReader(is): new InputStreamReader(is, charset);
+                parser = new ParserDelegator();
+                parser.parse(reader, new ParserCallback() {                    
+
+                    private int state = 0; //init
+                    private String signature = null;
+                    private StringBuilder sb = null;
+
+                    @Override
+                    public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
+                        if (t == HTML.Tag.A) {
+                            String attrName = (String)a.getAttribute(HTML.Attribute.NAME);
+                            if (attrName != null && ctor_summary_name.matcher(attrName).matches()) {
+                                // we have found desired javadoc constructor info anchor
+                                state = 10; //ctos open
+                            } else if (attrName != null && method_summary_name.matcher(attrName).matches()) {
+                                // we have found desired javadoc method info anchor
+                                state = 20; //methods open
+                            } else if (attrName != null && field_detail_name.matcher(attrName).matches()) {
+                                state = 30; //end
+                            } else if (attrName != null && ctor_detail_name.matcher(attrName).matches()) {
+                                state = 30; //end
+                            } else if (attrName != null && method_detail_name.matcher(attrName).matches()) {
+                                state = 30; //end
+                            } else if (state == 12 || state == 22) {
+                                String attrHref = (String)a.getAttribute(HTML.Attribute.HREF);
+                                if (attrHref != null) {
+                                    int idx = attrHref.indexOf('#');
+                                    if (idx >= 0) {
+                                        signature = attrHref.substring(idx + 1);
+                                        sb = new StringBuilder();
+                                    }
+                                }
+                            }
+                        } else if (t == HTML.Tag.TABLE) {
+                            if (state == 10 || state == 20)
+                                state++;
+                        } else if (t == HTML.Tag.CODE) {
+                            if (state == 11 || state == 21)
+                                state++;
+                        } else if (t == HTML.Tag.DIV && a.containsAttribute(HTML.Attribute.CLASS, "block")) { //NOI18N
+                            if (state == 11 && signature != null && sb != null) {
+                                setParamNames(signature, sb.toString().trim(), true);
+                                signature = null;
+                                sb = null;
+                            } else if (state == 21 && signature != null && sb != null) {
+                                setParamNames(signature, sb.toString().trim(), false);
+                                signature = null;
+                                sb = null;
+                            }
+                        }
+                    }
+
+                    @Override
+                    public void handleEndTag(Tag t, int pos) {
+                        if (t == HTML.Tag.CODE) {
+                            if (state == 12 || state == 22)
+                                state--;
+                        } else if (t == HTML.Tag.TABLE) {
+                            if (state == 11 || state == 21)
+                                state--;
+                        }
+                    }
+
+                    @Override
+                    public void handleText(char[] data, int pos) {
+                        if (signature != null && sb != null && (state == 12 || state == 22))
+                            sb.append(data);
+                    }
+
+                    @Override
+                    public void handleSimpleTag(Tag t, MutableAttributeSet a, int pos) {
+                        if (t == HTML.Tag.BR) {
+                            if (state == 11 && signature != null && sb != null) {
+                                setParamNames(signature, sb.toString().trim(), true);
+                                signature = null;
+                                sb = null;
+                            } else if (state == 21 && signature != null && sb != null) {
+                                setParamNames(signature, sb.toString().trim(), false);
+                                signature = null;
+                                sb = null;
+                            }
+                        }
+                    }
+
+                    private void setParamNames(String signature, String names, boolean isCtor) {
+                        ArrayList<String> paramTypes = new ArrayList<String>();
+                        int idx = -1;
+                        for(int i = 0; i < signature.length(); i++) {
+                            switch(signature.charAt(i)) {
+                                case '-':
+                                case '(':
+                                case ')':
+                                case ',':
+                                    if (idx > -1 && idx < i - 1) {
+                                        String typeName = signature.substring(idx + 1, i).trim();
+                                        if (typeName.endsWith("...")) //NOI18N
+                                            typeName = typeName.substring(0, typeName.length() - 3) + "[]"; //NOI18N
+                                        paramTypes.add(typeName);
+                                    }
+                                    idx = i;
+                                    break;
+                            }
+                        }
+                        String methodName = null;
+                        ArrayList<String> paramNames = new ArrayList<String>();
+                        idx = -1;
+                        for(int i = 0; i < names.length(); i++) {
+                            switch(names.charAt(i)) {
+                                case '(':
+                                    methodName = names.substring(0, i);
+                                    break;
+                                case ')':
+                                case ',':
+                                    if (idx > -1) {
+                                        paramNames.add(names.substring(idx + 1, i));
+                                        idx = -1;
+                                    }
+                                    break;
+                                case 160: //&nbsp;
+                                    idx = i;
+                                    break;
+                            }
+                        }
+                        assert methodName != null : "Null methodName. Signature: [" + signature + "], Names: [" + names + "]";
+                        assert paramTypes.size() == paramNames.size() : "Inconsistent param types/names. Signature: [" + signature + "], Names: [" + names + "]";
+                        if (paramNames.size() > 0) {
+                            for (Symbol s : clazz.members().getSymbolsByName(isCtor
+                                    ? clazz.name.table.names.init
+                                    : clazz.name.table.fromString(methodName))) {
+                                if (s.kind == Kinds.Kind.MTH && s.owner == clazz) {
+                                    MethodSymbol sym = (MethodSymbol)s;
+                                    List<VarSymbol> params = sym.params;
+                                    if (checkParamTypes(params, paramTypes)) {
+                                        for (String name : paramNames) {
+                                            params.head.setName(clazz.name.table.fromString(name));
+                                            params = params.tail;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+
+                    private boolean checkParamTypes(List<VarSymbol> params, ArrayList<String> paramTypes) {
+                        Types types = Types.instance(context);
+                        for (String typeName : paramTypes) {
+                            if (params.isEmpty())
+                                return false;
+                            Type type = params.head.type;
+                            if (type.isParameterized())
+                                type = types.erasure(type);
+                            if (!typeName.equals(type.toString()))
+                                return false;
+                            params = params.tail;
+                        }
+                        return params.isEmpty();
+                    }
+                }, charset != null);
+                return true;
+            } catch (ChangedCharSetException e) {
+                if (charset == null) {
+                    charset = JavadocHelper.getCharSet(e);
+                    //restart with valid charset
+                } else {
+                    e.printStackTrace();
+                    break;
+                }
+            } catch (InterruptedIOException x) {
+                //Http javadoc timeout
+                break;
+            } catch(IOException ioe){
+                ioe.printStackTrace();
+                break;
+            }finally{
+                parser = null;
+                if (is!=null) {
+                    try{
+                        is.close();
+                    }catch(IOException ioe){
+                        ioe.printStackTrace();
+                    }
+                }
+            }
+        }
+        return false;
+    }
+    
+    private void fillArtificalParamNames(final ClassSymbol clazz) {
+        for (Symbol s : clazz.getEnclosedElements()) {
+            if (s instanceof MethodSymbol) {
+                MethodSymbol ms = (MethodSymbol) s;
+
+                if (ms.getParameters().isEmpty()) {
+                    continue;
+                }
+                
+                Set<String> usedNames = new HashSet<String>();
+                
+                for (VarSymbol vs : ms.getParameters()) {
+                    String name = JavaSourceAccessor.getINSTANCE().generateReadableParameterName(vs.asType().toString(), usedNames);
+
+                    vs.setName(clazz.name.table.fromString(name));
+                }
+            }
+        }
+    }
+
+    private synchronized boolean attachTo(final Thread thread) {
+        assert thread != null;
+        if (!checkContention) {
+            return true;
+        } else if (this.owner == null) {
+            assert this.depth == 0;
+            this.owner = thread;
+            this.depth++;
+            return true;
+        } else if (this.owner == thread) {
+            assert this.depth > 0;
+            this.depth++;
+            return true;
+        } else {
+            assert this.depth > 0;
+            return false;
+        }
+    }
+
+    private synchronized boolean dettachFrom(final Thread thread) {
+        assert thread != null;
+        if (!checkContention) {
+            return true;
+        } else if (this.owner == thread) {
+            assert depth > 0;
+            this.depth--;
+            if (this.depth == 0) {
+                this.owner = null;
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
+    
+    private boolean canWrite(final ClasspathInfo cpInfo) {
+        final FileManagerTransaction fmTx = ClasspathInfoAccessor.getINSTANCE().getFileManagerTransaction(cpInfo);
+        assert fmTx != null;
+        return fmTx.canWrite();
+    }
+
+    @ServiceProvider(service=TreeLoaderRegistry.class)
+    public static final class TreeLoaderRegistryImpl implements TreeLoaderRegistry {
+
+        @Override
+        public void enhance(Context context, ClasspathInfo cpInfo, boolean detached) {
+            TreeLoader.preRegister(context, cpInfo, detached);
+        }
+        
+    }
+    
+    @ServiceProvider(service=DuplicateClassRegistry.class)
+    public static final class DuplicateClassRegistryImpl implements DuplicateClassRegistry {
+
+        @Override
+        public void enhance(Context context, FQN2Files fqn2Files) {
+            if (fqn2Files == null)
+                return;
+            context.put(DuplicateClassChecker.class, new DuplicateClassChecker() {
+                @Override
+                public boolean check(Name name, JavaFileObject jfo) {
+                    return fqn2Files.check(name, jfo);
+                }
+            });
+        }
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
new file mode 100644
index 0000000..6658518
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.nbjavac.services;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.model.JavacElements;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import junit.framework.TestCase;
+
+/**XXX: why is this passing?????
+ *
+ * @author lahvac
+ */
+public class CouplingTest extends TestCase {
+
+    public void test200122() throws Exception {
+        String code = "package test; public class Test { void t() { new Runnable() { public void run() {} }; } }";
+        List<String> fqns = compile(code);
+
+        assertEquals(testCoupling(code, false, fqns), testCoupling(code, true, fqns));
+    }
+    
+    //<editor-fold defaultstate="collapsed" desc=" Test Infrastructure ">
+    private static class MyFileObject extends SimpleJavaFileObject {
+        private String text;
+
+        public MyFileObject(String text) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+
+    private File workingDir;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        workingDir = File.createTempFile("CouplingTest", "");
+
+        workingDir.delete();
+        workingDir.mkdirs();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        deleteRecursively(workingDir);
+        super.tearDown();
+    }
+
+    private List<String> compile(String code) throws Exception {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final String version = System.getProperty("java.vm.specification.version"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        StandardJavaFileManager std = tool.getStandardFileManager(null, null, null);
+
+        std.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(workingDir));
+
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath, "-source", version, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(new MyFileObject(code)));
+        Iterable<? extends CompilationUnitTree> cuts = ct.parse();
+
+        ct.analyze();
+
+        final List<String> result = new ArrayList<String>();
+
+        new ErrorAwareTreePathScanner<Void, Void>() {
+            @Override public Void visitClass(ClassTree node, Void p) {
+                Element el = Trees.instance(ct).getElement(getCurrentPath());
+
+                if (el != null && (el.getKind().isClass() || el.getKind().isInterface())) {
+                    result.add(ct.getElements().getBinaryName((TypeElement) el).toString());
+                }
+
+                return super.visitClass(node, p);
+            }
+        }.scan(cuts, null);
+
+        ct.generate();
+
+        return result;
+    }
+
+    private Set<String> testCoupling(String code, boolean loadFromClasses, List<String> fqns) throws IOException {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        StandardJavaFileManager std = tool.getStandardFileManager(null, null, null);
+
+        if (loadFromClasses) {
+            std.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(workingDir));
+            std.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(workingDir));
+        }
+
+        JavacTaskImpl ct = Utilities.createJavac(std);
+        ct.enter();
+        
+        if (loadFromClasses) {
+            for (String fqn : fqns) {
+                assertNotNull(fqn, ((JavacElements)ct.getElements()).getTypeElementByBinaryName(fqn));
+            }
+        }
+
+        ct.parse(Utilities.fileObjectFor(code));
+        ct.analyze();
+
+        Set<String> classInfo = new HashSet<String>();
+
+        for (String fqn : fqns) {
+            ClassSymbol clazz = ((JavacElements)ct.getElements()).getTypeElementByBinaryName(fqn);
+            StringBuilder info = new StringBuilder();
+
+            info.append(clazz.flatname.toString()).append(",");
+            info.append(Long.toHexString(clazz.flags() & ~(Flags.FROMCLASS | Flags.APT_CLEANED))).append(",");
+            info.append(clazz.hasOuterInstance());
+
+            classInfo.add(info.toString());
+        }
+
+        return classInfo;
+    }
+
+    private void deleteRecursively(File f) {
+        if (f.isDirectory()) {
+            for (File c : f.listFiles()) {
+                deleteRecursively(c);
+            }
+        }
+
+        f.delete();
+    }
+    //</editor-fold>
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java
new file mode 100644
index 0000000..f5a226a
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import com.sun.tools.javac.api.ClassNamesForFileOraculum;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.NestingKind;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author lahvac
+ */
+public class ClassNamesForFileOraculumImplTest {
+
+    public ClassNamesForFileOraculumImplTest() {
+    }
+
+    @Test
+    public void testDivineSources() {
+        TestJavaFileObject fo1 = new TestJavaFileObject();
+        TestJavaFileObject fo2 = new TestJavaFileObject();
+        Map<JavaFileObject, List<String>> fo2FQNs = new HashMap<JavaFileObject, List<String>>();
+
+        fo2FQNs.put(fo1, Arrays.asList("a.b.c.Class1"));
+        fo2FQNs.put(fo2, Arrays.asList("e.f.g"));
+
+        ClassNamesForFileOraculum oraculum = new ClassNamesForFileOraculumImpl(fo2FQNs);
+
+        assertArrayEquals(new JavaFileObject[] {fo1}, oraculum.divineSources("a.b.c"));
+        assertNull(oraculum.divineSources("a.b"));
+        assertNull(oraculum.divineSources("e.f.g"));
+    }
+
+    private static final class TestJavaFileObject extends SimpleJavaFileObject {
+
+        public TestJavaFileObject() {
+            super(URI.create("test://test.java"), Kind.SOURCE);
+        }
+
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java
new file mode 100644
index 0000000..874079c
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.util.Collection;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+
+/**
+ *
+ * @author lahvac
+ */
+public class MultiPassCompileWorkerTest extends NBJavacCompileWorkerTestBase {
+    
+    public MultiPassCompileWorkerTest(String name) {
+        super(name);
+    }
+    
+    @Override
+    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) throws Exception {
+        JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER = true;
+        ParsingOutput fromOnePass = new OnePassCompileWorker().compile(null, context, javaContext, files);
+        return new MultiPassCompileWorker().compile(fromOnePass, context, javaContext, files);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java
new file mode 100644
index 0000000..09e57ae
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.CompileWorkerTestBase;
+
+/**
+ *
+ * @author lahvac
+ */
+public abstract class NBJavacCompileWorkerTestBase extends CompileWorkerTestBase {
+    
+    public NBJavacCompileWorkerTestBase(String name) {
+        super(name);
+    }
+    
+    public void test219787() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test3.java", "package test; public class Test3")),
+                                           Arrays.asList(virtualCompileTuple("test/Test1.virtual", "package test; public class Test1 {}"),
+                                                         virtualCompileTuple("test/Test2.virtual", "package test; public class Test2 {}")));
+        
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+        
+        Set<String> createdFiles = new HashSet<String>();
+        
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+        
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test3.sig")), createdFiles);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java
new file mode 100644
index 0000000..743e114
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.util.Collection;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+
+/**
+ *
+ * @author lahvac
+ */
+public class OnePassCompileWorkerTest extends NBJavacCompileWorkerTestBase {
+    
+    public OnePassCompileWorkerTest(String name) {
+        super(name);
+    }
+
+    @Override
+    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) {
+        return new OnePassCompileWorker().compile(null, context, javaContext, files);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java
new file mode 100644
index 0000000..093b0b0
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.util.Collection;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+
+/**
+ *
+ * @author lahvac
+ */
+public class SuperOnePassCompileWorkerTest extends NBJavacCompileWorkerTestBase {
+    
+    public SuperOnePassCompileWorkerTest(String name) {
+        super(name);
+    }
+    
+    @Override
+    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) {
+        return new SuperOnePassCompileWorker().compile(null, context, javaContext, files);
+    }
+    
+}


[11/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
----------------------------------------------------------------------
diff --git a/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java b/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
index 79df8ba..b6a220b 100644
--- a/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
+++ b/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
@@ -22,7 +22,7 @@ import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -634,7 +634,7 @@ nextCpE:for (ClassPath.Entry e : cp.entries()) {
     }
 
     //@NonThreadSafe
-    private static final class FindPosScanner extends TreePathScanner<Void, Void> {
+    private static final class FindPosScanner extends ErrorAwareTreePathScanner<Void, Void> {
 
         private final FileObject target;
         private final Elements elements;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.j2seproject/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.j2seproject/nbproject/project.properties b/java.j2seproject/nbproject/project.properties
index e242fda..ca9f13c 100644
--- a/java.j2seproject/nbproject/project.properties
+++ b/java.j2seproject/nbproject/project.properties
@@ -37,3 +37,4 @@ test.config.stableBTD.excludes=\
     **/BuildImplTest.class,\
     **/J2SEConfigurationProviderTest.class,\
     **/J2SEProjectGeneratorTest.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
index fe483ce..f7a129c 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.TypeCastTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.beans.Expression;
 import java.util.Collection;
 import java.util.EnumSet;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
index 98de561..edad948 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
@@ -30,7 +30,7 @@ import com.sun.source.tree.ForLoopTree;
 import com.sun.source.tree.IfTree;
 import com.sun.source.tree.ThrowTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * This Visitor counts a Cyclomatic complexity on the visited tree. 
@@ -40,7 +40,7 @@ import com.sun.source.util.TreePathScanner;
  * 
  * @author sdedic
  */
-public final class CyclomaticComplexityVisitor extends TreePathScanner<Object, Object> {
+public final class CyclomaticComplexityVisitor extends ErrorAwareTreePathScanner<Object, Object> {
     private int complexity;
     
     private boolean inClass;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
index 03128ef..2716b23 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.TypeCastTree;
 import com.sun.source.tree.UnionTypeTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -51,7 +51,7 @@ import org.netbeans.api.java.source.CompilationInfo;
  * Collect dependencies on external classes.
  * Depending on 'ignoreJavaLibraries' it ignores classes whose QN begins with 'java.' or 'javax.'.
  */
-class DependencyCollector extends TreePathScanner<Object, Object> {
+class DependencyCollector extends ErrorAwareTreePathScanner<Object, Object> {
     private boolean ignoreJavaLibraries;
     private final CompilationInfo info;
     private TypeElement outermostClass;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
index e6fd546..1954a57 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
@@ -29,14 +29,14 @@ import com.sun.source.tree.SwitchTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * Counts the maximum depth of the Tree
  * 
  * @author sdedic
  */
-public final class DepthVisitor extends TreePathScanner {
+public final class DepthVisitor extends ErrorAwareTreePathScanner {
     private int depth;
     private int maxDepth;
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
index 01d2fb5..0ef1d89 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.ParenthesizedTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -48,7 +48,7 @@ import org.netbeans.api.java.source.CompilationInfo;
  * 
  * @author sdedic
  */
-class ExpressionVisitor extends TreePathScanner<Object, Object> {
+class ExpressionVisitor extends ErrorAwareTreePathScanner<Object, Object> {
     private static final EnumSet<Tree.Kind> NUMERIC_OPERATORS = EnumSet.of(
             Tree.Kind.BITWISE_COMPLEMENT, Tree.Kind.LEFT_SHIFT, Tree.Kind.RIGHT_SHIFT, Tree.Kind.UNSIGNED_RIGHT_SHIFT, 
             Tree.Kind.DIVIDE, Tree.Kind.MINUS, Tree.Kind.MULTIPLY, Tree.Kind.PLUS, Tree.Kind.REMAINDER, 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
index c973cc1..25dca56 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
@@ -33,7 +33,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collection;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -484,7 +484,7 @@ public class MethodMetrics {
      * The visitor will ignore returns, which are the *sole* statement in a if-branch.
      * Such branches are considered to be guards, which abort further processing.
      */
-    private static class ReturnCountVisitor extends TreePathScanner {
+    private static class ReturnCountVisitor extends ErrorAwareTreePathScanner {
         /**
          * Suppressed in local classes
          */
@@ -585,7 +585,7 @@ public class MethodMetrics {
      * Counts number of 'negations' in a Tree. A negation is either unary ! or binary != inequality
      * operator.
      */
-    private static class NegationsVisitor extends TreePathScanner {
+    private static class NegationsVisitor extends ErrorAwareTreePathScanner {
         private int negationsCount;
         private final boolean ignoreAsserts;
 
@@ -627,7 +627,7 @@ public class MethodMetrics {
     /**
      * Utility scanner class, which counts all kinds of loops in the scanned subtree 
      */
-    private static class LoopFinder extends TreePathScanner {
+    private static class LoopFinder extends ErrorAwareTreePathScanner {
         private int loopCount;
 
         public int getLoopCount() {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
----------------------------------------------------------------------
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
index add17e0..253ca4b 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
@@ -40,7 +40,7 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * Non-comment line visitor. Counts the number of non-comment
@@ -50,7 +50,7 @@ import com.sun.source.util.TreePathScanner;
  * 
  * @author sdedic
  */
-public final class NCLOCVisitor extends TreePathScanner<Object, Object> {
+public final class NCLOCVisitor extends ErrorAwareTreePathScanner<Object, Object> {
     /**
      * The source text 
      */

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.metrics/test/unit/src/org/netbeans/modules/java/metrics/hints/MethodMetricsTest.java
----------------------------------------------------------------------
diff --git a/java.metrics/test/unit/src/org/netbeans/modules/java/metrics/hints/MethodMetricsTest.java b/java.metrics/test/unit/src/org/netbeans/modules/java/metrics/hints/MethodMetricsTest.java
index d0601bd..e9937a1 100644
--- a/java.metrics/test/unit/src/org/netbeans/modules/java/metrics/hints/MethodMetricsTest.java
+++ b/java.metrics/test/unit/src/org/netbeans/modules/java/metrics/hints/MethodMetricsTest.java
@@ -74,7 +74,7 @@ public class MethodMetricsTest extends NbTestCase {
     }
     
     /**
-     * Runs the hints through code, which triggers all branches of TreeScanner.
+     * Runs the hints through code, which triggers all branches of ErrorAwareTreeScanner.
      * This is just a sanity check that a hint does not throw exceptions on some
      * construction; but will not catch all errors, obviously.
      */

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.module.graph/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.module.graph/nbproject/project.properties b/java.module.graph/nbproject/project.properties
index 5137752..b3de9cd 100644
--- a/java.module.graph/nbproject/project.properties
+++ b/java.module.graph/nbproject/project.properties
@@ -17,3 +17,4 @@
 
 javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.module.graph/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/java.module.graph/nbproject/project.xml b/java.module.graph/nbproject/project.xml
index cec3af8..dc2b425 100644
--- a/java.module.graph/nbproject/project.xml
+++ b/java.module.graph/nbproject/project.xml
@@ -69,15 +69,15 @@
                         <specification-version>1.44</specification-version>
                     </run-dependency>
                 </dependency>
-                <dependency>
+<!--                <dependency>
                     <code-name-base>org.netbeans.libs.javacapi</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
                         <specification-version>8.19</specification-version>
                     </run-dependency>
-                </dependency>
-                <dependency>
+                </dependency>-->
+<!--                <dependency>
                     <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
@@ -85,7 +85,7 @@
                         <release-version>1</release-version>
                         <specification-version>0.42</specification-version>
                     </run-dependency>
-                </dependency>
+                </dependency>-->
                 <dependency>
                     <code-name-base>org.netbeans.modules.java.graph</code-name-base>
                     <build-prerequisite/>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
----------------------------------------------------------------------
diff --git a/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java b/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
index 807ecfe..616c234 100644
--- a/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
+++ b/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
@@ -49,7 +49,7 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.awt.Image;
 import java.io.CharConversionException;
@@ -511,7 +511,7 @@ public class BreadCrumbsNodeImpl implements BreadcrumbsElement {
                         return;
                     }
 
-                    tp.getLeaf().accept(new TreeScanner<Void, TreePath>() {
+                    tp.getLeaf().accept(new ErrorAwareTreeScanner<Void, TreePath>() {
                         @Override public Void scan(Tree node, TreePath p) {
                             if (node == null) return null;
                             if (node.getKind() == Kind.IF) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
----------------------------------------------------------------------
diff --git a/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java b/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
index 1ed6372..3b73e42 100644
--- a/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
+++ b/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
@@ -27,7 +27,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -211,7 +211,7 @@ public class ElementScanningTask implements CancellableTask<CompilationInfo>{
         }
     }
 
-    private static class PositionVisitor extends TreePathScanner<Context, Void> {
+    private static class PositionVisitor extends ErrorAwareTreePathScanner<Context, Void> {
 
         private final Trees trees;
         private final SourcePositions sourcePositions;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
----------------------------------------------------------------------
diff --git a/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java b/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
index a700f1d..875ede6 100644
--- a/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
+++ b/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
@@ -31,7 +31,7 @@ import com.sun.source.tree.RequiresTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UsesTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Toolkit;
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.java.source.ui.ElementOpen;
@@ -237,7 +237,7 @@ public final class OpenAction extends AbstractAction {
                 @Override
                 public void run(final CompilationController cc) throws Exception {
                     cc.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
                         @Override
                         public Void visitExports(ExportsTree node, Void p) {
                             if (matches(handle, ModuleElement.DirectiveKind.EXPORTS, node.getPackageName())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.preprocessorbridge/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.preprocessorbridge/nbproject/project.properties b/java.preprocessorbridge/nbproject/project.properties
index 8aff049..a6f0b61 100644
--- a/java.preprocessorbridge/nbproject/project.properties
+++ b/java.preprocessorbridge/nbproject/project.properties
@@ -20,3 +20,4 @@ javac.source=1.8
 spec.version.base=1.49.0
 javadoc.apichanges=${basedir}/apichanges.xml
 
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/manifest.mf
----------------------------------------------------------------------
diff --git a/java.source.base/manifest.mf b/java.source.base/manifest.mf
index 09331a8..21b5540 100644
--- a/java.source.base/manifest.mf
+++ b/java.source.base/manifest.mf
@@ -3,3 +3,4 @@ OpenIDE-Module: org.netbeans.modules.java.source.base
 OpenIDE-Module-Implementation-Version: 2
 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/source/base/Bundle.properties
 OpenIDE-Module-Layer: org/netbeans/modules/java/source/base/layer.xml
+OpenIDE-Module-Requires: org.netbeans.modules.javac

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.source.base/nbproject/project.properties b/java.source.base/nbproject/project.properties
index 85952e9..e83bfa0 100644
--- a/java.source.base/nbproject/project.properties
+++ b/java.source.base/nbproject/project.properties
@@ -146,6 +146,7 @@ test.config.generator.includes=\
 test.config.jet-main.includes=\
     ${test.config.core.includes},\
     ${test.config.generator.includes},\
+    org/netbeans/api/java/source/TreeUtilitiesTest.class,\
     org/netbeans/api/java/source/TypeUtilitiesTest.class,\
     org/netbeans/api/java/source/TreePathHandleTest.class,\
     org/netbeans/api/java/source/TreeMirrorHandleTest.class,\

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/java.source.base/nbproject/project.xml b/java.source.base/nbproject/project.xml
index e21285e..dcc344b 100644
--- a/java.source.base/nbproject/project.xml
+++ b/java.source.base/nbproject/project.xml
@@ -290,6 +290,9 @@
                 <test-type>
                     <name>unit</name>
                     <test-dependency>
+                        <code-name-base>org.netbeans.api.progress.nb</code-name-base>
+                    </test-dependency>
+                    <test-dependency>
                         <code-name-base>org.netbeans.core.startup</code-name-base>
                     </test-dependency>
                     <test-dependency>
@@ -410,18 +413,15 @@
                         <code-name-base>org.openide.text</code-name-base>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.openide.util.ui</code-name-base>
+                        <code-name-base>org.openide.util.lookup</code-name-base>
                         <compile-dependency/>
                         <test/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.openide.util.lookup</code-name-base>
+                        <code-name-base>org.openide.util.ui</code-name-base>
                         <compile-dependency/>
                         <test/>
                     </test-dependency>
-                    <test-dependency>
-                        <code-name-base>org.netbeans.api.progress.nb</code-name-base>
-                    </test-dependency>
                 </test-type>
             </test-dependencies>
             <public-packages>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/AssignComments.java b/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
index ec75aef..1606b2d 100644
--- a/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
+++ b/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
@@ -36,7 +36,7 @@ import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -63,7 +63,7 @@ import static org.netbeans.modules.java.source.save.PositionEstimator.NOPOS;
  *
  * @author Pavel Flaska, Rastislav Komara, Jan Lahoda
  */
-class AssignComments extends TreeScanner<Void, Void> {
+class AssignComments extends ErrorAwareTreeScanner<Void, Void> {
     
     private static final EnumSet<Tree.Kind> JAVADOC_KINDS = EnumSet.of(
             Tree.Kind.CLASS,

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java b/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
index 8a47f53..33937b7 100644
--- a/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
+++ b/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
@@ -23,16 +23,19 @@ import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
 import com.sun.source.util.TreePath;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.model.JavacElements;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ModuleElement;
@@ -41,6 +44,7 @@ import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
 import javax.swing.text.Document;
 import javax.tools.Diagnostic;
+
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.CheckReturnValue;
 import org.netbeans.api.annotations.common.NonNull;
@@ -48,6 +52,8 @@ import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.api.annotations.common.NullUnknown;
 import org.netbeans.api.lexer.TokenHierarchy;
 import org.netbeans.modules.java.preprocessorbridge.spi.WrapperFactory;
+import org.netbeans.modules.java.source.CompilationInfoAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
 import org.netbeans.modules.java.source.parsing.DocPositionRegion;
 import org.netbeans.modules.java.source.parsing.FileObjects;
@@ -222,8 +228,8 @@ public class CompilationInfo {
                             SourceUtils.getModuleName(impl.getRoot().toURL(), true) :
                             null)
                     .map(elements::getModuleElement)
-                    .map((module) -> elements.getTypeElementByBinaryName(module, name))
-                    .orElseGet(() -> elements.getTypeElementByBinaryName(name));
+                    .map((module) -> ElementUtils.getTypeElementByBinaryName(this, module, name))
+                    .orElseGet(() -> ElementUtils.getTypeElementByBinaryName(this, name));
             if (e != null) {                
                 result.add (e);
             }
@@ -257,6 +263,8 @@ public class CompilationInfo {
     public synchronized @NonNull Trees getTrees() {
         checkConfinement();
         if (trees == null) {
+            //use a working init order:
+            com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext());
             trees = JavacTrees.instance(impl.getJavacTask().getContext());
             Snapshot snapshot = impl.getSnapshot();
             Document doc = snapshot != null ? snapshot.getSource().getDocument(false) : null;
@@ -283,6 +291,8 @@ public class CompilationInfo {
      */
     public @NonNull Types getTypes() {
         checkConfinement();
+        //use a working init order:
+        com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext());
         return impl.getJavacTask().getTypes();
     }
     
@@ -292,6 +302,8 @@ public class CompilationInfo {
      */
     public @NonNull Elements getElements() {
         checkConfinement();
+        //use a working init order:
+        com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext());
 	return impl.getJavacTask().getElements();
     }
         
@@ -474,4 +486,13 @@ public class CompilationInfo {
         /** The cached value will be cleared when a method/field/class is added, removed or its signature changes. */
         ON_SIGNATURE_CHANGE;
     }
+
+    static {
+        CompilationInfoAccessor.setInstance(new CompilationInfoAccessor() {
+            @Override
+            public JavacTask getJavacTask(CompilationInfo info) {
+                return info.impl.getJavacTask();
+            }
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java b/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
index 93e1984..c15ea75 100644
--- a/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
+++ b/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
@@ -41,9 +41,11 @@ import javax.lang.model.element.TypeParameterElement;
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeKind;
+
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.modules.java.source.ElementHandleAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.usages.ClassFileUtil;
 import org.openide.util.Parameters;
 import org.openide.util.WeakSet;
@@ -633,10 +635,9 @@ public final class ElementHandle<T extends Element> {
             return Symtab.instance(jt.getContext()).arrayClass;
         }
         else {
-            final JavacElements elements = (JavacElements) jt.getElements();                    
             return (TypeElement) (module != null
-                    ? elements.getTypeElementByBinaryName(module, signature)
-                    : elements.getTypeElementByBinaryName(signature));
+                    ? ElementUtils.getTypeElementByBinaryName(jt, module, signature)
+                    : ElementUtils.getTypeElementByBinaryName(jt, signature));
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java b/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
index a0c404b..58ee801 100644
--- a/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
@@ -53,8 +53,8 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Flags;
@@ -89,6 +89,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -114,6 +115,8 @@ import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 import javax.swing.text.Document;
 import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.parser.ParserFactory;
 import org.netbeans.api.editor.document.LineDocumentUtils;
 import org.netbeans.api.editor.guards.DocumentGuards;
 import org.netbeans.api.java.lexer.JavaTokenId;
@@ -124,6 +127,7 @@ import org.netbeans.modules.java.source.builder.CommentHandlerService;
 import org.netbeans.modules.java.source.builder.CommentSetImpl;
 import org.netbeans.modules.java.source.parsing.AbstractSourceFileObject;
 import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.ParsingUtils;
 import org.netbeans.modules.java.source.query.CommentSet.RelativePosition;
 import org.netbeans.modules.java.source.save.DiffContext;
 import org.openide.filesystems.FileObject;
@@ -171,7 +175,7 @@ public final class GeneratorUtilities {
         JavaFileObject sourceFile = FileObjects.templateFileObject(sourceRoot, nameComponent[0], nameComponent[1]);
         FileObject template = FileUtil.getConfigFile(copy.template(kind));
         FileObject targetFile = copy.doCreateFromTemplate(template, sourceFile);
-        CompilationUnitTree templateCUT = copy.impl.getJavacTask().parse(FileObjects.sourceFileObject(targetFile, targetFile.getParent())).iterator().next();
+        CompilationUnitTree templateCUT = ParsingUtils.parseArbitrarySource(copy.impl.getJavacTask(), FileObjects.sourceFileObject(targetFile, targetFile.getParent()));
         CompilationUnitTree importComments = GeneratorUtilities.get(copy).importComments(templateCUT, templateCUT);
         CompilationUnitTree result = copy.getTreeMaker().CompilationUnit(importComments.getPackageAnnotations(),
                 sourceRoot,
@@ -498,7 +502,7 @@ public final class GeneratorUtilities {
      * the revDependencies and dependencies can be used to determine partial order
      * between existing members and the newly inserted one.
      */
-    private class FieldRefVisitor extends TreePathScanner {
+    private class FieldRefVisitor extends ErrorAwareTreePathScanner {
         private final ClassTree clazz;
         // collects field names; serves to identify unqualified indentifiers
         // which might refer to field names.
@@ -1781,7 +1785,7 @@ public final class GeneratorUtilities {
         }
 
         final Map<Tree, Tree> translate = new IdentityHashMap<Tree, Tree>();
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override public Void visitWildcard(WildcardTree node, Void p) {
                 Tree bound = node.getBound();
 
@@ -1853,7 +1857,7 @@ public final class GeneratorUtilities {
     private Map<Name, TypeElement> getUsedTypes(final CompilationUnitTree cut) {
         final Trees trees = copy.getTrees();
         final Map<Name, TypeElement> map = new HashMap<Name, TypeElement>();
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -2218,7 +2222,7 @@ public final class GeneratorUtilities {
     }
     
     private static boolean containsErrors(Tree tree) {
-        Boolean b = new TreeScanner<Boolean, Boolean>() {
+        Boolean b = new ErrorAwareTreeScanner<Boolean, Boolean>() {
             @Override
             public Boolean visitErroneous(ErroneousTree node, Boolean p) {
                 return true;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java b/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
index 10016b6..3bb7694 100644
--- a/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
+++ b/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
@@ -60,6 +60,7 @@ import com.sun.tools.javac.comp.Check;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.util.Context;
+
 import java.io.BufferedInputStream;
 import java.io.InputStream;
 import java.util.function.Predicate;
@@ -93,6 +94,7 @@ import org.netbeans.modules.classfile.ClassFile;
 import org.netbeans.modules.classfile.Module;
 import org.netbeans.modules.java.preprocessorbridge.spi.ImportProcessor;
 import org.netbeans.modules.java.source.ElementHandleAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.JavadocHelper;
 import org.netbeans.modules.java.source.indexing.FQN2Files;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
@@ -206,39 +208,6 @@ public class SourceUtils {
      */
     public static List<? extends Completion> getAttributeValueCompletions(CompilationInfo info, Element element, AnnotationMirror annotation, ExecutableElement member, String userText) {
         List<Completion> completions = new LinkedList<>();
-        if (info.getPhase().compareTo(Phase.ELEMENTS_RESOLVED) >= 0) {
-            String fqn = ((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName().toString();
-            Iterable<? extends Processor> processors = info.impl.getJavacTask().getProcessors();
-            if (processors != null) {
-                for (Processor processor : processors) {
-                    boolean match = false;
-                    for (String sat : processor.getSupportedAnnotationTypes()) {
-                        if ("*".equals(sat)) { //NOI18N
-                            match = true;
-                            break;
-                        } else if (sat.endsWith(".*")) { //NOI18N
-                            sat = sat.substring(0, sat.length() - 1);
-                            if (fqn.startsWith(sat)) {
-                                match = true;
-                                break;
-                            }
-                        } else if (fqn.equals(sat)) {
-                            match = true;
-                            break;
-                        }
-                    }
-                    if (match) {
-                        try {
-                            for (Completion c : processor.getCompletions(element, annotation, member, userText)) {
-                                completions.add(c);
-                            }
-                        } catch (Exception e) {
-                            Logger.getLogger(processor.getClass().getName()).log(Level.INFO, e.getMessage(), e);
-                        }
-                    }
-                }
-            }
-        }
         return completions;
     }
 
@@ -931,7 +900,7 @@ public class SourceUtils {
                     public void run(CompilationController control) throws Exception {
                         control.toPhase(Phase.ELEMENTS_RESOLVED);
                         final JavacElements elms = (JavacElements)control.getElements();
-                        TypeElement type = elms.getTypeElementByBinaryName(qualifiedName);
+                        TypeElement type = ElementUtils.getTypeElementByBinaryName(control, qualifiedName);
                         if (type == null) {
                             return;
                         }
@@ -1358,13 +1327,12 @@ public class SourceUtils {
                 null,
                 null,
                 null,
-                null);
-        try {
-            final CompilationUnitTree cu =  jt.parse(FileObjects.fileObjectFileObject(
+                Collections.singletonList(FileObjects.fileObjectFileObject(
                     moduleInfo,
                     moduleInfo.getParent(),
                     null,
-                    FileEncodingQuery.getEncoding(moduleInfo))).iterator().next();
+                    FileEncodingQuery.getEncoding(moduleInfo))));
+            final CompilationUnitTree cu =  jt.parse().iterator().next();
             final List<? extends Tree> typeDecls = cu.getTypeDecls();
             if (!typeDecls.isEmpty()) {
                 final Tree typeDecl = typeDecls.get(0);
@@ -1372,9 +1340,6 @@ public class SourceUtils {
                     return ((ModuleTree)typeDecl).getName().toString();
                 }
             }
-        } catch (IOException ioe) {
-            Exceptions.printStackTrace(ioe);
-        }
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java b/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
index 2d29fe6..9f9021f 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
@@ -27,7 +27,7 @@ import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.code.Symbol;
 import java.util.HashMap;
 import java.util.Map;
@@ -47,7 +47,7 @@ import org.netbeans.api.annotations.common.NonNull;
  *
  * @author Pavel Flaska
  */
-class TranslateIdentifier extends TreePathScanner<Void, Void>{
+class TranslateIdentifier extends ErrorAwareTreePathScanner<Void, Void>{
     
     public static <T extends Tree> T importFQNs(WorkingCopy copy, T tree) {
         if (tree == null) return null;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java b/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
index 55bc7ea..ae550cd 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
@@ -52,7 +52,7 @@ import static com.sun.source.tree.Tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
 
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCModifiers;
@@ -1096,7 +1096,7 @@ public final class TreeMaker {
         Tree typeTree = copy.getTreeUtilities().parseType(type);
         final Map<Tree, Tree> translate = new HashMap<Tree, Tree>();
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitMemberSelect(MemberSelectTree node, Void p) {
                 translate.put(node, QualIdent(node.toString()));
@@ -3344,7 +3344,7 @@ public final class TreeMaker {
         }*/
     }
 
-    private static class TreePosCleaner extends TreeScanner<Void, Void> {
+    private static class TreePosCleaner extends ErrorAwareTreeScanner<Void, Void> {
 
         @Override
         public Void scan(Tree tree, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java b/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
index c2eebef..4f4be2b 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;                                                                                                                                                                                               
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;                                                                                                                                                                                           
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.tree.JCTree;                                                                                                                                                                                        
 
@@ -864,7 +864,7 @@ public final class TreePathHandle {
     private static List<Tree> listChildren(@NonNull Tree t) {
         final List<Tree> result = new LinkedList<Tree>();
 
-        t.accept(new TreeScanner<Void, Void>() {
+        t.accept(new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 result.add(node);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java b/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
index af36c3d..b35b14c 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
@@ -18,6 +18,12 @@
  */
 package org.netbeans.api.java.source;
 
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.nio.CharBuffer;
+
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.ReferenceTree;
@@ -28,8 +34,8 @@ import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacScope;
 import com.sun.tools.javac.api.JavacTrees;
@@ -45,9 +51,12 @@ import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.Context;
+
 import java.util.*;
+import java.util.function.Function;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
 import javax.lang.model.type.DeclaredType;
@@ -57,6 +66,24 @@ import javax.lang.model.type.UnionType;
 import javax.lang.model.util.ElementFilter;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.source.util.DocTrees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.comp.ArgumentAttr;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.parser.JavacParser;
+import com.sun.tools.javac.parser.Parser;
+import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.parser.ScannerFactory;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Names;
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
@@ -64,6 +91,8 @@ import org.netbeans.api.java.lexer.JavaTokenId;
 import org.netbeans.api.java.lexer.JavadocTokenId;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.lexer.TokenSequence;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import org.netbeans.lib.nbjavac.services.NBParserFactory;
 import org.netbeans.lib.nbjavac.services.NBResolve;
 import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
 import org.netbeans.modules.java.source.builder.CommentHandlerService;
@@ -71,6 +100,7 @@ import org.netbeans.modules.java.source.builder.CommentSetImpl;
 import org.netbeans.modules.java.source.pretty.ImportAnalysis2;
 import org.netbeans.modules.java.source.transform.ImmutableDocTreeTranslator;
 import org.netbeans.modules.java.source.transform.ImmutableTreeTranslator;
+import org.openide.util.Exceptions;
 
 /**
  *
@@ -301,7 +331,7 @@ public final class TreeUtilities {
             }
         }
         
-        class PathFinder extends TreePathScanner<Void,Void> {
+        class PathFinder extends ErrorAwareTreePathScanner<Void,Void> {
             private int pos;
             private SourcePositions sourcePositions;
             
@@ -345,6 +375,7 @@ public final class TreeUtilities {
                 
                 return super.visitMethod(node, p);
             }
+
         }
         
         try {
@@ -534,13 +565,7 @@ public final class TreeUtilities {
      * @return parsed {@link TypeMirror} or null if the given specification cannot be parsed
      */
     Tree parseType(String expr) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        try {
-            return info.impl.getJavacTask().parseType(expr);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(expr, null, 0, Parser::parseType);
     }
     
     /**Parses given statement.
@@ -550,16 +575,9 @@ public final class TreeUtilities {
      * @return parsed {@link StatementTree} or null?
      */
     public StatementTree parseStatement(String stmt, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        
-        try {
-            return (StatementTree)info.impl.getJavacTask().parseStatement(stmt, sourcePositions);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(stmt, sourcePositions, 0, Parser::parseStatement);
     }
-    
+
     /**Parses given expression.
      * 
      * @param expr expression code
@@ -567,14 +585,7 @@ public final class TreeUtilities {
      * @return parsed {@link ExpressionTree} or null?
      */
     public ExpressionTree parseExpression(String expr, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        
-        try {
-            return (ExpressionTree) info.impl.getJavacTask().parseExpression(expr, sourcePositions);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(expr, sourcePositions, 0, Parser::parseExpression);
     }
     
     /**Parses given variable initializer.
@@ -584,14 +595,7 @@ public final class TreeUtilities {
      * @return parsed {@link ExpressionTree} or null?
      */
     public ExpressionTree parseVariableInitializer(String init, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        
-        try {
-            return (ExpressionTree)info.impl.getJavacTask().parseVariableInitializer(init, sourcePositions);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(init, sourcePositions, 0, p -> ((JavacParser) p).variableInitializer());
     }
 
     /**Parses given static block.
@@ -601,15 +605,86 @@ public final class TreeUtilities {
      * @return parsed {@link BlockTree} or null?
      */
     public BlockTree parseStaticBlock(String block, SourcePositions[] sourcePositions) {
+        return doParse("{ class C { " + block + " }", sourcePositions, "{ class C { ".length(), p -> {
+            JCClassDecl decl = (JCClassDecl) ((BlockTree) p.parseStatement()).getStatements().get(0);
+            return decl.defs.head.getKind() == Kind.BLOCK ? (BlockTree) decl.defs.head : null; //check result
+        });
+    }
+
+    /**Parses given statement.
+     * 
+     * @param text code
+     * @param sourcePositions return value - new SourcePositions for the new tree
+     * @return parsed {@link T} or null?
+     */
+    private <T extends Tree> T doParse(String text, SourcePositions[] sourcePositions, int offset, Function<Parser, T> actualParse) {
+        if (text == null || (sourcePositions != null && sourcePositions.length != 1))
+            throw new IllegalArgumentException();
+        //use a working init order:
+        com.sun.tools.javac.main.JavaCompiler.instance(info.impl.getJavacTask().getContext());
         com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
         int oldPos = jcMaker.pos;
         
         try {
-            return (BlockTree)info.impl.getJavacTask().parseStaticBlock(block, sourcePositions);
+            //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+            Context context = info.impl.getJavacTask().getContext();
+            JavaCompiler compiler = JavaCompiler.instance(context);
+            JavaFileObject prev = compiler.log.useSource(new DummyJFO());
+            Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(compiler.log) {
+                @Override
+                public void report(JCDiagnostic diag) {
+                    //ignore:
+                }            
+            };
+            try {
+                CharBuffer buf = CharBuffer.wrap((text+"\u0000").toCharArray(), 0, text.length());
+                ParserFactory factory = ParserFactory.instance(context);
+                Parser parser = factory.newParser(buf, false, true, false, false);
+                if (parser instanceof JavacParser) {
+                    if (sourcePositions != null)
+                        sourcePositions[0] = new ParserSourcePositions((JavacParser)parser, offset);
+                    return actualParse.apply(parser);
+                }
+                return null;
+            } finally {
+                compiler.log.useSource(prev);
+                compiler.log.popDiagnosticHandler(discardHandler);
+            }
         } finally {
             jcMaker.pos = oldPos;
         }
     }
+    
+    //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+    private static final class DummyJFO extends SimpleJavaFileObject {
+        private DummyJFO() {
+            super(URI.create("dummy.java"), JavaFileObject.Kind.SOURCE);
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+            return "";
+        }
+    }
+
+    //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+    private static class ParserSourcePositions implements SourcePositions {
+
+        private final JavacParser parser;
+        private final int offset;
+
+        private ParserSourcePositions(JavacParser parser, int offset) {
+            this.parser = parser;
+            this.offset = offset;
+        }
+
+        public long getStartPosition(CompilationUnitTree file, Tree tree) {
+            return parser.getStartPos((JCTree)tree) - offset;
+        }
+
+        public long getEndPosition(CompilationUnitTree file, Tree tree) {
+            return parser.getEndPos((JCTree)tree) - offset;
+        }
+    }
 
     //XXX: parseAnnotationValue
     
@@ -687,7 +762,7 @@ public final class TreeUtilities {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTree((JCTree) tree, ((JavacScope) scope).getEnv());
+            return attributeTree(info.impl.getJavacTask(), (JCTree) tree, scope, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
@@ -701,7 +776,7 @@ public final class TreeUtilities {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, ((JavacScope)scope).getEnv(), (JCTree)to);
+            return attributeTreeTo(info.impl.getJavacTask(), (JCTree)tree, scope, (JCTree)to, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
@@ -714,7 +789,7 @@ public final class TreeUtilities {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTree((JCTree)tree, env);
+            return attributeTree(info.impl.getJavacTask(), (JCTree)tree, scope, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
@@ -727,12 +802,80 @@ public final class TreeUtilities {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, env, (JCTree)to);
+            return attributeTreeTo(info.impl.getJavacTask(), (JCTree)tree, scope, (JCTree)to, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
     }
     
+    //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+    private static TypeMirror attributeTree(JavacTaskImpl jti, Tree tree, Scope scope, final List<Diagnostic<? extends JavaFileObject>> errors) {
+        Log log = Log.instance(jti.getContext());
+        JavaFileObject prev = log.useSource(new DummyJFO());
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
+            @Override
+            public void report(JCDiagnostic diag) {
+                errors.add(diag);
+            }            
+        };
+        NBResolve resolve = NBResolve.instance(jti.getContext());
+        resolve.disableAccessibilityChecks();
+//        Enter enter = Enter.instance(jti.getContext());
+//        enter.shadowTypeEnvs(true);
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+        try {
+            Attr attr = Attr.instance(jti.getContext());
+            Env<AttrContext> env = ((JavacScope) scope).getEnv();
+            if (tree instanceof JCExpression)
+                return attr.attribExpr((JCTree) tree,env, Type.noType);
+            return attr.attribStat((JCTree) tree,env);
+        } finally {
+//            cacheContext.leave();
+            log.useSource(prev);
+            log.popDiagnosticHandler(discardHandler);
+            resolve.restoreAccessbilityChecks();
+//            enter.shadowTypeEnvs(false);
+        }
+    }
+
+    private static Scope attributeTreeTo(JavacTaskImpl jti, Tree tree, Scope scope, Tree to, final List<Diagnostic<? extends JavaFileObject>> errors) {
+        Log log = Log.instance(jti.getContext());
+        JavaFileObject prev = log.useSource(new DummyJFO());
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
+            @Override
+            public void report(JCDiagnostic diag) {
+                errors.add(diag);
+            }            
+        };
+        NBResolve resolve = NBResolve.instance(jti.getContext());
+        resolve.disableAccessibilityChecks();
+//        Enter enter = Enter.instance(jti.getContext());
+//        enter.shadowTypeEnvs(true);
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+        try {
+            Attr attr = Attr.instance(jti.getContext());
+            Env<AttrContext> env = ((JavacScope) scope).getEnv();
+            Env<AttrContext> result = tree instanceof JCExpression ?
+                attr.attribExprToTree((JCExpression) tree, env, (JCTree) to) :
+                attr.attribStatToTree((JCTree) tree, env, (JCTree) to);
+            try {
+                Constructor<JavacScope> c = JavacScope.class.getDeclaredConstructor(Env.class);
+                c.setAccessible(true);
+                return c.newInstance(result);
+            } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                throw new IllegalStateException(ex);
+            }
+        } finally {
+//            cacheContext.leave();
+            log.useSource(prev);
+            log.popDiagnosticHandler(discardHandler);
+            resolve.restoreAccessbilityChecks();
+//            enter.shadowTypeEnvs(false);
+        }
+    }
+
     /**Returns tokens for a given tree.
      */
     public TokenSequence<JavaTokenId> tokensFor(Tree tree) {
@@ -764,7 +907,7 @@ public final class TreeUtilities {
     /**Checks whether the given scope is in "static" context.
      */
     public boolean isStaticContext(Scope scope) {
-        return Resolve.instance(info.impl.getJavacTask().getContext()).isStatic(((JavacScope)scope).getEnv());
+        return NBResolve.isStatic(((JavacScope)scope).getEnv());
     }
     
     /**Returns uncaught exceptions inside the given tree path.
@@ -797,7 +940,7 @@ public final class TreeUtilities {
                 fields.add(ve);
             }
         }
-        new TreePathScanner<Void, Boolean>() {
+        new ErrorAwareTreePathScanner<Void, Boolean>() {
             @Override
             public Void visitAssignment(AssignmentTree node, Boolean p) {
                 Element el = trees.getElement(new TreePath(getCurrentPath(), node.getVariable()));
@@ -1454,7 +1597,7 @@ public final class TreeUtilities {
     
     private void copyInnerClassIndexes(Tree from, Tree to) {
         final int[] fromIdx = {-3};
-        TreeScanner<Void, Void> scanner = new TreeScanner<Void, Void>() {
+        ErrorAwareTreeScanner<Void, Void> scanner = new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 return fromIdx[0] < -1 ? super.scan(node, p) : null;
@@ -1486,7 +1629,7 @@ public final class TreeUtilities {
         scanner.scan(from, null);
         if (fromIdx[0] < -1)
             return;
-        scanner = new TreeScanner<Void, Void>() {
+        scanner = new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitClass(ClassTree node, Void p) {
                 ((IndexedClassDecl)node).index = fromIdx[0]++;
@@ -1496,7 +1639,7 @@ public final class TreeUtilities {
         scanner.scan(to, null);
     }
 
-    private static class UncaughtExceptionsVisitor extends TreePathScanner<Void, Set<TypeMirror>> {
+    private static class UncaughtExceptionsVisitor extends ErrorAwareTreePathScanner<Void, Set<TypeMirror>> {
         
         private final CompilationInfo info;
         
@@ -1657,7 +1800,9 @@ public final class TreeUtilities {
         TreePath tp = path.getTreePath();
         DCReference ref = (DCReference) path.getLeaf();
         
-        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
+        ((DocTrees) this.info.getTrees()).getElement(path);
+//        was:
+//        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
         
         return (ExpressionTree) ref.qualifierExpression;
     }
@@ -1682,19 +1827,44 @@ public final class TreeUtilities {
         TreePath tp = path.getTreePath();
         DCReference ref = (DCReference) path.getLeaf();
         
-        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
+        ((DocTrees) this.info.getTrees()).getElement(path);
+//        was:
+//        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
         
         return ref.paramTypes;
     }
     
-    private static final class NBScope extends JavacScope {
+    private static final class NBScope implements Scope {
 
-        private NBScope(JavacScope scope) {
-            super(scope.getEnv());
+        private final JavacScope delegate;
+
+        private NBScope(JavacScope delegate) {
+            this.delegate = delegate;
         }
         
         private boolean areAccessibilityChecksDisabled() {
             return true;
         }
+
+        @Override
+        public Scope getEnclosingScope() {
+            //TODO: wrap?
+            return delegate.getEnclosingScope();
+        }
+
+        @Override
+        public TypeElement getEnclosingClass() {
+            return delegate.getEnclosingClass();
+        }
+
+        @Override
+        public ExecutableElement getEnclosingMethod() {
+            return delegate.getEnclosingMethod();
+        }
+
+        @Override
+        public Iterable<? extends Element> getLocalElements() {
+            return delegate.getLocalElements();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java b/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
index 2bd3d1a..3e47602 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
@@ -26,11 +26,14 @@ import com.sun.tools.javac.code.Type.TypeVar;
 import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.model.JavacTypes;
+
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.ArrayType;
@@ -42,6 +45,7 @@ import javax.lang.model.type.TypeMirror;
 import javax.lang.model.type.TypeVariable;
 import javax.lang.model.type.WildcardType;
 import javax.lang.model.util.SimpleTypeVisitor6;
+
 import org.netbeans.api.annotations.common.CheckReturnValue;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
@@ -169,7 +173,7 @@ public final class TypeUtilities {
         } else if (tk == TypeKind.NONE || tk == TypeKind.OTHER) {
             return types.createErrorType(inType);
         }
-        Type t = types.upward(inType, types.captures(inType));
+        Type t = (Type) resolveCapturedType(info, type);
         if (t == null) {
             return types.createErrorType(inType);
         }
@@ -240,6 +244,108 @@ public final class TypeUtilities {
         }
     };
 
+    //from java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java:
+    private static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
+        if (tm == null) {
+            return tm;
+        }
+        if (tm.getKind() == TypeKind.ERROR) {
+            tm = info.getTrees().getOriginalType((ErrorType) tm);
+        }
+        TypeMirror type = resolveCapturedTypeInt(info, tm);
+        if (type == null) {
+            return tm;
+        }
+        if (type.getKind() == TypeKind.WILDCARD) {
+            TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
+            if (tmirr != null)
+                return tmirr;
+            else { //no extends, just '?'
+                TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
+                return te == null ? null : te.asType();
+            }
+                
+        }
+        
+        return type;
+    }
+    
+    /**
+     * Note: may return {@code null}, if an intersection type is encountered, to indicate a 
+     * real type cannot be created.
+     */
+    private static TypeMirror resolveCapturedTypeInt(CompilationInfo info, TypeMirror tm) {
+        if (tm == null) return tm;
+        
+        TypeMirror orig = SourceUtils.resolveCapturedType(tm);
+
+        if (orig != null) {
+            tm = orig;
+        }
+        
+        if (tm.getKind() == TypeKind.WILDCARD) {
+            TypeMirror extendsBound = ((WildcardType) tm).getExtendsBound();
+            TypeMirror superBound = ((WildcardType) tm).getSuperBound();
+            if (extendsBound != null || superBound != null) {
+                TypeMirror rct = resolveCapturedTypeInt(info, extendsBound != null ? extendsBound : superBound);
+                if (rct != null) {
+                    switch (rct.getKind()) {
+                        case WILDCARD:
+                            return rct;
+                        case ARRAY:
+                        case DECLARED:
+                        case ERROR:
+                        case TYPEVAR:
+                        case OTHER:
+                            return info.getTypes().getWildcardType(
+                                    extendsBound != null ? rct : null, superBound != null ? rct : null);
+                    }
+                } else {
+                    // propagate failure out of all wildcards
+                    return null;
+                }
+            }
+        } else if (tm.getKind() == TypeKind.INTERSECTION) {
+            return null;
+        }
+        
+        if (tm.getKind() == TypeKind.DECLARED) {
+            DeclaredType dt = (DeclaredType) tm;
+            List<TypeMirror> typeArguments = new LinkedList<TypeMirror>();
+            
+            for (TypeMirror t : dt.getTypeArguments()) {
+                TypeMirror targ = resolveCapturedTypeInt(info, t);
+                if (targ == null) {
+                    // bail out, if the type parameter is a wildcard, it's probably not possible
+                    // to create a proper parametrized type from it
+                    if (t.getKind() == TypeKind.WILDCARD || t.getKind() == TypeKind.INTERSECTION) {
+                        return null;
+                    }
+                    // use rawtype
+                    typeArguments.clear();
+                    break;
+                }
+                typeArguments.add(targ);
+            }
+            
+            final TypeMirror enclosingType = dt.getEnclosingType();
+            if (enclosingType.getKind() == TypeKind.DECLARED) {
+                return info.getTypes().getDeclaredType((DeclaredType) enclosingType, (TypeElement) dt.asElement(), typeArguments.toArray(new TypeMirror[0]));
+            } else {
+                if (dt.asElement() == null) return dt;
+                return info.getTypes().getDeclaredType((TypeElement) dt.asElement(), typeArguments.toArray(new TypeMirror[0]));
+            }
+        }
+
+        if (tm.getKind() == TypeKind.ARRAY) {
+            ArrayType at = (ArrayType) tm;
+            TypeMirror tm2 = resolveCapturedTypeInt(info, at.getComponentType());
+            return info.getTypes().getArrayType(tm2 != null ? tm2 : tm);
+        }
+        
+        return tm;
+    }
+
     /**Options for the {@link #getTypeName(javax.lang.model.type.TypeMirror, org.netbeans.api.java.source.TypeUtilities.TypeNameOptions[]) } method.
      * @since 0.62
      */

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java b/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
index f613b9e..5428253 100644
--- a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
+++ b/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
@@ -32,8 +32,8 @@ import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.Context;
 
@@ -66,9 +66,11 @@ import com.sun.source.tree.TreeVisitor;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.DocTrees;
+
 import java.util.Collection;
 import java.util.Comparator;
 
+import com.sun.tools.javac.parser.ParserFactory;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.api.annotations.common.NullUnknown;
@@ -85,6 +87,7 @@ import org.netbeans.modules.java.source.builder.CommentSetImpl;
 import org.netbeans.modules.java.source.builder.TreeFactory;
 import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
 import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.ParsingUtils;
 import org.netbeans.modules.java.source.pretty.ImportAnalysis2;
 import org.netbeans.modules.java.source.query.CommentSet.RelativePosition;
 import org.netbeans.modules.java.source.save.CasualDiff;
@@ -275,7 +278,7 @@ public class WorkingCopy extends CompilationController {
         return ok || introducedTrees.containsKey(t);
     }
     
-    private static class TreeCollector extends TreeScanner {
+    private static class TreeCollector extends ErrorAwareTreeScanner {
         private final Map<Tree, Boolean> collectTo;
         private final boolean add;
 
@@ -577,7 +580,7 @@ public class WorkingCopy extends CompilationController {
 
         final Map<Tree, Boolean> presentInResult = new IdentityHashMap<Tree, Boolean>();
         if (CasualDiff.OLD_TREES_VERBATIM) {
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 private boolean synthetic = false;
                 @Override
                 public Void scan(Tree node, Void p) {
@@ -624,7 +627,7 @@ public class WorkingCopy extends CompilationController {
                 
             }.scan(diffContext.origUnit, null);
         } else {
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override
                 public Void scan(Tree node, Void p) {
                     addSyntheticTrees(diffContext, node);
@@ -635,7 +638,7 @@ public class WorkingCopy extends CompilationController {
         }
 
         if (!REWRITE_WHOLE_FILE) {
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 private TreePath currentParent;
                 private final Map<Tree, TreePath> tree2Path = new IdentityHashMap<Tree, TreePath>();
                 private final FQNComputer fqn = new FQNComputer();
@@ -1031,7 +1034,7 @@ public class WorkingCopy extends CompilationController {
      * <li>copies comments from a tree to an associated tree
      * <li>
      */
-    private class CommentReplicator extends TreePathScanner<Object, Object> {
+    private class CommentReplicator extends ErrorAwareTreePathScanner<Object, Object> {
         private final Set<Tree>   stillPresent;
         
         private boolean collectCommentsFromRemovedNodes;
@@ -1188,7 +1191,7 @@ public class WorkingCopy extends CompilationController {
         for (CompilationUnitTree t : externalChanges.values()) {
             try {
                 FileObject targetFile = doCreateFromTemplate(t);
-                CompilationUnitTree templateCUT = impl.getJavacTask().parse(FileObjects.sourceFileObject(targetFile, targetFile.getParent())).iterator().next();
+                CompilationUnitTree templateCUT = ParsingUtils.parseArbitrarySource(impl.getJavacTask(), FileObjects.sourceFileObject(targetFile, targetFile.getParent()));
                 CompilationUnitTree importComments = GeneratorUtilities.get(this).importComments(templateCUT, templateCUT);
 
                 rewrite(importComments, getTreeMaker().asRemoved(t));
@@ -1296,7 +1299,7 @@ public class WorkingCopy extends CompilationController {
                 fqn.setCompilationUnit(t);
                 overlay.registerPackage(fqn.getFQN());
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         String parent = fqn.getFQN();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
index c519b91..d5f88d6 100644
--- a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
+++ b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
@@ -19,14 +19,14 @@
 package org.netbeans.api.java.source.support;
 
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  *
  * @author Jan Lahoda
  */
-public class CancellableTreePathScanner<R,P> extends TreePathScanner<R,P> {
+public class CancellableTreePathScanner<R,P> extends ErrorAwareTreePathScanner<R,P> {
 
     private final AtomicBoolean internalCanceled;
     private final AtomicBoolean canceled;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
index e3ec87c..4c535ea 100644
--- a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
+++ b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
@@ -19,14 +19,14 @@
 package org.netbeans.api.java.source.support;
 
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  *
  * @author Jan Lahoda
  */
-public class CancellableTreeScanner<R,P> extends TreeScanner<R,P> {
+public class CancellableTreeScanner<R,P> extends ErrorAwareTreeScanner<R,P> {
 
     private final AtomicBoolean internalCanceled;
     private final AtomicBoolean canceled;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java
new file mode 100644
index 0000000..a04e544
--- /dev/null
+++ b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.java.source.support;
+
+import com.sun.source.tree.ErroneousTree;
+import com.sun.source.util.TreePathScanner;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class ErrorAwareTreePathScanner<R,P> extends TreePathScanner<R,P> {
+
+    @Override
+    public R visitErroneous(ErroneousTree et, P p) {
+        return scan(et.getErrorTrees(), p);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java
new file mode 100644
index 0000000..eebbcb5
--- /dev/null
+++ b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.java.source.support;
+
+import com.sun.source.tree.ErroneousTree;
+import com.sun.source.util.TreeScanner;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class ErrorAwareTreeScanner<R,P> extends TreeScanner<R,P> {
+
+    @Override
+    public R visitErroneous(ErroneousTree et, P p) {
+        return scan(et.getErrorTrees(), p);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java b/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java
new file mode 100644
index 0000000..efe5d7f
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source;
+
+import com.sun.source.util.JavacTask;
+import org.netbeans.api.java.source.CompilationInfo;
+
+/**
+ *
+ * @author lahvac
+ */
+public abstract class CompilationInfoAccessor {
+    
+    private static volatile CompilationInfoAccessor INSTANCE;
+
+    public static CompilationInfoAccessor getInstance() {
+        CompilationInfoAccessor result = INSTANCE;
+        
+        if (result == null) {
+            synchronized (CompilationInfoAccessor.class) {
+                if (INSTANCE == null) {
+                    Class c = CompilationInfo.class;
+                    try {
+                        Class.forName(c.getName(), true, c.getClassLoader());
+                    } catch (Exception ex) {
+                        ex.printStackTrace();
+                    }
+                    
+                    assert INSTANCE != null;
+                }
+                
+                return INSTANCE;
+            }
+        }
+        
+        return result;
+    }
+    
+    public static void setInstance(CompilationInfoAccessor instance) {
+        assert instance != null;
+        INSTANCE = instance;
+    }
+
+    protected CompilationInfoAccessor() {
+    }
+    
+    public abstract JavacTask getJavacTask(CompilationInfo info);
+
+}


[08/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
new file mode 100644
index 0000000..b329e4f
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
@@ -0,0 +1,357 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.indexing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.PackageTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.CompileStates.CompileState;
+import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
+import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
+import org.netbeans.lib.nbjavac.services.CancelAbort;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import com.sun.tools.javac.util.FatalError;
+import com.sun.tools.javac.util.Log;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+import javax.annotation.processing.Processor;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
+import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.OutputFileManager;
+import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.Indexable;
+import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+/**
+ *
+ * @author Dusan Balek
+ */
+final class VanillaCompileWorker extends CompileWorker {
+
+    @Override
+    protected ParsingOutput compile(
+            final ParsingOutput previous,
+            final Context context,
+            final JavaParsingContext javaContext,
+            final Collection<? extends CompileTuple> files) {
+        final Map<JavaFileObject, List<String>> file2FQNs = previous != null ? previous.file2FQNs : new HashMap<>();
+        final Set<ElementHandle<TypeElement>> addedTypes = previous != null ? previous.addedTypes : new HashSet<>();
+        final Set<ElementHandle<ModuleElement>> addedModules = previous != null ? previous.addedModules : new HashSet<>();
+        final Set<File> createdFiles = previous != null ? previous.createdFiles : new HashSet<>();
+        final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
+        final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
+        final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
+
+        final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
+        final LinkedList<CompilationUnitTree> trees = new LinkedList<CompilationUnitTree>();
+        Map<CompilationUnitTree, CompileTuple> units = new IdentityHashMap<CompilationUnitTree, CompileTuple>();
+        JavacTaskImpl jt = null;
+
+        boolean nop = true;
+        final SuspendStatus suspendStatus = context.getSuspendStatus();
+        final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus);
+        Map<JavaFileObject, CompileTuple> fileObjects = new IdentityHashMap<>();
+        try {
+            final boolean flm[] = {true};
+            while (sourcePrefetcher.hasNext())  {
+                final CompileTuple tuple = sourcePrefetcher.next();
+                try {
+                    if (tuple != null) {
+                        nop = false;
+                        if (context.isCancelled()) {
+                            return null;
+                        }
+                        fileObjects.put(tuple.jfo, tuple);
+                    }
+                }  finally {
+                    sourcePrefetcher.remove();
+                }
+            }
+        } finally {
+            try {
+                sourcePrefetcher.close();
+            } catch (IOException ex) {
+                Exceptions.printStackTrace(ex);
+            }
+        }
+        ModuleName moduleName = new ModuleName(javaContext.getModuleName());
+        if (nop) {
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        try {
+            jt = JavacParser.createJavacTask(
+                javaContext.getClasspathInfo(),
+                dc,
+                javaContext.getSourceLevel(),
+                javaContext.getProfile(),
+                javaContext.getFQNs(),
+                new CancelService() {
+                    public @Override boolean isCanceled() {
+                        return context.isCancelled() || isLowMemory(null);
+                    }
+                },
+                fileObjects.values().iterator().next().aptGenerated ? null : APTUtils.get(context.getRoot()),
+                CompilerOptionsQuery.getOptions(context.getRoot()),
+                fileObjects.keySet());
+            for (CompilationUnitTree cut : jt.parse()) {
+                trees.add(cut);
+                CompileTuple tuple = fileObjects.get(cut.getSourceFile());
+                units.put(cut, tuple);
+                computeFQNs(file2FQNs, cut, tuple);
+            }
+            Log.instance(jt.getContext()).nerrors = 0;
+        } catch (CancelAbort ca) {
+            if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+            }
+        } catch (Throwable t) {
+            if (JavaIndex.LOG.isLoggable(Level.WARNING)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("SuperOnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            fileObjects.values().iterator().next().indexable.getURL().toString(),
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.WARNING, message, t);  //NOI18N
+            }
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            } else {
+                jt = null;
+                units = null;
+                dc.cleanDiagnostics();
+                freeMemory(false);
+            }
+        }
+        if (jt == null || units == null || JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER) {
+            return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        if (context.isCancelled()) {
+            return null;
+        }
+        if (isLowMemory(null)) {
+            return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        boolean aptEnabled = true;
+        Log log = Log.instance(jt.getContext());
+        JavaCompiler compiler = JavaCompiler.instance(jt.getContext());
+        Set<JavaFileObject> haveErrors = new HashSet<>();
+        try {
+            final Iterable<? extends Element> types = jt.enter(trees);
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            final Map<Element, CompileTuple> clazz2Tuple = new IdentityHashMap<Element, CompileTuple>();
+            Enter enter = Enter.instance(jt.getContext());
+            for (Element type : types) {
+                if (type.getKind().isClass() || type.getKind().isInterface() || type.getKind() == ElementKind.MODULE) {
+                    Env<AttrContext> typeEnv = enter.getEnv((TypeSymbol) type);
+                    if (typeEnv == null) {
+                        JavaIndex.LOG.log(Level.FINE, "No Env for: {0}", ((TypeSymbol) type).getQualifiedName());
+                        continue;
+                    }
+                    clazz2Tuple.put(type, units.get(typeEnv.toplevel));
+                }
+            }
+            jt.analyze(types);
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
+                CompileTuple active = unit.getValue();
+                if (aptEnabled) {
+                    JavaCustomIndexer.addAptGenerated(context, javaContext, active, aptGenerated);
+                }
+                List<Element> activeTypes = new ArrayList<>();
+                if (unit.getValue().jfo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
+                    final PackageTree pt = unit.getKey().getPackage();
+                    if (pt instanceof JCPackageDecl) {                        
+                        final Element sym = ((JCPackageDecl)pt).packge;
+                        if (sym != null)
+                            activeTypes.add(sym);
+                    }
+                } else {
+                    for (Tree tree : unit.getKey().getTypeDecls()) {
+                        if (tree instanceof JCTree) {
+                            final JCTree jct = (JCTree)tree;
+                            if (jct.getTag() == JCTree.Tag.CLASSDEF) {
+                                final Element sym = ((JCClassDecl)tree).sym;
+                                if (sym != null)
+                                    activeTypes.add(sym);
+                            } else if (jct.getTag() == JCTree.Tag.MODULEDEF) {
+                                final Element sym = ((JCModuleDecl)tree).sym;
+                                if (sym != null)
+                                    activeTypes.add(sym);
+                            }
+                        }
+                    }
+                }
+                javaContext.getFQNs().set(activeTypes, active.indexable.getURL());
+                boolean[] main = new boolean[1];
+                if (javaContext.getCheckSums().checkAndSet(
+                        active.indexable.getURL(),
+                        activeTypes.stream()                                                
+                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
+                                .map ((e) -> (TypeElement)e)
+                                .collect(Collectors.toList()),
+                        jt.getElements()) || context.isSupplementaryFilesIndexing()) {
+                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, addedTypes, addedModules, main);
+                } else {
+                    final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
+                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, aTypes, addedModules, main);
+                    addedTypes.addAll(aTypes);
+                    modifiedTypes.addAll(aTypes);
+                }
+                ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
+                if (!dc.getDiagnostics(active.jfo).isEmpty())
+                    haveErrors.add(active.jfo);
+                JavaCustomIndexer.setErrors(context, active, dc);
+            }
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            final JavacTaskImpl jtFin = jt;
+            final Future<Void> done = FileManagerTransaction.runConcurrent(new FileSystem.AtomicAction() {
+                @Override
+                public void run() throws IOException {
+                    Modules modules = Modules.instance(jtFin.getContext());
+                    compiler.shouldStopPolicyIfError = CompileState.FLOW; 
+                    for (Element type : types) {
+                        TreePath tp = Trees.instance(jtFin).getPath(type);
+                        assert tp != null;
+                        log.nerrors = haveErrors.contains(tp.getCompilationUnit().getSourceFile()) ? 1 : 0;
+                        Iterable<? extends JavaFileObject> generatedFiles = jtFin.generate(Collections.singletonList(type));
+                        CompileTuple unit = clazz2Tuple.get(type);
+                        if (unit == null || !unit.virtual) {
+                            for (JavaFileObject generated : generatedFiles) {
+                                if (generated instanceof FileObjects.FileBase) {
+                                    createdFiles.add(((FileObjects.FileBase) generated).getFile());
+                                } else {
+                                    // presumably should not happen
+                                }
+                            }
+                        }
+                    }
+                    if (!moduleName.assigned) {
+                        ModuleElement module = !trees.isEmpty() ?
+                            ((JCTree.JCCompilationUnit)trees.getFirst()).modle :
+                            null;
+                        if (module == null) {
+                            module = modules.getDefaultModule();
+                        }
+                        moduleName.name = module == null || module.isUnnamed() ?
+                            null :
+                            module.getQualifiedName().toString();
+                        moduleName.assigned = true;
+                    }
+                }
+            });
+            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
+                finished.add(unit.getValue().indexable);
+            }
+            done.get();
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        } catch (OutputFileManager.InvalidSourcePath isp) {
+            //Deleted project - log & ignore
+            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.FINEST, message, isp);
+            }
+        } catch (CancelAbort ca) {
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+            }
+        } catch (Throwable t) {
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            } else {
+                Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
+                if (JavaIndex.LOG.isLoggable(level)) {
+                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                    final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                FileUtil.getFileDisplayName(context.getRoot()),
+                                bootPath == null   ? null : bootPath.toString(),
+                                classPath == null  ? null : classPath.toString(),
+                                sourcePath == null ? null : sourcePath.toString()
+                                );
+                    JavaIndex.LOG.log(level, message, t);  //NOI18N
+                }
+            }
+        }
+        return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java b/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
index 9f99014..ab9af13 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
@@ -71,7 +71,7 @@ import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -105,7 +105,7 @@ import org.netbeans.api.java.source.CompilationInfo;
  *
  * @author Jan Lahoda
  */
-public class CopyFinder extends TreeScanner<Boolean, TreePath> {
+public class CopyFinder extends ErrorAwareTreeScanner<Boolean, TreePath> {
 
     private final TreePath searchingFor;
     private final CompilationInfo info;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
index b60a657..8b7710e 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
@@ -76,12 +76,13 @@ public abstract class AbstractSourceFileObject implements PrefetchableJavaFileOb
 
     protected AbstractSourceFileObject (
             @NonNull final Handle handle,
-            @NullAllowed final JavaFileFilterImplementation filter) {
+            @NullAllowed final JavaFileFilterImplementation filter,
+            boolean hasContent) { //TODO: if has a content, then Kind.SOURCE, right??
         Parameters.notNull("handle", handle);   //NOI18N
         this.handle = handle;
         this.filter = filter;
         final String ext = this.handle.getExt();
-        this.kind = filter == null ?
+        this.kind = filter == null && !hasContent ?
             FileObjects.getKind(ext) :
             Kind.SOURCE; //#141411
     }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
index 766957e..97a7534 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
@@ -74,7 +74,7 @@ public class BasicSourceFileObject extends AbstractSourceFileObject implements D
         @NullAllowed final JavaFileFilterImplementation filter,
         @NullAllowed final CharSequence content,
         final boolean renderNow) throws IOException {
-        super(handle, filter);
+        super(handle, filter, content != null);
         this.hasFilter = filter != null;
         if (content != null || renderNow) {
             update(content);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
index 6ce3c87..62bf92b 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
@@ -163,7 +163,7 @@ public final class CompilationInfoImpl {
         this.isDetached = false;
     }
 
-    void update (final Snapshot snapshot) throws IOException {
+    public void update (final Snapshot snapshot) throws IOException {
         assert snapshot != null;
         this.jfo.update(snapshot.getText());
         this.snapshot = snapshot;
@@ -354,7 +354,7 @@ public final class CompilationInfoImpl {
             if (currentPhase.compareTo(phase)<0) {
                 setPhase(phase);
                 if (currentPhase == JavaSource.Phase.MODIFIED)
-                    getJavacTask().analyze(); // Ensure proper javac initialization
+                    getJavacTask().getElements().getTypeElement("java.lang.Object"); // Ensure proper javac initialization
             }
             return phase;
         } else {
@@ -372,7 +372,7 @@ public final class CompilationInfoImpl {
         if (javacTask == null) {
             diagnosticListener = new DiagnosticListenerImpl(this.root, this.jfo, this.cpInfo);
             javacTask = JavacParser.createJavacTask(this.file, this.root, this.cpInfo,
-                    this.parser, diagnosticListener, null, isDetached);
+                    this.parser, diagnosticListener, isDetached);
         }
 	return javacTask;
     }
@@ -413,7 +413,7 @@ public final class CompilationInfoImpl {
      * Returns current {@link DiagnosticListener}
      * @return listener
      */
-    DiagnosticListener<JavaFileObject> getDiagnosticListener() {
+    public DiagnosticListener<JavaFileObject> getDiagnosticListener() {
         return diagnosticListener;
     }
     
@@ -452,7 +452,7 @@ public final class CompilationInfoImpl {
     
     // Innerclasses ------------------------------------------------------------
     @Trusted
-    static class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
+    public static class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
         
         private final Map<JavaFileObject, Diagnostics> source2Errors;
         private final FileObject root;
@@ -517,12 +517,12 @@ public final class CompilationInfoImpl {
             return errors;
         }
 
-        final boolean hasPartialReparseErrors () {
+        public final boolean hasPartialReparseErrors () {
             // #236654: warnings should not stop processing of the reparsed method
             return this.partialReparseErrors != null && partialReparseRealErrors;
         }
         
-        final void startPartialReparse (int from, int to) {
+        public final void startPartialReparse (int from, int to) {
             if (partialReparseErrors == null) {
                 partialReparseErrors = new ArrayList<>();
                 Diagnostics errors = getErrors(jfo);
@@ -562,7 +562,7 @@ public final class CompilationInfoImpl {
             partialReparseRealErrors = false;
         }
         
-        final void endPartialReparse (final int delta) {
+        public final void endPartialReparse (final int delta) {
             this.currentDelta+=delta;
         }
         
@@ -602,27 +602,18 @@ public final class CompilationInfoImpl {
             @Override
             public long getPosition() {
                 long ret = this.delegate.getPosition();
-                if (delegate.hasFixedPositions()) {
-                    ret+=currentDelta;
-                }
                 return ret;
             }
 
             @Override
             public long getStartPosition() {
                 long ret = this.delegate.getStartPosition();
-                if (delegate.hasFixedPositions()) {
-                    ret+=currentDelta;
-                }
                 return ret;
             }
 
             @Override
             public long getEndPosition() {
                 long ret = this.delegate.getEndPosition();
-                if (delegate.hasFixedPositions()) {
-                    ret+=currentDelta;
-                }
                 return ret;
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
index f214d7b..ca35183 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
@@ -18,7 +18,6 @@
  */
 package org.netbeans.modules.java.source.parsing;
 
-import com.sun.tools.javac.model.LazyTreeLoader;
 import java.io.*;
 import java.net.URL;
 import java.nio.channels.CompletionHandler;
@@ -37,7 +36,6 @@ import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.JavaIndexerWorker;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.openide.filesystems.FileSystem;
@@ -375,9 +373,7 @@ public abstract class FileManagerTransaction extends TransactionContext.Service
 
         @NonNull
         private FileManagerTransaction getDelegate() {
-            return TreeLoader.isTreeLoading() ?
-                writeThrough :
-                nullWrite;
+            return nullWrite;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java
deleted file mode 100644
index 5d84b2a..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.parsing;
-
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import java.util.HashSet;
-import java.util.Set;
-import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
-
-/**
- * Partial reparse helper visitor.
- * Finds anonymous and local classes in given method tree.
- * @author Tomas Zezula
- */
-class FindAnonymousVisitor extends TreeScanner<Void,Void> {
-
-    private static enum Mode {COLLECT, CHECK};
-
-    int firstInner = -1;
-    int noInner;
-    boolean hasLocalClass;
-    final Set<Tree> docOwners = new HashSet<Tree>();
-    private Mode mode = Mode.COLLECT;            
-    
-    public final void reset () {
-        this.firstInner = -1;
-        this.noInner = 0;
-        this.hasLocalClass = false;
-        this.mode = Mode.CHECK;
-    }
-
-    @Override
-    public Void visitClass(ClassTree node, Void p) {
-        if (firstInner == -1) {
-            firstInner = ((IndexedClassDecl)node).index;
-        }
-        if (node.getSimpleName().length() != 0) {
-            hasLocalClass = true;
-        }
-        noInner++;
-        handleDoc(node);
-        return super.visitClass(node, p);
-    }
-
-    @Override
-    public Void visitMethod(MethodTree node, Void p) {
-        handleDoc(node);
-        return super.visitMethod(node, p);
-    }
-
-    @Override
-    public Void visitVariable(VariableTree node, Void p) {
-        handleDoc(node);
-        return super.visitVariable(node, p);
-    }
-
-    private void handleDoc (final Tree tree) {
-        if (mode == Mode.COLLECT) {
-            docOwners.add(tree);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
index f28c7f1..8354821 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
@@ -36,7 +36,7 @@ import org.openide.filesystems.FileObject;
  *
  * @author Tomas Zezula
  */
-class JavacFlowListener {
+public class JavacFlowListener {
         
     protected static final Context.Key<JavacFlowListener> flowListenerKey =
         new Context.Key<JavacFlowListener>();
@@ -58,7 +58,7 @@ class JavacFlowListener {
         jti.setTaskListener(new TaskListenerImpl());
     }
 
-    final boolean hasFlowCompleted (final FileObject fo) {
+    public final boolean hasFlowCompleted (final FileObject fo) {
         if (fo == null) {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
index 5975abf..e044b86 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
@@ -19,33 +19,18 @@
 
 package org.netbeans.modules.java.source.parsing;
 
-import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePath;
+import com.sun.source.util.JavacTask;
 import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.ClassNamesForFileOraculum;
-import com.sun.tools.javac.api.DuplicateClassChecker;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.api.JavacTrees;
-import com.sun.tools.javac.parser.LazyDocCommentTable;
-import com.sun.tools.javac.tree.EndPosTable;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCBlock;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.util.Abort;
 
 import org.netbeans.lib.nbjavac.services.CancelAbort;
 import org.netbeans.lib.nbjavac.services.CancelService;
 
 import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.CouplingAbort;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.util.Position.LineMapImpl;
 import com.sun.tools.javadoc.main.JavadocClassFinder;
 
 import java.io.File;
@@ -62,7 +47,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumMap;
 import java.util.EnumSet;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -80,7 +64,6 @@ import javax.annotation.processing.Processor;
 import javax.swing.event.ChangeEvent;
 import  javax.swing.event.ChangeListener;
 import javax.swing.text.Document;
-import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
@@ -94,7 +77,6 @@ import org.netbeans.api.java.source.ClasspathInfo.PathKind;
 import org.netbeans.api.java.source.JavaParserResultTask;
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.JavaSource.Phase;
-import org.netbeans.api.java.source.SourceUtils;
 import org.netbeans.api.project.FileOwnerQuery;
 import org.netbeans.api.project.Project;
 import org.netbeans.lib.editor.util.swing.PositionRegion;
@@ -103,7 +85,6 @@ import org.netbeans.modules.java.source.JavaFileFilterQuery;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
 import org.netbeans.modules.java.source.JavadocEnv;
 import org.netbeans.modules.java.source.PostFlowAnalysis;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.APTUtils;
 import org.netbeans.modules.java.source.indexing.FQN2Files;
 import org.netbeans.lib.nbjavac.services.NBAttr;
@@ -118,7 +99,6 @@ import org.netbeans.lib.nbjavac.services.NBJavacTrees;
 import org.netbeans.lib.nbjavac.services.NBMessager;
 import org.netbeans.lib.nbjavac.services.NBResolve;
 import org.netbeans.lib.nbjavac.services.NBTreeMaker;
-import org.netbeans.lib.nbjavac.services.PartialReparser;
 import org.netbeans.modules.java.source.indexing.JavaIndex;
 import org.netbeans.modules.java.source.tasklist.CompilerSettings;
 import org.netbeans.modules.java.source.usages.ClassIndexImpl;
@@ -137,8 +117,10 @@ import org.openide.filesystems.FileUtil;
 import org.openide.modules.SpecificationVersion;
 import org.openide.util.ChangeSupport;
 import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
 import org.openide.util.Pair;
 import org.openide.util.WeakListeners;
+import org.openide.util.lookup.ServiceProvider;
 
 /**
  * Provides Parsing API parser built atop Javac (using JSR 199).
@@ -159,7 +141,7 @@ public class JavacParser extends Parser {
     private static final int MAX_DUMPS = Integer.getInteger("org.netbeans.modules.java.source.parsing.JavacParser.maxDumps", 255);  //NOI18N
     //Command line switch disabling partial reparse
     private static final boolean DISABLE_PARTIAL_REPARSE = Boolean.getBoolean("org.netbeans.modules.java.source.parsing.JavacParser.no_reparse");   //NOI18N
-    private static final String LOMBOK_DETECTED = "lombokDetected";
+    public static final String LOMBOK_DETECTED = "lombokDetected";
 
     /**
      * Helper map mapping the {@link Phase} to message for performance logger
@@ -200,6 +182,7 @@ public class JavacParser extends Parser {
     private final FilterListener filterListener;
     //ClasspathInfo Listener
     private final ChangeListener cpInfoListener;
+    private final SequentialParsing sequentialParsing;
     //Cached javac impl
     private CompilationInfoImpl ciImpl;
     //State of the parser, used only for single source parser, otherwise don't care.
@@ -240,6 +223,7 @@ public class JavacParser extends Parser {
                     }
                 }
             });
+        this.sequentialParsing = Lookup.getDefault().lookup(SequentialParsing.class);
     }
 
     private void init (final Snapshot snapshot, final Task task, final boolean singleSource) {
@@ -401,12 +385,14 @@ public class JavacParser extends Parser {
                         final Pair<DocPositionRegion,MethodTree> _changedMethod = changedMethod.getAndSet(null);
                         if (_changedMethod != null && ciImpl != null) {
                             LOGGER.log(Level.FINE, "\t:trying partial reparse:\n{0}", _changedMethod.first().getText());                           //NOI18N
-                            needsFullReparse = !reparseMethod(ciImpl, snapshot, _changedMethod.second(), _changedMethod.first().getText());
+                            PartialReparser reparser = Lookup.getDefault().lookup(PartialReparser.class);
+                            needsFullReparse = !reparser.reparseMethod(ciImpl, snapshot, _changedMethod.second(), _changedMethod.first().getText());
                             if (!needsFullReparse) {
                                 ciImpl.setChangedMethod(_changedMethod);
                             }
                         }
                     }
+                    System.err.println("needsFullReparse=" + needsFullReparse);
                     if (needsFullReparse) {
                         positions.clear();
                         ciImpl = createCurrentInfo (this, file, root, snapshot, null, null);
@@ -416,8 +402,8 @@ public class JavacParser extends Parser {
                 default:
                     init (snapshot, task, false);
                     ciImpl = createCurrentInfo(this, file, root, snapshot,
-                        ciImpl == null ? null : ciImpl.getJavacTask(),
-                        ciImpl == null ? null : ciImpl.getDiagnosticListener());
+                        sequentialParsing != null && ciImpl == null ? null : ciImpl.getJavacTask(),
+                        sequentialParsing != null && ciImpl == null ? null : ciImpl.getDiagnosticListener());
             }
             success = true;
         } finally {
@@ -582,7 +568,12 @@ public class JavacParser extends Parser {
                 }
                 long start = System.currentTimeMillis();
                 // XXX - this might be with wrong encoding
-                Iterable<? extends CompilationUnitTree> trees = currentInfo.getJavacTask().parse(new JavaFileObject[] {currentInfo.jfo});
+                Iterable<? extends CompilationUnitTree> trees;
+                if (sequentialParsing != null) {
+                    trees = sequentialParsing.parse(currentInfo.getJavacTask(), currentInfo.jfo);
+                } else {
+                    trees = currentInfo.getJavacTask().parse();
+                }
                 if (trees == null) {
                     LOGGER.log( Level.INFO, "Did not parse anything for: {0}", currentInfo.jfo.toUri()); //NOI18N
                     return Phase.MODIFIED;
@@ -638,18 +629,11 @@ public class JavacParser extends Parser {
             if (currentPhase == Phase.RESOLVED && phase.compareTo(Phase.UP_TO_DATE)>=0) {
                 currentPhase = Phase.UP_TO_DATE;
             }
-        } catch (CouplingAbort a) {
-            TreeLoader.dumpCouplingAbort(a, null);
-            return currentPhase;
         } catch (CancelAbort ca) {
             currentPhase = Phase.MODIFIED;
             invalidate(false);
         } catch (Abort abort) {
             parserError = currentPhase;
-        } catch (IOException ex) {
-            currentInfo.parserCrashed = currentPhase;
-            dumpSource(currentInfo, ex);
-            throw ex;
         } catch (RuntimeException | Error ex) {
             parserError = currentPhase;
             dumpSource(currentInfo, ex);
@@ -681,17 +665,16 @@ public class JavacParser extends Parser {
             final ClasspathInfo cpInfo,
             final JavacParser parser,
             final DiagnosticListener<? super JavaFileObject> diagnosticListener,
-            final ClassNamesForFileOraculum oraculum,
             final boolean detached) {
         if (file != null) {
             if (LOGGER.isLoggable(Level.FINER)) {
                 LOGGER.log(Level.FINER, "Created new JavacTask for: {0}", FileUtil.getFileDisplayName(file));
             }
         }
-        FQN2Files dcc = null;
+        FQN2Files fqn2Files = null;
         if (root != null) {
             try {
-                dcc = FQN2Files.forRoot(root.toURL());
+                fqn2Files = FQN2Files.forRoot(root.toURL());
             } catch (IOException ex) {
                 LOGGER.log(Level.FINE, null, ex);
             }
@@ -744,14 +727,16 @@ public class JavacParser extends Parser {
                     sourceLevel != null ? sourceLevel.getSourceLevel() : null,
                     sourceLevel != null ? sourceLevel.getProfile() : null,
                     flags,
-                    oraculum,
-                    dcc,
+                    fqn2Files,
                     parser == null ? null : new DefaultCancelService(parser),
                     APTUtils.get(root),
                     compilerOptions,
-                    additionalModules);
-            Context context = javacTask.getContext();
-            TreeLoader.preRegister(context, cpInfo, detached);
+                    additionalModules,
+                    file != null ? Arrays.asList(FileObjects.sourceFileObject(file, root)) : Collections.emptyList());
+            Lookup.getDefault()
+                  .lookupAll(TreeLoaderRegistry.class)
+                  .stream()
+                  .forEach(r -> r.enhance(javacTask.getContext(), cpInfo, detached));
             return javacTask;
         }
     }
@@ -761,23 +746,23 @@ public class JavacParser extends Parser {
             @NullAllowed final DiagnosticListener<? super JavaFileObject> diagnosticListener,
             @NullAllowed final String sourceLevel,
             @NullAllowed final SourceLevelQuery.Profile sourceProfile,
-            @NullAllowed final ClassNamesForFileOraculum cnih,
-            @NullAllowed final DuplicateClassChecker dcc,
+            @NullAllowed FQN2Files fqn2Files,
             @NullAllowed final CancelService cancelService,
             @NullAllowed final APTUtils aptUtils,
-            @NullAllowed final CompilerOptionsQuery.Result compilerOptions) {
+            @NullAllowed final CompilerOptionsQuery.Result compilerOptions,
+            @NonNull Iterable<? extends JavaFileObject> files) {
         return createJavacTask(
                 cpInfo,
                 diagnosticListener,
                 sourceLevel,
                 sourceProfile,
                 EnumSet.of(ConfigFlags.BACKGROUND_COMPILATION, ConfigFlags.MULTI_SOURCE),
-                cnih,
-                dcc,
+                fqn2Files,
                 cancelService,
                 aptUtils,
                 compilerOptions,
-                Collections.emptySet());
+                Collections.emptySet(),
+                files);
     }
 
     private static enum ConfigFlags {
@@ -792,12 +777,12 @@ public class JavacParser extends Parser {
             @NullAllowed final String sourceLevel,
             @NullAllowed SourceLevelQuery.Profile sourceProfile,
             @NonNull final Set<? extends ConfigFlags> flags,
-            @NullAllowed final ClassNamesForFileOraculum cnih,
-            @NullAllowed final DuplicateClassChecker dcc,
+            @NullAllowed FQN2Files fqn2Files,
             @NullAllowed final CancelService cancelService,
             @NullAllowed final APTUtils aptUtils,
             @NullAllowed final CompilerOptionsQuery.Result compilerOptions,
-            @NonNull final Collection<? extends String> additionalModules) {
+            @NonNull final Collection<? extends String> additionalModules,
+            @NonNull Iterable<? extends JavaFileObject> files) {
         final boolean backgroundCompilation = flags.contains(ConfigFlags.BACKGROUND_COMPILATION);
         final boolean multiSource = flags.contains(ConfigFlags.MULTI_SOURCE);
         final List<String> options = new ArrayList<>();
@@ -883,19 +868,18 @@ public class JavacParser extends Parser {
         NBMessager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
         JavacTaskImpl task = (JavacTaskImpl)JavacTool.create().getTask(null,
                 ClasspathInfoAccessor.getINSTANCE().createFileManager(cpInfo, validatedSourceLevel.name),
-                diagnosticListener, options, null, Collections.<JavaFileObject>emptySet(),
+                diagnosticListener, options, files.iterator().hasNext() ? null : Arrays.asList("java.lang.Object"), files,
                 context);
         if (aptEnabled) {
             task.setProcessors(processors);
         }
         NBClassReader.preRegister(context);
-        JavadocClassFinder.preRegister(context, !backgroundCompilation);
-        if (cnih != null) {
-            context.put(ClassNamesForFileOraculum.class, cnih);
-        }
-        if (dcc != null) {
-            context.put(DuplicateClassChecker.class, dcc);
-        }
+        if (!backgroundCompilation)
+            JavadocClassFinder.preRegister(context);
+        Lookup.getDefault()
+              .lookupAll(DuplicateClassRegistry.class)
+              .stream()
+              .forEach(r -> r.enhance(context, fqn2Files));
         if (cancelService != null) {
             DefaultCancelService.preRegister(context, cancelService);
         }
@@ -1077,7 +1061,7 @@ public class JavacParser extends Parser {
          return false;
      }
 
-    private static void logTime (FileObject source, Phase phase, long time) {
+    public static void logTime (FileObject source, Phase phase, long time) {
         assert source != null && phase != null;
         String message = phase2Message.get(phase);
         assert message != null;
@@ -1091,7 +1075,7 @@ public class JavacParser extends Parser {
      * @param  info  CompilationInfo for which the error occurred.
      * @param  exc  exception to write to the end of dump file
      */
-    private static void dumpSource(CompilationInfoImpl info, Throwable exc) {
+    public static void dumpSource(CompilationInfoImpl info, Throwable exc) {
         String userDir = System.getProperty("netbeans.user");
         if (userDir == null) {
             return;
@@ -1154,168 +1138,6 @@ public class JavacParser extends Parser {
         }
     }
 
-    private static boolean reparseMethod (final CompilationInfoImpl ci,
-            final Snapshot snapshot,
-            final MethodTree orig,
-            final String newBody) throws IOException {
-        assert ci != null;
-        final FileObject fo = ci.getFileObject();
-        if (LOGGER.isLoggable(Level.FINER)) {
-            LOGGER.log(Level.FINER, "Reparse method in: {0}", fo);          //NOI18N
-        }
-        if (((JCMethodDecl)orig).localEnv == null) {
-            //We are seeing interface method or abstract or native method with body.
-            //Don't do any optimalization of this broken code - has no attr env.
-            return false;
-        }
-        final Phase currentPhase = ci.getPhase();
-        if (Phase.PARSED.compareTo(currentPhase) > 0) {
-            return false;
-        }
-        try {
-            final CompilationUnitTree cu = ci.getCompilationUnit();
-            if (cu == null || newBody == null) {
-                return false;
-            }
-            final JavacTaskImpl task = ci.getJavacTask();
-            if (Options.instance(task.getContext()).isSet(LOMBOK_DETECTED)) {
-                return false;
-            }
-            PartialReparser pr = PartialReparser.instance(task.getContext());
-            final JavacTrees jt = JavacTrees.instance(task);
-            final int origStartPos = (int) jt.getSourcePositions().getStartPosition(cu, orig.getBody());
-            final int origEndPos = (int) jt.getSourcePositions().getEndPosition(cu, orig.getBody());
-            if (origStartPos < 0) {
-                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} < 0", new Object[]{origStartPos});  //NOI18N
-                return false;
-            }
-            if (origStartPos > origEndPos) {
-                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} > endpos: {1}", new Object[]{origStartPos, origEndPos});  //NOI18N
-                return false;
-            }
-            final FindAnonymousVisitor fav = new FindAnonymousVisitor();
-            fav.scan(orig.getBody(), null);
-            if (fav.hasLocalClass) {
-                if (LOGGER.isLoggable(Level.FINER)) {
-                    LOGGER.log(Level.FINER, "Skeep reparse method (old local classes): {0}", fo);   //NOI18N
-                }
-                return false;
-            }
-            final int firstInner = fav.firstInner;
-            final int noInner = fav.noInner;
-            final Context ctx = task.getContext();
-            final TreeLoader treeLoader = TreeLoader.instance(ctx);
-            if (treeLoader != null) {
-                treeLoader.startPartialReparse();
-            }
-            try {
-                final Log l = Log.instance(ctx);
-                l.startPartialReparse();
-                final JavaFileObject prevLogged = l.useSource(cu.getSourceFile());
-                JCBlock block;
-                try {
-                    DiagnosticListener dl = ci.getDiagnosticListener();
-                    assert dl instanceof CompilationInfoImpl.DiagnosticListenerImpl;
-                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).startPartialReparse(origStartPos, origEndPos);
-                    long start = System.currentTimeMillis();
-                    Map<JCTree,LazyDocCommentTable.Entry> docComments = new HashMap<>();
-                    block = pr.reparseMethodBody(cu, orig, newBody + " ", firstInner, docComments);
-                    LOGGER.log(Level.FINER, "Reparsed method in: {0}", fo);     //NOI18N
-                    if (block == null) {
-                        LOGGER.log(
-                            Level.FINER,
-                            "Skeep reparse method, invalid position, newBody: ",       //NOI18N
-                            newBody);
-                        return false;
-                    }
-                    final int newEndPos = (int) jt.getSourcePositions().getEndPosition(cu, block);
-                    if (newEndPos != origStartPos + newBody.length()) {
-                        return false;
-                    }
-                    fav.reset();
-                    fav.scan(block, null);
-                    final int newNoInner = fav.noInner;
-                    if (fav.hasLocalClass || noInner != newNoInner) {
-                        if (LOGGER.isLoggable(Level.FINER)) {
-                            LOGGER.log(Level.FINER, "Skeep reparse method (new local classes): {0}", fo);   //NOI18N
-                        }
-                        return false;
-                    }
-                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.keySet().removeAll(fav.docOwners);
-                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.putAll(docComments);
-                    long end = System.currentTimeMillis();
-                    if (fo != null) {
-                        logTime (fo,Phase.PARSED,(end-start));
-                    }
-                    final int delta = newEndPos - origEndPos;
-                    final EndPosTable endPos = ((JCCompilationUnit)cu).endPositions;
-                    final TranslatePositionsVisitor tpv = new TranslatePositionsVisitor(orig, endPos, delta);
-                    tpv.scan(cu, null);
-                    ((JCMethodDecl)orig).body = block;
-                    if (Phase.RESOLVED.compareTo(currentPhase)<=0) {
-                        start = System.currentTimeMillis();
-                        pr.reattrMethodBody(orig, block);
-                        if (LOGGER.isLoggable(Level.FINER)) {
-                            LOGGER.log(Level.FINER, "Resolved method in: {0}", fo);     //NOI18N
-                        }
-                        if (!((CompilationInfoImpl.DiagnosticListenerImpl)dl).hasPartialReparseErrors()) {
-                            final JavacFlowListener fl = JavacFlowListener.instance(ctx);
-                            if (fl != null && fl.hasFlowCompleted(fo)) {
-                                if (LOGGER.isLoggable(Level.FINER)) {
-                                    final List<? extends Diagnostic> diag = ci.getDiagnostics();
-                                    if (!diag.isEmpty()) {
-                                        LOGGER.log(Level.FINER, "Reflow with errors: {0} {1}", new Object[]{fo, diag});     //NOI18N
-                                    }
-                                }
-                                TreePath tp = TreePath.getPath(cu, orig);       //todo: store treepath in changed method => improve speed
-                                Tree t = tp.getParentPath().getLeaf();
-                                pr.reflowMethodBody(cu, (ClassTree) t, orig);
-                                if (LOGGER.isLoggable(Level.FINER)) {
-                                    LOGGER.log(Level.FINER, "Reflowed method in: {0}", fo); //NOI18N
-                                }
-                            }
-                        }
-                        end = System.currentTimeMillis();
-                        if (fo != null) {
-                            logTime (fo, Phase.ELEMENTS_RESOLVED,0L);
-                            logTime (fo,Phase.RESOLVED,(end-start));
-                        }
-                    }
-
-                    //fix CompilationUnitTree.getLineMap:
-                    long startM = System.currentTimeMillis();
-                    char[] chars = snapshot.getText().toString().toCharArray();
-                    ((LineMapImpl) cu.getLineMap()).build(chars, chars.length);
-                    LOGGER.log(Level.FINER, "Rebuilding LineMap took: {0}", System.currentTimeMillis() - startM);
-
-                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).endPartialReparse (delta);
-                } finally {
-                    l.endPartialReparse();
-                    l.useSource(prevLogged);
-                }
-                ci.update(snapshot);
-            } finally {
-              if (treeLoader != null) {
-                  treeLoader.endPartialReparse();
-              }
-            }
-        } catch (CouplingAbort ca) {
-            //Needs full reparse
-            return false;
-        } catch (Throwable t) {
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            }
-            boolean a = false;
-            assert a = true;
-            if (a) {
-                dumpSource(ci, t);
-            }
-            return false;
-        }
-        return true;
-    }
-
     //Helper classes
     private static class DefaultCancelService extends CancelService {
 
@@ -1396,4 +1218,33 @@ public class JavacParser extends Parser {
             listeners.fireChange();
         }
     }
+    
+    public static interface PartialReparser {
+        public boolean reparseMethod (final CompilationInfoImpl ci,
+                final Snapshot snapshot,
+                final MethodTree orig,
+                final String newBody) throws IOException;
+    }
+    
+    @ServiceProvider(service = PartialReparser.class, position = 1000)
+    public static class DefaultPartialReparser implements PartialReparser {
+
+        @Override
+        public boolean reparseMethod(CompilationInfoImpl ci, Snapshot snapshot, MethodTree orig, String newBody) throws IOException {
+            return false;
+        }
+        
+    }
+    
+    public static interface TreeLoaderRegistry {
+        public void enhance(Context context, ClasspathInfo cpInfo, boolean detached);
+    }
+    
+    public static interface DuplicateClassRegistry {
+        public void enhance(Context context, FQN2Files fqn2Files);
+    }
+    
+    public static interface SequentialParsing {
+        public Iterable<? extends CompilationUnitTree> parse(JavacTask task, JavaFileObject file) throws IOException;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
index 45cd52a..364b467 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
@@ -182,7 +182,6 @@ public final class ModuleOraculum implements CompilerOptionsQueryImplementation,
     @NonNull
     private static String parsePackage(FileObject file) {
         String pkg = "";    //NOI18N
-        try {
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                     new ClasspathInfo.Builder(ClassPath.EMPTY).build(),
                     null,
@@ -192,22 +191,16 @@ public final class ModuleOraculum implements CompilerOptionsQueryImplementation,
                     null,
                     null,
                     null,
-                    null);
-            final CompilationUnitTree cu =  jt.parse(FileObjects.fileObjectFileObject(
+                    Collections.singletonList(FileObjects.fileObjectFileObject(
                     file,
                     file.getParent(),
                     null,
-                    FileEncodingQuery.getEncoding(file))).iterator().next();
+                    FileEncodingQuery.getEncoding(file))));
+            final CompilationUnitTree cu =  jt.parse().iterator().next();
             pkg = Optional.ofNullable(cu.getPackage())
                     .map((pt) -> pt.getPackageName())
                     .map((xt) -> xt.toString())
                     .orElse(pkg);
-        } catch (IOException ioe) {
-            LOG.log(
-                    Level.INFO,
-                    "Cannot parse: {0}",
-                    FileUtil.getFileDisplayName(file));
-        }
         return pkg;
     }
 
@@ -253,7 +246,7 @@ public final class ModuleOraculum implements CompilerOptionsQueryImplementation,
         R(@NonNull final String moduleName) {
             Parameters.notNull("moduleName", moduleName);   //NOI18N
             this.ops = Collections.singletonList(String.format(
-                    "-Xmodule:%s",  //NOI18N
+                    "-XD-Xmodule:%s",  //NOI18N
                     moduleName));
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java
new file mode 100644
index 0000000..e478405
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.parsing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.util.Log;
+import java.io.IOException;
+import javax.tools.JavaFileObject;
+
+/**
+ *
+ * @author lahvac
+ */
+public class ParsingUtils {
+    
+    public static CompilationUnitTree parseArbitrarySource(JavacTask task, JavaFileObject file) throws IOException {
+        JavacTaskImpl taskImpl = (JavacTaskImpl) task;
+        com.sun.tools.javac.util.Context context = taskImpl.getContext();
+        Log log = Log.instance(context);
+        JavaFileObject prevSource = log.useSource(file);
+        try {
+            ParserFactory fac = ParserFactory.instance(context);
+            JCCompilationUnit cut = fac.newParser(file.getCharContent(true), true, true, true).parseCompilationUnit();
+            
+            cut.sourcefile = file;
+            
+            return cut;
+        } finally {
+            log.useSource(prevSource);
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java
deleted file mode 100644
index c0119f7..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.parsing;
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
-import com.sun.tools.javac.tree.EndPosTable;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import org.netbeans.lib.nbjavac.services.NBParserFactory.NBJavacParser.EndPosTableImpl;
-
-/**
- * Helper visitor for partial reparse.
- * Updates tree positions by the given delta.
- * @author Tomas Zezula
- */
-class TranslatePositionsVisitor extends TreeScanner<Void,Void> {
-
-    private final MethodTree changedMethod;
-    private final EndPosTable endPos;
-    private final int delta;
-    boolean active;
-    boolean inMethod;
-
-    public TranslatePositionsVisitor (final MethodTree changedMethod, final EndPosTable endPos, final int delta) {
-        assert changedMethod != null;
-        assert endPos != null;
-        this.changedMethod = changedMethod;
-        this.endPos = endPos;
-        this.delta = delta;
-    }
-
-
-    @Override
-    public Void scan(Tree node, Void p) {
-        if (active && node != null) {
-            if (((JCTree)node).pos >= 0) {                    
-                ((JCTree)node).pos+=delta;
-            }                
-        }
-        Void result = super.scan(node, p);            
-        if (inMethod && node != null) {
-            endPos.replaceTree((JCTree) node, null);//remove
-        }
-        if (active && node != null) {
-            Integer pos = endPos.replaceTree((JCTree) node, null);//remove
-            if (pos != null) {
-                int newPos;
-                if (pos < 0) {
-                    newPos = pos;
-                }
-                else {
-                    newPos = pos+delta;
-                }
-                ((EndPosTableImpl) endPos).storeEnd((JCTree)node,newPos);
-            }                
-        }
-        return result;
-    }
-
-    @Override
-    public Void visitCompilationUnit(CompilationUnitTree node, Void p) {
-        return scan (node.getTypeDecls(), p);
-    }
-
-
-    @Override
-    public Void visitMethod(MethodTree node, Void p) {    
-        if (active || inMethod) {
-            scan(node.getModifiers(), p);
-            scan(node.getReturnType(), p);
-            scan(node.getTypeParameters(), p);
-            scan(node.getParameters(), p);
-            scan(node.getThrows(), p);
-        }
-        if (node == changedMethod) {
-            inMethod = true;
-        }
-        if (active || inMethod) {
-            scan(node.getBody(), p);
-        }
-        if (inMethod) {
-            active = inMethod;
-            inMethod = false;                
-        }
-        if (active || inMethod) {
-            scan(node.getDefaultValue(), p);
-        }
-        return null;
-    }
-
-    @Override
-    public Void visitVariable(VariableTree node, Void p) {
-        JCVariableDecl varDecl = (JCVariableDecl) node;
-        if (varDecl.sym != null && active && varDecl.sym.pos >= 0) {
-            varDecl.sym.pos += delta;
-        }
-        return super.visitVariable(node, p);
-    }
-    
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java b/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
index e2b01cf..6335f4a 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
@@ -27,7 +27,7 @@ import com.sun.source.tree.ImportTree;
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.util.Context;
@@ -178,7 +178,7 @@ public class ImportAnalysis2 {
     private String getFQN(Tree expression) {
         final StringBuffer result = new StringBuffer();
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
 
             @Override
             public Void visitMemberSelect(MemberSelectTree tree, Void p) {
@@ -402,7 +402,7 @@ public class ImportAnalysis2 {
         
         usedImplicitlyImportedClassesCache = new HashMap<String, Element>();
         
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 Element e = overlay.wrap(model, elements, model.getElement(node));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java b/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
index 5b23f72..58367b9 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
@@ -32,7 +32,7 @@ import static com.sun.source.tree.Tree.*;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 
 import com.sun.source.doctree.AttributeTree;
 import com.sun.source.doctree.AttributeTree.ValueKind;
@@ -496,7 +496,7 @@ public final class VeryPretty extends JCTree.Visitor implements DocTreeVisitor<V
         final int newStart = out.length() + initialOffset;
 
         final int[] realEnd = {endPos(lastTree)};
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 if (node != null) {
@@ -2564,7 +2564,7 @@ public final class VeryPretty extends JCTree.Visitor implements DocTreeVisitor<V
         return null;
     }
 
-    private final class Linearize extends TreeScanner<Boolean, java.util.List<Tree>> {
+    private final class Linearize extends ErrorAwareTreeScanner<Boolean, java.util.List<Tree>> {
         @Override
         public Boolean scan(Tree node, java.util.List<Tree> p) {
             p.add(node);
@@ -2577,7 +2577,7 @@ public final class VeryPretty extends JCTree.Visitor implements DocTreeVisitor<V
         }
     }
 
-    private final class CopyTags extends TreeScanner<Void, java.util.List<Tree>> {
+    private final class CopyTags extends ErrorAwareTreeScanner<Void, java.util.List<Tree>> {
         private final CompilationUnitTree fake;
         private final SourcePositions sp;
         public CopyTags(CompilationUnitTree fake, SourcePositions sp) {
@@ -2607,20 +2607,16 @@ public final class VeryPretty extends JCTree.Visitor implements DocTreeVisitor<V
             return; //nothing to  copy
         }
         
-        try {
             ClassPath empty = ClassPathSupport.createClassPath(new URL[0]);
             ClasspathInfo cpInfo = ClasspathInfo.create(JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(), empty, empty);
-            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, null);
+            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, Arrays.asList(FileObjects.memoryFileObject("", "Scratch.java", code)));
             com.sun.tools.javac.util.Context ctx = javacTask.getContext();
             JavaCompiler.instance(ctx).genEndPos = true;
-            CompilationUnitTree tree = javacTask.parse(FileObjects.memoryFileObject("", "", code)).iterator().next(); //NOI18N
+            CompilationUnitTree tree = javacTask.parse().iterator().next(); //NOI18N
             SourcePositions sp = JavacTrees.instance(ctx).getSourcePositions();
             ClassTree clazz = (ClassTree) tree.getTypeDecls().get(0);
 
             new CopyTags(tree, sp).scan(clazz.getModifiers().getAnnotations(), linearized);
-        } catch (IOException ex) {
-            Exceptions.printStackTrace(ex);
-        }
     }
 
     private boolean reallyPrintAnnotations;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
index 3fec5af..b1e91bd 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.DocSourcePositions;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.code.*;
 import static com.sun.tools.javac.code.Flags.*;
@@ -487,6 +487,16 @@ public class CasualDiff {
         // TODO: the package name actually ends at the end of the name, so the semicolon could be treated as part
         // of the diffed list
         int start = td.oldTopLevel.getPackage() != null ? td.endPos(td.oldTopLevel.getPackage()) : 0;
+        
+        //XXX: no-javac-patch:
+        td.tokenSequence.move(start);
+        
+        while (td.tokenSequence.movePrevious()) {
+            if (td.isNoop(td.tokenSequence.token().id())) {
+                start = td.tokenSequence.offset();
+            }
+        }
+        //XXX: no-javac-patch end
 
         List<JCImport> originalJC = new LinkedList<JCImport>();
         List<JCImport> nueJC = new LinkedList<JCImport>();
@@ -1597,6 +1607,18 @@ public class CasualDiff {
         }
     }
 
+    private boolean isNoop(JavaTokenId tid) {
+        switch (tid) {
+            case LINE_COMMENT:
+            case BLOCK_COMMENT:
+            case JAVADOC_COMMENT:
+            case WHITESPACE:
+                return true;
+            default:
+                return false;
+        }
+    }
+
     private int dimension(JCTree t, int afterPos) {
         if (t.getKind() != Kind.ARRAY_TYPE) {
             return 0;
@@ -5055,7 +5077,7 @@ public class CasualDiff {
     }
     
     private int getPosAfterTreeComments(JCTree t, int end) {
-        class Scn extends TreeScanner<Void, Void> {
+        class Scn extends ErrorAwareTreeScanner<Void, Void> {
             int max = -1;
             
             @Override
@@ -5675,7 +5697,7 @@ public class CasualDiff {
 
     private int getCommentCorrectedEndPos(JCTree tree) {
         final int[] res = new int[] {endPos(tree)};
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override public Void scan(Tree node, Void p) {
                 if (node != null) {
                     CommentSet ch = comments.getComments(node);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java b/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
index f91046f..d1b19d2 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
@@ -44,6 +44,7 @@ import org.netbeans.api.java.lexer.JavadocTokenId;
 import org.netbeans.api.java.platform.JavaPlatformManager;
 import org.netbeans.api.java.source.*;
 import org.netbeans.api.java.source.CodeStyle.WrapStyle;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.lexer.Token;
 import org.netbeans.api.lexer.TokenHierarchy;
 import org.netbeans.api.lexer.TokenSequence;
@@ -105,13 +106,12 @@ public class Reformatter implements ReformatTask {
 
     public static String reformat(String text, CodeStyle style, int rightMargin) {
         StringBuilder sb = new StringBuilder(text);
-        try {
             ClassPath empty = ClassPathSupport.createClassPath(new URL[0]);
             ClasspathInfo cpInfo = ClasspathInfo.create(JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(), empty, empty);
-            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, null);
+            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, Arrays.asList(FileObjects.memoryFileObject("","Scratch.java", text)));
             com.sun.tools.javac.util.Context ctx = javacTask.getContext();
             JavaCompiler.instance(ctx).genEndPos = true;
-            CompilationUnitTree tree = javacTask.parse(FileObjects.memoryFileObject("","", text)).iterator().next(); //NOI18N
+            CompilationUnitTree tree = javacTask.parse().iterator().next(); //NOI18N
             SourcePositions sp = JavacTrees.instance(ctx).getSourcePositions();
             TokenSequence<JavaTokenId> tokens = TokenHierarchy.create(text, JavaTokenId.language()).tokenSequence(JavaTokenId.language());
             for (Diff diff : Pretty.reformat(text, tokens, new TreePath(tree), sp, style, rightMargin)) {
@@ -124,8 +124,6 @@ public class Reformatter implements ReformatTask {
                 }
             }
 
-        } catch (IOException ioe) {
-        }
         return sb.toString();
     }
     
@@ -391,7 +389,7 @@ public class Reformatter implements ReformatTask {
         }        
     }
 
-    private static class Pretty extends TreePathScanner<Boolean, Void> {
+    private static class Pretty extends ErrorAwareTreePathScanner<Boolean, Void> {
 
         private static final String OPERATOR = "operator"; //NOI18N
         private static final String EMPTY = ""; //NOI18N

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java b/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
index 91fb6bf..b8bf792 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
@@ -43,7 +43,7 @@ import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.api.JavacTrees;
@@ -63,6 +63,8 @@ import java.util.Set;
 import javax.swing.text.BadLocationException;
 import javax.tools.JavaFileObject;
 
+import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.util.Log;
 import org.netbeans.api.java.lexer.JavaTokenId;
 import org.netbeans.api.java.source.CodeStyle;
 import org.netbeans.api.lexer.TokenHierarchy;
@@ -73,6 +75,8 @@ import org.netbeans.modules.editor.indent.spi.ExtraLock;
 import org.netbeans.modules.editor.indent.spi.IndentTask;
 import org.netbeans.modules.java.source.parsing.FileObjects;
 import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.ParsingUtils;
+import org.netbeans.modules.java.source.parsing.PrefetchableJavaFileObject;
 import org.netbeans.modules.parsing.impl.Utilities;
 import org.openide.filesystems.FileObject;
 
@@ -218,24 +222,25 @@ public class Reindenter implements IndentTask {
                 text = context.document().getText(currentEmbeddingStartOffset, currentEmbeddingLength);
                 if (JavacParser.MIME_TYPE.equals(context.mimePath())) {
                     FileObject fo = Utilities.getFileObject(context.document());
-                    cut = javacTask.parse(FileObjects.memoryFileObject("", fo != null ? fo.getNameExt() : "", text)).iterator().next(); //NOI18N
+                    cut = ParsingUtils.parseArbitrarySource(javacTask, FileObjects.memoryFileObject("", fo != null ? fo.getNameExt() : "", text));
                     parsedTree = cut;
                     sp = JavacTrees.instance(ctx).getSourcePositions();
                 } else {
-                    final SourcePositions[] psp = new SourcePositions[1];
-                    cut = null;
-                    parsedTree = javacTask.parseStatement("{" + text + "}", psp);
-                    sp = new SourcePositions() {
-                        @Override
-                        public long getStartPosition(CompilationUnitTree file, Tree tree) {
-                            return currentEmbeddingStartOffset + psp[0].getStartPosition(file, tree) - 1;
-                        }
-
-                        @Override
-                        public long getEndPosition(CompilationUnitTree file, Tree tree) {
-                            return currentEmbeddingStartOffset + psp[0].getEndPosition(file, tree) - 1;
-                        }
-                    };
+//                    final SourcePositions[] psp = new SourcePositions[1];
+//                    cut = null;
+//                    parsedTree = javacTask.parseStatement("{" + text + "}", psp);
+//                    sp = new SourcePositions() {
+//                        @Override
+//                        public long getStartPosition(CompilationUnitTree file, Tree tree) {
+//                            return currentEmbeddingStartOffset + psp[0].getStartPosition(file, tree) - 1;
+//                        }
+//
+//                        @Override
+//                        public long getEndPosition(CompilationUnitTree file, Tree tree) {
+//                            return currentEmbeddingStartOffset + psp[0].getEndPosition(file, tree) - 1;
+//                        }
+//                    };
+                    throw new UnsupportedOperationException("TODO");
                 }
             } catch (Exception ex) {
                 return false;
@@ -831,7 +836,7 @@ public class Reindenter implements IndentTask {
                 ts.token().id().primaryCategory().equals("literal")) //NOI18N
                 ? ts.offset() : startOffset;
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
 
             @Override
             public Void scan(Tree node, Void p) {


[07/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java b/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
deleted file mode 100644
index 97eb34a..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.usages;
-
-import com.sun.tools.javac.api.ClassNamesForFileOraculum;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import javax.tools.JavaFileObject;
-
-/**
- *
- * @author Jan Lahoda
- */
-public class ClassNamesForFileOraculumImpl implements ClassNamesForFileOraculum {
-
-    private final Map<JavaFileObject, List<String>> misplacedSource2FQNs;
-
-    public ClassNamesForFileOraculumImpl(Map<JavaFileObject, List<String>> misplacedSource2FQNs) {
-        this.misplacedSource2FQNs = misplacedSource2FQNs;
-    }
-    
-    public String[] divineClassName(JavaFileObject jfo) {
-        if (misplacedSource2FQNs.isEmpty()) {
-            return null;
-        }
-        
-        List<String> result = misplacedSource2FQNs.get(jfo);
-        
-        if (result != null) {
-            return result.toArray(new String[result.size()]);
-        }
-        
-        return null;
-    }
-
-    public JavaFileObject[] divineSources(String fqn) {
-        if (fqn == null || fqn.length() == 0 || misplacedSource2FQNs.isEmpty()) {
-            return null;
-        }
-
-        fqn += "."; //fqn should always be a package name
-
-        List<JavaFileObject> jfos = new LinkedList<JavaFileObject>();
-        for (Map.Entry<JavaFileObject, List<String>> entry : misplacedSource2FQNs.entrySet()) {
-            for (String s : entry.getValue()) {
-                if (s.startsWith(fqn)) {
-                    if (s.indexOf('.', fqn.length()) == -1) {
-                        jfos.add(entry.getKey());
-                        break;
-                    }
-                }
-            }
-        }
-        
-        return jfos.size() > 0 ? jfos.toArray(new JavaFileObject[jfos.size()]) : null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java b/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
index 5c24026..f2e05d4 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
@@ -19,8 +19,8 @@
 package org.netbeans.modules.java.source.usages;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Kinds;
@@ -271,7 +271,7 @@ public final class SourceAnalyzerFactory {
         }
     }
         
-    private static class UsagesVisitor extends TreePathScanner<Void,Map<Pair<BinaryName,String>,UsagesData<String>>> {
+    private static class UsagesVisitor extends ErrorAwareTreePathScanner<Void,Map<Pair<BinaryName,String>,UsagesData<String>>> {
 
         enum State {EXTENDS, IMPLEMENTS, GT, OTHER, IMPORT, PACKAGE_ANN};
 
@@ -827,7 +827,7 @@ public final class SourceAnalyzerFactory {
                 activeClass.push(name);
                 try {
                     addAndClearImports(name, p);
-                    node.accept(new TreeScanner<Void, Set<Symbol>>() {
+                    node.accept(new ErrorAwareTreeScanner<Void, Set<Symbol>>() {
                                 @Override
                                 public Void visitExports(ExportsTree node, Set<Symbol> p) {
                                     final Symbol sym = ((JCTree.JCExports)node).directive.packge;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
index bc87669..6e6ea24 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
@@ -187,8 +187,6 @@ public class APIIsSelfContainedTest extends NbTestCase {
         
         return new FileObject[] {
             FileUtil.getArchiveRoot(root.getFileObject("java/modules/org-netbeans-modules-java-source.jar")),
-            FileUtil.getArchiveRoot(root.getFileObject("java/modules/ext/nb-javac-api.jar")),
-            FileUtil.getArchiveRoot(root.getFileObject("java/modules/ext/nb-javac-impl.jar")),
         };
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
index dd65e03..0cb7cf3 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import org.junit.Test;
@@ -127,7 +127,7 @@ public class CommentCollectorTest extends NbTestCase {
                 cu.accept(printer, null);
 
 
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void aVoid) {
                         switch (node.getName().toString()) {
@@ -205,7 +205,7 @@ public class CommentCollectorTest extends NbTestCase {
                 cu.accept(printer, null);
 
 
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void aVoid) {
                         verify(node, CommentSet.RelativePosition.PRECEDING, service, "/** (COMM1) This comment belongs before class */");
@@ -282,7 +282,7 @@ public class CommentCollectorTest extends NbTestCase {
 
                 JCTree.JCClassDecl clazz = (JCTree.JCClassDecl) cu.getTypeDecls().get(0);
                 final boolean[] processed = new boolean[1];
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitExpressionStatement(ExpressionStatementTree node, Void p) {
                         verify(node, CommentSet.RelativePosition.PRECEDING, service, "// Test");
@@ -329,7 +329,7 @@ public class CommentCollectorTest extends NbTestCase {
                 cu.accept(printer, null);
 
                 JCTree.JCClassDecl clazz = (JCTree.JCClassDecl) cu.getTypeDecls().get(0);
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void visitReturn(ReturnTree node, Void aVoid) {
@@ -382,7 +382,7 @@ public class CommentCollectorTest extends NbTestCase {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         GeneratorUtilities.get(workingCopy).importComments(node, workingCopy.getCompilationUnit());
@@ -433,7 +433,7 @@ public class CommentCollectorTest extends NbTestCase {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         if (node.getName().contentEquals("m3")) {
@@ -471,7 +471,7 @@ public class CommentCollectorTest extends NbTestCase {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         GeneratorUtilities.get(workingCopy).importComments(node, workingCopy.getCompilationUnit());
@@ -517,7 +517,7 @@ public class CommentCollectorTest extends NbTestCase {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         if (node.getName().contentEquals("test")) {
@@ -552,7 +552,7 @@ public class CommentCollectorTest extends NbTestCase {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         GeneratorUtilities.get(workingCopy).importComments(node, workingCopy.getCompilationUnit());
@@ -746,7 +746,7 @@ public class CommentCollectorTest extends NbTestCase {
         }
     }
 
-    private static class CommentPrinter extends TreeScanner<Void, Void> {
+    private static class CommentPrinter extends ErrorAwareTreeScanner<Void, Void> {
         private CommentHandlerService service;
 
         CommentPrinter(CommentHandlerService service) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
index 51fe5c4..4dcbfc4 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
@@ -43,6 +43,7 @@ import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.usages.IndexUtil;
 import org.netbeans.spi.java.classpath.ClassPathProvider;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
@@ -171,7 +172,7 @@ public class ElementHandleTest extends NbTestCase {
                     }
                 }
                 assertNotNull (retentionPolicyClassHandle[0]);
-                Element csl = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                Element csl = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (csl);
                 innerClassHandle[0] = ElementHandle.create(csl);
                 assertNotNull (innerClassHandle[0]);
@@ -179,16 +180,16 @@ public class ElementHandleTest extends NbTestCase {
                 assertNotNull (cadd);
                 collectionAddHandle[0] = ElementHandle.create(cadd);
                 assertNotNull (collectionAddHandle[0]);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 annonClassHandle[0] = ElementHandle.create(annonClass);
                 assertNotNull (annonClassHandle[0]);
-                TypeElement listClass = elements.getTypeElementByBinaryName("java.util.List"); //NOI18N
+                TypeElement listClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.List"); //NOI18N
                 assertNotNull(listClass);
                 List<? extends TypeParameterElement> tpes = listClass.getTypeParameters();
                 assertEquals(tpes.size(), 1);
                 genParList[0] = ElementHandle.create(tpes.get(0));
-                TypeElement collsClass = elements.getTypeElementByBinaryName("java.util.Collections"); //NOI18N
+                TypeElement collsClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections"); //NOI18N
                 assertNotNull(collsClass);
                 for (Element member : collsClass.getEnclosedElements()) {
                     if (member.getKind() == ElementKind.METHOD && member.getSimpleName().contentEquals("min")) {
@@ -249,7 +250,7 @@ public class ElementHandleTest extends NbTestCase {
                 assertEquals(resolved,retentionClassElement);
                 resolved = innerClassHandle[0].resolve(parameter);
                 assertNotNull (resolved);
-                Element csl = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                Element csl = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (csl);
                 assertEquals(resolved,csl);
                 resolved = collectionAddHandle[0].resolve(parameter);
@@ -259,18 +260,18 @@ public class ElementHandleTest extends NbTestCase {
                 assertEquals (resolved, cadd);
                 resolved = annonClassHandle[0].resolve(parameter);
                 assertNotNull (resolved);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 assertEquals(resolved,annonClass);
                 
-                TypeElement listClass = elements.getTypeElementByBinaryName("java.util.List"); //NOI18N
+                TypeElement listClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.List"); //NOI18N
                 assertNotNull(listClass);
                 TypeParameterElement tpe = listClass.getTypeParameters().get(0);
                 resolved = genParList[0].resolve(parameter);
                 assertEquals(tpe, resolved);
                 
                 tpe = null;
-                TypeElement collsClass = elements.getTypeElementByBinaryName("java.util.Collections"); //NOI18N
+                TypeElement collsClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections"); //NOI18N
                 assertNotNull(collsClass);
                 for (Element member : collsClass.getEnclosedElements()) {
                     if (member.getKind() == ElementKind.METHOD && member.getSimpleName().contentEquals("min")) {
@@ -345,7 +346,7 @@ public class ElementHandleTest extends NbTestCase {
                 assertNotNull (cadd);
                 collectionAddHandle[0] = ElementHandle.create(cadd);
                 assertNotNull (collectionAddHandle[0]);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 annonClassHandle[0] = ElementHandle.create(annonClass);
                 assertNotNull (annonClassHandle[0]);
@@ -383,13 +384,13 @@ public class ElementHandleTest extends NbTestCase {
                 }
                 assertNotNull (retentionClassElement);
                 assertTrue(retentionPolicyClassHandle[0].signatureEquals(retentionClassElement));
-                Element csl = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                Element csl = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (csl);
                 assertTrue(innerClassHandle[0].signatureEquals(csl));
                 Element cadd = getCollectionAdd(elements.getTypeElement(java.util.Collection.class.getName()));
                 assertNotNull(cadd);
                 assertTrue (collectionAddHandle[0].signatureEquals(cadd));
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 assertTrue(annonClassHandle[0].signatureEquals(annonClass));
             }
@@ -483,7 +484,7 @@ public class ElementHandleTest extends NbTestCase {
                 assertNotNull (cadd);
                 collectionAddHandle[0] = ElementHandle.create(cadd);
                 assertNotNull (collectionAddHandle[0]);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 annonClassHandle[0] = ElementHandle.create(annonClass);
                 assertNotNull (annonClassHandle[0]);
@@ -565,7 +566,7 @@ public class ElementHandleTest extends NbTestCase {
                 assertEquals("java.lang.annotation.RetentionPolicy", handle.getBinaryName());
                 assertEquals("java.lang.annotation.RetentionPolicy", handle.getQualifiedName());
                 
-                element = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                element = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (element);                
                 handle = ElementHandle.create(element);
                 assertEquals("java.util.Collections$SingletonList", handle.getBinaryName());
@@ -597,7 +598,7 @@ public class ElementHandleTest extends NbTestCase {
 
             public void run(CompilationController parameter) throws Exception {
                 JavacElements elements = (JavacElements) parameter.getElements();
-                TypeElement te = elements.getTypeElementByBinaryName("java.lang.String$1");
+                TypeElement te = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1");
                 List<? extends Element> content = elements.getAllMembers(te);                
             }
         }, true);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
index bbe0bcd..58a09a1 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
@@ -44,8 +44,9 @@ import javax.tools.Diagnostic;
 import com.sun.source.tree.*;
 import com.sun.source.util.SimpleTreeVisitor;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
+import com.sun.tools.javac.api.JavacTaskImpl;
 import junit.framework.*;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.FieldSelector;
@@ -160,6 +161,8 @@ public class JavaSourceTest extends NbTestCase {
         suite.addTest(new JavaSourceTest("testModificationJob"));
 //        suite.addTest(new JavaSourceTest("testInterference"));
         suite.addTest(new JavaSourceTest("testDocumentChanges"));
+        suite.addTest(new JavaSourceTest("testMultipleFiles"));
+        suite.addTest(new JavaSourceTest("testMultipleFilesSameJavac"));
         /*
         suite.addTest(new JavaSourceTest("testParsingDelay"));
 //        suite.addTest(new JavaSourceTest("testJavaSourceIsReclaimable"));     fails in trunk
@@ -261,6 +264,59 @@ public class JavaSourceTest extends NbTestCase {
         assertTrue ("Time out",latch.await(15,TimeUnit.SECONDS));
     }
 
+    public void testMultipleFiles () throws Exception {
+        final FileObject testFile1 = createTestFile("Test1");
+        final FileObject testFile2 = createTestFile("Test2");
+        final ClassPath bootPath = createBootPath();
+        final ClassPath compilePath = createCompilePath();
+        final ClassPath srcPath = createSourcePath();
+        final JavaSource js = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), testFile1, testFile2);
+        boolean[] test1 = new boolean[1];
+        boolean[] test2 = new boolean[1];
+        js.runUserActionTask(new Task<CompilationController>() {
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                parameter.toPhase(Phase.RESOLVED);
+                
+                //TODO: safer checks!
+                if (parameter.getCompilationUnit().toString().contains("Test1")) {
+                    test1[0] = true;
+                } else if (parameter.getCompilationUnit().toString().contains("Test2")) {
+                    test2[0] = true;
+                } else {
+                   fail();
+                }
+            }
+        }, true);
+        assertTrue ("Test1", test1[0]);
+        assertTrue ("Test2", test2[0]);
+    }
+
+    public void testMultipleFilesSameJavac() throws Exception {
+        final FileObject testFile1 = createTestFile("Test1");
+        final FileObject testFile2 = createTestFile("Test2");
+        final ClassPath bootPath = createBootPath();
+        final ClassPath compilePath = createCompilePath();
+        final ClassPath srcPath = createSourcePath();
+        final JavaSource js = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), testFile1, testFile2);
+        js.runUserActionTask(new Task<CompilationController>() {
+            private JavacTaskImpl seenTask;
+
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                parameter.toPhase(Phase.RESOLVED);
+                
+                JavacTaskImpl currentTask = parameter.impl.getJavacTask();
+                
+                if (seenTask == null) {
+                    seenTask= currentTask;
+                } else if (seenTask != currentTask) {
+                   fail();
+                }
+            }
+        }, true);
+    }
+
     public void testInterference () throws MalformedURLException, IOException, InterruptedException {
         FileObject testFile1 = createTestFile ("Test1");
         FileObject testFile2 = createTestFile ("Test2");
@@ -2020,7 +2076,7 @@ public class JavaSourceTest extends NbTestCase {
         }
     }
 
-    private static class ScannerImpl extends TreePathScanner<Void, Void> {
+    private static class ScannerImpl extends ErrorAwareTreePathScanner<Void, Void> {
 
         private CompilationInfo info;
 
@@ -2054,7 +2110,7 @@ public class JavaSourceTest extends NbTestCase {
         }
     }
 
-    private static class TransformImpl extends TreeScanner<Void, Object> {
+    private static class TransformImpl extends ErrorAwareTreeScanner<Void, Object> {
 
         private WorkingCopy copy;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
index 5b7c957..3c947bc 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
@@ -20,9 +20,13 @@ package org.netbeans.api.java.source;
 
 import com.sun.source.tree.Tree;
 import org.apache.lucene.store.FSDirectory;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.TreeLoaderRegistry;
 import org.netbeans.modules.java.source.transform.Transformer;
 import org.netbeans.modules.parsing.lucene.LuceneIndex;
 import org.netbeans.modules.parsing.lucene.support.IndexManagerTestUtilities;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
 
 /**
  *
@@ -55,5 +59,22 @@ public final class SourceUtilsTestUtil2 {
     
     public static void disableLocks() {
     }
-    
+
+    public static void disableArtificalParameterNames() {
+        try {
+            Class treeLoader = Class.forName("org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader");
+            treeLoader.getField("DISABLE_ARTIFICAL_PARAMETER_NAMES").set(null, true);
+        } catch (Exception ex) {
+            //ignore
+        }
+    }
+
+    public static void disableConfinementTest() {
+        try {
+            Class treeLoader = Class.forName("org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader");
+            treeLoader.getField("DISABLE_CONFINEMENT_TEST").set(null, true);
+        } catch (Exception ex) {
+            //ignore
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
index 38b2dea..144e672 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
@@ -29,7 +29,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
@@ -490,7 +490,7 @@ public class TreeUtilitiesTest extends NbTestCase {
 
         final List<Boolean> result = new ArrayList<Boolean>();
 
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override public Void visitAssignment(AssignmentTree node, Void p) {
                 result.add(info.getTreeUtilities().isCompileTimeConstantExpression(new TreePath(getCurrentPath(), node.getExpression())));
                 return super.visitAssignment(node, p);
@@ -511,6 +511,22 @@ public class TreeUtilitiesTest extends NbTestCase {
         }, true);
     }
     
+    public void testStaticBlock() throws Exception {
+        ClassPath boot = ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));
+        JavaSource js = JavaSource.create(ClasspathInfo.create(boot, ClassPath.EMPTY, ClassPath.EMPTY));
+        js.runUserActionTask(new Task<CompilationController>() {
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                final SourcePositions[] sp = new SourcePositions[1];
+                BlockTree block = parameter.getTreeUtilities().parseStaticBlock("static { }", sp);
+                assertNotNull(block);
+                assertEquals(0, sp[0].getStartPosition(null, block));
+                assertEquals(10, sp[0].getEndPosition(null, block));
+                assertNull(parameter.getTreeUtilities().parseStaticBlock("static", new SourcePositions[1]));
+            }
+        }, true);
+    }
+    
     public void testJavacInitializationElements() throws Exception {
         ClassPath boot = ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));
         JavaSource js = JavaSource.create(ClasspathInfo.create(boot, ClassPath.EMPTY, ClassPath.EMPTY));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
index 586bcab..686130a 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
@@ -20,7 +20,7 @@
 package org.netbeans.api.java.source;
 
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.OutputStream;
 import java.net.URL;
@@ -187,7 +187,7 @@ public class TypeMirrorHandleTest extends NbTestCase {
 
             public void run(final CompilationController info) throws Exception {
                 info.toPhase(Phase.RESOLVED);
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("e")) {
                             TypeMirror tm = info.getTrees().getTypeMirror(getCurrentPath());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
index a5b66a0..f9ca8a7 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
@@ -20,8 +20,8 @@ package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -220,7 +220,7 @@ public class AnnotationTest extends GeneratorTestBase {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         workingCopy.rewrite(node, workingCopy.getTreeMaker().setInitialValue(node, workingCopy.getTreeMaker().Identifier("A.E")));
@@ -257,7 +257,7 @@ public class AnnotationTest extends GeneratorTestBase {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         workingCopy.rewrite(node, workingCopy.getTreeMaker().setInitialValue(node, null));
@@ -733,7 +733,7 @@ public class AnnotationTest extends GeneratorTestBase {
 
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitModifiers(ModifiersTree node, Void p) {
                         String toParse = "new Object() {" + annotationSpecification + " void test() {} }";
@@ -951,7 +951,7 @@ public class AnnotationTest extends GeneratorTestBase {
                 final TreeMaker make = workingCopy.getTreeMaker();
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("MyEntity"))
                             workingCopy.rewrite(node, make.Identifier("MyEntity1"));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
index 69f2f68..b75bc9a 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -512,7 +512,7 @@ public class ArraysTest extends GeneratorTestMDRCompat {
     }
 
     public void testRewriteType() throws Exception {
-        final class ReplaceQualifiedNames extends TreePathScanner<Void, Void> {
+        final class ReplaceQualifiedNames extends ErrorAwareTreePathScanner<Void, Void> {
             private final WorkingCopy copy;
 
             public ReplaceQualifiedNames(WorkingCopy copy) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
index 84129aa..a26d341 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
@@ -20,7 +20,7 @@ package org.netbeans.api.java.source.gen;
 
 import java.io.File;
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.JavaSource;
 import static org.netbeans.api.java.source.JavaSource.*;
@@ -160,7 +160,7 @@ public class BlockTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("a")) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
index 6fe7aa3..03e8c93 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
@@ -21,8 +21,8 @@ package org.netbeans.api.java.source.gen;
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.*;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -1499,7 +1499,7 @@ public class CommentsTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         GeneratorUtilities gu = GeneratorUtilities.get(workingCopy);
@@ -1633,7 +1633,7 @@ public class CommentsTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitIf(IfTree node, Void p) {
                         node = GeneratorUtilities.get(workingCopy).importComments(node, cut);
                         workingCopy.rewrite(node.getThenStatement(), make.Block(Collections.singletonList(node.getThenStatement()), false));
@@ -1683,7 +1683,7 @@ public class CommentsTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitIf(IfTree node, Void p) {
                         node = GeneratorUtilities.get(workingCopy).importComments(node, cut);
                         workingCopy.rewrite(node.getThenStatement(), make.Block(Collections.singletonList(node.getThenStatement()), false));
@@ -1918,7 +1918,7 @@ public class CommentsTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker tm = wc.getTreeMaker();
                 final TreeUtilities tu = wc.getTreeUtilities();
-                wc.getCompilationUnit().accept(new TreeScanner<Void, Void>() {
+                wc.getCompilationUnit().accept(new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree mt, Void p) {
                         Tree nt = tm.setLabel(mt, mt.getName());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
index 5f63928..0b1079b 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -724,7 +724,7 @@ public class CompilationUnitTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy parameter) throws Exception {
                 parameter.toPhase(Phase.ELEMENTS_RESOLVED);
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         assertNotNull(parameter.getTrees().getElement(getCurrentPath()));
@@ -739,7 +739,7 @@ public class CompilationUnitTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy parameter) throws Exception {
                 parameter.toPhase(Phase.ELEMENTS_RESOLVED);
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         assertNotNull(parameter.getTrees().getElement(getCurrentPath()));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
index 7987161..e012614 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
@@ -21,7 +21,7 @@ package org.netbeans.api.java.source.gen;
 import com.sun.source.tree.*;
 import java.io.File;
 import static com.sun.source.tree.Tree.Kind.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.*;
 import java.io.IOException;
 import java.util.EnumSet;
@@ -287,7 +287,7 @@ public class ConstructorTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {
@@ -332,7 +332,7 @@ public class ConstructorTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
index f0101aa..d22b82c 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
@@ -45,7 +45,7 @@ import com.sun.source.tree.ExpressionTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.util.DocTreeScanner;
 import com.sun.source.util.DocTrees;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -119,7 +119,7 @@ public class DoctreeTest extends GeneratorTestBase {
             public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         ParamTree param = make.Param(false, make.DocIdentifier("test"), new LinkedList<DocTree>());
@@ -183,7 +183,7 @@ public class DoctreeTest extends GeneratorTestBase {
             public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         if("test".contentEquals(mt.getName())) {
@@ -245,7 +245,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -304,7 +304,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -365,7 +365,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -426,7 +426,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -488,7 +488,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -552,7 +552,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -615,7 +615,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -681,7 +681,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -750,7 +750,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -836,7 +836,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -899,7 +899,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -959,7 +959,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1022,7 +1022,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1082,7 +1082,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1141,7 +1141,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1200,7 +1200,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1259,7 +1259,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1318,7 +1318,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1381,7 +1381,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1444,7 +1444,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1507,7 +1507,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1584,7 +1584,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1647,7 +1647,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1710,7 +1710,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1772,7 +1772,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1834,7 +1834,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1892,7 +1892,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1950,7 +1950,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2018,7 +2018,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2080,7 +2080,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2139,7 +2139,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
 
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
@@ -2200,7 +2200,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2263,7 +2263,7 @@ public class DoctreeTest extends GeneratorTestBase {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
index 688c218..f8294f6 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
@@ -23,7 +23,7 @@ import java.util.List;
 import java.io.*;
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.LinkedList;
@@ -1100,7 +1100,7 @@ public class EnumTest extends GeneratorTestBase {
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         Element type = workingCopy.getTrees().getElement(new TreePath(getCurrentPath(), node.getType()));
@@ -1544,7 +1544,7 @@ public class EnumTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitClass(ClassTree node, Void p) {
                         if (node.getSimpleName().length() == 0) {
                             MethodTree method = make.Method(make.Modifiers(EnumSet.of(Modifier.PUBLIC)),

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
index 47587a5..443f5b3 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.*;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -768,7 +768,7 @@ public class ForLoopTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("i"))

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
index 66f18eb..9c3458e 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
@@ -35,7 +35,7 @@ import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -807,7 +807,7 @@ public class GuardedBlockTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitIdentifier(IdentifierTree node, Void p) {
                         if ("X".equals(node.getName().toString())) {
@@ -895,7 +895,7 @@ public class GuardedBlockTest extends GeneratorTestMDRCompat {
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
                 final TreeUtilities tu = workingCopy.getTreeUtilities();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                   @Override
                   public Void visitMethod(MethodTree mt, Void p) {
                      Tree nt = make.setLabel(mt, mt.getName());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
index d3b756a..47c3480 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
@@ -34,8 +34,8 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -93,7 +93,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLiteral(LiteralTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                         return super.visitLiteral(node, p);
@@ -133,7 +133,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("e")) {
                             workingCopy.rewrite(node, make.setLabel(node, "f"));
@@ -174,7 +174,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "e", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -213,7 +213,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -252,7 +252,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -291,7 +291,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.insertLambdaParameter(node, 0, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -330,7 +330,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -369,7 +369,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 1));
                         return super.visitLambdaExpression(node, p);
@@ -408,7 +408,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -447,7 +447,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         ReturnTree t = (ReturnTree) ((BlockTree) node.getBody()).getStatements().get(0);
                         workingCopy.rewrite(node, make.setLambdaBody(node, t.getExpression()));
@@ -489,7 +489,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -532,7 +532,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -571,7 +571,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), make.Identifier("Test"), node.getName(), node.getTypeArguments()));
                         return super.visitMemberReference(node, p);
@@ -610,7 +610,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.setLabel(node, "taragui2"));
                         return super.visitMemberReference(node, p);
@@ -649,7 +649,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), Collections.singletonList(make.Identifier("String"))));
                         return super.visitMemberReference(node, p);
@@ -688,7 +688,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), null));
                         return super.visitMemberReference(node, p);
@@ -729,7 +729,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par.getType(), make.Identifier("String"));
@@ -772,7 +772,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par, make.Variable(par.getModifiers(), par.getName(), null, par.getInitializer()));
@@ -895,7 +895,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         VariableTree vt = node.getParameters().get(0);
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(vt.getModifiers(), "f", vt.getType(), vt.getInitializer())));
@@ -935,7 +935,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void scan(Tree node, Void p) {
                         return super.scan(node, p);
@@ -986,7 +986,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {



[10/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java b/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
new file mode 100644
index 0000000..757bc57
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Kinds.Kind;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.CompletionFailure;
+import com.sun.tools.javac.code.Symbol.ModuleSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+import java.util.Set;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import org.netbeans.api.java.source.CompilationInfo;
+
+/** TODO
+ *
+ * @author lahvac
+ */
+public class ElementUtils {
+
+    public static TypeElement getTypeElementByBinaryName(CompilationInfo info, String name) {
+        return getTypeElementByBinaryName(CompilationInfoAccessor.getInstance().getJavacTask(info), name);
+    }
+
+    public static TypeElement getTypeElementByBinaryName(JavacTask task, String name) {
+        Set<? extends ModuleElement> allModules = task.getElements().getAllModuleElements();
+        
+        if (allModules.isEmpty()) {
+            Context ctx = ((JavacTaskImpl) task).getContext();
+            Symtab syms = Symtab.instance(ctx);
+            
+            return getTypeElementByBinaryName(task, syms.noModule, name);
+        }
+        
+        TypeElement result = null;
+        
+        for (ModuleElement me : allModules) {
+            TypeElement found = getTypeElementByBinaryName(task, me, name);
+            
+            if (found != null) {
+                if (result != null) return null;
+                result = found;
+            }
+        }
+        
+        return result;
+    }
+
+    public static TypeElement getTypeElementByBinaryName(CompilationInfo info, ModuleElement mod, String name) {
+        return getTypeElementByBinaryName(CompilationInfoAccessor.getInstance().getJavacTask(info), mod, name);
+    }
+
+    public static TypeElement getTypeElementByBinaryName(JavacTask task, ModuleElement mod, String name) {
+        Context ctx = ((JavacTaskImpl) task).getContext();
+        Names names = Names.instance(ctx);
+        Symtab syms = Symtab.instance(ctx);
+        final Name wrappedName = names.fromString(name);
+        ClassSymbol clazz = syms.enterClass((ModuleSymbol) mod, wrappedName);
+        
+        try {
+            clazz.complete();
+            
+            if (clazz.kind == Kind.TYP &&
+                clazz.flatName() == wrappedName) {
+                return clazz;
+            }
+        } catch (CompletionFailure cf) {
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java b/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
index 2f9cdcc..cc981dd 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
@@ -24,14 +24,15 @@ import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.ModuleTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.ClassFinder;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.api.JavacTaskImpl;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
@@ -39,6 +40,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -50,6 +52,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
+
 import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.TypeElement;
 import javax.tools.Diagnostic;
@@ -57,6 +60,7 @@ import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardLocation;
+
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
@@ -222,11 +226,11 @@ public final class JavaSourceUtilImpl extends org.netbeans.modules.java.preproce
                     r.getProfile(),
                     null,
                     null,
-                    null,
                     aptUtils,
-                    null);
+                    null,
+                    Arrays.asList(toCompile));
             final Iterable<? extends JavaFileObject> generated = jt.generate(
-                    StreamSupport.stream(jt.analyze(jt.enter(jt.parse(toCompile))).spliterator(), false)
+                    StreamSupport.stream(jt.analyze(jt.enter(jt.parse())).spliterator(), false)
                             .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
                             .map((e) -> (TypeElement)e)
                             .collect(Collectors.toList()));
@@ -285,7 +289,7 @@ public final class JavaSourceUtilImpl extends org.netbeans.modules.java.preproce
                     @CheckForNull
                     public ModuleTree parseModule() throws IOException {
                         cc.toPhase(JavaSource.Phase.PARSED);
-                        final TreeScanner<ModuleTree, Void> scanner = new TreeScanner<ModuleTree, Void>() {
+                        final ErrorAwareTreeScanner<ModuleTree, Void> scanner = new ErrorAwareTreeScanner<ModuleTree, Void>() {
                             @Override
                             public ModuleTree visitModule(ModuleTree node, Void p) {
                                 return node;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java b/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
index 1843522..f62b8f6 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
@@ -44,8 +44,12 @@ import com.sun.tools.javadoc.main.FieldDocImpl;
 import com.sun.tools.javadoc.main.MethodDocImpl;
 import com.sun.tools.javadoc.main.ModifierFilter;
 import com.sun.tools.javadoc.main.PackageDocImpl;
+import com.sun.tools.javadoc.main.ProgramElementDocImpl;
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.lang.model.element.Element;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.ClasspathInfo;
@@ -105,7 +109,7 @@ public class JavadocEnv extends DocEnv {
         }
         ClassDocImpl result = classMap.get(clazz);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
             return;
         }
         if (isAnnotationType((JCClassDecl)treePath.getLeaf())) {	// flags of clazz may not yet be set
@@ -129,7 +133,7 @@ public class JavadocEnv extends DocEnv {
     protected void makeFieldDoc(VarSymbol var, TreePath treePath) {
         FieldDocImpl result = fieldMap.get(var);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocField(this, var, treePath);
             fieldMap.put(var, result);
@@ -152,7 +156,7 @@ public class JavadocEnv extends DocEnv {
     protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) {
         MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocMethod(this, meth, treePath);
             methodMap.put(meth, result);
@@ -175,7 +179,7 @@ public class JavadocEnv extends DocEnv {
     protected void makeConstructorDoc(MethodSymbol meth, TreePath treePath) {
         ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocConstructor(this, meth, treePath);
             methodMap.put(meth, result);
@@ -198,12 +202,22 @@ public class JavadocEnv extends DocEnv {
     protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
         AnnotationTypeElementDocImpl result = (AnnotationTypeElementDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocAnnotationTypeElement(this, meth, treePath);
             methodMap.put(meth, result);
         }
     }
+    
+    private void setTreePath(ProgramElementDocImpl pe, TreePath treePath) {
+        try {
+            Method setTreePath = ProgramElementDocImpl.class.getDeclaredMethod("setTreePath", TreePath.class);
+            setTreePath.setAccessible(true);
+            setTreePath.invoke(pe, treePath);
+        } catch (Throwable ex) {
+            Logger.getLogger(JavadocEnv.class.getName()).log(Level.FINE, null, ex);
+        }
+    }
 
     /**
      * Return the AnnotationTypeElementDoc for a MethodSymbol.

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java b/java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java
deleted file mode 100644
index 0a4761e..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java
+++ /dev/null
@@ -1,779 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source;
-
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.PackageTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.TypeParameterTree;
-import com.sun.source.tree.VariableTree;
-import com.sun.source.util.JavacTask;
-import com.sun.source.util.TaskEvent;
-import com.sun.source.util.TaskListener;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.code.Kinds;
-import com.sun.tools.javac.code.Scope;
-import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.Types;
-import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.Enter;
-import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.main.JavaCompiler;
-import com.sun.tools.javac.model.LazyTreeLoader;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.tree.TreeScanner;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.CouplingAbort;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Log.DiscardDiagnosticHandler;
-import java.awt.EventQueue;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Pattern;
-import javax.swing.text.ChangedCharSetException;
-import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTML.Tag;
-import javax.swing.text.html.HTMLEditorKit;
-import javax.swing.text.html.HTMLEditorKit.ParserCallback;
-import javax.swing.text.html.parser.ParserDelegator;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-import org.netbeans.api.annotations.common.CheckForNull;
-import org.netbeans.api.annotations.common.NonNull;
-import org.netbeans.api.java.source.ClasspathInfo;
-import org.netbeans.api.java.source.ElementUtilities;
-import org.netbeans.api.java.source.SourceUtils;
-import org.netbeans.modules.java.source.indexing.JavaBinaryIndexer;
-import org.netbeans.modules.java.source.indexing.JavaIndex;
-import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
-import org.netbeans.modules.java.source.parsing.FileObjects;
-import org.netbeans.modules.java.source.parsing.OutputFileManager.InvalidSourcePath;
-import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
-import org.netbeans.modules.parsing.impl.indexing.IndexingUtils;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.URLMapper;
-import org.openide.util.Exceptions;
-
-/**
- *
- * @author Dusan Balek
- */
-public class TreeLoader extends LazyTreeLoader {
-
-    private static final String OPTION_OUTPUT_ROOT = "output-root"; //NOI18N
-    private static final Pattern ctor_summary_name = Pattern.compile("constructor[_.]summary"); //NOI18N
-    private static final Pattern method_summary_name = Pattern.compile("method[_.]summary"); //NOI18N
-    private static final Pattern field_detail_name = Pattern.compile("field[_.]detail"); //NOI18N
-    private static final Pattern ctor_detail_name = Pattern.compile("constructor[_.]detail"); //NOI18N
-    private static final Pattern method_detail_name = Pattern.compile("method[_.]detail"); //NOI18N
-    private static final ThreadLocal<Boolean> isTreeLoading = new ThreadLocal<Boolean>();
-
-    public static void preRegister(final Context context, final ClasspathInfo cpInfo, final boolean detached) {
-        context.put(lazyTreeLoaderKey, new TreeLoader(context, cpInfo, detached));
-    }
-    
-    public static TreeLoader instance (final Context ctx) {
-        final LazyTreeLoader tl = LazyTreeLoader.instance(ctx);
-        return (tl instanceof TreeLoader) ? (TreeLoader)tl : null;
-    }
-
-    public static boolean isTreeLoading() {
-        return isTreeLoading.get() == Boolean.TRUE;
-    }
-
-    private static final Logger LOGGER = Logger.getLogger(TreeLoader.class.getName());
-    private static final boolean ALWAYS_ALLOW_JDOC_ARG_NAMES = Boolean.getBoolean("java.source.args.from.http.jdoc");  //NOI18N
-    public  static boolean DISABLE_CONFINEMENT_TEST = false; //Only for tests!
-    public  static boolean DISABLE_ARTIFICAL_PARAMETER_NAMES = false; //Only for tests!
-
-    private Context context;
-    private ClasspathInfo cpInfo;
-    private Map<ClassSymbol, StringBuilder> couplingErrors;
-    private boolean partialReparse;
-    //@GuardedBy("this")
-    private Thread owner;
-    //@GuardedBy("this")
-    private int depth;
-    private final boolean checkContention;
-
-    private TreeLoader(Context context, ClasspathInfo cpInfo, boolean detached) {
-        this.context = context;
-        this.cpInfo = cpInfo;
-        this.checkContention = detached;
-    }
-    
-    @Override
-    public boolean loadTreeFor(final ClassSymbol clazz, boolean persist) {
-        boolean contended = !attachTo(Thread.currentThread());
-        try {
-            assert DISABLE_CONFINEMENT_TEST || JavaSourceAccessor.getINSTANCE().isJavaCompilerLocked() || !contended;
-            if (clazz != null) {
-                if (Enter.instance(context).getEnv(clazz) != null) {
-                    return true;
-                }
-                try {
-                    FileObject fo = SourceUtils.getFile(clazz, cpInfo);
-                    final JavacTaskImpl jti = (JavacTaskImpl) context.get(JavacTask.class);
-                    JavaCompiler jc = JavaCompiler.instance(context);
-                    if (fo != null && jti != null) {
-                        final Log log = Log.instance(context);
-                        log.nerrors = 0;
-                        final JavaFileManager jfm = context.get(JavaFileManager.class);
-                        final Symtab syms = Symtab.instance(context);
-                        JavaFileObject jfo = FileObjects.sourceFileObject(fo, null);
-                        Map<ClassSymbol, StringBuilder> oldCouplingErrors = couplingErrors;
-                        boolean oldSkipAPT = jc.skipAnnotationProcessing;
-                        try {
-                            couplingErrors = new HashMap<ClassSymbol, StringBuilder>();
-                            jc.skipAnnotationProcessing = true;
-                            Iterable<? extends CompilationUnitTree> cuts = jti.parse(jfo);
-                            for (CompilationUnitTree cut : cuts) {
-                                ((JCTree.JCCompilationUnit)cut).modle = clazz.packge().modle;
-                            }
-                            jti.analyze(jti.enter(cuts));
-                            if (persist && log.nerrors == 0) {
-                                final File classFolder = getClassFolder(jfm, clazz);
-                                if (classFolder != null) {
-                                    jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList(classFolder.getPath()).iterator()); //NOI18N
-                                    try {
-                                        if (jfm.hasLocation(StandardLocation.CLASS_OUTPUT) && canWrite(cpInfo)) {
-                                            Env<AttrContext> env = Enter.instance(context).getEnv(clazz);
-                                            HashMap<ClassSymbol, JCClassDecl> syms2trees;
-                                            if (env != null && pruneTree(env.tree, Symtab.instance(context), syms2trees = new HashMap<>())) {
-                                                isTreeLoading.set(Boolean.TRUE);
-                                                try {
-                                                    dumpSymFile(jti, clazz, syms2trees);
-                                                } finally {
-                                                    isTreeLoading.remove();
-                                                }
-                                            }
-                                        } else {
-                                            final JavaFileObject cfo = clazz.classfile;
-                                            final FileObject cFileObject = URLMapper.findFileObject(cfo.toUri().toURL());
-                                            FileObject root = null;
-                                            if (cFileObject != null) {
-                                                root = cFileObject;
-                                                for (String pathElement : ElementUtilities.getBinaryName(clazz).split("\\.")) {
-                                                    root = root.getParent();
-                                                }
-                                            }
-                                            if (root != null) {
-                                                final FileObject rootFin = root;
-                                                IndexingUtils.runAsScanWork(new Runnable() {
-                                                    @Override
-                                                    public void run() {
-                                                        try {
-                                                            JavaBinaryIndexer.preBuildArgs(rootFin,cFileObject);
-                                                        } catch (IOException ioe) {
-                                                            Exceptions.printStackTrace(ioe);
-                                                        }
-                                                    }
-                                                });
-                                            }
-                                        }
-                                    } finally {
-                                        jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList("").iterator()); //NOI18N
-                                    }
-                                }
-                            }
-                            return true;
-                        } finally {
-                            jc.skipAnnotationProcessing = oldSkipAPT;
-                            log.nerrors = 0;
-                            for (Map.Entry<ClassSymbol, StringBuilder> e : couplingErrors.entrySet()) {
-                                dumpCouplingAbort(new CouplingAbort(e.getKey(), null), e.getValue().toString());
-                            }
-                            couplingErrors = oldCouplingErrors;
-                        }
-                    }
-                } catch (IOException ex) {
-                    Exceptions.printStackTrace(ex);
-                }
-            }
-            return false;
-        } finally {
-            dettachFrom(Thread.currentThread());
-        }
-    }
-    
-    @Override
-    public boolean loadParamNames(ClassSymbol clazz) {
-        boolean contended = !attachTo(Thread.currentThread());
-        try {
-            assert DISABLE_CONFINEMENT_TEST || JavaSourceAccessor.getINSTANCE().isJavaCompilerLocked() || !contended;
-            if (clazz != null) {
-                JavadocHelper.TextStream page = JavadocHelper.getJavadoc(clazz, ALWAYS_ALLOW_JDOC_ARG_NAMES, null);
-                if (page != null && (!page.isRemote() || !EventQueue.isDispatchThread())) {
-                    if (getParamNamesFromJavadocText(page, clazz)) {
-                        return true;
-                    }
-                }
-                if (!DISABLE_ARTIFICAL_PARAMETER_NAMES) {
-                    fillArtificalParamNames(clazz);
-                    return true;
-                }
-            }
-
-            return false;
-        } finally {
-            dettachFrom(Thread.currentThread());
-        }
-    }
-
-    @Override
-    public void couplingError(ClassSymbol clazz, Tree t) {
-        if (this.partialReparse) {
-            super.couplingError(clazz, t);
-        }
-        if (clazz != null && couplingErrors != null) {
-            StringBuilder sb = couplingErrors.get(clazz);            
-            if (sb != null)
-                sb.append(getTreeInfo(t));
-            else
-                couplingErrors.put(clazz, getTreeInfo(t));
-        } else {
-            dumpCouplingAbort(new CouplingAbort(clazz, t), null);
-        }
-    }
-
-    @Override
-    public void updateContext(Context context) {
-        this.context = context;
-    }
-
-    public final void startPartialReparse () {
-        this.partialReparse = true;
-    }
-
-    public final void endPartialReparse () {
-        this.partialReparse = false;
-    }
-
-    public static boolean pruneTree(final JCTree tree, final Symtab syms, final HashMap<ClassSymbol, JCClassDecl> syms2trees) {
-        final AtomicBoolean ret = new AtomicBoolean(true);
-        new TreeScanner() {
-            @Override
-            public void visitMethodDef(JCMethodDecl tree) {
-                super.visitMethodDef(tree);
-                if (tree.sym == null || tree.type == null || tree.type == syms.unknownType)
-                    ret.set(false);
-                tree.body = null;
-            }
-            @Override
-            public void visitVarDef(JCVariableDecl tree) {
-                super.visitVarDef(tree);
-                if (tree.sym == null || tree.type == null || tree.type == syms.unknownType)
-                    ret.set(false);
-                tree.init = null;
-            }
-            @Override
-            public void visitClassDef(JCClassDecl tree) {
-                scan(tree.mods);
-                scan(tree.typarams);
-                scan(tree.extending);
-                scan(tree.implementing);
-                if (tree.defs != null) {
-                    List<JCTree> prev = null;
-                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                        scan(l.head);
-                        if (l.head.getTag() == JCTree.Tag.BLOCK) {
-                            if (prev != null)
-                                prev.tail = l.tail;
-                            else
-                                tree.defs = l.tail;
-                        }
-                        prev = l;
-                    }
-                }
-                if (tree.sym == null || tree.type == null || tree.type == syms.unknownType) {
-                    ret.set(false);
-                } else if (syms2trees != null) {
-                    syms2trees.put(tree.sym, tree);
-                }
-            }
-            @Override
-            public void visitModuleDef(JCTree.JCModuleDecl tree) {
-                ret.set(false);
-                super.visitModuleDef(tree);
-            }
-        }.scan(tree);
-        return ret.get();
-    }
-
-    public static void dumpSymFile(
-            @NonNull final JavaFileManager jfm,
-            @NonNull final JavacTaskImpl jti,
-            @NonNull final ClassSymbol clazz,
-            @NonNull final File classFolder,
-            @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
-        jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList(classFolder.getPath()).iterator()); //NOI18N
-        try {
-            dumpSymFile(jti, clazz, syms2trees);
-        } finally {
-            jfm.handleOption(OPTION_OUTPUT_ROOT, Collections.singletonList("").iterator()); //NOI18N
-        }
-    }
-
-    @CheckForNull
-    private static File getClassFolder(
-        JavaFileManager jfm,
-        ClassSymbol clazz) throws IOException {
-        String binaryName = null;
-        String surl = null;
-        if (clazz.classfile != null) {
-            binaryName = jfm.inferBinaryName(StandardLocation.PLATFORM_CLASS_PATH, clazz.classfile);
-            if (binaryName == null)
-                binaryName = jfm.inferBinaryName(StandardLocation.CLASS_PATH, clazz.classfile);
-            surl = clazz.classfile.toUri().toURL().toExternalForm();
-        } else if (clazz.sourcefile != null) {
-            binaryName = jfm.inferBinaryName(StandardLocation.SOURCE_PATH, clazz.sourcefile);
-            surl = clazz.sourcefile.toUri().toURL().toExternalForm();
-        }
-        if (binaryName == null || surl == null) {
-            return null;
-        }
-        int index = surl.lastIndexOf(FileObjects.convertPackage2Folder(binaryName));
-        if (index > 0) {
-            return JavaIndex.getClassFolder(new URL(surl.substring(0, index)));
-        } else {
-            LOGGER.log(
-               Level.INFO,
-               "Invalid binary name when writing sym file for class: {0}, source: {1}, binary name {2}",    // NOI18N
-               new Object[] {
-                   clazz.flatname,
-                   surl,
-                   binaryName
-               });
-            return null;
-        }
-    }
-
-    private static void dumpSymFile(
-            @NonNull final JavacTaskImpl jti,
-            @NonNull final ClassSymbol clazz,
-            @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
-        Log log = Log.instance(jti.getContext());
-        JavaCompiler compiler = JavaCompiler.instance(jti.getContext());
-        JavaFileObject prevLogTo = log.useSource(null);
-        DiscardDiagnosticHandler discardDiagnosticHandler = new Log.DiscardDiagnosticHandler(log);
-        final TaskListener listener = new TaskListener() {
-            @Override
-            public void started(TaskEvent e) {
-                if (e != null && e.getKind() == TaskEvent.Kind.GENERATE) {
-                    JCClassDecl tree = syms2trees.get((ClassSymbol)e.getTypeElement());
-                    if (tree != null)
-                        pruneTree(tree, Symtab.instance(jti.getContext()), null);
-                }
-            }
-            @Override
-            public void finished(TaskEvent e) {
-            }
-        };
-        boolean oldSkipAP = compiler.skipAnnotationProcessing;
-        try {
-            compiler.skipAnnotationProcessing = true;
-            jti.addTaskListener(listener);
-            jti.generate(Collections.singletonList(clazz));
-        } catch (InvalidSourcePath isp) {
-            LOGGER.log(Level.INFO, "InvalidSourcePath reported when writing sym file for class: {0}", clazz.flatname); // NOI18N
-        } finally {
-            jti.removeTaskListener(listener);
-            compiler.skipAnnotationProcessing = oldSkipAP;
-            log.popDiagnosticHandler(discardDiagnosticHandler);
-            log.useSource(prevLogTo);
-        }
-    }
-
-    private static final int MAX_DUMPS = Integer.getInteger("org.netbeans.modules.java.source.parsing.JavacParser.maxDumps", 255);
-    
-    public static void dumpCouplingAbort(CouplingAbort couplingAbort, String treeInfo) {
-        if (treeInfo == null)
-            treeInfo = getTreeInfo(couplingAbort.getTree()).toString();
-        String dumpDir = System.getProperty("netbeans.user") + "/var/log/"; //NOI18N
-        JavaFileObject classFile = couplingAbort.getClassFile();
-        String cfURI = classFile != null ? classFile.toUri().toASCIIString() : "<unknown>"; //NOI18N
-        JavaFileObject sourceFile = couplingAbort.getSourceFile();
-        String sfURI = sourceFile != null ? sourceFile.toUri().toASCIIString() : "<unknown>"; //NOI18N
-        String origName = classFile != null ? classFile.getName() : "unknown"; //NOI18N
-        File f = new File(dumpDir + origName + ".dump"); // NOI18N
-        boolean dumpSucceeded = false;
-        int i = 1;
-        while (i < MAX_DUMPS) {
-            if (!f.exists())
-                break;
-            f = new File(dumpDir + origName + '_' + i + ".dump"); // NOI18N
-            i++;
-        }
-        if (!f.exists()) {
-            try {
-                f.getParentFile().mkdirs();
-                OutputStream os = new FileOutputStream(f);
-                PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, "UTF-8")); // NOI18N
-                try {
-                    writer.println("Coupling error:"); //NOI18N
-                    writer.println(String.format("class file %s", cfURI)); //NOI18N
-                    writer.println(String.format("source file %s", sfURI)); //NOI18N
-                    writer.println("----- Source file content: ----------------------------------------"); // NOI18N
-                    if (sourceFile != null) {
-                        try {
-                            writer.println(sourceFile.getCharContent(true));
-                        } catch (UnsupportedOperationException uoe) {
-                            writer.println("<unknown>"); //NOI18N
-                        }
-                    } else {
-                        writer.println("<unknown>"); //NOI18N
-                    }
-                    writer.print("----- Trees: -------------------------------------------------------"); // NOI18N
-                    writer.println(treeInfo);
-                    writer.println("----- Stack trace: ---------------------------------------------"); // NOI18N
-                    couplingAbort.printStackTrace(writer);
-                } finally {
-                    writer.close();
-                    dumpSucceeded = true;
-                }
-            } catch (IOException ioe) {
-                LOGGER.log(Level.INFO, "Error when writing coupling error dump file!", ioe); // NOI18N
-            }
-        }
-        LOGGER.log(Level.WARNING, "Coupling error:\nclass file: {0}\nsource file: {1}{2}\n", new Object[] {cfURI, sfURI, treeInfo}); //NOI18N
-        if (!dumpSucceeded) {
-            LOGGER.log(Level.WARNING,
-                    "Dump could not be written. Either dump file could not " + // NOI18N
-                    "be created or all dump files were already used. Please " + // NOI18N
-                    "check that you have write permission to '" + dumpDir + "' and " + // NOI18N
-                    "clean all *.dump files in that directory."); // NOI18N
-        }
-    }
-
-    private static StringBuilder getTreeInfo(Tree t) {
-        StringBuilder info = new StringBuilder("\n"); //NOI18N
-        if (t != null) {
-            switch (t.getKind()) {
-                case ANNOTATION_TYPE:
-                case CLASS:
-                case ENUM:
-                case INTERFACE:
-                    info.append("CLASS: ").append(((ClassTree) t).getSimpleName().toString()); //NOI18N
-                    break;
-                case VARIABLE:
-                    info.append("VARIABLE: ").append(((VariableTree) t).getName().toString()); //NOI18N
-                    break;
-                case METHOD:
-                    info.append("METHOD: ").append(((MethodTree) t).getName().toString()); //NOI18N
-                    break;
-                case TYPE_PARAMETER:
-                    info.append("TYPE_PARAMETER: ").append(((TypeParameterTree) t).getName().toString()); //NOI18N
-                    break;
-                default:
-                    info.append("TREE: <unknown>"); //NOI18N
-                    break;
-            }
-        }
-        return info;
-    }
-
-    private boolean getParamNamesFromJavadocText(final JavadocHelper.TextStream page, final ClassSymbol clazz) {
-        HTMLEditorKit.Parser parser;
-        InputStream is = null;        
-        String charset = null;
-        for (;;) {
-            try{
-                is = page.openStream();
-                Reader reader = charset == null ? new InputStreamReader(is): new InputStreamReader(is, charset);
-                parser = new ParserDelegator();
-                parser.parse(reader, new ParserCallback() {                    
-
-                    private int state = 0; //init
-                    private String signature = null;
-                    private StringBuilder sb = null;
-
-                    @Override
-                    public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
-                        if (t == HTML.Tag.A) {
-                            String attrName = (String)a.getAttribute(HTML.Attribute.NAME);
-                            if (attrName != null && ctor_summary_name.matcher(attrName).matches()) {
-                                // we have found desired javadoc constructor info anchor
-                                state = 10; //ctos open
-                            } else if (attrName != null && method_summary_name.matcher(attrName).matches()) {
-                                // we have found desired javadoc method info anchor
-                                state = 20; //methods open
-                            } else if (attrName != null && field_detail_name.matcher(attrName).matches()) {
-                                state = 30; //end
-                            } else if (attrName != null && ctor_detail_name.matcher(attrName).matches()) {
-                                state = 30; //end
-                            } else if (attrName != null && method_detail_name.matcher(attrName).matches()) {
-                                state = 30; //end
-                            } else if (state == 12 || state == 22) {
-                                String attrHref = (String)a.getAttribute(HTML.Attribute.HREF);
-                                if (attrHref != null) {
-                                    int idx = attrHref.indexOf('#');
-                                    if (idx >= 0) {
-                                        signature = attrHref.substring(idx + 1);
-                                        sb = new StringBuilder();
-                                    }
-                                }
-                            }
-                        } else if (t == HTML.Tag.TABLE) {
-                            if (state == 10 || state == 20)
-                                state++;
-                        } else if (t == HTML.Tag.CODE) {
-                            if (state == 11 || state == 21)
-                                state++;
-                        } else if (t == HTML.Tag.DIV && a.containsAttribute(HTML.Attribute.CLASS, "block")) { //NOI18N
-                            if (state == 11 && signature != null && sb != null) {
-                                setParamNames(signature, sb.toString().trim(), true);
-                                signature = null;
-                                sb = null;
-                            } else if (state == 21 && signature != null && sb != null) {
-                                setParamNames(signature, sb.toString().trim(), false);
-                                signature = null;
-                                sb = null;
-                            }
-                        }
-                    }
-
-                    @Override
-                    public void handleEndTag(Tag t, int pos) {
-                        if (t == HTML.Tag.CODE) {
-                            if (state == 12 || state == 22)
-                                state--;
-                        } else if (t == HTML.Tag.TABLE) {
-                            if (state == 11 || state == 21)
-                                state--;
-                        }
-                    }
-
-                    @Override
-                    public void handleText(char[] data, int pos) {
-                        if (signature != null && sb != null && (state == 12 || state == 22))
-                            sb.append(data);
-                    }
-
-                    @Override
-                    public void handleSimpleTag(Tag t, MutableAttributeSet a, int pos) {
-                        if (t == HTML.Tag.BR) {
-                            if (state == 11 && signature != null && sb != null) {
-                                setParamNames(signature, sb.toString().trim(), true);
-                                signature = null;
-                                sb = null;
-                            } else if (state == 21 && signature != null && sb != null) {
-                                setParamNames(signature, sb.toString().trim(), false);
-                                signature = null;
-                                sb = null;
-                            }
-                        }
-                    }
-
-                    private void setParamNames(String signature, String names, boolean isCtor) {
-                        ArrayList<String> paramTypes = new ArrayList<String>();
-                        int idx = -1;
-                        for(int i = 0; i < signature.length(); i++) {
-                            switch(signature.charAt(i)) {
-                                case '-':
-                                case '(':
-                                case ')':
-                                case ',':
-                                    if (idx > -1 && idx < i - 1) {
-                                        String typeName = signature.substring(idx + 1, i).trim();
-                                        if (typeName.endsWith("...")) //NOI18N
-                                            typeName = typeName.substring(0, typeName.length() - 3) + "[]"; //NOI18N
-                                        paramTypes.add(typeName);
-                                    }
-                                    idx = i;
-                                    break;
-                            }
-                        }
-                        String methodName = null;
-                        ArrayList<String> paramNames = new ArrayList<String>();
-                        idx = -1;
-                        for(int i = 0; i < names.length(); i++) {
-                            switch(names.charAt(i)) {
-                                case '(':
-                                    methodName = names.substring(0, i);
-                                    break;
-                                case ')':
-                                case ',':
-                                    if (idx > -1) {
-                                        paramNames.add(names.substring(idx + 1, i));
-                                        idx = -1;
-                                    }
-                                    break;
-                                case 160: //&nbsp;
-                                    idx = i;
-                                    break;
-                            }
-                        }
-                        assert methodName != null : "Null methodName. Signature: [" + signature + "], Names: [" + names + "]";
-                        assert paramTypes.size() == paramNames.size() : "Inconsistent param types/names. Signature: [" + signature + "], Names: [" + names + "]";
-                        if (paramNames.size() > 0) {
-                            for (Symbol s : clazz.members().getSymbolsByName(isCtor
-                                    ? clazz.name.table.names.init
-                                    : clazz.name.table.fromString(methodName))) {
-                                if (s.kind == Kinds.Kind.MTH && s.owner == clazz) {
-                                    MethodSymbol sym = (MethodSymbol)s;
-                                    List<VarSymbol> params = sym.params;
-                                    if (checkParamTypes(params, paramTypes)) {
-                                        for (String name : paramNames) {
-                                            params.head.setName(clazz.name.table.fromString(name));
-                                            params = params.tail;
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-
-                    private boolean checkParamTypes(List<VarSymbol> params, ArrayList<String> paramTypes) {
-                        Types types = Types.instance(context);
-                        for (String typeName : paramTypes) {
-                            if (params.isEmpty())
-                                return false;
-                            Type type = params.head.type;
-                            if (type.isParameterized())
-                                type = types.erasure(type);
-                            if (!typeName.equals(type.toString()))
-                                return false;
-                            params = params.tail;
-                        }
-                        return params.isEmpty();
-                    }
-                }, charset != null);
-                return true;
-            } catch (ChangedCharSetException e) {
-                if (charset == null) {
-                    charset = JavadocHelper.getCharSet(e);
-                    //restart with valid charset
-                } else {
-                    e.printStackTrace();
-                    break;
-                }
-            } catch (InterruptedIOException x) {
-                //Http javadoc timeout
-                break;
-            } catch(IOException ioe){
-                ioe.printStackTrace();
-                break;
-            }finally{
-                parser = null;
-                if (is!=null) {
-                    try{
-                        is.close();
-                    }catch(IOException ioe){
-                        ioe.printStackTrace();
-                    }
-                }
-            }
-        }
-        return false;
-    }
-    
-    private void fillArtificalParamNames(final ClassSymbol clazz) {
-        for (Symbol s : clazz.getEnclosedElements()) {
-            if (s instanceof MethodSymbol) {
-                MethodSymbol ms = (MethodSymbol) s;
-
-                if (ms.getParameters().isEmpty()) {
-                    continue;
-                }
-                
-                Set<String> usedNames = new HashSet<String>();
-                
-                for (VarSymbol vs : ms.getParameters()) {
-                    String name = JavaSourceAccessor.getINSTANCE().generateReadableParameterName(vs.asType().toString(), usedNames);
-
-                    vs.setName(clazz.name.table.fromString(name));
-                }
-            }
-        }
-    }
-
-    private synchronized boolean attachTo(final Thread thread) {
-        assert thread != null;
-        if (!checkContention) {
-            return true;
-        } else if (this.owner == null) {
-            assert this.depth == 0;
-            this.owner = thread;
-            this.depth++;
-            return true;
-        } else if (this.owner == thread) {
-            assert this.depth > 0;
-            this.depth++;
-            return true;
-        } else {
-            assert this.depth > 0;
-            return false;
-        }
-    }
-
-    private synchronized boolean dettachFrom(final Thread thread) {
-        assert thread != null;
-        if (!checkContention) {
-            return true;
-        } else if (this.owner == thread) {
-            assert depth > 0;
-            this.depth--;
-            if (this.depth == 0) {
-                this.owner = null;
-            }
-            return true;
-        } else {
-            return false;
-        }
-    }
-    
-    private boolean canWrite(final ClasspathInfo cpInfo) {
-        final FileManagerTransaction fmTx = ClasspathInfoAccessor.getINSTANCE().getFileManagerTransaction(cpInfo);
-        assert fmTx != null;
-        return fmTx.canWrite();
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
index 103b8f3..318219c 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
@@ -40,9 +40,9 @@ import org.netbeans.modules.parsing.spi.indexing.Indexable;
  *
  * @author Jan Lahoda, Dusan Balek
  */
-abstract class CompileWorker {
+public abstract class CompileWorker {
 
-    abstract ParsingOutput compile(ParsingOutput previous, Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files);
+    protected abstract ParsingOutput compile(ParsingOutput previous, Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files);
 
     protected void computeFQNs(final Map<JavaFileObject, List<String>> file2FQNs, CompilationUnitTree cut, CompileTuple tuple) {
         String pack;
@@ -89,26 +89,26 @@ abstract class CompileWorker {
         lm.free(freeCaches);
     }
     
-    static class ModuleName {
-        String name;
-        boolean assigned;
+    protected static class ModuleName {
+        public String name;
+        public boolean assigned;
         
-        ModuleName(final String name) {
+        public ModuleName(final String name) {
             this.name = name;
         }
     }
 
-    static class ParsingOutput {
-        final boolean success;
-        final boolean lowMemory;
-        final String moduleName;
-        final Map<JavaFileObject, List<String>> file2FQNs;
-        final Set<ElementHandle<TypeElement>> addedTypes;
-        final Set<ElementHandle<ModuleElement>> addedModules;
-        final Set<File> createdFiles;
-        final Set<Indexable> finishedFiles;
-        final Set<ElementHandle<TypeElement>> modifiedTypes;
-        final Set<javax.tools.FileObject> aptGenerated;
+    public static class ParsingOutput {
+        public final boolean success;
+        public final boolean lowMemory;
+        public final String moduleName;
+        public final Map<JavaFileObject, List<String>> file2FQNs;
+        public final Set<ElementHandle<TypeElement>> addedTypes;
+        public final Set<ElementHandle<ModuleElement>> addedModules;
+        public final Set<File> createdFiles;
+        public final Set<Indexable> finishedFiles;
+        public final Set<ElementHandle<TypeElement>> modifiedTypes;
+        public final Set<javax.tools.FileObject> aptGenerated;
 
         private ParsingOutput(
                 final boolean success,
@@ -134,7 +134,7 @@ abstract class CompileWorker {
             this.aptGenerated = aptGenerated;
         }
 
-        static ParsingOutput success (
+        public static ParsingOutput success (
                 @NullAllowed final String moduleName,
                 final Map<JavaFileObject, List<String>> file2FQNs,
                 final Set<ElementHandle<TypeElement>> addedTypes,
@@ -148,7 +148,7 @@ abstract class CompileWorker {
                     modifiedTypes, aptGenerated);
         }
 
-        static ParsingOutput failure(
+        public static ParsingOutput failure(
                 @NullAllowed final String moduleName,
                 final Map<JavaFileObject, List<String>> file2FQNs,
                 final Set<ElementHandle<TypeElement>> addedTypes,
@@ -162,7 +162,7 @@ abstract class CompileWorker {
                     modifiedTypes, aptGenerated);
         }
 
-        static ParsingOutput lowMemory(
+        public static ParsingOutput lowMemory(
                 @NullAllowed final String moduleName,
                 final Map<JavaFileObject, List<String>> file2FQNs,
                 final Set<ElementHandle<TypeElement>> addedTypes,

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
index 4103f83..507bb55 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
@@ -31,7 +31,7 @@ import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
-class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
+public class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
 
     private static final Logger ERROR_LOG = Logger.getLogger(DiagnosticListenerImpl.class.getName() + "-errors");
     private final Map<URI, List<Diagnostic<? extends JavaFileObject>>> diagnostics = new HashMap<URI, List<Diagnostic<? extends JavaFileObject>>>();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
index 9348f2b..056ada4 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
@@ -18,7 +18,6 @@
  */
 package org.netbeans.modules.java.source.indexing;
 
-import com.sun.tools.javac.api.DuplicateClassChecker;
 import com.sun.tools.javac.code.Symbol;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -48,7 +47,7 @@ import org.openide.util.Exceptions;
  *
  * @author Dusan Balek
  */
-public final class FQN2Files implements DuplicateClassChecker {
+public final class FQN2Files {
 
     private static final Logger LOG = Logger.getLogger(FQN2Files.class.getName());
     private static final String FQN2FILES_FILE = "fqn2files.properties"; //NOI18N
@@ -134,7 +133,6 @@ public final class FQN2Files implements DuplicateClassChecker {
         }
     }
 
-    @Override
     public boolean check(final Name fqn, final JavaFileObject jfo) {
         String value = props.getProperty(fqn.toString());
         try {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
index b70a354..c5e796c 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -47,7 +48,7 @@ import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.platform.JavaPlatform;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.base.Module;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
@@ -191,11 +192,10 @@ public class JavaBinaryIndexer extends BinaryIndexer {
             false,
             false,
             null);
-        final JavacTaskImpl jt = JavacParser.createJavacTask(cpInfo, new DevNullDiagnosticListener(), null, null, null, null, null, null, null);
-        TreeLoader.preRegister(jt.getContext(), cpInfo, true);
+        final JavacTaskImpl jt = JavacParser.createJavacTask(cpInfo, new DevNullDiagnosticListener(), null, null, null, null, null, null, Collections.emptyList());
         //Force JTImpl.prepareCompiler to get JTImpl into Context
         jt.enter();
-        TypeElement jc = (TypeElement) ((JavacElements)jt.getElements()).getTypeElementByBinaryName(fqn);
+        TypeElement jc = ElementUtils.getTypeElementByBinaryName(jt, fqn);
         if (jc != null) {
             List<ExecutableElement> methods = ElementFilter.methodsIn(jt.getElements().getAllMembers(jc));
             for (ExecutableElement method : methods) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
index c84ad6f..1f61e68 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
@@ -113,6 +113,7 @@ import org.openide.util.Parameters;
 import org.openide.util.TopologicalSortException;
 import org.openide.util.BaseUtilities;
 import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
 
 /**
  *
@@ -120,13 +121,12 @@ import org.openide.util.Lookup;
  */
 public class JavaCustomIndexer extends CustomIndexer {
 
-            static       boolean NO_ONE_PASS_COMPILE_WORKER = Boolean.getBoolean(JavaCustomIndexer.class.getName() + ".no.one.pass.compile.worker");
+    public  static       boolean NO_ONE_PASS_COMPILE_WORKER = Boolean.getBoolean(JavaCustomIndexer.class.getName() + ".no.one.pass.compile.worker");
     private static final String DUMP_ON_LOW_MEM = System.getProperty(JavaCustomIndexer.class.getName() + ".dump.on.low.mem");    //NOI18N
     private static final String SOURCE_PATH = "sourcePath"; //NOI18N
     private static final String APT_SOURCE_OUTPUT = "apSrcOut"; //NOI18N
     private static final Pattern ANONYMOUS = Pattern.compile("\\$[0-9]"); //NOI18N
     private static final ClassPath EMPTY = ClassPathSupport.createClassPath(new URL[0]);
-    private static final int TRESHOLD = 500;
 
     @Override
     protected void index(final Iterable<? extends Indexable> files, final Context context) {
@@ -251,10 +251,7 @@ public class JavaCustomIndexer extends CustomIndexer {
                     int round = 0;
                     String moduleName = null;
                     while (round++ < 2) {
-                        CompileWorker[] WORKERS = {
-                            toCompileRound.size() < TRESHOLD ? new SuperOnePassCompileWorker() : new OnePassCompileWorker(),
-                            new MultiPassCompileWorker()
-                        };
+                        CompileWorker[] WORKERS = Lookup.getDefault().lookup(CompileWorkerProvider.class).getWorkers(toCompileRound);
                         for (CompileWorker w : WORKERS) {
                             compileResult = w.compile(compileResult, context, javaContext, toCompileRound);
                             if (compileResult == null || context.isCancelled()) {
@@ -675,7 +672,7 @@ public class JavaCustomIndexer extends CustomIndexer {
         return result;
     }
 
-    static void addAptGenerated(
+    public static void addAptGenerated(
             @NonNull final Context context,
             @NonNull JavaParsingContext javaContext,
             @NonNull final CompileTuple source,
@@ -686,14 +683,14 @@ public class JavaCustomIndexer extends CustomIndexer {
         }
     }
 
-    static void setErrors(Context context, CompileTuple active, DiagnosticListenerImpl errors) {
+    public static void setErrors(Context context, CompileTuple active, DiagnosticListenerImpl errors) {
         if (!active.virtual) {
             Iterable<Diagnostic<? extends JavaFileObject>> filteredErrorsList = Iterators.filter(errors.getDiagnostics(active.jfo), new FilterOutJDK7AndLaterWarnings());
             ErrorsCache.setErrors(context.getRootURI(), active.indexable, filteredErrorsList, active.aptGenerated ? ERROR_CONVERTOR_NO_BADGE : ERROR_CONVERTOR);
         }
     }
 
-    static void brokenPlatform(
+    public static void brokenPlatform(
             @NonNull final Context ctx,
             @NonNull final Iterable<? extends CompileTuple> files,
             @NullAllowed final Diagnostic<JavaFileObject> diagnostic) {
@@ -1391,4 +1388,20 @@ public class JavaCustomIndexer extends CustomIndexer {
             return vote;
         }
     }
+    
+    public static interface CompileWorkerProvider {
+        public CompileWorker[] getWorkers(List<CompileTuple> toCompile);
+    }
+
+    @ServiceProvider(service=CompileWorkerProvider.class, position=1000)
+    public static class DefaultCompileWorkerProvider implements CompileWorkerProvider {
+
+        @Override
+        public CompileWorker[] getWorkers(List<CompileTuple> toCompile) {
+            return new CompileWorker[] {
+                new VanillaCompileWorker()
+            };
+        }
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
index a89c32b..2058f77 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
@@ -60,7 +60,7 @@ public final class JavaIndex {
     public static final String NAME = "java"; //NOI18N
     public static final int VERSION = 15;
     public static final String ATTR_MODULE_NAME = "moduleName"; //NOI18N
-    static final Logger LOG = Logger.getLogger(JavaIndex.class.getName());
+    public static final Logger LOG = Logger.getLogger(JavaIndex.class.getName());
     private static final String CLASSES = "classes"; //NOI18N
     private static final String APT_SOURCES = "sources";    //NOI18N
     private static final String ATTR_FILE_NAME = "attributes.properties"; //NOI18N

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
index e56cfc1..d1dbb69 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
@@ -65,7 +65,7 @@ import org.openide.util.Pair;
 import org.openide.util.lookup.Lookups;
 
 //@NotThreadSafe
-final class JavaParsingContext {
+public final class JavaParsingContext {
 
     private final Context ctx;
     private final boolean rootNotNeeded;    
@@ -147,7 +147,7 @@ final class JavaParsingContext {
     }
     
     @CheckForNull
-    ClasspathInfo getClasspathInfo() {
+    public ClasspathInfo getClasspathInfo() {
         return cpInfo;
     }
     
@@ -157,13 +157,13 @@ final class JavaParsingContext {
     }
     
     @CheckForNull
-    String getSourceLevel() {
+    public String getSourceLevel() {
         final SourceLevelQuery.Result sl = initSourceLevel();
         return sl == null ? null : sl.getSourceLevel();
     }
 
     @CheckForNull
-    SourceLevelQuery.Profile getProfile() {
+    public SourceLevelQuery.Profile getProfile() {
         final SourceLevelQuery.Result sl = initSourceLevel();
         return sl == null ? null : sl.getProfile();
     }
@@ -195,7 +195,7 @@ final class JavaParsingContext {
     }
     
     @NonNull
-    CheckSums getCheckSums() throws IOException {
+    public CheckSums getCheckSums() throws IOException {
         if (checkSums == null) {
             try {
                 checkSums = CheckSums.forContext(ctx);
@@ -207,7 +207,7 @@ final class JavaParsingContext {
     }
     
     @NonNull
-    FQN2Files getFQNs() throws IOException {
+    public FQN2Files getFQNs() throws IOException {
         if (fqn2Files == null) {
             fqn2Files = FQN2Files.forRoot(ctx.getRootURI());
         }
@@ -223,7 +223,7 @@ final class JavaParsingContext {
     }
 
     @CheckForNull
-    String getModuleName() {
+    public String getModuleName() {
         try {
             return JavaIndex.getAttribute(ctx.getRootURI(), JavaIndex.ATTR_MODULE_NAME, null);
         } catch (IOException ioe) {
@@ -231,7 +231,7 @@ final class JavaParsingContext {
         }
     }
 
-    void analyze(
+    public void analyze(
             @NonNull final Iterable<? extends CompilationUnitTree> trees,
             @NonNull final JavacTaskImpl jt,
             @NonNull final CompileTuple active,


[13/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
Work in progress: an experiment on using javac from JDK for source code modeling.


Project: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/commit/ffc0de5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/tree/ffc0de5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-netbeans/diff/ffc0de5a

Branch: refs/heads/jdk-javac
Commit: ffc0de5a17b88ced95a0bd5b89175108701f86a0
Parents: 81234c9
Author: Jan Lahoda <jl...@netbeans.org>
Authored: Wed Oct 4 21:39:38 2017 +0200
Committer: Jan Lahoda <jl...@netbeans.org>
Committed: Wed Oct 4 21:39:38 2017 +0200

----------------------------------------------------------------------
 apisupport.project/nbproject/project.properties |   1 +
 apisupport.wizards/nbproject/project.properties |   1 +
 beans/nbproject/project.properties              |   3 +-
 .../addproperty/AddPropertyCodeGenerator.java   |   4 +-
 .../org/netbeans/core/startup/NbInstaller.java  |   2 +
 debugger.jpda.ant/nbproject/project.properties  |   1 +
 .../debugger/jpda/projects/ClassScanner.java    |   4 +-
 .../jpda/projects/EditorContextSupport.java     |   6 +-
 .../jpda/projects/ExpressionScanner.java        |   4 +-
 .../jpda/projects/MethodArgumentsScanner.java   |   4 +-
 .../jpda/projects/PreferredCCParser.java        |   8 +-
 .../debugger/jpda/projects/ScanLocalVars.java   |   4 +-
 .../jpda/projectsui/EditorContextImpl.java      |   6 +-
 debugger.jpda.visual/nbproject/project.xml      |   8 +
 .../debugger/jpda/EditorContextBridge.java      |  20 +-
 .../debugger/jpda/expr/CanInterpretVisitor.java |   4 +-
 .../debugger/jpda/expr/EvaluatorVisitor.java    |   4 +-
 .../api/debugger/jpda/JDIWrappersTest.java      |   4 +-
 form.binding/nbproject/project.properties       |   2 +
 form.j2ee/nbproject/project.properties          |   2 +
 form.nb/nbproject/project.properties            |   2 +
 form.refactoring/nbproject/project.properties   |   2 +
 .../RADComponentRenameRefactoringSupport.java   |   4 +-
 hibernate/nbproject/project.properties          |   3 +
 i18n/nbproject/project.properties               |   2 +
 ide/launcher/netbeans.conf                      |   2 +-
 .../nbproject/project.properties                |   3 +
 .../api/common/classpath/ModuleClassPaths.java  |   4 +-
 .../impl/DefaultProjectModulesModifier.java     |   8 +-
 .../common/impl/TemplateModuleDeclarator.java   |   4 +-
 .../modules/java/completion/BaseTask.java       |   5 +-
 .../java/completion/JavaCompletionTask.java     |   3 +-
 .../java/completion/CompletionTestBase.java     |   4 +-
 .../java/debug/TreeNavigatorProviderImpl.java   |   4 +-
 .../java/editor/base/imports/UnusedImports.java |   4 +-
 .../editor/base/javadoc/JavadocImports.java     |  14 +-
 .../MarkOccurrencesHighlighterBase.java         |   4 +-
 .../editor/base/semantic/UnusedImportsTest.java |   4 +-
 .../modules/editor/java/GoToSupport.java        |   6 +-
 .../editor/java/JavaCodeTemplateProcessor.java  |   3 +-
 .../netbeans/modules/editor/java/Utilities.java |   8 +-
 .../editor/codegen/EqualsHashCodeGenerator.java |   4 +-
 .../editor/fold/ResourceStringFoldProvider.java |   4 +-
 .../java/editor/imports/ClipboardHandler.java   |   4 +-
 .../java/editor/imports/JavaFixAllImports.java  |   4 +-
 .../editor/rename/InstantRenamePerformer.java   |   4 +-
 .../modules/editor/java/GoToSupportTest.java    |   5 +-
 .../modules/editor/java/UtilitiesTest.java      |   4 +-
 .../codegen/DelegateMethodGeneratorTest.java    |   4 +-
 .../editor/completion/CompletionTestBase.java   |   5 +-
 .../IsOverriddenAnnotationCreatorTest.java      |   7 +-
 .../declarative/DeclarativeHintsParser.java     |  13 +-
 .../hints/declarative/conditionapi/Matcher.java |   6 +-
 .../debugging/EvaluationSpanTaskTest.java       |   5 +-
 .../modules/java/hints/test/api/HintTest.java   |   2 -
 java.hints.ui/nbproject/project.properties      |   1 +
 .../modules/java/hints/ArithmeticUtilities.java |   4 +-
 .../modules/java/hints/AssignmentIssues.java    |   4 +-
 .../java/hints/ConvertAnonymousToInner.java     |   8 +-
 .../modules/java/hints/DoubleCheck.java         |   4 +-
 .../modules/java/hints/EqualsMethodHint.java    |   4 +-
 .../modules/java/hints/OrganizeImports.java     |   4 +-
 .../java/hints/WrongPackageSuggestion.java      |   4 +-
 .../java/hints/bugs/AssertWithSideEffects.java  |   2 +-
 .../java/hints/bugs/CloneAndCloneable.java      |   4 +-
 .../hints/bugs/ComparatorParameterNotUsed.java  |   4 +-
 .../java/hints/bugs/InfiniteRecursion.java      |   4 +-
 .../modules/java/hints/bugs/Regexp.java         |   4 +-
 .../netbeans/modules/java/hints/bugs/Tiny.java  |   6 +-
 .../java/hints/bugs/TryCatchFinally.java        |   4 +-
 .../java/hints/control/RemoveUnnecessary.java   |   4 +-
 .../hints/errors/AddParameterOrLocalFix.java    |   4 +-
 .../errors/ImplementAllAbstractMethods.java     |   4 +-
 .../errors/MagicSurroundWithTryCatchFix.java    |   4 +-
 .../hints/errors/MissingReturnStatement.java    |   2 +-
 .../errors/OrigSurroundWithTryCatchFix.java     |   4 +-
 .../modules/java/hints/errors/Utilities.java    |  18 +-
 .../finalize/FinalizeDoesNotCallSuper.java      |   4 +-
 .../modules/java/hints/introduce/Flow.java      |   4 +-
 .../java/hints/introduce/InstanceRefFinder.java |   4 +-
 .../java/hints/introduce/IntroduceHint.java     |  12 +-
 .../hints/introduce/ReferenceTransformer.java   |   4 +-
 .../java/hints/introduce/ScanStatement.java     |   4 +-
 .../modules/java/hints/jdk/ConvertToARM.java    |  12 +-
 .../hints/jdk/ConvertToLambdaConverter.java     |   4 +-
 .../jdk/ConvertToLambdaPreconditionChecker.java |   4 +-
 .../modules/java/hints/jdk/IteratorToFor.java   |   4 +-
 .../java/hints/jdk/UseSpecificCatch.java        |   4 +-
 .../jdk/mapreduce/PreconditionsChecker.java     |   8 +-
 .../java/hints/perf/ManualArrayCopy.java        |   4 +-
 .../java/hints/perf/ReplaceBufferByString.java  |   8 +-
 .../java/hints/perf/StringBuffer2Builder.java   |   4 +-
 .../hints/suggestions/ExpectedTypeResolver.java |   2 +-
 .../hints/suggestions/IfToSwitchSupport.java    |   8 +-
 .../modules/java/hints/suggestions/Lambda.java  |   6 +-
 .../modules/java/hints/suggestions/Tiny.java    |   4 +-
 .../modules/java/hints/threading/Tiny.java      |   4 +-
 .../java/hints/ConvertAnonymousToInnerTest.java |   4 +-
 .../hints/SuspiciousNamesCombinationTest.java   |   4 +-
 .../hints/infrastructure/TreeRuleTestBase.java  |   5 +-
 .../java/hints/introduce/RefFinderTest.java     |   2 +-
 java.j2semodule/nbproject/project.properties    |   1 +
 java.j2seprofiles/nbproject/project.properties  |   2 +
 .../java/j2seprofiles/ProfilesAnalyzer.java     |   4 +-
 java.j2seproject/nbproject/project.properties   |   1 +
 .../java/metrics/hints/ClassMetrics.java        |   2 +-
 .../hints/CyclomaticComplexityVisitor.java      |   4 +-
 .../java/metrics/hints/DependencyCollector.java |   4 +-
 .../java/metrics/hints/DepthVisitor.java        |   4 +-
 .../java/metrics/hints/ExpressionVisitor.java   |   4 +-
 .../java/metrics/hints/MethodMetrics.java       |   8 +-
 .../java/metrics/hints/NCLOCVisitor.java        |   4 +-
 .../java/metrics/hints/MethodMetricsTest.java   |   2 +-
 java.module.graph/nbproject/project.properties  |   1 +
 java.module.graph/nbproject/project.xml         |   8 +-
 .../java/navigation/BreadCrumbsNodeImpl.java    |   4 +-
 .../java/navigation/ElementScanningTask.java    |   4 +-
 .../java/navigation/actions/OpenAction.java     |   4 +-
 .../nbproject/project.properties                |   1 +
 java.source.base/manifest.mf                    |   1 +
 java.source.base/nbproject/project.properties   |   1 +
 java.source.base/nbproject/project.xml          |  10 +-
 .../api/java/source/AssignComments.java         |   4 +-
 .../api/java/source/CompilationInfo.java        |  25 +-
 .../netbeans/api/java/source/ElementHandle.java |   7 +-
 .../api/java/source/GeneratorUtilities.java     |  18 +-
 .../netbeans/api/java/source/SourceUtils.java   |  47 +-
 .../api/java/source/TranslateIdentifier.java    |   4 +-
 .../org/netbeans/api/java/source/TreeMaker.java |   6 +-
 .../api/java/source/TreePathHandle.java         |   4 +-
 .../netbeans/api/java/source/TreeUtilities.java | 270 ++++--
 .../netbeans/api/java/source/TypeUtilities.java | 108 ++-
 .../netbeans/api/java/source/WorkingCopy.java   |  21 +-
 .../support/CancellableTreePathScanner.java     |   4 +-
 .../source/support/CancellableTreeScanner.java  |   4 +-
 .../support/ErrorAwareTreePathScanner.java      |  35 +
 .../source/support/ErrorAwareTreeScanner.java   |  35 +
 .../java/source/CompilationInfoAccessor.java    |  65 ++
 .../modules/java/source/ElementUtils.java       |  94 +++
 .../modules/java/source/JavaSourceUtilImpl.java |  16 +-
 .../modules/java/source/JavadocEnv.java         |  24 +-
 .../modules/java/source/TreeLoader.java         | 779 ------------------
 .../java/source/indexing/CompileWorker.java     |  40 +-
 .../source/indexing/DiagnosticListenerImpl.java |   2 +-
 .../modules/java/source/indexing/FQN2Files.java |   4 +-
 .../java/source/indexing/JavaBinaryIndexer.java |   8 +-
 .../java/source/indexing/JavaCustomIndexer.java |  31 +-
 .../modules/java/source/indexing/JavaIndex.java |   2 +-
 .../source/indexing/JavaParsingContext.java     |  16 +-
 .../source/indexing/MultiPassCompileWorker.java | 518 ------------
 .../source/indexing/OnePassCompileWorker.java   | 370 ---------
 .../java/source/indexing/SourcePrefetcher.java  |   4 +-
 .../indexing/SuperOnePassCompileWorker.java     | 375 ---------
 .../source/indexing/VanillaCompileWorker.java   | 357 ++++++++
 .../java/source/matching/CopyFinder.java        |   4 +-
 .../parsing/AbstractSourceFileObject.java       |   5 +-
 .../source/parsing/BasicSourceFileObject.java   |   2 +-
 .../source/parsing/CompilationInfoImpl.java     |  25 +-
 .../source/parsing/FileManagerTransaction.java  |   6 +-
 .../source/parsing/FindAnonymousVisitor.java    |  85 --
 .../java/source/parsing/JavacFlowListener.java  |   4 +-
 .../java/source/parsing/JavacParser.java        | 295 ++-----
 .../java/source/parsing/ModuleOraculum.java     |  15 +-
 .../java/source/parsing/ParsingUtils.java       |  53 ++
 .../parsing/TranslatePositionsVisitor.java      | 122 ---
 .../java/source/pretty/ImportAnalysis2.java     |   6 +-
 .../modules/java/source/pretty/VeryPretty.java  |  16 +-
 .../modules/java/source/save/CasualDiff.java    |  28 +-
 .../modules/java/source/save/Reformatter.java   |  10 +-
 .../modules/java/source/save/Reindenter.java    |  39 +-
 .../usages/ClassNamesForFileOraculumImpl.java   |  75 --
 .../source/usages/SourceAnalyzerFactory.java    |   8 +-
 .../api/java/source/APIIsSelfContainedTest.java |   2 -
 .../api/java/source/CommentCollectorTest.java   |  22 +-
 .../api/java/source/ElementHandleTest.java      |  29 +-
 .../api/java/source/JavaSourceTest.java         |  64 +-
 .../api/java/source/SourceUtilsTestUtil2.java   |  23 +-
 .../api/java/source/TreeUtilitiesTest.java      |  20 +-
 .../api/java/source/TypeMirrorHandleTest.java   |   4 +-
 .../api/java/source/gen/AnnotationTest.java     |  12 +-
 .../api/java/source/gen/ArraysTest.java         |   4 +-
 .../netbeans/api/java/source/gen/BlockTest.java |   4 +-
 .../api/java/source/gen/CommentsTest.java       |  12 +-
 .../java/source/gen/CompilationUnitTest.java    |   6 +-
 .../api/java/source/gen/ConstructorTest.java    |   6 +-
 .../api/java/source/gen/DoctreeTest.java        |  72 +-
 .../netbeans/api/java/source/gen/EnumTest.java  |   6 +-
 .../api/java/source/gen/ForLoopTest.java        |   4 +-
 .../api/java/source/gen/GuardedBlockTest.java   |   6 +-
 .../api/java/source/gen/LambdaTest.java         |  46 +-
 .../api/java/source/gen/MemberAdditionTest.java |   6 +-
 .../api/java/source/gen/MethodBodyTest.java     |   8 +-
 .../api/java/source/gen/ModifiersTest.java      |   8 +-
 .../api/java/source/gen/MoveTreeTest.java       |   6 +-
 .../api/java/source/gen/MultiCatchTest.java     |  10 +-
 .../source/gen/RefactoringRegressionsTest.java  |   4 +-
 .../source/gen/RewriteOccasionalStatements.java |   6 +-
 .../api/java/source/gen/SwitchTest.java         |   6 +-
 .../netbeans/api/java/source/gen/TryTest.java   |   4 +-
 .../api/java/source/gen/TypeAnnotationTest.java |  10 +-
 .../modules/java/source/TreeLoaderTest.java     |  94 ---
 .../source/indexing/CompileWorkerTestBase.java  |  37 +-
 .../indexing/MultiPassCompileWorkerTest.java    |  42 -
 .../indexing/OnePassCompileWorkerTest.java      |  41 -
 .../indexing/SuperOnePassCompileWorkerTest.java |  41 -
 .../indexing/VanillaCompileWorkerTest.java      |  71 ++
 .../java/source/parsing/ClasspathInfoTest.java  |   9 +-
 .../java/source/parsing/JavacParserTest.java    |   6 +-
 .../java/source/parsing/ModuleOraculumTest.java |  21 -
 .../java/source/transform/Transformer.java      |   4 +-
 .../ClassNamesForFileOraculumImplTest.java      |  73 --
 .../java/source/usages/CompromiseSATest.java    |   4 +-
 .../java/source/usages/SourceAnalyzerTest.java  |  19 +-
 java.source.jdk9.req/build.xml                  |   5 +
 java.source.jdk9.req/manifest.mf                |   7 +
 .../nbproject/project.properties                |   3 +
 java.source.jdk9.req/nbproject/project.xml      |  11 +
 .../java/source/jdk9/req/Bundle.properties      |   1 +
 java.source.nbjavac/build.xml                   |   5 +
 java.source.nbjavac/manifest.mf                 |   6 +
 .../nbproject/project.properties                |   5 +
 java.source.nbjavac/nbproject/project.xml       | 160 ++++
 .../java/source/nbjavac/Bundle.properties       |   1 +
 .../indexing/ClassNamesForFileOraculumImpl.java |  75 ++
 .../indexing/MultiPassCompileWorker.java        | 525 ++++++++++++
 .../indexing/NBJavacCompileWorkerProvider.java  |  45 +
 .../nbjavac/indexing/OnePassCompileWorker.java  | 379 +++++++++
 .../indexing/SuperOnePassCompileWorker.java     | 381 +++++++++
 .../nbjavac/parsing/FindAnonymousVisitor.java   |  85 ++
 .../nbjavac/parsing/PartialReparserImpl.java    | 226 +++++
 .../nbjavac/parsing/PartialReparserService.java | 187 +++++
 .../nbjavac/parsing/SequentialParsingImpl.java  |  41 +
 .../parsing/TranslatePositionsVisitor.java      | 121 +++
 .../java/source/nbjavac/parsing/TreeLoader.java | 814 +++++++++++++++++++
 .../lib/nbjavac/services/CouplingTest.java      | 177 ++++
 .../ClassNamesForFileOraculumImplTest.java      |  73 ++
 .../indexing/MultiPassCompileWorkerTest.java    |  44 +
 .../indexing/NBJavacCompileWorkerTestBase.java  |  55 ++
 .../indexing/OnePassCompileWorkerTest.java      |  42 +
 .../indexing/SuperOnePassCompileWorkerTest.java |  42 +
 .../source/nbjavac/indexing/TreeLoaderTest.java |  94 +++
 .../source/queriesimpl/JavaOperationsImpl.java  |   8 +-
 .../org/netbeans/api/java/source/UiUtils.java   |   4 +-
 .../src/org/netbeans/modules/java/JavaNode.java |   4 +-
 .../modules/java/classfile/CodeGenerator.java   |  18 +-
 .../java/source/parsing/SourceFileObject.java   |   2 +-
 .../api/java/source/gen/LambdaTest.java         |  46 +-
 .../api/java/source/ui/ElementOpen.java         |   4 +-
 .../source/ui/AsyncJavaSymbolDescriptor.java    |   6 +-
 .../api/java/source/ui/ElementHeadersTest.java  |   4 +-
 java.testrunner.ui/nbproject/project.properties |   2 +
 java.testrunner/nbproject/project.properties    |   1 +
 javaee.injection/nbproject/project.properties   |   1 +
 .../javafx2/editor/FXMLCompletionTestBase.java  |   5 +-
 javafx2.project/nbproject/project.properties    |   1 +
 javawebstart/nbproject/project.properties       |   1 +
 jshell.support/nbproject/project.properties     |   1 +
 jshell.support/nbproject/project.xml            |   4 +-
 junit.ant.ui/nbproject/project.properties       |   1 +
 junit.ui/nbproject/project.properties           |   2 +
 .../modules/junit/ui/OpenTestAction.java        |   4 +-
 .../lib/nbjavac/services/NBClassReader.java     |  40 -
 .../lib/nbjavac/services/NBClassWriter.java     | 124 ---
 .../netbeans/lib/nbjavac/services/NBEnter.java  |   2 +-
 .../lib/nbjavac/services/NBJavadocEnter.java    |   2 +-
 .../nbjavac/services/NBJavadocMemberEnter.java  |  18 +-
 .../lib/nbjavac/services/NBParserFactory.java   |  94 +--
 .../lib/nbjavac/services/NBResolve.java         |   5 +-
 .../lib/nbjavac/services/PartialReparser.java   | 135 ---
 .../services/AnonymousNumberingTest.java        |  17 +-
 .../lib/nbjavac/services/CouplingTest.java      | 177 ----
 .../lib/nbjavac/services/NBClassWriterTest.java |   6 +-
 .../lib/nbjavac/services/Utilities.java         |  15 +-
 lib.nbjshell/nbproject/project.properties       |   1 +
 libs.javacapi/build.xml                         |  13 +
 libs.javacapi/manifest.mf                       |   2 +-
 libs.javacapi/nbproject/project.properties      |   4 +-
 libs.javacapi/nbproject/project.xml             |   6 +-
 libs.javacimpl/build.xml                        |   4 +-
 libs.javacimpl/manifest.mf                      |   4 +-
 libs.javacimpl/nbproject/project.properties     |   3 +-
 libs.javacimpl/nbproject/project.xml            |  11 +-
 .../nbproject/project.properties                |   1 +
 libs.jshell.compile/nbproject/project.xml       |   4 +-
 maven.apisupport/nbproject/project.properties   |   1 +
 maven.hints/nbproject/project.properties        |   1 +
 maven.junit.ui/nbproject/project.properties     |   1 +
 maven.refactoring/nbproject/project.properties  |   1 +
 .../UnitTestsCompilerOptionsQueryImpl.java      |   2 +-
 nbbuild/build.xml                               |  36 +-
 nbbuild/cluster.properties                      |   2 +
 nbbuild/external/binaries-list                  |   1 +
 nbbuild/templates/common.xml                    |   1 +
 nbbuild/templates/projectized.xml               |  40 +-
 .../src/org/netbeans/ModuleManager.java         |   2 +-
 .../netbeans/modules/parsing/api/Source.java    |   2 +
 .../nbimpl/javac/ElementUtilitiesEx.java        |   4 +-
 .../profiler/nbimpl/javac/JavacClassInfo.java   |   4 +-
 .../providers/JavaProfilerSourceImpl.java       |  10 +-
 .../nbproject/project.properties                |   1 +
 .../java/api/JavaRefactoringUtils.java          |   4 +-
 .../java/callhierarchy/CallHierarchyTasks.java  |   4 +-
 .../java/plugins/ChangeParametersPlugin.java    |   4 +-
 .../java/plugins/ChangeParamsTransformer.java   |  10 +-
 .../ExtractSuperclassRefactoringPlugin.java     |   2 +-
 .../java/plugins/FindUsagesVisitor.java         |   4 +-
 .../refactoring/java/plugins/FindVisitor.java   |   4 +-
 .../java/plugins/InlineMethodTransformer.java   |  14 +-
 .../java/plugins/InlineRefactoringPlugin.java   |   6 +-
 .../java/plugins/IntroduceParameterPlugin.java  |   6 +-
 .../plugins/InvertBooleanRefactoringPlugin.java |   4 +-
 .../java/plugins/LocalVarScanner.java           |   4 +-
 .../java/plugins/MoveClassTransformer.java      |   4 +-
 .../java/plugins/MoveMembersTransformer.java    |  12 +-
 .../java/plugins/PullUpTransformer.java         |   6 +-
 .../java/plugins/PushDownTransformer.java       |   4 +-
 .../java/plugins/RenameRefactoringPlugin.java   |   4 +-
 .../java/plugins/RenameTransformer.java         |   4 +-
 .../java/spi/RefactoringVisitor.java            |   4 +-
 .../java/ui/InstantRefactoringUIImpl.java       |   4 +-
 .../refactoring/java/ui/MoveMembersPanel.java   |   4 +-
 .../refactoring/java/ui/RenamePanel.java        |   4 +-
 .../java/test/RefactoringTestBase.java          |   2 +-
 .../nbproject/project.properties                |   1 +
 .../bindings/java/JavaSemanticTokenList.java    |   4 +-
 .../modules/java/hints/spiimpl/Hacks.java       |  18 +-
 .../modules/java/hints/spiimpl/Utilities.java   |  48 +-
 .../hints/spiimpl/pm/NFABasedBulkSearch.java    |   2 +-
 .../spi/java/hints/JavaFixUtilities.java        |   8 +-
 .../modules/java/hints/spiimpl/TestBase.java    |   5 +-
 .../java/hints/spiimpl/UtilitiesTest.java       |   4 +-
 .../spiimpl/pm/BulkSearchTestPerformer.java     |   5 +-
 .../spi/java/hints/matching/CopyFinderTest.java |   4 +-
 testng.ui/nbproject/project.properties          |   1 +
 .../nbproject/project.properties                |   1 +
 .../api/whitelist/support/WhiteListSupport.java |   4 +-
 xml.jaxb/nbproject/project.properties           |   1 +
 xml.tools.java/nbproject/project.properties     |   1 +
 338 files changed, 5949 insertions(+), 4323 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/apisupport.project/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/apisupport.project/nbproject/project.properties b/apisupport.project/nbproject/project.properties
index c947b08..73392e5 100644
--- a/apisupport.project/nbproject/project.properties
+++ b/apisupport.project/nbproject/project.properties
@@ -25,3 +25,4 @@ test-unit-sys-prop.java.awt.headless=true
 test.config.stableBTD.includes=**/*Test.class
 test.config.stableBTD.excludes=\
     **/ModuleOperationsTest.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/apisupport.wizards/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/apisupport.wizards/nbproject/project.properties b/apisupport.wizards/nbproject/project.properties
index c0af75f..315878a 100644
--- a/apisupport.wizards/nbproject/project.properties
+++ b/apisupport.wizards/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/beans/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/beans/nbproject/project.properties b/beans/nbproject/project.properties
index 915c8bf..ac47b14 100644
--- a/beans/nbproject/project.properties
+++ b/beans/nbproject/project.properties
@@ -17,7 +17,7 @@
 javac.compilerargs=-Xlint -Xlint:-serial
 javac.source=1.6
 spec.version.base=1.52.0
-
+cp.extra=${tools.jar}
 
 test.config.stable.includes=\
     **/PropertyGeneration.class
@@ -30,3 +30,4 @@ test.config.beaninfo.includes=\
 
 test.config.stable.include=\
     **/StableSuite.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
----------------------------------------------------------------------
diff --git a/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java b/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
index f630bd6..aaedaa9 100644
--- a/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
+++ b/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.Collections;
@@ -301,7 +301,7 @@ public class AddPropertyCodeGenerator implements CodeGenerator {
         return semicolon;
     }
 
-    private static final class ImportFQNsHack extends TreePathScanner<Void, Void> {
+    private static final class ImportFQNsHack extends ErrorAwareTreePathScanner<Void, Void> {
 
         private WorkingCopy wc;
         private int start;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/core.startup/src/org/netbeans/core/startup/NbInstaller.java
----------------------------------------------------------------------
diff --git a/core.startup/src/org/netbeans/core/startup/NbInstaller.java b/core.startup/src/org/netbeans/core/startup/NbInstaller.java
index 08b6372..b4c47cc 100644
--- a/core.startup/src/org/netbeans/core/startup/NbInstaller.java
+++ b/core.startup/src/org/netbeans/core/startup/NbInstaller.java
@@ -230,11 +230,13 @@ final class NbInstaller extends ModuleInstaller {
         List<Module.PackageExport> hiddenPackages = new ArrayList<Module.PackageExport>();
         List<Module> mWithDeps = new LinkedList<Module>();
         mWithDeps.add(m);
+        mWithDeps.addAll(mgr.getAttachedFragments(m));
         for (Dependency d : m.getDependencies()) {
             if (d.getType() == Dependency.TYPE_MODULE) {
                 Module _m = mgr.get((String) Util.parseCodeName(d.getName())[0]);
                 assert _m != null : d;
                 mWithDeps.add(_m);
+                mWithDeps.addAll(mgr.getAttachedFragments(_m));
             }
         }
         for (Module _m : mWithDeps) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.ant/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/debugger.jpda.ant/nbproject/project.properties b/debugger.jpda.ant/nbproject/project.properties
index 0d7b6d5..773b2c0 100644
--- a/debugger.jpda.ant/nbproject/project.properties
+++ b/debugger.jpda.ant/nbproject/project.properties
@@ -20,3 +20,4 @@ ant.jar=${ant.core.lib}
 javac.compilerargs=-Xlint:unchecked
 javac.source=1.6
 javadoc.arch=${basedir}/arch.xml
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
index 860b126..d7602bd 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
@@ -20,7 +20,7 @@
 package org.netbeans.modules.debugger.jpda.projects;
 
 import com.sun.source.tree.ClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.util.Elements;
@@ -30,7 +30,7 @@ import javax.lang.model.util.Elements;
  * 
  * @author martin
  */
-class ClassScanner extends TreePathScanner<TypeElement, Void> {
+class ClassScanner extends ErrorAwareTreePathScanner<TypeElement, Void> {
     
     private Trees trees;
     private Elements elements;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
index cd6e65b..d375d02 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -1428,8 +1428,8 @@ public final class EditorContextSupport {
     
     public static <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                                  final String url, final int line,
-                                                 final TreePathScanner<Boolean,D> canInterpret,
-                                                 final TreePathScanner<R,D> interpreter,
+                                                 final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                                 final ErrorAwareTreePathScanner<R,D> interpreter,
                                                  final D context, boolean staticContext,
                                                  final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                                  final SourcePathProvider sp) throws InvalidExpressionException {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
index 7bc80a9..1630aa2 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
@@ -52,7 +52,7 @@ import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -69,7 +69,7 @@ import javax.tools.Diagnostic;
  * 
  * @author Martin Entlicher
  */
-class ExpressionScanner extends TreeScanner<List<Tree>, ExpressionScanner.ExpressionsInfo> {
+class ExpressionScanner extends ErrorAwareTreeScanner<List<Tree>, ExpressionScanner.ExpressionsInfo> {
     
     private int lineNumber;
     private int statementStart;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
index 790026f..e39cf4c 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
@@ -29,7 +29,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.List;
 import javax.tools.Diagnostic;
 import org.netbeans.spi.debugger.jpda.EditorContext.MethodArgument;
@@ -39,7 +39,7 @@ import org.netbeans.spi.debugger.jpda.EditorContext.MethodArgument;
  * 
  * @author Martin Entlicher
  */
-class MethodArgumentsScanner extends TreeScanner<MethodArgument[], Object> {
+class MethodArgumentsScanner extends ErrorAwareTreeScanner<MethodArgument[], Object> {
     
     private int offset;
     private CompilationUnitTree tree;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
index 5838e93..4a59859 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
@@ -27,7 +27,7 @@ import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -404,8 +404,8 @@ class PreferredCCParser {
     @NbBundle.Messages("MSG_NoParseNoEval=Can not evaluate expression - parsing failed.")
     public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                           final String url, final int line,
-                                          final TreePathScanner<Boolean,D> canInterpret,
-                                          final TreePathScanner<R,D> interpreter,
+                                          final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                          final ErrorAwareTreePathScanner<R,D> interpreter,
                                           final D context, boolean staticContext,
                                           final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                           final SourcePathProvider sp) throws InvalidExpressionException {
@@ -654,7 +654,7 @@ class PreferredCCParser {
 
     private static boolean isErroneous(Tree tree) {
 
-        class TreeChecker extends TreePathScanner<Boolean,Void> {
+        class TreeChecker extends ErrorAwareTreePathScanner<Boolean,Void> {
 
             @Override
             public Boolean scan(Tree tree, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
index 4d51f0b..4e057d3 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
@@ -30,7 +30,7 @@ import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -51,7 +51,7 @@ import org.netbeans.api.java.source.CompilationInfo;
  *
  * @author sdedic, Martin Entlicher
  */
-final class ScanLocalVars extends TreePathScanner<Void, Void> {
+final class ScanLocalVars extends ErrorAwareTreePathScanner<Void, Void> {
     
     private static final Set<ElementKind> LOCAL_VARIABLES = EnumSet.of(ElementKind.EXCEPTION_PARAMETER,
                                                                        ElementKind.LOCAL_VARIABLE,

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
----------------------------------------------------------------------
diff --git a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java b/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
index 96aaaa2..b505e84 100644
--- a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
+++ b/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
@@ -19,7 +19,7 @@
 
 package org.netbeans.modules.debugger.jpda.projectsui;
 
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Color;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -817,8 +817,8 @@ public class EditorContextImpl extends EditorContext {
     }
     
     public <R,D> R interpretOrCompileCode(final Expression<Object> expression, String url, final int line,
-                                          final TreePathScanner<Boolean,D> canInterpret,
-                                          final TreePathScanner<R,D> interpreter,
+                                          final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                          final ErrorAwareTreePathScanner<R,D> interpreter,
                                           final D context, final boolean staticContext,
                                           final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                           final SourcePathProvider sp) throws InvalidExpressionException {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda.visual/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/debugger.jpda.visual/nbproject/project.xml b/debugger.jpda.visual/nbproject/project.xml
index d711277..8c5bea1 100644
--- a/debugger.jpda.visual/nbproject/project.xml
+++ b/debugger.jpda.visual/nbproject/project.xml
@@ -101,6 +101,14 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
+                    <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>2.30</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
                     <code-name-base>org.netbeans.modules.options.api</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
----------------------------------------------------------------------
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
index 10fcf65..d7e67a9 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.debugger.jpda;
 
 import com.sun.jdi.AbsentInformationException;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.net.MalformedURLException;
@@ -96,8 +96,8 @@ public class EditorContextBridge {
 
     public static <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                                  final String url, final int line,
-                                                 final TreePathScanner<Boolean,D> canInterpret,
-                                                 final TreePathScanner<R,D> interpreter,
+                                                 final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                                 final ErrorAwareTreePathScanner<R,D> interpreter,
                                                  final D context, final boolean staticContext,
                                                  final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                                  final SourcePathProvider sp) throws InvalidExpressionException {
@@ -105,7 +105,7 @@ public class EditorContextBridge {
             return (R) getContext ().getClass().getMethod(
                     "interpretOrCompileCode",
                     new Class[] { Expression.class, String.class, Integer.TYPE,
-                                  TreePathScanner.class, TreePathScanner.class,
+                                  ErrorAwareTreePathScanner.class, ErrorAwareTreePathScanner.class,
                                   Object.class, Boolean.TYPE, Function.class,
                                   SourcePathProvider.class }).
                         invoke(getContext(), new Object[] { expression, url, line,
@@ -347,8 +347,8 @@ public class EditorContextBridge {
 
         public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                               final String url, final int line,
-                                              final TreePathScanner<Boolean,D> canInterpret,
-                                              final TreePathScanner<R,D> interpreter,
+                                              final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                              final ErrorAwareTreePathScanner<R,D> interpreter,
                                               final D context, final boolean staticContext,
                                               final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                               final SourcePathProvider sp) throws InvalidExpressionException {
@@ -356,8 +356,8 @@ public class EditorContextBridge {
             try {
                 ret = (R) cp1.getClass().getMethod(
                     "interpretOrCompileCode",
-                    new Class[] { Expression.class, String.class, Integer.TYPE, TreePathScanner.class,
-                                  TreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
+                    new Class[] { Expression.class, String.class, Integer.TYPE, ErrorAwareTreePathScanner.class,
+                                  ErrorAwareTreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
                                   SourcePathProvider.class }).
                         invoke(cp1, new Object[] { expression, url, line, canInterpret, interpreter,
                                                    context, staticContext, compiledClassHandler, sp });
@@ -375,8 +375,8 @@ public class EditorContextBridge {
                 try {
                     ret = (R) cp2.getClass().getMethod(
                     "interpretOrCompileCode",
-                    new Class[] { Expression.class, String.class, Integer.TYPE, TreePathScanner.class,
-                                  TreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
+                    new Class[] { Expression.class, String.class, Integer.TYPE, ErrorAwareTreePathScanner.class,
+                                  ErrorAwareTreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
                                   SourcePathProvider.class }).
                         invoke(cp2, new Object[] { expression, url, line, canInterpret, interpreter,
                                                    context, staticContext, compiledClassHandler, sp });

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
----------------------------------------------------------------------
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
index 2bf465b..ee92d32 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
@@ -32,14 +32,14 @@ import com.sun.source.tree.RequiresTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UsesTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * Test of ability and suitability of an interpreter or compiler when evaluating.
  * 
  * @author Martin
  */
-class CanInterpretVisitor extends TreePathScanner<Boolean, EvaluationContext> {
+class CanInterpretVisitor extends ErrorAwareTreePathScanner<Boolean, EvaluationContext> {
 
     @Override
     public Boolean reduce(Boolean r1, Boolean r2) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
----------------------------------------------------------------------
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
index d6714dc..b0ea376 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
@@ -128,7 +128,7 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -184,7 +184,7 @@ import org.openide.util.NbBundle;
  * @author Martin Entlicher
  */
 @SuppressWarnings("ClassWithMultipleLoggers")
-public class EvaluatorVisitor extends TreePathScanner<Mirror, EvaluationContext> {
+public class EvaluatorVisitor extends ErrorAwareTreePathScanner<Mirror, EvaluationContext> {
 
     private static final Logger loggerMethod = Logger.getLogger("org.netbeans.modules.debugger.jpda.invokeMethod"); // NOI18N
     private static final Logger loggerValue = Logger.getLogger("org.netbeans.modules.debugger.jpda.getValue"); // NOI18N

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
----------------------------------------------------------------------
diff --git a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
index 2e33bae..5f4d6d3 100644
--- a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
+++ b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
@@ -30,7 +30,7 @@ import com.sun.source.tree.ParenthesizedTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeCastTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.List;
 import javax.lang.model.element.Element;
@@ -142,7 +142,7 @@ public class JDIWrappersTest extends NbTestCase {
         return successPtr[0];
     }
 
-    private static class JDICallsScanner extends TreeScanner<Void, Object> {
+    private static class JDICallsScanner extends ErrorAwareTreeScanner<Void, Object> {
 
         private Trees trees;
         private Types types;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/form.binding/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/form.binding/nbproject/project.properties b/form.binding/nbproject/project.properties
index 2b22049..212ca62 100644
--- a/form.binding/nbproject/project.properties
+++ b/form.binding/nbproject/project.properties
@@ -18,3 +18,5 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.18.0
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/form.j2ee/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/form.j2ee/nbproject/project.properties b/form.j2ee/nbproject/project.properties
index f4bc62b..a7a5f0d 100644
--- a/form.j2ee/nbproject/project.properties
+++ b/form.j2ee/nbproject/project.properties
@@ -18,3 +18,5 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.34.0
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/form.nb/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/form.nb/nbproject/project.properties b/form.nb/nbproject/project.properties
index 982a077..3ee4af6 100644
--- a/form.nb/nbproject/project.properties
+++ b/form.nb/nbproject/project.properties
@@ -18,3 +18,5 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.19.0
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/form.refactoring/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/form.refactoring/nbproject/project.properties b/form.refactoring/nbproject/project.properties
index 2b22049..212ca62 100644
--- a/form.refactoring/nbproject/project.properties
+++ b/form.refactoring/nbproject/project.properties
@@ -18,3 +18,5 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.18.0
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
----------------------------------------------------------------------
diff --git a/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java b/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
index 32543b3..3b591b2 100644
--- a/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
+++ b/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
@@ -22,7 +22,7 @@ import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -106,7 +106,7 @@ public class RADComponentRenameRefactoringSupport implements RenameSupport.Refac
     }
 
     private static class MemberVisitor
-            extends TreePathScanner<Void, Void>
+            extends ErrorAwareTreePathScanner<Void, Void>
             implements CancellableTask<CompilationController>{
         
         private CompilationInfo info;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/hibernate/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/hibernate/nbproject/project.properties b/hibernate/nbproject/project.properties
index 931ad2e..7df6ca7 100644
--- a/hibernate/nbproject/project.properties
+++ b/hibernate/nbproject/project.properties
@@ -37,3 +37,6 @@ test.config.stableBTD.excludes=\
     **/HibernateEnvironmentTest.class,\
     **/HibernateMappingCompletionManagerTest.class,\
     **/HibernateMappingHyperlinkProviderTest.class
+
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/i18n/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/i18n/nbproject/project.properties b/i18n/nbproject/project.properties
index def2291..740881b 100644
--- a/i18n/nbproject/project.properties
+++ b/i18n/nbproject/project.properties
@@ -20,3 +20,5 @@ javadoc.arch=${basedir}/arch.xml
 disable.qa-functional.tests=true
 
 test.config.stableBTD.includes=**/*Test.class
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/ide/launcher/netbeans.conf
----------------------------------------------------------------------
diff --git a/ide/launcher/netbeans.conf b/ide/launcher/netbeans.conf
index e8620d5..5efd53e 100644
--- a/ide/launcher/netbeans.conf
+++ b/ide/launcher/netbeans.conf
@@ -43,7 +43,7 @@ netbeans_default_cachedir="${DEFAULT_CACHEDIR_ROOT}/dev"
 # Concurrent Mark & Sweep garbage collector.
 # (see http://wiki.netbeans.org/FaqGCPauses)
 #
-netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dplugin.manager.check.updates=false -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED  -J--add-modules=java.activat
 ion,jdk.jshell -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"
+netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dplugin.manager.check.updates=false -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED  -J--add-modules=java.activat
 ion,jdk.jshell -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"
 
 # Default location of JDK:
 # (set by installer or commented out if launcher should decide)

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/j2ee.core.utilities/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/j2ee.core.utilities/nbproject/project.properties b/j2ee.core.utilities/nbproject/project.properties
index cf40f29..80f3dbc 100644
--- a/j2ee.core.utilities/nbproject/project.properties
+++ b/j2ee.core.utilities/nbproject/project.properties
@@ -23,3 +23,6 @@ is.autoload=true
 test.config.stableBTD.includes=**/*Test.class
 test.config.stableBTD.excludes=\
     **/SourceGroupsTest.class
+
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
----------------------------------------------------------------------
diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java b/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
index 31cb876..f3c5de9 100644
--- a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
+++ b/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.java.api.common.classpath;
 
 import com.sun.source.tree.ModuleTree;
 import com.sun.source.tree.RequiresTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
@@ -1249,7 +1249,7 @@ final class ModuleClassPaths {
                 }
                 if (moduleTree != null) {
                     //Add dependencies for non resolvable modules.
-                    moduleTree.accept(new TreeScanner<Void, Void>() {
+                    moduleTree.accept(new ErrorAwareTreeScanner<Void, Void>() {
                                 @Override
                                 public Void visitRequires(RequiresTree node, Void p) {
                                     final String moduleName = node.getModuleName().toString();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
----------------------------------------------------------------------
diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java b/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
index 395a1b9..c6537c8 100644
--- a/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
+++ b/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
@@ -22,7 +22,7 @@ import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.DirectiveTree;
 import com.sun.source.tree.ModuleTree;
 import com.sun.source.tree.RequiresTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -190,7 +190,7 @@ public class DefaultProjectModulesModifier implements ProjectModulesModifier {
             final Set<String> knownModules = new HashSet<>();
             final ModuleTree[] module = new ModuleTree[1];
             final RequiresTree[] lastRequires = new RequiresTree[1];
-            cu.accept(new TreeScanner<Void, Void>() {
+            cu.accept(new ErrorAwareTreeScanner<Void, Void>() {
                         @Override
                         public Void visitModule(ModuleTree m, Void p) {
                             module[0] = m;
@@ -259,7 +259,7 @@ public class DefaultProjectModulesModifier implements ProjectModulesModifier {
                     final Set<DirectiveTree> toRemove = new HashSet<>();
                     final ModuleTree[] module = new ModuleTree[1];
                     cu.accept(
-                            new TreeScanner<Void, Set<DirectiveTree>>() {
+                            new ErrorAwareTreeScanner<Void, Set<DirectiveTree>>() {
                                 @Override
                                 public Void visitModule(final ModuleTree node, Set<DirectiveTree> param) {
                                     module[0] = node;
@@ -339,7 +339,7 @@ public class DefaultProjectModulesModifier implements ProjectModulesModifier {
         return resultMap;
     }
     
-    private static class S extends TreeScanner implements Task<CompilationController> {
+    private static class S extends ErrorAwareTreeScanner implements Task<CompilationController> {
         final Map<URL, Collection<ClassPath>> resultMap;
         final ClassPath g;
         final Map<String, URL> modLocations;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
----------------------------------------------------------------------
diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java b/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
index 0b41f94..d9b57db 100644
--- a/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
+++ b/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
@@ -23,7 +23,7 @@ import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -200,7 +200,7 @@ public final class TemplateModuleDeclarator implements CreateFromTemplateDecorat
         }
     }
    
-    private static class Scanner extends TreePathScanner<Boolean, Boolean> {
+    private static class Scanner extends ErrorAwareTreePathScanner<Boolean, Boolean> {
         private final CompilationInfo info;
         private final Set<String> unresolved;
         

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
----------------------------------------------------------------------
diff --git a/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java b/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
index d3c84f1..7224a4d 100644
--- a/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
+++ b/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
@@ -37,7 +37,7 @@ import javax.tools.Diagnostic;
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import javax.lang.model.element.Name;
 
 import org.netbeans.api.java.lexer.JavaTokenId;
@@ -546,7 +546,7 @@ abstract class BaseTask extends UserTask {
         return sb.toString();
     }
 
-    private static class SourcePositionsImpl extends TreeScanner<Void, Tree> implements SourcePositions {
+    private static class SourcePositionsImpl extends ErrorAwareTreeScanner<Void, Tree> implements SourcePositions {
 
         private final Tree root;
         private final SourcePositions original;
@@ -593,6 +593,7 @@ abstract class BaseTask extends UserTask {
             }
             return null;
         }
+
     }
 
     private static boolean isCamelCasePrefix(String prefix) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
----------------------------------------------------------------------
diff --git a/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java b/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
index 3cef602..234e0b3 100644
--- a/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
+++ b/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
@@ -45,6 +45,7 @@ import org.netbeans.api.java.source.*;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.ClassIndex;
 import org.netbeans.api.java.source.ClassIndex.Symbols;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.java.source.support.ReferencesCount;
 import org.netbeans.api.lexer.TokenSequence;
 import org.netbeans.modules.parsing.api.Source;
@@ -5626,7 +5627,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
                             if (element == trees.getElement(new TreePath(path, instTree.getExpression()))) {
                                 TypeMirror tm = trees.getTypeMirror(new TreePath(path, instTree.getType()));
                                 if (tm != null && tu.isCastable(original, tm)) {
-                                    Boolean used = new TreePathScanner<Boolean, Element>() {
+                                    Boolean used = new ErrorAwareTreePathScanner<Boolean, Element>() {
                                         @Override
                                         public Boolean reduce(Boolean r1, Boolean r2) {
                                             return r1 == Boolean.TRUE ? r1 : r2;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
----------------------------------------------------------------------
diff --git a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java b/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
index 95e7b1a..20f56b5 100644
--- a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
+++ b/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
@@ -54,7 +54,7 @@ import org.netbeans.api.lexer.Language;
 import org.netbeans.core.startup.Main;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.netbeans.modules.java.source.usages.BinaryAnalyser;
 import org.netbeans.modules.java.source.usages.ClassIndexImpl;
@@ -83,7 +83,7 @@ public class CompletionTestBase extends NbTestCase {
     
     static {
         JavaCompletionTaskBasicTest.class.getClassLoader().setDefaultAssertionStatus(true);
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
 
     static final int FINISH_OUTTIME = 5 * 60 * 1000;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
----------------------------------------------------------------------
diff --git a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java b/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
index 5bf7390..06add7c 100644
--- a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
+++ b/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
@@ -23,7 +23,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.beans.PropertyChangeEvent;
@@ -228,7 +228,7 @@ public class TreeNavigatorProviderImpl implements NavigatorPanel {
             }
         }
 
-        class PathFinder extends TreePathScanner<Void,Void> {
+        class PathFinder extends ErrorAwareTreePathScanner<Void,Void> {
             private int pos;
             private SourcePositions sourcePositions;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
----------------------------------------------------------------------
diff --git a/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java b/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
index ecef052..6d5080d 100644
--- a/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
+++ b/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
@@ -28,7 +28,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -192,7 +192,7 @@ public class UnusedImports {
         private boolean parseErrorInImport(ImportTree imp) {
             if (isStar(imp)) return false;
             final StringBuilder fqn = new StringBuilder();
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override
                 public Void visitMemberSelect(MemberSelectTree node, Void p) {
                     super.visitMemberSelect(node, p);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
----------------------------------------------------------------------
diff --git a/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java b/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
index befb17b..c0b9c8c 100644
--- a/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
+++ b/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
@@ -36,7 +36,7 @@ import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -98,7 +98,7 @@ public final class JavadocImports {
         
         new DocTreePathScanner<Void, Void>() {
             @Override public Void visitReference(ReferenceTree node, Void p) {
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         Element el = trees.getElement(getCurrentPath());
                         
@@ -143,7 +143,7 @@ public final class JavadocImports {
         
         new DocTreePathScanner<Void, Void>() {
             @Override public Void visitReference(ReferenceTree node, Void p) {
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (toFind.equals(trees.getElement(getCurrentPath()))) {
                             handleUsage((int) trees.getSourcePositions().getStartPosition(javac.getCompilationUnit(), node));
@@ -269,7 +269,7 @@ public final class JavadocImports {
                     result[0] = trees.getElement(getCurrentPath());
                     return null;
                 }
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (   positions.getStartPosition(javac.getCompilationUnit(), node) <= offset
                             && positions.getEndPosition(javac.getCompilationUnit(), node) >= offset) {
@@ -350,7 +350,7 @@ public final class JavadocImports {
                     handleUsage(offset);
                     return null;
                 }
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (   positions.getStartPosition(javac.getCompilationUnit(), node) <= offset
                             && positions.getEndPosition(javac.getCompilationUnit(), node) >= offset) {
@@ -509,7 +509,7 @@ public final class JavadocImports {
         return javadoc;
     }
 
-    private static final class UnresolvedImportScanner extends TreePathScanner<Void, Void> {
+    private static final class UnresolvedImportScanner extends ErrorAwareTreePathScanner<Void, Void> {
         
         private final CompilationInfo javac;
         private Set<String> unresolved = new HashSet<String>();
@@ -544,7 +544,7 @@ public final class JavadocImports {
             
             new DocTreePathScanner<Void, Void>() {
                 @Override public Void visitReference(ReferenceTree node, Void p) {
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
                         @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                             Element el = trees.getElement(getCurrentPath());
                             

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
----------------------------------------------------------------------
diff --git a/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java b/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
index a331dcd..5951c5b 100644
--- a/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
+++ b/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
@@ -37,7 +37,7 @@ import com.sun.source.tree.TryTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -555,7 +555,7 @@ public abstract class MarkOccurrencesHighlighterBase extends JavaParserResultTas
         final List<int[]> result = new ArrayList<int[]>();
         if (labeledStatement.getLeaf().getKind() == Kind.LABELED_STATEMENT) {
             final Name label = ((LabeledStatementTree)labeledStatement.getLeaf()).getLabel();
-            new TreePathScanner <Void, Void>() {
+            new ErrorAwareTreePathScanner <Void, Void>() {
                 @Override
                 public Void visitBreak(BreakTree node, Void p) {
                     if (node.getLabel() != null && label.contentEquals(node.getLabel())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
----------------------------------------------------------------------
diff --git a/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java b/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
index cb779ce..76c498a 100644
--- a/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
+++ b/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
@@ -40,7 +40,7 @@ import org.netbeans.api.lexer.Language;
 import org.netbeans.core.startup.Main;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.editor.base.imports.UnusedImports;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
 import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
@@ -335,7 +335,7 @@ public class UnusedImportsTest extends NbTestCase {
 
     private void performUnusedImportsTest(String... golden) throws Exception {
         CompilationInfo ci = SourceUtilsTestUtil.getCompilationInfo(JavaSource.forFileObject(src.getFileObject("test/Main.java")), Phase.RESOLVED);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         Document doc = ci.getSnapshot().getSource().getDocument(true);
         doc.putProperty(Language.class, JavaTokenId.language());
         List<TreePathHandle> unused = UnusedImports.computeUnusedImports(ci);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java b/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
index 45f3543..b5e8915 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
@@ -38,7 +38,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
@@ -706,7 +706,7 @@ public class GoToSupport {
     private static TreePath getPath(final CompilationInfo info, Element el) {
         final Element toFind = info.getElementUtilities().isSynthetic(el) ? el.getEnclosingElement() : el;
 
-        class S extends TreePathScanner<Void, Void> {
+        class S extends ErrorAwareTreePathScanner<Void, Void> {
             private TreePath found;
             @Override
             public Void scan(Tree tree, Void p) {
@@ -760,7 +760,7 @@ public class GoToSupport {
         return search.found;
     }
 
-    private static final class FindSuperConstructorCall extends TreePathScanner<TreePath, Void> {
+    private static final class FindSuperConstructorCall extends ErrorAwareTreePathScanner<TreePath, Void> {
         
         @Override
         public TreePath visitMethodInvocation(MethodInvocationTree tree, Void v) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java b/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
index 86e15e3..90565c2 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
@@ -34,6 +34,7 @@ import javax.swing.text.Document;
 import javax.swing.text.JTextComponent;
 
 import org.netbeans.api.java.source.*;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.java.source.ui.ElementHeaders;
 import org.netbeans.api.progress.ProgressUtils;
 import org.netbeans.lib.editor.codetemplates.spi.*;
@@ -245,7 +246,7 @@ public class JavaCodeTemplateProcessor implements CodeTemplateProcessor {
                                 final SourcePositions sp = trees.getSourcePositions();
                                 final Map<VariableElement, VariableTree> vars = new HashMap<>();
                                 final LinkedList<VariableTree> varList = new LinkedList<>();
-                                TreePathScanner scanner = new TreePathScanner() {
+                                ErrorAwareTreePathScanner scanner = new ErrorAwareTreePathScanner() {
                                     private int cnt = 0;
                                     @Override
                                     public Object visitIdentifier(IdentifierTree node, Object p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/editor/java/Utilities.java b/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
index 65ea358..eadf642 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
@@ -39,9 +39,9 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 
 import java.awt.Color;
 import java.util.*;
@@ -467,7 +467,7 @@ public final class Utilities {
     public static Set<Element> getUsedElements(final CompilationInfo info) {
         final Set<Element> ret = new HashSet<>();
         final Trees trees = info.getTrees();
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -516,7 +516,7 @@ public final class Utilities {
     
     public static boolean containErrors(Tree tree) {
         final AtomicBoolean containsErrors = new AtomicBoolean();
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitErroneous(ErroneousTree node, Void p) {
                 containsErrors.set(true);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java b/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
index 75d8a12..a223d7a 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
@@ -36,7 +36,7 @@ import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.awt.Dialog;
 import java.beans.PropertyChangeEvent;
@@ -182,7 +182,7 @@ public class EqualsHashCodeGenerator implements CodeGenerator {
     /** Checks whether a field is used inside given methods.
      */
     private static boolean isUsed(CompilationInfo cc, VariableElement field, ExecutableElement... methods) {
-        class Used extends TreePathScanner<Void, VariableElement> {
+        class Used extends ErrorAwareTreePathScanner<Void, VariableElement> {
             boolean found;
             
             @Override

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java b/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
index 0421281..2b90599 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
@@ -28,7 +28,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -177,7 +177,7 @@ public class ResourceStringFoldProvider extends ParsingFoldSupport{
     }
     
 
-    private static class V extends TreePathScanner<Void, Void> {
+    private static class V extends ErrorAwareTreePathScanner<Void, Void> {
         private final FileObject                  anchor;
         private final Proc                         proc;
         private final CompilationInfo info;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java b/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
index 77be50f..a0555f4 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
@@ -29,7 +29,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Dialog;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.DataFlavor;
@@ -427,7 +427,7 @@ public class ClipboardHandler {
                         @Override public void run(final CompilationController parameter) throws Exception {
                             parameter.toPhase(JavaSource.Phase.RESOLVED);
 
-                            new TreePathScanner<Void, Void>() {
+                            new ErrorAwareTreePathScanner<Void, Void>() {
                                 private final Set<Element> declaredInCopiedText = new HashSet<>();
                                 @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                                     int s = (int) parameter.getTrees().getSourcePositions().getStartPosition(parameter.getCompilationUnit(), node);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
----------------------------------------------------------------------
diff --git a/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java b/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
index fe4e464..dc1e150 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.ImportTree;
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Dialog;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
@@ -172,7 +172,7 @@ public class JavaFixAllImports {
         return v.getImports();
     }
 
-    private static class ImportVisitor extends TreePathScanner {
+    private static class ImportVisitor extends ErrorAwareTreePathScanner {
         private CompilationInfo info;
         private String currentPackage;
         private List<TreePathHandle> imports;



[06/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
index 7e4a19c..98f5da1 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
@@ -28,7 +28,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -200,7 +200,7 @@ public class MemberAdditionTest extends NbTestCase {
         return i.topLevel;
     }
 
-    private static class TopLevelClassInfo extends TreeScanner<Void, Boolean> {
+    private static class TopLevelClassInfo extends ErrorAwareTreeScanner<Void, Boolean> {
 
         private ClassTree topLevel;
 
@@ -211,7 +211,7 @@ public class MemberAdditionTest extends NbTestCase {
 
     }
 
-    private static class FindVariableDeclaration extends TreeScanner<Void, Boolean> {
+    private static class FindVariableDeclaration extends ErrorAwareTreeScanner<Void, Boolean> {
 
         private VariableTree var;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
index 5b7d9b9..a614545 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
@@ -20,7 +20,7 @@ package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -320,7 +320,7 @@ public class MethodBodyTest extends GeneratorTestBase {
                 MethodTree method = (MethodTree) clazz.getMembers().get(1);
                 final NewClassTree[] nctFin = new NewClassTree[1];
                 
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override
                     public Object visitNewClass(NewClassTree node, Object p) {
                         nctFin[0] = node;
@@ -378,7 +378,7 @@ public class MethodBodyTest extends GeneratorTestBase {
                 MethodTree method = (MethodTree) clazz.getMembers().get(1);
                 final NewClassTree[] nctFin = new NewClassTree[1];
                 
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override
                     public Object visitNewClass(NewClassTree node, Object p) {
                         nctFin[0] = node;
@@ -652,7 +652,7 @@ public class MethodBodyTest extends GeneratorTestBase {
                 public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                     workingCopy.toPhase(Phase.RESOLVED);
                     TreeMaker treeMaker = workingCopy.getTreeMaker();
-                    new TreeScanner<Void, Void>() {
+                    new ErrorAwareTreeScanner<Void, Void>() {
                         @Override public Void visitReturn(ReturnTree node, Void p) {
                             ExpressionTree parsed = workingCopy.getTreeUtilities().parseExpression("str.toString().length()", new SourcePositions[1]);
                             workingCopy.rewrite(node.getExpression(), parsed);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
index 4de632d..3a20381 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
@@ -31,7 +31,7 @@ import com.sun.source.tree.NewArrayTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -1453,7 +1453,7 @@ public class ModifiersTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override
                     public Object visitVariable(VariableTree var, Object p) {
                         ModifiersTree mods = var.getModifiers();
@@ -1495,7 +1495,7 @@ public class ModifiersTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override public Object visitMethod(MethodTree node, Object p) {
                         if (node.getName().contentEquals("add")) {
                             workingCopy.rewrite(node.getModifiers(), make.addModifiersModifier(node.getModifiers(), Modifier.DEFAULT));
@@ -1537,7 +1537,7 @@ public class ModifiersTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override public Object visitMethod(MethodTree node, Object p) {
                         if (node.getName().contentEquals("find")) {
                             workingCopy.rewrite(node.getModifiers(), make.Modifiers(Collections.emptySet()));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
index 767d285..b3ea208 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
@@ -34,7 +34,7 @@ import com.sun.source.tree.TypeCastTree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -721,7 +721,7 @@ public class MoveTreeTest extends GeneratorTestBase {
                 VariableTree locVar = (VariableTree) method.getBody().getStatements().get(0);
                 TypeCastTree tct = (TypeCastTree) locVar.getInitializer();
                 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (node.getArguments().size() == 1) {
                             workingCopy.tag(node, "test");
@@ -784,7 +784,7 @@ public class MoveTreeTest extends GeneratorTestBase {
                 VariableTree locVar = (VariableTree) method.getBody().getStatements().get(0);
                 TreeMaker make = workingCopy.getTreeMaker();
                 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (node.getArguments().size() == 1) {
                             workingCopy.tag(node, "test");

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
index 010f3aa..d2e5cd1 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -137,7 +137,7 @@ public class MultiCatchTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("FileNotFoundException")) {
                             workingCopy.rewrite(node, make.Identifier("IOException"));
@@ -186,7 +186,7 @@ public class MultiCatchTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitUnionType(UnionTypeTree node, Void p) {
                         List<Tree> alternatives = new ArrayList<Tree>(node.getTypeAlternatives());
                         alternatives.add(make.Identifier("IOException"));
@@ -235,7 +235,7 @@ public class MultiCatchTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitUnionType(UnionTypeTree node, Void p) {
                         List<Tree> alternatives = new ArrayList<Tree>(node.getTypeAlternatives());
                         alternatives.add(0, make.Identifier("IOException"));
@@ -284,7 +284,7 @@ public class MultiCatchTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitUnionType(UnionTypeTree node, Void p) {
                         List<Tree> alternatives = new ArrayList<Tree>(node.getTypeAlternatives());
                         alternatives.add(1, make.Identifier("IOException"));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
index ba16891..ced9501 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
@@ -26,7 +26,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
@@ -562,7 +562,7 @@ public class RefactoringRegressionsTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMemberSelect(MemberSelectTree node, Void p) {
                         if ("E".equals(node.getIdentifier().toString())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
index e32f969..bccff6e 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
@@ -20,7 +20,7 @@ package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import org.junit.Test;
 import org.netbeans.api.java.source.*;
 import org.netbeans.junit.NbTestSuite;
@@ -451,7 +451,7 @@ public class RewriteOccasionalStatements extends GeneratorTestBase {
 */
 
 
-    class SimpleScanner extends TreeScanner<Void, Void> {
+    class SimpleScanner extends ErrorAwareTreeScanner<Void, Void> {
         private final WorkingCopy wc;
         protected GeneratorUtilities gu;
 
@@ -501,7 +501,7 @@ public class RewriteOccasionalStatements extends GeneratorTestBase {
                 workingCopy.toPhase(JavaSource.Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (node.getMethodSelect().getKind() == Kind.IDENTIFIER && ((IdentifierTree) node.getMethodSelect()).getName().contentEquals("a")) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
index 51eb1d6..64e3ef8 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.SwitchTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -170,7 +170,7 @@ public class SwitchTest extends GeneratorTestBase {
                     return;
                 }
                 final TreeMaker make = copy.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIf(IfTree node, Void p) {
                         List<StatementTree> statements = new ArrayList<StatementTree>(((BlockTree) node.getThenStatement()).getStatements());
                         statements.add(make.Break(null));
@@ -218,7 +218,7 @@ public class SwitchTest extends GeneratorTestBase {
                     return;
                 }
                 final TreeMaker make = copy.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitCase(CaseTree node, Void p) {
                         IfTree nue = make.If(make.Binary(Kind.EQUAL_TO, make.Identifier("p"), make.Literal(0)), make.Block(node.getStatements().subList(0, node.getStatements().size() - 1), false), null);
                         copy.rewrite(getCurrentPath().getParentPath().getLeaf(), nue);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
index 1e3567f..4ccdba1 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -506,7 +506,7 @@ public class TryTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED); //for RESOLVED, the 1.7 runtime (java.lang.AutoCloseable) would be needed
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("in")) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
index e15b47f..0476263 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -162,7 +162,7 @@ public class TypeAnnotationTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void p) {
                         workingCopy.rewrite(node, WorkingCopyTest.MakeAnnotatedTypeTemp(make, node.getUnderlyingType(), alter.alter(workingCopy, node.getAnnotations())));
                         return null;
@@ -210,7 +210,7 @@ public class TypeAnnotationTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void p) {
                         workingCopy.rewrite(node, WorkingCopyTest.MakeAnnotatedTypeTemp(make, make.Identifier("String"), node.getAnnotations()));
                         return null;
@@ -258,7 +258,7 @@ public class TypeAnnotationTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitParameterizedType(ParameterizedTypeTree node, Void p) {
                         List<AnnotationTree> annotations = Collections.singletonList(workingCopy.getTreeMaker().TypeAnnotation(make.Identifier("A"), Collections.<ExpressionTree>emptyList()));
                         Tree orig = node.getTypeArguments().get(0);
@@ -308,7 +308,7 @@ public class TypeAnnotationTest extends GeneratorTestBase {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void p) {
                         workingCopy.rewrite(node, node.getUnderlyingType());
                         return super.visitAnnotatedType(node, p);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java
deleted file mode 100644
index 08a68c6..0000000
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source;
-
-import java.io.File;
-import java.io.IOException;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import org.netbeans.api.java.source.CompilationController;
-import org.netbeans.api.java.source.JavaSource;
-import org.netbeans.api.java.source.JavaSource.Phase;
-import org.netbeans.api.java.source.SourceUtilsTestUtil;
-import org.netbeans.api.java.source.Task;
-import org.netbeans.api.java.source.TestUtilities;
-import org.netbeans.junit.NbTestCase;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-
-/**
- *
- * @author lahvac
- */
-public class TreeLoaderTest extends NbTestCase {
-
-    public TreeLoaderTest(String name) {
-        super(name);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        clearWorkDir();
-        SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
-    }
-
-    public void test171340() throws Exception {
-        prepareTest();
-
-        FileObject src1 = FileUtil.createData(sourceRoot, "test/Test1.java");
-        FileObject src2 = FileUtil.createData(sourceRoot, "test/Test2.java");
-
-        TestUtilities.copyStringToFile(src1,
-                "package test;\n" +
-                "public class Test1 {}");
-        TestUtilities.copyStringToFile(src2,
-                "package test;\n" +
-                "public class Test2 {" +
-                "    public void test() {}" +
-                "}");
-        SourceUtilsTestUtil.compileRecursively(sourceRoot);
-        JavaSource javaSource = JavaSource.forFileObject(src1);
-        javaSource.runUserActionTask(new Task<CompilationController>() {
-            public void run(CompilationController controller) throws IOException {
-                controller.toPhase(Phase.RESOLVED);
-                TypeElement typeElement = controller.getElements().getTypeElement("test.Test2");
-                assertNotNull(typeElement);
-                ExecutableElement method = (ExecutableElement) typeElement.getEnclosedElements().get(1);
-                assertNotNull(controller.getTrees().getPath(method));
-            }
-        }, true);
-    }
-
-    private FileObject sourceRoot;
-
-    private void prepareTest() throws Exception {
-        File work = getWorkDir();
-        FileObject workFO = FileUtil.toFileObject(work);
-
-        assertNotNull(workFO);
-
-        sourceRoot = workFO.createFolder("src");
-        FileObject buildRoot  = workFO.createFolder("build");
-        FileObject cache = workFO.createFolder("cache");
-
-        SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
index 0ca6a3c..26e657b 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
@@ -18,7 +18,6 @@
  */
 package org.netbeans.modules.java.source.indexing;
 
-import com.sun.source.tree.CompilationUnitTree;
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
@@ -26,15 +25,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
-import javax.tools.JavaFileObject;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
 import org.netbeans.api.java.source.TestUtilities;
@@ -52,6 +43,7 @@ import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
 import org.netbeans.modules.parsing.impl.indexing.SuspendSupport.SuspendStatusImpl;
 import org.netbeans.modules.parsing.impl.indexing.lucene.LuceneIndexFactory;
 import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.ErrorsCache;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -66,10 +58,10 @@ public abstract class CompileWorkerTestBase extends NbTestCase {
         super(name);
     }
     
-    public void test219787() throws Exception {
-        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test3.java", "package test; public class Test3")),
-                                           Arrays.asList(virtualCompileTuple("test/Test1.virtual", "package test; public class Test1 {}"),
-                                                         virtualCompileTuple("test/Test2.virtual", "package test; public class Test2 {}")));
+    public void testClassesLivingElsewhere() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test1.java", "package test; public class Test1 { Test2a t; } class Test1a { }"),
+                                                         compileTuple("test/Test2.java", "package test; public class Test2 { Test1a t; } class Test2a { }")),
+                                           Arrays.asList());
         
         assertFalse(result.lowMemory);
         assertTrue(result.success);
@@ -80,10 +72,15 @@ public abstract class CompileWorkerTestBase extends NbTestCase {
             createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
         }
         
-        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test3.sig")), createdFiles);
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test1.sig",
+                                                       "cache/s1/java/15/classes/test/Test1a.sig",
+                                                       "cache/s1/java/15/classes/test/Test2.sig",
+                                                       "cache/s1/java/15/classes/test/Test2a.sig")),
+                     createdFiles);
+        assertFalse(ErrorsCache.isInError(getRoot(), true));
     }
-    
-    private ParsingOutput runIndexing(List<CompileTuple> files, List<CompileTuple> virtualFiles) throws Exception {
+
+    protected ParsingOutput runIndexing(List<CompileTuple> files, List<CompileTuple> virtualFiles) throws Exception {
         TransactionContext txc = TransactionContext.beginStandardTransaction(src.toURL(), true, false, false);
         Factory f = new JavaCustomIndexer.Factory();
         Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(src.toURL()), src.toURL(), f.getIndexerName(), f.getIndexVersion(), LuceneIndexFactory.getDefault(), false, false, true, SPIAccessor.getInstance().createSuspendStatus(new SuspendStatusImpl() {
@@ -142,13 +139,17 @@ public abstract class CompileWorkerTestBase extends NbTestCase {
         return testFile;
     }
     
-    private CompileTuple virtualCompileTuple(String relativePath, String content) throws Exception {
+    protected CompileTuple virtualCompileTuple(String relativePath, String content) throws Exception {
         FileObject file = createSrcFile(relativePath, "");
         return new CompileTuple(FileObjects.sourceFileObject(file, src, null, content), SPIAccessor.getInstance().create(new FileObjectIndexable(src, relativePath)), true, true);
     }
     
-    private CompileTuple compileTuple(String relativePath, String content) throws Exception {
+    protected CompileTuple compileTuple(String relativePath, String content) throws Exception {
         FileObject file = createSrcFile(relativePath, content);
         return new CompileTuple(FileObjects.sourceFileObject(file, src), SPIAccessor.getInstance().create(new FileObjectIndexable(src, relativePath)), false, true);
     }
+    
+    protected FileObject getRoot() {
+        return src;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java
deleted file mode 100644
index d2632df..0000000
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.modules.java.source.indexing;
-
-import java.util.Collection;
-import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
-import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
-import org.netbeans.modules.parsing.spi.indexing.Context;
-
-/**
- *
- * @author lahvac
- */
-public class MultiPassCompileWorkerTest extends CompileWorkerTestBase {
-    
-    public MultiPassCompileWorkerTest(String name) {
-        super(name);
-    }
-
-    @Override
-    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) throws Exception {
-        JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER = true;
-        ParsingOutput fromOnePass = new OnePassCompileWorker().compile(null, context, javaContext, files);
-        return new MultiPassCompileWorker().compile(fromOnePass, context, javaContext, files);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java
deleted file mode 100644
index 0878533..0000000
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.modules.java.source.indexing;
-
-import java.util.Collection;
-import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
-import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
-import org.netbeans.modules.parsing.spi.indexing.Context;
-
-/**
- *
- * @author lahvac
- */
-public class OnePassCompileWorkerTest extends CompileWorkerTestBase {
-    
-    public OnePassCompileWorkerTest(String name) {
-        super(name);
-    }
-
-    @Override
-    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) {
-        return new OnePassCompileWorker().compile(null, context, javaContext, files);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java
deleted file mode 100644
index 5b0233b..0000000
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.modules.java.source.indexing;
-
-import java.util.Collection;
-import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
-import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
-import org.netbeans.modules.parsing.spi.indexing.Context;
-
-/**
- *
- * @author lahvac
- */
-public class SuperOnePassCompileWorkerTest extends CompileWorkerTestBase {
-    
-    public SuperOnePassCompileWorkerTest(String name) {
-        super(name);
-    }
-    
-    @Override
-    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) {
-        return new SuperOnePassCompileWorker().compile(null, context, javaContext, files);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
new file mode 100644
index 0000000..c2f5ee0
--- /dev/null
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.indexing;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+
+/**TODO: this test needs to run with vanilla javac
+ *
+ * @author lahvac
+ */
+public class VanillaCompileWorkerTest extends CompileWorkerTestBase {
+    
+    public VanillaCompileWorkerTest(String name) {
+        super(name);
+    }
+    
+    @Override
+    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) {
+        return new VanillaCompileWorker().compile(null, context, javaContext, files);
+    }
+    
+    public void testVanillaWorker() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test3.java", "package test; public class Test3"),
+                                                         compileTuple("test/Test4.java", "package test; public class Test4 { Undef undef; }")),
+                                           Arrays.asList(virtualCompileTuple("test/Test1.virtual", "package test; public class Test1 {}"),
+                                                         virtualCompileTuple("test/Test2.virtual", "package test; public class Test2 {}")));
+        
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+        
+        Set<String> createdFiles = new HashSet<String>();
+        
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+        
+        //TODO:
+//        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test3.sig")), createdFiles);
+        result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public class Test4 { void t() { Undef undef; } }")),
+                             Collections.emptyList());
+        
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
index e63a8ea..a9abe87 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
@@ -27,6 +27,7 @@ import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.net.URL;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Enumeration;
@@ -45,6 +46,7 @@ import junit.framework.*;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
 import org.netbeans.modules.java.source.TestUtil;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
@@ -108,9 +110,8 @@ public class ClasspathInfoTest extends NbTestCase {
     
     public void testGetTypeDeclaration() throws Exception {
         ClasspathInfo ci = ClasspathInfo.create( bootPath, classPath, null);
-        JavacTaskImpl jTask = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, null);
+        JavacTaskImpl jTask = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, Collections.emptyList());
         jTask.enter(); 
-	JavacElements elements = (JavacElements) jTask.getElements();
 	
         List<String> notFound = new LinkedList<String>();
         JarFile jf = new JarFile( rtJar );       
@@ -121,7 +122,7 @@ public class ClasspathInfoTest extends NbTestCase {
                 String typeName = jeName.substring( 0, jeName.length() - ".class".length() );
 
                 typeName = typeName.replace( "/", "." ); //.replace( "$", "." );
-                TypeElement te = elements.getTypeElementByBinaryName( typeName );
+                TypeElement te = ElementUtils.getTypeElementByBinaryName(jTask, typeName );
 //                assertNotNull( "Declaration for " + typeName + " should not be null.", td );
                 if ( te == null ) {
                     if (!typeName.endsWith("package-info")) {
@@ -148,7 +149,7 @@ public class ClasspathInfoTest extends NbTestCase {
                     // empty package
                     continue;
                 }
-                PackageElement pd = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, null).getElements().getPackageElement( packageName );
+                PackageElement pd = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, Collections.emptyList()).getElements().getPackageElement( packageName );
                 assertNotNull( "Declaration for " + packageName + " should not be null.", pd );
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
index a64483f..5d7d1d5 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
@@ -22,7 +22,7 @@ package org.netbeans.modules.java.source.parsing;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.code.Source;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -158,7 +158,7 @@ public class JavacParserTest extends NbTestCase {
                 
                 assertSame(tree.get(), parameter.getCompilationUnit());
                 
-                new TreePathScanner<Void, long[]>() {
+                new ErrorAwareTreePathScanner<Void, long[]>() {
 
                     @Override
                     public Void scan(Tree tree, long[] parentSpan) {
@@ -249,7 +249,7 @@ public class JavacParserTest extends NbTestCase {
                 
                 assertSame(tree.get(), parameter.getCompilationUnit());
                 
-                new TreePathScanner<Void, long[]>() {
+                new ErrorAwareTreePathScanner<Void, long[]>() {
 
                     @Override
                     public Void scan(Tree tree, long[] parentSpan) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
index b54a417..7ef958a 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
@@ -91,7 +91,6 @@ public class ModuleOraculumTest extends NbTestCase {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -112,7 +111,6 @@ public class ModuleOraculumTest extends NbTestCase {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -129,7 +127,6 @@ public class ModuleOraculumTest extends NbTestCase {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -147,7 +144,6 @@ public class ModuleOraculumTest extends NbTestCase {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -165,7 +161,6 @@ public class ModuleOraculumTest extends NbTestCase {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -185,7 +180,6 @@ public class ModuleOraculumTest extends NbTestCase {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -218,7 +212,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             List<? extends FileObject> roots = h.getRoots();
@@ -231,7 +224,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             roots = h.getRoots();
@@ -242,7 +234,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Next", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             roots = h.getRoots();
@@ -269,7 +260,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -282,7 +272,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -293,7 +282,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Next", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -320,7 +308,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -334,7 +321,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestUpdated", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -347,7 +333,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestUpdated", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -373,7 +358,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -387,7 +371,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertNull(Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -400,7 +383,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertNull(Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -427,7 +409,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertNull(Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -441,7 +422,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestNew", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -454,7 +434,6 @@ public class ModuleOraculumTest extends NbTestCase {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestNew", Options.instance(impl.getContext()).get("-Xmodule:"));    //NOI18N
             names = h.getModuleNames();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
index b0ac072..dff1d3d 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
@@ -22,7 +22,7 @@ package org.netbeans.modules.java.source.transform;
 import org.netbeans.modules.java.source.query.CommentHandler;
 import org.openide.util.NbBundle;
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.model.JavacTypes;
 import com.sun.tools.javac.util.Context;
 import java.util.List;
@@ -39,7 +39,7 @@ import org.netbeans.modules.java.source.builder.TreeFactory;
  * is done by a supplied ImmutableTreeTranslator implementation.  A new context
  * is set upon successful completion of this Transformer.
  */
-public abstract class Transformer<R, P> extends TreeScanner<R,P> {
+public abstract class Transformer<R, P> extends ErrorAwareTreeScanner<R,P> {
 
     CommentHandler commentHandler;
     public TreeMaker make;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java
deleted file mode 100644
index 43dadab..0000000
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.usages;
-
-import com.sun.tools.javac.api.ClassNamesForFileOraculum;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author lahvac
- */
-public class ClassNamesForFileOraculumImplTest {
-
-    public ClassNamesForFileOraculumImplTest() {
-    }
-
-    @Test
-    public void testDivineSources() {
-        TestJavaFileObject fo1 = new TestJavaFileObject();
-        TestJavaFileObject fo2 = new TestJavaFileObject();
-        Map<JavaFileObject, List<String>> fo2FQNs = new HashMap<JavaFileObject, List<String>>();
-
-        fo2FQNs.put(fo1, Arrays.asList("a.b.c.Class1"));
-        fo2FQNs.put(fo2, Arrays.asList("e.f.g"));
-
-        ClassNamesForFileOraculum oraculum = new ClassNamesForFileOraculumImpl(fo2FQNs);
-
-        assertArrayEquals(new JavaFileObject[] {fo1}, oraculum.divineSources("a.b.c"));
-        assertNull(oraculum.divineSources("a.b"));
-        assertNull(oraculum.divineSources("e.f.g"));
-    }
-
-    private static final class TestJavaFileObject extends SimpleJavaFileObject {
-
-        public TestJavaFileObject() {
-            super(URI.create("test://test.java"), Kind.SOURCE);
-        }
-
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
index 78cd883..f62766b 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
@@ -50,6 +50,7 @@ import org.netbeans.modules.classfile.ClassFile;
 import org.netbeans.modules.classfile.ClassName;
 import org.netbeans.modules.classfile.Method;
 import org.netbeans.modules.classfile.Variable;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.usages.ClassIndexImpl.UsageType;
 
 /**
@@ -223,8 +224,7 @@ public class CompromiseSATest extends NbTestCase {
         InputStream in = this.prepareData (testClassName);
 	try {
 	    JavacTask jt = prepareJavac ();
-	    JavacElements elements = (JavacElements) jt.getElements();
-	    TypeElement be = elements.getTypeElementByBinaryName(testClassName);
+	    TypeElement be = ElementUtils.getTypeElementByBinaryName(jt, testClassName);
             assertNotNull ("Javac Error", be);
 	    String className = ClassFileUtil.encodeClassName(be);
 	    ClassFile cf = new ClassFile (in, true);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
----------------------------------------------------------------------
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
index ca9d1d8..a39cad7 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
@@ -23,6 +23,7 @@ import com.sun.source.tree.CompilationUnitTree;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import java.io.File;
 import java.util.ArrayDeque;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.List;
@@ -106,14 +107,14 @@ public class SourceAnalyzerTest extends NbTestCase {
                 true,
                 false,
                 true);
+            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                 cpInfo,
                 diag,
                 SourceLevelQuery.getSourceLevel(src),  //NOI18N
                 SourceLevelQuery.Profile.DEFAULT,
-                null, null, null, null, null);
-            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
-            final Iterable<? extends CompilationUnitTree> trees = jt.parse(jfo);
+                null, null, null, null, Arrays.asList(jfo));
+            final Iterable<? extends CompilationUnitTree> trees = jt.parse();
             jt.enter();
             jt.analyze();
             final SourceAnalyzerFactory.SimpleAnalyzer sa = SourceAnalyzerFactory.createSimpleAnalyzer();
@@ -159,14 +160,14 @@ public class SourceAnalyzerTest extends NbTestCase {
                 true,
                 false,
                 true);
+            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                 cpInfo,
                 diag,
                 SourceLevelQuery.getSourceLevel(src),  //NOI18N
                 SourceLevelQuery.Profile.DEFAULT,
-                null, null, null, null, null);
-            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
-            final Iterable<? extends CompilationUnitTree> trees = jt.parse(jfo);
+                null, null, null, null, Arrays.asList(jfo));
+            final Iterable<? extends CompilationUnitTree> trees = jt.parse();
             jt.enter();
             jt.analyze();
             final SourceAnalyzerFactory.SimpleAnalyzer sa = SourceAnalyzerFactory.createSimpleAnalyzer();
@@ -208,14 +209,14 @@ public class SourceAnalyzerTest extends NbTestCase {
                 true,
                 false,
                 true);
+            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                 cpInfo,
                 diag,
                 SourceLevelQuery.getSourceLevel(src),  //NOI18N
                 SourceLevelQuery.Profile.DEFAULT,
-                null, null, null, null, null);
-            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
-            final Iterable<? extends CompilationUnitTree> trees = jt.parse(jfo);
+                null, null, null, null, Arrays.asList(jfo));
+            final Iterable<? extends CompilationUnitTree> trees = jt.parse();
             jt.enter();
             jt.analyze();
             final SourceAnalyzerFactory.SimpleAnalyzer sa = SourceAnalyzerFactory.createSimpleAnalyzer();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.jdk9.req/build.xml
----------------------------------------------------------------------
diff --git a/java.source.jdk9.req/build.xml b/java.source.jdk9.req/build.xml
new file mode 100644
index 0000000..3ee732c
--- /dev/null
+++ b/java.source.jdk9.req/build.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." default="netbeans" name="java.source.jdk9.req">
+    <description>Builds, tests, and runs the project org.netbeans.modules.java.source.jdk9.req</description>
+    <import file="../nbbuild/templates/projectized.xml"/>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.jdk9.req/manifest.mf
----------------------------------------------------------------------
diff --git a/java.source.jdk9.req/manifest.mf b/java.source.jdk9.req/manifest.mf
new file mode 100644
index 0000000..9ab42f9
--- /dev/null
+++ b/java.source.jdk9.req/manifest.mf
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+AutoUpdate-Show-In-Client: false
+OpenIDE-Module: org.netbeans.modules.java.source.jdk9.req
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/source/jdk9/req/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+OpenIDE-Module-Package-Dependencies: [com.sun.source.tree.ModuleTree]
+OpenIDE-Module-Provides: org.netbeans.modules.javac

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.jdk9.req/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.source.jdk9.req/nbproject/project.properties b/java.source.jdk9.req/nbproject/project.properties
new file mode 100644
index 0000000..ff160e0
--- /dev/null
+++ b/java.source.jdk9.req/nbproject/project.properties
@@ -0,0 +1,3 @@
+is.eager=true
+javac.source=1.7
+javac.compilerargs=-Xlint -Xlint:-serial

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.jdk9.req/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/java.source.jdk9.req/nbproject/project.xml b/java.source.jdk9.req/nbproject/project.xml
new file mode 100644
index 0000000..43d5e53
--- /dev/null
+++ b/java.source.jdk9.req/nbproject/project.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.apisupport.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+            <code-name-base>org.netbeans.modules.java.source.jdk9.req</code-name-base>
+            <module-dependencies/>
+            <public-packages/>
+        </data>
+    </configuration>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.jdk9.req/src/org/netbeans/modules/java/source/jdk9/req/Bundle.properties
----------------------------------------------------------------------
diff --git a/java.source.jdk9.req/src/org/netbeans/modules/java/source/jdk9/req/Bundle.properties b/java.source.jdk9.req/src/org/netbeans/modules/java/source/jdk9/req/Bundle.properties
new file mode 100644
index 0000000..3991227
--- /dev/null
+++ b/java.source.jdk9.req/src/org/netbeans/modules/java/source/jdk9/req/Bundle.properties
@@ -0,0 +1 @@
+OpenIDE-Module-Name=Java Source JDK 9 Required

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/build.xml
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/build.xml b/java.source.nbjavac/build.xml
new file mode 100644
index 0000000..28b8f66
--- /dev/null
+++ b/java.source.nbjavac/build.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." default="netbeans" name="java.source.nbjavac">
+    <description>Builds, tests, and runs the project org.netbeans.modules.java.source.nbjavac</description>
+    <import file="../nbbuild/templates/projectized.xml"/>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/manifest.mf
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/manifest.mf b/java.source.nbjavac/manifest.mf
new file mode 100644
index 0000000..0abeede
--- /dev/null
+++ b/java.source.nbjavac/manifest.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+AutoUpdate-Show-In-Client: false
+OpenIDE-Module: org.netbeans.modules.java.source.nbjavac
+OpenIDE-Module-Implementation-Version: 1
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/source/nbjavac/Bundle.properties
+OpenIDE-Module-Requires: org.netbeans.modules.nbjavac

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/nbproject/project.properties b/java.source.nbjavac/nbproject/project.properties
new file mode 100644
index 0000000..8942dda
--- /dev/null
+++ b/java.source.nbjavac/nbproject/project.properties
@@ -0,0 +1,5 @@
+is.eager=true
+javac.source=1.8
+javac.compilerargs=-Xlint -Xlint:-serial
+spec.version.base=1.0
+requires.nb.javac.impl=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/nbproject/project.xml b/java.source.nbjavac/nbproject/project.xml
new file mode 100644
index 0000000..75f5402
--- /dev/null
+++ b/java.source.nbjavac/nbproject/project.xml
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.apisupport.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+            <code-name-base>org.netbeans.modules.java.source.nbjavac</code-name-base>
+            <module-dependencies>
+                <dependency>
+                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.28</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.api.java</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.66</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.54</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.lib.nbjavac</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>8.21</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>9.7</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.parsing.indexing</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.filesystems</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>9.11</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.util</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>9.8</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.util.lookup</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>8.34</specification-version>
+                    </run-dependency>
+                </dependency>
+            </module-dependencies>
+            <test-dependencies>
+                <test-type>
+                    <name>unit</name>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.lib.nbjavac</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.source</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
+                        <recursive/>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+                        <recursive/>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.parsing.indexing</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.parsing.nb</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                </test-type>
+            </test-dependencies>
+            <public-packages/>
+        </data>
+    </configuration>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties
new file mode 100644
index 0000000..ae5ccca
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties
@@ -0,0 +1 @@
+OpenIDE-Module-Name=Java Source nb-javac Bridge

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java
new file mode 100644
index 0000000..196b078
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import com.sun.tools.javac.api.ClassNamesForFileOraculum;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.tools.JavaFileObject;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class ClassNamesForFileOraculumImpl implements ClassNamesForFileOraculum {
+
+    private final Map<JavaFileObject, List<String>> misplacedSource2FQNs;
+
+    public ClassNamesForFileOraculumImpl(Map<JavaFileObject, List<String>> misplacedSource2FQNs) {
+        this.misplacedSource2FQNs = misplacedSource2FQNs;
+    }
+    
+    public String[] divineClassName(JavaFileObject jfo) {
+        if (misplacedSource2FQNs.isEmpty()) {
+            return null;
+        }
+        
+        List<String> result = misplacedSource2FQNs.get(jfo);
+        
+        if (result != null) {
+            return result.toArray(new String[result.size()]);
+        }
+        
+        return null;
+    }
+
+    public JavaFileObject[] divineSources(String fqn) {
+        if (fqn == null || fqn.length() == 0 || misplacedSource2FQNs.isEmpty()) {
+            return null;
+        }
+
+        fqn += "."; //fqn should always be a package name
+
+        List<JavaFileObject> jfos = new LinkedList<JavaFileObject>();
+        for (Map.Entry<JavaFileObject, List<String>> entry : misplacedSource2FQNs.entrySet()) {
+            for (String s : entry.getValue()) {
+                if (s.startsWith(fqn)) {
+                    if (s.indexOf('.', fqn.length()) == -1) {
+                        jfos.add(entry.getKey());
+                        break;
+                    }
+                }
+            }
+        }
+        
+        return jfos.size() > 0 ? jfos.toArray(new JavaFileObject[jfos.size()]) : null;
+    }
+}


[02/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacimpl/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/libs.javacimpl/nbproject/project.properties b/libs.javacimpl/nbproject/project.properties
index b602c8a..89770eb 100644
--- a/libs.javacimpl/nbproject/project.properties
+++ b/libs.javacimpl/nbproject/project.properties
@@ -19,7 +19,7 @@ javac.source=1.6
 nbm.homepage=http://jackpot.netbeans.org/
 nbm.module.author=Petr Hrebejk
 spec.version.base=0.47.0
-release.external/nb-javac-impl.jar=modules/ext/nb-javac-impl.jar
+#release.external/nb-javac-impl.jar=modules/ext/nb-javac-impl.jar
 javadoc.arch=${basedir}/arch.xml
 
 
@@ -37,3 +37,4 @@ javadoc.arch=${basedir}/arch.xml
 # Hidden class found: com.sun.tools.javac.jvm.Code$State in method public int com.sun.tools.javac.jvm.Code.entryPoint(com.sun.tools.javac.jvm.Code$State,com.sun.tools.javac.code.Type) in class com.sun.tools.javac.jvm.Code
 sigtest.gen.fail.on.error=false
 
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacimpl/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/libs.javacimpl/nbproject/project.xml b/libs.javacimpl/nbproject/project.xml
index 7944a18..e5bdda9 100644
--- a/libs.javacimpl/nbproject/project.xml
+++ b/libs.javacimpl/nbproject/project.xml
@@ -30,11 +30,11 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>8.17</specification-version>
+                        <implementation-version/>
                     </run-dependency>
                 </dependency>
             </module-dependencies>
-            <friend-packages>
+<!--            <friend-packages>
                 <friend>org.netbeans.modules.jackpot.rules</friend>
                 <friend>org.netbeans.modules.java.hints</friend>
                 <friend>org.netbeans.modules.java.source</friend>
@@ -57,11 +57,12 @@
                 <package>com.sun.tools.javac.tree</package>
                 <package>com.sun.tools.javac.util</package>
                 <package>com.sun.tools.javadoc</package>
-            </friend-packages>
-            <class-path-extension>
+            </friend-packages>-->
+            <public-packages/>
+<!--            <class-path-extension>
                 <runtime-relative-path>ext/nb-javac-impl.jar</runtime-relative-path>
                 <binary-origin>external/nb-javac-impl.jar</binary-origin>
-            </class-path-extension>
+            </class-path-extension>-->
         </data>
     </configuration>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.jshell.compile/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/libs.jshell.compile/nbproject/project.properties b/libs.jshell.compile/nbproject/project.properties
index d192e77..01fcd9b 100644
--- a/libs.jshell.compile/nbproject/project.properties
+++ b/libs.jshell.compile/nbproject/project.properties
@@ -26,3 +26,4 @@ javadoc.arch=${basedir}/arch.xml
 module.javadoc.packages=
 sigtest.skip.check=true
 sigtest.gen.fail.on.error=false
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.jshell.compile/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/libs.jshell.compile/nbproject/project.xml b/libs.jshell.compile/nbproject/project.xml
index 5ecafda..0ec3316 100644
--- a/libs.jshell.compile/nbproject/project.xml
+++ b/libs.jshell.compile/nbproject/project.xml
@@ -25,7 +25,7 @@
         <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
             <code-name-base>org.netbeans.libs.jshell.compile</code-name-base>
             <module-dependencies>
-                <dependency>
+<!--                <dependency>
                     <code-name-base>org.netbeans.libs.javacapi</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
@@ -41,7 +41,7 @@
                         <release-version>1</release-version>
                         <specification-version>0.47</specification-version>
                     </run-dependency>
-                </dependency>
+                </dependency>-->
                 <dependency>
                     <code-name-base>org.netbeans.lib.nbjshell</code-name-base>
                     <run-dependency>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/maven.apisupport/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/maven.apisupport/nbproject/project.properties b/maven.apisupport/nbproject/project.properties
index 41c0e06..5f7dca0 100644
--- a/maven.apisupport/nbproject/project.properties
+++ b/maven.apisupport/nbproject/project.properties
@@ -20,3 +20,4 @@ javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/maven.hints/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/maven.hints/nbproject/project.properties b/maven.hints/nbproject/project.properties
index 2aea11b..82150ad 100644
--- a/maven.hints/nbproject/project.properties
+++ b/maven.hints/nbproject/project.properties
@@ -20,3 +20,4 @@ javac.source=1.6
 #javac.compilerargs=-Xlint -Xlint:-serial
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/maven.junit.ui/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/maven.junit.ui/nbproject/project.properties b/maven.junit.ui/nbproject/project.properties
index 7f641b7..375b088 100644
--- a/maven.junit.ui/nbproject/project.properties
+++ b/maven.junit.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/maven.refactoring/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/maven.refactoring/nbproject/project.properties b/maven.refactoring/nbproject/project.properties
index c0af75f..315878a 100644
--- a/maven.refactoring/nbproject/project.properties
+++ b/maven.refactoring/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
----------------------------------------------------------------------
diff --git a/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java b/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
index 1415258..0613261 100644
--- a/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
+++ b/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
@@ -290,7 +290,7 @@ public final class UnitTestsCompilerOptionsQueryImpl implements CompilerOptionsQ
                         cc.toPhase(JavaSource.Phase.PARSED);
                         final CompilationUnitTree cu = cc.getCompilationUnit();
                         for (Tree decl : cu.getTypeDecls()) {
-                            if (decl.getKind() == Tree.Kind.MODULE) {
+                            if (decl.getKind().name().equals("MODULE")) {
                                 res[0] = ((ModuleTree)decl).getName().toString();
                                 break;
                             }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/nbbuild/build.xml
----------------------------------------------------------------------
diff --git a/nbbuild/build.xml b/nbbuild/build.xml
index 1db4316..68028ad 100644
--- a/nbbuild/build.xml
+++ b/nbbuild/build.xml
@@ -71,6 +71,7 @@
     <property name="have-downloadbinaries-task" value="true" />
     <downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
         <manifest dir="${nb_all}">
+            <include name="nbbuild/external/binaries-list"/>
             <include name="libs.junit4/external/binaries-list"/>
             <include name="javahelp/external/binaries-list"/>
         </manifest>
@@ -124,7 +125,40 @@
     </downloadbinaries>
   </target>
 
-  <target name="init-module-list" depends="bootstrap,init-tasks">
+  <target name="-check-vanilla-javac" depends="bootstrap">
+    <condition property="vanilla.javac.exists">
+      <and>
+        <available file="${nb_all}/nbbuild/external/vanilla-javac-api.jar" />
+        <available file="${nb_all}/nbbuild/external/vanilla-javac-impl.jar" />
+      </and>
+    </condition>
+  </target>
+
+  <target name="prepare-vanilla-javac" depends="-check-vanilla-javac" unless="vanilla.javac.exists">
+    <delete dir="${nb_all}/nbbuild/build/langtools" />
+    <mkdir dir="${nb_all}/nbbuild/build/langtools" />
+    <get src="http://hg.openjdk.java.net/jdk9/jdk9/langtools/archive/tip.zip" dest="${nb_all}/nbbuild/build/langtools.zip" skipexisting="true"/>
+    <unzip src="${nb_all}/nbbuild/build/langtools.zip" dest="${nb_all}/nbbuild/build/langtools">
+        <cutdirsmapper dirs="1"/>
+    </unzip>
+    <ant antfile="${nb_all}/nbbuild/build/langtools/make/build.xml" dir="${nb_all}/nbbuild/build/langtools/" target="generate-sources">
+        <property name="langtools.jdk.home" value="${java.home}" />
+    </ant>
+    <mkdir dir="${nb_all}/nbbuild/build/langtools/build/nb" />
+    <javac srcdir="${nb_all}/nbbuild/build/langtools/src/java.compiler/share/classes:${nb_all}/nbbuild/build/langtools/src/jdk.compiler/share/classes:${nb_all}/nbbuild/build/langtools/src/jdk.javadoc/share/classes:${nb_all}/nbbuild/build/langtools/src/jdk.jdeps/share/classes:${nb_all}/nbbuild/build/langtools/build/gensrc/jdk.compiler"
+           destdir="${nb_all}/nbbuild/build/langtools/build/nb"
+           excludes="**/module-info.java,com/sun/tools/javac/main/JavacToolProvider.java,com/sun/tools/jdeps/**,com/sun/tools/jdeprscan/**,com/sun/tools/javap/Main.java,jdk/javadoc/internal/tool/JavadocToolProvider.java,com/sun/tools/doclets/standard/Standard.java" />
+    <copy todir="${nb_all}/nbbuild/build/langtools/build/nb">
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/java.compiler/share/classes" includes="**/*.properties"/>
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/jdk.compiler/share/classes" includes="**/*.properties"/>
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/jdk.javadoc/share/classes" includes="**/*.properties"/>
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/jdk.jdeps/share/classes" includes="**/*.properties"/>
+    </copy>
+    <jar destfile="${nb_all}/nbbuild/external/vanilla-javac-api.jar" basedir="${nb_all}/nbbuild/build/langtools/build/nb" includes="javax/**,com/sun/source/**,com/sun/javadoc/**" />
+    <jar destfile="${nb_all}/nbbuild/external/vanilla-javac-impl.jar" basedir="${nb_all}/nbbuild/build/langtools/build/nb" excludes="javax/**,com/sun/source/**,com/sun/javadoc/**" />
+  </target>
+
+  <target name="init-module-list" depends="bootstrap,init-tasks,prepare-vanilla-javac">
     <!-- Define modules. -->
     <checkmoduleconfigs nbroot=".."/>
     <resolvelist name="allmodules" list="${nb.clusters.list}"/>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/nbbuild/cluster.properties
----------------------------------------------------------------------
diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties
index 6cbb9a9..dc00472 100644
--- a/nbbuild/cluster.properties
+++ b/nbbuild/cluster.properties
@@ -627,6 +627,8 @@ nb.cluster.java=\
         java.source.ant,\
         java.source.base,\
         java.source.compat8,\
+        java.source.jdk9.req,\
+        java.source.nbjavac,\
         java.source.queries,\
         java.source.queriesimpl,\
         java.sourceui,\

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/nbbuild/external/binaries-list
----------------------------------------------------------------------
diff --git a/nbbuild/external/binaries-list b/nbbuild/external/binaries-list
index 435c1cd..7335f3b 100644
--- a/nbbuild/external/binaries-list
+++ b/nbbuild/external/binaries-list
@@ -16,4 +16,5 @@
 # under the License.
 A7674A6D78B7FEA58AF76B357DAE6EA5E3FDFBE9 apitest.jar
 88CADDFC6785B6B7B7E65C9DC80C03958EBAEE73 nbbuild-xhtml1-dtds-resources.zip
+071355012BD9E174619F838E72F1869277E24B69 nb-javac-impl.jar
 16398550402B27F81CD0D508CEF54B3E47A4A6DA org.apache.rat:apache-rat:0.12

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/nbbuild/templates/common.xml
----------------------------------------------------------------------
diff --git a/nbbuild/templates/common.xml b/nbbuild/templates/common.xml
index 7ff3e4c..6265067 100644
--- a/nbbuild/templates/common.xml
+++ b/nbbuild/templates/common.xml
@@ -534,6 +534,7 @@
                     <pathelement path="${module.run.classpath}"/>
                     <pathelement path="${test.@{test.type}.run.cp.extra}"/>
                     <pathelement path="${test.@{test.type}.cp.extra}"/>
+                    <pathelement path="${test.extra.nb.javac.deps}"/>
                 </path>
                 <!-- path reference used in both compiler and executor -->
                 <propertyset id="test.@{test.type}.properties">

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/nbbuild/templates/projectized.xml
----------------------------------------------------------------------
diff --git a/nbbuild/templates/projectized.xml b/nbbuild/templates/projectized.xml
index ef60182..1d8885f 100644
--- a/nbbuild/templates/projectized.xml
+++ b/nbbuild/templates/projectized.xml
@@ -170,30 +170,40 @@ If you are sure you want to build with JDK 9+ anyway, use: -Dpermit.jdk9.builds=
         <property name="locjhindexer.locales" value="${locales}"/>
         <property name="locmakenbm.locales" value="${locales}"/>
         <property name="locmakenbm.brands" value="${brandings}"/>
-        <pathconvert property="retouche.javac.api">
-            <fileset dir="${nb_all}">
-                <include name="libs.javacapi/external/*javac*.jar"/>
-            </fileset>
-        </pathconvert>
-        <pathconvert property="retouche.javac.impl">
-            <fileset dir="${nb_all}">
-                <include name="libs.javacimpl/external/*javac*.jar"/>
-            </fileset>
-            <fileset dir="${nbjdk.home}/../Classes" erroronmissingdir="false">
-                <include name="*.jar"/>
-            </fileset>
-        </pathconvert>
         <!-- When requires.nb.javac property is true, prepend javac-api and javac-impl on bootclasspath to allow override the default annotation
              processing API located in rt.jar. -->
-        <condition property="bootclasspath.prepend" value="${retouche.javac.api}${path.separator}${retouche.javac.impl}">
+        <property name="bootclasspath.prepend.vanilla" value="${nb_all}/nbbuild/external/vanilla-javac-api.jar:${nb_all}/nbbuild/external/vanilla-javac-impl.jar" />
+        <property name="bootclasspath.prepend.nb" value="${nb_all}/nbbuild/external/vanilla-javac-api.jar:${nb_all}/nbbuild/external/nb-javac-impl.jar" />
+        <condition property="bootclasspath.prepend" value="${bootclasspath.prepend.nb}">
+            <istrue value="${requires.nb.javac.impl}"/>
+        </condition>
+        <condition property="bootclasspath.prepend" value="${bootclasspath.prepend.vanilla}">
             <istrue value="${requires.nb.javac}"/>
         </condition>
-        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend}">
+        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend.vanilla}">
+            <and>
+                <istrue value="${requires.nb.javac}"/>
+                <istrue value="${test.use.vanilla.javac}"/>
+            </and>
+        </condition>
+        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend.nb}">
             <istrue value="${requires.nb.javac}"/>
         </condition>
+        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend.nb}">
+            <istrue value="${requires.nb.javac.impl}"/>
+        </condition>
         <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend}">
             <isset property="bootclasspath.prepend"/>
         </condition>
+        <condition property="test.extra.nb.javac.deps" value="${java.source.nbjavac.dir}/modules/org-netbeans-modules-java-source-nbjavac.jar">
+            <and>
+                <istrue value="${requires.nb.javac}"/>
+                <not>
+                    <istrue value="${test.use.vanilla.javac}"/>
+                </not>
+            </and>
+        </condition>
+        <property name="test.extra.nb.javac.deps" value="" />
         <fail message="Delete standalone/suite-related metadata from netbeans.org modules">
             <condition>
                 <or>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/o.n.bootstrap/src/org/netbeans/ModuleManager.java
----------------------------------------------------------------------
diff --git a/o.n.bootstrap/src/org/netbeans/ModuleManager.java b/o.n.bootstrap/src/org/netbeans/ModuleManager.java
index 9276954..f63fd33 100644
--- a/o.n.bootstrap/src/org/netbeans/ModuleManager.java
+++ b/o.n.bootstrap/src/org/netbeans/ModuleManager.java
@@ -882,7 +882,7 @@ public final class ModuleManager extends Modules {
         return theHost.getClassLoader();
     }
     
-    private Collection<Module> getAttachedFragments(Module m) {
+    public Collection<Module> getAttachedFragments(Module m) {
         String cdn = m.getCodeNameBase();
         Collection<Module> frags = fragmentModules.get(cdn);
         return frags == null ? Collections.<Module>emptySet() : frags;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/parsing.api/src/org/netbeans/modules/parsing/api/Source.java
----------------------------------------------------------------------
diff --git a/parsing.api/src/org/netbeans/modules/parsing/api/Source.java b/parsing.api/src/org/netbeans/modules/parsing/api/Source.java
index b608e2c..de03c14 100644
--- a/parsing.api/src/org/netbeans/modules/parsing/api/Source.java
+++ b/parsing.api/src/org/netbeans/modules/parsing/api/Source.java
@@ -570,6 +570,8 @@ public final class Source implements Lookup.Provider {
     }
 
     private void setSourceModification (boolean sourceChanged, int startOffset, int endOffset) {
+        if (!sourceChanged)
+            return ;
         ASourceModificationEvent oldSourceModificationEvent;
         ASourceModificationEvent newSourceModificationEvent;
         do {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
----------------------------------------------------------------------
diff --git a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
index 7b1ce92..6ca03d9 100644
--- a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
+++ b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.profiler.nbimpl.javac;
 
 import com.sun.source.tree.ClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -191,7 +191,7 @@ public class ElementUtilitiesEx {
                 @Override
                 public void run(final CompilationController cc) throws Exception {
                     cc.toPhase(Phase.RESOLVED);
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
 
                         @Override
                         public Void visitClass(ClassTree node, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
----------------------------------------------------------------------
diff --git a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
index ee328dc..ece6b75 100644
--- a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
+++ b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.profiler.nbimpl.javac;
 
 import com.sun.source.tree.ClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
@@ -348,7 +348,7 @@ public class JavacClassInfo extends SourceClassInfo {
 
         cc.toPhase(JavaSource.Phase.RESOLVED);
 
-        TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+        ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitClass(ClassTree node, Void v) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
----------------------------------------------------------------------
diff --git a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
index 9c6906f..f681956 100644
--- a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
+++ b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -194,7 +194,7 @@ public class JavaProfilerSourceImpl implements AbstractJavaProfilerSource {
                         return;
                     }
 
-                    TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                    ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
                         public Void visitMethod(MethodTree node, Void p) {
                             Void retValue;
@@ -241,7 +241,7 @@ public class JavaProfilerSourceImpl implements AbstractJavaProfilerSource {
                         return;
                     }
 
-                    TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                    ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
                         @Override
                         public Void visitClass(ClassTree node, Void param) {
@@ -295,7 +295,7 @@ public class JavaProfilerSourceImpl implements AbstractJavaProfilerSource {
                 public void run(final CompilationController controller) throws Exception {
                     controller.toPhase(Phase.ELEMENTS_RESOLVED);
 
-                    TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                    ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
                         @Override
                         public Void visitAnnotation(AnnotationTree annTree, Void p) {
@@ -632,7 +632,7 @@ public class JavaProfilerSourceImpl implements AbstractJavaProfilerSource {
                     public void run(final CompilationController cc) throws Exception {
                         cc.toPhase(Phase.ELEMENTS_RESOLVED);
 
-                        TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                        ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
                             @Override
                             public Void visitMethod(MethodTree node, Void p) {
                                 Element e = cc.getTrees().getElement(getCurrentPath());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/profiler.projectsupport/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/profiler.projectsupport/nbproject/project.properties b/profiler.projectsupport/nbproject/project.properties
index 352701b..1918eaa 100644
--- a/profiler.projectsupport/nbproject/project.properties
+++ b/profiler.projectsupport/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.autoload=true
 javac.compilerargs=-Xlint -Xlint:-serial
 javac.source=1.6
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
index 62de70c..c487ced 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.api;
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -297,7 +297,7 @@ public final class JavaRefactoringUtils {
         return scanner.usages;
     }
 
-    private static final class InvocationScanner extends TreePathScanner <Tree, ElementHandle> implements CancellableTask <CompilationController> {
+    private static final class InvocationScanner extends ErrorAwareTreePathScanner <Tree, ElementHandle> implements CancellableTask <CompilationController> {
         private CompilationController cc;
         private final ElementHandle toFind;
         InvocationScanner (ElementHandle toFind) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
index bbd26bf..1f299e9 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
@@ -22,7 +22,7 @@ package org.netbeans.modules.refactoring.java.callhierarchy;
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.EventQueue;
 import java.io.IOException;
 import java.lang.annotation.Annotation;
@@ -530,7 +530,7 @@ final class CallHierarchyTasks {
         
     }
     
-    private static final class CalleeScanner extends TreePathScanner<Void, Void> {
+    private static final class CalleeScanner extends ErrorAwareTreePathScanner<Void, Void> {
         private final CompilationInfo   javac;
         /** map of all executables and their occurrences in the method body */
         private Map<Element, OccurrencesDesc> refs = new HashMap<Element, OccurrencesDesc>();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
index 1cc4e4b..86a7dfd 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.*;
@@ -506,7 +506,7 @@ public class ChangeParametersPlugin extends JavaRefactoringPlugin {
             String name = paramTable[index].getName();
             int originalIndex = paramTable[index].getOriginalIndex();
             final VariableElement parameterElement = originalIndex == -1 ? null : method.getParameters().get(originalIndex);
-            TreeScanner<Boolean, String> scanner = new TreeScanner<Boolean, String>() {
+            ErrorAwareTreeScanner<Boolean, String> scanner = new ErrorAwareTreeScanner<Boolean, String>() {
 
                 @Override
                 public Boolean visitVariable(VariableTree vt, String p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
index 86204c2..5194ef2 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
@@ -41,7 +41,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
@@ -788,7 +788,7 @@ public class ChangeParamsTransformer extends RefactoringVisitor {
         do {
             original2Translated.clear();
             if(renameParams) {
-                TreeScanner<Void, Void> idScan = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> idScan = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitIdentifier(IdentifierTree node, Void p) {
                         String name = node.getName().toString();
@@ -808,7 +808,7 @@ public class ChangeParamsTransformer extends RefactoringVisitor {
                 blockTree = (BlockTree) workingCopy.getTreeUtilities().translate(blockTree, original2Translated);
             }
             original2Translated.clear();
-            TreeScanner<Boolean, ExecutableElement> methodScanner = new TreeScanner<Boolean, ExecutableElement>() {
+            ErrorAwareTreeScanner<Boolean, ExecutableElement> methodScanner = new ErrorAwareTreeScanner<Boolean, ExecutableElement>() {
                 @Override
                 public Boolean visitMethodInvocation(MethodInvocationTree node, ExecutableElement p) {
                     boolean changed = false;
@@ -847,7 +847,7 @@ public class ChangeParamsTransformer extends RefactoringVisitor {
         boolean changed = false;
         do {
             original2Translated.clear();
-            TreeScanner<Void, Void> idScan = new TreeScanner<Void, Void>() {
+            ErrorAwareTreeScanner<Void, Void> idScan = new ErrorAwareTreeScanner<Void, Void>() {
                 @Override
                 public Void visitIdentifier(IdentifierTree node, Void p) {
                     String name = node.getName().toString();
@@ -866,7 +866,7 @@ public class ChangeParamsTransformer extends RefactoringVisitor {
             expressionTree = (ExpressionTree) workingCopy.getTreeUtilities().translate(expressionTree, original2Translated);
             
             original2Translated.clear();
-            TreeScanner<Boolean, ExecutableElement> methodScanner = new TreeScanner<Boolean, ExecutableElement>() {
+            ErrorAwareTreeScanner<Boolean, ExecutableElement> methodScanner = new ErrorAwareTreeScanner<Boolean, ExecutableElement>() {
                 @Override
                 public Boolean visitMethodInvocation(MethodInvocationTree node, ExecutableElement p) {
                     boolean changed = false;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
index a2f5b92..0804d6d 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
index 1bdece1..28c9b0b 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
@@ -51,7 +51,7 @@ import org.openide.util.Exceptions;
  *
  * @author Jan Becicka
  */
-public class FindUsagesVisitor extends TreePathScanner<Tree, Element> {
+public class FindUsagesVisitor extends ErrorAwareTreePathScanner<Tree, Element> {
 
     private Collection<TreePath> usages = new ArrayList<>();
     private List<WhereUsedElement> elements = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
index d7d5789..10f6f1c 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -36,7 +36,7 @@ import org.openide.util.Exceptions;
  *
  * @author Jan Becicka
  */
-public class FindVisitor extends TreePathScanner<Tree, Element> {
+public class FindVisitor extends ErrorAwareTreePathScanner<Tree, Element> {
 
     private Collection<TreePath> usages = new ArrayList<TreePath>();
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
index ac1fe21..8a36ef9 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
@@ -31,6 +31,8 @@ import org.netbeans.api.java.source.ElementUtilities;
 import org.netbeans.api.java.source.GeneratorUtilities;
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.java.source.TreeUtilities;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import org.netbeans.modules.refactoring.api.Problem;
 import org.netbeans.modules.refactoring.java.api.JavaRefactoringUtils;
 import org.netbeans.modules.refactoring.java.spi.RefactoringVisitor;
@@ -208,7 +210,7 @@ public class InlineMethodTransformer extends RefactoringVisitor {
             body = (BlockTree) treeUtilities.translate(body, original2TranslatedBody);
             
             final Boolean[] multiplereturn = {null};
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
 
                 @Override
                 public Void scan(Tree node, Void p) {
@@ -396,7 +398,7 @@ public class InlineMethodTransformer extends RefactoringVisitor {
         final ElementUtilities elementUtilities = workingCopy.getElementUtilities();
         final TypeElement bodyEnclosingTypeElement = elementUtilities.enclosingTypeElement(method);
 
-        TreePathScanner<Void, ExecutableElement> idScan = new TreePathScanner<Void, ExecutableElement>() {
+        ErrorAwareTreePathScanner<Void, ExecutableElement> idScan = new ErrorAwareTreePathScanner<Void, ExecutableElement>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, ExecutableElement p) {
                 TreePath currentPath = getCurrentPath();
@@ -524,7 +526,7 @@ public class InlineMethodTransformer extends RefactoringVisitor {
         final CompilationUnitTree compilationUnitTree = workingCopy.getTrees().getPath(resolved).getCompilationUnit();
         final LinkedList<Pair<Element, String>> renames = new LinkedList<>();
         // Scan the body and look for name clashes
-        TreeScanner<Void, ExecutableElement> nameClashScanner = new TreeScanner<Void, ExecutableElement>() {
+        ErrorAwareTreeScanner<Void, ExecutableElement> nameClashScanner = new ErrorAwareTreeScanner<Void, ExecutableElement>() {
             @Override
             public Void visitVariable(VariableTree node, ExecutableElement p) {
                 TreePath path = trees.getPath(compilationUnitTree, node);
@@ -577,7 +579,7 @@ public class InlineMethodTransformer extends RefactoringVisitor {
             
         };
         nameClashScanner.scan(body, (ExecutableElement) p);
-        TreeScanner<Void, Pair<Element, String>> idScan = new TreeScanner<Void, Pair<Element, String>>() {
+        ErrorAwareTreeScanner<Void, Pair<Element, String>> idScan = new ErrorAwareTreeScanner<Void, Pair<Element, String>>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Pair<Element, String> p) {
                 TreePath path = trees.getPath(compilationUnitTree, node);
@@ -617,7 +619,7 @@ public class InlineMethodTransformer extends RefactoringVisitor {
         final CompilationUnitTree compilationUnitTree = workingCopy.getTrees().getPath(resolved).getCompilationUnit();
         final LinkedList<Pair<Element, String>> renames = new LinkedList<>();
         
-        TreeScanner<Void, Pair<VariableElement, ExpressionTree>> idScan = new TreeScanner<Void, Pair<VariableElement, ExpressionTree>>() {
+        ErrorAwareTreeScanner<Void, Pair<VariableElement, ExpressionTree>> idScan = new ErrorAwareTreeScanner<Void, Pair<VariableElement, ExpressionTree>>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Pair<VariableElement, ExpressionTree> p) {
                 TreePath currentPath = trees.getPath(compilationUnitTree, node);
@@ -675,7 +677,7 @@ public class InlineMethodTransformer extends RefactoringVisitor {
             }
         }
 
-        TreeScanner<Void, Pair<Element, String>> renameScan = new TreeScanner<Void, Pair<Element, String>>() {
+        ErrorAwareTreeScanner<Void, Pair<Element, String>> renameScan = new ErrorAwareTreeScanner<Void, Pair<Element, String>>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Pair<Element, String> p) {
                 TreePath path = trees.getPath(compilationUnitTree, node);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
index 917a01e..80cfb4b 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
@@ -250,7 +250,7 @@ public class InlineRefactoringPlugin extends JavaRefactoringPlugin {
                 if (initializer.getKind().equals(Tree.Kind.METHOD_INVOCATION)) {
                     skipFirstMethodInvocation++;
                 }
-                TreeScanner<Boolean, Boolean> scanner = new UnsafeTreeScanner(skipFirstMethodInvocation);
+                ErrorAwareTreeScanner<Boolean, Boolean> scanner = new UnsafeTreeScanner(skipFirstMethodInvocation);
                 Boolean isChanged = scanner.scan(initializer, false);
                 if (isChanged != null && isChanged) {
                     preCheckProblem = createProblem(preCheckProblem, false, WRN_InlineChange()); //NOI18N
@@ -542,7 +542,7 @@ public class InlineRefactoringPlugin extends JavaRefactoringPlugin {
         }
     }
 
-    private static class UnsafeTreeScanner extends TreeScanner<Boolean, Boolean> {
+    private static class UnsafeTreeScanner extends ErrorAwareTreeScanner<Boolean, Boolean> {
 
         private int skipFirstMethodInvocation;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
index fdba31e..24fc93a 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -92,7 +92,7 @@ public class IntroduceParameterPlugin extends JavaRefactoringPlugin {
                 String name = paramTable[index].getName();
                 int originalIndex = paramTable[index].getOriginalIndex();
                 final VariableElement parameterElement = originalIndex == -1 ? null : method.getParameters().get(originalIndex);
-                TreeScanner<Boolean, String> scanner = new TreeScanner<Boolean, String>() {
+                ErrorAwareTreeScanner<Boolean, String> scanner = new ErrorAwareTreeScanner<Boolean, String>() {
                
                     @Override
                     public Boolean visitVariable(VariableTree vt, String p) {
@@ -330,7 +330,7 @@ public class IntroduceParameterPlugin extends JavaRefactoringPlugin {
     private Set<TreePath> computeDuplicates(final WorkingCopy workingCopy, TreePath resolved, TreePath meth) {
         Set<TreePath> ret = SourceUtils.computeDuplicates(workingCopy, resolved, meth, new AtomicBoolean());
 //        final Set<TreePath> ret = new HashSet<TreePath>();
-//        TreePathScanner<Void, Element> scanner = new TreePathScanner<Void, Element>() {
+//        ErrorAwareTreePathScanner<Void, Element> scanner = new ErrorAwareTreePathScanner<Void, Element>() {
 //
 //            @Override
 //            public Void visitIdentifier(IdentifierTree node, Element p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
index 4dd18c2..e9cbf5f 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
@@ -22,7 +22,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -259,7 +259,7 @@ public class InvertBooleanRefactoringPlugin implements RefactoringPlugin { //ext
                         format.setRightBrace("}$");
                         final String mthFormat = format.format(MTH_INIT);
 
-                        new TreePathScanner<Void, Void>() {
+                        new ErrorAwareTreePathScanner<Void, Void>() {
                             @Override public Void visitReturn(ReturnTree node, Void p) {
                                 TransformationSupport.create(mthFormat).setCancel(cancel).transformTreePath(parameter, getCurrentPath());
                                 return super.visitReturn(node, p);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
index a58afff..9f7c98b 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.SwitchTree;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import org.netbeans.api.java.source.CompilationInfo;
@@ -41,7 +41,7 @@ import org.netbeans.api.java.source.CompilationInfo;
  *
  * @author Jan Becicka
  */
-public class LocalVarScanner extends TreePathScanner<Boolean, Element> {
+public class LocalVarScanner extends ErrorAwareTreePathScanner<Boolean, Element> {
 
     private CompilationInfo info;
     private String newName;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
index 26c7a74..e7e1fdd 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
@@ -170,7 +170,7 @@ public class MoveClassTransformer extends RefactoringVisitor {
                     ClassTree classTree = (ClassTree) workingCopy.getTrees().getTree(resolved);
                     ClassTree origTree = get.importComments(classTree, workingCopy.getTrees().getPath(resolved).getCompilationUnit());
                     final Map<Tree, Tree> org2trans = new HashMap<Tree, Tree>();
-                    TreeScanner<Object, Element> scanner= new TreeScanner<Object, Element>() {
+                    ErrorAwareTreeScanner<Object, Element> scanner= new ErrorAwareTreeScanner<Object, Element>() {
 
                         @Override
                         public Object visitIdentifier(IdentifierTree node, Element p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
index 37c9c8e..ccc162f 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
@@ -23,7 +23,7 @@ import com.sun.javadoc.Tag;
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.*;
 import java.util.logging.Level;
@@ -377,7 +377,7 @@ public class MoveMembersTransformer extends RefactoringVisitor {
                 arguments.remove(removedIndex);
             }
             TypeMirror sourceType = workingCopy.getTrees().getTypeMirror(enclosingClassPath);
-            TreeScanner<Boolean, TypeMirror> needsArgumentScanner = new TreeScanner<Boolean, TypeMirror>() {
+            ErrorAwareTreeScanner<Boolean, TypeMirror> needsArgumentScanner = new ErrorAwareTreeScanner<Boolean, TypeMirror>() {
                 // Logic is a copy from #insertIfMatch
 
                 @Override
@@ -549,7 +549,7 @@ public class MoveMembersTransformer extends RefactoringVisitor {
                     final TreePath bodyPath = new TreePath(resolvedPath, body);
                     final Trees trees = workingCopy.getTrees();
                     final Map<ExpressionTree, ExpressionTree> fqns = new HashMap<ExpressionTree, ExpressionTree>();
-                    TreeScanner<Void, Void> fqnScan = new TreeScanner<Void, Void>() {
+                    ErrorAwareTreeScanner<Void, Void> fqnScan = new ErrorAwareTreeScanner<Void, Void>() {
 
                         @Override
                         public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -573,7 +573,7 @@ public class MoveMembersTransformer extends RefactoringVisitor {
                     TreePath sourceClass = JavaRefactoringUtils.findEnclosingClass(workingCopy, resolvedPath, true, true, true, true, true);
                     TypeMirror sourceType = workingCopy.getTrees().getTypeMirror(sourceClass);
                     final String parameterName = getParameterName(sourceType, workingCopy.getTrees().getScope(bodyPath), workingCopy);
-                    TreeScanner<Boolean, TypeMirror> idScan = new TreeScanner<Boolean, TypeMirror>() {
+                    ErrorAwareTreeScanner<Boolean, TypeMirror> idScan = new ErrorAwareTreeScanner<Boolean, TypeMirror>() {
 
                         @Override
                         public Boolean visitMemberSelect(MemberSelectTree node, TypeMirror source) {
@@ -646,7 +646,7 @@ public class MoveMembersTransformer extends RefactoringVisitor {
                     boolean addParameter = idScan.scan(body, sourceType) == Boolean.TRUE;
 
                     if (removedParameter != null) {
-                        TreeScanner<Void, Pair<Element, ExpressionTree>> idScan2 = new TreeScanner<Void, Pair<Element, ExpressionTree>>() {
+                        ErrorAwareTreeScanner<Void, Pair<Element, ExpressionTree>> idScan2 = new ErrorAwareTreeScanner<Void, Pair<Element, ExpressionTree>>() {
 
                             @Override
                             public Void visitIdentifier(IdentifierTree node, Pair<Element, ExpressionTree> p) {
@@ -950,7 +950,7 @@ public class MoveMembersTransformer extends RefactoringVisitor {
         final Map<Tree, Tree> original2Translated = new HashMap<Tree, Tree>();
         
         // TODO Change this to something like that is used for method body; importFqns
-        TreeScanner<Void, Void> idScan = new TreeScanner<Void, Void>() {
+        ErrorAwareTreeScanner<Void, Void> idScan = new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 TreePath currentPath = new TreePath(resolvedPath, node);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
index 1e991a7..7648fa8 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -318,7 +318,7 @@ public class PullUpTransformer extends RefactoringVisitor {
         final Types types = workingCopy.getTypes();
 
         final Map<IdentifierTree, Tree> original2Translated = new HashMap<IdentifierTree, Tree>();
-        TreeScanner<Void, Void> scanner = new TreeScanner<Void, Void>() {
+        ErrorAwareTreeScanner<Void, Void> scanner = new ErrorAwareTreeScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -359,7 +359,7 @@ public class PullUpTransformer extends RefactoringVisitor {
     private BlockTree updateSuperThisReferences(BlockTree body, final TreePath mpath) {
         final Map<ExpressionTree, ExpressionTree> original2Translated = new HashMap<ExpressionTree, ExpressionTree>();
         final Trees trees = workingCopy.getTrees();
-        TreeScanner<Boolean, Void> idScan = new TreeScanner<Boolean, Void>() {
+        ErrorAwareTreeScanner<Boolean, Void> idScan = new ErrorAwareTreeScanner<Boolean, Void>() {
             @Override
             public Boolean visitMemberSelect(MemberSelectTree node, Void nothing) {
                 String isThis = node.getExpression().toString();

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
index be45fb4..8188d2e 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.plugins;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.Deque;
@@ -376,7 +376,7 @@ public class PushDownTransformer extends RefactoringVisitor {
             return;
         }
         
-        new TreePathScanner() {
+        new ErrorAwareTreePathScanner() {
 
             @Override
             public Object visitIdentifier(IdentifierTree node, Object p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
index 26fa10f..b783668 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
@@ -23,7 +23,7 @@ import com.sun.source.tree.LabeledStatementTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.*;
@@ -187,7 +187,7 @@ public class RenameRefactoringPlugin extends JavaRefactoringPlugin {
                 parent = parent.getParentPath();
             }
             final String[] result = new String[1];
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 
                 @Override
                 public Void visitLabeledStatement(LabeledStatementTree tree, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
index 7c23169..55c5975 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
@@ -26,7 +26,7 @@ import com.sun.source.tree.*;
 import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -606,7 +606,7 @@ public class RenameTransformer extends RefactoringVisitor {
     }
 
     private boolean duplicateDeclaration() {
-        TreeScanner<Boolean, String> duplicateIds = new TreeScanner<Boolean, String>() {
+        ErrorAwareTreeScanner<Boolean, String> duplicateIds = new ErrorAwareTreeScanner<Boolean, String>() {
             @Override public Boolean visitClass(ClassTree node, String p) {
                 if(node.getSimpleName().contentEquals(p)) {
                     return Boolean.TRUE;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
index 4b77368..39031ab 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
@@ -57,7 +57,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import javax.lang.model.element.Element;
 import org.netbeans.api.annotations.common.CheckForNull;
@@ -73,7 +73,7 @@ import org.openide.ErrorManager;
  *
  * @author Jan Becicka
  */
-public class RefactoringVisitor extends TreePathScanner<Tree, Element> implements DocTreeVisitor<DocTree, Element> {
+public class RefactoringVisitor extends ErrorAwareTreePathScanner<Tree, Element> implements DocTreeVisitor<DocTree, Element> {
     /**
      * 
      */

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
index 1216081..958141d 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
@@ -30,7 +30,7 @@ import com.sun.source.util.DocSourcePositions;
 import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -430,7 +430,7 @@ public final class InstantRefactoringUIImpl implements InstantRefactoringUI {
                         }
                     }
                     final Name label = ((LabeledStatementTree)labeledStatement.getLeaf()).getLabel();
-                    new TreePathScanner <Void, Void>() {
+                    new ErrorAwareTreePathScanner <Void, Void>() {
                         @Override
                         public Void visitBreak(BreakTree node, Void p) {
                             if (node.getLabel() != null && label.contentEquals(node.getLabel())) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
index 697242d..e6152a5 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.refactoring.java.ui;
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.awt.*;
 import java.awt.event.*;
@@ -1088,7 +1088,7 @@ public class MoveMembersPanel extends javax.swing.JPanel implements CustomRefact
         }
     }
 
-    private static class PositionVisitor extends TreePathScanner<Void, Map<Element, Long>> {
+    private static class PositionVisitor extends ErrorAwareTreePathScanner<Void, Map<Element, Long>> {
 
         private final Trees trees;
         private final SourcePositions sourcePositions;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
----------------------------------------------------------------------
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
index 120f8d5..50dd12f 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.refactoring.java.ui;
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Component;
 import java.awt.event.ItemEvent;
 import java.io.IOException;
@@ -190,7 +190,7 @@ public class RenamePanel extends JPanel implements CustomRefactoringPanel {
         initialized = true;
     }
 
-    private class TestClassMethodsVisitor extends TreePathScanner<Void, Void> {
+    private class TestClassMethodsVisitor extends ErrorAwareTreePathScanner<Void, Void> {
 
 	private CompilationInfo info;
 	private List<ExecutableElement> testClassMethods;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
----------------------------------------------------------------------
diff --git a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
index db31258..cae3ee7 100644
--- a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
+++ b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
@@ -321,7 +321,7 @@ public class RefactoringTestBase extends NbTestCase {
         Main.initializeURLFactory();
         org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
         
-        org.netbeans.modules.java.source.TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+//        org.netbeans.modules.java.source.TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         
         prepareTest();
         org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj = ProjectManager.getDefault().findProject(src.getParent())}, false);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spellchecker.bindings.java/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/spellchecker.bindings.java/nbproject/project.properties b/spellchecker.bindings.java/nbproject/project.properties
index c306880..e13a23a 100644
--- a/spellchecker.bindings.java/nbproject/project.properties
+++ b/spellchecker.bindings.java/nbproject/project.properties
@@ -38,3 +38,4 @@ test.unit.run.cp.extra=\
     ${netbeans.dest.dir}/ide8/modules/ext/jmi.jar:\
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
----------------------------------------------------------------------
diff --git a/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java b/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
index effe969..f277d09 100644
--- a/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
+++ b/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.spellchecker.bindings.java;
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -159,7 +159,7 @@ public class JavaSemanticTokenList implements TokenList {
             l.set(pos, parameter.getDocument());
         }
         
-        private static final class ScannerImpl extends TreeScanner<Void, List<Position[]>> {
+        private static final class ScannerImpl extends ErrorAwareTreeScanner<Void, List<Position[]>> {
             private Document doc;
             private CompilationInfo info;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
index 88b5b23..c9adef9 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
@@ -25,7 +25,7 @@ import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.comp.AttrContext;
@@ -36,13 +36,18 @@ import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCErroneous;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
+
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.parser.ParserFactory;
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.java.source.CompilationInfo;
@@ -83,26 +88,21 @@ public class Hacks {
         Log.instance(context).nerrors = 0;
 
         JavaFileObject jfo = FileObjects.memoryFileObject("$$", "$", new File("/tmp/t.java").toURI(), System.currentTimeMillis(), clazz.toString());
-        boolean oldSkipAPs = jc.skipAnnotationProcessing;
 
         try {
-            jc.skipAnnotationProcessing = true;
-
-            Iterable<? extends CompilationUnitTree> parsed = jti.parse(jfo);
-            CompilationUnitTree cut = parsed.iterator().next();
+            CompilationUnitTree cut = ParserFactory.instance(context).newParser(jfo.getCharContent(true), true, true, true).parseCompilationUnit();
 
-            jti.analyze(jti.enter(parsed));
+            jti.analyze(jti.enter(Collections.singletonList(cut)));
 
             return new ScannerImpl().scan(cut, info);
         } catch (IOException ex) {
             Exceptions.printStackTrace(ex);
             return null;
         } finally {
-            jc.skipAnnotationProcessing = oldSkipAPs;
         }
     }
 
-    private static final class ScannerImpl extends TreePathScanner<Scope, CompilationInfo> {
+    private static final class ScannerImpl extends ErrorAwareTreePathScanner<Scope, CompilationInfo> {
 
         @Override
         public Scope visitBlock(BlockTree node, CompilationInfo p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
index 3051cd7..5962f8c 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
@@ -44,8 +44,8 @@ import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacScope;
 import com.sun.tools.javac.api.JavacTaskImpl;
@@ -59,6 +59,7 @@ import com.sun.tools.javac.comp.Attr;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.comp.Todo;
 import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.parser.JavacParser;
@@ -93,6 +94,7 @@ import java.io.File;
 import java.io.IOException;
 import java.lang.ref.Reference;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
 import java.net.URI;
 import java.nio.CharBuffer;
 import java.util.Arrays;
@@ -109,6 +111,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.AnnotationValueVisitor;
@@ -441,7 +445,7 @@ public class Utilities {
                     CompilationUnitTree cut = ((JavacScope) scope).getEnv().toplevel;
                     final boolean[] found = new boolean[1];
 
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
                         @Override public Void visitMemberSelect(MemberSelectTree node, Void p) {
                             Element currentElement = trees.getElement(getCurrentPath());
 
@@ -546,7 +550,7 @@ public class Utilities {
     }
     
     private static boolean containsError(Tree t) {
-        return new TreeScanner<Boolean, Void>() {
+        return new ErrorAwareTreeScanner<Boolean, Void>() {
             @Override
             public Boolean scan(Tree node, Void p) {
                 if (node != null && isErrorTree(node)) {
@@ -635,10 +639,10 @@ public class Utilities {
         };
         NBResolve resolve = NBResolve.instance(jti.getContext());
         resolve.disableAccessibilityChecks();
-        Enter enter = Enter.instance(jti.getContext());
-        enter.shadowTypeEnvs(true);
-        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
-        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+//        Enter enter = Enter.instance(jti.getContext());
+//        enter.shadowTypeEnvs(true);
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
         try {
             Attr attr = Attr.instance(jti.getContext());
             Env<AttrContext> env = ((JavacScope) scope).getEnv();
@@ -646,11 +650,11 @@ public class Utilities {
                 return attr.attribExpr((JCTree) tree,env, Type.noType);
             return attr.attribStat((JCTree) tree,env);
         } finally {
-            cacheContext.leave();
+//            cacheContext.leave();
             log.useSource(prev);
             log.popDiagnosticHandler(discardHandler);
             resolve.restoreAccessbilityChecks();
-            enter.shadowTypeEnvs(false);
+//            enter.shadowTypeEnvs(false);
         }
     }
 
@@ -732,6 +736,7 @@ public class Utilities {
         JavacTaskImpl jti = JavaSourceAccessor.getINSTANCE().getJavacTask(info);
         Context context = jti.getContext();
         JavaCompiler compiler = JavaCompiler.instance(context);
+        Modules modules = Modules.instance(context);
         Log log = Log.instance(context);
         NBResolve resolve = NBResolve.instance(context);
         Annotate annotate = Annotate.instance(context);
@@ -739,18 +744,24 @@ public class Utilities {
 
         JavaFileObject jfo = FileObjects.memoryFileObject("$", "$", new File("/tmp/$" + count + ".java").toURI(), System.currentTimeMillis(), clazz.toString());
 
-        boolean oldSkipAPs = compiler.skipAnnotationProcessing;
-
         try {
-            compiler.skipAnnotationProcessing = true;
             resolve.disableAccessibilityChecks();
             if (compiler.isEnterDone()) {
                 annotate.blockAnnotations();
-                compiler.resetEnterDone();
+//                try {
+//                    Field f = compiler.getClass().getDeclaredField("enterDone");
+//                    f.setAccessible(true);
+//                    f.set(compiler, false);
+//                } catch (Throwable t) {
+//                    Logger.getLogger(Utilities.class.getName()).log(Level.FINE, null, t);
+//                }
+                //was:
+//                compiler.resetEnterDone();
             }
             
             JCCompilationUnit cut = compiler.parse(jfo);
-            compiler.enterTrees(compiler.initModules(com.sun.tools.javac.util.List.of(cut)));
+            modules.enter(com.sun.tools.javac.util.List.of(cut), null);
+            compiler.enterTrees(com.sun.tools.javac.util.List.of(cut));
 
             Todo todo = compiler.todo;
             ListBuffer<Env<AttrContext>> defer = new ListBuffer<Env<AttrContext>>();
@@ -774,11 +785,10 @@ public class Utilities {
         } finally {
             resolve.restoreAccessbilityChecks();
             log.popDiagnosticHandler(discardHandler);
-            compiler.skipAnnotationProcessing = oldSkipAPs;
         }
     }
 
-    private static final class ScannerImpl extends TreePathScanner<Scope, CompilationInfo> {
+    private static final class ScannerImpl extends ErrorAwareTreePathScanner<Scope, CompilationInfo> {
 
         @Override
         public Scope visitBlock(BlockTree node, CompilationInfo p) {
@@ -1075,7 +1085,7 @@ public class Utilities {
         }
     }
     
-    private static final class GeneralizePattern extends TreePathScanner<Void, Void> {
+    private static final class GeneralizePattern extends ErrorAwareTreePathScanner<Void, Void> {
 
         public final Map<Tree, Tree> tree2Variable = new HashMap<Tree, Tree>();
         private final Map<Element, String> element2Variable = new HashMap<Element, String>();
@@ -1214,7 +1224,7 @@ public class Utilities {
     }
 
     public static long patternValue(Tree pattern) {
-        class VisitorImpl extends TreeScanner<Void, Void> {
+        class VisitorImpl extends ErrorAwareTreeScanner<Void, Void> {
             private int value;
             @Override
             public Void scan(Tree node, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
index 4211d95..6ed8348 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
@@ -32,7 +32,7 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java b/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
index 45539b5..642541d 100644
--- a/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
+++ b/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
@@ -57,8 +57,8 @@ import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -522,7 +522,7 @@ public class JavaFixUtilities {
 
             final Set<Tree> originalTrees = Collections.newSetFromMap(new IdentityHashMap<Tree, Boolean>());
             
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override public Void scan(Tree tree, Void p) {
                     originalTrees.add(tree);
                     return super.scan(tree, p);
@@ -580,7 +580,7 @@ public class JavaFixUtilities {
 
     private static final Set<Kind> NUMBER_LITERAL_KINDS = EnumSet.of(Kind.FLOAT_LITERAL, Kind.DOUBLE_LITERAL, Kind.INT_LITERAL, Kind.LONG_LITERAL);
 
-    private static class ReplaceParameters extends TreePathScanner<Number, Void> {
+    private static class ReplaceParameters extends ErrorAwareTreePathScanner<Number, Void> {
 
         private final CompilationInfo info;
         private final TreeMaker make;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
index 1ec2c70..7eadb97 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
@@ -31,7 +31,7 @@ import org.netbeans.api.java.source.SourceUtilsTestUtil;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -51,7 +51,8 @@ public class TestBase extends NbTestCase {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        //XXX:
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         clearWorkDir();
 
         FileUtil.refreshFor(File.listRoots());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
----------------------------------------------------------------------
diff --git a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
index 5a47794..01edc45 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
@@ -30,7 +30,7 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -623,7 +623,7 @@ public class UtilitiesTest extends TestBase {
     private void assertPositions(Tree t, final SourcePositions sp, final String code, String... golden) {
         final List<String> actual = new ArrayList<String>(golden.length);
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 if (node != null) {



[05/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java
new file mode 100644
index 0000000..5d5fae9
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java
@@ -0,0 +1,525 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.tools.javac.api.ClassNamesForFileOraculum;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.TypeTag;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.TreeScanner;
+import org.netbeans.lib.nbjavac.services.CancelAbort;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import com.sun.tools.javac.util.CouplingAbort;
+import com.sun.tools.javac.util.FatalError;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.MissingPlatformError;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+import javax.annotation.processing.Processor;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.annotations.common.NullAllowed;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.modules.java.source.indexing.APTUtils;
+//import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.DiagnosticListenerImpl;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.OutputFileManager;
+import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.Indexable;
+import org.openide.filesystems.FileUtil;
+
+/**
+ *
+ * @author Dusan Balek
+ */
+final class MultiPassCompileWorker extends CompileWorker {
+
+    private static final int MEMORY_LOW = 1;
+    private static final int ERR = 2;
+    private boolean checkForMemLow = true;
+
+    @Override
+    protected ParsingOutput compile(
+            final ParsingOutput previous,
+            final Context context,
+            final JavaParsingContext javaContext,
+            final Collection<? extends CompileTuple> files) {
+        final LinkedList<CompileTuple> toProcess = new LinkedList<>();
+        final HashMap<JavaFileObject, CompileTuple> jfo2tuples = new HashMap<>();
+        final ModuleName moduleName = new ModuleName(javaContext.getModuleName());
+        for (CompileTuple i : files) {
+            if (!previous.finishedFiles.contains(i.indexable)) {
+                toProcess.add(i);
+                jfo2tuples.put(i.jfo, i);
+            }
+        }
+        if (toProcess.isEmpty()) {
+            return ParsingOutput.success(
+                    moduleName.name,
+                    previous.file2FQNs,
+                    previous.addedTypes,
+                    previous.addedModules,
+                    previous.createdFiles,
+                    previous.finishedFiles,
+                    previous.modifiedTypes,
+                    previous.aptGenerated);
+        }
+        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(previous.file2FQNs);
+        final DiagnosticListenerImpl diagnosticListener = new DiagnosticListenerImpl();
+        final LinkedList<CompileTuple> bigFiles = new LinkedList<CompileTuple>();
+        JavacTaskImpl jt = null;
+        CompileTuple active = null;
+        boolean aptEnabled = false;
+        int state = 0;
+        boolean isBigFile = false;
+        boolean[] flm = null;        
+        while (!toProcess.isEmpty() || !bigFiles.isEmpty() || active != null) {
+            if (context.isCancelled()) {
+                return null;
+            }
+            try {
+                context.getSuspendStatus().parkWhileSuspended();
+            } catch (InterruptedException ex) {
+                //NOP - safe to ignore
+            }
+            try {
+                try {
+                    if (isLowMemory(flm)) {
+                        dumpSymFiles(jt, previous.createdFiles, context);
+                        jt = null;
+                        diagnosticListener.cleanDiagnostics();
+                        if ((state & MEMORY_LOW) != 0) {
+                            break;
+                        } else {
+                            state |= MEMORY_LOW;
+                        }
+                        freeMemory(true);
+                        continue;
+                    }
+                    if (active == null) {
+                        if (!toProcess.isEmpty()) {
+                            active = toProcess.removeFirst();
+                            if (active == null || previous.finishedFiles.contains(active.indexable))
+                                continue;
+                            isBigFile = false;
+                        } else {
+                            active = bigFiles.removeFirst();
+                            isBigFile = true;
+                            if (flm == null) {
+                                flm = new boolean[] {true};
+                            }
+                        }
+                    }
+                    if (jt == null) {
+                        jt = JavacParser.createJavacTask(
+                                javaContext.getClasspathInfo(),
+                                diagnosticListener,
+                                javaContext.getSourceLevel(),
+                                javaContext.getProfile(),
+                                javaContext.getFQNs(),
+                                new CancelService() {
+                                    public @Override boolean isCanceled() {
+                                        return context.isCancelled() || (checkForMemLow && isLowMemory(null));
+                                    }
+                                },
+                                active.aptGenerated ? null : APTUtils.get(context.getRoot()),
+                                CompilerOptionsQuery.getOptions(context.getRoot()),
+                                Collections.emptyList());
+                        jt.getContext().put(ClassNamesForFileOraculum.class, cnffOraculum);
+                        Iterable<? extends Processor> processors = jt.getProcessors();
+                        aptEnabled = processors != null && processors.iterator().hasNext();
+                        if (JavaIndex.LOG.isLoggable(Level.FINER)) {
+                            JavaIndex.LOG.finer("Created new JavacTask for: " + FileUtil.getFileDisplayName(context.getRoot()) + " " + javaContext.getClasspathInfo().toString()); //NOI18N
+                        }
+                    }
+                    Iterable<? extends CompilationUnitTree> trees = jt.parse(new JavaFileObject[]{active.jfo});
+                    if (isLowMemory(flm)) {
+                        dumpSymFiles(jt, previous.createdFiles, context);
+                        jt = null;
+                        diagnosticListener.cleanDiagnostics();
+                        trees = null;
+                        if ((state & MEMORY_LOW) != 0) {
+                            if (isBigFile) {
+                                break;
+                            } else {
+                                bigFiles.add(active);
+                                active = null;
+                                state &= ~MEMORY_LOW;
+                            }
+                        } else {
+                            state |= MEMORY_LOW;
+                        }
+                        freeMemory(true);
+                        continue;
+                    }
+                    Iterable<? extends Element> types;
+                    types = jt.enterTrees(trees);
+                    if (jfo2tuples.remove(active.jfo) != null) {
+                        final Types ts = Types.instance(jt.getContext());
+                        final Indexable activeIndexable = active.indexable;
+                        class ScanNested extends TreeScanner {
+                            Set<CompileTuple> dependencies = new LinkedHashSet<CompileTuple>();
+                            @Override
+                            public void visitClassDef(JCClassDecl node) {
+                                if (node.sym != null) {
+                                    Type st = ts.supertype(node.sym.type);
+                                    boolean envForSuperTypeFound = false;
+                                    while (!envForSuperTypeFound && st != null && st.hasTag(TypeTag.CLASS)) {
+                                        ClassSymbol c = st.tsym.outermostClass();
+                                        CompileTuple u = jfo2tuples.get(c.sourcefile);
+                                        if (u != null && !previous.finishedFiles.contains(u.indexable) && !u.indexable.equals(activeIndexable)) {
+                                            dependencies.add(u);
+                                            envForSuperTypeFound = true;
+                                        }
+                                        st = ts.supertype(st);
+                                    }
+                                }
+                                super.visitClassDef(node);
+                            }
+                        }
+                        ScanNested scanner = new ScanNested();
+                        for (CompilationUnitTree cut : trees) {
+                            scanner.scan((JCCompilationUnit)cut);
+                        }
+                        if (!scanner.dependencies.isEmpty()) {
+                            toProcess.addFirst(active);
+                            for (CompileTuple tuple : scanner.dependencies) {
+                                toProcess.addFirst(tuple);
+                            }
+                            active = null;
+                            continue;
+                        }
+                    }
+                    if (isLowMemory(flm)) {
+                        dumpSymFiles(jt, previous.createdFiles, context);
+                        jt = null;
+                        diagnosticListener.cleanDiagnostics();
+                        trees = null;
+                        types = null;
+                        if ((state & MEMORY_LOW) != 0) {
+                            if (isBigFile) {
+                                break;
+                            } else {
+                                bigFiles.add(active);
+                                active = null;
+                                state &= ~MEMORY_LOW;
+                            }
+                        } else {
+                            state |= MEMORY_LOW;
+                        }
+                        freeMemory(true);
+                        continue;
+                    }
+                    jt.analyze(types);
+                    if (aptEnabled) {
+                        JavaCustomIndexer.addAptGenerated(context, javaContext, active, previous.aptGenerated);
+                    }
+                    if (isLowMemory(flm)) {
+                        dumpSymFiles(jt, previous.createdFiles, context);
+                        jt = null;
+                        diagnosticListener.cleanDiagnostics();
+                        trees = null;
+                        types = null;
+                        if ((state & MEMORY_LOW) != 0) {
+                            if (isBigFile) {
+                                break;
+                            } else {
+                                bigFiles.add(active);
+                                active = null;
+                                state &= ~MEMORY_LOW;
+                            }
+                        } else {
+                            state |= MEMORY_LOW;
+                        }
+                        freeMemory(true);
+                        continue;
+                    }
+                    javaContext.getFQNs().set(types, active.indexable.getURL());
+                    boolean[] main = new boolean[1];
+                    if (javaContext.getCheckSums().checkAndSet(
+                            active.indexable.getURL(),
+                            StreamSupport.stream(types.spliterator(), false)
+                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
+                                .map ((e) -> (TypeElement)e)
+                                .collect(Collectors.toList()),
+                            jt.getElements()) || context.isSupplementaryFilesIndexing()) {
+                        javaContext.analyze(trees, jt, active, previous.addedTypes, previous.addedModules, main);
+                    } else {
+                        final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
+                        javaContext.analyze(trees, jt, active, aTypes, previous.addedModules, main);
+                        previous.addedTypes.addAll(aTypes);
+                        previous.modifiedTypes.addAll(aTypes);
+                    }
+                    ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
+                    JavaCustomIndexer.setErrors(context, active, diagnosticListener);
+                    Iterable<? extends JavaFileObject> generatedFiles = jt.generate(types);
+                    if (!active.virtual) {
+                        for (JavaFileObject generated : generatedFiles) {
+                            if (generated instanceof FileObjects.FileBase) {
+                                previous.createdFiles.add(((FileObjects.FileBase) generated).getFile());
+                            } else {
+                                // presumably should not happen
+                            }
+                        }
+                    }
+                    if (!moduleName.assigned) {
+                        ModuleElement module = trees.iterator().hasNext() ?
+                            ((JCTree.JCCompilationUnit)trees.iterator().next()).modle :
+                            null;
+                        if (module == null) {
+                            module = module = Modules.instance(jt.getContext()).getDefaultModule();
+                        }
+                        moduleName.name = module == null || module.isUnnamed() ?
+                                null :
+                                module.getQualifiedName().toString();
+                        moduleName.assigned = true;
+                    }
+                    Log.instance(jt.getContext()).nerrors = 0;
+                    previous.finishedFiles.add(active.indexable);
+                    active = null;
+                    state  = 0;
+                } catch (CancelAbort ca) {
+                    if (isLowMemory(flm)) {
+                        dumpSymFiles(jt, previous.createdFiles, context);
+                        jt = null;
+                        diagnosticListener.cleanDiagnostics();
+                        if ((state & MEMORY_LOW) != 0) {
+                            if (isBigFile) {
+                                break;
+                            } else {
+                                bigFiles.add(active);
+                                active = null;
+                                state &= ~MEMORY_LOW;
+                            }
+                        } else {
+                            state |= MEMORY_LOW;
+                        }
+                        freeMemory(true);
+                    } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                        JavaIndex.LOG.log(Level.FINEST, "OnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+                    }
+                }
+            } catch (CouplingAbort ca) {
+                //Coupling error
+//                TreeLoader.dumpCouplingAbort(ca, null);
+                jt = null;
+                diagnosticListener.cleanDiagnostics();
+                if ((state & ERR) != 0) {
+                    //When a javac failed with the Exception mark a file
+                    //causing this exceptin as compiled
+                    if (active != null)
+                        previous.finishedFiles.add(active.indexable);
+                    active = null;
+                    state = 0;
+                } else {
+                    state |= ERR;
+                }
+            } catch (OutputFileManager.InvalidSourcePath isp) {
+                //Deleted project - log & ignore
+                if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                    final String message = String.format("MultiPassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                active.jfo.toUri().toString(),
+                                FileUtil.getFileDisplayName(context.getRoot()),
+                                bootPath == null   ? null : bootPath.toString(),
+                                classPath == null  ? null : classPath.toString(),
+                                sourcePath == null ? null : sourcePath.toString()
+                                );
+                    JavaIndex.LOG.log(Level.FINEST, message, isp);
+                }
+                return ParsingOutput.failure(moduleName.name, previous.file2FQNs,
+                        previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
+                        previous.modifiedTypes, previous.aptGenerated);
+            } catch (MissingPlatformError mpe) {
+                //No platform - log & mark files as errornous
+                if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                    final String message = String.format("MultiPassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                active.jfo.toUri().toString(),
+                                FileUtil.getFileDisplayName(context.getRoot()),
+                                bootPath == null   ? null : bootPath.toString(),
+                                classPath == null  ? null : classPath.toString(),
+                                sourcePath == null ? null : sourcePath.toString()
+                                );
+                    JavaIndex.LOG.log(Level.FINEST, message, mpe);
+                }
+                JavaCustomIndexer.brokenPlatform(context, files, mpe.getDiagnostic());
+                return ParsingOutput.failure(moduleName.name, previous.file2FQNs,
+                        previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
+                        previous.modifiedTypes, previous.aptGenerated);
+            } catch (Throwable t) {
+                if (t instanceof ThreadDeath) {
+                    throw (ThreadDeath) t;
+                }
+                else {
+                    Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
+                    if (JavaIndex.LOG.isLoggable(level)) {
+                        final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                        final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                        final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                        final String message = String.format("MultiPassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                    active == null ? null : active.jfo.toUri().toString(),
+                                    FileUtil.getFileDisplayName(context.getRoot()),
+                                    bootPath == null ? null : bootPath.toString(),
+                                    classPath == null ? null : classPath.toString(),
+                                    sourcePath == null ? null : sourcePath.toString()
+                                    );
+                        JavaIndex.LOG.log(level, message, t);  //NOI18N
+                    }
+                    jt = null;
+                    diagnosticListener.cleanDiagnostics();
+                    if ((state & ERR) != 0) {
+                        //When a javac failed with the Exception mark a file
+                        //causing this exceptin as compiled
+                        if (active != null)
+                            previous.finishedFiles.add(active.indexable);
+                        active = null;
+                        state = 0;
+                    } else {
+                        state |= ERR;
+                    }
+                }
+            }
+        }
+        return (state & MEMORY_LOW) == 0?
+            ParsingOutput.success(moduleName.name, previous.file2FQNs,
+                    previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
+                    previous.modifiedTypes, previous.aptGenerated):
+            ParsingOutput.lowMemory(moduleName.name, previous.file2FQNs,
+                    previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
+                    previous.modifiedTypes, previous.aptGenerated);
+    }
+
+    private void dumpSymFiles(
+            final JavacTaskImpl jti,
+            final Set<File> alreadyCreated,
+            final Context ctx) throws IOException {
+        if (jti != null) {
+            final JavaFileManager jfm = jti.getContext().get(JavaFileManager.class);
+            checkForMemLow = false;
+            try {
+                final Types types = Types.instance(jti.getContext());
+                final Enter enter = Enter.instance(jti.getContext());
+                final Symtab syms = Symtab.instance(jti.getContext());
+                final HashMap<ClassSymbol, JCClassDecl> syms2trees = new HashMap<>();
+                class ScanNested extends TreeScanner {
+                    private Env<AttrContext> env;
+                    private Set<Env<AttrContext>> checked = new HashSet<Env<AttrContext>>();
+                    private List<Env<AttrContext>> dependencies = new LinkedList<Env<AttrContext>>();
+                    public ScanNested(Env<AttrContext> env) {
+                        this.env = env;
+                    }
+                    @Override
+                    public void visitClassDef(JCClassDecl node) {
+                        if (node.sym != null) {
+                            Type st = types.supertype(node.sym.type);
+                            boolean envForSuperTypeFound = false;
+                            while (!envForSuperTypeFound && st != null && st.hasTag(TypeTag.CLASS)) {
+                                ClassSymbol c = st.tsym.outermostClass();
+                                Env<AttrContext> stEnv = enter.getEnv(c);
+                                if (stEnv != null && env != stEnv) {
+                                    if (checked.add(stEnv)) {
+                                        scan(stEnv.tree);
+//                                        if (TreeLoader.pruneTree(stEnv.tree, syms, syms2trees))
+//                                            dependencies.add(stEnv);
+                                    }
+                                    envForSuperTypeFound = true;
+                                }
+                                st = types.supertype(st);
+                            }
+                        }
+                        super.visitClassDef(node);
+                    }
+                }
+                final Set<Env<AttrContext>> processedEnvs = new HashSet<Env<AttrContext>>();
+                File classes = JavaIndex.getClassFolder(ctx);
+                for (Env<AttrContext> env : jti.getTodo()) {
+                    if (processedEnvs.add(env)) {
+                        ScanNested scanner = new ScanNested(env);
+                        scanner.scan(env.tree);
+                        for (Env<AttrContext> dep: scanner.dependencies) {
+                            if (processedEnvs.add(dep)) {
+                                dumpSymFile(jfm, jti, dep.enclClass.sym, alreadyCreated, classes, syms2trees);
+                            }
+                        }
+//                        if (TreeLoader.pruneTree(env.tree, syms, syms2trees))
+//                            dumpSymFile(jfm, jti, env.enclClass.sym, alreadyCreated, classes, syms2trees);
+                    }
+                }
+            } finally {
+                checkForMemLow = true;
+            }
+        }
+    }
+    
+    private void dumpSymFile(
+            @NonNull final JavaFileManager jfm,
+            @NonNull final JavacTaskImpl jti,
+            @NullAllowed final ClassSymbol cs,
+            @NonNull final Set<File> alreadyCreated,
+            @NonNull final File classes,
+            @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
+        if (cs == null) {
+            //ClassDecl has no symbol because compilation was cancelled
+            //by low memory before ENTER done.
+            return;
+        }        
+        JavaFileObject file = jfm.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT,
+                cs.flatname.toString(), JavaFileObject.Kind.CLASS, cs.sourcefile);
+        if (file instanceof FileObjects.FileBase && !alreadyCreated.contains(((FileObjects.FileBase)file).getFile())) {
+//            TreeLoader.dumpSymFile(jfm, jti, cs, classes, syms2trees);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java
new file mode 100644
index 0000000..1029796
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.util.List;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileWorkerProvider;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service=JavaCustomIndexer.CompileWorkerProvider.class, position=100)
+public class NBJavacCompileWorkerProvider implements CompileWorkerProvider {
+
+    private static final int TRESHOLD = 500;
+
+    @Override
+    public CompileWorker[] getWorkers(List<CompileTuple> toCompile) {
+        return new CompileWorker[] {
+            toCompile.size() < TRESHOLD ? new SuperOnePassCompileWorker() : new OnePassCompileWorker(),
+            new MultiPassCompileWorker()
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java
new file mode 100644
index 0000000..874378c
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java
@@ -0,0 +1,379 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.tools.javac.api.ClassNamesForFileOraculum;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.TypeTag;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.CouplingAbort;
+import com.sun.tools.javac.util.FatalError;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.MissingPlatformError;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+import javax.annotation.processing.Processor;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.lib.nbjavac.services.CancelAbort;
+import org.netbeans.lib.nbjavac.services.CancelService;
+//import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.indexing.APTUtils;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.DiagnosticListenerImpl;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.java.source.indexing.SourcePrefetcher;
+import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
+import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.OutputFileManager;
+//import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
+import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.Indexable;
+import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+import org.openide.util.Pair;
+
+/**
+ *
+ * @author Jan Lahoda, Dusan Balek
+ */
+final class OnePassCompileWorker extends CompileWorker {
+
+    @Override
+    protected ParsingOutput compile(
+            final ParsingOutput previous,
+            final Context context,
+            final JavaParsingContext javaContext,
+            final Collection<? extends CompileTuple> files) {
+        final Map<JavaFileObject, List<String>> file2FQNs = previous != null ? previous.file2FQNs : new HashMap<>();
+        final Set<ElementHandle<TypeElement>> addedTypes = previous != null ? previous.addedTypes : new HashSet<>();
+        final Set<ElementHandle<ModuleElement>> addedModules = previous != null ? previous.addedModules : new HashSet<>();
+        final Set<File> createdFiles = previous != null ? previous.createdFiles : new HashSet<>();
+        final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
+        final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
+        final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
+        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(file2FQNs);
+
+        final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
+        final HashMap<JavaFileObject, Pair<CompilationUnitTree, CompileTuple>> jfo2units = new HashMap<JavaFileObject, Pair<CompilationUnitTree, CompileTuple>>();
+        LinkedList<Pair<CompilationUnitTree, CompileTuple>> units = new LinkedList<Pair<CompilationUnitTree, CompileTuple>>();
+        JavacTaskImpl jt = null;
+
+        boolean nop = true;
+        final SuspendStatus suspendStatus = context.getSuspendStatus();
+        final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus);
+        try {
+            while (sourcePrefetcher.hasNext())  {
+                final CompileTuple tuple = sourcePrefetcher.next();
+                try {
+                    if (tuple != null) {
+                        nop = false;
+                        if (context.isCancelled()) {
+                            return null;
+                        }
+                        try {
+                            if (isLowMemory(null)) {
+                                jt = null;
+                                units = null;
+                                jfo2units.clear();
+                                dc.cleanDiagnostics();
+                                freeMemory(false);
+                            }
+                            if (jt == null) {
+                                jt = JavacParser.createJavacTask(
+                                    javaContext.getClasspathInfo(),
+                                    dc,
+                                    javaContext.getSourceLevel(),
+                                    javaContext.getProfile(),
+                                    javaContext.getFQNs(),
+                                    new CancelService() {
+                                        public @Override boolean isCanceled() {
+                                            return context.isCancelled() || isLowMemory(null);
+                                        }
+                                    },
+                                    tuple.aptGenerated ? null : APTUtils.get(context.getRoot()),
+                                    CompilerOptionsQuery.getOptions(context.getRoot()),
+                                    Collections.emptyList());
+                                jt.getContext().put(ClassNamesForFileOraculum.class, cnffOraculum);
+                            }
+                            for (CompilationUnitTree cut : jt.parse(tuple.jfo)) { //TODO: should be exactly one
+                                if (units != null) {
+                                    Pair<CompilationUnitTree, CompileTuple> unit = Pair.<CompilationUnitTree, CompileTuple>of(cut, tuple);
+                                    units.add(unit);
+                                    jfo2units.put(tuple.jfo, unit);
+                                }
+                                computeFQNs(file2FQNs, cut, tuple);
+                            }
+                            Log.instance(jt.getContext()).nerrors = 0;
+                        } catch (CancelAbort ca) {
+                            if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                                JavaIndex.LOG.log(Level.FINEST, "OnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+                            }
+                        } catch (Throwable t) {
+                            if (JavaIndex.LOG.isLoggable(Level.WARNING)) {
+                                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                                final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                            tuple.indexable.getURL().toString(),
+                                            FileUtil.getFileDisplayName(context.getRoot()),
+                                            bootPath == null   ? null : bootPath.toString(),
+                                            classPath == null  ? null : classPath.toString(),
+                                            sourcePath == null ? null : sourcePath.toString()
+                                            );
+                                JavaIndex.LOG.log(Level.WARNING, message, t);  //NOI18N
+                            }
+                            if (t instanceof ThreadDeath) {
+                                throw (ThreadDeath) t;
+                            } else {
+                                jt = null;
+                                units = null;
+                                dc.cleanDiagnostics();
+                                freeMemory(false);
+                            }
+                        }
+                    }
+                } finally {
+                    sourcePrefetcher.remove();
+                }
+            }
+        } finally {
+            try {
+                sourcePrefetcher.close();
+            } catch (IOException ioe) {
+                Exceptions.printStackTrace(ioe);
+            }
+        }
+        final ModuleName moduleName = new ModuleName(javaContext.getModuleName());
+        if (nop) {
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+
+        if (units == null || JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER) {
+            return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+
+        CompileTuple active = null;
+        final boolean aptEnabled = Optional.ofNullable(jt)
+                .map((jtask) -> jtask.getProcessors())
+                .map((it) -> it.iterator().hasNext())
+                .orElse(Boolean.FALSE);
+        final boolean[] flm = {true};
+        try {
+            final Queue<Future<Void>> barriers = new ArrayDeque<>();
+            while(!units.isEmpty()) {
+                if (context.isCancelled()) {
+                    return null;
+                }
+                final Pair<CompilationUnitTree, CompileTuple> unit = units.removeFirst();
+                active = unit.second();
+                if (finished.contains(active.indexable)) {
+                    continue;
+                }
+                if (isLowMemory(flm)) {
+                    return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+                }
+                final Iterable<? extends Element> types = jt.enterTrees(Collections.singletonList(unit.first()));
+                if (jfo2units.remove(active.jfo) != null) {
+                    final Types ts = Types.instance(jt.getContext());
+                    final Indexable activeIndexable = active.indexable;
+                    class ScanNested extends TreeScanner {
+                        Set<Pair<CompilationUnitTree, CompileTuple>> dependencies = new LinkedHashSet<Pair<CompilationUnitTree, CompileTuple>>();
+                        @Override
+                        public void visitClassDef(JCClassDecl node) {
+                            if (node.sym != null) {
+                                Type st = ts.supertype(node.sym.type);
+                                boolean envForSuperTypeFound = false;
+                                while (!envForSuperTypeFound && st != null && st.hasTag(TypeTag.CLASS)) {
+                                    ClassSymbol c = st.tsym.outermostClass();
+                                    Pair<CompilationUnitTree, CompileTuple> u = jfo2units.remove(c.sourcefile);
+                                    if (u != null && !finished.contains(u.second().indexable) && !u.second().indexable.equals(activeIndexable)) {
+                                        if (dependencies.add(u)) {
+                                            scan((JCCompilationUnit)u.first());
+                                        }
+                                        envForSuperTypeFound = true;
+                                    }
+                                    st = ts.supertype(st);
+                                }
+                            }
+                            super.visitClassDef(node);
+                        }
+                    }
+                    ScanNested scanner = new ScanNested();
+                    scanner.scan((JCCompilationUnit)unit.first());
+                    if (!scanner.dependencies.isEmpty()) {
+                        units.addFirst(unit);
+                        for (Pair<CompilationUnitTree, CompileTuple> pair : scanner.dependencies) {
+                            units.addFirst(pair);
+                        }
+                        continue;
+                    }
+                }
+                if (isLowMemory(flm)) {
+                    return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+                }
+                jt.analyze(types);
+                if (aptEnabled) {
+                    JavaCustomIndexer.addAptGenerated(context, javaContext, active, aptGenerated);
+                }
+                if (isLowMemory(flm)) {
+                    return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+                }
+                javaContext.getFQNs().set(types, active.indexable.getURL());
+                boolean[] main = new boolean[1];
+                if (javaContext.getCheckSums().checkAndSet(
+                        active.indexable.getURL(),
+                        StreamSupport.stream(types.spliterator(), false)
+                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
+                                .map ((e) -> (TypeElement)e)
+                                .collect(Collectors.toList()),
+                        jt.getElements()) || context.isSupplementaryFilesIndexing()) {
+                    javaContext.analyze(Collections.singleton(unit.first()), jt, unit.second(), addedTypes, addedModules, main);
+                } else {
+                    final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
+                    javaContext.analyze(Collections.singleton(unit.first()), jt, unit.second(), aTypes, addedModules, main);
+                    addedTypes.addAll(aTypes);
+                    modifiedTypes.addAll(aTypes);
+                }
+                ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
+                JavaCustomIndexer.setErrors(context, active, dc);
+                final boolean virtual = active.virtual;
+                final JavacTaskImpl jtFin = jt;
+                barriers.offer(FileManagerTransaction.runConcurrent(new FileSystem.AtomicAction(){
+                    @Override
+                    public void run() throws IOException {
+                        Iterable<? extends JavaFileObject> generatedFiles = jtFin.generate(types);
+                        if (!virtual) {
+                            for (JavaFileObject generated : generatedFiles) {
+                                if (generated instanceof FileObjects.FileBase) {
+                                    createdFiles.add(((FileObjects.FileBase) generated).getFile());
+                                } else {
+                                    // presumably should not happen
+                                }
+                            }
+                        }
+                        if (!moduleName.assigned) {
+                            ModuleElement module = ((JCTree.JCCompilationUnit)unit.first()).modle;
+                            if (module == null) {
+                                module = Modules.instance(jtFin.getContext()).getDefaultModule();
+                            }
+                            moduleName.name = module == null || module.isUnnamed() ?
+                                null :
+                                module.getQualifiedName().toString();
+                            moduleName.assigned = true;
+                        }
+                    }
+                }));
+                Log.instance(jt.getContext()).nerrors = 0;
+                finished.add(active.indexable);
+            }
+            for (Future<Void> barrier : barriers) {
+                barrier.get();
+            }
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        } catch (CouplingAbort ca) {
+            //Coupling error
+//            TreeLoader.dumpCouplingAbort(ca, null);
+        } catch (OutputFileManager.InvalidSourcePath isp) {
+            //Deleted project - log & ignore
+            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            active.jfo.toUri().toString(),
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.FINEST, message, isp);
+            }
+        } catch (MissingPlatformError mpe) {
+            //No platform - log & mark files as errornous
+            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            active.jfo.toUri().toString(),
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.FINEST, message, mpe);
+            }
+            JavaCustomIndexer.brokenPlatform(context, files, mpe.getDiagnostic());
+        } catch (CancelAbort ca) {
+            if (isLowMemory(flm)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                JavaIndex.LOG.log(Level.FINEST, "OnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+            }
+        } catch (Throwable t) {
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            } else {
+                Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
+                if (JavaIndex.LOG.isLoggable(level)) {
+                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                    final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                active.jfo.toUri().toString(),
+                                FileUtil.getFileDisplayName(context.getRoot()),
+                                bootPath == null   ? null : bootPath.toString(),
+                                classPath == null  ? null : classPath.toString(),
+                                sourcePath == null ? null : sourcePath.toString()
+                                );
+                    JavaIndex.LOG.log(level, message, t);  //NOI18N
+                }
+            }
+        }
+        return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java
new file mode 100644
index 0000000..d9ece60
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java
@@ -0,0 +1,381 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.PackageTree;
+import com.sun.source.tree.Tree;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
+import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
+import org.netbeans.lib.nbjavac.services.CancelAbort;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import com.sun.tools.javac.util.CouplingAbort;
+import com.sun.tools.javac.util.FatalError;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.MissingPlatformError;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+import javax.annotation.processing.Processor;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.ElementHandle;
+//import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.indexing.APTUtils;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.DiagnosticListenerImpl;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.java.source.indexing.SourcePrefetcher;
+import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
+import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.OutputFileManager;
+//import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
+import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.Indexable;
+import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+/**
+ *
+ * @author Dusan Balek
+ */
+final class SuperOnePassCompileWorker extends CompileWorker {
+
+    @Override
+    protected ParsingOutput compile(
+            final ParsingOutput previous,
+            final Context context,
+            final JavaParsingContext javaContext,
+            final Collection<? extends CompileTuple> files) {
+        final Map<JavaFileObject, List<String>> file2FQNs = previous != null ? previous.file2FQNs : new HashMap<>();
+        final Set<ElementHandle<TypeElement>> addedTypes = previous != null ? previous.addedTypes : new HashSet<>();
+        final Set<ElementHandle<ModuleElement>> addedModules = previous != null ? previous.addedModules : new HashSet<>();
+        final Set<File> createdFiles = previous != null ? previous.createdFiles : new HashSet<>();
+        final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
+        final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
+        final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
+//        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(file2FQNs);
+
+        final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
+        final LinkedList<CompilationUnitTree> trees = new LinkedList<CompilationUnitTree>();
+        Map<CompilationUnitTree, CompileTuple> units = new IdentityHashMap<CompilationUnitTree, CompileTuple>();
+        JavacTaskImpl jt = null;
+
+        boolean nop = true;
+        final SuspendStatus suspendStatus = context.getSuspendStatus();
+        final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus);
+        try {
+            final boolean flm[] = {true};
+            while (sourcePrefetcher.hasNext())  {
+                final CompileTuple tuple = sourcePrefetcher.next();
+                try {
+                    if (tuple != null) {
+                        nop = false;
+                        if (context.isCancelled()) {
+                            return null;
+                        }
+                        try {
+                            if (isLowMemory(flm)) {
+                                jt = null;
+                                units = null;
+                                trees.clear();
+                                dc.cleanDiagnostics();
+                                freeMemory(false);
+                            }
+                            if (jt == null) {
+                                jt = JavacParser.createJavacTask(
+                                    javaContext.getClasspathInfo(),
+                                    dc,
+                                    javaContext.getSourceLevel(),
+                                    javaContext.getProfile(),
+                                    javaContext.getFQNs(),
+                                    new CancelService() {
+                                        public @Override boolean isCanceled() {
+                                            return context.isCancelled() || isLowMemory(null);
+                                        }
+                                    },
+                                    tuple.aptGenerated ? null : APTUtils.get(context.getRoot()),
+                                    CompilerOptionsQuery.getOptions(context.getRoot()),
+                                    Collections.emptyList());
+                            }
+                            for (CompilationUnitTree cut : jt.parse(tuple.jfo)) { //TODO: should be exactly one
+                                if (units != null) {
+                                    trees.add(cut);
+                                    units.put(cut, tuple);
+                                }
+                                computeFQNs(file2FQNs, cut, tuple);
+                            }
+                            Log.instance(jt.getContext()).nerrors = 0;
+                        } catch (CancelAbort ca) {
+                            if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                                JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+                            }
+                        } catch (Throwable t) {
+                            if (JavaIndex.LOG.isLoggable(Level.WARNING)) {
+                                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                                final String message = String.format("SuperOnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                            tuple.indexable.getURL().toString(),
+                                            FileUtil.getFileDisplayName(context.getRoot()),
+                                            bootPath == null   ? null : bootPath.toString(),
+                                            classPath == null  ? null : classPath.toString(),
+                                            sourcePath == null ? null : sourcePath.toString()
+                                            );
+                                JavaIndex.LOG.log(Level.WARNING, message, t);  //NOI18N
+                            }
+                            if (t instanceof ThreadDeath) {
+                                throw (ThreadDeath) t;
+                            } else {
+                                jt = null;
+                                units = null;
+                                dc.cleanDiagnostics();
+                                freeMemory(false);
+                            }
+                        }
+                    }
+                }  finally {
+                    sourcePrefetcher.remove();
+                }
+            }
+        } finally {
+            try {
+                sourcePrefetcher.close();
+            } catch (IOException ex) {
+                Exceptions.printStackTrace(ex);
+            }
+        }
+        ModuleName moduleName = new ModuleName(javaContext.getModuleName());
+        if (nop) {
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        if (jt == null || units == null || JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER) {
+            return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        if (context.isCancelled()) {
+            return null;
+        }
+        if (isLowMemory(null)) {
+            return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        Iterable<? extends Processor> processors = jt.getProcessors();
+        boolean aptEnabled = processors != null && processors.iterator().hasNext();
+        try {
+            final Iterable<? extends Element> types = jt.enter(trees);
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            final Map<Element, CompileTuple> clazz2Tuple = new IdentityHashMap<Element, CompileTuple>();
+            Enter enter = Enter.instance(jt.getContext());
+            for (Element type : types) {
+                if (type.getKind().isClass() || type.getKind().isInterface() || type.getKind() == ElementKind.MODULE) {
+                    Env<AttrContext> typeEnv = enter.getEnv((TypeSymbol) type);
+                    if (typeEnv == null) {
+                        JavaIndex.LOG.log(Level.FINE, "No Env for: {0}", ((TypeSymbol) type).getQualifiedName());
+                        continue;
+                    }
+                    clazz2Tuple.put(type, units.get(typeEnv.toplevel));
+                }
+            }
+            jt.analyze(types);
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
+                CompileTuple active = unit.getValue();
+                if (aptEnabled) {
+                    JavaCustomIndexer.addAptGenerated(context, javaContext, active, aptGenerated);
+                }
+                List<Element> activeTypes = new ArrayList<>();
+                if (unit.getValue().jfo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
+                    final PackageTree pt = unit.getKey().getPackage();
+                    if (pt instanceof JCPackageDecl) {                        
+                        final Element sym = ((JCPackageDecl)pt).packge;
+                        if (sym != null)
+                            activeTypes.add(sym);
+                    }
+                } else {
+                    for (Tree tree : unit.getKey().getTypeDecls()) {
+                        if (tree instanceof JCTree) {
+                            final JCTree jct = (JCTree)tree;
+                            if (jct.getTag() == JCTree.Tag.CLASSDEF) {
+                                final Element sym = ((JCClassDecl)tree).sym;
+                                if (sym != null)
+                                    activeTypes.add(sym);
+                            } else if (jct.getTag() == JCTree.Tag.MODULEDEF) {
+                                final Element sym = ((JCModuleDecl)tree).sym;
+                                if (sym != null)
+                                    activeTypes.add(sym);
+                            }
+                        }
+                    }
+                }
+                javaContext.getFQNs().set(activeTypes, active.indexable.getURL());
+                boolean[] main = new boolean[1];
+                if (javaContext.getCheckSums().checkAndSet(
+                        active.indexable.getURL(),
+                        activeTypes.stream()                                                
+                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
+                                .map ((e) -> (TypeElement)e)
+                                .collect(Collectors.toList()),
+                        jt.getElements()) || context.isSupplementaryFilesIndexing()) {
+                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, addedTypes, addedModules, main);
+                } else {
+                    final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
+                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, aTypes, addedModules, main);
+                    addedTypes.addAll(aTypes);
+                    modifiedTypes.addAll(aTypes);
+                }
+                ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
+                JavaCustomIndexer.setErrors(context, active, dc);
+            }
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            final JavacTaskImpl jtFin = jt;
+            final Future<Void> done = FileManagerTransaction.runConcurrent(new FileSystem.AtomicAction() {
+                @Override
+                public void run() throws IOException {
+                    for (Element type : types) {
+                        Iterable<? extends JavaFileObject> generatedFiles = jtFin.generate(Collections.singletonList(type));
+                        CompileTuple unit = clazz2Tuple.get(type);
+                        if (unit == null || !unit.virtual) {
+                            for (JavaFileObject generated : generatedFiles) {
+                                if (generated instanceof FileObjects.FileBase) {
+                                    createdFiles.add(((FileObjects.FileBase) generated).getFile());
+                                } else {
+                                    // presumably should not happen
+                                }
+                            }
+                        }
+                    }
+                    if (!moduleName.assigned) {
+                        ModuleElement module = !trees.isEmpty() ?
+                            ((JCTree.JCCompilationUnit)trees.getFirst()).modle :
+                            null;
+                        if (module == null) {
+                            module = Modules.instance(jtFin.getContext()).getDefaultModule();
+                        }
+                        moduleName.name = module == null || module.isUnnamed() ?
+                            null :
+                            module.getQualifiedName().toString();
+                        moduleName.assigned = true;
+                    }
+                }
+            });
+            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
+                finished.add(unit.getValue().indexable);
+            }
+            done.get();
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        } catch (CouplingAbort ca) {
+            //Coupling error
+//            TreeLoader.dumpCouplingAbort(ca, null);
+        } catch (OutputFileManager.InvalidSourcePath isp) {
+            //Deleted project - log & ignore
+            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.FINEST, message, isp);
+            }
+        } catch (MissingPlatformError mpe) {
+            //No platform - log & mark files as errornous
+            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.FINEST, message, mpe);
+            }
+            JavaCustomIndexer.brokenPlatform(context, files, mpe.getDiagnostic());
+        } catch (CancelAbort ca) {
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+            }
+        } catch (Throwable t) {
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            } else {
+                Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
+                if (JavaIndex.LOG.isLoggable(level)) {
+                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                    final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                FileUtil.getFileDisplayName(context.getRoot()),
+                                bootPath == null   ? null : bootPath.toString(),
+                                classPath == null  ? null : classPath.toString(),
+                                sourcePath == null ? null : sourcePath.toString()
+                                );
+                    JavaIndex.LOG.log(level, message, t);  //NOI18N
+                }
+            }
+        }
+        return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java
new file mode 100644
index 0000000..5017958
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import java.util.HashSet;
+import java.util.Set;
+import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
+
+/**
+ * Partial reparse helper visitor.
+ * Finds anonymous and local classes in given method tree.
+ * @author Tomas Zezula
+ */
+class FindAnonymousVisitor extends ErrorAwareTreeScanner<Void,Void> {
+
+    private static enum Mode {COLLECT, CHECK};
+
+    int firstInner = -1;
+    int noInner;
+    boolean hasLocalClass;
+    final Set<Tree> docOwners = new HashSet<Tree>();
+    private Mode mode = Mode.COLLECT;            
+    
+    public final void reset () {
+        this.firstInner = -1;
+        this.noInner = 0;
+        this.hasLocalClass = false;
+        this.mode = Mode.CHECK;
+    }
+
+    @Override
+    public Void visitClass(ClassTree node, Void p) {
+        if (firstInner == -1) {
+            firstInner = ((IndexedClassDecl)node).index;
+        }
+        if (node.getSimpleName().length() != 0) {
+            hasLocalClass = true;
+        }
+        noInner++;
+        handleDoc(node);
+        return super.visitClass(node, p);
+    }
+
+    @Override
+    public Void visitMethod(MethodTree node, Void p) {
+        handleDoc(node);
+        return super.visitMethod(node, p);
+    }
+
+    @Override
+    public Void visitVariable(VariableTree node, Void p) {
+        handleDoc(node);
+        return super.visitVariable(node, p);
+    }
+
+    private void handleDoc (final Tree tree) {
+        if (mode == Mode.COLLECT) {
+            docOwners.add(tree);
+        }
+    }
+
+}


[09/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java
deleted file mode 100644
index b832607..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.indexing;
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.TypeTag;
-import com.sun.tools.javac.code.Types;
-import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.Enter;
-import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.comp.Modules;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.tree.TreeScanner;
-import org.netbeans.lib.nbjavac.services.CancelAbort;
-import org.netbeans.lib.nbjavac.services.CancelService;
-import com.sun.tools.javac.util.CouplingAbort;
-import com.sun.tools.javac.util.FatalError;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.MissingPlatformError;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-import javax.annotation.processing.Processor;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-import org.netbeans.api.annotations.common.NonNull;
-import org.netbeans.api.annotations.common.NullAllowed;
-import org.netbeans.api.java.classpath.ClassPath;
-import org.netbeans.api.java.queries.CompilerOptionsQuery;
-import org.netbeans.api.java.source.ClasspathInfo;
-import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.modules.java.source.TreeLoader;
-import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
-import org.netbeans.modules.java.source.parsing.FileObjects;
-import org.netbeans.modules.java.source.parsing.JavacParser;
-import org.netbeans.modules.java.source.parsing.OutputFileManager;
-import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
-import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
-import org.netbeans.modules.parsing.spi.indexing.Context;
-import org.netbeans.modules.parsing.spi.indexing.Indexable;
-import org.openide.filesystems.FileUtil;
-
-/**
- *
- * @author Dusan Balek
- */
-final class MultiPassCompileWorker extends CompileWorker {
-
-    private static final int MEMORY_LOW = 1;
-    private static final int ERR = 2;
-    private boolean checkForMemLow = true;
-
-    @Override
-    ParsingOutput compile(
-            final ParsingOutput previous,
-            final Context context,
-            final JavaParsingContext javaContext,
-            final Collection<? extends CompileTuple> files) {
-        final LinkedList<CompileTuple> toProcess = new LinkedList<>();
-        final HashMap<JavaFileObject, CompileTuple> jfo2tuples = new HashMap<>();
-        final ModuleName moduleName = new ModuleName(javaContext.getModuleName());
-        for (CompileTuple i : files) {
-            if (!previous.finishedFiles.contains(i.indexable)) {
-                toProcess.add(i);
-                jfo2tuples.put(i.jfo, i);
-            }
-        }
-        if (toProcess.isEmpty()) {
-            return ParsingOutput.success(
-                    moduleName.name,
-                    previous.file2FQNs,
-                    previous.addedTypes,
-                    previous.addedModules,
-                    previous.createdFiles,
-                    previous.finishedFiles,
-                    previous.modifiedTypes,
-                    previous.aptGenerated);
-        }
-        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(previous.file2FQNs);
-        final DiagnosticListenerImpl diagnosticListener = new DiagnosticListenerImpl();
-        final LinkedList<CompileTuple> bigFiles = new LinkedList<CompileTuple>();
-        JavacTaskImpl jt = null;
-        CompileTuple active = null;
-        boolean aptEnabled = false;
-        int state = 0;
-        boolean isBigFile = false;
-        boolean[] flm = null;        
-        while (!toProcess.isEmpty() || !bigFiles.isEmpty() || active != null) {
-            if (context.isCancelled()) {
-                return null;
-            }
-            try {
-                context.getSuspendStatus().parkWhileSuspended();
-            } catch (InterruptedException ex) {
-                //NOP - safe to ignore
-            }
-            try {
-                try {
-                    if (isLowMemory(flm)) {
-                        dumpSymFiles(jt, previous.createdFiles, context);
-                        jt = null;
-                        diagnosticListener.cleanDiagnostics();
-                        if ((state & MEMORY_LOW) != 0) {
-                            break;
-                        } else {
-                            state |= MEMORY_LOW;
-                        }
-                        freeMemory(true);
-                        continue;
-                    }
-                    if (active == null) {
-                        if (!toProcess.isEmpty()) {
-                            active = toProcess.removeFirst();
-                            if (active == null || previous.finishedFiles.contains(active.indexable))
-                                continue;
-                            isBigFile = false;
-                        } else {
-                            active = bigFiles.removeFirst();
-                            isBigFile = true;
-                            if (flm == null) {
-                                flm = new boolean[] {true};
-                            }
-                        }
-                    }
-                    if (jt == null) {
-                        jt = JavacParser.createJavacTask(
-                                javaContext.getClasspathInfo(),
-                                diagnosticListener,
-                                javaContext.getSourceLevel(),
-                                javaContext.getProfile(),
-                                cnffOraculum,
-                                javaContext.getFQNs(),
-                                new CancelService() {
-                                    public @Override boolean isCanceled() {
-                                        return context.isCancelled() || (checkForMemLow && isLowMemory(null));
-                                    }
-                                },
-                                active.aptGenerated ? null : APTUtils.get(context.getRoot()),
-                                CompilerOptionsQuery.getOptions(context.getRoot()));
-                        Iterable<? extends Processor> processors = jt.getProcessors();
-                        aptEnabled = processors != null && processors.iterator().hasNext();
-                        if (JavaIndex.LOG.isLoggable(Level.FINER)) {
-                            JavaIndex.LOG.finer("Created new JavacTask for: " + FileUtil.getFileDisplayName(context.getRoot()) + " " + javaContext.getClasspathInfo().toString()); //NOI18N
-                        }
-                    }
-                    Iterable<? extends CompilationUnitTree> trees = jt.parse(new JavaFileObject[]{active.jfo});
-                    if (isLowMemory(flm)) {
-                        dumpSymFiles(jt, previous.createdFiles, context);
-                        jt = null;
-                        diagnosticListener.cleanDiagnostics();
-                        trees = null;
-                        if ((state & MEMORY_LOW) != 0) {
-                            if (isBigFile) {
-                                break;
-                            } else {
-                                bigFiles.add(active);
-                                active = null;
-                                state &= ~MEMORY_LOW;
-                            }
-                        } else {
-                            state |= MEMORY_LOW;
-                        }
-                        freeMemory(true);
-                        continue;
-                    }
-                    Iterable<? extends Element> types;
-                    types = jt.enterTrees(trees);
-                    if (jfo2tuples.remove(active.jfo) != null) {
-                        final Types ts = Types.instance(jt.getContext());
-                        final Indexable activeIndexable = active.indexable;
-                        class ScanNested extends TreeScanner {
-                            Set<CompileTuple> dependencies = new LinkedHashSet<CompileTuple>();
-                            @Override
-                            public void visitClassDef(JCClassDecl node) {
-                                if (node.sym != null) {
-                                    Type st = ts.supertype(node.sym.type);
-                                    boolean envForSuperTypeFound = false;
-                                    while (!envForSuperTypeFound && st != null && st.hasTag(TypeTag.CLASS)) {
-                                        ClassSymbol c = st.tsym.outermostClass();
-                                        CompileTuple u = jfo2tuples.get(c.sourcefile);
-                                        if (u != null && !previous.finishedFiles.contains(u.indexable) && !u.indexable.equals(activeIndexable)) {
-                                            dependencies.add(u);
-                                            envForSuperTypeFound = true;
-                                        }
-                                        st = ts.supertype(st);
-                                    }
-                                }
-                                super.visitClassDef(node);
-                            }
-                        }
-                        ScanNested scanner = new ScanNested();
-                        for (CompilationUnitTree cut : trees) {
-                            scanner.scan((JCCompilationUnit)cut);
-                        }
-                        if (!scanner.dependencies.isEmpty()) {
-                            toProcess.addFirst(active);
-                            for (CompileTuple tuple : scanner.dependencies) {
-                                toProcess.addFirst(tuple);
-                            }
-                            active = null;
-                            continue;
-                        }
-                    }
-                    if (isLowMemory(flm)) {
-                        dumpSymFiles(jt, previous.createdFiles, context);
-                        jt = null;
-                        diagnosticListener.cleanDiagnostics();
-                        trees = null;
-                        types = null;
-                        if ((state & MEMORY_LOW) != 0) {
-                            if (isBigFile) {
-                                break;
-                            } else {
-                                bigFiles.add(active);
-                                active = null;
-                                state &= ~MEMORY_LOW;
-                            }
-                        } else {
-                            state |= MEMORY_LOW;
-                        }
-                        freeMemory(true);
-                        continue;
-                    }
-                    jt.analyze(types);
-                    if (aptEnabled) {
-                        JavaCustomIndexer.addAptGenerated(context, javaContext, active, previous.aptGenerated);
-                    }
-                    if (isLowMemory(flm)) {
-                        dumpSymFiles(jt, previous.createdFiles, context);
-                        jt = null;
-                        diagnosticListener.cleanDiagnostics();
-                        trees = null;
-                        types = null;
-                        if ((state & MEMORY_LOW) != 0) {
-                            if (isBigFile) {
-                                break;
-                            } else {
-                                bigFiles.add(active);
-                                active = null;
-                                state &= ~MEMORY_LOW;
-                            }
-                        } else {
-                            state |= MEMORY_LOW;
-                        }
-                        freeMemory(true);
-                        continue;
-                    }
-                    javaContext.getFQNs().set(types, active.indexable.getURL());
-                    boolean[] main = new boolean[1];
-                    if (javaContext.getCheckSums().checkAndSet(
-                            active.indexable.getURL(),
-                            StreamSupport.stream(types.spliterator(), false)
-                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
-                                .map ((e) -> (TypeElement)e)
-                                .collect(Collectors.toList()),
-                            jt.getElements()) || context.isSupplementaryFilesIndexing()) {
-                        javaContext.analyze(trees, jt, active, previous.addedTypes, previous.addedModules, main);
-                    } else {
-                        final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
-                        javaContext.analyze(trees, jt, active, aTypes, previous.addedModules, main);
-                        previous.addedTypes.addAll(aTypes);
-                        previous.modifiedTypes.addAll(aTypes);
-                    }
-                    ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
-                    JavaCustomIndexer.setErrors(context, active, diagnosticListener);
-                    Iterable<? extends JavaFileObject> generatedFiles = jt.generate(types);
-                    if (!active.virtual) {
-                        for (JavaFileObject generated : generatedFiles) {
-                            if (generated instanceof FileObjects.FileBase) {
-                                previous.createdFiles.add(((FileObjects.FileBase) generated).getFile());
-                            } else {
-                                // presumably should not happen
-                            }
-                        }
-                    }
-                    if (!moduleName.assigned) {
-                        ModuleElement module = trees.iterator().hasNext() ?
-                            ((JCTree.JCCompilationUnit)trees.iterator().next()).modle :
-                            null;
-                        if (module == null) {
-                            module = module = Modules.instance(jt.getContext()).getDefaultModule();
-                        }
-                        moduleName.name = module == null || module.isUnnamed() ?
-                                null :
-                                module.getQualifiedName().toString();
-                        moduleName.assigned = true;
-                    }
-                    Log.instance(jt.getContext()).nerrors = 0;
-                    previous.finishedFiles.add(active.indexable);
-                    active = null;
-                    state  = 0;
-                } catch (CancelAbort ca) {
-                    if (isLowMemory(flm)) {
-                        dumpSymFiles(jt, previous.createdFiles, context);
-                        jt = null;
-                        diagnosticListener.cleanDiagnostics();
-                        if ((state & MEMORY_LOW) != 0) {
-                            if (isBigFile) {
-                                break;
-                            } else {
-                                bigFiles.add(active);
-                                active = null;
-                                state &= ~MEMORY_LOW;
-                            }
-                        } else {
-                            state |= MEMORY_LOW;
-                        }
-                        freeMemory(true);
-                    } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                        JavaIndex.LOG.log(Level.FINEST, "OnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
-                    }
-                }
-            } catch (CouplingAbort ca) {
-                //Coupling error
-                TreeLoader.dumpCouplingAbort(ca, null);
-                jt = null;
-                diagnosticListener.cleanDiagnostics();
-                if ((state & ERR) != 0) {
-                    //When a javac failed with the Exception mark a file
-                    //causing this exceptin as compiled
-                    if (active != null)
-                        previous.finishedFiles.add(active.indexable);
-                    active = null;
-                    state = 0;
-                } else {
-                    state |= ERR;
-                }
-            } catch (OutputFileManager.InvalidSourcePath isp) {
-                //Deleted project - log & ignore
-                if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                    final String message = String.format("MultiPassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                active.jfo.toUri().toString(),
-                                FileUtil.getFileDisplayName(context.getRoot()),
-                                bootPath == null   ? null : bootPath.toString(),
-                                classPath == null  ? null : classPath.toString(),
-                                sourcePath == null ? null : sourcePath.toString()
-                                );
-                    JavaIndex.LOG.log(Level.FINEST, message, isp);
-                }
-                return ParsingOutput.failure(moduleName.name, previous.file2FQNs,
-                        previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
-                        previous.modifiedTypes, previous.aptGenerated);
-            } catch (MissingPlatformError mpe) {
-                //No platform - log & mark files as errornous
-                if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                    final String message = String.format("MultiPassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                active.jfo.toUri().toString(),
-                                FileUtil.getFileDisplayName(context.getRoot()),
-                                bootPath == null   ? null : bootPath.toString(),
-                                classPath == null  ? null : classPath.toString(),
-                                sourcePath == null ? null : sourcePath.toString()
-                                );
-                    JavaIndex.LOG.log(Level.FINEST, message, mpe);
-                }
-                JavaCustomIndexer.brokenPlatform(context, files, mpe.getDiagnostic());
-                return ParsingOutput.failure(moduleName.name, previous.file2FQNs,
-                        previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
-                        previous.modifiedTypes, previous.aptGenerated);
-            } catch (Throwable t) {
-                if (t instanceof ThreadDeath) {
-                    throw (ThreadDeath) t;
-                }
-                else {
-                    Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
-                    if (JavaIndex.LOG.isLoggable(level)) {
-                        final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                        final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                        final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                        final String message = String.format("MultiPassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                    active == null ? null : active.jfo.toUri().toString(),
-                                    FileUtil.getFileDisplayName(context.getRoot()),
-                                    bootPath == null ? null : bootPath.toString(),
-                                    classPath == null ? null : classPath.toString(),
-                                    sourcePath == null ? null : sourcePath.toString()
-                                    );
-                        JavaIndex.LOG.log(level, message, t);  //NOI18N
-                    }
-                    jt = null;
-                    diagnosticListener.cleanDiagnostics();
-                    if ((state & ERR) != 0) {
-                        //When a javac failed with the Exception mark a file
-                        //causing this exceptin as compiled
-                        if (active != null)
-                            previous.finishedFiles.add(active.indexable);
-                        active = null;
-                        state = 0;
-                    } else {
-                        state |= ERR;
-                    }
-                }
-            }
-        }
-        return (state & MEMORY_LOW) == 0?
-            ParsingOutput.success(moduleName.name, previous.file2FQNs,
-                    previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
-                    previous.modifiedTypes, previous.aptGenerated):
-            ParsingOutput.lowMemory(moduleName.name, previous.file2FQNs,
-                    previous.addedTypes, previous.addedModules, previous.createdFiles, previous.finishedFiles,
-                    previous.modifiedTypes, previous.aptGenerated);
-    }
-
-    private void dumpSymFiles(
-            final JavacTaskImpl jti,
-            final Set<File> alreadyCreated,
-            final Context ctx) throws IOException {
-        if (jti != null) {
-            final JavaFileManager jfm = jti.getContext().get(JavaFileManager.class);
-            checkForMemLow = false;
-            try {
-                final Types types = Types.instance(jti.getContext());
-                final Enter enter = Enter.instance(jti.getContext());
-                final Symtab syms = Symtab.instance(jti.getContext());
-                final HashMap<ClassSymbol, JCClassDecl> syms2trees = new HashMap<>();
-                class ScanNested extends TreeScanner {
-                    private Env<AttrContext> env;
-                    private Set<Env<AttrContext>> checked = new HashSet<Env<AttrContext>>();
-                    private List<Env<AttrContext>> dependencies = new LinkedList<Env<AttrContext>>();
-                    public ScanNested(Env<AttrContext> env) {
-                        this.env = env;
-                    }
-                    @Override
-                    public void visitClassDef(JCClassDecl node) {
-                        if (node.sym != null) {
-                            Type st = types.supertype(node.sym.type);
-                            boolean envForSuperTypeFound = false;
-                            while (!envForSuperTypeFound && st != null && st.hasTag(TypeTag.CLASS)) {
-                                ClassSymbol c = st.tsym.outermostClass();
-                                Env<AttrContext> stEnv = enter.getEnv(c);
-                                if (stEnv != null && env != stEnv) {
-                                    if (checked.add(stEnv)) {
-                                        scan(stEnv.tree);
-                                        if (TreeLoader.pruneTree(stEnv.tree, syms, syms2trees))
-                                            dependencies.add(stEnv);
-                                    }
-                                    envForSuperTypeFound = true;
-                                }
-                                st = types.supertype(st);
-                            }
-                        }
-                        super.visitClassDef(node);
-                    }
-                }
-                final Set<Env<AttrContext>> processedEnvs = new HashSet<Env<AttrContext>>();
-                File classes = JavaIndex.getClassFolder(ctx);
-                for (Env<AttrContext> env : jti.getTodo()) {
-                    if (processedEnvs.add(env)) {
-                        ScanNested scanner = new ScanNested(env);
-                        scanner.scan(env.tree);
-                        for (Env<AttrContext> dep: scanner.dependencies) {
-                            if (processedEnvs.add(dep)) {
-                                dumpSymFile(jfm, jti, dep.enclClass.sym, alreadyCreated, classes, syms2trees);
-                            }
-                        }
-                        if (TreeLoader.pruneTree(env.tree, syms, syms2trees))
-                            dumpSymFile(jfm, jti, env.enclClass.sym, alreadyCreated, classes, syms2trees);
-                    }
-                }
-            } finally {
-                checkForMemLow = true;
-            }
-        }
-    }
-    
-    private void dumpSymFile(
-            @NonNull final JavaFileManager jfm,
-            @NonNull final JavacTaskImpl jti,
-            @NullAllowed final ClassSymbol cs,
-            @NonNull final Set<File> alreadyCreated,
-            @NonNull final File classes,
-            @NonNull final HashMap<ClassSymbol, JCClassDecl> syms2trees) throws IOException {
-        if (cs == null) {
-            //ClassDecl has no symbol because compilation was cancelled
-            //by low memory before ENTER done.
-            return;
-        }        
-        JavaFileObject file = jfm.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT,
-                cs.flatname.toString(), JavaFileObject.Kind.CLASS, cs.sourcefile);
-        if (file instanceof FileObjects.FileBase && !alreadyCreated.contains(((FileObjects.FileBase)file).getFile())) {
-            TreeLoader.dumpSymFile(jfm, jti, cs, classes, syms2trees);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java
deleted file mode 100644
index f89b4cf..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.indexing;
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.TypeTag;
-import com.sun.tools.javac.code.Types;
-import com.sun.tools.javac.comp.Modules;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.tree.TreeScanner;
-import com.sun.tools.javac.util.CouplingAbort;
-import com.sun.tools.javac.util.FatalError;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.MissingPlatformError;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.Future;
-import java.util.logging.Level;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-import javax.annotation.processing.Processor;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileObject;
-import org.netbeans.api.java.classpath.ClassPath;
-import org.netbeans.api.java.queries.CompilerOptionsQuery;
-import org.netbeans.api.java.source.ClasspathInfo;
-import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.lib.nbjavac.services.CancelAbort;
-import org.netbeans.lib.nbjavac.services.CancelService;
-import org.netbeans.modules.java.source.TreeLoader;
-import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
-import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
-import org.netbeans.modules.java.source.parsing.FileObjects;
-import org.netbeans.modules.java.source.parsing.JavacParser;
-import org.netbeans.modules.java.source.parsing.OutputFileManager;
-import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
-import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
-import org.netbeans.modules.parsing.spi.indexing.Context;
-import org.netbeans.modules.parsing.spi.indexing.Indexable;
-import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
-import org.openide.filesystems.FileSystem;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-import org.openide.util.Pair;
-
-/**
- *
- * @author Jan Lahoda, Dusan Balek
- */
-final class OnePassCompileWorker extends CompileWorker {
-
-    @Override
-    ParsingOutput compile(
-            final ParsingOutput previous,
-            final Context context,
-            final JavaParsingContext javaContext,
-            final Collection<? extends CompileTuple> files) {
-        final Map<JavaFileObject, List<String>> file2FQNs = previous != null ? previous.file2FQNs : new HashMap<>();
-        final Set<ElementHandle<TypeElement>> addedTypes = previous != null ? previous.addedTypes : new HashSet<>();
-        final Set<ElementHandle<ModuleElement>> addedModules = previous != null ? previous.addedModules : new HashSet<>();
-        final Set<File> createdFiles = previous != null ? previous.createdFiles : new HashSet<>();
-        final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
-        final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
-        final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
-        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(file2FQNs);
-
-        final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
-        final HashMap<JavaFileObject, Pair<CompilationUnitTree, CompileTuple>> jfo2units = new HashMap<JavaFileObject, Pair<CompilationUnitTree, CompileTuple>>();
-        LinkedList<Pair<CompilationUnitTree, CompileTuple>> units = new LinkedList<Pair<CompilationUnitTree, CompileTuple>>();
-        JavacTaskImpl jt = null;
-
-        boolean nop = true;
-        final SuspendStatus suspendStatus = context.getSuspendStatus();
-        final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus);
-        try {
-            while (sourcePrefetcher.hasNext())  {
-                final CompileTuple tuple = sourcePrefetcher.next();
-                try {
-                    if (tuple != null) {
-                        nop = false;
-                        if (context.isCancelled()) {
-                            return null;
-                        }
-                        try {
-                            if (isLowMemory(null)) {
-                                jt = null;
-                                units = null;
-                                jfo2units.clear();
-                                dc.cleanDiagnostics();
-                                freeMemory(false);
-                            }
-                            if (jt == null) {
-                                jt = JavacParser.createJavacTask(
-                                    javaContext.getClasspathInfo(),
-                                    dc,
-                                    javaContext.getSourceLevel(),
-                                    javaContext.getProfile(),
-                                    cnffOraculum,
-                                    javaContext.getFQNs(),
-                                    new CancelService() {
-                                        public @Override boolean isCanceled() {
-                                            return context.isCancelled() || isLowMemory(null);
-                                        }
-                                    },
-                                    tuple.aptGenerated ? null : APTUtils.get(context.getRoot()),
-                                    CompilerOptionsQuery.getOptions(context.getRoot()));
-                            }
-                            for (CompilationUnitTree cut : jt.parse(tuple.jfo)) { //TODO: should be exactly one
-                                if (units != null) {
-                                    Pair<CompilationUnitTree, CompileTuple> unit = Pair.<CompilationUnitTree, CompileTuple>of(cut, tuple);
-                                    units.add(unit);
-                                    jfo2units.put(tuple.jfo, unit);
-                                }
-                                computeFQNs(file2FQNs, cut, tuple);
-                            }
-                            Log.instance(jt.getContext()).nerrors = 0;
-                        } catch (CancelAbort ca) {
-                            if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                                JavaIndex.LOG.log(Level.FINEST, "OnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
-                            }
-                        } catch (Throwable t) {
-                            if (JavaIndex.LOG.isLoggable(Level.WARNING)) {
-                                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                                final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                            tuple.indexable.getURL().toString(),
-                                            FileUtil.getFileDisplayName(context.getRoot()),
-                                            bootPath == null   ? null : bootPath.toString(),
-                                            classPath == null  ? null : classPath.toString(),
-                                            sourcePath == null ? null : sourcePath.toString()
-                                            );
-                                JavaIndex.LOG.log(Level.WARNING, message, t);  //NOI18N
-                            }
-                            if (t instanceof ThreadDeath) {
-                                throw (ThreadDeath) t;
-                            } else {
-                                jt = null;
-                                units = null;
-                                dc.cleanDiagnostics();
-                                freeMemory(false);
-                            }
-                        }
-                    }
-                } finally {
-                    sourcePrefetcher.remove();
-                }
-            }
-        } finally {
-            try {
-                sourcePrefetcher.close();
-            } catch (IOException ioe) {
-                Exceptions.printStackTrace(ioe);
-            }
-        }
-        final ModuleName moduleName = new ModuleName(javaContext.getModuleName());
-        if (nop) {
-            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        }
-
-        if (units == null || JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER) {
-            return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        }
-
-        CompileTuple active = null;
-        final boolean aptEnabled = Optional.ofNullable(jt)
-                .map((jtask) -> jtask.getProcessors())
-                .map((it) -> it.iterator().hasNext())
-                .orElse(Boolean.FALSE);
-        final boolean[] flm = {true};
-        try {
-            final Queue<Future<Void>> barriers = new ArrayDeque<>();
-            while(!units.isEmpty()) {
-                if (context.isCancelled()) {
-                    return null;
-                }
-                final Pair<CompilationUnitTree, CompileTuple> unit = units.removeFirst();
-                active = unit.second();
-                if (finished.contains(active.indexable)) {
-                    continue;
-                }
-                if (isLowMemory(flm)) {
-                    return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-                }
-                final Iterable<? extends Element> types = jt.enterTrees(Collections.singletonList(unit.first()));
-                if (jfo2units.remove(active.jfo) != null) {
-                    final Types ts = Types.instance(jt.getContext());
-                    final Indexable activeIndexable = active.indexable;
-                    class ScanNested extends TreeScanner {
-                        Set<Pair<CompilationUnitTree, CompileTuple>> dependencies = new LinkedHashSet<Pair<CompilationUnitTree, CompileTuple>>();
-                        @Override
-                        public void visitClassDef(JCClassDecl node) {
-                            if (node.sym != null) {
-                                Type st = ts.supertype(node.sym.type);
-                                boolean envForSuperTypeFound = false;
-                                while (!envForSuperTypeFound && st != null && st.hasTag(TypeTag.CLASS)) {
-                                    ClassSymbol c = st.tsym.outermostClass();
-                                    Pair<CompilationUnitTree, CompileTuple> u = jfo2units.remove(c.sourcefile);
-                                    if (u != null && !finished.contains(u.second().indexable) && !u.second().indexable.equals(activeIndexable)) {
-                                        if (dependencies.add(u)) {
-                                            scan((JCCompilationUnit)u.first());
-                                        }
-                                        envForSuperTypeFound = true;
-                                    }
-                                    st = ts.supertype(st);
-                                }
-                            }
-                            super.visitClassDef(node);
-                        }
-                    }
-                    ScanNested scanner = new ScanNested();
-                    scanner.scan((JCCompilationUnit)unit.first());
-                    if (!scanner.dependencies.isEmpty()) {
-                        units.addFirst(unit);
-                        for (Pair<CompilationUnitTree, CompileTuple> pair : scanner.dependencies) {
-                            units.addFirst(pair);
-                        }
-                        continue;
-                    }
-                }
-                if (isLowMemory(flm)) {
-                    return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-                }
-                jt.analyze(types);
-                if (aptEnabled) {
-                    JavaCustomIndexer.addAptGenerated(context, javaContext, active, aptGenerated);
-                }
-                if (isLowMemory(flm)) {
-                    return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-                }
-                javaContext.getFQNs().set(types, active.indexable.getURL());
-                boolean[] main = new boolean[1];
-                if (javaContext.getCheckSums().checkAndSet(
-                        active.indexable.getURL(),
-                        StreamSupport.stream(types.spliterator(), false)
-                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
-                                .map ((e) -> (TypeElement)e)
-                                .collect(Collectors.toList()),
-                        jt.getElements()) || context.isSupplementaryFilesIndexing()) {
-                    javaContext.analyze(Collections.singleton(unit.first()), jt, unit.second(), addedTypes, addedModules, main);
-                } else {
-                    final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
-                    javaContext.analyze(Collections.singleton(unit.first()), jt, unit.second(), aTypes, addedModules, main);
-                    addedTypes.addAll(aTypes);
-                    modifiedTypes.addAll(aTypes);
-                }
-                ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
-                JavaCustomIndexer.setErrors(context, active, dc);
-                final boolean virtual = active.virtual;
-                final JavacTaskImpl jtFin = jt;
-                barriers.offer(FileManagerTransaction.runConcurrent(new FileSystem.AtomicAction(){
-                    @Override
-                    public void run() throws IOException {
-                        Iterable<? extends JavaFileObject> generatedFiles = jtFin.generate(types);
-                        if (!virtual) {
-                            for (JavaFileObject generated : generatedFiles) {
-                                if (generated instanceof FileObjects.FileBase) {
-                                    createdFiles.add(((FileObjects.FileBase) generated).getFile());
-                                } else {
-                                    // presumably should not happen
-                                }
-                            }
-                        }
-                        if (!moduleName.assigned) {
-                            ModuleElement module = ((JCTree.JCCompilationUnit)unit.first()).modle;
-                            if (module == null) {
-                                module = Modules.instance(jtFin.getContext()).getDefaultModule();
-                            }
-                            moduleName.name = module == null || module.isUnnamed() ?
-                                null :
-                                module.getQualifiedName().toString();
-                            moduleName.assigned = true;
-                        }
-                    }
-                }));
-                Log.instance(jt.getContext()).nerrors = 0;
-                finished.add(active.indexable);
-            }
-            for (Future<Void> barrier : barriers) {
-                barrier.get();
-            }
-            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        } catch (CouplingAbort ca) {
-            //Coupling error
-            TreeLoader.dumpCouplingAbort(ca, null);
-        } catch (OutputFileManager.InvalidSourcePath isp) {
-            //Deleted project - log & ignore
-            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                            active.jfo.toUri().toString(),
-                            FileUtil.getFileDisplayName(context.getRoot()),
-                            bootPath == null   ? null : bootPath.toString(),
-                            classPath == null  ? null : classPath.toString(),
-                            sourcePath == null ? null : sourcePath.toString()
-                            );
-                JavaIndex.LOG.log(Level.FINEST, message, isp);
-            }
-        } catch (MissingPlatformError mpe) {
-            //No platform - log & mark files as errornous
-            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                            active.jfo.toUri().toString(),
-                            FileUtil.getFileDisplayName(context.getRoot()),
-                            bootPath == null   ? null : bootPath.toString(),
-                            classPath == null  ? null : classPath.toString(),
-                            sourcePath == null ? null : sourcePath.toString()
-                            );
-                JavaIndex.LOG.log(Level.FINEST, message, mpe);
-            }
-            JavaCustomIndexer.brokenPlatform(context, files, mpe.getDiagnostic());
-        } catch (CancelAbort ca) {
-            if (isLowMemory(flm)) {
-                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-            } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                JavaIndex.LOG.log(Level.FINEST, "OnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
-            }
-        } catch (Throwable t) {
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            } else {
-                Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
-                if (JavaIndex.LOG.isLoggable(level)) {
-                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                    final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                active.jfo.toUri().toString(),
-                                FileUtil.getFileDisplayName(context.getRoot()),
-                                bootPath == null   ? null : bootPath.toString(),
-                                classPath == null  ? null : classPath.toString(),
-                                sourcePath == null ? null : sourcePath.toString()
-                                );
-                    JavaIndex.LOG.log(level, message, t);  //NOI18N
-                }
-            }
-        }
-        return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
index ab1343a..2cdb35b 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
@@ -31,7 +31,7 @@ import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
  *
  * @author Tomas Zezula
  */
-class SourcePrefetcher implements Iterator<CompileTuple>, /*Auto*/Closeable {
+public class SourcePrefetcher implements Iterator<CompileTuple>, /*Auto*/Closeable {
        
     private final Iterator<? extends CompileTuple> iterator;
     //@NotThreadSafe
@@ -79,7 +79,7 @@ class SourcePrefetcher implements Iterator<CompileTuple>, /*Auto*/Closeable {
     }
     
     
-    static SourcePrefetcher create(
+    public static SourcePrefetcher create(
             @NonNull final Collection<? extends CompileTuple> files,
             @NonNull final SuspendStatus suspendStatus) {
         return new SourcePrefetcher(JavaIndexerWorker.getCompileTupleIterator(files, suspendStatus));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java
deleted file mode 100644
index 870a01b..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.netbeans.modules.java.source.indexing;
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.PackageTree;
-import com.sun.source.tree.Tree;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Symbol.TypeSymbol;
-import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.Enter;
-import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.comp.Modules;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
-import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
-import org.netbeans.lib.nbjavac.services.CancelAbort;
-import org.netbeans.lib.nbjavac.services.CancelService;
-import com.sun.tools.javac.util.CouplingAbort;
-import com.sun.tools.javac.util.FatalError;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.MissingPlatformError;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.Future;
-import java.util.logging.Level;
-import java.util.stream.Collectors;
-import javax.annotation.processing.Processor;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileObject;
-import org.netbeans.api.java.classpath.ClassPath;
-import org.netbeans.api.java.queries.CompilerOptionsQuery;
-import org.netbeans.api.java.source.ClasspathInfo;
-import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.modules.java.source.TreeLoader;
-import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
-import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
-import org.netbeans.modules.java.source.parsing.FileObjects;
-import org.netbeans.modules.java.source.parsing.JavacParser;
-import org.netbeans.modules.java.source.parsing.OutputFileManager;
-import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
-import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
-import org.netbeans.modules.parsing.spi.indexing.Context;
-import org.netbeans.modules.parsing.spi.indexing.Indexable;
-import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
-import org.openide.filesystems.FileSystem;
-import org.openide.filesystems.FileUtil;
-import org.openide.util.Exceptions;
-
-/**
- *
- * @author Dusan Balek
- */
-final class SuperOnePassCompileWorker extends CompileWorker {
-
-    @Override
-    ParsingOutput compile(
-            final ParsingOutput previous,
-            final Context context,
-            final JavaParsingContext javaContext,
-            final Collection<? extends CompileTuple> files) {
-        final Map<JavaFileObject, List<String>> file2FQNs = previous != null ? previous.file2FQNs : new HashMap<>();
-        final Set<ElementHandle<TypeElement>> addedTypes = previous != null ? previous.addedTypes : new HashSet<>();
-        final Set<ElementHandle<ModuleElement>> addedModules = previous != null ? previous.addedModules : new HashSet<>();
-        final Set<File> createdFiles = previous != null ? previous.createdFiles : new HashSet<>();
-        final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
-        final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
-        final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
-        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(file2FQNs);
-
-        final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
-        final LinkedList<CompilationUnitTree> trees = new LinkedList<CompilationUnitTree>();
-        Map<CompilationUnitTree, CompileTuple> units = new IdentityHashMap<CompilationUnitTree, CompileTuple>();
-        JavacTaskImpl jt = null;
-
-        boolean nop = true;
-        final SuspendStatus suspendStatus = context.getSuspendStatus();
-        final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus);
-        try {
-            final boolean flm[] = {true};
-            while (sourcePrefetcher.hasNext())  {
-                final CompileTuple tuple = sourcePrefetcher.next();
-                try {
-                    if (tuple != null) {
-                        nop = false;
-                        if (context.isCancelled()) {
-                            return null;
-                        }
-                        try {
-                            if (isLowMemory(flm)) {
-                                jt = null;
-                                units = null;
-                                trees.clear();
-                                dc.cleanDiagnostics();
-                                freeMemory(false);
-                            }
-                            if (jt == null) {
-                                jt = JavacParser.createJavacTask(
-                                    javaContext.getClasspathInfo(),
-                                    dc,
-                                    javaContext.getSourceLevel(),
-                                    javaContext.getProfile(),
-                                    cnffOraculum,
-                                    javaContext.getFQNs(),
-                                    new CancelService() {
-                                        public @Override boolean isCanceled() {
-                                            return context.isCancelled() || isLowMemory(null);
-                                        }
-                                    },
-                                    tuple.aptGenerated ? null : APTUtils.get(context.getRoot()),
-                                    CompilerOptionsQuery.getOptions(context.getRoot()));
-                            }
-                            for (CompilationUnitTree cut : jt.parse(tuple.jfo)) { //TODO: should be exactly one
-                                if (units != null) {
-                                    trees.add(cut);
-                                    units.put(cut, tuple);
-                                }
-                                computeFQNs(file2FQNs, cut, tuple);
-                            }
-                            Log.instance(jt.getContext()).nerrors = 0;
-                        } catch (CancelAbort ca) {
-                            if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                                JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
-                            }
-                        } catch (Throwable t) {
-                            if (JavaIndex.LOG.isLoggable(Level.WARNING)) {
-                                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                                final String message = String.format("SuperOnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                            tuple.indexable.getURL().toString(),
-                                            FileUtil.getFileDisplayName(context.getRoot()),
-                                            bootPath == null   ? null : bootPath.toString(),
-                                            classPath == null  ? null : classPath.toString(),
-                                            sourcePath == null ? null : sourcePath.toString()
-                                            );
-                                JavaIndex.LOG.log(Level.WARNING, message, t);  //NOI18N
-                            }
-                            if (t instanceof ThreadDeath) {
-                                throw (ThreadDeath) t;
-                            } else {
-                                jt = null;
-                                units = null;
-                                dc.cleanDiagnostics();
-                                freeMemory(false);
-                            }
-                        }
-                    }
-                }  finally {
-                    sourcePrefetcher.remove();
-                }
-            }
-        } finally {
-            try {
-                sourcePrefetcher.close();
-            } catch (IOException ex) {
-                Exceptions.printStackTrace(ex);
-            }
-        }
-        ModuleName moduleName = new ModuleName(javaContext.getModuleName());
-        if (nop) {
-            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        }
-        if (jt == null || units == null || JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER) {
-            return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        }
-        if (context.isCancelled()) {
-            return null;
-        }
-        if (isLowMemory(null)) {
-            return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        }
-        Iterable<? extends Processor> processors = jt.getProcessors();
-        boolean aptEnabled = processors != null && processors.iterator().hasNext();
-        try {
-            final Iterable<? extends Element> types = jt.enter(trees);
-            if (context.isCancelled()) {
-                return null;
-            }
-            if (isLowMemory(null)) {
-                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-            }
-            final Map<Element, CompileTuple> clazz2Tuple = new IdentityHashMap<Element, CompileTuple>();
-            Enter enter = Enter.instance(jt.getContext());
-            for (Element type : types) {
-                if (type.getKind().isClass() || type.getKind().isInterface() || type.getKind() == ElementKind.MODULE) {
-                    Env<AttrContext> typeEnv = enter.getEnv((TypeSymbol) type);
-                    if (typeEnv == null) {
-                        JavaIndex.LOG.log(Level.FINE, "No Env for: {0}", ((TypeSymbol) type).getQualifiedName());
-                        continue;
-                    }
-                    clazz2Tuple.put(type, units.get(typeEnv.toplevel));
-                }
-            }
-            jt.analyze(types);
-            if (context.isCancelled()) {
-                return null;
-            }
-            if (isLowMemory(null)) {
-                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-            }
-            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
-                CompileTuple active = unit.getValue();
-                if (aptEnabled) {
-                    JavaCustomIndexer.addAptGenerated(context, javaContext, active, aptGenerated);
-                }
-                List<Element> activeTypes = new ArrayList<>();
-                if (unit.getValue().jfo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
-                    final PackageTree pt = unit.getKey().getPackage();
-                    if (pt instanceof JCPackageDecl) {                        
-                        final Element sym = ((JCPackageDecl)pt).packge;
-                        if (sym != null)
-                            activeTypes.add(sym);
-                    }
-                } else {
-                    for (Tree tree : unit.getKey().getTypeDecls()) {
-                        if (tree instanceof JCTree) {
-                            final JCTree jct = (JCTree)tree;
-                            if (jct.getTag() == JCTree.Tag.CLASSDEF) {
-                                final Element sym = ((JCClassDecl)tree).sym;
-                                if (sym != null)
-                                    activeTypes.add(sym);
-                            } else if (jct.getTag() == JCTree.Tag.MODULEDEF) {
-                                final Element sym = ((JCModuleDecl)tree).sym;
-                                if (sym != null)
-                                    activeTypes.add(sym);
-                            }
-                        }
-                    }
-                }
-                javaContext.getFQNs().set(activeTypes, active.indexable.getURL());
-                boolean[] main = new boolean[1];
-                if (javaContext.getCheckSums().checkAndSet(
-                        active.indexable.getURL(),
-                        activeTypes.stream()                                                
-                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
-                                .map ((e) -> (TypeElement)e)
-                                .collect(Collectors.toList()),
-                        jt.getElements()) || context.isSupplementaryFilesIndexing()) {
-                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, addedTypes, addedModules, main);
-                } else {
-                    final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
-                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, aTypes, addedModules, main);
-                    addedTypes.addAll(aTypes);
-                    modifiedTypes.addAll(aTypes);
-                }
-                ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
-                JavaCustomIndexer.setErrors(context, active, dc);
-            }
-            if (context.isCancelled()) {
-                return null;
-            }
-            if (isLowMemory(null)) {
-                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-            }
-            final JavacTaskImpl jtFin = jt;
-            final Future<Void> done = FileManagerTransaction.runConcurrent(new FileSystem.AtomicAction() {
-                @Override
-                public void run() throws IOException {
-                    for (Element type : types) {
-                        Iterable<? extends JavaFileObject> generatedFiles = jtFin.generate(Collections.singletonList(type));
-                        CompileTuple unit = clazz2Tuple.get(type);
-                        if (unit == null || !unit.virtual) {
-                            for (JavaFileObject generated : generatedFiles) {
-                                if (generated instanceof FileObjects.FileBase) {
-                                    createdFiles.add(((FileObjects.FileBase) generated).getFile());
-                                } else {
-                                    // presumably should not happen
-                                }
-                            }
-                        }
-                    }
-                    if (!moduleName.assigned) {
-                        ModuleElement module = !trees.isEmpty() ?
-                            ((JCTree.JCCompilationUnit)trees.getFirst()).modle :
-                            null;
-                        if (module == null) {
-                            module = Modules.instance(jtFin.getContext()).getDefaultModule();
-                        }
-                        moduleName.name = module == null || module.isUnnamed() ?
-                            null :
-                            module.getQualifiedName().toString();
-                        moduleName.assigned = true;
-                    }
-                }
-            });
-            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
-                finished.add(unit.getValue().indexable);
-            }
-            done.get();
-            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-        } catch (CouplingAbort ca) {
-            //Coupling error
-            TreeLoader.dumpCouplingAbort(ca, null);
-        } catch (OutputFileManager.InvalidSourcePath isp) {
-            //Deleted project - log & ignore
-            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                            FileUtil.getFileDisplayName(context.getRoot()),
-                            bootPath == null   ? null : bootPath.toString(),
-                            classPath == null  ? null : classPath.toString(),
-                            sourcePath == null ? null : sourcePath.toString()
-                            );
-                JavaIndex.LOG.log(Level.FINEST, message, isp);
-            }
-        } catch (MissingPlatformError mpe) {
-            //No platform - log & mark files as errornous
-            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                            FileUtil.getFileDisplayName(context.getRoot()),
-                            bootPath == null   ? null : bootPath.toString(),
-                            classPath == null  ? null : classPath.toString(),
-                            sourcePath == null ? null : sourcePath.toString()
-                            );
-                JavaIndex.LOG.log(Level.FINEST, message, mpe);
-            }
-            JavaCustomIndexer.brokenPlatform(context, files, mpe.getDiagnostic());
-        } catch (CancelAbort ca) {
-            if (isLowMemory(null)) {
-                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-            } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
-                JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
-            }
-        } catch (Throwable t) {
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            } else {
-                Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
-                if (JavaIndex.LOG.isLoggable(level)) {
-                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
-                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
-                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
-                    final String message = String.format("SuperOnePassCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
-                                FileUtil.getFileDisplayName(context.getRoot()),
-                                bootPath == null   ? null : bootPath.toString(),
-                                classPath == null  ? null : classPath.toString(),
-                                sourcePath == null ? null : sourcePath.toString()
-                                );
-                    JavaIndex.LOG.log(level, message, t);  //NOI18N
-                }
-            }
-        }
-        return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
-    }
-}


[03/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

Posted by jl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java
----------------------------------------------------------------------
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java
new file mode 100644
index 0000000..8c114e5
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.io.File;
+import java.io.IOException;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import org.netbeans.api.java.source.CompilationController;
+import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.JavaSource.Phase;
+import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.Task;
+import org.netbeans.api.java.source.TestUtilities;
+import org.netbeans.junit.NbTestCase;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ *
+ * @author lahvac
+ */
+public class TreeLoaderTest extends NbTestCase {
+
+    public TreeLoaderTest(String name) {
+        super(name);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        clearWorkDir();
+        SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
+    }
+
+    public void test171340() throws Exception {
+        prepareTest();
+
+        FileObject src1 = FileUtil.createData(sourceRoot, "test/Test1.java");
+        FileObject src2 = FileUtil.createData(sourceRoot, "test/Test2.java");
+
+        TestUtilities.copyStringToFile(src1,
+                "package test;\n" +
+                "public class Test1 {}");
+        TestUtilities.copyStringToFile(src2,
+                "package test;\n" +
+                "public class Test2 {" +
+                "    public void test() {}" +
+                "}");
+        SourceUtilsTestUtil.compileRecursively(sourceRoot);
+        JavaSource javaSource = JavaSource.forFileObject(src1);
+        javaSource.runUserActionTask(new Task<CompilationController>() {
+            public void run(CompilationController controller) throws IOException {
+                controller.toPhase(Phase.RESOLVED);
+                TypeElement typeElement = controller.getElements().getTypeElement("test.Test2");
+                assertNotNull(typeElement);
+                ExecutableElement method = (ExecutableElement) typeElement.getEnclosedElements().get(1);
+                assertNotNull(controller.getTrees().getPath(method));
+            }
+        }, true);
+    }
+
+    private FileObject sourceRoot;
+
+    private void prepareTest() throws Exception {
+        File work = getWorkDir();
+        FileObject workFO = FileUtil.toFileObject(work);
+
+        assertNotNull(workFO);
+
+        sourceRoot = workFO.createFolder("src");
+        FileObject buildRoot  = workFO.createFolder("build");
+        FileObject cache = workFO.createFolder("cache");
+
+        SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
----------------------------------------------------------------------
diff --git a/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java b/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
index cd93972..272da11 100644
--- a/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
+++ b/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
@@ -20,7 +20,7 @@ package org.netbeans.modules.java.source.queriesimpl;
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -340,7 +340,7 @@ class JavaOperationsImpl<T> implements ModelOperations {
                 oldVarTree.getInitializer());
         wcopy.rewrite(oldVarTree, newVarTree);
         final VariableElement fieldF = field;
-        final TreePathScanner<Void,Void> scanner = new TreePathScanner<Void, Void>(){
+        final ErrorAwareTreePathScanner<Void,Void> scanner = new ErrorAwareTreePathScanner<Void, Void>(){
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 super.visitIdentifier(node, p);
@@ -397,7 +397,7 @@ class JavaOperationsImpl<T> implements ModelOperations {
         final Trees trees = wcopy.getTrees();
         final GeneratorUtilities utils = GeneratorUtilities.get(wcopy);
         final List<Tree> toImport = new ArrayList<Tree>();
-        final TreePathScanner<Void,Void> scanner = new TreePathScanner<Void, Void>(){
+        final ErrorAwareTreePathScanner<Void,Void> scanner = new ErrorAwareTreePathScanner<Void, Void>(){
             @Override
             public Void scan(Tree node, Void p) {
                 final int start = (int) trees.getSourcePositions().getStartPosition(cu, node);
@@ -518,7 +518,7 @@ nextM:  for (ExecutableElement me : ElementFilter.methodsIn(te.getEnclosedElemen
             throw new QueryException(ioe);
         }
         final Trees trees = control.getTrees();
-        final TreePathScanner<TreePath,Void> visitor = new TreePathScanner<TreePath, Void>() {
+        final ErrorAwareTreePathScanner<TreePath,Void> visitor = new ErrorAwareTreePathScanner<TreePath, Void>() {
             @Override
             public TreePath visitClass(ClassTree node, Void p) {
                 final Element el = trees.getElement(getCurrentPath());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source/src/org/netbeans/api/java/source/UiUtils.java
----------------------------------------------------------------------
diff --git a/java.source/src/org/netbeans/api/java/source/UiUtils.java b/java.source/src/org/netbeans/api/java/source/UiUtils.java
index 3f8db8d..7751f10 100644
--- a/java.source/src/org/netbeans/api/java/source/UiUtils.java
+++ b/java.source/src/org/netbeans/api/java/source/UiUtils.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.util.Context;
 import java.io.IOException;
 import java.util.Collection;
@@ -435,7 +435,7 @@ public final class  UiUtils {
     
     // Private innerclasses ----------------------------------------------------
     
-    private static class FindDeclarationVisitor extends TreePathScanner<Void, Void> {
+    private static class FindDeclarationVisitor extends ErrorAwareTreePathScanner<Void, Void> {
         
         private Element element;
         private Tree declTree;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source/src/org/netbeans/modules/java/JavaNode.java
----------------------------------------------------------------------
diff --git a/java.source/src/org/netbeans/modules/java/JavaNode.java b/java.source/src/org/netbeans/modules/java/JavaNode.java
index 34a991a..dbd170c 100644
--- a/java.source/src/org/netbeans/modules/java/JavaNode.java
+++ b/java.source/src/org/netbeans/modules/java/JavaNode.java
@@ -21,7 +21,7 @@ package org.netbeans.modules.java;
 
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.awt.Image;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -475,7 +475,7 @@ public final class JavaNode extends DataNode implements ChangeListener {
                 return res[0];
             }
 
-            private static final class ClasssFinder extends TreeScanner<Collection<ClassTree>, Collection<ClassTree>> {
+            private static final class ClasssFinder extends ErrorAwareTreeScanner<Collection<ClassTree>, Collection<ClassTree>> {
 
                 @Override
                 public Collection<ClassTree> visitCompilationUnit(CompilationUnitTree node, Collection<ClassTree> p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
----------------------------------------------------------------------
diff --git a/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java b/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
index 6b1ecc1..d886f9a 100644
--- a/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
+++ b/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
@@ -45,6 +45,7 @@ import com.sun.tools.javap.CodeWriter;
 import com.sun.tools.javap.ConstantWriter;
 import com.sun.tools.javap.Context;
 import com.sun.tools.javap.Messages;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -67,6 +68,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.AnnotationValueVisitor;
@@ -85,6 +87,8 @@ import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.AbstractElementVisitor9;
 import javax.tools.JavaFileObject;
 import javax.tools.JavaFileObject.Kind;
+
+import com.sun.tools.classfile.ConstantPool.CPInfo;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ClasspathInfo.PathKind;
@@ -739,19 +743,7 @@ public class CodeGenerator {
         
         @Override
         public void writeInstr(Instruction instr) {
-            if (INSTRUCTION_WITH_REFERENCE.contains(instr.getOpcode())) {
-                print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
-                int constantPoolEntry;
-                if (instr.getOpcode() == Opcode.LDC) {
-                    constantPoolEntry = instr.getUnsignedByte(1);
-                } else {
-                    constantPoolEntry = instr.getUnsignedShort(1);
-                }
-                print(constantWriter.stringValue(constantPoolEntry));
-                println();
-            } else {
-                super.writeInstr(instr);
-            }
+            super.writeInstr(instr);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
----------------------------------------------------------------------
diff --git a/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java b/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
index 7a4fab2..28cb84f 100644
--- a/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
+++ b/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
@@ -76,7 +76,7 @@ public class SourceFileObject extends AbstractSourceFileObject implements Docume
         @NullAllowed final JavaFileFilterImplementation filter,
         @NullAllowed final CharSequence content,
         final boolean renderNow) throws IOException {
-        super(handle, filter);
+        super(handle, filter, content != null);
         this.hasFilter = filter != null;
         if (content != null || renderNow) {
             update(content);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
----------------------------------------------------------------------
diff --git a/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java b/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
index d3b756a..47c3480 100644
--- a/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
+++ b/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
@@ -34,8 +34,8 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -93,7 +93,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLiteral(LiteralTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                         return super.visitLiteral(node, p);
@@ -133,7 +133,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("e")) {
                             workingCopy.rewrite(node, make.setLabel(node, "f"));
@@ -174,7 +174,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "e", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -213,7 +213,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -252,7 +252,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -291,7 +291,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.insertLambdaParameter(node, 0, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -330,7 +330,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -369,7 +369,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 1));
                         return super.visitLambdaExpression(node, p);
@@ -408,7 +408,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -447,7 +447,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         ReturnTree t = (ReturnTree) ((BlockTree) node.getBody()).getStatements().get(0);
                         workingCopy.rewrite(node, make.setLambdaBody(node, t.getExpression()));
@@ -489,7 +489,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -532,7 +532,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -571,7 +571,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), make.Identifier("Test"), node.getName(), node.getTypeArguments()));
                         return super.visitMemberReference(node, p);
@@ -610,7 +610,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.setLabel(node, "taragui2"));
                         return super.visitMemberReference(node, p);
@@ -649,7 +649,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), Collections.singletonList(make.Identifier("String"))));
                         return super.visitMemberReference(node, p);
@@ -688,7 +688,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), null));
                         return super.visitMemberReference(node, p);
@@ -729,7 +729,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par.getType(), make.Identifier("String"));
@@ -772,7 +772,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par, make.Variable(par.getModifiers(), par.getName(), null, par.getInitializer()));
@@ -895,7 +895,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         VariableTree vt = node.getParameters().get(0);
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(vt.getModifiers(), "f", vt.getType(), vt.getInitializer())));
@@ -935,7 +935,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void scan(Tree node, Void p) {
                         return super.scan(node, p);
@@ -986,7 +986,7 @@ public class LambdaTest extends GeneratorTestMDRCompat {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
----------------------------------------------------------------------
diff --git a/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java b/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
index 425da5f..2850cb5 100644
--- a/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
+++ b/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
@@ -21,7 +21,7 @@ package org.netbeans.api.java.source.ui;
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Level;
@@ -400,7 +400,7 @@ public final class ElementOpen {
     
     // Private innerclasses ----------------------------------------------------
     
-    private static class FindDeclarationVisitor extends TreePathScanner<Void, Void> {
+    private static class FindDeclarationVisitor extends ErrorAwareTreePathScanner<Void, Void> {
         
         private Element element;
         private Tree declTree;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
----------------------------------------------------------------------
diff --git a/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java b/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
index 427a5a4..a7cfc0d 100644
--- a/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
+++ b/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
@@ -25,6 +25,7 @@ import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.model.JavacElements;
+
 import java.io.File;
 import java.io.IOException;
 import java.lang.ref.Reference;
@@ -42,6 +43,7 @@ import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Logger;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.Modifier;
@@ -58,6 +60,7 @@ import org.netbeans.api.java.queries.SourceLevelQuery;
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.project.ProjectInformation;
 import org.netbeans.modules.java.source.ElementHandleAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.indexing.JavaIndex;
 import org.netbeans.modules.java.source.parsing.CachingArchiveProvider;
 import org.netbeans.modules.java.source.parsing.CachingFileManager;
@@ -211,8 +214,7 @@ final class AsyncJavaSymbolDescriptor extends JavaSymbolDescriptorBase implement
             final Symtab syms = Symtab.instance(jt.getContext());
             final Set<?> pkgs = new HashSet<>(getPackages(syms).keySet());
             final Set<?> clzs = new HashSet<>(getClasses(syms).keySet());
-            final JavacElements elements = (JavacElements)jt.getElements();
-            final TypeElement te = (TypeElement) elements.getTypeElementByBinaryName(
+            final TypeElement te = (TypeElement) ElementUtils.getTypeElementByBinaryName(jt,
                     ElementHandleAccessor.getInstance().getJVMSignature(getOwner())[0]);
             if (te != null) {
                 if (ident.equals(getSimpleName(te, null, caseSensitive))) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
----------------------------------------------------------------------
diff --git a/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java b/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
index 0392a98..ac5c08c 100644
--- a/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
+++ b/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
@@ -33,7 +33,7 @@ import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -121,7 +121,7 @@ public class ElementHeadersTest extends NbTestCase {
     }
     
     public void test134664() throws Exception {
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+//        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         performTest("test/Test.java", "package test; public class Test { public Tfst {} }", 43, ElementHeaders.NAME, "Tfst");
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.testrunner.ui/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.testrunner.ui/nbproject/project.properties b/java.testrunner.ui/nbproject/project.properties
index 7f641b7..5fdc82a 100644
--- a/java.testrunner.ui/nbproject/project.properties
+++ b/java.testrunner.ui/nbproject/project.properties
@@ -17,3 +17,5 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.testrunner/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/java.testrunner/nbproject/project.properties b/java.testrunner/nbproject/project.properties
index 7f641b7..375b088 100644
--- a/java.testrunner/nbproject/project.properties
+++ b/java.testrunner/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/javaee.injection/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/javaee.injection/nbproject/project.properties b/javaee.injection/nbproject/project.properties
index ab06b41..bd782ba 100644
--- a/javaee.injection/nbproject/project.properties
+++ b/javaee.injection/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
----------------------------------------------------------------------
diff --git a/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java b/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
index a72bcca..7ca3fc9 100644
--- a/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
+++ b/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
@@ -35,6 +35,7 @@ import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.CompilationController;
 import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.gen.WhitespaceIgnoringDiff;
 import org.netbeans.api.lexer.Language;
@@ -45,7 +46,7 @@ import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.editor.completion.CompletionItemComparator;
 import org.netbeans.modules.editor.java.Utilities;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.netbeans.modules.java.source.parsing.JavacParserFactory;
 import org.netbeans.modules.java.source.usages.BinaryAnalyser;
@@ -85,7 +86,7 @@ public class FXMLCompletionTestBase extends NbTestCase {
         System.setProperty("org.openide.util.Lookup", Lkp.class.getName());
         Assert.assertEquals(Lkp.class, Lookup.getDefault().getClass());
 
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
 
     static final int FINISH_OUTTIME = 5 * 60 * 1000;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/javafx2.project/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/javafx2.project/nbproject/project.properties b/javafx2.project/nbproject/project.properties
index 4b04a20..b6bb147 100644
--- a/javafx2.project/nbproject/project.properties
+++ b/javafx2.project/nbproject/project.properties
@@ -18,3 +18,4 @@ javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
 
 test.config.stable.includes=**/NewJavaFX2ProjectTest.class
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/javawebstart/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/javawebstart/nbproject/project.properties b/javawebstart/nbproject/project.properties
index 24b5a55..5c67e0d 100644
--- a/javawebstart/nbproject/project.properties
+++ b/javawebstart/nbproject/project.properties
@@ -19,3 +19,4 @@ javac.compilerargs=-Xlint:unchecked
 javac.source=1.7
 extra.module.files=ant/extra/org-netbeans-modules-javawebstart-anttasks.jar
 jnlp.indirect.jars=ant/extra/org-netbeans-modules-javawebstart-anttasks.jar
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/jshell.support/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/jshell.support/nbproject/project.properties b/jshell.support/nbproject/project.properties
index 952f643..89fa9ac 100644
--- a/jshell.support/nbproject/project.properties
+++ b/jshell.support/nbproject/project.properties
@@ -21,3 +21,4 @@ spec.version.base=1.0
 cp.extra=${tools.jar}
 bootclasspath.prepend=${nb_all}/libs.javacapi/external/nb-javac-api.jar${path.separator}${nb_all}/libs.javacimpl/external/nb-javac-impl.jar
 is.eager=true
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/jshell.support/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/jshell.support/nbproject/project.xml b/jshell.support/nbproject/project.xml
index e87a5b8..313c930 100644
--- a/jshell.support/nbproject/project.xml
+++ b/jshell.support/nbproject/project.xml
@@ -120,7 +120,7 @@
                         <specification-version>8.19</specification-version>
                     </run-dependency>
                 </dependency>
-                <dependency>
+<!--                <dependency>
                     <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
@@ -128,7 +128,7 @@
                         <release-version>1</release-version>
                         <specification-version>0.47</specification-version>
                     </run-dependency>
-                </dependency>
+                </dependency>-->
                 <dependency>
                     <code-name-base>org.netbeans.libs.jshell.compile</code-name-base>
                     <build-prerequisite/>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/junit.ant.ui/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/junit.ant.ui/nbproject/project.properties b/junit.ant.ui/nbproject/project.properties
index 7f641b7..5d0fa29 100644
--- a/junit.ant.ui/nbproject/project.properties
+++ b/junit.ant.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/junit.ui/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/junit.ui/nbproject/project.properties b/junit.ui/nbproject/project.properties
index 7f641b7..5fdc82a 100644
--- a/junit.ui/nbproject/project.properties
+++ b/junit.ui/nbproject/project.properties
@@ -17,3 +17,5 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+cp.extra=${tools.jar}
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
----------------------------------------------------------------------
diff --git a/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java b/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
index 542cd4b..69e49ee 100644
--- a/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
+++ b/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
@@ -24,7 +24,7 @@ import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.net.URL;
@@ -354,7 +354,7 @@ public class OpenTestAction extends TestAction {
     /**
      *
      */
-    private static class DeclarationTreeFinder extends TreePathScanner<Void, Void> {
+    private static class DeclarationTreeFinder extends ErrorAwareTreePathScanner<Void, Void> {
 
         private final Element element;
         private final Trees trees;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
index 35b23ec..d139a5e 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
@@ -60,46 +60,6 @@ public class NBClassReader extends ClassReader {
                     bp = newbp;
                 }
             },
-            new NBAttributeReader(nbNames._org_netbeans_TypeSignature, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    sym.type = readType(nextChar());
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_ParameterNames, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    int newbp = bp + attrLen;
-                    List<Name> parameterNames = List.nil();
-                    int numParams = 0;
-                    if (sym.type != null) {
-                        List<Type> parameterTypes = sym.type.getParameterTypes();
-                        if (parameterTypes != null)
-                            numParams = parameterTypes.length();
-                    }
-                    for (int i = 0; i < numParams; i++) {
-                        if (bp < newbp - 1)
-                            parameterNames = parameterNames.prepend(readName(nextChar()));
-                    }
-                    parameterNames = parameterNames.reverse();
-                    while(parameterNames.length() < numParams)
-                        parameterNames = parameterNames.prepend(names.empty);
-                    ((MethodSymbol)sym).savedParameterNames = parameterNames;
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_SourceLevelAnnotations, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    attachAnnotations(sym);
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_SourceLevelParameterAnnotations, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    attachParameterAnnotations(sym);
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_SourceLevelTypeAnnotations, Version.V52, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    attachTypeAnnotations(sym);
-                }
-            },
         };
 
         for (NBAttributeReader r: readers)

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
index 76c5593..22cb6ee 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
@@ -58,128 +58,4 @@ public class NBClassWriter extends ClassWriter {
         types = Types.instance(context);
     }
     
-    @Override
-    protected int writeExtraClassAttributes(ClassSymbol c) {
-        if (c.sourcefile != null) {
-            final Collection<? extends ClassSymbol> nip = nbMessager.removeNotInProfile(c.sourcefile.toUri());
-            if (nip != null) {
-                for (ClassSymbol s : nip) {
-                    pool.put(s.type);
-                }
-            }
-        }
-        return 0;
-    }
-
-    @Override
-    protected int writeExtraMemberAttributes(Symbol sym) {
-        int attrCount = 0;
-        if (sym.externalType(types).isErroneous()) {
-            int rsIdx = writeAttr(nbNames._org_netbeans_TypeSignature);
-            try {
-                preserveErrors = true;
-                databuf.appendChar(pool.put(typeSig(sym.type)));
-            } finally {
-                preserveErrors = false;
-            }
-            endAttr(rsIdx);
-            attrCount++;
-        }
-        return attrCount;
-    }
-
-    @Override
-    protected int writeExtraParameterAttributes(MethodSymbol m) {
-        boolean hasSourceLevel = false;
-        if (m.params != null) for (VarSymbol s : m.params) {
-            for (Attribute.Compound a : s.getRawAttributes()) {
-                if (types.getRetention(a) == RetentionPolicy.SOURCE) {
-                    hasSourceLevel = true;
-                    break;
-                }
-            }
-        }
-        int attrCount = 0;
-        if (hasSourceLevel) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_SourceLevelParameterAnnotations);
-            databuf.appendByte(m.params.length());
-            for (VarSymbol s : m.params) {
-                ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
-                for (Attribute.Compound a : s.getRawAttributes())
-                    if (types.getRetention(a) == RetentionPolicy.SOURCE)
-                        buf.append(a);
-                databuf.appendChar(buf.length());
-                for (Attribute.Compound a : buf)
-                    writeCompoundAttribute(a);
-            }
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        if (m.code == null && m.params != null && m.params.nonEmpty()) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_ParameterNames);
-            for (VarSymbol s : m.params)
-                databuf.appendChar(pool.put(s.name));
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        return attrCount;
-    }
-
-    @Override
-    protected int writeExtraJavaAnnotations(List<Attribute.Compound> attrs) {
-        ListBuffer<Attribute.Compound> sourceLevel = new ListBuffer<Attribute.Compound>();
-        for (Attribute.Compound a : attrs) {
-            if (types.getRetention(a) == RetentionPolicy.SOURCE) {
-                sourceLevel.append(a);
-            }
-        }
-        int attrCount = 0;
-        if (sourceLevel.nonEmpty()) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_SourceLevelAnnotations);
-            databuf.appendChar(sourceLevel.length());
-            for (Attribute.Compound a : sourceLevel)
-                writeCompoundAttribute(a);
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        return attrCount;
-    }
-
-    @Override
-    protected int writeExtraTypeAnnotations(List<TypeCompound> attrs) {
-        ListBuffer<Attribute.TypeCompound> sourceLevel = new ListBuffer<Attribute.TypeCompound>();
-        for (Attribute.TypeCompound tc : attrs) {
-            if (tc.hasUnknownPosition()) {
-                boolean fixed = tc.tryFixPosition();
-
-                // Could we fix it?
-                if (!fixed) {
-                    // This happens for nested types like @A Outer. @B Inner.
-                    // For method parameters we get the annotation twice! Once with
-                    // a valid position, once unknown.
-                    // TODO: find a cleaner solution.
-                    continue;
-                }
-            }
-
-            if (tc.position.type.isLocal())
-                continue;
-            if (!tc.position.emitToClassfile()) {
-                continue;
-            }
-            if (types.getRetention(tc) == RetentionPolicy.SOURCE) {
-                sourceLevel.append(tc);
-            }
-        }
-        int attrCount = 0;
-        if (sourceLevel.nonEmpty()) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_SourceLevelTypeAnnotations);
-            databuf.appendChar(sourceLevel.length());
-            for (Attribute.TypeCompound p : sourceLevel)
-                writeTypeAnnotation(p);
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        return attrCount;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
index 231cd91..06709d8 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
@@ -50,7 +50,7 @@ public class NBEnter extends Enter {
         super.visitClassDef(tree);
     }
 
-    @Override
+    //no @Override to ensure compatibility with ordinary javac:
     protected int getIndex(JCClassDecl clazz) {
         return clazz instanceof IndexedClassDecl ? ((IndexedClassDecl) clazz).index : -1;
     }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
index d8e288a..7da8d65 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
@@ -72,7 +72,7 @@ public class NBJavadocEnter extends JavadocEnter {
         super.visitClassDef(tree);
     }
 
-    @Override
+    //no @Override to ensure compatibility with ordinary javac:
     protected int getIndex(JCClassDecl clazz) {
         return clazz instanceof IndexedClassDecl ? ((IndexedClassDecl) clazz).index : -1;
     }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
index 8f22759..462859c 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
@@ -21,7 +21,9 @@ package org.netbeans.lib.nbjavac.services;
 import com.sun.source.util.TreePath;
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.comp.MemberEnter;
+import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCImport;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -66,7 +68,13 @@ public class NBJavadocMemberEnter extends JavadocMemberEnter {
     @Override
     public void visitMethodDef(JCMethodDecl tree) {
         cancelService.abortIfCanceled();
-        super.visitMethodDef(tree);
+        JCBlock body = tree.body;
+        try {
+            super.visitMethodDef(tree);
+        } finally {
+            //reinstall body:
+            tree.body = body;
+        }
         if (trees instanceof NBJavacTrees && !env.enclClass.defs.contains(tree)) {
             ((NBJavacTrees)trees).addPathForElement(tree.sym, new TreePath(trees.getPath(env.toplevel, env.enclClass), tree));
         }
@@ -75,7 +83,13 @@ public class NBJavadocMemberEnter extends JavadocMemberEnter {
     @Override
     public void visitVarDef(JCVariableDecl tree) {
         cancelService.abortIfCanceled();
-        super.visitVarDef(tree);
+        JCExpression init = tree.init;
+        try {
+            super.visitVarDef(tree);
+        } finally {
+            //reinstall init:
+            tree.init = init;
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
index 0c14f42..ee294de 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
@@ -76,51 +76,6 @@ public class NBParserFactory extends ParserFactory {
         return new NBJavacParser(this, lexer, keepDocComments, keepLineMap, keepEndPos, parseModuleInfo, cancelService);
     }
 
-    public JavacParser newParser(CharSequence input, int startPos, final EndPosTable endPos) {
-        Scanner lexer = scannerFactory.newScanner(input, true);
-        lexer.seek(startPos);
-        ((NBJavacParser.EndPosTableImpl)endPos).resetErrorEndPos();
-        return new NBJavacParser(this, lexer, true, false, true, false, cancelService) {
-            @Override protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
-                return new AbstractEndPosTable(this) {
-
-                    @Override
-                    public void storeEnd(JCTree tree, int endpos) {
-                        ((EndPosTableImpl)endPos).storeEnd(tree, endpos);
-                    }
-
-                    @Override
-                    protected <T extends JCTree> T to(T t) {
-                        storeEnd(t, token.endPos);
-                        return t;
-                    }
-
-                    @Override
-                    protected <T extends JCTree> T toP(T t) {
-                        storeEnd(t, S.prevToken().endPos);
-                        return t;
-                    }
-
-                    @Override
-                    public int getEndPos(JCTree tree) {
-                        return endPos.getEndPos(tree);
-                    }
-
-                    @Override
-                    public int replaceTree(JCTree oldtree, JCTree newtree) {
-                        return endPos.replaceTree(oldtree, newtree);
-                    }
-
-                    @Override
-                    public void setErrorEndPos(int errPos) {
-                        super.setErrorEndPos(errPos);
-                        ((EndPosTableImpl)endPos).setErrorEndPos(errPos);
-                    }
-                };
-            }
-        };
-    }
-
     public static class NBJavacParser extends JavacParser {
 
         private final Names names;
@@ -134,7 +89,13 @@ public class NBParserFactory extends ParserFactory {
 
         @Override
         protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
-            return keepEndPositions ? new EndPosTableImpl(this) : super.newEndPosTable(keepEndPositions);
+            AbstractEndPosTable res = super.newEndPosTable(keepEndPositions);
+            
+            if (keepEndPositions) {
+                return new EndPosTableImpl(S, this, (SimpleEndPosTable) res);
+            }
+            
+            return res;
         }
 
         @Override
@@ -176,24 +137,53 @@ public class NBParserFactory extends ParserFactory {
             return toplevel;
         }
         
-        public final class EndPosTableImpl extends SimpleEndPosTable {
+        public final class EndPosTableImpl extends AbstractEndPosTable {
             
-            private EndPosTableImpl(JavacParser parser) {
+            private final Lexer lexer;
+            private final SimpleEndPosTable delegate;
+
+            private EndPosTableImpl(Lexer lexer, JavacParser parser, SimpleEndPosTable delegate) {
                 super(parser);
+                this.lexer = lexer;
+                this.delegate = delegate;
             }
             
-            private void resetErrorEndPos() {
-                errorEndPos = Position.NOPOS;
+            public void resetErrorEndPos() {
+                delegate.errorEndPos = Position.NOPOS;
+                errorEndPos = delegate.errorEndPos;
             }
             
             @Override public void storeEnd(JCTree tree, int endpos) {
                 if (endpos >= 0)
-                    super.storeEnd(tree, endpos);
+                    delegate.storeEnd(tree, endpos);
             }
 
             @Override
             public void setErrorEndPos(int errPos) {
-                super.setErrorEndPos(errPos);
+                delegate.setErrorEndPos(errPos);
+                errorEndPos = delegate.errorEndPos;
+            }
+
+            @Override
+            protected <T extends JCTree> T to(T t) {
+                storeEnd(t, parser.token().endPos);
+                return t;
+            }
+
+            @Override
+            protected <T extends JCTree> T toP(T t) {
+                storeEnd(t, lexer.prevToken().endPos);
+                return t;
+            }
+
+            @Override
+            public int getEndPos(JCTree jctree) {
+                return delegate.getEndPos(jctree);
+            }
+
+            @Override
+            public int replaceTree(JCTree jctree, JCTree jctree1) {
+                return delegate.replaceTree(jctree, jctree1);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
index f8a0c68..e1cd8d9 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
@@ -71,5 +71,8 @@ public class NBResolve extends Resolve {
         if (accessibleOverride) return true;
         return super.isAccessible(env, c, checkInner);
     }
-    
+
+    public static boolean isStatic(Env<AttrContext> env) {
+        return Resolve.isStatic(env);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java
deleted file mode 100644
index 5e171cb..0000000
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.lib.nbjavac.services;
-
-import com.sun.source.tree.BlockTree;
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.Tree;
-import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Symtab;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.comp.Attr;
-import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.comp.Flow;
-import com.sun.tools.javac.comp.TypeEnter;
-import com.sun.tools.javac.parser.JavacParser;
-import com.sun.tools.javac.parser.LazyDocCommentTable;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCBlock;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.tree.JCTree.JCStatement;
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.tree.TreeInfo;
-import com.sun.tools.javac.tree.TreeMaker;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Names;
-import java.nio.CharBuffer;
-import java.util.Map;
-
-/**
- *
- * @author Tomas Zezula
- */
-public class PartialReparser {
-    
-    protected static final Context.Key<PartialReparser> partialReparserKey = new Context.Key<PartialReparser>();
-    
-    public static PartialReparser instance(Context ctx) {
-        PartialReparser res = ctx.get(partialReparserKey);
-        
-        if (res == null) {
-            ctx.put(partialReparserKey, res = new PartialReparser(ctx));
-        }
-        
-        return res;
-    }
-
-    private final Context context;
-
-    public PartialReparser(Context context) {
-        this.context = context;
-    }
-
-    public JCBlock reparseMethodBody(CompilationUnitTree topLevel, MethodTree methodToReparse, String newBodyText, int annonIndex,
-            final Map<? super JCTree,? super LazyDocCommentTable.Entry> docComments) {
-        NBParserFactory parserFactory = (NBParserFactory) NBParserFactory.instance(context);
-        CharBuffer buf = CharBuffer.wrap((newBodyText+"\u0000").toCharArray(), 0, newBodyText.length());
-        JavacParser parser = parserFactory.newParser(buf, ((JCBlock)methodToReparse.getBody()).pos, ((JCCompilationUnit)topLevel).endPositions);
-        final JCStatement statement = parser.parseStatement();
-        NBParserFactory.assignAnonymousClassIndices(Names.instance(context), statement, Names.instance(context).empty, annonIndex);
-        if (statement.getKind() == Tree.Kind.BLOCK) {
-            if (docComments != null) {
-                docComments.putAll(((LazyDocCommentTable) parser.getDocComments()).table);
-            }
-            return (JCBlock) statement;
-        }
-        return null;
-    }
-
-    public BlockTree reattrMethodBody(MethodTree methodToReparse, BlockTree block) {
-        Attr attr = Attr.instance(context);
-        assert ((JCMethodDecl)methodToReparse).localEnv != null;
-        JCMethodDecl tree = (JCMethodDecl) methodToReparse;
-        final Names names = Names.instance(context);
-        final Symtab syms = Symtab.instance(context);
-        final TypeEnter typeEnter = TypeEnter.instance(context);
-        final Log log = Log.instance(context);
-        final TreeMaker make = TreeMaker.instance(context);
-        final Env<AttrContext> env = attr.dupLocalEnv(((JCMethodDecl) methodToReparse).localEnv);
-        final ClassSymbol owner = env.enclClass.sym;
-        if (tree.name == names.init && !owner.type.isErroneous() && owner.type != syms.objectType) {
-            JCBlock body = tree.body;
-            if (body.stats.isEmpty() || !TreeInfo.isSelfCall(body.stats.head)) {
-                body.stats = body.stats.
-                prepend(typeEnter.SuperCall(make.at(body.pos),
-                    List.<Type>nil(),
-                    List.<JCVariableDecl>nil(),
-                    false));
-            } else if ((env.enclClass.sym.flags() & Flags.ENUM) != 0 &&
-                (tree.mods.flags & Flags.GENERATEDCONSTR) == 0 &&
-                TreeInfo.isSuperCall(body.stats.head)) {
-                // enum constructors are not allowed to call super
-                // directly, so make sure there aren't any super calls
-                // in enum constructors, except in the compiler
-                // generated one.
-                log.error(tree.body.stats.head.pos(),
-                          "call.to.super.not.allowed.in.enum.ctor",
-                          env.enclClass.sym);
-                    }
-                }
-        attr.attribStat((JCBlock)block, env);
-        return block;
-    }
-
-    public BlockTree reflowMethodBody(CompilationUnitTree topLevel, ClassTree ownerClass, MethodTree methodToReparse) {
-        Flow flow = Flow.instance(context);
-        TreeMaker make = TreeMaker.instance(context);
-        flow.reanalyzeMethod(make.forToplevel((JCCompilationUnit)topLevel),
-                (JCClassDecl)ownerClass);
-        return methodToReparse.getBody();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
index 1866c5e..e0e11c0 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
+++ b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
@@ -19,11 +19,16 @@
 
 package org.netbeans.lib.nbjavac.services;
 
+import com.sun.source.tree.CompilationUnitTree;
 import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Name;
 import java.io.IOException;
+import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
 import junit.framework.TestCase;
@@ -38,7 +43,7 @@ public class AnonymousNumberingTest extends TestCase {
         super(name);
     }
 
-    public void testCorrectAnonymousIndicesForMethodInvocations() throws IOException {
+    public void testCorrectAnonymousIndicesForMethodInvocations() throws Exception {
         String code = "package test;\n" +
                       "public class Test {\n" +
                       "    public Test main(Object o) {\n" +
@@ -56,9 +61,17 @@ public class AnonymousNumberingTest extends TestCase {
 
         JavacTaskImpl ct = Utilities.createJavac(null, Utilities.fileObjectFor(code));
         
-        ct.analyze();
+        Iterable<? extends CompilationUnitTree> cuts = ct.parse();
+        Iterable<? extends Element> analyze = ct.analyze();
         
+        System.err.println("repair: " + Class.forName("com.sun.tools.javac.comp.Repair"));
         Symtab symTab = Symtab.instance(ct.getContext());
+        
+        for (Symbol.ClassSymbol cs : symTab.getAllClasses()) {
+            if (cs.flatname.toString().contains("test.Test")) {
+                System.err.println("XXX");
+            }
+        }
         Modules modules = Modules.instance(ct.getContext());
         TypeElement first = symTab.getClass(modules.getDefaultModule(), (Name)ct.getElements().getName("test.Test$1"));
         TypeElement second = symTab.getClass(modules.getDefaultModule(), (Name)ct.getElements().getName("test.Test$2"));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
deleted file mode 100644
index 5e76c3c..0000000
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.lib.nbjavac.services;
-
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.model.JavacElements;
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-import junit.framework.TestCase;
-
-/**
- *
- * @author lahvac
- */
-public class CouplingTest extends TestCase {
-
-    public void test200122() throws Exception {
-        String code = "package test; public class Test { void t() { new Runnable() { public void run() {} }; } }";
-        List<String> fqns = compile(code);
-
-        assertEquals(testCoupling(code, false, fqns), testCoupling(code, true, fqns));
-    }
-    
-    //<editor-fold defaultstate="collapsed" desc=" Test Infrastructure ">
-    private static class MyFileObject extends SimpleJavaFileObject {
-        private String text;
-
-        public MyFileObject(String text) {
-            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            this.text = text;
-        }
-
-        @Override
-        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
-            return text;
-        }
-    }
-
-    private File workingDir;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        workingDir = File.createTempFile("CouplingTest", "");
-
-        workingDir.delete();
-        workingDir.mkdirs();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        deleteRecursively(workingDir);
-        super.tearDown();
-    }
-
-    private List<String> compile(String code) throws Exception {
-        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
-        final String version = System.getProperty("java.vm.specification.version"); //NOI18N
-        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
-        assert tool != null;
-
-        StandardJavaFileManager std = tool.getStandardFileManager(null, null, null);
-
-        std.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(workingDir));
-
-        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath, "-source", version, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(new MyFileObject(code)));
-        Iterable<? extends CompilationUnitTree> cuts = ct.parse();
-
-        ct.analyze();
-
-        final List<String> result = new ArrayList<String>();
-
-        new TreePathScanner<Void, Void>() {
-            @Override public Void visitClass(ClassTree node, Void p) {
-                Element el = Trees.instance(ct).getElement(getCurrentPath());
-
-                if (el != null && (el.getKind().isClass() || el.getKind().isInterface())) {
-                    result.add(ct.getElements().getBinaryName((TypeElement) el).toString());
-                }
-
-                return super.visitClass(node, p);
-            }
-        }.scan(cuts, null);
-
-        ct.generate();
-
-        return result;
-    }
-
-    private Set<String> testCoupling(String code, boolean loadFromClasses, List<String> fqns) throws IOException {
-        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
-        assert tool != null;
-
-        StandardJavaFileManager std = tool.getStandardFileManager(null, null, null);
-
-        if (loadFromClasses) {
-            std.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(workingDir));
-            std.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(workingDir));
-        }
-
-        JavacTaskImpl ct = Utilities.createJavac(std);
-        ct.enter();
-        
-        if (loadFromClasses) {
-            for (String fqn : fqns) {
-                assertNotNull(fqn, ((JavacElements)ct.getElements()).getTypeElementByBinaryName(fqn));
-            }
-        }
-
-        ct.parse(Utilities.fileObjectFor(code));
-        ct.analyze();
-
-        Set<String> classInfo = new HashSet<String>();
-
-        for (String fqn : fqns) {
-            ClassSymbol clazz = ((JavacElements)ct.getElements()).getTypeElementByBinaryName(fqn);
-            StringBuilder info = new StringBuilder();
-
-            info.append(clazz.flatname.toString()).append(",");
-            info.append(Long.toHexString(clazz.flags() & ~(Flags.FROMCLASS | Flags.APT_CLEANED))).append(",");
-            info.append(clazz.hasOuterInstance());
-
-            classInfo.add(info.toString());
-        }
-
-        return classInfo;
-    }
-
-    private void deleteRecursively(File f) {
-        if (f.isDirectory()) {
-            for (File c : f.listFiles()) {
-                deleteRecursively(c);
-            }
-        }
-
-        f.delete();
-    }
-    //</editor-fold>
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
index 51ea6f7..2620b79 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
+++ b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
@@ -94,7 +94,7 @@ public class NBClassWriterTest extends NbTestCase {
         final JavacTaskImpl ct = (JavacTaskImpl) ((JavacTool)tool).getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath, "-source", "1.6", "-target", "1.6"), null, Arrays.asList(new MyFileObject(code)), context);
 
         NBClassReader.preRegister(ct.getContext());
-        JavadocClassFinder.preRegister(ct.getContext(), false);
+//        JavadocClassFinder.preRegister(ct.getContext());
         NBClassWriter.preRegister(ct.getContext());
 
         ct.call();
@@ -112,10 +112,10 @@ public class NBClassWriterTest extends NbTestCase {
 
         Context context = new Context();
         NBMessager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
-        JavacTaskImpl ct = (JavacTaskImpl)((JavacTool)tool).getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath), null, Arrays.<JavaFileObject>asList(), context);
+        JavacTaskImpl ct = (JavacTaskImpl)((JavacTool)tool).getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath, "-source", "1.8", "-target", "1.8"), null, Arrays.<JavaFileObject>asList(), context);
 
         NBClassReader.preRegister(ct.getContext());
-        JavadocClassFinder.preRegister(ct.getContext(), false);
+//        JavadocClassFinder.preRegister(ct.getContext());
         NBClassWriter.preRegister(ct.getContext());
         
         PackageElement pack = ct.getElements().getPackageElement(packageName);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
----------------------------------------------------------------------
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
index c0e8a2a..ad8c203 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
+++ b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
@@ -29,6 +29,8 @@ import java.io.Writer;
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Collections;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
@@ -50,14 +52,17 @@ public class Utilities {
         //need to preregister the Messages here, because the getTask below requires Log instance:
         Messager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
         JavacTaskImpl task = (JavacTaskImpl)JavacTool.create().getTask(null, 
-                fm,
-                null, Arrays.asList("-bootclasspath",  bootPath, "-source", version, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(sources),
+                fm, new DiagnosticListener<JavaFileObject>() {
+            @Override
+            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                System.err.println("diagnostic= " + diagnostic);
+            }
+                }
+                , Arrays.asList("-bootclasspath",  bootPath, "-source", version, "-target", version, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(sources),
                 context);
         NBParserFactory.preRegister(context);
         NBTreeMaker.preRegister(context);
-        NBJavadocEnter.preRegister(context);
-        PrintWriter w = new PrintWriter(System.out);
-        JavadocClassFinder.preRegister(context, true);
+        NBEnter.preRegister(context);
         return task;
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/lib.nbjshell/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/lib.nbjshell/nbproject/project.properties b/lib.nbjshell/nbproject/project.properties
index 484c87b..d457ff7 100644
--- a/lib.nbjshell/nbproject/project.properties
+++ b/lib.nbjshell/nbproject/project.properties
@@ -21,3 +21,4 @@ cp.extra=${tools.jar}
 sigtest.skip.check=true
 sigtest.gen.fail.on.error=false
 is.autoload=true
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacapi/build.xml
----------------------------------------------------------------------
diff --git a/libs.javacapi/build.xml b/libs.javacapi/build.xml
index fb52289..216907d 100644
--- a/libs.javacapi/build.xml
+++ b/libs.javacapi/build.xml
@@ -21,4 +21,17 @@
 -->
 <project name="libs.javacapi" default="netbeans" basedir=".">
     <import file="../nbbuild/templates/projectized.xml"/>
+    <target name="-check-nb-javac-exists">
+        <available property="nb-javac.exists" file="../nb-javac/make/netbeans/nb-javac/build.xml"/>
+    </target>
+    <target name="-release.files-build-javac" if="nb-javac.exists">
+        <ant dir="../nb-javac/make/netbeans/nb-javac" target="jar" inheritAll="false"/>
+        <copy file="../nb-javac/make/netbeans/nb-javac/dist/javac-api.jar" tofile="external/nb-javac-api.jar" overwrite="true"/>
+<!--        <property name="release.files.extra" value="modules/ext/nb-javac-api.jar"/>-->
+    </target>
+    <target name="-release.files-delegate" unless="nb-javac.exists">
+        <antcall target="projectized.-release.files" />
+<!--        <property name="release.files.extra" value="modules/ext/nb-javac-api.jar"/>-->
+    </target>
+    <target name="-release.files" depends="-check-nb-javac-exists,-release.files-build-javac,-release.files-delegate" />
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacapi/manifest.mf
----------------------------------------------------------------------
diff --git a/libs.javacapi/manifest.mf b/libs.javacapi/manifest.mf
index 1017f66..7a11322 100644
--- a/libs.javacapi/manifest.mf
+++ b/libs.javacapi/manifest.mf
@@ -4,4 +4,4 @@ OpenIDE-Module-Implementation-Version: 3
 OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/javacapi/Bundle.properties
 OpenIDE-Module-Layer: org/netbeans/libs/javacapi/layer.xml
 OpenIDE-Module-Requires: org.openide.modules.ModuleFormat2
-OpenIDE-Module-Hide-Classpath-Packages: com.sun.javadoc.**, com.sun.source.**, javax.annotation.processing.**, javax.lang.model.**, javax.tools.**, com.sun.tools.javac.**
+XOpenIDE-Module-Hide-Classpath-Packages: com.sun.javadoc.**, com.sun.source.**, javax.annotation.processing.**, javax.lang.model.**, javax.tools.**, com.sun.tools.javac.** com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**, com.sun.tools.classfile.**, com.sun.tools.doclint.**

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacapi/nbproject/project.properties
----------------------------------------------------------------------
diff --git a/libs.javacapi/nbproject/project.properties b/libs.javacapi/nbproject/project.properties
index 66800e7..e9b9f60 100644
--- a/libs.javacapi/nbproject/project.properties
+++ b/libs.javacapi/nbproject/project.properties
@@ -22,6 +22,8 @@ javadoc.title=Javac API
 nbm.homepage=http://jackpot.netbeans.org/
 nbm.module.author=Petr Hrebejk
 spec.version.base=8.21.0
-release.external/nb-javac-api.jar=modules/ext/nb-javac-api.jar
+#release.external/nb-javac-api.jar=modules/ext/nb-javac-api.jar
 javadoc.arch=${basedir}/arch.xml
 module.javadoc.packages=com.sun.source.tree,com.sun.source.util
+requires.nb.javac=true
+requires.nb.javac=true

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacapi/nbproject/project.xml
----------------------------------------------------------------------
diff --git a/libs.javacapi/nbproject/project.xml b/libs.javacapi/nbproject/project.xml
index 21efad0..e068833 100644
--- a/libs.javacapi/nbproject/project.xml
+++ b/libs.javacapi/nbproject/project.xml
@@ -26,6 +26,8 @@
             <code-name-base>org.netbeans.libs.javacapi</code-name-base>
             <module-dependencies/>
             <public-packages>
+                <!-- TODO: need to specify exports here, because fragments cannot add exports - should be fixed? -->
+                <package>org.netbeans.libs.javacapi</package>
                 <package>com.sun.javadoc</package>
                 <package>com.sun.source.doctree</package>
                 <package>com.sun.source.tree</package>
@@ -37,10 +39,10 @@
                 <package>javax.lang.model.util</package>
                 <package>javax.tools</package>
             </public-packages>
-            <class-path-extension>
+<!--            <class-path-extension>
                 <runtime-relative-path>ext/nb-javac-api.jar</runtime-relative-path>
                 <binary-origin>external/nb-javac-api.jar</binary-origin>
-            </class-path-extension>
+            </class-path-extension>-->
         </data>
     </configuration>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacimpl/build.xml
----------------------------------------------------------------------
diff --git a/libs.javacimpl/build.xml b/libs.javacimpl/build.xml
index 30feadd..9cef228 100644
--- a/libs.javacimpl/build.xml
+++ b/libs.javacimpl/build.xml
@@ -27,11 +27,11 @@
     <target name="-release.files-build-javac" if="nb-javac.exists">
         <ant dir="../nb-javac/make/netbeans/nb-javac" target="jar" inheritAll="false"/>
         <copy file="../nb-javac/make/netbeans/nb-javac/dist/javac-impl.jar" tofile="external/nb-javac-impl.jar" overwrite="true"/>
-        <property name="release.files.extra" value="modules/ext/nb-javac-impl.jar"/>
+<!--        <property name="release.files.extra" value="modules/ext/nb-javac-impl.jar"/>-->
     </target>
     <target name="-release.files-delegate" unless="nb-javac.exists">
         <antcall target="projectized.-release.files" />
-        <property name="release.files.extra" value="modules/ext/nb-javac-impl.jar"/>
+<!--        <property name="release.files.extra" value="modules/ext/nb-javac-impl.jar"/>-->
     </target>
     <target name="-release.files" depends="-check-nb-javac-exists,-release.files-build-javac,-release.files-delegate" />
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/libs.javacimpl/manifest.mf
----------------------------------------------------------------------
diff --git a/libs.javacimpl/manifest.mf b/libs.javacimpl/manifest.mf
index 276717c..e0ab3ac 100644
--- a/libs.javacimpl/manifest.mf
+++ b/libs.javacimpl/manifest.mf
@@ -3,5 +3,5 @@ OpenIDE-Module: org.netbeans.libs.javacimpl/1
 OpenIDE-Module-Implementation-Version: 25
 OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/javacimpl/Bundle.properties
 OpenIDE-Module-Requires: org.openide.modules.ModuleFormat2
-OpenIDE-Module-Hide-Classpath-Packages: com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**, com.sun.tools.classfile.**, com.sun.tools.doclint.**
-
+xOpenIDE-Module-Hide-Classpath-Packages: com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**, com.sun.tools.classfile.**, com.sun.tools.doclint.**
+xOpenIDE-Module-Fragment-Host: org.netbeans.libs.javacapi