You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "matthiasblaesing (via GitHub)" <gi...@apache.org> on 2025/06/04 19:02:22 UTC

Re: [PR] vue files - include parametric embedding support for javascript and styles [netbeans]

matthiasblaesing commented on PR #8401:
URL: https://github.com/apache/netbeans/pull/8401#issuecomment-2941117472

   @haidubogdan I had another quick look and I noticed, that JS integration did not work properly. I fixed it be cutting down the `VueHtmlEmbeddingProvider` to the scope it should handle (in my first pass I already left an inline comment, that it looked strange). With this code:
   
   ```java
       @Override
       public List<Embedding> getEmbeddings(final Snapshot snapshot) {
           TokenHierarchy<?> tokenHierarchy = snapshot.getTokenHierarchy();
           TokenSequence<?> ts = tokenHierarchy.tokenSequence();
   
           if (ts == null || !ts.isValid()) {
               return Collections.emptyList();
           }
           ts.moveStart();
           List<Embedding> embeddings = new ArrayList<>();
   
           try {
               while (ts.moveNext()) {
                   Token<?> token = ts.token();
                   TokenId id = token.id();
   
                   if (token.text() != null && id == VueTokenId.HTML) {
                       embeddings.add(snapshot.create(ts.offset(), token.length(), TARGET_MIME_TYPE));
                   }
               }
           } catch (Exception ex) {
               return Collections.emptyList();
           }
   
           if (embeddings.isEmpty()) {
               return Collections.emptyList();
           } else {
               return Collections.singletonList(Embedding.create(embeddings));
           }
       }
   ```
   
   Opening `component_01.vue` seems to work correctly. The JS highlighting and code completion worked. The same is true for the style tag.
   
   So why not wrap this up and make it a mergable change, so that we can get it in?


-- 
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-unsubscribe@netbeans.apache.org

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


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

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