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 EntityNotDeclared #532

Closed
xorye opened this issue Jul 22, 2019 · 2 comments · Fixed by #724
Closed

CodeAction for EntityNotDeclared #532

xorye opened this issue Jul 22, 2019 · 2 comments · Fixed by #724
Assignees
Labels
code action enhancement New feature or request
Milestone

Comments

@xorye
Copy link

xorye commented Jul 22, 2019

(Originally from #518 )

Given this XML file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article [
  <!ELEMENT article (#PCDATA)>
]>          
<article>
	&nbsp;
</article>

  should be highlighted. (It should be managed in XMLSyntaxErrorCode).

CodeAction could create the proper entity in the DOCTYPE like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article [
  <!ELEMENT article (#PCDATA)>
  <!ENTITY nbsp "entity-value">
]>           
<article>
	&nbsp;
</article>

We must take care of existing of doctype. For instance if we have

<?xml version="1.0" encoding="UTF-8"?>          
<article>
	&nbsp;
</article>

CodeAction should generate

<!DOCTYPE article [
  <!ENTITY nbsp "entity-value">
]>
@xorye xorye self-assigned this Jul 22, 2019
@xorye
Copy link
Author

xorye commented Jul 22, 2019

I think it would be best for me to handle this one since I have already started it.

@fbricon fbricon added code action enhancement New feature or request labels Jul 22, 2019
@fbricon fbricon added this to the 0.12.0 milestone Apr 2, 2020
@fbricon fbricon removed this from the 0.12.0 milestone Apr 10, 2020
@fbricon fbricon added this to the 0.12.0 milestone May 13, 2020
@xorye
Copy link
Author

xorye commented May 22, 2020

This code action involves inserting indentation, so the natural idea is to get the insertSpaces boolean and tabSize integer from the XMLFormattingOptions from SharedSettings. The problem is that these values are only accurate during formatting requests.

When a formatting request is received, we create a new settings instance with the insertSpaces and tabSize values coming from the request here:
https://github.com/eclipse/lemminx/blob/034b2b3e2246f83765e5a8aa7626fe4c35127bbb/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/XMLTextDocumentService.java#L267

Unfortunately we do not get these values for code action requests. We need another way to get these values.

For VS Code, we cannot just read editor.tabSize and editor.insertSpaces from VS Code and map them to lemminx by creating new settings, because in VS Code you can set these values per file, from the bar at the bottom of VS Code:
image

Maybe we can deduce these values by reading the actual document itself?

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.

2 participants