Skip to content

Commit a020e15

Browse files
committed
feat: ts license
1 parent 7a652ec commit a020e15

File tree

5 files changed

+122
-97
lines changed

5 files changed

+122
-97
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-editor/code-language-typescript",
5+
"comment": "ts license",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@coze-editor/code-language-typescript",
10+
"email": "[email protected]"
11+
}

packages/text-editor/code-language-typescript/src/as.ts

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,7 @@
33

44
import { CompletionItemKind } from 'vscode-languageserver-types';
55

6-
/**
7-
* Copied from TypeScript 5.8.2
8-
*/
9-
enum ScriptElementKind {
10-
unknown = '',
11-
warning = 'warning',
12-
/** predefined type (void) or keyword (class) */
13-
keyword = 'keyword',
14-
/** top level script node */
15-
scriptElement = 'script',
16-
/** module foo {} */
17-
moduleElement = 'module',
18-
/** class X {} */
19-
classElement = 'class',
20-
/** var x = class X {} */
21-
localClassElement = 'local class',
22-
/** interface Y {} */
23-
interfaceElement = 'interface',
24-
/** type T = ... */
25-
typeElement = 'type',
26-
/** enum E */
27-
enumElement = 'enum',
28-
enumMemberElement = 'enum member',
29-
/**
30-
* Inside module and script only
31-
* const v = ..
32-
*/
33-
variableElement = 'var',
34-
/** Inside function */
35-
localVariableElement = 'local var',
36-
/** using foo = ... */
37-
variableUsingElement = 'using',
38-
/** await using foo = ... */
39-
variableAwaitUsingElement = 'await using',
40-
/**
41-
* Inside module and script only
42-
* function f() { }
43-
*/
44-
functionElement = 'function',
45-
/** Inside function */
46-
localFunctionElement = 'local function',
47-
/** class X { [public|private]* foo() {} } */
48-
memberFunctionElement = 'method',
49-
/** class X { [public|private]* [get|set] foo:number; } */
50-
memberGetAccessorElement = 'getter',
51-
memberSetAccessorElement = 'setter',
52-
/**
53-
* class X { [public|private]* foo:number; }
54-
* interface Y { foo:number; }
55-
*/
56-
memberVariableElement = 'property',
57-
/** class X { [public|private]* accessor foo: number; } */
58-
memberAccessorVariableElement = 'accessor',
59-
/**
60-
* class X { constructor() { } }
61-
* class X { static { } }
62-
*/
63-
constructorImplementationElement = 'constructor',
64-
/** interface Y { ():number; } */
65-
callSignatureElement = 'call',
66-
/** interface Y { []:number; } */
67-
indexSignatureElement = 'index',
68-
/** interface Y { new():Y; } */
69-
constructSignatureElement = 'construct',
70-
/** function foo(*Y*: string) */
71-
parameterElement = 'parameter',
72-
typeParameterElement = 'type parameter',
73-
primitiveType = 'primitive type',
74-
label = 'label',
75-
alias = 'alias',
76-
constElement = 'const',
77-
letElement = 'let',
78-
directory = 'directory',
79-
externalModuleName = 'external module name',
80-
/**
81-
* <JsxTagName attribute1 attribute2={0} />
82-
* @deprecated
83-
*/
84-
jsxAttribute = 'JSX attribute',
85-
/** String literal */
86-
string = 'string',
87-
/** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */
88-
link = 'link',
89-
/** Jsdoc @link: in `{@link C link text}`, the entity name "C" */
90-
linkName = 'link name',
91-
/** Jsdoc @link: in `{@link C link text}`, the link text "link text" */
92-
linkText = 'link text',
93-
}
6+
import { ScriptElementKind } from './ts-enums';
947

958
/*
969
* Copyright (C) 2018 TypeFox and others.

packages/text-editor/code-language-typescript/src/service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ import type {
2727
TransactionSpec,
2828
} from '@codemirror/state';
2929

30-
import { DiagnosticCategory, displayPartsToString, tagToString } from './utils';
30+
import { displayPartsToString, tagToString } from './utils';
3131
import type { InitializeOptions, ITypeScriptWorker } from './types';
32+
import { DiagnosticCategory } from './ts-enums';
3233
import { asCompletionItemKind } from './as';
3334

3435
function isDiagnostic(v: unknown): v is Diagnostic {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
export enum ScriptElementKind {
17+
unknown = '',
18+
warning = 'warning',
19+
/** predefined type (void) or keyword (class) */
20+
keyword = 'keyword',
21+
/** top level script node */
22+
scriptElement = 'script',
23+
/** module foo {} */
24+
moduleElement = 'module',
25+
/** class X {} */
26+
classElement = 'class',
27+
/** var x = class X {} */
28+
localClassElement = 'local class',
29+
/** interface Y {} */
30+
interfaceElement = 'interface',
31+
/** type T = ... */
32+
typeElement = 'type',
33+
/** enum E */
34+
enumElement = 'enum',
35+
enumMemberElement = 'enum member',
36+
/**
37+
* Inside module and script only
38+
* const v = ..
39+
*/
40+
variableElement = 'var',
41+
/** Inside function */
42+
localVariableElement = 'local var',
43+
/** using foo = ... */
44+
variableUsingElement = 'using',
45+
/** await using foo = ... */
46+
variableAwaitUsingElement = 'await using',
47+
/**
48+
* Inside module and script only
49+
* function f() { }
50+
*/
51+
functionElement = 'function',
52+
/** Inside function */
53+
localFunctionElement = 'local function',
54+
/** class X { [public|private]* foo() {} } */
55+
memberFunctionElement = 'method',
56+
/** class X { [public|private]* [get|set] foo:number; } */
57+
memberGetAccessorElement = 'getter',
58+
memberSetAccessorElement = 'setter',
59+
/**
60+
* class X { [public|private]* foo:number; }
61+
* interface Y { foo:number; }
62+
*/
63+
memberVariableElement = 'property',
64+
/** class X { [public|private]* accessor foo: number; } */
65+
memberAccessorVariableElement = 'accessor',
66+
/**
67+
* class X { constructor() { } }
68+
* class X { static { } }
69+
*/
70+
constructorImplementationElement = 'constructor',
71+
/** interface Y { ():number; } */
72+
callSignatureElement = 'call',
73+
/** interface Y { []:number; } */
74+
indexSignatureElement = 'index',
75+
/** interface Y { new():Y; } */
76+
constructSignatureElement = 'construct',
77+
/** function foo(*Y*: string) */
78+
parameterElement = 'parameter',
79+
typeParameterElement = 'type parameter',
80+
primitiveType = 'primitive type',
81+
label = 'label',
82+
alias = 'alias',
83+
constElement = 'const',
84+
letElement = 'let',
85+
directory = 'directory',
86+
externalModuleName = 'external module name',
87+
/**
88+
* <JsxTagName attribute1 attribute2={0} />
89+
* @deprecated
90+
*/
91+
jsxAttribute = 'JSX attribute',
92+
/** String literal */
93+
string = 'string',
94+
/** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */
95+
link = 'link',
96+
/** Jsdoc @link: in `{@link C link text}`, the entity name "C" */
97+
linkName = 'link name',
98+
/** Jsdoc @link: in `{@link C link text}`, the link text "link text" */
99+
linkText = 'link text',
100+
}
101+
102+
export enum DiagnosticCategory {
103+
Warning = 0,
104+
Error = 1,
105+
Suggestion = 2,
106+
Message = 3,
107+
}

packages/text-editor/code-language-typescript/src/utils.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,4 @@ function displayPartsToString(displayParts?: SymbolDisplayPart[]) {
2727
return '';
2828
}
2929

30-
enum DiagnosticCategory {
31-
Warning = 0,
32-
Error = 1,
33-
Suggestion = 2,
34-
Message = 3,
35-
}
36-
37-
export { tagToString, displayPartsToString, DiagnosticCategory };
30+
export { tagToString, displayPartsToString };

0 commit comments

Comments
 (0)