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

CodeAction for cvc-complex-type.2.4.b #1218

Closed
angelozerr opened this issue Jun 3, 2022 · 6 comments · Fixed by #1226
Closed

CodeAction for cvc-complex-type.2.4.b #1218

angelozerr opened this issue Jun 3, 2022 · 6 comments · Fixed by #1226
Assignees
Labels
code action enhancement New feature or request
Milestone

Comments

@angelozerr
Copy link
Contributor

angelozerr commented Jun 3, 2022

Given this XML file:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    <servlet></servlet>
</web-app>

There is an error on servlet:

image

because servlet expects some content. It should be nice to provide a code action which generate the expected content.

@JessicaJHee
Copy link
Contributor

I was taking a look at this issue to see if I can pick it up and I see that the code action for cvc_complex_type_2_4_a is very similar (this one is to replace the unexpected content and cvc_complex_type_2_4_b is to insert the expected content). When I tried out the 2_4_a code action, the error is detected properly but the diagnostic is not being sent correctly in the code action request. As a result, the code action response is empty and there is no yellow light bulb that pops up.

image

image

When I try to activate other code actions (such as completing with '>'), it works fine. I also checked out the code actions tests for cvc_complex_type_2_4_a , which are passing as expected.

I'm wondering if this is something on the vscode-xml side or I'm missing something (maybe a setting)?

@angelozerr
Copy link
Contributor Author

When I tried out the 2_4_a code action, the error is detected properly but the diagnostic is not being sent correctly in the code action request.

It works for me:

image

Are you sure that you see the correct trace of codeAction? Your range of codeAction an diagnostics are not the same?

@JessicaJHee
Copy link
Contributor

Are you sure that you see the correct trace of codeAction? Your range of codeAction an diagnostics are not the same?

I searched through all the code action related traces and those were the only requests I see, where the code action request is being sent empty at the end of the file.

image

But good to know it's just an issue on my end, Will look into it more!

@GitMensch
Copy link
Contributor

I gave this a try, works fine in general. Things I've recognized that may be considered a bug:

  • the code action says "Insert all expected elements" - but it also inserts elements with "minOccurs="0" maxOccurs="1" --> so also optional elements (and then complains that those have an invalid data type, manually deleting those lead to a warning free xml) -> can you split this into two actions "insert all expected" and "insert all possible"?
  • given a sequence of elements and missing elements at the end the code action inserts those directly at the beginning --> leading to "invalid element name" errors [if the complete complex element is empty then adding the entries via code action inserts those in the correct order] -> is it possible to insert the missing elements at the correct place?

@fbricon
Copy link
Contributor

fbricon commented Jul 20, 2022

@GitMensch can you please open 2 separate issues?

@GitMensch
Copy link
Contributor

Done. Again: thanks for the feature - it already is helping, it just can be even better :-)

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

Successfully merging a pull request may close this issue.

4 participants