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

Yaml syntax errors in .clangd file leads to unhandled exception #245

Closed
ghentschke opened this issue Feb 5, 2024 · 0 comments · Fixed by #246
Closed

Yaml syntax errors in .clangd file leads to unhandled exception #245

ghentschke opened this issue Feb 5, 2024 · 0 comments · Fixed by #246
Assignees
Milestone

Comments

@ghentschke
Copy link
Contributor

ghentschke commented Feb 5, 2024

If the .clangd file has syntax errors like:

CompileFlags: {CompilationDatabase: Release

and the active build configuration of a MBS project will be changed, an unhandled exception is thrown. The org.eclipse.cdt.lsp.clangd.ClangdConfigurationFileManager should not update the .clangd configuration file in the projects root, because the file syntax is corrupted. It has to be fixed first.

The unhandled exception:

!ENTRY org.eclipse.ui 4 0 2024-02-06 07:28:33.679
!MESSAGE Unhandled event loop exception
!STACK 0
while parsing a flow mapping
 in 'reader', line 1, column 15:
    CompileFlags: {CompilationDatabase: Release
                  ^
expected ',' or '}', but got <stream end>
 in 'reader', line 2, column 1:
    
    ^

	at org.yaml.snakeyaml.parser.ParserImpl$ParseFlowMappingKey.produce(ParserImpl.java:894)
	at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161)
	at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:57)
	at org.yaml.snakeyaml.comments.CommentEventsCollector$1.peek(CommentEventsCollector.java:43)
	at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:136)
	at org.yaml.snakeyaml.comments.CommentEventsCollector.collectEvents(CommentEventsCollector.java:116)
	at org.yaml.snakeyaml.composer.Composer.composeScalarNode(Composer.java:241)
	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:205)
	at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
	at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
	at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
	at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:369)
	at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:348)
	at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:323)
	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:209)
	at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:131)
	at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:157)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:178)
	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:493)
	at org.yaml.snakeyaml.Yaml.load(Yaml.java:434)
	at org.eclipse.cdt.lsp.clangd.ClangdConfigurationFileManager.setCompilationDatabase(ClangdConfigurationFileManager.java:193)
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Feb 5, 2024
- Move showErrorMessage method from LSpUtils to
ClangdConfigurationFileManager since it's only used here. Despite that
we do not want to publish the LspUtils when making the
org.eclipse.cdt.lsp.clangd package public API.
@ghentschke ghentschke self-assigned this Feb 5, 2024
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Feb 5, 2024
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Feb 5, 2024
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Feb 5, 2024
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Feb 5, 2024
- remove error dialog since it does not belong to the
ClangdConfigurationFileManager. The check, if the user edits the .clangd
file properly should be done somewhere else.
@ghentschke ghentschke changed the title Yaml syntax errors in .clangd file are not shown to the user Yaml syntax errors in .clangd file leads to unhandled exception Feb 6, 2024
ghentschke added a commit to ghentschke/eclipse-cdt-lsp that referenced this issue Feb 6, 2024
- do not set database path in .clangd file with invalid yaml syntax. The
user has to fix it first.
ghentschke added a commit that referenced this issue Feb 6, 2024
* [#245] catch all exceptions during yaml parsing

- do not set database path in .clangd file with invalid yaml syntax. The
user has to fix it first.
@ghentschke ghentschke added this to the 1.1.0 milestone Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant