netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Inline hints do not show in some cases, shouldn't they always be visible? (Java)

Open istinnstudio opened this issue 2 years ago • 4 comments

Apache NetBeans version

Apache NetBeans 18

What happened

Actually I am on 17 but this was always there, I guess is in 18 also. Inline hints disappear when the parameter in a method use math operators like -,+, /,* , parameter has the same name or casting the data type,

How to reproduce

just using a negative number as parameter will cause disappearance of inline hints, using e,g. 1/aNumber, or -aNumber, any basic math operator -+/* will do the same

Did this work correctly in an earlier version?

No / Don't know

Operating System

windows 10

JDK

17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

every time

Are you willing to submit a pull request?

No

istinnstudio avatar Jul 02 '23 22:07 istinnstudio

@istinnstudio Could you provide a code example and/or a screenshot?

asbachb avatar Jul 03 '23 12:07 asbachb

ok, in this test class with lots of cases we can trigger the issue, 1, for parameters with the same name or same name and a negative operator in front, 2. with parameters that have a casting, 3. parameters with functions like 1/2 or num/2, maybe more that this, a screenshot attached. In any case I do not find an obvious reason not to display inline on some cases. and in my opinion should always be visible independently of the name. Now it is somewhat confusing.


public class Addition {

   public static int addThreeNumbers(int num1, int num2, double num3) {

      return (int) (num1 + num2 + num3);
   }

   public static void main(String[] args) {
      int num1 = 2;
      float num2 = 5;
      int num3 = 8;

      int sum = addThreeNumbers(num1, (int) num2, num3);
      int sum2 = addThreeNumbers(num1, (int) -2.7, 4);
      int sum3 = addThreeNumbers(num1, -3, -4d);
      System.out.println("Sum: " + sum);
   }

   public static void m0(String[] args) {
      int num1 = 2;
      int num10 = 2;
      float num2 = 5;
      int num3 = 8;
      int num30 = 8;
      int sum = addThreeNumbers(num10, (int) num2, num30); // different name
      int sum0 = addThreeNumbers(num10, (int) num2, num3);
      int sum2 = addThreeNumbers(num1, 2, 4);
      int sum3 = addThreeNumbers(num1, -3, -4f); // a valid float number but ...
      System.out.println("Sum: " + sum);
   }

   public static int addThreeNumbers2(int num1, float num2, double num3, double num4) {
      return (int) (num1 + num2 + num3);
   }

   public static void m2(String[] args) {
      int num1 = 2;
      int num2 = 5;
      int num3 = 8;
      double num4 = 8.0;
      int sum = addThreeNumbers2(num1, num2, -num3, -1 / 2); // function
      int sum0 = addThreeNumbers2(num1, num2, num3, -0.5); // foating point

      int sum2 = addThreeNumbers2(num1, 2, 4, 0.5d);
      int sum3 = addThreeNumbers2(num1, -3, 4d, num4); // sane name
      System.out.println("Sum: " + sum);
   }
}

2023-07-03 22_45_00- Apache NetBeans IDE 17

istinnstudio avatar Jul 03 '23 19:07 istinnstudio

Inline hints disappear when the parameter ... has the same name

Thanks for the report. The same name one is intentional behaviour, although I too have found it a bit odd in practice. Haven't tested the other two.

neilcsmith-net avatar Jul 06 '23 14:07 neilcsmith-net

thanks for the attention. I think a function to set "show in all cases mode" to hints would be of great value. And I personally prefer this to be the default behavior,

istinnstudio avatar Jul 11 '23 08:07 istinnstudio