Skip to content

Conversation

@mbien
Copy link
Member

@mbien mbien commented Mar 27, 2022

proposal to remove some of the in-editor links to their template files.

Some templates, specifically in the code snippet category, are unlikely to be ever edited by the user - except for the lone purpose of removing the comment with the link.

example:

        List.of(1,2,3).sort((o1, o2) -> {
            return 0; // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/LambdaBody
        });

It is unlikely that the user will ever want to change the template for a lambda body, since there is simply not a lot to change. I think a better default would be to not have a link, the templates can be still found via Tools -> Templates.

links are removed from: GeneratedMethodBody, LambdaBody and OverriddenMethodBody

edit: made some other minor improvements, see commit msg.

I found also a bug in the URL highlighter, it adds the ')' to the url which creates an invalid link. Does anyone know where the code for that is?

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Editor labels Mar 27, 2022
@mbien mbien added this to the NB14 milestone Mar 27, 2022
Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is valid to remove the links here. The templates are indeed mostly place holders, with little incentive for customization.

If the VSCODE and IDE variants of the templates are now identical I think it would be good to remove the duplication.

@mbien
Copy link
Member Author

mbien commented Mar 27, 2022

If the VSCODE and IDE variants of the templates are now identical I think it would be good to remove the duplication.

I don't want to change too much there since I don't know the requirements. I also don't understand why for example a maven project has its own new project template instead of just using the template for "new java main class" as it used to be the case if I remember correctly. (this added new bugs and confusion as seen on the mailing list or issue #3678)

this reminds me: going to try to update the txt on the other templates to mention that users have to hold down ctrl while clicking since that was also brought up on the ml.

 - some snippet templates are so trivial that they don't need a link.
 - updated template header to mention ctrl/cmd buttons.
 - updated freemarker url.
 - tests needed repairs after the change.
@mbien mbien force-pushed the template-link-update branch from 6bf995e to 16306f7 Compare March 28, 2022 05:11
@mbien mbien changed the title removed some less useful template links removed some less useful template links and other minor updates Mar 28, 2022
@mbien mbien marked this pull request as ready for review March 28, 2022 05:12
Copy link

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until NetBeans continues to provide template modifying functionality, it is important to promote it to the user. Removing the links goes against that effort. I'd rather not see this PR integrated.

" Field f = method(c1, c2);\n" +
" }\n" +
" private <T extends Number & CharSequence, E extends Integer> Field method(Class<E> c1, Class<T> c2) {\n" +
" throw new UnsupportedOperationException(\"Not supported yet.\"); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody\n" +

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a useful link that I used as I am not satisfied with new UnsupportedOperationException(\"Not supported yet.\").

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its also editable via Tools -> Templates -> Java/Code Snippets. It should be picked up during a NB version upgrade too as far as i know, so you have edit it only once.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have always known the template is in Tools -> Templates. But I never bothered searching for it! Having the link/action/hint next to the generated text block at the time the incorrect (as perceived by user) block is inserted is essential for people to really invoke the customization.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover the Tools -> Templates UI isn't in VSCode. Clicking the URL is the only way to customize the template in VSCode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JaroslavTulach what happens if the user deletes the link in the template then?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover the Tools -> Templates UI isn't in VSCode. Clicking the URL is the only way to customize the template in VSCode.

now I understand the problem. VSCode is missing a feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbien not entirely. The text suggesting that a generated snippet can be customized has been there for a long time. Especially novice users reminded that they can adjust the IDE to his/her own style (i.e. the UnsupportedException default body is seen as good or bad, depending on coding style).

I opt for leaving the live links in there. If a presentation does not seem nice (?), we can enhance Folding SPI (now allows only to provide plaintext for the placeholder, could provide i.e. JComponent or TextLayout for the entire fold contents.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be curious what templates you guys are using for the generated methods

${licensePrefix}Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
${licensePrefix}Click nbfs://nbhost/SystemFileSystem/${.data_model["org.openide.filesystems.FileObject"].getPath()} to edit this template
${licensePrefix}Ctrl/Cmd+Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
${licensePrefix}Ctrl/Cmd+Click nbfs://nbhost/SystemFileSystem/${.data_model["org.openide.filesystems.FileObject"].getPath()} to edit this template

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl/Cmd sounds horrible. I don't have Cmd on my keyboard! Would See nbfs:/.... work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem was that many didn't know how to click the link as seen in issues and on the mailing list. I don't have Cmd either. If I wouldn't have added it someone would have commented that they had no Ctrl on their kb.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have noticed the complaint on mailing list as well. Yes, we have a usability problem.

I don't have Cmd either. If I wouldn't have added it someone would have commented that they had no Ctrl on their kb.

Probably a sign that the user experience deserves deeper fix than Ctrl/Cmd prefix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be a sign. But maybe its sufficient to explain how the link works at least until someone is interested to implement a deeper fix.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to point out that users not knowing how to "click" in the editor (e.g. with Ctrl or Cmd) probably don't know how to navigate to symbol definitions either! "Addressing" just the URL problem without fixing the underlying usability issue makes little sense to me.

I am fine with some rewording - for example Visit nbfs:... or Navigate to nbfs: - and then letting the user intelligence work - but I find Ctrl/Cmd+Click so ugly, that I cannot adore it... even if it helped even a single user.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Visit nbfs:..., and possibly thinking about better ways of guiding the user into how to click things separately.

@JaroslavTulach JaroslavTulach requested a review from sdedic March 29, 2022 15:20
Copy link
Contributor

@jtulach jtulach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the overall concensus is that this needs some changes:

@mbien
Copy link
Member Author

mbien commented Apr 19, 2022

going to close this since I don't think there is going to be a consensus

  • Visit/Open/etc sounds good but it doesn't really solve the original issue of communicating that the user has to ctrl-click the link, I don't want to obfuscate this further with this PR
  • I am not a fan of IDE specific tags landing in generated code, this simply does not seem to be good default behavior to me, I think its ok for file/class headers, but its too much for methods and doesn't make sense for lambdas IMO. But I underestimated how popular those links are under maintainers (i would be curious what custom templates for auto-generated methods everyone is using though)
  • I might try to remove the lambda snipped with lambda expression completion support. #3458 If i revisit the draft again

edit: i also did not consider that VSCode does not have a template editor, so there is a non-NetBeans requirement for providing those until someone adds that feature I suppose

@mbien mbien closed this Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Editor Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants