@@ -4,7 +4,7 @@ import * as path from 'path';
44import * as os from 'os' ;
55import * as fs from 'fs' ;
66import { workspace , extensions , ExtensionContext , window , StatusBarAlignment , commands , ViewColumn , Uri , CancellationToken , TextDocumentContentProvider , languages , IndentAction , ProgressLocation , InputBoxOptions , Selection , Position , EventEmitter , OutputChannel , TextDocument , RelativePattern } from 'vscode' ;
7- import { ExecuteCommandParams , ExecuteCommandRequest , LanguageClient , LanguageClientOptions , RevealOutputChannelOn , Position as LSPosition , Location as LSLocation , StreamInfo , ErrorHandler , Message , ErrorAction , CloseAction , DidChangeConfigurationNotification } from 'vscode-languageclient' ;
7+ import { ExecuteCommandParams , ExecuteCommandRequest , LanguageClient , LanguageClientOptions , RevealOutputChannelOn , Position as LSPosition , Location as LSLocation , StreamInfo , ErrorHandler , Message , ErrorAction , CloseAction , DidChangeConfigurationNotification , Emitter } from 'vscode-languageclient' ;
88import { onExtensionChange , collectJavaExtensions } from './plugin' ;
99import { prepareExecutable , awaitServerConnection } from './javaServerStarter' ;
1010import { getDocumentSymbolsCommand , getDocumentSymbolsProvider } from './documentSymbols' ;
@@ -14,7 +14,7 @@ import {
1414 StatusNotification , ClassFileContentsRequest , ProjectConfigurationUpdateRequest , MessageType , ActionableNotification , FeatureStatus , CompileWorkspaceRequest , CompileWorkspaceStatus , ProgressReportNotification , ExecuteClientCommandRequest , SendNotificationRequest ,
1515 SourceAttachmentRequest , SourceAttachmentResult , SourceAttachmentAttribute
1616} from './protocol' ;
17- import { ExtensionAPI , ExtensionApiVersion } from './extension.api' ;
17+ import { ExtensionAPI , ExtensionApiVersion , ClasspathQueryOptions , ClasspathResult } from './extension.api' ;
1818import * as buildpath from './buildpath' ;
1919import * as hoverAction from './hoverAction' ;
2020import * as sourceAction from './sourceAction' ;
@@ -242,6 +242,21 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
242242 const snippetProvider : SnippetCompletionProvider = new SnippetCompletionProvider ( ) ;
243243 context . subscriptions . push ( languages . registerCompletionItemProvider ( { scheme : 'file' , language : 'java' } , snippetProvider ) ) ;
244244
245+ const getProjectSettings = async ( uri : string , SettingKeys : string [ ] ) => {
246+ return await commands . executeCommand < Object > ( Commands . EXECUTE_WORKSPACE_COMMAND , Commands . GET_PROJECT_SETTINGS , uri , SettingKeys ) ;
247+ } ;
248+
249+ const getClasspaths = async ( uri : string , options : ClasspathQueryOptions ) => {
250+ return await commands . executeCommand < ClasspathResult > ( Commands . EXECUTE_WORKSPACE_COMMAND , Commands . GET_CLASSPATHS , uri , JSON . stringify ( options ) ) ;
251+ } ;
252+
253+ const isTestFile = async ( uri : string ) => {
254+ return await commands . executeCommand < boolean > ( Commands . EXECUTE_WORKSPACE_COMMAND , Commands . IS_TEST_FILE , uri ) ;
255+ } ;
256+
257+ const _onDidClasspathUpdate = new Emitter < Uri > ( ) ;
258+ const onDidClasspathUpdate = _onDidClasspathUpdate . event ;
259+
245260 languageClient . onReady ( ) . then ( ( ) => {
246261 languageClient . onNotification ( StatusNotification . type , ( report ) => {
247262 switch ( report . type ) {
@@ -253,7 +268,11 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
253268 javaRequirement : requirements ,
254269 status : report . type ,
255270 registerHoverCommand,
256- getDocumentSymbols
271+ getDocumentSymbols,
272+ getProjectSettings,
273+ getClasspaths,
274+ isTestFile,
275+ onDidClasspathUpdate
257276 } ) ;
258277 snippetProvider . setActivation ( false ) ;
259278 break ;
@@ -264,7 +283,11 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
264283 javaRequirement : requirements ,
265284 status : report . type ,
266285 registerHoverCommand,
267- getDocumentSymbols
286+ getDocumentSymbols,
287+ getProjectSettings,
288+ getClasspaths,
289+ isTestFile,
290+ onDidClasspathUpdate
268291 } ) ;
269292 break ;
270293 case 'Starting' :
@@ -278,6 +301,10 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
278301 serverTasks . updateServerTask ( progress ) ;
279302 } ) ;
280303 languageClient . onNotification ( ActionableNotification . type , ( notification ) => {
304+ if ( notification . message === "__CLASSPATH_UPDATED__" ) {
305+ _onDidClasspathUpdate . fire ( Uri . parse ( notification . data ) ) ;
306+ return ;
307+ }
281308 let show = null ;
282309 switch ( notification . severity ) {
283310 case MessageType . Log :
0 commit comments