Skip to content

Commit b73b94a

Browse files
committed
Refactored NB language client listeners
1 parent 0551af8 commit b73b94a

File tree

7 files changed

+43
-12
lines changed

7 files changed

+43
-12
lines changed

vscode/src/extension.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
'use strict';
2525

26-
import { commands, workspace, ExtensionContext, TextEditorDecorationType } from 'vscode';
26+
import { ExtensionContext, TextEditorDecorationType } from 'vscode';
2727

2828

2929
import * as vscode from 'vscode';
@@ -41,6 +41,8 @@ import { subscribeCommands } from './commands/register';
4141
import { VSNetBeansAPI } from './lsp/types';
4242
import { registerListenersBeforeClientInit } from './listener';
4343
import { registerDebugger } from './debugger/debugger';
44+
import { registerConfigChangeListeners } from './configurations/listener';
45+
import { registerFileProviders } from './lsp/listeners/textDocumentContentProvider';
4446

4547
export let LOGGER: ExtensionLogger;
4648
export namespace globalVars {
@@ -83,15 +85,8 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
8385

8486
// register commands
8587
subscribeCommands(context);
86-
87-
const archiveFileProvider = <vscode.TextDocumentContentProvider> {
88-
provideTextDocumentContent: async (uri: vscode.Uri, token: vscode.CancellationToken): Promise<string> => {
89-
return await commands.executeCommand(extConstants.COMMAND_PREFIX + '.get.archive.file.content', uri.toString());
90-
}
91-
};
92-
context.subscriptions.push(workspace.registerTextDocumentContentProvider('jar', archiveFileProvider));
93-
context.subscriptions.push(workspace.registerTextDocumentContentProvider('nbjrt', archiveFileProvider));
94-
88+
registerFileProviders(context);
89+
9590
launchConfigurations.updateLaunchConfig();
9691

9792
// register completions:

vscode/src/lsp/initializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { attachNbProcessListeners, launchNbcode } from "./nbcode";
2525
import { NbLanguageClient } from "./nbLanguageClient";
2626
import { NbTestAdapter } from "../testAdapter";
2727
import { registerListenersAfterClientInit } from "../listener";
28-
import { registerNotificationListeners } from "./notifications/register";
29-
import { registerRequestListeners } from "./requests/register";
28+
import { registerNotificationListeners } from "./listeners/notifications/register";
29+
import { registerRequestListeners } from "./listeners/requests/register";
3030
import { TreeViewService, Visualizer } from "../explorer";
3131
import { commands, TextEditor, TreeView, window, workspace } from "vscode";
3232
import { extConstants } from "../constants";
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright (c) 2023-2024, Oracle and/or its affiliates.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { ExtensionContext, TextDocumentContentProvider, Uri, commands, workspace } from "vscode";
18+
import { nbCommands } from "../../commands/commands";
19+
import { Disposable } from "vscode-languageclient";
20+
21+
const archiveFileProvider = <TextDocumentContentProvider> {
22+
provideTextDocumentContent: async (uri: Uri): Promise<string> => {
23+
return await commands.executeCommand(nbCommands.archiveFileContent, uri.toString());
24+
}
25+
};
26+
27+
const textDocumentContentProvider: Disposable[] = [
28+
workspace.registerTextDocumentContentProvider('nbjrt', archiveFileProvider),
29+
workspace.registerTextDocumentContentProvider('jar', archiveFileProvider)
30+
]
31+
32+
export const registerFileProviders = (context: ExtensionContext) => {
33+
textDocumentContentProvider.forEach((provider: Disposable) =>{
34+
context.subscriptions.push(provider);
35+
})
36+
}

0 commit comments

Comments
 (0)