matthiasblaesing commented on code in PR #8401:
URL: https://github.com/apache/netbeans/pull/8401#discussion_r2052730951


##########
ide/css.lib/src/org/netbeans/modules/css/lib/nbparser/CssParser.java:
##########
@@ -93,12 +93,23 @@ public void parse(Snapshot snapshot, Task task, 
SourceModificationEvent event) t
             
             //parse just an empty string in case of an oversize snapshot
             CharSequence source = tooLargeSnapshot ? "" : snapshot.getText();
-            
+
+            String mimePath = snapshot.getMimePath() != null ? 
snapshot.getMimePath().getPath() : null;
+            if (mimePath != null) {
+                //vue plugin embedding
+                if (mimePath.startsWith("text/x-vue/text/scss")) { //NOI18N
+                    mimeType = "text/scss"; //NOI18N
+                } else if (mimePath.startsWith("text/x-vue/text/less")){ 
//NOI18N
+                    mimeType = "text/less"; //NOI18N
+                }
+            }
+

Review Comment:
   I think we should fix the CSS parsing correctly. Currently CSS/SCSS/LESS 
switching is a mess as it relies on three different patterns. Before this 
change:
   
   - for tests the mimetype is forced via the constructor 
`org.netbeans.modules.css.lib.nbparser.CssParser.CssParser(String)`
   - for "plain" stylesheets it is deduced from the file mimetype
   - for all other types parsing falls hard to `text/css`
   
   What I envision (please see if want to pursue this, else I'll create a 
followup) is, that we drop the specialcases like this:
   
   - check the inner most element of the mimepath 
(`snapshot.getMimePath().getMimeType(snapshot.getMimePath().size() - 1)`)
   - if that is from the set `text/less`, `text/scss` or `text/css` use it, 
else fall back to `text/css`
   
   For unittests we should be able to create a correct snapshot, for normal 
execution, the behaviour should match.
   
   That way we don't need to special case CSS/SCSS/LESS embeddings in other 
languages and the new vue-specialcase is not necessary.



##########
webcommon/javascript2.vue/src/org/netbeans/modules/javascript2/vue/resources/vue16.png:
##########


Review Comment:
   Nicer. I asumme you are still the author?



##########
webcommon/javascript2.vue/src/org/netbeans/modules/javascript2/vue/editor/embedding/VueHtmlEmbeddingProvider.java:
##########
@@ -33,21 +33,22 @@
 
 /**
  * this will enable braces matches of html elements
- * 
+ *
  * @author bhaidu
  */
 @EmbeddingProvider.Registration(
         mimeType = VueLanguage.MIME_TYPE,
         targetMimeType = "text/html")

Review Comment:
   Replace with `TARGET_MIME_TYPE` (as done in other place)



##########
webcommon/javascript2.vue/src/org/netbeans/modules/javascript2/vue/editor/embedding/VueHtmlEmbeddingProvider.java:
##########
@@ -61,12 +62,16 @@ public List<Embedding> getEmbeddings(final Snapshot 
snapshot) {
 
                 if (id.equals(VueTokenId.HTML)) {
                     embeddings.add(snapshot.create(ts.offset(), t.length(), 
TARGET_MIME_TYPE));
+                } else if (t.text() != null) {
+                    //issue with bracematcher
+                    String fake = new String(new 
char[t.text().toString().length()]).replace("\0", FILLER); //NOI18N

Review Comment:
   Please check if this works:
   
   ```suggestion
                       String fake = new String(new 
char[t.length()]).replace("\0", FILLER); //NOI18N
   ```



##########
webcommon/javascript2.vue/src/org/netbeans/modules/javascript2/vue/editor/embedding/VueHtmlEmbeddingProvider.java:
##########
@@ -61,12 +62,16 @@ public List<Embedding> getEmbeddings(final Snapshot 
snapshot) {
 
                 if (id.equals(VueTokenId.HTML)) {
                     embeddings.add(snapshot.create(ts.offset(), t.length(), 
TARGET_MIME_TYPE));
+                } else if (t.text() != null) {
+                    //issue with bracematcher
+                    String fake = new String(new 
char[t.text().toString().length()]).replace("\0", FILLER); //NOI18N
+                    embeddings.add(snapshot.create(fake, TARGET_MIME_TYPE));

Review Comment:
   It would be great to have an example what goes wrong here. I have an idea, 
but like to verify. Thank you.



##########
webcommon/javascript2.vue/test/unit/data/testfiles/embedding/vue_embedding_01.vue:
##########
@@ -0,0 +1,51 @@
+<!--

Review Comment:
   For tests please include the ASF header. There is no need to skip it and we 
should carry it where possible. This comment applies for other test files too.



##########
webcommon/javascript2.vue/src/org/netbeans/modules/javascript2/vue/editor/lexer/VueLexer.java:
##########
@@ -29,6 +29,13 @@
  * @author bogdan.haidu
  */
 public class VueLexer extends AbstractAntlrLexerBridge<VueAntlrColoringLexer, 
VueTokenId> {
+    public static final String PUG_LANG = "pug"; //NOI18N
+    public static final String JADE_LANG = "jade"; //NOI18N
+    
+    //Styles
+    //embedding not working in netbeans ide
+    public static final String SCSS_LANG = "scss"; //NOI18N
+    public static final String LESS_LANG = "less"; //NOI18N

Review Comment:
   With the suggested changes for `CssParser` it should be possible to create a 
mimepath `text/x-vue/text/scss`, that will be properly handled. This might 
reveals broken assumptions in the CSS parser, but then we should fix them ;-)



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