Skip to content
Merged
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
25 changes: 7 additions & 18 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export async function activate(context: ExtensionContext): Promise<void> {
await initializeFromJsonFile(context.asAbsolutePath('./package.json'), { firstParty: true });
await initExpService(context);
await instrumentOperation('activation', doActivate)(context);
await commands.executeCommand('setContext', Context.ACTIVATION_CONTEXT_KEY, true);
}

export async function deactivate(): Promise<void> {
Expand Down Expand Up @@ -62,16 +61,10 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
if (extensionApi.onDidServerModeChange) {
const onDidServerModeChange: Event<string> = extensionApi.onDidServerModeChange;
context.subscriptions.push(onDidServerModeChange(async (mode: string) => {
if (serverMode === mode) {
return;
}
serverMode = mode;
// Only re-initialize the component when its lightweight -> standard
if (mode === LanguageServerMode.Standard) {
testSourceProvider.clear();
registerTestCodeActionProvider();
createTestController();
await showTestItemsInCurrentFile();
registerComponents(context);
}
}));
}
Expand All @@ -89,7 +82,9 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
if (javaDebugger?.isActive) {
progressProvider = javaDebugger.exports?.progressProvider;
}
}

function registerComponents(context: ExtensionContext): void {
registerAskForChoiceCommand(context);
registerAdvanceAskForChoice(context);
registerAskForInputCommand(context);
Expand Down Expand Up @@ -130,19 +125,13 @@ async function doActivate(_operationId: string, context: ExtensionContext): Prom
}),
);

if (isStandardServerReady()) {
registerTestCodeActionProvider();
createTestController();
await showTestItemsInCurrentFile();
}

registerTestCodeActionProvider();
createTestController();
showTestItemsInCurrentFile();
commands.executeCommand('setContext', Context.ACTIVATION_CONTEXT_KEY, true);
}

async function isTestJavaFile(document: TextDocument | undefined): Promise<boolean> {
if (!isStandardServerReady()) {
return false;
}

if (!document?.uri || !isJavaFile(document)) {
return false;
}
Expand Down