@@ -5,7 +5,7 @@ import * as fs from 'fs';
55import * as fse from 'fs-extra' ;
66import * as os from 'os' ;
77import * as path from 'path' ;
8- import { CodeActionContext , commands , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions , IndentAction , InputBoxOptions , languages , QuickPickItemKind , RelativePattern , TextDocument , UIKind , Uri , ViewColumn , window , workspace , WorkspaceConfiguration } from 'vscode' ;
8+ import { CodeActionContext , commands , ConfigurationTarget , Diagnostic , env , EventEmitter , ExtensionContext , extensions , IndentAction , InputBoxOptions , languages , QuickPickItemKind , RelativePattern , TextDocument , TextEditorRevealType , UIKind , Uri , ViewColumn , window , workspace , WorkspaceConfiguration } from 'vscode' ;
99import { CancellationToken , CodeActionParams , CodeActionRequest , Command , CompletionRequest , DidChangeConfigurationNotification , ExecuteCommandParams , ExecuteCommandRequest , LanguageClientOptions , RevealOutputChannelOn } from 'vscode-languageclient' ;
1010import { LanguageClient } from 'vscode-languageclient/node' ;
1111import { apiManager } from './apiManager' ;
@@ -30,7 +30,6 @@ import { JavaClassEditorProvider } from './javaClassEditor';
3030import { StandardLanguageClient } from './standardLanguageClient' ;
3131import { SyntaxLanguageClient } from './syntaxLanguageClient' ;
3232import { convertToGlob , deleteClientLog , deleteDirectory , ensureExists , getBuildFilePatterns , getExclusionGlob , getInclusionPatternsFromNegatedExclusion , getJavaConfig , getJavaConfiguration , hasBuildToolConflicts , resolveActualCause } from './utils' ;
33- import glob = require( 'glob' ) ;
3433import { Telemetry } from './telemetry' ;
3534import { getMessage } from './errorUtils' ;
3635import { TelemetryService } from '@redhat-developer/vscode-redhat-telemetry/lib' ;
@@ -39,6 +38,7 @@ import { loadSupportedJreNames } from './jdkUtils';
3938import { BuildFileSelector , PICKED_BUILD_FILES , cleanupProjectPickerCache } from './buildFilesSelector' ;
4039import { pasteFile } from './pasteAction' ;
4140import { ServerStatusKind } from './serverStatus' ;
41+ import glob = require( 'glob' ) ;
4242
4343const syntaxClient : SyntaxLanguageClient = new SyntaxLanguageClient ( ) ;
4444const standardClient : StandardLanguageClient = new StandardLanguageClient ( ) ;
@@ -399,7 +399,16 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
399399 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_FORMATTER , async ( ) => openFormatter ( context . extensionPath ) ) ) ;
400400 context . subscriptions . push ( commands . registerCommand ( Commands . OPEN_FILE , async ( uri : string ) => {
401401 const parsedUri = Uri . parse ( uri ) ;
402- await window . showTextDocument ( parsedUri ) ;
402+ const editor = await window . showTextDocument ( parsedUri ) ;
403+ // Reveal the document at the specified line, if possible (e.g. jumping to a specific javadoc method).
404+ if ( editor && parsedUri . scheme === 'jdt' && parsedUri . fragment ) {
405+ const line = parseInt ( parsedUri . fragment ) ;
406+ if ( isNaN ( line ) || line < 1 || line > editor . document . lineCount ) {
407+ return ;
408+ }
409+ const range = editor . document . lineAt ( line - 1 ) . range ;
410+ editor . revealRange ( range , TextEditorRevealType . AtTop ) ;
411+ }
403412 } ) ) ;
404413
405414 context . subscriptions . push ( commands . registerCommand ( Commands . CLEAN_WORKSPACE , ( force ?: boolean ) => cleanWorkspace ( workspacePath , force ) ) ) ;
0 commit comments