Skip to content

Commit

Permalink
Merge pull request #48 from mhuttenlauch/add_hover_debug
Browse files Browse the repository at this point in the history
Enable VS Code hover evaluation when debugging
  • Loading branch information
softwareCobbler authored Sep 25, 2023
2 parents 36d747b + 35c1642 commit 4c67f5e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions luceedebug/src/main/java/luceedebug/DapServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ static public DapEntry create(ILuceeVm luceeVm, Config config, InputStream in, O
@Override
public CompletableFuture<Capabilities> initialize(InitializeRequestArguments args) {
var c = new Capabilities();
c.setSupportsEvaluateForHovers(true);
c.setSupportsConfigurationDoneRequest(true);
c.setSupportsSingleThreadExecutionRequests(true); // but, vscode does not (from the stack frame panel at least?)

Expand Down
29 changes: 29 additions & 0 deletions vscode-client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,35 @@ export function activate(context: vscode.ExtensionContext) {
})
);

// add hover for debugger
// TODO: replace naive regex matcher with better implementation
context.subscriptions.push(vscode.languages.registerEvaluatableExpressionProvider('cfml', {
provideEvaluatableExpression(document: vscode.TextDocument, position: vscode.Position): vscode.ProviderResult<vscode.EvaluatableExpression> {
/**
* will match most variable declaration styles:
* local.varName
* varName
* local.varName.subKey
* local.varName['subKey']
* local['varName'].subKey
* local['varNam'][subKey]
* local.varName["subKey"]
* <cfquery name="queryName"> -> queryName
*
* however will also match:
* local.varName.functionCall()
* "somestring.that.looks.like[a]variable" -> somestring.that.looks.like[a]variable
*
*/
const varRange = document.getWordRangeAtPosition(position, /[\w_][\w\[\]"'\._\-]+[\w\]]/ig)
?? document.getWordRangeAtPosition(position);
if(varRange !== undefined) {
return new vscode.EvaluatableExpression(varRange);
}
return undefined;
}
}));

// context.subscriptions.push(
// vscode.commands.registerCommand("luceeDebugger.showLoadedClasses", () => {
// currentDebugSession?.customRequest("showLoadedClasses");
Expand Down

0 comments on commit 4c67f5e

Please sign in to comment.