-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add an article documenting auto importing for Java code #2688
base: main
Are you sure you want to change the base?
Conversation
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.
I'm struggling to see why this is useful enough for an frc-docs article. This seems fairly niche to me.
|
||
.. code-block:: json | ||
|
||
"editor.codeActionsOnSave": { |
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.
What's the difference between this and "java.saveActions.organizeImports": true,
which can also be set in the preferences gui?
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.
I'm not sure as I haven't heard of that option before but it looks like it's less reliable? redhat-developer/vscode-java#2207
Organize Imports | ||
================ | ||
|
||
Visual Studio Code provides many settings to speed up programming. The Java extensions installed by WPILib allow for a setting to automatically insert the correct imports and organize them in your Java code when that file is saved. To enable this feature, first navigate to the user settings by opening the command palette with :kbd:`Ctrl+Shift+P`, then type User Settings (JSON) and press enter. Finally, add this section of code to the end of the user settings. |
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.
In most cases, the imports are put in automatically as code is written. The main benefit seems to be the organizational aspect, But it seems like someone who cares that much would also want to use a full code formatter, which we have an article for. https://docs.wpilib.org/en/stable/docs/software/advanced-gradlerio/code-formatting.html
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.
In my experience a lot of my imports are put in automatically through this setting and less so through the intellisense. The move for this article came from a discussion on the frc discord that a majority of people aren't aware of the auto import feature which this article aims to document. It also alleviates concerns when WPILib wants to move classes to different packages and break users' imports. Since it's so small perhaps it would be better suited to be added to an existing article?
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.
Whats the benefit of people knowing this option exists? Why does it justify maintaining a docs article
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.
I believe it is helpful when coding and helps people from having to type imports manually which is pushback for WPILib to move classes around to different packages. Since it is such a small section I would be more than happy to add it to an existing VSCode article I'm just not sure which one would be best. I don't believe the maintenance would be high as this option has stayed the same the entire time I've been using VSCode (4 years).
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.
A note should be added that syntax errors can cause auto-importing to delete imports that are actually used. Basically, any syntax error in a given scope will cause the extension to not register referenced imports in that scope, so if the only use of an import is in the scope where the syntax error is, that import will be removed. Once the syntax error is fixed, auto-import will fix up everything.
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.
If this is common enough to be mentioned in frc-docs then IMO it should instead be added to the templates vscode settings
I asked about that but it seems that people would rather have it documented and not be the default. |
Resolves #2675