Skip to content

Provide Qute DAP debugger support #48962

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

angelozerr
Copy link
Contributor

@angelozerr angelozerr commented Jul 17, 2025

Here a draft PR which provide Qute DAP debugger support

This PR contains a README.md (not finished) which explains how the debugger is working.

I need to clean code, write doc, write tests and improve completion, but the debugger can be used.

@mkouba I will add comments github to speak about some choice that I did because of some missing features of Qute engine (because you don't need it) like

  • evaluation of condition expression
  • retrieve the file path from template id which is required in debugging word.

//cc @mkouba @ia3andy @FroMage

@quarkus-bot quarkus-bot bot added the area/qute The template engine label Jul 17, 2025
conditionEngine = Engine.builder().addDefaults().build();
}

public static TemplateNode parseCondition(String condition) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkouba I need to evaluate Qute condition expression:

  • to manage conditonal breakpoint
  • evaluate a conditional expression when user evaluate an expression with debugger

Qute doesn't provide this mechanism. My hack is to create a template with #if and get this ifNode.

}

public CompletionStage<Object> evaluate(String expression) {
if (expression.contains("!") || expression.contains(">") || expression.contains("gt")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When user evaluate an expression with client debugger (vscode, IntelliJ, etc) it does that with a simple field.

Here I need to know if expression is a conditional expression or a simple expression to evaluate it.

}

public SourceTemplateRegistry(List<String> basePaths, List<String> fileExtensions) {
this.basePaths = basePaths;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Qute doesn't store the template file path, but only template id, I need to manage a mapping between template id and full file path):

  • basePaths will search templates from those basePaths
  • file extension

It would be super nice if Qute could manage those file path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is you don't always have a file path because templates are not necessarily backed by a file. In theory, we could record a map of ids to file paths (for file-based templates) and make it accessible via io.quarkus.qute.runtime.QuteRecorder.QuteContext if it helps... but that won't help for Qute-standalone use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed you already explained me that. But I think if Quarkus knows the file path of the template it should fill it somewhere.

As it should work in Qute standalone mode, using QuteContext in the debugger is a bad idea.

Ideally Template should store the file path and have Template#getFilePath() but as template can be used without file, an another idea is to add a new API in Template : Template.setAttribute / Template.getAttribute like you did for TemplateInstance.

QuteContext could update Template with the proper file path by using Template#setAttribute with the "qute.file.path" key and debuger could trigger Template.getAttribute("qute.file.path" ). If it is null (ex: in standalone mode) debugger will switch with my current strategy.

For standalone, Qute could provide a FilePathLocator which could update Template#setAttribute.

@angelozerr angelozerr force-pushed the qute-debugger-dap branch 9 times, most recently from 3ecf910 to 9bf2d51 Compare July 18, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants