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

Provide IntelliSense status information when using github.dev #17658

Merged
merged 18 commits into from
Oct 13, 2021
Merged
1 change: 1 addition & 0 deletions news/1 Enhancements/17658.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide IntelliSense status information when using `github.dev` or any other web platform.
3 changes: 3 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@
"Testing.configureTests": "Configure Test Framework",
"Testing.testNotConfigured": "No test framework configured.",
"Common.openOutputPanel": "Show output",
"LanguageService.statusItem.name":"Python IntelliSense Status",
"LanguageService.statusItem.text": "Partial Mode",
"LanguageService.statusItem.detail": "Limited IntelliSense provided by Pylance",
"LanguageService.lsFailedToStart": "We encountered an issue starting the language server. Reverting to Jedi language engine. Check the Python output panel for details.",
"LanguageService.lsFailedToDownload": "We encountered an issue downloading the language server. Reverting to Jedi language engine. Check the Python output panel for details.",
"LanguageService.lsFailedToExtract": "We encountered an issue extracting the language server. Reverting to Jedi language engine. Check the Python output panel for details.",
Expand Down
2 changes: 2 additions & 0 deletions src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LanguageServerType } from '../activation/types';
import { AppinsightsKey, PVSC_EXTENSION_ID, PYLANCE_EXTENSION_ID } from '../common/constants';
import { loadLocalizedStringsForBrowser } from '../common/utils/localizeHelpers';
import { EventName } from '../telemetry/constants';
import { createStatusItem } from './intellisenseStatus';

interface BrowserConfig {
distUrl: string; // URL to Pylance's dist folder.
Expand Down Expand Up @@ -115,6 +116,7 @@ async function runPylance(
const disposable = languageClient.start();

context.subscriptions.push(disposable);
context.subscriptions.push(createStatusItem());
} catch (e) {
console.log(e);
}
Expand Down
26 changes: 26 additions & 0 deletions src/client/browser/intellisenseStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// IMPORTANT: Do not import any node fs related modules here, as they do not work in browser.
import * as vscode from 'vscode';
import { LanguageService } from './localize';

export function createStatusItem(): vscode.Disposable {
if ('createLanguageStatusItem' in vscode.languages) {
const statusItem = vscode.languages.createLanguageStatusItem('python.projectStatus', {
language: 'python',
});
statusItem.name = LanguageService.statusItem.name();
statusItem.severity = vscode.LanguageStatusSeverity.Warning;
statusItem.text = LanguageService.statusItem.text();
statusItem.detail = LanguageService.statusItem.detail();
statusItem.command = {
title: 'Learn More',
command: 'vscode.open',
arguments: [vscode.Uri.parse('https://aka.ms/AAdzyh4')],
};
return statusItem;
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
return { dispose: () => {} };
}
3 changes: 2 additions & 1 deletion tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"include": [
"./src/client/browser"
"./src/client/browser",
"./types/vscode.proposed.d.ts"
]
}
27 changes: 27 additions & 0 deletions types/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,33 @@ declare module 'vscode' {
replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
}

//#region https://github.com/microsoft/vscode/issues/129037

enum LanguageStatusSeverity {
Information = 0,
Warning = 1,
Error = 2,
}

interface LanguageStatusItem {
readonly id: string;
selector: DocumentSelector;
// todo@jrieken replace with boolean ala needsAttention
severity: LanguageStatusSeverity;
name: string | undefined;
text: string;
detail?: string;
command: Command | undefined;
accessibilityInformation?: AccessibilityInformation;
dispose(): void;
}

namespace languages {
export function createLanguageStatusItem(id: string, selector: DocumentSelector): LanguageStatusItem;
}

//#endregion

export interface QuickPick<T extends QuickPickItem> extends QuickInput {
/**
* An optional flag to sort the final results by index of first query match in label. Defaults to true.
Expand Down