mbien commented on code in PR #8460:
URL: https://github.com/apache/netbeans/pull/8460#discussion_r2061495133


##########
java/maven.hints/src/org/netbeans/modules/maven/hints/pom/MavenPOMParser.java:
##########
@@ -76,13 +78,17 @@ public void parse(Snapshot snapshot, Task task, 
SourceModificationEvent event) t
             return;
         }
         //#236116 passing document protects from looking it up later and 
causing a deadlock.
-        final BaseDocument document = 
(BaseDocument)snapshot.getSource().getDocument(false);
+        final Document doc = snapshot.getSource().getDocument(false);
         final DataObject d = sFile.getLookup().lookup(DataObject.class);
+        try {
+            final BaseDocument document = Utilities.asBaseDocument(doc, d);
         ModelSource ms = Utilities.createModelSource(sFile, d, document);
         synchronized (this) {
             theModel = POMModelFactory.getDefault().getModel(ms);
             lastSnapshot = snapshot;
         }
+        } catch (IOException ignored) {
+    }

Review Comment:
   would replace this section with:
   ```java
           final Document document = snapshot.getSource().getDocument(false);
           final DataObject d = sFile.getLookup().lookup(DataObject.class);
           ModelSource ms = Utilities.createModelSource(sFile, d, document 
instanceof BaseDocument bd ? bd : null);
           synchronized (this) {
               theModel = POMModelFactory.getDefault().getModel(ms);
               lastSnapshot = snapshot;
           }
   ```
   and drop the change in `Utilities`.
   
   Looking through the `getDocument()` code and the comments in it, it sounds 
like that the VSCode plugins will hit fallback paths which were meant for tests 
when the document type is not `BaseDocument`. Other methods throw illegal 
argument exceptions when document isn't `BaseDocument`.
   
   But adding the instanceof check as hotfix is probably ok.



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

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

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

Reply via email to