You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/11/27 13:02:16 UTC

[GitHub] [netbeans] matthiasblaesing opened a new pull request, #5013: Make more hints for java available

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

   There are two PRs currently bitrotting: #2785 and #4522. Both add type information to the java editor view. The type information is shown like the parameter name hint, that is already part of NetBeans. For a visual example please have a look at the linked PRs.
   
   This PR bundles the two, fixes a compilation problem and adds an option to enable and disable the hints individually:
   
   ![Bildschirmfoto vom 2022-11-27 13-49-48](https://user-images.githubusercontent.com/2179736/204136608-764e0243-e23a-424e-aba5-4221d8de6f27.png)


-- 
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] matthiasblaesing commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1328243077

   @neilcsmith-net @mbien @jtulach: What do you think? I agree, that `var` and chaining should not be abused and that code should not rely on IDE to help understanding. However there are times where you don't have influence on decisions or you want to understand better what the `javac`  thinks about your code and then it can help to show the hints.


-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1037728736


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   I see the issue now. This github account was set to render tabs with 4 spaces by default. Feel free to ignore this, however, i think it would still be better for new code to not use tabs at all. Since if they are mixed with spaces like here, it might lead to inconsistent formatting.



-- 
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] neilcsmith-net commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1356770439

   > showing the type for `var` at the end of the line is a nice trick, but I am not sure if it will scale. Specifically, if we try to add the same feature for implicitly type lambda parameters, it will be hard to put the types at the end of the line. Ultimately, `var` will be the an outlier in how other similar things will be handled. (And, overall, we may need to add more stuff at the end of lines - debugging info comes to mind.)
   
   @jlahoda that depends a little whether you consider if it's conceptually the `var` type that should be hinted, or the return type of methods where it's chained or not assigned to the same explicit type. eg. could consider hinting where assignment is to a super type as well as `var`?
   
   Personally I'm not sure completely inline hints scale anyway.  Some users get confused by non-editable text appearing in amongst their text, and they affect formatting of code (eg. by default we show a right margin guide, which becomes less useful the more hints there are).  Whereas there's at least more space at line ends to show information in a potentially less confusing way?  Or we could consider vertical space instead?
   
   I have less concerns where hints are not enabled by default though.
   


-- 
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] matthiasblaesing merged pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing merged PR #5013:
URL: https://github.com/apache/netbeans/pull/5013


-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1034123339


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsPanel.java:
##########
@@ -0,0 +1,214 @@
+/*
+ * 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.java.editor.options;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import javax.swing.JCheckBox;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.editor.EditorRegistry;
+import org.netbeans.modules.editor.NbEditorUtilities;
+import org.netbeans.modules.parsing.api.indexing.IndexingManager;
+import org.openide.util.Exceptions;
+
+
+public class InlineHintsPanel extends javax.swing.JPanel {
+
+    public static final String JAVA_INLINE_HINT_PARAMETER_NAME = "javaInlineHintParameterName"; //NOI18N
+    public static final String JAVA_INLINE_HINT_CHAINED_TYPES = "javaInlineHintChainedTypes"; //NOI18N
+    public static final String JAVA_INLINE_HINT_VAR_TYPE = "javaInlineHintVarType"; //NOI18N
+
+    private static final Map<String, Boolean> DEFAULT_VALUES;
+
+    static {
+        Map<String, Boolean> defaultValuesBuilder = new HashMap<>();
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_PARAMETER_NAME, true);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_CHAINED_TYPES, false);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_VAR_TYPE, false);
+        DEFAULT_VALUES = Collections.unmodifiableMap(defaultValuesBuilder);
+    }
+    
+    private List<JCheckBox> boxes;
+    private InlineHintsOptionsPanelController controller;
+    private boolean changed = false;
+    
+    /** Creates new form InlineHintsPanel */
+    public InlineHintsPanel( InlineHintsOptionsPanelController controller ) {
+        initComponents();
+//        if( "Windows".equals(UIManager.getLookAndFeel().getID()) ) //NOI18N
+//            setOpaque( false );
+        fillBoxes();
+        addListeners();
+        load( controller );
+    }
+    
+    public void load( InlineHintsOptionsPanelController controller ) {
+        this.controller = controller;
+        
+        Preferences node = InlineHintsSettings.getCurrentNode();
+        
+        for (JCheckBox box : boxes) {
+            box.setSelected(node.getBoolean(box.getActionCommand(), DEFAULT_VALUES.get(box.getActionCommand())));
+        }
+        
+        changed = false;
+    }
+    
+    public void store( ) {
+        Preferences node = InlineHintsSettings.getCurrentNode();
+
+        for (javax.swing.JCheckBox box : boxes) {
+            boolean value = box.isSelected();
+            boolean original = node.getBoolean(box.getActionCommand(),
+                                               DEFAULT_VALUES.get(box.getActionCommand()));
+
+            if (value != original) {
+                node.putBoolean(box.getActionCommand(), value);
+            }
+        }
+        try {
+            node.flush();
+        }
+        catch (BackingStoreException ex) {
+            Exceptions.printStackTrace(ex);
+        }
+        changed = false;
+
+        EditorRegistry
+                .componentList()
+                .stream()
+                .map(jtc -> jtc.getDocument())
+                .filter(doc -> doc != null)
+                .map(doc -> NbEditorUtilities.getFileObject(doc))
+                .filter(fo -> fo != null)
+                .forEach(fo -> IndexingManager.getDefault().refreshAllIndices(fo));
+}

Review Comment:
   indentation in front of brace



##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   indentation is missing in a few places in this class. Possibly an issue with tab/spaces if its copy pasted.



##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsPanel.java:
##########
@@ -0,0 +1,214 @@
+/*
+ * 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.java.editor.options;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import javax.swing.JCheckBox;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.editor.EditorRegistry;
+import org.netbeans.modules.editor.NbEditorUtilities;
+import org.netbeans.modules.parsing.api.indexing.IndexingManager;
+import org.openide.util.Exceptions;
+
+
+public class InlineHintsPanel extends javax.swing.JPanel {
+
+    public static final String JAVA_INLINE_HINT_PARAMETER_NAME = "javaInlineHintParameterName"; //NOI18N
+    public static final String JAVA_INLINE_HINT_CHAINED_TYPES = "javaInlineHintChainedTypes"; //NOI18N
+    public static final String JAVA_INLINE_HINT_VAR_TYPE = "javaInlineHintVarType"; //NOI18N
+
+    private static final Map<String, Boolean> DEFAULT_VALUES;
+
+    static {
+        Map<String, Boolean> defaultValuesBuilder = new HashMap<>();
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_PARAMETER_NAME, true);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_CHAINED_TYPES, false);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_VAR_TYPE, false);
+        DEFAULT_VALUES = Collections.unmodifiableMap(defaultValuesBuilder);
+    }
+    
+    private List<JCheckBox> boxes;
+    private InlineHintsOptionsPanelController controller;
+    private boolean changed = false;
+    
+    /** Creates new form InlineHintsPanel */
+    public InlineHintsPanel( InlineHintsOptionsPanelController controller ) {
+        initComponents();
+//        if( "Windows".equals(UIManager.getLookAndFeel().getID()) ) //NOI18N
+//            setOpaque( false );
+        fillBoxes();
+        addListeners();
+        load( controller );
+    }
+    
+    public void load( InlineHintsOptionsPanelController controller ) {

Review Comment:
   nitpick: feel free to ignore but this class uses different formatting rules for methods.



-- 
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] matthiasblaesing commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1037511249


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   This is the result of a clean build from NetBeans:
   
   ![image](https://user-images.githubusercontent.com/2179736/205146655-e8920b5b-f498-42c0-a52b-fd59b7663453.png)
   
   The same on Github (the marked area is 8 chars wide):
   
   ![image](https://user-images.githubusercontent.com/2179736/205147271-bacd3e1c-224f-4d69-97cd-ec3d213dc3e4.png)
   
   The method declaration (`public HelpCtx`) was idented with 4 spaces, the method body (`return new HelpCtx`) is idented by a single tab (equivalent to 8 spaces).



-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1034111025


##########
java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java:
##########
@@ -84,17 +90,78 @@
 import org.netbeans.modules.parsing.spi.SchedulerEvent;
 import org.netbeans.modules.parsing.spi.TaskIndexingMode;
 import org.openide.filesystems.FileUtil;
+import org.openide.util.NbPreferences;
 import org.openide.util.Pair;
+import org.openide.util.WeakListeners;
 
 
 /**
  *
  * @author Jan Lahoda
  */
 public abstract class SemanticHighlighterBase extends JavaParserResultTask {
-    
+
+    public static final String JAVA_INLINE_HINT_PARAMETER_NAME = "javaInlineHintParameterName"; //NOI18N
+    public static final String JAVA_INLINE_HINT_CHAINED_TYPES = "javaInlineHintChainedTypes"; //NOI18N
+    public static final String JAVA_INLINE_HINT_VAR_TYPE = "javaInlineHintVarType"; //NOI18N
+
+    private static final Map<String, Boolean> DEFAULT_VALUES;
+
+    static {
+        Map<String, Boolean> defaultValuesBuilder = new HashMap<>();
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_PARAMETER_NAME, true);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_CHAINED_TYPES, false);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_VAR_TYPE, false);
+        DEFAULT_VALUES = Collections.unmodifiableMap(defaultValuesBuilder);
+    }
+
+    private static final AtomicBoolean inited = new AtomicBoolean();
+    private static Preferences preferences;
+    private static final PreferenceChangeListener preferencesTracker = new PreferenceChangeListener() {
+        @Override
+        public void preferenceChange(PreferenceChangeEvent evt) {
+            String settingName = evt == null ? null : evt.getKey();
+            if (settingName == null || JAVA_INLINE_HINT_PARAMETER_NAME.equals(settingName)) {
+                javaInlineHintParameterName = preferences.getBoolean(JAVA_INLINE_HINT_PARAMETER_NAME, DEFAULT_VALUES.get(JAVA_INLINE_HINT_PARAMETER_NAME));
+            }
+            if (settingName == null || JAVA_INLINE_HINT_CHAINED_TYPES.equals(settingName)) {
+                javaInlineHintChainedTypes = preferences.getBoolean(JAVA_INLINE_HINT_CHAINED_TYPES, DEFAULT_VALUES.get(JAVA_INLINE_HINT_CHAINED_TYPES));
+            }
+            if (settingName == null || JAVA_INLINE_HINT_VAR_TYPE.equals(settingName)) {
+                javaInlineHintVarType = preferences.getBoolean(JAVA_INLINE_HINT_VAR_TYPE, DEFAULT_VALUES.get(JAVA_INLINE_HINT_VAR_TYPE));
+            }
+        }
+    };
+
+    private static boolean javaInlineHintParameterName;
+    private static boolean javaInlineHintChainedTypes;
+    private static boolean javaInlineHintVarType;
+
+    private static boolean isJavaInlineHintParameterName() {
+        lazyInit();
+        return javaInlineHintParameterName;
+    }
+
+    private static boolean isJavaInlineHintChainedTypes() {
+        lazyInit();
+        return javaInlineHintChainedTypes;
+    }
+
+    private static boolean isJavaInlineHintVarType() {
+        lazyInit();
+        return javaInlineHintVarType;
+    }
+
+    private static void lazyInit() {
+        if (inited.compareAndSet(false, true)) {
+            preferences = NbPreferences.root().node("/org/netbeans/modules/java/editor/InlineHints/default");
+            preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
+            preferencesTracker.preferenceChange(null);
+        }

Review Comment:
   this isn't thread safe unfortunately. Since `inited` is set right away without waiting for the block to complete. A second thread could see everything uninitialized while the first is still working on it. This essentially needs to be a critical section while `inited` is converted back to a normal boolean and read and written inside it or:
   
   a trick I sometimes use in situations like this is to use a static initializer of a not exposed inner class and let the classloader do the work lazily.
   
   `PreferencesHolder.get()` would give you the initialized Preferences singleton, `PreferencesHolder.init()`/`get()` would both make sure the listener was called accordingly.
   
   ```java
       // inner class
       private class PreferencesHolder {
           
           private static final Preferences preferences;
           static {
               preferences = NbPreferences.root().node("/org/netbeans/modules/java/editor/InlineHints/default");
               preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
               preferencesTracker.preferenceChange(null);
           }
           
           private static void init(){}
           
           private static Preferences get() {
               return preferences;
           }
           
       }
   ```



-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1036644541


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   NB is displaying the tab char by default with 8 spaces, while github default is 4 i believe. I thought this might be the reason for the difference if tabs were indeed used.
   
   We also had a [thread](https://lists.apache.org/thread/g9w0038rdsksony6xyl4q42vnj4jrjk4) on the dev list which asks if we should change the default to 4 spaces in NB too. Even though 8 is the default in many classic shell editors, 4 seems to have won on the web - its also the most common indentation size in java. It might be also questionable to have an indentation size default which is smaller than tab size default.



-- 
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] mbien commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1328321040

   @matthiasblaesing I had no time to look at the code yet but having more granularity for this setting is great, +1 from me.
   
   The short version about my opinion on inline hints taken from past discussions: I am not a fan of inline-text since the demand for them indicates problems with the code ("code smell"). Code has to be readable without them. Wanting to see the type of a `var` indicates that this probably should not be a `var` - swapping `var` with the type can sometimes even be more compact than letting the IDE draw the type next to `var`. Enabling those kind of hints by default is risky since it could influence how new devs write new code and lead to more var-overuse - if you see the type anyway, why not use `var` literally everywhere. The parameter hints have a similar issue (but this has smaller impact IMO) since they could influence formatting.
   
   So how should an IDE make (somewhat) badly written code more readable without influencing how new code is written? I am not sure.
   
   (one thought: if you really want to see the type of a `var` to understand the code better, why not draw the type _instead_ of `var` with some kind of toggle button. This would be a pure readability aid and would not make sense to have always on while you write code. There is also the `ctrl+p `option to render param types on methods - what if this would appear by default if the cursor is over the method name? Maybe the answer to all this is to have some buttons in the editor toolbar to quickly toggle the setting on or off on demand instead of global options you set once?)
   
   
   But more options is a good start +1 from me - good job Matthias. I wouldn't say no to having them on by default - I just would prefer not to due to the reasons given.


-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1034111025


##########
java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java:
##########
@@ -84,17 +90,78 @@
 import org.netbeans.modules.parsing.spi.SchedulerEvent;
 import org.netbeans.modules.parsing.spi.TaskIndexingMode;
 import org.openide.filesystems.FileUtil;
+import org.openide.util.NbPreferences;
 import org.openide.util.Pair;
+import org.openide.util.WeakListeners;
 
 
 /**
  *
  * @author Jan Lahoda
  */
 public abstract class SemanticHighlighterBase extends JavaParserResultTask {
-    
+
+    public static final String JAVA_INLINE_HINT_PARAMETER_NAME = "javaInlineHintParameterName"; //NOI18N
+    public static final String JAVA_INLINE_HINT_CHAINED_TYPES = "javaInlineHintChainedTypes"; //NOI18N
+    public static final String JAVA_INLINE_HINT_VAR_TYPE = "javaInlineHintVarType"; //NOI18N
+
+    private static final Map<String, Boolean> DEFAULT_VALUES;
+
+    static {
+        Map<String, Boolean> defaultValuesBuilder = new HashMap<>();
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_PARAMETER_NAME, true);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_CHAINED_TYPES, false);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_VAR_TYPE, false);
+        DEFAULT_VALUES = Collections.unmodifiableMap(defaultValuesBuilder);
+    }
+
+    private static final AtomicBoolean inited = new AtomicBoolean();
+    private static Preferences preferences;
+    private static final PreferenceChangeListener preferencesTracker = new PreferenceChangeListener() {
+        @Override
+        public void preferenceChange(PreferenceChangeEvent evt) {
+            String settingName = evt == null ? null : evt.getKey();
+            if (settingName == null || JAVA_INLINE_HINT_PARAMETER_NAME.equals(settingName)) {
+                javaInlineHintParameterName = preferences.getBoolean(JAVA_INLINE_HINT_PARAMETER_NAME, DEFAULT_VALUES.get(JAVA_INLINE_HINT_PARAMETER_NAME));
+            }
+            if (settingName == null || JAVA_INLINE_HINT_CHAINED_TYPES.equals(settingName)) {
+                javaInlineHintChainedTypes = preferences.getBoolean(JAVA_INLINE_HINT_CHAINED_TYPES, DEFAULT_VALUES.get(JAVA_INLINE_HINT_CHAINED_TYPES));
+            }
+            if (settingName == null || JAVA_INLINE_HINT_VAR_TYPE.equals(settingName)) {
+                javaInlineHintVarType = preferences.getBoolean(JAVA_INLINE_HINT_VAR_TYPE, DEFAULT_VALUES.get(JAVA_INLINE_HINT_VAR_TYPE));
+            }
+        }
+    };
+
+    private static boolean javaInlineHintParameterName;
+    private static boolean javaInlineHintChainedTypes;
+    private static boolean javaInlineHintVarType;
+
+    private static boolean isJavaInlineHintParameterName() {
+        lazyInit();
+        return javaInlineHintParameterName;
+    }
+
+    private static boolean isJavaInlineHintChainedTypes() {
+        lazyInit();
+        return javaInlineHintChainedTypes;
+    }
+
+    private static boolean isJavaInlineHintVarType() {
+        lazyInit();
+        return javaInlineHintVarType;
+    }
+
+    private static void lazyInit() {
+        if (inited.compareAndSet(false, true)) {
+            preferences = NbPreferences.root().node("/org/netbeans/modules/java/editor/InlineHints/default");
+            preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
+            preferencesTracker.preferenceChange(null);
+        }

Review Comment:
   this isn't thread safe unfortunately. Since `inited` is set right away without waiting for the block to complete. A second thread could see everything uninitialized while the first is still working on it. This essentially needs to be a critical section while `inited` is converted back to a normal boolean and read and written inside it or:
   
   a trick I sometimes use in situations like this is to use a static initializer of a not exposed inner class and let the classloader do the work lazily.
   
   `get()` would give you the initialized Preferences singleton, `init()`/`get()` would both make sure the listener was called accordingly.
   
   ```java
       // inner class
       private class PreferencesHolder {
           
           private static final Preferences preferences;
           static {
               preferences = NbPreferences.root().node("/org/netbeans/modules/java/editor/InlineHints/default");
               preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
               preferencesTracker.preferenceChange(null);
           }
           
           private static void init(){}
           
           private static Preferences get() {
               return preferences;
           }
           
       }
   ```



-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1036644541


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   NB is displaying the tab char by default with 8 spaces, while github default is 4 i believe. I thought this might be the reason for the difference if tabs were indeed used.
   
   We also had a [thread](https://lists.apache.org/thread/g9w0038rdsksony6xyl4q42vnj4jrjk4) on the dev list which asks if we should change the default to 4 spaces in NB too. Even though 8 is the default in many classic shell editors, 4 seems to have won in the web - its also the most common indentation size in java.



-- 
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] matthiasblaesing commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1343307744

   I pushed an updated version the changes:
   - Rebases onto current master
   - Adjust formatting
   - Move lazy initialization in `Utilities` and `SemanticHighlighterBase` to double checked locking
   - Move types for `var` statements to the end of line
   - Fix rendering of "prepend-text" at EOL (cursor was display in prepend text and EOL special char was overprinted)
   - Make typeinformation for `var` available as tooltip (independed of inline hints). The tooltip can be called when the cursor is one the `var` token and CTRL-P is pressed (it is the keystroke, that shows method parameters).
   
   Result:
   
   ![image](https://user-images.githubusercontent.com/2179736/206559651-f69b7912-3b62-41c7-863d-5182b2494ac2.png)
   
   This has all inline hints enabled and shows the new tooltip


-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1036644541


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   NB is displaying the tab char by default with 8 spaces, while github default is 4 i believe. I thought this might be the reason for the difference if tabs were indeed used.
   
   We also had a [thread](https://lists.apache.org/thread/g9w0038rdsksony6xyl4q42vnj4jrjk4) on the dev list which asks if we should change the default to 4 spaces in NB too. Even though 8 is the default in many classic shell editors, 4 seems to have won in the web.



-- 
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] matthiasblaesing commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1356330215

   > Besides the inline comment: -I am not sure about the Ctrl-P - feels a bit unconceptial, it will be difficult to enhance this to other possible cases (like for implicitly typed lambda parameters, which, frankly, and not really different to vars). 
   
   Well - I used the existing code path, that runs through the completion (type tooltip) code path. From a code perspective it seemed logical. Though...
   
   > The tooltip for Ctrl-mouse is showing types of variables (and could be fixed to also work over `var`), and if a shortcut is needed to allow pure keyboard access, chossing a different action might be more viable for the long term. 
   
   I did not know of the CTRL-mouse way yet. It indeed looks like the right appoach. Could you give me a hint where this is handled (@jlahoda)?
   
   For the placement of the var type - indeed from a readability perspective I think it would be better placed behind the var, though the same is true for the method invocations.


-- 
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] matthiasblaesing commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1352140932

   I'll merge this next weekend, if none objects before 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


[GitHub] [netbeans] jlahoda commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
jlahoda commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1356867473

   The Ctrl-mouse tooltips are computed here: https://github.com/apache/netbeans/blob/9ae371e7494863b6bfbf84fb76ae66449b280e5b/java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java#L137
   
   It may be needed to add the `var` "keyword" into the list here: https://github.com/apache/netbeans/blob/9ae371e7494863b6bfbf84fb76ae66449b280e5b/java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java#L631
   
   It is all used from here (among other places): https://github.com/apache/netbeans/blob/master/java/java.editor/src/org/netbeans/modules/java/editor/hyperlink/JavaHyperlinkProvider.java
   
   Thanks.


-- 
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] matthiasblaesing commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1362065125

   @jlahoda thank you. Indeed the `GoToSupport`  already covers my use case. In my tests it felt a bit flaky, but mostly works:
   
   ![image](https://user-images.githubusercontent.com/2179736/208996878-422e9734-8c32-4bc4-a87c-809c2748ee0a.png)
   
   So I dropped that part from this PR.
   
   The reading of the preferences was simplified and happens now on invocation.
   
   @neilcsmith-net @mbien I returned to the original implementation for the var types. The moment you enable inline hints, the layout is already screwed. Maybe my taste is damaged from working with typescript, but having seen that syntax it looks more natural this way.
   
   ![image](https://user-images.githubusercontent.com/2179736/208997728-099bc55c-5acf-4f61-8aa5-b1a2aeedece0.png)
   
   I still agree, that inline hints should not be needed, but I can imagine situations were I might be happy to have it.
   
   The screenshot shows, that the rendering of the prepend text still works after simplification and now the "prepend text", the cursor and the end-of-line character are all fully rendered (fourth line).


-- 
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] matthiasblaesing commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1365108385

   Lets get this in. Thank you all for taking part in the discussion and review!


-- 
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] mbien commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1362094211

   i have been testing this PR with the following setup and it worked quite well:
    - checked all boxes
    - turned it off by default
    - temp enabled it via hotkey while reading foreign code and I felt it would help
   
   this avoids basically all issues I would encounter while writing code (since its off when i write code). like a cursor which jumps around the inline text which is something I would have to get used to first. It also doesn't interfere in how I write or format code - while aiding with code readability when needed. I really like that.
   
   wondering if it would make sense to add a toolbar toggle icon to the editor toolbar so that this feature and particular usecase could be easier discovered. (doesn't have to be with this PR, just something to think about maybe?)


-- 
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] jlahoda commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
jlahoda commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1050418936


##########
java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java:
##########
@@ -84,17 +85,83 @@
 import org.netbeans.modules.parsing.spi.SchedulerEvent;
 import org.netbeans.modules.parsing.spi.TaskIndexingMode;
 import org.openide.filesystems.FileUtil;
+import org.openide.util.NbPreferences;
 import org.openide.util.Pair;
+import org.openide.util.WeakListeners;
 
 
 /**
  *
  * @author Jan Lahoda
  */
 public abstract class SemanticHighlighterBase extends JavaParserResultTask {
-    
+
+    public static final String JAVA_INLINE_HINT_PARAMETER_NAME = "javaInlineHintParameterName"; //NOI18N
+    public static final String JAVA_INLINE_HINT_CHAINED_TYPES = "javaInlineHintChainedTypes"; //NOI18N
+    public static final String JAVA_INLINE_HINT_VAR_TYPE = "javaInlineHintVarType"; //NOI18N
+
+    private static final Map<String, Boolean> DEFAULT_VALUES;
+
+    static {
+        Map<String, Boolean> defaultValuesBuilder = new HashMap<>();
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_PARAMETER_NAME, true);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_CHAINED_TYPES, false);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_VAR_TYPE, false);
+        DEFAULT_VALUES = Collections.unmodifiableMap(defaultValuesBuilder);
+    }
+
+    private static boolean inited = false;
+    private static Preferences preferences;
+    private static final PreferenceChangeListener preferencesTracker = new PreferenceChangeListener() {

Review Comment:
   Not sure if this listening and updating settings is really needed - it would probably be enough to read the settings at the start of the task. Listening on the change is often only needed to trigger re-run of the tasks when the settings change.



-- 
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] neilcsmith-net commented on pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#issuecomment-1328260743

   Good to see enablement options. My opinion on #4522 is the same as stated there - could we bring it more in line with #2785 ? Hinting method return types, like chaining, at the end of lines would help with most cases of var while not screwing around with formatting within the line.


-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1034127427


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsPanel.java:
##########
@@ -0,0 +1,214 @@
+/*
+ * 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.java.editor.options;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+import javax.swing.JCheckBox;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.editor.EditorRegistry;
+import org.netbeans.modules.editor.NbEditorUtilities;
+import org.netbeans.modules.parsing.api.indexing.IndexingManager;
+import org.openide.util.Exceptions;
+
+
+public class InlineHintsPanel extends javax.swing.JPanel {
+
+    public static final String JAVA_INLINE_HINT_PARAMETER_NAME = "javaInlineHintParameterName"; //NOI18N
+    public static final String JAVA_INLINE_HINT_CHAINED_TYPES = "javaInlineHintChainedTypes"; //NOI18N
+    public static final String JAVA_INLINE_HINT_VAR_TYPE = "javaInlineHintVarType"; //NOI18N
+
+    private static final Map<String, Boolean> DEFAULT_VALUES;
+
+    static {
+        Map<String, Boolean> defaultValuesBuilder = new HashMap<>();
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_PARAMETER_NAME, true);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_CHAINED_TYPES, false);
+        defaultValuesBuilder.put(JAVA_INLINE_HINT_VAR_TYPE, false);
+        DEFAULT_VALUES = Collections.unmodifiableMap(defaultValuesBuilder);
+    }
+    
+    private List<JCheckBox> boxes;
+    private InlineHintsOptionsPanelController controller;
+    private boolean changed = false;
+    
+    /** Creates new form InlineHintsPanel */
+    public InlineHintsPanel( InlineHintsOptionsPanelController controller ) {
+        initComponents();
+//        if( "Windows".equals(UIManager.getLookAndFeel().getID()) ) //NOI18N
+//            setOpaque( false );
+        fillBoxes();
+        addListeners();
+        load( controller );
+    }
+    
+    public void load( InlineHintsOptionsPanelController controller ) {

Review Comment:
   nitpick: feel free to ignore but this class uses different formatting rules for methods compared to the other new code added.



-- 
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] matthiasblaesing commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1036322367


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   It is a copy from the `Controller` in the same directory. Actually your settings might be different. If you look at the changeset on github everything is in line and the same was true on my system (default NetBeans settings). Anyway, I ran the class through the reformatter and it will be updated with spaces.



-- 
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] mbien commented on a diff in pull request #5013: Make more hints for java available

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #5013:
URL: https://github.com/apache/netbeans/pull/5013#discussion_r1036642443


##########
java/java.editor/src/org/netbeans/modules/java/editor/options/InlineHintsOptionsPanelController.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.java.editor.options;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import javax.swing.JComponent;
+import org.netbeans.spi.options.OptionsPanelController;
+import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
+
+public final class InlineHintsOptionsPanelController extends OptionsPanelController {
+    
+    private InlineHintsPanel panel;
+    
+    private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+                    
+    @Override
+    public void update() {
+        panel.load( this );
+    }
+    
+    @Override
+    public void applyChanges() {
+        panel.store();
+    }
+    
+    @Override
+    public void cancel() {
+	// need not do anything special, if no changes have been persisted yet
+    }
+    
+    @Override
+    public boolean isValid() {
+        return true; // Always valid 
+    }
+    
+    @Override
+    public boolean isChanged() {
+	return panel.changed();
+    }
+    
+    @Override
+    public HelpCtx getHelpCtx() {
+	return new HelpCtx("netbeans.optionsDialog.java.inlineHints");

Review Comment:
   wait, you say you don't see it like this:
   ![image](https://user-images.githubusercontent.com/114367/204954628-c63850ec-60a5-4f90-a03e-13127f5aaf0d.png)
   



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