Skip to content
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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
// --- Chat ---
"inlineChat.enableV2": true,
"inlineChat.affordance": "gutter",
"inlineChat.affordance": "editor",
"inlineChat.renderMode": "hover",
"chat.tools.terminal.autoApprove": {
"scripts/test.bat": true,
Expand Down
6 changes: 4 additions & 2 deletions extensions/json-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@
"type": "object",
"default": {
"https://schemastore.azurewebsites.net/": true,
"https://raw.githubusercontent.com/": true,
"https://raw.githubusercontent.com/microsoft/vscode/": true,
"https://raw.githubusercontent.com/devcontainers/spec/": true,
"https://www.schemastore.org/": true,
"https://json.schemastore.org/": true,
"https://json-schema.org/": true
"https://json-schema.org/": true,
"https://developer.microsoft.com/json-schemas/": true
},
"additionalProperties": {
"type": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type * as Proto from '../../tsServer/protocol/protocol';
import * as PConst from '../../tsServer/protocol/protocol.const';
import * as typeConverters from '../../typeConverters';
import { ClientCapability, ITypeScriptServiceClient } from '../../typescriptService';
import { readUnifiedConfig, unifiedConfigSection } from '../../utils/configuration';
import { ResourceUnifiedConfigValue } from '../../utils/configuration';
import { conditionalRegistration, requireHasModifiedUnifiedConfig, requireSomeCapability } from '../util/dependentRegistration';
import { ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange } from './baseCodeLensProvider';
import { ExecutionTarget } from '../../tsServer/server';
Expand All @@ -23,31 +23,29 @@ const Config = Object.freeze({
});

export default class TypeScriptImplementationsCodeLensProvider extends TypeScriptBaseCodeLensProvider {

private readonly _enabled: ResourceUnifiedConfigValue<boolean>;
private readonly _showOnInterfaceMethods: ResourceUnifiedConfigValue<boolean>;
private readonly _showOnAllClassMethods: ResourceUnifiedConfigValue<boolean>;

public constructor(
client: ITypeScriptServiceClient,
protected _cachedResponse: CachedResponse<Proto.NavTreeResponse>,
private readonly language: LanguageDescription
) {
super(client, _cachedResponse);
this._register(
vscode.workspace.onDidChangeConfiguration(evt => {
if (
evt.affectsConfiguration(`${unifiedConfigSection}.${Config.enabled}`) ||
evt.affectsConfiguration(`${language.id}.${Config.enabled}`) ||
evt.affectsConfiguration(`${unifiedConfigSection}.${Config.showOnInterfaceMethods}`) ||
evt.affectsConfiguration(`${language.id}.${Config.showOnInterfaceMethods}`) ||
evt.affectsConfiguration(`${unifiedConfigSection}.${Config.showOnAllClassMethods}`) ||
evt.affectsConfiguration(`${language.id}.${Config.showOnAllClassMethods}`)
) {
this.changeEmitter.fire();
}
})
);
}

this._enabled = this._register(new ResourceUnifiedConfigValue<boolean>(Config.enabled, false));
this._register(this._enabled.onDidChange(() => this.changeEmitter.fire()));

this._showOnInterfaceMethods = this._register(new ResourceUnifiedConfigValue<boolean>(Config.showOnInterfaceMethods, false));
this._register(this._showOnInterfaceMethods.onDidChange(() => this.changeEmitter.fire()));

this._showOnAllClassMethods = this._register(new ResourceUnifiedConfigValue<boolean>(Config.showOnAllClassMethods, false));
this._register(this._showOnAllClassMethods.onDidChange(() => this.changeEmitter.fire()));
}

override async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<ReferencesCodeLens[]> {
const enabled = readUnifiedConfig<boolean>(Config.enabled, false, { scope: document, fallbackSection: this.language.id });
const enabled = this._enabled.getValue(document);
if (!enabled) {
return [];
}
Expand Down Expand Up @@ -131,7 +129,7 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip
if (
item.kind === PConst.Kind.method &&
parent?.kind === PConst.Kind.interface &&
readUnifiedConfig<boolean>('implementationsCodeLens.showOnInterfaceMethods', false, { scope: document, fallbackSection: this.language.id })
this._showOnInterfaceMethods.getValue(document)
) {
return getSymbolRange(document, item);
}
Expand All @@ -141,7 +139,7 @@ export default class TypeScriptImplementationsCodeLensProvider extends TypeScrip
if (
item.kind === PConst.Kind.method &&
parent?.kind === PConst.Kind.class &&
readUnifiedConfig<boolean>('implementationsCodeLens.showOnAllClassMethods', false, { scope: document, fallbackSection: this.language.id })
this._showOnAllClassMethods.getValue(document)
) {
// But not private ones as these can never be overridden
if (/\bprivate\b/.test(item.kindModifiers ?? '')) {
Expand All @@ -165,6 +163,6 @@ export function register(
requireSomeCapability(client, ClientCapability.Semantic),
], () => {
return vscode.languages.registerCodeLensProvider(selector.semantic,
new TypeScriptImplementationsCodeLensProvider(client, cachedResponse, language));
new TypeScriptImplementationsCodeLensProvider(client, cachedResponse));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as PConst from '../../tsServer/protocol/protocol.const';
import { ExecutionTarget } from '../../tsServer/server';
import * as typeConverters from '../../typeConverters';
import { ClientCapability, ITypeScriptServiceClient } from '../../typescriptService';
import { readUnifiedConfig, unifiedConfigSection } from '../../utils/configuration';
import { ResourceUnifiedConfigValue } from '../../utils/configuration';
import { conditionalRegistration, requireHasModifiedUnifiedConfig, requireSomeCapability } from '../util/dependentRegistration';
import { ReferencesCodeLens, TypeScriptBaseCodeLensProvider, getSymbolRange } from './baseCodeLensProvider';

Expand All @@ -22,28 +22,25 @@ const Config = Object.freeze({
});

export class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLensProvider {

private readonly _enabled: ResourceUnifiedConfigValue<boolean>;
private readonly _showOnAllFunctions: ResourceUnifiedConfigValue<boolean>;

public constructor(
client: ITypeScriptServiceClient,
protected _cachedResponse: CachedResponse<Proto.NavTreeResponse>,
private readonly language: LanguageDescription
) {
super(client, _cachedResponse);
this._register(
vscode.workspace.onDidChangeConfiguration(evt => {
if (
evt.affectsConfiguration(`${unifiedConfigSection}.${Config.enabled}`) ||
evt.affectsConfiguration(`${language.id}.${Config.enabled}`) ||
evt.affectsConfiguration(`${unifiedConfigSection}.${Config.showOnAllFunctions}`) ||
evt.affectsConfiguration(`${language.id}.${Config.showOnAllFunctions}`)
) {
this.changeEmitter.fire();
}
})
);

this._enabled = this._register(new ResourceUnifiedConfigValue<boolean>(Config.enabled, false));
this._register(this._enabled.onDidChange(() => this.changeEmitter.fire()));

this._showOnAllFunctions = this._register(new ResourceUnifiedConfigValue<boolean>(Config.showOnAllFunctions, false));
this._register(this._showOnAllFunctions.onDidChange(() => this.changeEmitter.fire()));
}

override async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<ReferencesCodeLens[]> {
const enabled = readUnifiedConfig<boolean>(Config.enabled, false, { scope: document, fallbackSection: this.language.id });
const enabled = this._enabled.getValue(document);
if (!enabled) {
return [];
}
Expand Down Expand Up @@ -95,7 +92,7 @@ export class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLens

switch (item.kind) {
case PConst.Kind.function: {
const showOnAllFunctions = readUnifiedConfig<boolean>(Config.showOnAllFunctions, false, { scope: document, fallbackSection: this.language.id });
const showOnAllFunctions = this._showOnAllFunctions.getValue(document);
if (showOnAllFunctions && item.nameSpan) {
return getSymbolRange(document, item);
}
Expand Down Expand Up @@ -160,6 +157,6 @@ export function register(
requireSomeCapability(client, ClientCapability.Semantic),
], () => {
return vscode.languages.registerCodeLensProvider(selector.semantic,
new TypeScriptReferencesCodeLensProvider(client, cachedResponse, language));
new TypeScriptReferencesCodeLensProvider(client, cachedResponse));
});
}
20 changes: 11 additions & 9 deletions extensions/typescript-language-features/src/languageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ClientCapability } from './typescriptService';
import TypeScriptServiceClient from './typescriptServiceClient';
import TypingsStatus from './ui/typingsStatus';
import { Disposable } from './utils/dispose';
import { readUnifiedConfig } from './utils/configuration';
import { UnifiedConfigValue } from './utils/configuration';
import { isWeb, isWebAndHasSharedArrayBuffers, supportsReadableByteStreams } from './utils/platform';


Expand All @@ -34,8 +34,16 @@ export default class LanguageProvider extends Disposable {
private readonly onCompletionAccepted: (item: vscode.CompletionItem) => void,
) {
super();
vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
this.configurationChanged();

const scope: vscode.ConfigurationScope = { languageId: this.description.languageIds[0] };

const validateConfig = this._register(new UnifiedConfigValue<boolean>('validate.enabled', true, { scope, fallbackSection: this.id, fallbackSubSectionNameOverride: 'validate.enable' }));
this.updateValidate(validateConfig.getValue());
this._register(validateConfig.onDidChange(value => this.updateValidate(value)));

const suggestionsConfig = this._register(new UnifiedConfigValue<boolean>('suggestionActions.enabled', true, { scope, fallbackSection: this.id }));
this.updateSuggestionDiagnostics(suggestionsConfig.getValue());
this._register(suggestionsConfig.onDidChange(value => this.updateSuggestionDiagnostics(value)));

client.onReady(() => this.registerProviders());
}
Expand Down Expand Up @@ -91,12 +99,6 @@ export default class LanguageProvider extends Disposable {
]);
}

private configurationChanged(): void {
const scope: vscode.ConfigurationScope = { languageId: this.description.languageIds[0] };
this.updateValidate(readUnifiedConfig<boolean>('validate.enabled', true, { scope, fallbackSection: this.id, fallbackSubSectionNameOverride: 'validate.enable' }));
this.updateSuggestionDiagnostics(readUnifiedConfig<boolean>('suggestionActions.enabled', true, { scope, fallbackSection: this.id }));
}

public handlesUri(resource: vscode.Uri): boolean {
const ext = extname(resource.path).slice(1).toLowerCase();
return this.description.standardFileExtensions.includes(ext) || this.handlesConfigFile(resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as typeConverters from '../typeConverters';
import { ClientCapability, ITypeScriptServiceClient } from '../typescriptService';
import { inMemoryResourcePrefix } from '../typescriptServiceClient';
import { coalesce } from '../utils/arrays';
import { readUnifiedConfig, unifiedConfigSection } from '../utils/configuration';
import { ResourceUnifiedConfigValue } from '../utils/configuration';
import { Delayer, setImmediate } from '../utils/async';
import { nulToken } from '../utils/cancellation';
import { Disposable } from '../utils/dispose';
Expand Down Expand Up @@ -471,6 +471,8 @@ export default class BufferSyncSupport extends Disposable {
private listening: boolean = false;
private readonly synchronizer: BufferSynchronizer;

private readonly _validate: ResourceUnifiedConfigValue<boolean>;

private readonly _tabResources: TabResourceTracker;

constructor(
Expand All @@ -482,6 +484,8 @@ export default class BufferSyncSupport extends Disposable {
this.client = client;
this.modeIds = new Set<string>(modeIds);

this._validate = this._register(new ResourceUnifiedConfigValue<boolean>('validate.enabled', true, { fallbackSubSectionNameOverride: 'validate.enable' }));

this.diagnosticDelayer = new Delayer<any>(300);

const pathNormalizer = (path: vscode.Uri) => this.client.toTsFilePath(path);
Expand Down Expand Up @@ -511,14 +515,7 @@ export default class BufferSyncSupport extends Disposable {
}
}));

this._register(vscode.workspace.onDidChangeConfiguration((e) => {
if (e.affectsConfiguration(`${unifiedConfigSection}.validate.enabled`)
|| e.affectsConfiguration('typescript.validate.enable')
|| e.affectsConfiguration('javascript.validate.enable')
) {
this.requestAllDiagnostics();
}
}));
this._register(this._validate.onDidChange(() => this.requestAllDiagnostics()));
}

private readonly _onDelete = this._register(new vscode.EventEmitter<vscode.Uri>());
Expand Down Expand Up @@ -769,9 +766,6 @@ export default class BufferSyncSupport extends Disposable {
return false;
}

const fallbackSection = (buffer.languageId === languageModeIds.javascript || buffer.languageId === languageModeIds.javascriptreact)
? 'javascript'
: 'typescript';
return readUnifiedConfig<boolean>('validate.enabled', true, { scope: buffer.document, fallbackSection, fallbackSubSectionNameOverride: 'validate.enable' });
return this._validate.getValue(buffer.document);
}
}
Loading
Loading