Skip to content

Migrate away from *.experimental.* tree sitter settings settings #245350

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions extensions/vscode-colorize-perf-tests/src/colorizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ suite('Tokenization Performance', () => {
let originalSettingValue: any;

suiteSetup(async function () {
originalSettingValue = workspace.getConfiguration('editor').get('experimental.preferTreeSitter');
await workspace.getConfiguration('editor').update('experimental.preferTreeSitter', ["typescript"], ConfigurationTarget.Global);
originalSettingValue = workspace.getConfiguration('editor').get('preferTreeSitter');
await workspace.getConfiguration('editor').update('preferTreeSitter', ["typescript"], ConfigurationTarget.Global);
});
suiteTeardown(async function () {
await workspace.getConfiguration('editor').update('experimental.preferTreeSitter', originalSettingValue, ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter', originalSettingValue, ConfigurationTarget.Global);
});

for (const fixture of fs.readdirSync(fixturesPath)) {
Expand Down
24 changes: 12 additions & 12 deletions extensions/vscode-colorize-tests/src/colorizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ suite('colorization', () => {

suiteSetup(async function () {
originalSettingValues = [
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.typescript'),
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.ini'),
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.regex'),
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.css')
workspace.getConfiguration('editor').get('preferTreeSitter.typescript'),
workspace.getConfiguration('editor').get('preferTreeSitter.ini'),
workspace.getConfiguration('editor').get('preferTreeSitter.regex'),
workspace.getConfiguration('editor').get('preferTreeSitter.css')
];
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.typescript', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.css', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.typescript', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.ini', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.regex', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.css', true, ConfigurationTarget.Global);
});
suiteTeardown(async function () {
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.typescript', originalSettingValues[0], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', originalSettingValues[1], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', originalSettingValues[2], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.css', originalSettingValues[3], ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.typescript', originalSettingValues[0], ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.ini', originalSettingValues[1], ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.regex', originalSettingValues[2], ConfigurationTarget.Global);
await workspace.getConfiguration('editor').update('preferTreeSitter.css', originalSettingValues[3], ConfigurationTarget.Global);
});

for (const fixture of fs.readdirSync(fixturesPath)) {
Expand Down
41 changes: 41 additions & 0 deletions src/vs/editor/browser/config/migrateOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,47 @@ registerEditorSettingMigration('highlightActiveIndentGuide', (value, read, write
}
});

registerEditorSettingMigration('experimental.treeSitterTelemetry', (value, read, write) => {
if (typeof value !== 'undefined') {
write('experimental.treeSitterTelemetry', undefined);
if (typeof read('treeSitterTelemetry') === 'undefined') {
write('treeSitterTelemetry', value);
}
}
});
registerEditorSettingMigration('experimental.preferTreeSitter.css', (value, read, write) => {
if (typeof value !== 'undefined') {
write('experimental.preferTreeSitter.css', undefined);
if (typeof read('preferTreeSitter.css') === 'undefined') {
write('preferTreeSitter.css', value);
}
}
});
registerEditorSettingMigration('experimental.preferTreeSitter.typescript', (value, read, write) => {
if (typeof value !== 'undefined') {
write('experimental.preferTreeSitter.typescript', undefined);
if (typeof read('preferTreeSitter.typescript') === 'undefined') {
write('preferTreeSitter.typescript', value);
}
}
});
registerEditorSettingMigration('experimental.preferTreeSitter.ini', (value, read, write) => {
if (typeof value !== 'undefined') {
write('experimental.preferTreeSitter.ini', undefined);
if (typeof read('preferTreeSitter.ini') === 'undefined') {
write('preferTreeSitter.ini', value);
}
}
});
registerEditorSettingMigration('experimental.preferTreeSitter.regex', (value, read, write) => {
if (typeof value !== 'undefined') {
write('experimental.preferTreeSitter.regex', undefined);
if (typeof read('preferTreeSitter.regex') === 'undefined') {
write('preferTreeSitter.regex', value);
}
}
});

const suggestFilteredTypesMapping: Record<string, string> = {
method: 'showMethods',
function: 'showFunctions',
Expand Down
20 changes: 10 additions & 10 deletions src/vs/editor/common/config/editorConfigurationSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,34 @@ const editorConfiguration: IConfigurationNode = {
description: nls.localize('editor.experimental.asyncTokenizationVerification', "Controls whether async tokenization should be verified against legacy background tokenization. Might slow down tokenization. For debugging only."),
tags: ['experimental'],
},
'editor.experimental.treeSitterTelemetry': {
'editor.treeSitterTelemetry': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.treeSitterTelemetry', "Controls whether tree sitter parsing should be turned on and telemetry collected. Setting `editor.experimental.preferTreeSitter` for specific languages will take precedence."),
markdownDescription: nls.localize('editor.experimental.treeSitterTelemetry', "Controls whether tree sitter parsing should be turned on and telemetry collected. Setting `editor.preferTreeSitter` for specific languages will take precedence."),
tags: ['experimental', 'onExP']
},
'editor.experimental.preferTreeSitter.css': {
'editor.preferTreeSitter.css': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.css', "Controls whether tree sitter parsing should be turned on for css. This will take precedence over `editor.experimental.treeSitterTelemetry` for css."),
markdownDescription: nls.localize('editor.preferTreeSitter.css', "Controls whether tree sitter parsing should be turned on for css. This will take precedence over `editor.preferTreeSitter` for css."),
tags: ['experimental', 'onExP']
},
'editor.experimental.preferTreeSitter.typescript': {
'editor.preferTreeSitter.typescript': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.typescript', "Controls whether tree sitter parsing should be turned on for typescript. This will take precedence over `editor.experimental.treeSitterTelemetry` for typescript."),
markdownDescription: nls.localize('editor.preferTreeSitter.typescript', "Controls whether tree sitter parsing should be turned on for typescript. This will take precedence over `editor.preferTreeSitter` for typescript."),
tags: ['experimental', 'onExP']
},
'editor.experimental.preferTreeSitter.ini': {
'editor.preferTreeSitter.ini': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.ini', "Controls whether tree sitter parsing should be turned on for ini. This will take precedence over `editor.experimental.treeSitterTelemetry` for ini."),
markdownDescription: nls.localize('editor.preferTreeSitter.ini', "Controls whether tree sitter parsing should be turned on for ini. This will take precedence over `editor.preferTreeSitter` for ini."),
tags: ['experimental', 'onExP']
},
'editor.experimental.preferTreeSitter.regex': {
'editor.preferTreeSitter.regex': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.regex', "Controls whether tree sitter parsing should be turned on for regex. This will take precedence over `editor.experimental.treeSitterTelemetry` for regex."),
markdownDescription: nls.localize('editor.preferTreeSitter.regex', "Controls whether tree sitter parsing should be turned on for regex. This will take precedence over `editor.preferTreeSitter` for regex."),
tags: ['experimental', 'onExP']
},
'editor.language.brackets': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import type * as Parser from '@vscode/tree-sitter-wasm';
import { AppResourcePath, FileAccess } from '../../../../base/common/network.js';
import { EDITOR_EXPERIMENTAL_PREFER_TREESITTER, ITreeSitterParserService, ITextModelTreeSitter, TreeUpdateEvent, ITreeSitterImporter, TREESITTER_ALLOWED_SUPPORT, ModelTreeUpdateEvent } from '../treeSitterParserService.js';
import { EDITOR_PREFER_TREESITTER, ITreeSitterParserService, ITextModelTreeSitter, TreeUpdateEvent, ITreeSitterImporter, TREESITTER_ALLOWED_SUPPORT, ModelTreeUpdateEvent } from '../treeSitterParserService.js';
import { IModelService } from '../model.js';
import { Disposable, DisposableMap, DisposableStore } from '../../../../base/common/lifecycle.js';
import { ITextModel } from '../../model.js';
Expand Down Expand Up @@ -44,7 +44,7 @@ export class TreeSitterTextModelService extends Disposable implements ITreeSitte
this._treeSitterLanguages = this._register(new TreeSitterLanguages(this._treeSitterImporter, fileService, this._environmentService, this._registeredLanguages));
this.onDidAddLanguage = this._treeSitterLanguages.onDidAddLanguage;
this._register(this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(EDITOR_EXPERIMENTAL_PREFER_TREESITTER)) {
if (e.affectsConfiguration(EDITOR_PREFER_TREESITTER)) {
this._supportedLanguagesChanged();
}
}));
Expand Down Expand Up @@ -146,7 +146,7 @@ export class TreeSitterTextModelService extends Disposable implements ITreeSitte
}

private _getSetting(languageId: string): boolean {
const setting = this._configurationService.getValue<boolean>(`${EDITOR_EXPERIMENTAL_PREFER_TREESITTER}.${languageId}`);
const setting = this._configurationService.getValue<boolean>(`${EDITOR_PREFER_TREESITTER}.${languageId}`);
if (!setting && TREESITTER_ALLOWED_SUPPORT.includes(languageId)) {
return this._configurationService.getValue<boolean>(EDITOR_TREESITTER_TELEMETRY);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/services/treeSitterParserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Range } from '../core/range.js';
import { importAMDNodeModule } from '../../../amdX.js';
import { IModelContentChangedEvent } from '../textModelEvents.js';

export const EDITOR_EXPERIMENTAL_PREFER_TREESITTER = 'editor.experimental.preferTreeSitter';
export const EDITOR_PREFER_TREESITTER = 'editor.preferTreeSitter';
export const TREESITTER_ALLOWED_SUPPORT = ['css', 'typescript', 'ini', 'regex'];

export const ITreeSitterParserService = createDecorator<ITreeSitterParserService>('treeSitterParserService');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Disposable, DisposableMap, DisposableStore, IDisposable } from '../../.
import { AppResourcePath, FileAccess } from '../../../../base/common/network.js';
import { ILanguageIdCodec, ITreeSitterTokenizationSupport, LazyTokenizationSupport, QueryCapture, TreeSitterTokenizationRegistry } from '../../../../editor/common/languages.js';
import { ITextModel } from '../../../../editor/common/model.js';
import { EDITOR_EXPERIMENTAL_PREFER_TREESITTER, ITreeSitterParserService, RangeChange, ITreeSitterImporter, TREESITTER_ALLOWED_SUPPORT, RangeWithOffsets, ITextModelTreeSitter } from '../../../../editor/common/services/treeSitterParserService.js';
import { EDITOR_PREFER_TREESITTER, ITreeSitterParserService, RangeChange, ITreeSitterImporter, TREESITTER_ALLOWED_SUPPORT, RangeWithOffsets, ITextModelTreeSitter } from '../../../../editor/common/services/treeSitterParserService.js';
import { IModelTokensChangedEvent } from '../../../../editor/common/textModelEvents.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IFileService } from '../../../../platform/files/common/files.js';
Expand Down Expand Up @@ -76,14 +76,14 @@ export class TreeSitterTokenizationFeature extends Disposable implements ITreeSi

this._handleGrammarsExtPoint();
this._register(this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(EDITOR_EXPERIMENTAL_PREFER_TREESITTER)) {
if (e.affectsConfiguration(EDITOR_PREFER_TREESITTER)) {
this._handleGrammarsExtPoint();
}
}));
}

private _getSetting(languageId: string): boolean {
return this._configurationService.getValue<boolean>(`${EDITOR_EXPERIMENTAL_PREFER_TREESITTER}.${languageId}`);
return this._configurationService.getValue<boolean>(`${EDITOR_PREFER_TREESITTER}.${languageId}`);
}

private _handleGrammarsExtPoint(): void {
Expand Down
Loading