From c8f9a680000a8fbb21551deeccc38d06b2065cf8 Mon Sep 17 00:00:00 2001 From: sanmaopep Date: Thu, 28 Aug 2025 11:29:46 +0800 Subject: [PATCH 1/5] fix(editor): remote ts dependency --- ...t-remove-ts-dependency_2025-08-28-03-30.json | 11 +++++++++++ .../code-language-typescript/src/service.ts | 4 +--- .../code-language-typescript/src/utils.ts | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-03-30.json diff --git a/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-03-30.json b/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-03-30.json new file mode 100644 index 00000000..302f7fe7 --- /dev/null +++ b/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-03-30.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@coze-editor/code-language-typescript", + "comment": "remote ts dependency", + "type": "patch" + } + ], + "packageName": "@coze-editor/code-language-typescript", + "email": "maoyiwei.ebay@bytedance.com" +} diff --git a/packages/text-editor/code-language-typescript/src/service.ts b/packages/text-editor/code-language-typescript/src/service.ts index 643b2914..38da72d7 100644 --- a/packages/text-editor/code-language-typescript/src/service.ts +++ b/packages/text-editor/code-language-typescript/src/service.ts @@ -11,8 +11,6 @@ import { } from 'vscode-languageserver-types'; import { type CompletionEntryDetails, - DiagnosticCategory, - displayPartsToString, type FormatCodeSettings, } from 'typescript'; import mitt from 'mitt'; @@ -29,7 +27,7 @@ import type { TransactionSpec, } from '@codemirror/state'; -import { tagToString } from './utils'; +import { DiagnosticCategory, displayPartsToString, tagToString } from './utils'; import type { InitializeOptions, ITypeScriptWorker } from './types'; import { asCompletionItemKind } from './as'; diff --git a/packages/text-editor/code-language-typescript/src/utils.ts b/packages/text-editor/code-language-typescript/src/utils.ts index e026ee58..996d2b90 100644 --- a/packages/text-editor/code-language-typescript/src/utils.ts +++ b/packages/text-editor/code-language-typescript/src/utils.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT import type ts from 'typescript'; +import { type SymbolDisplayPart } from 'typescript'; function tagToString(tag: ts.JSDocTagInfo): string { let tagLabel = `*@${tag.name}*`; @@ -19,4 +20,18 @@ function tagToString(tag: ts.JSDocTagInfo): string { return tagLabel; } -export { tagToString }; +function displayPartsToString(displayParts?: SymbolDisplayPart[]) { + if (displayParts) { + return displayParts.map(displayPart2 => displayPart2.text).join(''); + } + return ''; +} + +enum DiagnosticCategory { + Warning = 0, + Error = 1, + Suggestion = 2, + Message = 3, +} + +export { tagToString, displayPartsToString, DiagnosticCategory }; From e0f5f8fa8a1daaf5e7c287fae0935f18ab45b89d Mon Sep 17 00:00:00 2001 From: sanmaopep Date: Thu, 28 Aug 2025 11:54:46 +0800 Subject: [PATCH 2/5] feat: preset code --- ...remove-ts-dependency_2025-08-28-03-54.json | 11 ++++++++ .../config/subspaces/default/pnpm-lock.yaml | 28 +++++++++++++++++++ packages/text-editor/preset-code/package.json | 2 ++ .../preset-code/src/highlighter.ts | 23 ++++++++++++--- 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 common/changes/@coze-editor/preset-code/feat-remove-ts-dependency_2025-08-28-03-54.json diff --git a/common/changes/@coze-editor/preset-code/feat-remove-ts-dependency_2025-08-28-03-54.json b/common/changes/@coze-editor/preset-code/feat-remove-ts-dependency_2025-08-28-03-54.json new file mode 100644 index 00000000..71d95976 --- /dev/null +++ b/common/changes/@coze-editor/preset-code/feat-remove-ts-dependency_2025-08-28-03-54.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@coze-editor/preset-code", + "comment": "preset code", + "type": "minor" + } + ], + "packageName": "@coze-editor/preset-code", + "email": "maoyiwei.ebay@bytedance.com" +} diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index 8227a587..a9c7df73 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -2266,6 +2266,12 @@ importers: '@nozbe/microfuzz': specifier: ^1.0.0 version: 1.0.0 + '@shikijs/langs': + specifier: ~3.12.0 + version: 3.12.0 + '@shikijs/themes': + specifier: ~3.12.0 + version: 3.12.0 codemirror-shiki: specifier: ^0.2.2 version: 0.2.2(@codemirror/state@6.5.2)(@codemirror/view@6.37.1)(shiki@3.6.0) @@ -7406,12 +7412,21 @@ packages: '@shikijs/engine-oniguruma@3.6.0': resolution: {integrity: sha512-nmOhIZ9yT3Grd+2plmW/d8+vZ2pcQmo/UnVwXMUXAKTXdi+LK0S08Ancrz5tQQPkxvjBalpMW2aKvwXfelauvA==} + '@shikijs/langs@3.12.0': + resolution: {integrity: sha512-HIca0daEySJ8zuy9bdrtcBPhcYBo8wR1dyHk1vKrOuwDsITtZuQeGhEkcEfWc6IDyTcom7LRFCH6P7ljGSCEiQ==} + '@shikijs/langs@3.6.0': resolution: {integrity: sha512-IdZkQJaLBu1LCYCwkr30hNuSDfllOT8RWYVZK1tD2J03DkiagYKRxj/pDSl8Didml3xxuyzUjgtioInwEQM/TA==} + '@shikijs/themes@3.12.0': + resolution: {integrity: sha512-/lxvQxSI5s4qZLV/AuFaA4Wt61t/0Oka/P9Lmpr1UV+HydNCczO3DMHOC/CsXCCpbv4Zq8sMD0cDa7mvaVoj0Q==} + '@shikijs/themes@3.6.0': resolution: {integrity: sha512-Fq2j4nWr1DF4drvmhqKq8x5vVQ27VncF8XZMBuHuQMZvUSS3NBgpqfwz/FoGe36+W6PvniZ1yDlg2d4kmYDU6w==} + '@shikijs/types@3.12.0': + resolution: {integrity: sha512-jsFzm8hCeTINC3OCmTZdhR9DOl/foJWplH2Px0bTi4m8z59fnsueLsweX82oGcjRQ7mfQAluQYKGoH2VzsWY4A==} + '@shikijs/types@3.6.0': resolution: {integrity: sha512-cLWFiToxYu0aAzJqhXTQsFiJRTFDAGl93IrMSBNaGSzs7ixkLfdG6pH11HipuWFGW5vyx4X47W8HDQ7eSrmBUg==} @@ -22320,14 +22335,27 @@ snapshots: '@shikijs/types': 3.6.0 '@shikijs/vscode-textmate': 10.0.2 + '@shikijs/langs@3.12.0': + dependencies: + '@shikijs/types': 3.12.0 + '@shikijs/langs@3.6.0': dependencies: '@shikijs/types': 3.6.0 + '@shikijs/themes@3.12.0': + dependencies: + '@shikijs/types': 3.12.0 + '@shikijs/themes@3.6.0': dependencies: '@shikijs/types': 3.6.0 + '@shikijs/types@3.12.0': + dependencies: + '@shikijs/vscode-textmate': 10.0.2 + '@types/hast': 3.0.4 + '@shikijs/types@3.6.0': dependencies: '@shikijs/vscode-textmate': 10.0.2 diff --git a/packages/text-editor/preset-code/package.json b/packages/text-editor/preset-code/package.json index 6b605e52..67bf48b7 100644 --- a/packages/text-editor/preset-code/package.json +++ b/packages/text-editor/preset-code/package.json @@ -36,6 +36,8 @@ "@coze-editor/vscode": "workspace:*", "@lezer/highlight": "~1.2.0", "@nozbe/microfuzz": "^1.0.0", + "@shikijs/langs": "~3.12.0", + "@shikijs/themes": "~3.12.0", "codemirror-shiki": "^0.2.2", "marked": "^15.0.7", "marked-shiki": "^1.2.0", diff --git a/packages/text-editor/preset-code/src/highlighter.ts b/packages/text-editor/preset-code/src/highlighter.ts index 818ad25b..31435072 100644 --- a/packages/text-editor/preset-code/src/highlighter.ts +++ b/packages/text-editor/preset-code/src/highlighter.ts @@ -1,11 +1,26 @@ // Copyright (c) 2025 coze-dev // SPDX-License-Identifier: MIT -import { createHighlighter } from 'shiki'; +import { createOnigurumaEngine } from 'shiki/engine/oniguruma'; +import { createHighlighterCore } from 'shiki/core'; -const highlighterPromise = createHighlighter({ - langs: ['md', 'js', 'ts', 'python'], - themes: ['github-dark', 'one-dark-pro'], +// const highlighterPromise = createHighlighter({ +// langs: ['md', 'js', 'ts', 'python'], +// themes: ['github-dark', 'one-dark-pro'], +// }); + +const highlighterPromise = createHighlighterCore({ + langs: [ + () => import('@shikijs/langs/markdown'), + () => import('@shikijs/langs/javascript'), + () => import('@shikijs/langs/typescript'), + () => import('@shikijs/langs/python'), + ], + themes: [ + () => import('@shikijs/themes/github-dark'), + () => import('@shikijs/themes/one-dark-pro'), + ], + engine: createOnigurumaEngine(import('shiki/wasm')), }); export { highlighterPromise }; From 2c7ad54b56e222976c5a0fcef9aeb6f009b72ff5 Mon Sep 17 00:00:00 2001 From: sanmaopep Date: Thu, 28 Aug 2025 13:31:22 +0800 Subject: [PATCH 3/5] feat: remove ts dependencies --- ...remove-ts-dependency_2025-08-28-05-31.json | 11 +++ .../code-language-typescript/src/as.ts | 90 ++++++++++++++++++- 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-31.json diff --git a/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-31.json b/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-31.json new file mode 100644 index 00000000..1a14adcd --- /dev/null +++ b/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-31.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@coze-editor/code-language-typescript", + "comment": "remove ts dependencies", + "type": "minor" + } + ], + "packageName": "@coze-editor/code-language-typescript", + "email": "maoyiwei.ebay@bytedance.com" +} diff --git a/packages/text-editor/code-language-typescript/src/as.ts b/packages/text-editor/code-language-typescript/src/as.ts index 766370a9..09e77970 100644 --- a/packages/text-editor/code-language-typescript/src/as.ts +++ b/packages/text-editor/code-language-typescript/src/as.ts @@ -2,7 +2,95 @@ // SPDX-License-Identifier: MIT import { CompletionItemKind } from 'vscode-languageserver-types'; -import { ScriptElementKind } from 'typescript'; + +/** + * Copied from TypeScript 5.8.2 + */ +enum ScriptElementKind { + unknown = '', + warning = 'warning', + /** predefined type (void) or keyword (class) */ + keyword = 'keyword', + /** top level script node */ + scriptElement = 'script', + /** module foo {} */ + moduleElement = 'module', + /** class X {} */ + classElement = 'class', + /** var x = class X {} */ + localClassElement = 'local class', + /** interface Y {} */ + interfaceElement = 'interface', + /** type T = ... */ + typeElement = 'type', + /** enum E */ + enumElement = 'enum', + enumMemberElement = 'enum member', + /** + * Inside module and script only + * const v = .. + */ + variableElement = 'var', + /** Inside function */ + localVariableElement = 'local var', + /** using foo = ... */ + variableUsingElement = 'using', + /** await using foo = ... */ + variableAwaitUsingElement = 'await using', + /** + * Inside module and script only + * function f() { } + */ + functionElement = 'function', + /** Inside function */ + localFunctionElement = 'local function', + /** class X { [public|private]* foo() {} } */ + memberFunctionElement = 'method', + /** class X { [public|private]* [get|set] foo:number; } */ + memberGetAccessorElement = 'getter', + memberSetAccessorElement = 'setter', + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ + memberVariableElement = 'property', + /** class X { [public|private]* accessor foo: number; } */ + memberAccessorVariableElement = 'accessor', + /** + * class X { constructor() { } } + * class X { static { } } + */ + constructorImplementationElement = 'constructor', + /** interface Y { ():number; } */ + callSignatureElement = 'call', + /** interface Y { []:number; } */ + indexSignatureElement = 'index', + /** interface Y { new():Y; } */ + constructSignatureElement = 'construct', + /** function foo(*Y*: string) */ + parameterElement = 'parameter', + typeParameterElement = 'type parameter', + primitiveType = 'primitive type', + label = 'label', + alias = 'alias', + constElement = 'const', + letElement = 'let', + directory = 'directory', + externalModuleName = 'external module name', + /** + * + * @deprecated + */ + jsxAttribute = 'JSX attribute', + /** String literal */ + string = 'string', + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = 'link', + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = 'link name', + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = 'link text', +} /* * Copyright (C) 2018 TypeFox and others. From 7a652eccba4b279ab9ba1c15f0584359d3894f7b Mon Sep 17 00:00:00 2001 From: sanmaopep Date: Thu, 28 Aug 2025 13:32:04 +0800 Subject: [PATCH 4/5] feat: add vite bundle analyse --- common/config/subspaces/default/pnpm-lock.yaml | 9 +++++++++ packages/text-editor/dev/package.json | 3 ++- packages/text-editor/dev/src/index.tsx | 6 ++---- packages/text-editor/dev/vite.config.ts | 13 +++++++------ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index a9c7df73..5212818e 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -1568,6 +1568,9 @@ importers: vite: specifier: ^6.3.5 version: 6.3.5(@types/node@22.13.13)(jiti@2.4.2)(less@4.3.0)(sass-embedded@1.89.2)(sass@1.89.0)(sugarss@2.0.0)(terser@5.39.2)(tsx@4.19.3)(yaml@2.8.0) + vite-bundle-analyzer: + specifier: ~1.2.1 + version: 1.2.1 ../../../packages/text-editor/editor: dependencies: @@ -16894,6 +16897,10 @@ packages: victory-vendor@36.9.2: resolution: {integrity: sha512-PnpQQMuxlwYdocC8fIJqVXvkeViHYzotI+NJrCuav0ZYFoq912ZHBk3mCeuj+5/VpodOjPe1z0Fk2ihgzlXqjQ==} + vite-bundle-analyzer@1.2.1: + resolution: {integrity: sha512-dpJMQBnVjieMirpHILmgGsZAWU8fGyqK3ckj6O48wdy3fARlH7Mnz7BfYFUsd3ZdbuXjsYe7t5I/q2zsMOd5ig==} + hasBin: true + vite-node@3.0.9: resolution: {integrity: sha512-w3Gdx7jDcuT9cNn9jExXgOyKmf5UOTb6WMHz8LGAm54eS1Elf5OuBhCxl6zJxGhEeIkgsE1WbHuoL0mj/UXqXg==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} @@ -34381,6 +34388,8 @@ snapshots: d3-time: 3.1.0 d3-timer: 3.0.1 + vite-bundle-analyzer@1.2.1: {} + vite-node@3.0.9(@types/node@22.13.13)(jiti@2.4.2)(less@4.3.0)(sass-embedded@1.89.2)(sass@1.89.0)(sugarss@2.0.0)(terser@5.39.2)(tsx@4.19.3)(yaml@2.8.0): dependencies: cac: 6.7.14 diff --git a/packages/text-editor/dev/package.json b/packages/text-editor/dev/package.json index 9f0353e3..7ef8fd0d 100644 --- a/packages/text-editor/dev/package.json +++ b/packages/text-editor/dev/package.json @@ -51,6 +51,7 @@ "tailwindcss": "~3.3.3", "typescript": "^5.8.2", "typescript-eslint": "^8.30.1", - "vite": "^6.3.5" + "vite": "^6.3.5", + "vite-bundle-analyzer": "~1.2.1" } } diff --git a/packages/text-editor/dev/src/index.tsx b/packages/text-editor/dev/src/index.tsx index 0a27dddb..040c255c 100644 --- a/packages/text-editor/dev/src/index.tsx +++ b/packages/text-editor/dev/src/index.tsx @@ -1,7 +1,5 @@ import { createRoot } from 'react-dom/client'; -import Page from './pages/prompt'; +import Page from './pages/code'; import './index.css'; -createRoot(document.getElementById('app')!).render( - -) +createRoot(document.getElementById('app')!).render(); diff --git a/packages/text-editor/dev/vite.config.ts b/packages/text-editor/dev/vite.config.ts index 4a54356e..fc47616c 100644 --- a/packages/text-editor/dev/vite.config.ts +++ b/packages/text-editor/dev/vite.config.ts @@ -1,18 +1,19 @@ -import path from 'node:path' -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' +import path from 'node:path'; +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; +import { analyzer } from 'vite-bundle-analyzer'; // https://vite.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [react(), analyzer()], server: { fs: { strict: false, - } + }, }, resolve: { alias: { '@': path.resolve(__dirname, './src'), }, }, -}) +}); From a020e15ec00a4aed714c94376c09e380ea6883cd Mon Sep 17 00:00:00 2001 From: sanmaopep Date: Thu, 28 Aug 2025 13:37:32 +0800 Subject: [PATCH 5/5] feat: ts license --- ...remove-ts-dependency_2025-08-28-05-37.json | 11 ++ .../code-language-typescript/src/as.ts | 89 +-------------- .../code-language-typescript/src/service.ts | 3 +- .../code-language-typescript/src/ts-enums.ts | 107 ++++++++++++++++++ .../code-language-typescript/src/utils.ts | 9 +- 5 files changed, 122 insertions(+), 97 deletions(-) create mode 100644 common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-37.json create mode 100644 packages/text-editor/code-language-typescript/src/ts-enums.ts diff --git a/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-37.json b/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-37.json new file mode 100644 index 00000000..2a917db7 --- /dev/null +++ b/common/changes/@coze-editor/code-language-typescript/feat-remove-ts-dependency_2025-08-28-05-37.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@coze-editor/code-language-typescript", + "comment": "ts license", + "type": "minor" + } + ], + "packageName": "@coze-editor/code-language-typescript", + "email": "maoyiwei.ebay@bytedance.com" +} diff --git a/packages/text-editor/code-language-typescript/src/as.ts b/packages/text-editor/code-language-typescript/src/as.ts index 09e77970..eddede6b 100644 --- a/packages/text-editor/code-language-typescript/src/as.ts +++ b/packages/text-editor/code-language-typescript/src/as.ts @@ -3,94 +3,7 @@ import { CompletionItemKind } from 'vscode-languageserver-types'; -/** - * Copied from TypeScript 5.8.2 - */ -enum ScriptElementKind { - unknown = '', - warning = 'warning', - /** predefined type (void) or keyword (class) */ - keyword = 'keyword', - /** top level script node */ - scriptElement = 'script', - /** module foo {} */ - moduleElement = 'module', - /** class X {} */ - classElement = 'class', - /** var x = class X {} */ - localClassElement = 'local class', - /** interface Y {} */ - interfaceElement = 'interface', - /** type T = ... */ - typeElement = 'type', - /** enum E */ - enumElement = 'enum', - enumMemberElement = 'enum member', - /** - * Inside module and script only - * const v = .. - */ - variableElement = 'var', - /** Inside function */ - localVariableElement = 'local var', - /** using foo = ... */ - variableUsingElement = 'using', - /** await using foo = ... */ - variableAwaitUsingElement = 'await using', - /** - * Inside module and script only - * function f() { } - */ - functionElement = 'function', - /** Inside function */ - localFunctionElement = 'local function', - /** class X { [public|private]* foo() {} } */ - memberFunctionElement = 'method', - /** class X { [public|private]* [get|set] foo:number; } */ - memberGetAccessorElement = 'getter', - memberSetAccessorElement = 'setter', - /** - * class X { [public|private]* foo:number; } - * interface Y { foo:number; } - */ - memberVariableElement = 'property', - /** class X { [public|private]* accessor foo: number; } */ - memberAccessorVariableElement = 'accessor', - /** - * class X { constructor() { } } - * class X { static { } } - */ - constructorImplementationElement = 'constructor', - /** interface Y { ():number; } */ - callSignatureElement = 'call', - /** interface Y { []:number; } */ - indexSignatureElement = 'index', - /** interface Y { new():Y; } */ - constructSignatureElement = 'construct', - /** function foo(*Y*: string) */ - parameterElement = 'parameter', - typeParameterElement = 'type parameter', - primitiveType = 'primitive type', - label = 'label', - alias = 'alias', - constElement = 'const', - letElement = 'let', - directory = 'directory', - externalModuleName = 'external module name', - /** - * - * @deprecated - */ - jsxAttribute = 'JSX attribute', - /** String literal */ - string = 'string', - /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ - link = 'link', - /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ - linkName = 'link name', - /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ - linkText = 'link text', -} +import { ScriptElementKind } from './ts-enums'; /* * Copyright (C) 2018 TypeFox and others. diff --git a/packages/text-editor/code-language-typescript/src/service.ts b/packages/text-editor/code-language-typescript/src/service.ts index 38da72d7..57b09ddb 100644 --- a/packages/text-editor/code-language-typescript/src/service.ts +++ b/packages/text-editor/code-language-typescript/src/service.ts @@ -27,8 +27,9 @@ import type { TransactionSpec, } from '@codemirror/state'; -import { DiagnosticCategory, displayPartsToString, tagToString } from './utils'; +import { displayPartsToString, tagToString } from './utils'; import type { InitializeOptions, ITypeScriptWorker } from './types'; +import { DiagnosticCategory } from './ts-enums'; import { asCompletionItemKind } from './as'; function isDiagnostic(v: unknown): v is Diagnostic { diff --git a/packages/text-editor/code-language-typescript/src/ts-enums.ts b/packages/text-editor/code-language-typescript/src/ts-enums.ts new file mode 100644 index 00000000..21e41cbf --- /dev/null +++ b/packages/text-editor/code-language-typescript/src/ts-enums.ts @@ -0,0 +1,107 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +export enum ScriptElementKind { + unknown = '', + warning = 'warning', + /** predefined type (void) or keyword (class) */ + keyword = 'keyword', + /** top level script node */ + scriptElement = 'script', + /** module foo {} */ + moduleElement = 'module', + /** class X {} */ + classElement = 'class', + /** var x = class X {} */ + localClassElement = 'local class', + /** interface Y {} */ + interfaceElement = 'interface', + /** type T = ... */ + typeElement = 'type', + /** enum E */ + enumElement = 'enum', + enumMemberElement = 'enum member', + /** + * Inside module and script only + * const v = .. + */ + variableElement = 'var', + /** Inside function */ + localVariableElement = 'local var', + /** using foo = ... */ + variableUsingElement = 'using', + /** await using foo = ... */ + variableAwaitUsingElement = 'await using', + /** + * Inside module and script only + * function f() { } + */ + functionElement = 'function', + /** Inside function */ + localFunctionElement = 'local function', + /** class X { [public|private]* foo() {} } */ + memberFunctionElement = 'method', + /** class X { [public|private]* [get|set] foo:number; } */ + memberGetAccessorElement = 'getter', + memberSetAccessorElement = 'setter', + /** + * class X { [public|private]* foo:number; } + * interface Y { foo:number; } + */ + memberVariableElement = 'property', + /** class X { [public|private]* accessor foo: number; } */ + memberAccessorVariableElement = 'accessor', + /** + * class X { constructor() { } } + * class X { static { } } + */ + constructorImplementationElement = 'constructor', + /** interface Y { ():number; } */ + callSignatureElement = 'call', + /** interface Y { []:number; } */ + indexSignatureElement = 'index', + /** interface Y { new():Y; } */ + constructSignatureElement = 'construct', + /** function foo(*Y*: string) */ + parameterElement = 'parameter', + typeParameterElement = 'type parameter', + primitiveType = 'primitive type', + label = 'label', + alias = 'alias', + constElement = 'const', + letElement = 'let', + directory = 'directory', + externalModuleName = 'external module name', + /** + * + * @deprecated + */ + jsxAttribute = 'JSX attribute', + /** String literal */ + string = 'string', + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = 'link', + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = 'link name', + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = 'link text', +} + +export enum DiagnosticCategory { + Warning = 0, + Error = 1, + Suggestion = 2, + Message = 3, +} diff --git a/packages/text-editor/code-language-typescript/src/utils.ts b/packages/text-editor/code-language-typescript/src/utils.ts index 996d2b90..6eaaf1a9 100644 --- a/packages/text-editor/code-language-typescript/src/utils.ts +++ b/packages/text-editor/code-language-typescript/src/utils.ts @@ -27,11 +27,4 @@ function displayPartsToString(displayParts?: SymbolDisplayPart[]) { return ''; } -enum DiagnosticCategory { - Warning = 0, - Error = 1, - Suggestion = 2, - Message = 3, -} - -export { tagToString, displayPartsToString, DiagnosticCategory }; +export { tagToString, displayPartsToString };