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/12/18 06:43:00 UTC

[incubator-netbeans] branch jdk-javac updated: Fixing several bugs reported by Matthias: disabling binary indexer while on JDK 8; fixing logic for multi source without nb-javac.

This is an automated email from the ASF dual-hosted git repository.

jlahoda pushed a commit to branch jdk-javac
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/jdk-javac by this push:
     new eafb250  Fixing several bugs reported by Matthias: disabling binary indexer while on JDK 8; fixing logic for multi source without nb-javac.
eafb250 is described below

commit eafb250e0f8a861321359f58dfb92d826c63312c
Author: Jan Lahoda <jl...@netbeans.org>
AuthorDate: Mon Dec 18 07:42:35 2017 +0100

    Fixing several bugs reported by Matthias: disabling binary indexer while on JDK 8; fixing logic for multi source without nb-javac.
---
 .../netbeans/modules/java/source/base/layer.xml    |  3 --
 .../java/source/indexing/JavaBinaryIndexer.java    |  7 ++++
 .../modules/java/source/parsing/JavacParser.java   |  4 +-
 .../java/source/parsing/JavacParserTest.java       | 48 +++++++++++++++++++++-
 4 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml b/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml
index 1dad21e..dd4d338 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml
+++ b/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml
@@ -23,9 +23,6 @@
 <filesystem>
 
     <folder name="Editors">
-        <file name="JavaBinaryIndexer.instance">
-            <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.indexing.JavaBinaryIndexer$Factory"/>
-        </file>
         <file name="COSSynchronizingIndexer.instance">
             <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.indexing.COSSynchronizingIndexer$Factory"/>
         </file>
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 f0c3418..7875bda 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
@@ -44,11 +44,13 @@ import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
 import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
 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.ElementUtils;
+import org.netbeans.modules.java.source.NoJavacHelper;
 import org.netbeans.modules.java.source.base.Module;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
@@ -289,5 +291,10 @@ public class JavaBinaryIndexer extends BinaryIndexer {
                 Exceptions.printStackTrace(ex);
             }
         }
+
+        @MimeRegistration(mimeType="", service=BinaryIndexerFactory.class)
+        public static Factory register() {
+            return NoJavacHelper.hasWorkingJavac() ? new Factory() : null;
+        }
     }
 }
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 c878ef1..dbacaa3 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
@@ -406,8 +406,8 @@ public class JavacParser extends Parser {
                 default:
                     init (snapshot, task, false);
                     ciImpl = createCurrentInfo(this, file, root, snapshot,
-                        sequentialParsing != null && ciImpl == null ? null : ciImpl.getJavacTask(),
-                        sequentialParsing != null && ciImpl == null ? null : ciImpl.getDiagnosticListener());
+                        sequentialParsing == null || ciImpl == null ? null : ciImpl.getJavacTask(),
+                        sequentialParsing == null || ciImpl == null ? null : ciImpl.getDiagnosticListener());
             }
             success = true;
         } finally {
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 8b24495..0a3fd93 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
@@ -31,6 +31,7 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.lang.model.element.TypeElement;
@@ -51,11 +52,14 @@ import org.netbeans.api.lexer.TokenHierarchy;
 import org.netbeans.api.lexer.TokenSequence;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.source.tasklist.CompilerSettings;
+import org.netbeans.modules.openide.util.GlobalLookup;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 import org.openide.loaders.DataObject;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
 
 /**
  *
@@ -75,7 +79,7 @@ public class JavacParserTest extends NbTestCase {
         prepareTest();
     }
 
-    public void Dtest1() throws Exception {
+    public void testMultiSource() throws Exception {
         FileObject f1 = createFile("test/Test1.java", "package test; class Test1");
         FileObject f2 = createFile("test/Test2.java", "package test; class Test2{}");
         FileObject f3 = createFile("test/Test3.java", "package test; class Test3{}");
@@ -86,7 +90,7 @@ public class JavacParserTest extends NbTestCase {
         SourceUtilsTestUtil.compileRecursively(sourceRoot);
 
         js.runUserActionTask(new Task<CompilationController>() {
-
+            TypeElement storedJLObject;
             public void run(CompilationController parameter) throws Exception {
                 if ("Test3".equals(parameter.getFileObject().getName())) {
                     TypeElement te = parameter.getElements().getTypeElement("test.Test1");
@@ -95,10 +99,50 @@ public class JavacParserTest extends NbTestCase {
                 }
                 assertEquals(Phase.PARSED, parameter.toPhase(Phase.PARSED));
                 assertNotNull(parameter.getCompilationUnit());
+                TypeElement jlObject = parameter.getElements().getTypeElement("java.lang.Object");
+
+                if (storedJLObject == null) {
+                    storedJLObject = jlObject;
+                } else {
+                    assertEquals(storedJLObject, jlObject);
+                }
             }
         }, true);
     }
 
+    public void testMultiSourceVanilla() throws Exception {
+        Lookup noSP = Lookups.exclude(Lookup.getDefault(), JavacParser.SequentialParsing.class);
+        GlobalLookup.execute(noSP, () -> {
+            try {
+                FileObject f1 = createFile("test/Test1.java", "package test; class Test1");
+                FileObject f2 = createFile("test/Test2.java", "package test; class Test2{}");
+                FileObject f3 = createFile("test/Test3.java", "package test; class Test3{}");
+
+                ClasspathInfo cpInfo = ClasspathInfo.create(f2);
+                JavaSource js = JavaSource.create(cpInfo, f2, f3);
+
+                SourceUtilsTestUtil.compileRecursively(sourceRoot);
+
+                js.runUserActionTask(new Task<CompilationController>() {
+                    TypeElement storedJLObject;
+                    public void run(CompilationController parameter) throws Exception {
+                        assertEquals(Phase.PARSED, parameter.toPhase(Phase.PARSED));
+                        assertNotNull(parameter.getCompilationUnit());
+                        TypeElement jlObject = parameter.getElements().getTypeElement("java.lang.Object");
+
+                        if (storedJLObject == null) {
+                            storedJLObject = jlObject;
+                        } else {
+                            assertFalse(Objects.equals(storedJLObject, jlObject));
+                        }
+                    }
+                }, true);
+            } catch (Exception ex) {
+                throw new AssertionError(ex);
+            }
+        });
+    }
+
     public void test199332() throws Exception {
         settings.commandLine = "-Xlint:serial";
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@netbeans.apache.org" <co...@netbeans.apache.org>'].