Skip to content
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

Code Completion in Javadoc Comments #12

Open
JoelProminic opened this issue May 16, 2022 · 2 comments
Open

Code Completion in Javadoc Comments #12

JoelProminic opened this issue May 16, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@JoelProminic
Copy link

I see some strange behavior for code completion in JavaDoc (/**) comments. @JustinProminic reported similar issues for /* and // comments, but I couldn't reproduce this.

image

I think this is intentional, though. You can see that it gives me an option to generate an @link, which is something I use in Eclipse. Completing the class name could potentially be nice when writing the documentation as well.

However, it does feel a little strange when the auto-complete triggers at the end of a sentence like this. Also, I see it won't allow me to complete methods.

Here are some Javadoc actions I do in Eclipse.

  1. Create a JavaDoc comment. A closing */ is automatically added when you hit Enter
  2. Type "Syste" and hit CTRL-Space. I have options to complete this as a plain class name or a @link
  3. Continue typing "m.". This automatically completes as an @link, changes the '.' to a '#' and starts to complete the method.
  4. On a new line, type "System.". Completion does not trigger.
  5. Type '#' on a new line. Completion opens for methods and properties

In Moonshine, I see:

  1. Create a JavaDoc comment. Moonshine does not automatically complete the comment, so add the closing tag manually. I prefix new lines in the comment with " * ".
  2. Type "Syste" and hit CTRL-Space. I have options to complete this as a plain class name or a @link. This works the same as Eclipse
  3. Continue typing "m.". Moonshine starts completion again, but shows nested classes, not methods or properties.
  4. On a new line, type "System.". Completion triggers.
  5. Type '#' on a new line. Completion opens for methods and properties

Here is the behavior I see for Visual Studio Code (which uses the same language server, right?).

  1. Create a JavaDoc comment. A closing */ is automatically added when you hit Enter
  2. Type "Syste" and hit CTRL-Space. I have options to complete this as a plain class name or a @link
  3. Continue typing "m.". Completion closes. You can use CTRL-Space again to trigger text-only completion
  4. On a new line, type "System.". Completion does not trigger.
  5. Type '#' on a new line. Completion opens for methods and properties

I'm fine with matching either behavior. Note that the procedure for VS Code also involves text-only completion and comment completion. We can ignore the text-only completion for now to avoid confusion with the language servers, and I'll plan to create a separate issue for comment completion.

This is a moderate priority. I can work around the issue pretty easily, but it does cause frustration when it triggers at the end of sentences.

@JoelProminic JoelProminic added the enhancement New feature or request label May 16, 2022
@joshtynjala
Copy link
Contributor

I see some strange behavior for code completion in JavaDoc (/**) comments. @JustinProminic reported similar issues for /* and // comments, but I couldn't reproduce this.

I wonder if Justin accidentally added /** instead of /*, and that's why he saw some completion.

I think this is intentional, though. You can see that it gives me an option to generate an @link, which is something I use in Eclipse. Completing the class name could potentially be nice when writing the documentation as well.

Yes, this comes from the language server, and it appears to be intentional.

Continue typing "m.". Moonshine starts completion again, but shows nested classes, not methods or properties.

I have no idea why VSCode behaves differently here. There are indeed using the same language server.

It could be that different versions of the language server or different versions of the JDK provide slightly differing behaviors. The VSCode extension might be using a different default value for a setting than the language server. For reference, the language server is developed by Eclipse, while the VSCode extension is developed by Red Hat. It's possible that the teams have a disagreement on what should be default.

Regardless, this appears to be similar intentional behavior to me. I would be wary to consider it a bug. Even if you want to consider it a bug, I'm not sure how I would tell the language server to change this behavior. There probably aren't any settings for that level of granularity.

Create a JavaDoc comment. A closing */ is automatically added when you hit Enter

Moonshine's text editor supports "auto-closing pairs", but it looks like I haven't added any type of comments in the pairs specified in Moonshine's language syntax plugins. Only brackets so far. I may have simply forgotten to add them. I'll add this to my to-do list.

@JoelProminic
Copy link
Author

Continue typing "m.". Moonshine starts completion again, but shows nested classes, not methods or properties.

The VSCode behavior for this case is fine if we want to stick with that. I could see both the VSCode and Eclipse behavior being annoying in some cases, so this may have just been a developer preference. I am a little out of date on Eclipse (2020-09), so that could also explain the difference.

I had some more thoughts about the comment completion, so I created #13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants