-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interface/class snippets should not be available inside method bodies #689
Conversation
test this please |
test this please |
//This check might need to be pushed back to the different get*Snippet() methods, depending on future features | ||
if (UNSUPPORTED_RESOURCES.contains(cu.getResource().getName())) { | ||
return Collections.emptyList(); | ||
} | ||
if (!accept(cu, completionContext, true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L65-L70 need to be moved inside getClassSnippet.
if accept returns false, then you're not even trying interfaces next
if (classSnippet != null) { | ||
res.add(classSnippet); | ||
} | ||
CompletionItem interfaceSnippet = getInterfaceSnippet(cu); | ||
if (!accept(cu, completionContext, false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L80-L85 need to be moved to getInterfaceSnippet
@@ -109,6 +108,7 @@ public boolean isCanceled() { | |||
try { | |||
unit.codeComplete(offset, collector, subMonitor); | |||
proposals.addAll(collector.getCompletionItems()); | |||
proposals.addAll(SnippetCompletionProposal.getSnippets(unit, collector.getContext(), subMonitor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem here is the proposals ignore the currently typed text, i.e if you type m
in the class body, you'd still get the class
and interface
snippets proposals. While vscode luckily filters them out, other clients won't necessarily do it.
Signed-off-by: Snjezana Peco <[email protected]>
@fbricon I have updated the PR. |
Thanks @snjeza! |
Fixes #681
I have removed the class/interface snippets from the following contexts:
The class snippets is sometimes allowed in the method body such as:
I have also changed the snippets to not generate duplicated public keywords, as in the following place:
BTW all the client snippets have the same issue.
Signed-off-by: Snjezana Peco [email protected]