netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

[NETBEANS4428] Initial work on "is/get/set prefixes" bug

Open SirIntellegence opened this issue 3 years ago • 12 comments

It has been implemented. Just need to work on the tests

To resolve issue #4428

SirIntellegence avatar Jul 27 '22 18:07 SirIntellegence

before I forget: the commits need to have a real name and valid address in the header.

mbien avatar Jul 27 '22 23:07 mbien

By header, you mean the commits or the pull request? I will probably need to disable a certain Github option...

SirIntellegence avatar Jul 28 '22 14:07 SirIntellegence

By header, you mean the commits or the pull request? I will probably need to disable a certain Github option...

the commits. git log of your branch i checked out shows your nickname and a noreply mail address. Those would be the same commits which land in master. This project requires real names and valid addresses for contributions. You can change this per commit, per repository or globally in your git settings.

git commit --amend --author="Author Name <[email protected]>" --no-edit would update the author info of the last commit of the current branch.

mbien avatar Jul 28 '22 15:07 mbien

That should have done it? Don't know if I need to fiddle with other github settings or not

SirIntellegence avatar Jul 28 '22 15:07 SirIntellegence

I just noticed that time stamps on the commits were lost... I am trying to decide if they are important enough to fix...

SirIntellegence avatar Jul 28 '22 16:07 SirIntellegence

I just noticed that time stamps on the commits were lost... I am trying to decide if they are important enough to fix...

time stamps going to usually change every time the commit hash changes which is every time the commit itself is modified. PRs like this are usually squashed as last step after review to a single commit before merge anyway so don't worry about those.

the author details look good to me now, thanks.

mbien avatar Jul 28 '22 16:07 mbien

In regards to optimization, we could us a wrapper CharSequence to avoid creating 3 Strings when we check a method. That would require modifications to other methods as well. Another possible solution is to filter through the members in parallel.

SirIntellegence avatar Jul 28 '22 17:07 SirIntellegence

In regards to optimization, we could us a wrapper CharSequence to avoid creating 3 Strings when we check a method. That would require modifications to other methods as well. Another possible solution is to filter through the members in parallel.

string concatenation is rarely a problem. The JVM became very good at optimizing this. Most String ops are intensified. I wouldn't optimize anything by hand before knowing that this is actually a problem. But I would change it to the version i proposed at https://github.com/apache/netbeans/pull/4440#discussion_r931630020, since it creates the strings lazily/on-demand and is more compact/easier to read as bonus.

Its just that the non-matching case has 4 times more checks than before this PR. Would be good to test and show that this is in fact a non-issue. e.g generate a class with a few thousand methods/fields and compare before and after this PR.

Even if this turns out to be a problem there would be more paths we could take: e.g making this feature configurable/optional.

mbien avatar Jul 28 '22 17:07 mbien

Is the "Do not merge" tag still applicable?

SirIntellegence avatar Aug 01 '22 15:08 SirIntellegence

Is the "Do not merge" tag still applicable?

I think so.

  • I would still like to check that this does not introduce a performance regression since it does 4x more checks per candidate. This might be a non-issue.
  • this would also need more reviewers/opinions to see if this is something what should be enabled by default or via settings. This also somewhat depends on the results of the first bullet point.

mbien avatar Aug 01 '22 16:08 mbien

So, I tested this file with and without the 3 additional checks and didn't notice any difference (yes, I added methods). My attempt to profile the methods in question didn't seem to work? They never showed up in the results. Even if I used instrumentation. So someone else will probably need to test that. I did notice that going the star import route was slow for both variations. FieldsOfJoy10k.java.txt

SirIntellegence avatar Aug 12 '22 20:08 SirIntellegence

So, I tested this file with and without the 3 additional checks and didn't notice any difference (yes, I added methods). My attempt to profile the methods in question didn't seem to work? They never showed up in the results. Even if I used instrumentation. So someone else will probably need to test that. I did notice that going the star import route was slow for both variations. FieldsOfJoy10k.java.txt

interesting, filed an issue for this #4500

mbien avatar Aug 12 '22 22:08 mbien

@neilcsmith-net @matthiasblaesing would we need a setting in the options for this or is it ok to have this always enabled?

mbien avatar Oct 01 '22 11:10 mbien

I suspect this might be the wrong approach, although I haven't looked in depth as yet. How does it interact with camelcase completion? eg. typing bean.sF| for bean.setFoo. My initial thought would be to hook into, and extend, that process.

neilcsmith-net avatar Oct 01 '22 12:10 neilcsmith-net

Maybe I'm missing something obvious, but from my perspective the issue description is solved by enabling "Subword completion":

image

with that I get this:

image

for this code:

public class Test {
    public static void main(String[] args) {
        Test t = new Test();
    }

    private int demoNumber;

    public int getDemoNumber() {
        return demoNumber;
    }

    public void setDemoNumber(int demoNumber) {
        this.demoNumber = demoNumber;
    }
}

I don't see reason to make CC more complex.

matthiasblaesing avatar Oct 01 '22 19:10 matthiasblaesing

Agree with @matthiasblaesing that this seems better supported already via subword completion. I use camelcase completion sometimes, but had completely missed we had that option too!

@SirIntellegence if this meets your needs OK, please close this PR, or highlight what's missing. Thanks!

neilcsmith-net avatar Oct 11 '22 13:10 neilcsmith-net

i have to apologize to @SirIntellegence since I didn't actually know that the feature was already there, otherwise I would have mentioned it right away before reviewing.

mbien avatar Oct 11 '22 13:10 mbien

Ooo. How long was that there? Thanks for letting me know about that. That covers the request. Thanks!

SirIntellegence avatar Oct 11 '22 18:10 SirIntellegence