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

Use java.templates.typeComment on code snippet for "class" #3295

Closed
carljo-reyes opened this issue Oct 2, 2024 · 1 comment · Fixed by #3301
Closed

Use java.templates.typeComment on code snippet for "class" #3295

carljo-reyes opened this issue Oct 2, 2024 · 1 comment · Fixed by #3301
Assignees
Labels

Comments

@carljo-reyes
Copy link

When expanding a code snippet for type (e.g. class), typeComment is not applied in the generated code. typeComment is only applied for types created by the LSP

Please make it such that java.templates.typeComment is also applied for type snippets provided by the LSP

Screen Recording 2024-10-02 234047 (1)

@rgrunber rgrunber added the bug label Oct 4, 2024
@rgrunber
Copy link
Contributor

rgrunber commented Oct 4, 2024

Yup, definitely is happening and shouldn't. Not sure why it was never caught before. I think to solve it we need to modify

public static final String CODETEMPLATE_CLASSSNIPPET_PUBLIC = "${filecomment}${package_header}/**\n * ${type_name}\n */\npublic class ${type_name} {\n\n\t${cursor}\n}";
. Currently it's just set so that the type comment for class is just /**\n * ${type_name}\n */. We should probably add some new variable ${typeComment} and then when we use that "template", make sure to set it based on the what the client passes in settings at :
String fileComment = cu.getTypes().length == 0 ? CodeGeneration.getFileComment(cu, lineDelimiter) : null;
context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment + lineDelimiter : "");

Basically do the same thing that happens for file comments.

We should also make sure that things that create new files through server-side resource operations populate the new file correctly.

@rgrunber rgrunber changed the title Use java.templates.typeComment on code snippet for type Use java.templates.typeComment on code snippet for "class" Oct 4, 2024
@rgrunber rgrunber added this to the End October 2024 milestone Oct 17, 2024
@rgrunber rgrunber self-assigned this Oct 17, 2024
@rgrunber rgrunber moved this to Pending review in Java Tooling Oct 17, 2024
@github-project-automation github-project-automation bot moved this from Pending review to Done in Java Tooling Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants