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

TemplateExtension.java class generated in src/main/resources #831

Closed
datho7561 opened this issue Mar 27, 2023 · 3 comments · Fixed by #834
Closed

TemplateExtension.java class generated in src/main/resources #831

datho7561 opened this issue Mar 27, 2023 · 3 comments · Fixed by #834
Assignees
Labels
bug Something isn't working code action qute
Milestone

Comments

@datho7561
Copy link
Contributor

  1. Create a template in Quarkus project with qute:
{@java.lang.String identifier}

{identifier.sandw|ich}
  1. Apply the quick fix to resolve the error at the |: "Create template extension sandwich() in new template extensions class"

Expected: a new file TemplateExtensions.java is generated in src/main/java (the default package)

Actual: the file is generated in src/main/resources

@datho7561 datho7561 added bug Something isn't working code action qute labels Mar 27, 2023
@datho7561
Copy link
Contributor Author

I've only tested this with a Maven project. I guess it would be incorrect in a different way for a Gradle project.

@datho7561 datho7561 self-assigned this Mar 28, 2023
@datho7561 datho7561 added this to the 0.14.0 milestone Mar 28, 2023
@datho7561
Copy link
Contributor Author

@fbricon @angelozerr This isn't a regression, it's just very difficult to locate the folder that the project's code is in using the JDT APIs, since resource folders are hard to distinguish from Java source folders, and it's hard to tell if a Java source folder is for generated sources.

What are your thoughts about disabling this quick fix until we have some sort of UI to specify the name and location of the class file when creating it?

@fbricon
Copy link
Collaborator

fbricon commented Mar 28, 2023

for now, I'd check if there's a src/main/java source folder in the project classpath. Then exclude all source folders where the test attribute (IClasspathManager.TEST_ATTRIBUTE) is set to "true"

datho7561 added a commit to datho7561/quarkus-ls that referenced this issue Mar 28, 2023
Hard code the folder that `TemplateExtensions.java` is generated in
to `./src/main/java`,
and throw an exception if that path isn't on the classpath to indicate
that the quick fix failed.

We will need to improve this in the future,
since the location of the default package can be configured
in Maven and Gradle.

Fixes redhat-developer#831

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/quarkus-ls that referenced this issue Mar 29, 2023
When locating the folder to generate `TemplateExtension.java` into
during the "generate missing member" Qute quick fix:
- Filter out classpath entries that are in the output (`target`) folder
- Filter out classpath entries that represent test code
- Filter out classpath entries that represent resource folders (folders
  with no Java source files)

Fixes redhat-developer#831

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/quarkus-ls that referenced this issue Mar 29, 2023
When locating the folder to generate `TemplateExtension.java` into
during the "generate missing member" Qute quick fix:
- Filter out classpath entries that are in the output (`target`) folder
- Filter out classpath entries that represent test code
- Filter out classpath entries that represent resource folders (folders
  with no Java source files)

Fixes redhat-developer#831

Signed-off-by: David Thompson <davthomp@redhat.com>
angelozerr pushed a commit that referenced this issue Mar 29, 2023
When locating the folder to generate `TemplateExtension.java` into
during the "generate missing member" Qute quick fix:
- Filter out classpath entries that are in the output (`target`) folder
- Filter out classpath entries that represent test code
- Filter out classpath entries that represent resource folders (folders
  with no Java source files)

Fixes #831

Signed-off-by: David Thompson <davthomp@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code action qute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants