lahodaj commented on a change in pull request #1890: [NETBEANS-3693] Create 
only one instance of javac
URL: https://github.com/apache/netbeans/pull/1890#discussion_r369129150
 
 

 ##########
 File path: 
java/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
 ##########
 @@ -582,24 +608,37 @@ Phase moveToPhase (final Phase phase, final 
CompilationInfoImpl currentInfo,
                 }
                 long start = System.currentTimeMillis();
                 // XXX - this might be with wrong encoding
-                Iterable<? extends CompilationUnitTree> trees;
+                Iterable<? extends CompilationUnitTree> trees=null;
+                CompilationUnitTree unit=null;
+                if(snapshots.size()>1 && 
parsedTrees.containsKey(currentInfo.jfo.getName())){
+                    unit=parsedTrees.get(currentInfo.jfo.getName());
+                }
+                else{
                 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;
-                }
-                Iterator<? extends CompilationUnitTree> it = trees.iterator();
-                if (!it.hasNext()) {
-                    LOGGER.log( Level.INFO, "Did not parse anything for: {0}", 
currentInfo.jfo.toUri()); //NOI18N
-                    return Phase.MODIFIED;
+                if (unit == null) {
+                    if (trees == null) {
+                        LOGGER.log(Level.INFO, "Did not parse anything for: 
{0}", currentInfo.jfo.toUri()); //NOI18N
+                        return Phase.MODIFIED;
+                    }
+                    Iterator<? extends CompilationUnitTree> it = 
trees.iterator();
+                    if (!it.hasNext()) {
+                        LOGGER.log(Level.INFO, "Did not parse anything for: 
{0}", currentInfo.jfo.toUri()); //NOI18N
+                        return Phase.MODIFIED;
+                    }
+                    while (it.hasNext()) {
+                        CompilationUnitTree oneFileTree = it.next();
+                        CompilationUnitTree put = parsedTrees.put( 
oneFileTree.getSourceFile().getName(), oneFileTree);
+                    }
+                    unit = trees.iterator().next();
+                    }
                 }
-                CompilationUnitTree unit = it.next();
+               
                 currentInfo.setCompilationUnit(unit);
-                assert !it.hasNext();
+                //assert !it.hasNext();
 
 Review comment:
   Probably just delete the assert.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
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