netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Include "get", "set", and "is" as element prefixes when doing a Java auto-complete search

Open SirIntellegence opened this issue 3 years ago • 8 comments

Description

When a user invokes code completion for a member, which may be a "property" (which we shall call "Foo"), check to see if there is any "getFoo", "setFoo", or "isFoo" in the class and add it to the complete list if it is. The best possibly insertion point I think would be around hither: https://github.com/apache/netbeans/blob/487686125c370140bc39cc8f1d598783f187fdf5/java/java.completion/src/org/netbeans/modules/java/completion/Utilities.java#L102

Use case/motivation

I am actually porting quite a bit of code from C# to Java, and it would be immensely helpful if Netbeans just checked to see if there is a "Bar.getFoo()" when I invoke autocomplete on "Bar.Foo". It would speed things up quite a bit since I wouldn't have to go to the start, type in the "get", "set", or "is", and then move to the end to complete it.

Related issues

No response

Are you willing to submit a pull request?

Yes

Code of Conduct

Yes

SirIntellegence avatar Jul 22 '22 20:07 SirIntellegence

sounds reasonable to me. Looking forward to the PR :)

mbien avatar Jul 23 '22 10:07 mbien

Will I need to make a test too or can I just submit the change?

SirIntellegence avatar Jul 25 '22 14:07 SirIntellegence

Will I need to make a test too or can I just submit the change?

would be good to have test case covering it but the completion tests are a bit netbeans specific, so if you are struggling with it I am sure someone else could help.

I would probably put it in org.netbeans.modules.java.completion.JavaCompletionTaskBasicTest. You will probably also have to create a test file for it which would be in java/java.completion/test/unit/data/org/netbeans/modules/java/completion/data

Looking at the other test method might help with figuring out how this works.

here an example of a test which added completion for the record keyword: https://github.com/apache/netbeans/pull/3227/files

mbien avatar Jul 25 '22 15:07 mbien

Working branch in case I am slow and someone else wants to finish: https://github.com/SirIntellegence/incubator-netbeans/tree/NETBEANS4428

SirIntellegence avatar Jul 27 '22 15:07 SirIntellegence

it may be more manageable to create a PR even with a draft status and do not merge label for people to help.

ebarboni avatar Jul 27 '22 16:07 ebarboni

What is the standard for fixing other unrelated tests in the same test suite? Apparently System.out. has a charset() which is not accounted for and is failing 3 of the tests

SirIntellegence avatar Jul 27 '22 21:07 SirIntellegence

there is no need to hurry, NetBeans 16 is still far away.

You have to be more specific. The tests should work, you shouldn't have to fix "unrelated tests". I suppose you are not talking about your PR, since the draft you pushed doesn't compile.

mbien avatar Jul 27 '22 21:07 mbien

Some tests fail for me for some reason that are not related to my modifications. I am going to push a new commit in a bit.

SirIntellegence avatar Jul 27 '22 21:07 SirIntellegence

closing since already implemented. See https://github.com/apache/netbeans/pull/4440#issuecomment-1274702374

mbien avatar Dec 06 '22 23:12 mbien