You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "dbalek (via GitHub)" <gi...@apache.org> on 2023/05/25 16:44:57 UTC

[GitHub] [netbeans] dbalek opened a new pull request, #5991: Enable Micronaut HyperlinkProviders - deadlocks fixed.

dbalek opened a new pull request, #5991:
URL: https://github.com/apache/netbeans/pull/5991

   Enable Micronaut HyperlinkProviders again. Deadlocks fixed - `ParserManager.parse(...)` should not be called from AWT EDT anymore.


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


[GitHub] [netbeans] dbalek merged pull request #5991: Enable Micronaut HyperlinkProviders - deadlocks fixed.

Posted by "dbalek (via GitHub)" <gi...@apache.org>.
dbalek merged PR #5991:
URL: https://github.com/apache/netbeans/pull/5991


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


[GitHub] [netbeans] sdedic commented on a diff in pull request #5991: Enable Micronaut HyperlinkProviders - deadlocks fixed.

Posted by "sdedic (via GitHub)" <gi...@apache.org>.
sdedic commented on code in PR #5991:
URL: https://github.com/apache/netbeans/pull/5991#discussion_r1209016354


##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/hyperlink/MicronautConfigHyperlinkProvider.java:
##########
@@ -80,10 +95,26 @@ public boolean isHyperlinkPoint(Document doc, int offset, HyperlinkType type) {
 
     @Override
     public int[] getHyperlinkSpan(Document doc, int offset, HyperlinkType type) {
-        int[] span = new int[2];
-        List<ConfigurationMetadataSource> sources = new ArrayList<>();
-        ConfigurationMetadataProperty property = MicronautConfigUtilities.resolveProperty(doc, offset, span, sources);
-        return property != null || !sources.isEmpty() ? span : null;
+        String mimeType = DocumentUtilities.getMimeType(doc);
+        if ("text/x-yaml".equals(mimeType)) {
+            List<int[]> spans = null;
+            synchronized (doc) {
+                spans = (List<int[]>) doc.getProperty(SPANS_PROPERTY_NAME);
+            }
+            if (spans != null) {
+                for (int[] span : spans) {
+                    if (span.length == 2 && span[0] <= offset && offset <= span[1]) {

Review Comment:
   Maybe `< span[1]` (exclusive) ?



##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/MicronautConfigUtilities.java:
##########
@@ -211,6 +194,70 @@ public static void collectUsages(FileObject fo, String propertyName, Consumer<Us
             Exceptions.printStackTrace(ex);
         }
     }
+    
+    public static List<int[]> getPropertySpans(Project project, Parser.Result r) {
+        List<int[]> spans = new ArrayList<>();
+        if (r instanceof ParserResult) {
+            Language language = LanguageRegistry.getInstance().getLanguageByMimeType(r.getSnapshot().getMimeType());
+            if (language != null) {
+                StructureScanner scanner = language.getStructure();
+                if (scanner != null) {
+                    Map<String, ConfigurationMetadataGroup> groups = MicronautConfigProperties.getGroups(project);
+                    scan(scanner.scan((ParserResult) r), new Stack<>(), context -> {
+                        if (!context.empty()) {
+                            String propertyName = getPropertyName(context);
+                            List<ConfigurationMetadataSource> sources = new ArrayList<>();
+                            ConfigurationMetadataProperty property = getProperty(groups, propertyName, sources);

Review Comment:
   Does this depend on the scanning context ? If not, pls. move outside of the lambda - less invocations.



##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/hyperlink/MicronautConfigHyperlinkProvider.java:
##########
@@ -42,28 +44,41 @@
 import org.netbeans.api.java.source.ui.ElementOpen;
 import org.netbeans.api.lsp.HyperlinkLocation;
 import org.netbeans.api.progress.BaseProgressUtils;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
 import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt;
 import org.netbeans.lib.editor.hyperlink.spi.HyperlinkType;
+import org.netbeans.lib.editor.util.swing.DocumentUtilities;
+import org.netbeans.modules.micronaut.MicronautConfigProperties;
 import org.netbeans.modules.micronaut.MicronautConfigUtilities;
+import org.netbeans.modules.parsing.api.Snapshot;
+import org.netbeans.modules.parsing.spi.IndexingAwareParserResultTask;
+import org.netbeans.modules.parsing.spi.Parser;
+import org.netbeans.modules.parsing.spi.Scheduler;
+import org.netbeans.modules.parsing.spi.SchedulerEvent;
+import org.netbeans.modules.parsing.spi.SchedulerTask;
+import org.netbeans.modules.parsing.spi.TaskFactory;
+import org.netbeans.modules.parsing.spi.TaskIndexingMode;
 import org.netbeans.spi.lsp.HyperlinkLocationProvider;
+import org.openide.filesystems.FileObject;
 import org.openide.util.NbBundle;
 import org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty;
 import org.springframework.boot.configurationmetadata.ConfigurationMetadataSource;
 
 /**
- * CURRENTLY NOT ACTIVE - @MimeRegistration DISABLED to work around 
- * <a href="https://github.com/apache/netbeans/issues/3913">GITHUB-3913</a>
- *
+ * 
  * @author Dusan Balek
  */
 public class MicronautConfigHyperlinkProvider implements HyperlinkProviderExt {
 
-    //@MimeRegistration(mimeType = "text/x-yaml", service = HyperlinkProviderExt.class, position = 1250)
+    private static final String SPANS_PROPERTY_NAME = "MicronautConfigHyperlinkSpans";
+
+    @MimeRegistration(mimeType = "text/x-yaml", service = HyperlinkProviderExt.class, position = 1250)

Review Comment:
   nitpick: constant for YAML MIME type?



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


[GitHub] [netbeans] dbalek commented on a diff in pull request #5991: Enable Micronaut HyperlinkProviders - deadlocks fixed.

Posted by "dbalek (via GitHub)" <gi...@apache.org>.
dbalek commented on code in PR #5991:
URL: https://github.com/apache/netbeans/pull/5991#discussion_r1209062186


##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/hyperlink/MicronautConfigHyperlinkProvider.java:
##########
@@ -80,10 +95,26 @@ public boolean isHyperlinkPoint(Document doc, int offset, HyperlinkType type) {
 
     @Override
     public int[] getHyperlinkSpan(Document doc, int offset, HyperlinkType type) {
-        int[] span = new int[2];
-        List<ConfigurationMetadataSource> sources = new ArrayList<>();
-        ConfigurationMetadataProperty property = MicronautConfigUtilities.resolveProperty(doc, offset, span, sources);
-        return property != null || !sources.isEmpty() ? span : null;
+        String mimeType = DocumentUtilities.getMimeType(doc);
+        if ("text/x-yaml".equals(mimeType)) {
+            List<int[]> spans = null;
+            synchronized (doc) {
+                spans = (List<int[]>) doc.getProperty(SPANS_PROPERTY_NAME);
+            }
+            if (spans != null) {
+                for (int[] span : spans) {
+                    if (span.length == 2 && span[0] <= offset && offset <= span[1]) {

Review Comment:
   Go to declaration usually works even if caret is placed at the identifier end position `someId|`



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