diff --git a/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts b/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts index e55e06318d832..a38928849c57e 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts @@ -22,7 +22,8 @@ import { INotificationService } from 'vs/platform/notification/common/notificati import { editorHoverBackground, editorHoverBorder } from 'vs/platform/theme/common/colorRegistry'; import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { findMatchingThemeRule } from 'vs/workbench/services/textMate/common/TMHelper'; -import { ITextMateService, IGrammar, IToken, StackElement } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; +import { IGrammar, IToken, StackElement } from 'vscode-textmate'; import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { ColorThemeData, TokenStyleDefinitions, TokenStyleDefinition, TextMateThemingRuleDefinitions } from 'vs/workbench/services/themes/common/colorThemeData'; diff --git a/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts b/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts index c921dbd622f70..2ebad19d2a05c 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.ts @@ -14,7 +14,7 @@ import { ILanguageService } from 'vs/editor/common/services/language'; import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; -import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages'; import { IExtensionResourceLoaderService } from 'vs/workbench/services/extensionResourceLoader/common/extensionResourceLoader'; diff --git a/src/vs/workbench/contrib/codeEditor/electron-sandbox/startDebugTextMate.ts b/src/vs/workbench/contrib/codeEditor/electron-sandbox/startDebugTextMate.ts index 6f58565f8caa0..9b02f563905e6 100644 --- a/src/vs/workbench/contrib/codeEditor/electron-sandbox/startDebugTextMate.ts +++ b/src/vs/workbench/contrib/codeEditor/electron-sandbox/startDebugTextMate.ts @@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; import { Range } from 'vs/editor/common/core/range'; import { Action2, registerAction2 } from 'vs/platform/actions/common/actions'; import { CATEGORIES } from 'vs/workbench/common/actions'; -import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; import { IModelService } from 'vs/editor/common/services/model'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { URI } from 'vs/base/common/uri'; diff --git a/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts index b5e78b501ed94..96fc80d817c10 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.test.contribution.ts @@ -10,7 +10,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati import { IWorkbenchThemeService, IWorkbenchColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { EditorResourceAccessor } from 'vs/workbench/common/editor'; -import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; import { IGrammar, StackElement } from 'vscode-textmate'; import { TokenizationRegistry, TokenMetadata } from 'vs/editor/common/modes'; import { ThemeRule, findMatchingThemeRule } from 'vs/workbench/services/textMate/common/TMHelper'; diff --git a/src/vs/workbench/services/textMate/browser/abstractTextMateService.ts b/src/vs/workbench/services/textMate/browser/abstractTextMateService.ts index 1ca5c573582a6..a01933360ac61 100644 --- a/src/vs/workbench/services/textMate/browser/abstractTextMateService.ts +++ b/src/vs/workbench/services/textMate/browser/abstractTextMateService.ts @@ -21,7 +21,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { ExtensionMessageCollector } from 'vs/workbench/services/extensions/common/extensionsRegistry'; import { ITMSyntaxExtensionPoint, grammarsExtPoint } from 'vs/workbench/services/textMate/common/TMGrammars'; -import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; import { ITextMateThemingRule, IWorkbenchThemeService, IWorkbenchColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import type { IGrammar, StackElement, IOnigLib, IRawTheme } from 'vscode-textmate'; import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle'; diff --git a/src/vs/workbench/services/textMate/browser/textMateService.ts b/src/vs/workbench/services/textMate/browser/browserTextMateService.ts similarity index 97% rename from src/vs/workbench/services/textMate/browser/textMateService.ts rename to src/vs/workbench/services/textMate/browser/browserTextMateService.ts index 3ad434b7de262..4bd0b7afd17e6 100644 --- a/src/vs/workbench/services/textMate/browser/textMateService.ts +++ b/src/vs/workbench/services/textMate/browser/browserTextMateService.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { AbstractTextMateService } from 'vs/workbench/services/textMate/browser/abstractTextMateService'; import { FileAccess } from 'vs/base/common/network'; diff --git a/src/vs/workbench/services/textMate/electron-sandbox/textMateService.ts b/src/vs/workbench/services/textMate/browser/nativeTextMateService.ts similarity index 97% rename from src/vs/workbench/services/textMate/electron-sandbox/textMateService.ts rename to src/vs/workbench/services/textMate/browser/nativeTextMateService.ts index 81bdf8ff58ec9..53659b2e2a58e 100644 --- a/src/vs/workbench/services/textMate/electron-sandbox/textMateService.ts +++ b/src/vs/workbench/services/textMate/browser/nativeTextMateService.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService'; +import { ITextMateService } from 'vs/workbench/services/textMate/browser/textMate'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { AbstractTextMateService } from 'vs/workbench/services/textMate/browser/abstractTextMateService'; import { ILanguageService } from 'vs/editor/common/services/language'; @@ -15,7 +15,7 @@ import { createWebWorker, MonacoWebWorker } from 'vs/editor/common/services/webW import { IModelService } from 'vs/editor/common/services/model'; import type { IRawTheme } from 'vscode-textmate'; import { IValidGrammarDefinition } from 'vs/workbench/services/textMate/common/TMScopeRegistry'; -import { TextMateWorker } from 'vs/workbench/services/textMate/electron-sandbox/textMateWorker'; +import { TextMateWorker } from 'vs/workbench/services/textMate/browser/textMateWorker'; import { ITextModel } from 'vs/editor/common/model'; import { Disposable } from 'vs/base/common/lifecycle'; import { UriComponents, URI } from 'vs/base/common/uri'; @@ -207,7 +207,7 @@ export class TextMateService extends AbstractTextMateService { grammarDefinitions }, label: 'textMateWorker', - moduleId: 'vs/workbench/services/textMate/electron-browser/textMateWorker', + moduleId: 'vs/workbench/services/textMate/browser/textMateWorker', host: workerHost }); diff --git a/src/vs/workbench/services/textMate/browser/textMate.ts b/src/vs/workbench/services/textMate/browser/textMate.ts new file mode 100644 index 0000000000000..41963c90199af --- /dev/null +++ b/src/vs/workbench/services/textMate/browser/textMate.ts @@ -0,0 +1,20 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { Event } from 'vs/base/common/event'; +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; +import { IGrammar } from 'vscode-textmate'; + +export const ITextMateService = createDecorator('textMateService'); + +export interface ITextMateService { + readonly _serviceBrand: undefined; + + onDidEncounterLanguage: Event; + + createGrammar(languageId: string): Promise; + + startDebugMode(printFn: (str: string) => void, onStop: () => void): void; +} diff --git a/src/vs/workbench/services/textMate/electron-sandbox/textMateWorker.ts b/src/vs/workbench/services/textMate/browser/textMateWorker.ts similarity index 99% rename from src/vs/workbench/services/textMate/electron-sandbox/textMateWorker.ts rename to src/vs/workbench/services/textMate/browser/textMateWorker.ts index 73e149065e50d..aaef23b3768a0 100644 --- a/src/vs/workbench/services/textMate/electron-sandbox/textMateWorker.ts +++ b/src/vs/workbench/services/textMate/browser/textMateWorker.ts @@ -9,7 +9,7 @@ import { LanguageId } from 'vs/editor/common/modes'; import { IValidEmbeddedLanguagesMap, IValidTokenTypeMap, IValidGrammarDefinition } from 'vs/workbench/services/textMate/common/TMScopeRegistry'; import { TMGrammarFactory, ICreateGrammarResult } from 'vs/workbench/services/textMate/common/TMGrammarFactory'; import { IModelChangedEvent, MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel'; -import { TextMateWorkerHost } from 'vs/workbench/services/textMate/electron-sandbox/textMateService'; +import { TextMateWorkerHost } from 'vs/workbench/services/textMate/browser/nativeTextMateService'; import { TokenizationStateStore } from 'vs/editor/common/model/textModelTokens'; import type { IGrammar, StackElement, IRawTheme, IOnigLib } from 'vscode-textmate'; import { MultilineTokensBuilder, countEOL } from 'vs/editor/common/model/tokensStore'; diff --git a/src/vs/workbench/services/textMate/common/textMateService.ts b/src/vs/workbench/services/textMate/common/textMateService.ts deleted file mode 100644 index eda77328d07e2..0000000000000 --- a/src/vs/workbench/services/textMate/common/textMateService.ts +++ /dev/null @@ -1,85 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { Event } from 'vs/base/common/event'; -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; - -export const ITextMateService = createDecorator('textMateService'); - -export interface ITextMateService { - readonly _serviceBrand: undefined; - - onDidEncounterLanguage: Event; - - createGrammar(languageId: string): Promise; - - startDebugMode(printFn: (str: string) => void, onStop: () => void): void; -} - -// -------------- Types copied from vscode-textmate due to usage in /common/ - -/** - * A grammar - */ -export interface IGrammar { - /** - * Tokenize `lineText` using previous line state `prevState`. - */ - tokenizeLine(lineText: string, prevState: StackElement | null, timeLimit?: number): ITokenizeLineResult; - /** - * Tokenize `lineText` using previous line state `prevState`. - * The result contains the tokens in binary format, resolved with the following information: - * - language - * - token type (regex, string, comment, other) - * - font style - * - foreground color - * - background color - * e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET` - */ - tokenizeLine2(lineText: string, prevState: StackElement | null, timeLimit?: number): ITokenizeLineResult2; -} -export interface ITokenizeLineResult { - readonly tokens: IToken[]; - /** - * The `prevState` to be passed on to the next line tokenization. - */ - readonly ruleStack: StackElement; - /** - * Did tokenization stop early due to reaching the time limit. - */ - readonly stoppedEarly: boolean; -} -export interface ITokenizeLineResult2 { - /** - * The tokens in binary format. Each token occupies two array indices. For token i: - * - at offset 2*i => startIndex - * - at offset 2*i + 1 => metadata - * - */ - readonly tokens: Uint32Array; - /** - * The `prevState` to be passed on to the next line tokenization. - */ - readonly ruleStack: StackElement; - /** - * Did tokenization stop early due to reaching the time limit. - */ - readonly stoppedEarly: boolean; -} -export interface IToken { - startIndex: number; - readonly endIndex: number; - readonly scopes: string[]; -} -/** - * **IMPORTANT** - Immutable! - */ -export interface StackElement { - _stackElementBrand: void; - readonly depth: number; - clone(): StackElement; - equals(other: StackElement): boolean; -} -// -------------- End Types "liberated" from vscode-textmate due to usage in /common/ diff --git a/src/vs/workbench/workbench.sandbox.main.ts b/src/vs/workbench/workbench.sandbox.main.ts index 6b6d486faa29c..e9aabd04631f8 100644 --- a/src/vs/workbench/workbench.sandbox.main.ts +++ b/src/vs/workbench/workbench.sandbox.main.ts @@ -36,7 +36,7 @@ import 'vs/workbench/electron-sandbox/parts/dialogs/dialog.contribution'; import 'vs/workbench/services/textfile/electron-sandbox/nativeTextFileService'; import 'vs/workbench/services/dialogs/electron-sandbox/fileDialogService'; import 'vs/workbench/services/workspaces/electron-sandbox/workspacesService'; -import 'vs/workbench/services/textMate/electron-sandbox/textMateService'; +import 'vs/workbench/services/textMate/browser/nativeTextMateService'; import 'vs/workbench/services/menubar/electron-sandbox/menubarService'; import 'vs/workbench/services/issue/electron-sandbox/issueService'; import 'vs/workbench/services/update/electron-sandbox/updateService'; diff --git a/src/vs/workbench/workbench.web.main.ts b/src/vs/workbench/workbench.web.main.ts index 01b558c16b31e..a83ccb4d62a90 100644 --- a/src/vs/workbench/workbench.web.main.ts +++ b/src/vs/workbench/workbench.web.main.ts @@ -35,7 +35,7 @@ import 'vs/workbench/browser/web.main'; //#region --- workbench services import 'vs/workbench/services/integrity/browser/integrityService'; -import 'vs/workbench/services/textMate/browser/textMateService'; +import 'vs/workbench/services/textMate/browser/browserTextMateService'; import 'vs/workbench/services/search/browser/searchService'; import 'vs/workbench/services/textfile/browser/browserTextFileService'; import 'vs/workbench/services/keybinding/browser/keyboardLayoutService';