Skip to content

Commit 4c67f5e

Browse files
Merge pull request #48 from mhuttenlauch/add_hover_debug
Enable VS Code hover evaluation when debugging
2 parents 36d747b + 35c1642 commit 4c67f5e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

luceedebug/src/main/java/luceedebug/DapServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ static public DapEntry create(ILuceeVm luceeVm, Config config, InputStream in, O
173173
@Override
174174
public CompletableFuture<Capabilities> initialize(InitializeRequestArguments args) {
175175
var c = new Capabilities();
176+
c.setSupportsEvaluateForHovers(true);
176177
c.setSupportsConfigurationDoneRequest(true);
177178
c.setSupportsSingleThreadExecutionRequests(true); // but, vscode does not (from the stack frame panel at least?)
178179

vscode-client/src/extension.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,35 @@ export function activate(context: vscode.ExtensionContext) {
108108
})
109109
);
110110

111+
// add hover for debugger
112+
// TODO: replace naive regex matcher with better implementation
113+
context.subscriptions.push(vscode.languages.registerEvaluatableExpressionProvider('cfml', {
114+
provideEvaluatableExpression(document: vscode.TextDocument, position: vscode.Position): vscode.ProviderResult<vscode.EvaluatableExpression> {
115+
/**
116+
* will match most variable declaration styles:
117+
* local.varName
118+
* varName
119+
* local.varName.subKey
120+
* local.varName['subKey']
121+
* local['varName'].subKey
122+
* local['varNam'][subKey]
123+
* local.varName["subKey"]
124+
* <cfquery name="queryName"> -> queryName
125+
*
126+
* however will also match:
127+
* local.varName.functionCall()
128+
* "somestring.that.looks.like[a]variable" -> somestring.that.looks.like[a]variable
129+
*
130+
*/
131+
const varRange = document.getWordRangeAtPosition(position, /[\w_][\w\[\]"'\._\-]+[\w\]]/ig)
132+
?? document.getWordRangeAtPosition(position);
133+
if(varRange !== undefined) {
134+
return new vscode.EvaluatableExpression(varRange);
135+
}
136+
return undefined;
137+
}
138+
}));
139+
111140
// context.subscriptions.push(
112141
// vscode.commands.registerCommand("luceeDebugger.showLoadedClasses", () => {
113142
// currentDebugSession?.customRequest("showLoadedClasses");

0 commit comments

Comments
 (0)