2323
2424'use strict' ;
2525
26- import { commands , window , workspace , ExtensionContext , ProgressLocation , TextEditorDecorationType } from 'vscode' ;
26+ import { commands , window , workspace , ExtensionContext , TextEditorDecorationType } from 'vscode' ;
2727
2828import {
2929 LanguageClient ,
@@ -33,21 +33,18 @@ import {
3333import {
3434 MessageType ,
3535 LogMessageNotification ,
36- SymbolInformation ,
3736 TelemetryEventNotification
3837} from 'vscode-languageclient' ;
3938
4039import * as net from 'net' ;
4140import * as fs from 'fs' ;
42- import * as os from 'os' ;
4341import * as path from 'path' ;
4442import * as vscode from 'vscode' ;
45- import * as ls from 'vscode-languageserver-protocol' ;
4643import { StreamDebugAdapter } from './streamDebugAdapter' ;
4744import { NbTestAdapter } from './testAdapter' ;
4845import { asRanges , StatusMessageRequest , ShowStatusMessageParams , QuickPickRequest , InputBoxRequest , MutliStepInputRequest , TestProgressNotification , DebugConnector ,
4946 TextEditorDecorationCreateRequest , TextEditorDecorationSetNotification , TextEditorDecorationDisposeNotification , HtmlPageRequest , HtmlPageParams ,
50- ExecInHtmlPageRequest , SetTextEditorDecorationParams , ProjectActionParams , UpdateConfigurationRequest , QuickPickStep , InputBoxStep , SaveDocumentsRequest , SaveDocumentRequestParams
47+ ExecInHtmlPageRequest , SetTextEditorDecorationParams , UpdateConfigurationRequest , QuickPickStep , InputBoxStep , SaveDocumentsRequest , SaveDocumentRequestParams
5148} from './lsp/protocol' ;
5249import * as launchConfigurations from './launchConfigurations' ;
5350import { TreeViewService , Visualizer } from './explorer' ;
@@ -56,7 +53,6 @@ import { InputStep, MultiStepInput } from './utils';
5653import { PropertiesView } from './propertiesView/propertiesView' ;
5754import { l10n } from './localiser' ;
5855import { extConstants } from './constants' ;
59- import { JdkDownloaderView } from './jdkDownloader/view' ;
6056import { ExtensionInfo } from './extensionInfo' ;
6157import { ClientPromise } from './lsp/clientPromise' ;
6258import { ExtensionLogger , LogLevel } from './logger' ;
@@ -66,10 +62,11 @@ import { NbLanguageClient } from './lsp/nbLanguageClient';
6662import { configChangeListener } from './configurations/listener' ;
6763import { isNbJavacDisabledHandler } from './configurations/handlers' ;
6864import { subscribeCommands } from './commands/register' ;
65+ import { VSNetBeansAPI } from './lsp/types' ;
6966
70- const listeners = new Map < string , string [ ] > ( ) ;
7167export let LOGGER : ExtensionLogger ;
7268export namespace globalVars {
69+ export const listeners = new Map < string , string [ ] > ( ) ;
7370 export let extensionInfo : ExtensionInfo ;
7471 export let clientPromise : ClientPromise ;
7572 export let debugPort : number = - 1 ;
@@ -105,31 +102,6 @@ export function findClusters(myPath : string): string[] {
105102 return clusters ;
106103}
107104
108- // for tests only !
109- export function awaitClient ( ) : Promise < NbLanguageClient > {
110- const clientPromise = globalVars . clientPromise ;
111- if ( clientPromise . client && clientPromise . initialPromiseResolved ) {
112- return clientPromise . client ;
113- }
114- let nbcode = vscode . extensions . getExtension ( extConstants . ORACLE_VSCODE_EXTENSION_ID ) ;
115- if ( ! nbcode ) {
116- return Promise . reject ( new Error ( l10n . value ( "jdk.extension.notInstalled.label" ) ) ) ;
117- }
118- const t : Thenable < NbLanguageClient > = nbcode . activate ( ) . then ( nc => {
119- if ( globalVars . clientPromise . client === undefined || ! globalVars . clientPromise . initialPromiseResolved ) {
120- throw new Error ( l10n . value ( "jdk.extenstion.error_msg.clientNotAvailable" ) ) ;
121- } else {
122- return globalVars . clientPromise . client ;
123- }
124- } ) ;
125- return Promise . resolve ( t ) ;
126- }
127-
128- interface VSNetBeansAPI {
129- version : string ;
130- apiVersion : string ;
131- }
132-
133105function contextUri ( ctx : any ) : vscode . Uri | undefined {
134106 if ( ctx ?. fsPath ) {
135107 return ctx as vscode . Uri ;
@@ -307,21 +279,6 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
307279 context . subscriptions . push ( commands . registerCommand ( extConstants . COMMAND_PREFIX + '.package.test' , async ( uri , launchConfiguration ?) => {
308280 await runDebug ( true , true , uri , undefined , launchConfiguration ) ;
309281 } ) ) ;
310- context . subscriptions . push ( commands . registerCommand ( extConstants . COMMAND_PREFIX + '.workspace.symbols' , async ( query ) => {
311- const c = await globalVars . clientPromise . client ;
312- return ( await c . sendRequest < SymbolInformation [ ] > ( "workspace/symbol" , { "query" : query } ) ) ?? [ ] ;
313- } ) ) ;
314- context . subscriptions . push ( commands . registerCommand ( extConstants . COMMAND_PREFIX + '.startup.condition' , async ( ) => {
315- return globalVars . clientPromise . client ;
316- } ) ) ;
317- context . subscriptions . push ( commands . registerCommand ( extConstants . COMMAND_PREFIX + '.addEventListener' , ( eventName , listener ) => {
318- let ls = listeners . get ( eventName ) ;
319- if ( ! ls ) {
320- ls = [ ] ;
321- listeners . set ( eventName , ls ) ;
322- }
323- ls . push ( listener ) ;
324- } ) ) ;
325282 context . subscriptions . push ( commands . registerCommand ( extConstants . COMMAND_PREFIX + '.node.properties.edit' ,
326283 async ( node ) => await PropertiesView . createOrShow ( context , node , ( await globalVars . clientPromise . client ) . findTreeViewService ( ) ) ) ) ;
327284
@@ -481,7 +438,7 @@ function doActivateWithJDK(): void {
481438 }
482439 } ) ;
483440 c . onNotification ( TelemetryEventNotification . type , ( param ) => {
484- const ls = listeners . get ( param ) ;
441+ const ls = globalVars . listeners . get ( param ) ;
485442 if ( ls ) {
486443 for ( const listener of ls ) {
487444 commands . executeCommand ( listener ) ;
0 commit comments