vendor tsgo
This commit is contained in:
2
tools/tsgo/internal/lsp/lsproto/_generate/.gitignore
vendored
Normal file
2
tools/tsgo/internal/lsp/lsproto/_generate/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
metaModel.json
|
||||
metaModel.schema.json
|
||||
39
tools/tsgo/internal/lsp/lsproto/_generate/fetchModel.mts
Normal file
39
tools/tsgo/internal/lsp/lsproto/_generate/fetchModel.mts
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env -S node --experimental-strip-types
|
||||
|
||||
// Usage: node --experimental-strip-types fetchModel.mts
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
|
||||
const __filename = url.fileURLToPath(new URL(import.meta.url));
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const metaModelPath = path.join(__dirname, "metaModel.json");
|
||||
const metaModelSchemaPath = path.join(__dirname, "metaModelSchema.mts");
|
||||
|
||||
// Resolve the vscode-languageclient version from the root package-lock.json.
|
||||
const lockfilePath = path.resolve(__dirname, "../../../../package-lock.json");
|
||||
const lockfile = JSON.parse(fs.readFileSync(lockfilePath, "utf-8"));
|
||||
const clientVersion: string = lockfile.packages["node_modules/vscode-languageclient"].version;
|
||||
|
||||
const ref = `release/client/${clientVersion}`;
|
||||
console.log(`Using vscode-languageclient@${clientVersion}`);
|
||||
|
||||
const metaModelURL = `https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/${ref}/protocol/metaModel.json`;
|
||||
const metaModelSchemaURL = `https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/${ref}/tools/src/metaModel.ts`;
|
||||
|
||||
const metaModelResponse = await fetch(metaModelURL);
|
||||
const metaModel = await metaModelResponse.text();
|
||||
fs.writeFileSync(metaModelPath, metaModel);
|
||||
|
||||
const metaModelSchemaResponse = await fetch(metaModelSchemaURL);
|
||||
let metaModelSchema = await metaModelSchemaResponse.text();
|
||||
|
||||
// Patch the schema to add omitzeroValue property to Property type
|
||||
metaModelSchema = metaModelSchema.replace(
|
||||
/(\t \* Whether the property is deprecated or not\. If deprecated\n\t \* the property contains the deprecation message\.\n\t \*\/\n\tdeprecated\?: string;)\n}/m,
|
||||
`$1\n\n\t/**\n\t * Whether this property uses omitzero without being a pointer.\n\t * Custom extension for special value types.\n\t */\n\tomitzeroValue?: boolean;\n}`,
|
||||
);
|
||||
|
||||
fs.writeFileSync(metaModelSchemaPath, metaModelSchema);
|
||||
3436
tools/tsgo/internal/lsp/lsproto/_generate/generate.mts
Normal file
3436
tools/tsgo/internal/lsp/lsproto/_generate/generate.mts
Normal file
File diff suppressed because it is too large
Load Diff
635
tools/tsgo/internal/lsp/lsproto/_generate/metaModelSchema.mts
Normal file
635
tools/tsgo/internal/lsp/lsproto/_generate/metaModelSchema.mts
Normal file
@@ -0,0 +1,635 @@
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
|
||||
export type BaseTypes = 'URI' | 'DocumentUri' | 'integer' | 'uinteger' | 'decimal' | 'RegExp' | 'string' | 'boolean' | 'null';
|
||||
|
||||
export type TypeKind = 'base' | 'reference' | 'array' | 'map' | 'and' | 'or' | 'tuple' | 'literal' | 'stringLiteral' | 'integerLiteral' | 'booleanLiteral';
|
||||
|
||||
/**
|
||||
* Indicates in which direction a message is sent in the protocol.
|
||||
*/
|
||||
export type MessageDirection = 'clientToServer' | 'serverToClient' | 'both';
|
||||
|
||||
/**
|
||||
* Represents a base type like `string` or `DocumentUri`.
|
||||
*/
|
||||
export type BaseType = {
|
||||
kind: 'base';
|
||||
name: BaseTypes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a reference to another type (e.g. `TextDocument`).
|
||||
* This is either a `Structure`, a `Enumeration` or a `TypeAlias`
|
||||
* in the same meta model.
|
||||
*/
|
||||
export type ReferenceType = {
|
||||
kind: 'reference';
|
||||
name: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents an array type (e.g. `TextDocument[]`).
|
||||
*/
|
||||
export type ArrayType = {
|
||||
kind: 'array';
|
||||
element: Type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a type that can be used as a key in a
|
||||
* map type. If a reference type is used then the
|
||||
* type must either resolve to a `string` or `integer`
|
||||
* type. (e.g. `type ChangeAnnotationIdentifier === string`).
|
||||
*/
|
||||
export type MapKeyType = { kind: 'base'; name: 'URI' | 'DocumentUri' | 'string' | 'integer' } | ReferenceType;
|
||||
|
||||
/**
|
||||
* Represents a JSON object map
|
||||
* (e.g. `interface Map<K extends string | integer, V> { [key: K] => V; }`).
|
||||
*/
|
||||
export type MapType = {
|
||||
kind: 'map';
|
||||
key: MapKeyType;
|
||||
value: Type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents an `and` type
|
||||
* (e.g. TextDocumentParams & WorkDoneProgressParams`).
|
||||
*/
|
||||
export type AndType = {
|
||||
kind: 'and';
|
||||
items: Type[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents an `or` type
|
||||
* (e.g. `Location | LocationLink`).
|
||||
*/
|
||||
export type OrType = {
|
||||
kind: 'or';
|
||||
items: Type[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a `tuple` type
|
||||
* (e.g. `[integer, integer]`).
|
||||
*/
|
||||
export type TupleType = {
|
||||
kind: 'tuple';
|
||||
items: Type[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a literal structure
|
||||
* (e.g. `property: { start: uinteger; end: uinteger; }`).
|
||||
*/
|
||||
export type StructureLiteralType = {
|
||||
kind: 'literal';
|
||||
value: StructureLiteral;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a string literal type
|
||||
* (e.g. `kind: 'rename'`).
|
||||
*/
|
||||
export type StringLiteralType = {
|
||||
kind: 'stringLiteral';
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type IntegerLiteralType = {
|
||||
/**
|
||||
* Represents an integer literal type
|
||||
* (e.g. `kind: 1`).
|
||||
*/
|
||||
kind: 'integerLiteral';
|
||||
value: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a boolean literal type
|
||||
* (e.g. `kind: true`).
|
||||
*/
|
||||
export type BooleanLiteralType = {
|
||||
kind: 'booleanLiteral';
|
||||
value: boolean;
|
||||
};
|
||||
|
||||
export type Type = BaseType | ReferenceType | ArrayType | MapType | AndType | OrType | TupleType | StructureLiteralType | StringLiteralType | IntegerLiteralType | BooleanLiteralType;
|
||||
|
||||
/**
|
||||
* Represents a LSP request
|
||||
*/
|
||||
export type Request = {
|
||||
/**
|
||||
* The request's method name.
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* The type name of the request if any.
|
||||
*/
|
||||
typeName?: string;
|
||||
|
||||
/**
|
||||
* The parameter type(s) if any.
|
||||
*/
|
||||
params?: Type | Type[];
|
||||
|
||||
/**
|
||||
* The result type.
|
||||
*/
|
||||
result: Type;
|
||||
|
||||
/**
|
||||
* Optional partial result type if the request
|
||||
* supports partial result reporting.
|
||||
*/
|
||||
partialResult?: Type;
|
||||
|
||||
/**
|
||||
* An optional error data type.
|
||||
*/
|
||||
errorData?: Type;
|
||||
|
||||
/**
|
||||
* Optional a dynamic registration method if it
|
||||
* different from the request's method.
|
||||
*/
|
||||
registrationMethod?: string;
|
||||
|
||||
/**
|
||||
* Optional registration options if the request
|
||||
* supports dynamic registration.
|
||||
*/
|
||||
registrationOptions?: Type;
|
||||
|
||||
/**
|
||||
* The direction in which this request is sent
|
||||
* in the protocol.
|
||||
*/
|
||||
messageDirection: MessageDirection;
|
||||
|
||||
/**
|
||||
* An optional documentation;
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this request is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed feature. If omitted
|
||||
* the feature is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the request is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
|
||||
/**
|
||||
* The client capability property path if any.
|
||||
*/
|
||||
clientCapability?: string;
|
||||
|
||||
/**
|
||||
* The server capability property path if any.
|
||||
*/
|
||||
serverCapability?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a LSP notification
|
||||
*/
|
||||
export type Notification = {
|
||||
/**
|
||||
* The notifications's method name.
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* The type name of the notifications if any.
|
||||
*/
|
||||
typeName?: string;
|
||||
|
||||
/**
|
||||
* The parameter type(s) if any.
|
||||
*/
|
||||
params?: Type | Type[];
|
||||
|
||||
/**
|
||||
* Optional a dynamic registration method if it
|
||||
* different from the notifications's method.
|
||||
*/
|
||||
registrationMethod?: string;
|
||||
|
||||
/**
|
||||
* Optional registration options if the notification
|
||||
* supports dynamic registration.
|
||||
*/
|
||||
registrationOptions?: Type;
|
||||
|
||||
/**
|
||||
* The direction in which this notification is sent
|
||||
* in the protocol.
|
||||
*/
|
||||
messageDirection: MessageDirection;
|
||||
|
||||
/**
|
||||
* An optional documentation;
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this notification is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed notification. If omitted
|
||||
* the notification is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the notification is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
|
||||
/**
|
||||
* The client capability property path if any.
|
||||
*/
|
||||
clientCapability?: string;
|
||||
|
||||
/**
|
||||
* The server capability property path if any.
|
||||
*/
|
||||
serverCapability?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents an object property.
|
||||
*/
|
||||
export type Property = {
|
||||
/**
|
||||
* The property name;
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The type of the property
|
||||
*/
|
||||
type: Type;
|
||||
|
||||
/**
|
||||
* Whether the property is optional. If
|
||||
* omitted, the property is mandatory.
|
||||
*/
|
||||
optional?: boolean;
|
||||
|
||||
/**
|
||||
* An optional documentation.
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this property is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed property. If omitted,
|
||||
* the structure is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the property is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
|
||||
/**
|
||||
* Whether this property uses omitzero without being a pointer.
|
||||
* Custom extension for special value types.
|
||||
*/
|
||||
omitzeroValue?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines the structure of an object literal.
|
||||
*/
|
||||
export type Structure = {
|
||||
/**
|
||||
* The name of the structure.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Structures extended from. This structures form
|
||||
* a polymorphic type hierarchy.
|
||||
*/
|
||||
extends?: Type[];
|
||||
|
||||
/**
|
||||
* Structures to mix in. The properties of these
|
||||
* structures are `copied` into this structure.
|
||||
* Mixins don't form a polymorphic type hierarchy in
|
||||
* LSP.
|
||||
*/
|
||||
mixins?: Type[];
|
||||
|
||||
/**
|
||||
* The properties.
|
||||
*/
|
||||
properties: Property[];
|
||||
|
||||
/**
|
||||
* An optional documentation;
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this structure is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed structure. If omitted,
|
||||
* the structure is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the structure is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines an unnamed structure of an object literal.
|
||||
*/
|
||||
export type StructureLiteral = {
|
||||
|
||||
/**
|
||||
* The properties.
|
||||
*/
|
||||
properties: Property[];
|
||||
|
||||
/**
|
||||
* An optional documentation.
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this structure is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed structure. If omitted,
|
||||
* the structure is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the literal is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines a type alias.
|
||||
* (e.g. `type Definition = Location | LocationLink`)
|
||||
*/
|
||||
export type TypeAlias = {
|
||||
/**
|
||||
* The name of the type alias.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The aliased type.
|
||||
*/
|
||||
type: Type;
|
||||
|
||||
/**
|
||||
* An optional documentation.
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this structure is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed type alias. If omitted,
|
||||
* the type alias is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the type alias is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines an enumeration entry.
|
||||
*/
|
||||
export type EnumerationEntry = {
|
||||
/**
|
||||
* The name of the enum item.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The value.
|
||||
*/
|
||||
value: string | number;
|
||||
|
||||
/**
|
||||
* An optional documentation.
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this enumeration entry is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed enumeration entry. If omitted,
|
||||
* the enumeration entry is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the enum entry is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
};
|
||||
|
||||
export type EnumerationType = { kind: 'base'; name: 'string' | 'integer' | 'uinteger' };
|
||||
|
||||
/**
|
||||
* Defines an enumeration.
|
||||
*/
|
||||
export type Enumeration = {
|
||||
/**
|
||||
* The name of the enumeration.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The type of the elements.
|
||||
*/
|
||||
type: EnumerationType;
|
||||
|
||||
/**
|
||||
* The enum values.
|
||||
*/
|
||||
values: EnumerationEntry[];
|
||||
|
||||
/**
|
||||
* Whether the enumeration supports custom values (e.g. values which are not
|
||||
* part of the set defined in `values`). If omitted no custom values are
|
||||
* supported.
|
||||
*/
|
||||
supportsCustomValues?: boolean;
|
||||
|
||||
/**
|
||||
* An optional documentation.
|
||||
*/
|
||||
documentation?: string;
|
||||
|
||||
/**
|
||||
* Since when (release number) this enumeration is
|
||||
* available. Is undefined if not known.
|
||||
*/
|
||||
since?: string;
|
||||
|
||||
/**
|
||||
* All since tags in case there was more than one tag.
|
||||
* Is undefined if not known.
|
||||
*/
|
||||
sinceTags?: string[];
|
||||
|
||||
/**
|
||||
* Whether this is a proposed enumeration. If omitted,
|
||||
* the enumeration is final.
|
||||
*/
|
||||
proposed?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the enumeration is deprecated or not. If deprecated
|
||||
* the property contains the deprecation message.
|
||||
*/
|
||||
deprecated?: string;
|
||||
};
|
||||
|
||||
export type MetaData = {
|
||||
/**
|
||||
* The protocol version.
|
||||
*/
|
||||
version: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The actual meta model.
|
||||
*/
|
||||
export type MetaModel = {
|
||||
/**
|
||||
* Additional meta data.
|
||||
*/
|
||||
metaData: MetaData;
|
||||
|
||||
/**
|
||||
* The requests.
|
||||
*/
|
||||
requests: Request[];
|
||||
|
||||
/**
|
||||
* The notifications.
|
||||
*/
|
||||
notifications: Notification[];
|
||||
|
||||
/**
|
||||
* The structures.
|
||||
*/
|
||||
structures: Structure[];
|
||||
|
||||
/**
|
||||
* The enumerations.
|
||||
*/
|
||||
enumerations: Enumeration[];
|
||||
|
||||
/**
|
||||
* The type aliases.
|
||||
*/
|
||||
typeAliases: TypeAlias[];
|
||||
};
|
||||
20
tools/tsgo/internal/lsp/lsproto/_generate/tsconfig.json
Normal file
20
tools/tsgo/internal/lsp/lsproto/_generate/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"types": ["node"],
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
},
|
||||
"include": [
|
||||
"*.mts",
|
||||
"*.mjs"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user