Skip to content

Commit 858fdfa

Browse files
author
Kartik Raj
authored
Provide IntelliSense status information when using github.dev (microsoft#17658)
* Provide IntelliSense status information when using github.dev * News entry * Update wording * PR reviews * Include proposed APIs for browser config * Include common module for browser config * Change how we detect * Change wording * Have same browser config as extension config * Revert "Have same browser config as extension config" This reverts commit 515003a. * Revert "Change wording" This reverts commit dd64f24. * Revert "Change how we detect" This reverts commit ae56079. * Revert "Include common module for browser config" This reverts commit bf1815c. * Do not import from misc module * Detect how we check if property exists * Do not localize strings * Localize strings using new localize module * Remove outdated comment
1 parent 1c5ff76 commit 858fdfa

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

news/1 Enhancements/17658.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Provide IntelliSense status information when using `github.dev` or any other web platform.

package.nls.json

+3
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@
165165
"Testing.configureTests": "Configure Test Framework",
166166
"Testing.testNotConfigured": "No test framework configured.",
167167
"Common.openOutputPanel": "Show output",
168+
"LanguageService.statusItem.name":"Python IntelliSense Status",
169+
"LanguageService.statusItem.text": "Partial Mode",
170+
"LanguageService.statusItem.detail": "Limited IntelliSense provided by Pylance",
168171
"LanguageService.lsFailedToStart": "We encountered an issue starting the language server. Reverting to Jedi language engine. Check the Python output panel for details.",
169172
"LanguageService.lsFailedToDownload": "We encountered an issue downloading the language server. Reverting to Jedi language engine. Check the Python output panel for details.",
170173
"LanguageService.lsFailedToExtract": "We encountered an issue extracting the language server. Reverting to Jedi language engine. Check the Python output panel for details.",

src/client/browser/extension.ts

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { LanguageServerType } from '../activation/types';
1111
import { AppinsightsKey, PVSC_EXTENSION_ID, PYLANCE_EXTENSION_ID } from '../common/constants';
1212
import { loadLocalizedStringsForBrowser } from '../common/utils/localizeHelpers';
1313
import { EventName } from '../telemetry/constants';
14+
import { createStatusItem } from './intellisenseStatus';
1415

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

117118
context.subscriptions.push(disposable);
119+
context.subscriptions.push(createStatusItem());
118120
} catch (e) {
119121
console.log(e);
120122
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// IMPORTANT: Do not import any node fs related modules here, as they do not work in browser.
5+
import * as vscode from 'vscode';
6+
import { LanguageService } from './localize';
7+
8+
export function createStatusItem(): vscode.Disposable {
9+
if ('createLanguageStatusItem' in vscode.languages) {
10+
const statusItem = vscode.languages.createLanguageStatusItem('python.projectStatus', {
11+
language: 'python',
12+
});
13+
statusItem.name = LanguageService.statusItem.name();
14+
statusItem.severity = vscode.LanguageStatusSeverity.Warning;
15+
statusItem.text = LanguageService.statusItem.text();
16+
statusItem.detail = LanguageService.statusItem.detail();
17+
statusItem.command = {
18+
title: 'Learn More',
19+
command: 'vscode.open',
20+
arguments: [vscode.Uri.parse('https://aka.ms/AAdzyh4')],
21+
};
22+
return statusItem;
23+
}
24+
// eslint-disable-next-line @typescript-eslint/no-empty-function
25+
return { dispose: () => {} };
26+
}

tsconfig.browser.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "./tsconfig.json",
33
"include": [
4-
"./src/client/browser"
4+
"./src/client/browser",
5+
"./types/vscode.proposed.d.ts"
56
]
67
}

types/vscode.proposed.d.ts

+27
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,33 @@ declare module 'vscode' {
750750
replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
751751
}
752752

753+
//#region https://github.com/microsoft/vscode/issues/129037
754+
755+
enum LanguageStatusSeverity {
756+
Information = 0,
757+
Warning = 1,
758+
Error = 2,
759+
}
760+
761+
interface LanguageStatusItem {
762+
readonly id: string;
763+
selector: DocumentSelector;
764+
// todo@jrieken replace with boolean ala needsAttention
765+
severity: LanguageStatusSeverity;
766+
name: string | undefined;
767+
text: string;
768+
detail?: string;
769+
command: Command | undefined;
770+
accessibilityInformation?: AccessibilityInformation;
771+
dispose(): void;
772+
}
773+
774+
namespace languages {
775+
export function createLanguageStatusItem(id: string, selector: DocumentSelector): LanguageStatusItem;
776+
}
777+
778+
//#endregion
779+
753780
export interface QuickPick<T extends QuickPickItem> extends QuickInput {
754781
/**
755782
* An optional flag to sort the final results by index of first query match in label. Defaults to true.

0 commit comments

Comments
 (0)