haidubogdan commented on code in PR #8401: URL: https://github.com/apache/netbeans/pull/8401#discussion_r2106130988
########## ide/css.lib/src/org/netbeans/modules/css/lib/nbparser/CssParser.java: ########## @@ -81,24 +81,40 @@ public void parse(Snapshot snapshot, Task task, SourceModificationEvent event) t if (snapshot == null) { return; } - + this.snapshot = snapshot; FileObject fo = snapshot.getSource().getFileObject(); - String fileName = fo == null ? "no file" : fo.getPath(); //NOI18N - String mimeType = topLevelSnapshotMimetype != null ? topLevelSnapshotMimetype : (fo == null ? null : fo.getMIMEType()); + String fileName; + String mimeType; + if (fo != null) { + fileName= fo.getPath(); + MimePath mimePath = snapshot.getMimePath(); + + //scss, less mime embedding is a top layer for text/css + //positioned at the penultimate position + if (mimePath != null && mimePath.size() > 2) { + mimeType = mimePath.getMimeType(mimePath.size() - 2); + } else { + mimeType = fo.getMIMEType(); + } + } else { + fileName = "no file"; + mimeType = topLevelSnapshotMimetype; + } Review Comment: @matthiasblaesing So far I see that the `topLevelSnapshotMimetype` is a flag used in **Test Context** to parse css **Source** Snapshot without a fileObject and also imposing a mimeType. My observation with the current logic is that there is no real check if a **fo** is null or not, yet it's still possible to use a **Source** object without a **FileObject** and have a null **topLevelSnapshotMimetype** . So it will have an exception at this part. ``` fileName= fo.getPath(); ``` Strangely, the update didn't break any tests, so topLevelSnapshotMimetype must be used for sources without a fileObject. My general idea would be that the mimeType should be obtained correctly from the fileObject. Maybe a issue could be with the testUtils which creates a common text/css mimeType document to be used for parsing scss and less files, so the context needs to be created with specific flags. The coupling scss | less => css mimeType is really confusing here :) . -- 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