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

Prevent code action from exception #900

Closed
angelozerr opened this issue Oct 5, 2020 · 1 comment
Closed

Prevent code action from exception #900

angelozerr opened this issue Oct 5, 2020 · 1 comment
Assignees
Labels
bug Something isn't working code action
Milestone

Comments

@angelozerr
Copy link
Contributor

angelozerr commented Oct 5, 2020

Given this XML:

<a>

  </

</a>

When #880 will be implemented, when we hover to root element a, we should see several code action, but there are no code actions:

image

We have a the following stack traces:

[Error - 12:25:10] Request textDocument/codeAction failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.NullPointerException
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
	at java.base/java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1238)
	at java.base/java.util.concurrent.CompletableFuture$BiApply.tryFire(CompletableFuture.java:1205)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.NullPointerException
	at java.base/java.lang.StringBuilder.<init>(StringBuilder.java:124)
	at org.eclipse.lemminx.utils.XMLBuilder.trimTrailingSpacesEachLine(XMLBuilder.java:374)
	at org.eclipse.lemminx.utils.XMLBuilder.addContent(XMLBuilder.java:303)
	at org.eclipse.lemminx.utils.XMLBuilder.addContent(XMLBuilder.java:277)
	at org.eclipse.lemminx.extensions.generators.xml2dtd.XML2DTDGenerator.generate(XML2DTDGenerator.java:96)
	at org.eclipse.lemminx.extensions.generators.xml2dtd.XML2DTDGenerator.generate(XML2DTDGenerator.java:29)
	at org.eclipse.lemminx.extensions.generators.AbstractXML2GrammarGenerator.doGenerate(AbstractXML2GrammarGenerator.java:67)
	at org.eclipse.lemminx.extensions.generators.AbstractXML2GrammarGenerator.generate(AbstractXML2GrammarGenerator.java:47)
	at org.eclipse.lemminx.extensions.generators.AbstractXML2GrammarGenerator.generate(AbstractXML2GrammarGenerator.java:40)
	at org.eclipse.lemminx.extensions.generators.FileContentGeneratorManager.generate(FileContentGeneratorManager.java:88)
	at org.eclipse.lemminx.extensions.contentmodel.participants.codeactions.NoGrammarConstraintsCodeAction.doCodeAction(NoGrammarConstraintsCodeAction.java:93)
	at org.eclipse.lemminx.extensions.contentmodel.participants.ContentModelCodeActionParticipant.doCodeAction(ContentModelCodeActionParticipant.java:49)
	at org.eclipse.lemminx.services.XMLCodeActions.doCodeActions(XMLCodeActions.java:45)
	at org.eclipse.lemminx.services.XMLLanguageService.doCodeActions(XMLLanguageService.java:255)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$19(XMLTextDocumentService.java:389)
	at java.base/java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1236)
	... 7 more

This issue comes from the </ which have a null local name.

To fix correctly this issue, we should:

  • try catch each code action to display code action which doesn't throw exception.
  • fix the DTD generator to take care of element which have null tag name.
@angelozerr angelozerr added bug Something isn't working code action labels Oct 5, 2020
@angelozerr angelozerr added this to the 0.14.0 milestone Oct 5, 2020
@angelozerr angelozerr self-assigned this Oct 5, 2020
angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Oct 5, 2020
Fixes eclipse#900

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/lemminx that referenced this issue Oct 5, 2020
Fixes eclipse#900

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr
Copy link
Contributor Author

Fixed with #897

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
Projects
None yet
Development

No branches or pull requests

1 participant