Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose a public API methods from this extension #130

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/extension.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BazelProjectView } from './types';

export interface BazelVscodeExtensionAPI {
readonly parseProjectFile: BazelProjectView;
}
12 changes: 10 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import {
BazelLanguageServerTerminal,
getBazelTerminal,
} from './bazelLangaugeServerTerminal';
import { getBazelProjectFile } from './bazelprojectparser';
import { BazelTaskManager } from './bazelTaskManager';
import { registerBuildifierFormatter } from './buildifier';
import { Commands, executeJavaLanguageServerCommand } from './commands';
import { BazelVscodeExtensionAPI } from './extension.api';
import { registerLSClient } from './loggingTCPServer';
import { ProjectViewManager } from './projectViewManager';
import { BazelRunTargetProvider } from './provider/bazelRunTargetProvider';
Expand All @@ -29,7 +31,9 @@ import {

const workspaceRoot = getWorkspaceRoot();

export async function activate(context: ExtensionContext) {
export async function activate(
context: ExtensionContext
): Promise<BazelVscodeExtensionAPI> {
// activates
// LS processes current .eclipse/.bazelproject file
// if it DNE create one
Expand Down Expand Up @@ -137,9 +141,13 @@ export async function activate(context: ExtensionContext) {

// always update the project view after the initial project load
registerLSClient();

return Promise.resolve({
parseProjectFile: await getBazelProjectFile(),
});
}

export function deactivate() { }
export function deactivate() {}

function syncProjectView(): void {
if (!isRedhatJavaReady()) {
Expand Down
14 changes: 14 additions & 0 deletions test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@ import * as assert from 'assert';
import { setTimeout } from 'node:timers/promises';
import { env } from 'process';
import * as vscode from 'vscode';
import { extensions } from 'vscode';
import { Commands } from '../../src/commands';
import { BazelVscodeExtensionAPI } from '../../src/extension.api';
import { Jdtls } from './Jdtls';

suite('Java Language Extension - Standard', () => {
suiteSetup(async function () {
await extensions.getExtension('sfdc.bazel-vscode-java')?.activate();
});

test('version should be correct', async function () {
const api: BazelVscodeExtensionAPI = extensions.getExtension(
'sfdc.bazel-vscode-java'
)?.exports;

assert.ok(api.parseProjectFile !== null);
});

test('RedHat Java Extension should be present', () => {
assert.ok(vscode.extensions.getExtension('redhat.java'));
});
Expand Down
Loading