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/09/17 18:29:58 UTC

[PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

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

   The CSL/GSF infrastructure of NetBeans provides the basic infrastructure for the editor to highlight other occurrences corresponding to the element the caret is currently being placed on.
   
   For Java and PHP there is an option offered to keep the occurrences, even when the caret is moved of the highlightable element. The occurrences hightlights are then retained until another highlightable element is selected. This is called "Keep Marks" in NetBeans options.
   
   In NB27 for PHP the option to switch "Keep Marks" was wired up, but proved to be problematic. The OccurrenceFinder class, GSF/CSL implementors have to implement, returns highlighting areas. The return consists of indexes into the text content. For normal operation the finder can trivially be run again when the text is modified to update the highlights, this is not the case for the "Keep Marks" case. As the positions of the characters change, caused by deletions and insertions, the highlights can't be updated, as the originating element is not accessible anymore (the caret was moved of it).
   
   The Swing Document class has a solution for this: javax.swing.text.Position. Under the hood CSL/GSF already uses this in the GsfSemanticLayer, so the problem is solved there.
   
   To support "Keep Marks", handling of this configuration has to move to the CSL/GSF level.
   
   In addition to this there is no need to scan for occurrences if the highlighting is disabled, so that also moves to the CSL/GSF layer.
   
   With the infrastructure in place, in addition to Java and PHP (now fixed), support is added for:
   
   - ANTLR 3
   - ANTLR 4
   - Groovy
   - Expression Language (JSF/JSP)
   - CSS
   - Javascript
   - JSON
   
   <img width="482" height="324" alt="grafik" src="https://github.com/user-attachments/assets/84361cb8-851e-4d39-a564-f797a93c8e10" />
   
   <img width="482" height="324" alt="grafik" src="https://github.com/user-attachments/assets/376a5f8b-fc87-4253-b4e7-6014fe118c60" />
   
   Closes: #8803


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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #8844:
URL: https://github.com/apache/netbeans/pull/8844#issuecomment-3316109195

   its a bit unfortunate that things like this add so much duplicated UI code :( But other than that a great addition of course.
   
   (e.g was working on fixes for the go-to (ctrl+o) dialogs when I saw that its 3 different impls which diverged over time.)


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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

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


##########
ide/csl.api/src/org/netbeans/modules/csl/editor/semantic/MarkOccurrencesHighlighter.java:
##########
@@ -124,9 +124,22 @@ public void run(ParserResult info, SchedulerEvent event) {
                     } catch (BadLocationException ex) {}
                 }
             }
-            layer.setColorings(seqs);
 
-            OccurrencesMarkProvider.get(doc).setOccurrences(OccurrencesMarkProvider.createMarks(doc, bag, ES_COLOR, NbBundle.getMessage(MarkOccurrencesHighlighter.class, "LBL_ES_TOOLTIP")));
+            boolean updateHighlights = false;
+            if(seqs.isEmpty()) {

Review Comment:
   ```suggestion
               if (seqs.isEmpty()) {
   ```



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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

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


##########
enterprise/web.el/src/org/netbeans/modules/web/el/options/MarkOccurencesPanel.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.web.el.options;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import javax.swing.JCheckBox;
+import org.openide.awt.*;
+import org.openide.util.Exceptions;
+
+public class MarkOccurencesPanel extends javax.swing.JPanel {

Review Comment:
   Nitpick: FQNs used, here and below.
   



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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #8844:
URL: https://github.com/apache/netbeans/pull/8844#issuecomment-3319482950

   @mipaaa @troizet @lkishalmi @mbien @tmysik thanks for testing/review/checking.
   
   I intent to merge this by the end of the week unless there are objections raised till then.


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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

Posted by "troizet (via GitHub)" <gi...@apache.org>.
troizet commented on PR #8844:
URL: https://github.com/apache/netbeans/pull/8844#issuecomment-3307613115

   @matthiasblaesing I tested the dev build. Everything works great. Thank you very much!


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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

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


##########
ide/css.editor/src/org/netbeans/modules/css/editor/options/MarkOccurencesPanel.java:
##########
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.css.editor.options;
+
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import javax.swing.JCheckBox;
+import org.openide.util.Exceptions;
+
+public class MarkOccurencesPanel extends javax.swing.JPanel {

Review Comment:
   Nitpick: more FQNs usages, here and possibly in other files.
   



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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #8844:
URL: https://github.com/apache/netbeans/pull/8844#issuecomment-3307785622

   @lahodaj @junichi11 @tmysik @lkishalmi it would be great if you could have a look at this.
   
   The storage of preferences in the antlr and javascript modules feels a bit strange, but I think it is in line with the established usage in the Java and PHP modules.
   
   The API addition should be safe from my POV. Implementors might already implement the new methods, but I think the names match their usecase, so that should not be a problem. Differing return values would violate the JavaBeans contract.
   


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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

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


##########
ide/csl.api/src/org/netbeans/modules/csl/editor/semantic/MarkOccurrencesHighlighter.java:
##########
@@ -124,9 +124,22 @@ public void run(ParserResult info, SchedulerEvent event) {
                     } catch (BadLocationException ex) {}
                 }
             }
-            layer.setColorings(seqs);
 
-            OccurrencesMarkProvider.get(doc).setOccurrences(OccurrencesMarkProvider.createMarks(doc, bag, ES_COLOR, NbBundle.getMessage(MarkOccurrencesHighlighter.class, "LBL_ES_TOOLTIP")));
+            boolean updateHighlights = false;
+            if(seqs.isEmpty()) {
+                OccurrencesFinder finder = language.getOccurrencesFinder();
+                if (finder == null || !finder.isMarkOccurrencesEnabled() || !finder.isKeepMarks()) {
+                    updateHighlights = true;
+                }
+            } else {
+                updateHighlights = true;
+            }
+
+            if(updateHighlights) {

Review Comment:
   ```suggestion
               if (updateHighlights) {
   ```



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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

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


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


Re: [PR] Move CSL/GSF mark occurrences handling into API module and fix PHP highlighting [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #8844:
URL: https://github.com/apache/netbeans/pull/8844#issuecomment-3316092017

   Pushed changesets with the points raised by @tmysik (these will be squashed before merge).


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