@@ -29,7 +29,7 @@ export async function activate(context: vscode.ExtensionContext) {
2929 initStatusBar ( context ) ;
3030 initCommandPalette ( context ) ;
3131 initWebview ( context ) ;
32- initCodeLens ( context ) ;
32+ initHover ( ) ;
3333
3434 logger . client . info ( "Activating LiquidJava extension..." ) ;
3535
@@ -148,37 +148,26 @@ function initWebview(context: vscode.ExtensionContext) {
148148}
149149
150150/**
151- * Initializes code lens with clickable "View Details" button
152- * @param context The extension context
151+ * Initializes hover provider for LiquidJava diagnostics
153152 */
154- function initCodeLens ( context : vscode . ExtensionContext ) {
155- const codeLensEventEmitter = new vscode . EventEmitter < void > ( ) ;
156- const codeLensProvider : vscode . CodeLensProvider = {
157- provideCodeLenses ( document : vscode . TextDocument ) : vscode . CodeLens [ ] {
153+ function initHover ( ) {
154+ vscode . languages . registerHoverProvider ( 'java' , {
155+ provideHover ( document , position ) {
156+ // if webview is visible, do not show hover
157+ if ( webviewProvider ?. isVisible ( ) ) return null ;
158+
159+ // get lj diagnostic at the current position
158160 const diagnostics = vscode . languages . getDiagnostics ( document . uri ) ;
159- return diagnostics
160- . filter ( d => d . source === "liquidjava" && d . severity === vscode . DiagnosticSeverity . Error )
161- . map ( d => {
162- const range = new vscode . Range ( d . range . start . line , 0 , d . range . end . line , 0 ) ;
163- return new vscode . CodeLens ( range , {
164- title : "View " + ( d . message . split ( ":" ) [ 0 ] || "Error" ) ,
165- command : "liquidjava.showView" ,
166- tooltip : "Open LiquidJava View" ,
167- } ) ;
168- } ) ;
169- } ,
170- onDidChangeCodeLenses : codeLensEventEmitter . event
171- } ;
172- context . subscriptions . push (
173- vscode . languages . registerCodeLensProvider ( { language : "java" } , codeLensProvider )
174- ) ;
175- // update code lenses when diagnostics change
176- context . subscriptions . push (
177- vscode . languages . onDidChangeDiagnostics ( ( ) => {
178- codeLensEventEmitter . fire ( ) ;
179- } )
180- ) ;
181- context . subscriptions . push ( codeLensEventEmitter ) ;
161+ const diagnostic = diagnostics . find ( d => d . range . contains ( position ) && d . source === 'liquidjava' ) ;
162+ if ( ! diagnostic ) return null ;
163+
164+ // create hover content with link to open webview
165+ const hoverContent = new vscode . MarkdownString ( ) ;
166+ hoverContent . isTrusted = true ;
167+ hoverContent . appendMarkdown ( `\n\n[Open LiquidJava view](command:liquidjava.showView) for more details.` ) ;
168+ return new vscode . Hover ( hoverContent ) ;
169+ }
170+ } ) ;
182171}
183172
184173/**
0 commit comments