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

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


The following commit(s) were added to refs/heads/master by this push:
     new 47b72c4  [NETBEANS-299] Fixing parser over classfiles, tested by 
java.source.base/src/org/netbeans/modules/java/source/parsing/ClassParser.java. 
(#389)
47b72c4 is described below

commit 47b72c420698779f17652a23519120e2f52e6662
Author: Jan Lahoda <[email protected]>
AuthorDate: Wed Jan 31 18:47:36 2018 +0100

    [NETBEANS-299] Fixing parser over classfiles, tested by 
java.source.base/src/org/netbeans/modules/java/source/parsing/ClassParser.java. 
(#389)
---
 .../netbeans/modules/java/source/parsing/JavacParser.java   | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

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 c3fb0e9..baa3508 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
@@ -66,6 +66,7 @@ import  javax.swing.event.ChangeListener;
 import javax.swing.text.Document;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
 
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
@@ -724,8 +725,14 @@ public class JavacParser extends Parser {
                 compilerOptions = null;
                 sourceLevel = null;
             }
-            final JavacTaskImpl javacTask = createJavacTask(
-                    cpInfo,
+            AbstractSourceFileObject source = null;
+            if (file != null) {
+                source = FileObjects.sourceFileObject(file, root);
+                if (source.getKind() != Kind.SOURCE) {
+                    source = null;
+                }
+            }
+            final JavacTaskImpl javacTask = createJavacTask(cpInfo,
                     diagnosticListener,
                     sourceLevel != null ? sourceLevel.getSourceLevel() : null,
                     sourceLevel != null ? sourceLevel.getProfile() : null,
@@ -735,7 +742,7 @@ public class JavacParser extends Parser {
                     APTUtils.get(root),
                     compilerOptions,
                     additionalModules,
-                    file != null ? 
Arrays.asList(FileObjects.sourceFileObject(file, root)) : 
Collections.emptyList());
+                    source != null ? Arrays.asList(source) : 
Collections.emptyList());
             Lookup.getDefault()
                   .lookupAll(TreeLoaderRegistry.class)
                   .stream()

-- 
To stop receiving notification emails like this one, please contact
[email protected].

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to