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

[Qute] Create a Qute Language Server #176

Closed
angelozerr opened this issue Jan 3, 2020 · 6 comments · Fixed by #428
Closed

[Qute] Create a Qute Language Server #176

angelozerr opened this issue Jan 3, 2020 · 6 comments · Fixed by #428
Assignees
Labels
Milestone

Comments

@angelozerr
Copy link
Contributor

To support completion, validation, hover, etc for Qute, we need to create a Qute Language Server (in a new project like com.redhat.quarkus.qute.ls).

https://github.com/quarkusio/quarkus/blob/master/independent-projects/qute/core/src/main/java/io/quarkus/qute/Parser.java

This Qute Language Server requires a QuteAST which contains all position of Qute expressions. Take a sample:

{@org.acme.Item item} 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{item.name}</title> 
</head>
<body>
    <h1>{item.name}</h1>
    <div>Price: {item.price}</div>
    {#if item.price > 100} 
    <div>Discounted Price: {item.discountedPrice}</div> 
    {/if}
</body>
</html>

The QuteAST must store each Qute node with proper range (start (character, line) , end(character, line) of node.

QuteAST
-> {@org.acme.Item item }
/\ /\
| |
start (line=1, character = 1) start (line=1, character = 40)
-> {item.name}
-> {item.price}
-> {#if item.price > 100}
-> {item.discountedPrice}
-> {/if}

The parse to compute this QuteAST must:

  • stores each range (start, end) line character for each Qute nodes (expression, if condition, loop, etc)
  • tolerant : when user is typing some content in the editor, the Qute template cannot be valid but we must keep as soon as possible the following content. For instance if we have this template (item.name is not closed):
<h1>{item.name</h1>
<div>Price: {item.price}</div>

the QuteAST must contains:

-> {item.name
-> {item.price}

  • incremental parser. To avoid rebuilding the QuteAST on each changes (when user is typing in the editor), the Qute parser should be able to update a given QuteAST with a new content. But incremental parser is very hard to implement, we can live without this support for the moment.

To manage this QuteAST (build by the tolerant parser + store ranges) we have 2 solutions

but

Do you think @mkouba is there any chance to support tolerant parser and manages ranges ? It should be really fantastic to do that to integrates Qute parser in an editor.

@angelozerr
Copy link
Contributor Author

@mkouba if you are aware to support tolerant parser I suggest you see https://github.com/microsoft/tolerant-php-parser and read the section https://github.com/microsoft/tolerant-php-parser/blob/master/docs/HowItWorks.md#how-it-works to design the parser with tolerant mode.

If you think it's a feature that you don't want to support in Qute parser, please tell us, thanks!

@mkouba
Copy link
Collaborator

mkouba commented Jan 8, 2020

Hi @angelozerr and thanks for the summary!

Few comments:

  • {item.name in fact does not qualify as an error - it's just ignored.
  • the current parser is a simple "fail-fast" parser, ie. an exception is thrown when an error is found
  • user errors include:
    • unterminated tag
    • end tag does not match the start tag
    • non-existent "section helper"/tag
    • and few others

The reason why we did it this way is that some of the errors can completely break the parser, e.g. it's not possible to correctly parse the rest of the template.

If you think it's a feature that you don't want to support in Qute parser, please tell us, thanks!

I'll need to look at your links with tolerant parser examples.

@angelozerr
Copy link
Contributor Author

The reason why we did it this way is that some of the errors can completely break the parser, e.g. it's not possible to correctly parse the rest of the template.

Indeed, I understand this behaviour but IMHO I think it should be better to report several errors than the first error (like Java editor code for instance, you can see several problems than the first error in your file).

I'll need to look at your links with tolerant parser examples.

Thanks! I have started something on my side. When I will have something I will push it in my github repository.

@angelozerr
Copy link
Contributor Author

@mkouba @maxandersen please see my POC with Qute parser at https://github.com/angelozerr/tolerant-qute-parser

I did that by copying/pasting code from our XML tolerant parser for LSP4XML and adapt it for Qute syntax.

I did that to help more our discussion and it is a kind of parser required for the Qute Language Server.

@maxandersen
Copy link
Collaborator

How about making a pr to the qute parser directly?

@angelozerr
Copy link
Contributor Author

It was more easy for me to do a parser from scratch than trying to modify the qute parser ans i would like to know if @mkouba likes my parser before doing a pr

angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Jan 12, 2020
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Jan 12, 2020
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/vscode-quarkus that referenced this issue Jan 12, 2020
See redhat-developer/quarkus-ls#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Jan 12, 2020
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Jan 12, 2020
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Jan 13, 2020
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 10, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr angelozerr self-assigned this Nov 10, 2021
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 10, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 10, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 10, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 10, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 10, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
fbricon pushed a commit to fbricon/quarkus-ls that referenced this issue Nov 16, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 16, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 16, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 16, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 16, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 22, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 23, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
angelozerr pushed a commit to angelozerr/quarkus-ls that referenced this issue Nov 24, 2021
Fixes redhat-developer#176

Signed-off-by: azerr <azerr@redhat.com>
fbricon pushed a commit that referenced this issue Nov 24, 2021
Fixes #176

Signed-off-by: azerr <azerr@redhat.com>
@angelozerr angelozerr added this to the v0.11.0 milestone Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants