UNPKG

@sap/cds-lsp

Version:

Language server for CDS

1,457 lines (1,456 loc) 57.7 kB
import { BigIntStats, Dirent, PathLike, StatOptions, Stats, WriteFileOptions } from 'node:fs'; import { TypedEmitter } from 'tiny-typed-emitter'; import * as LS from 'vscode-languageserver'; import { _, _Connection } from 'vscode-languageserver'; import * as LSP from 'vscode-languageserver-protocol'; export declare const lspRoot: `/${string}`; export type SpecificString<T> = string & { _brand: T; }; export type FileUri = `file:///${string}`; export type UntitledUri = `untitled:${string}`; export type Uri = FileUri | UntitledUri; export type AbsolutePath = `/${string}`; export type FileContent = SpecificString<"FileContent">; export type WorkspaceRelativePath = SpecificString<"WorkspaceRelativePath">; export type UsingPath = SpecificString<"UsingPath">; declare const UNKNOWN_NAME = ""; export type XsnKind = "__i18n" | "$parameters" | "action" | "annotate" | "annotation" | "aspect" | "builtin" | "context" | "element" | "entity" | "enum" | "event" | "extend" | "function" | "key" | "mixin" | "namespace" | "param" | "qualifiedAnnotation" | "select" | "service" | "source" | "type" | "using" | "view" | "$tableAlias"; export interface Thing { kind: XsnKind; name: XsnBaseName; location: XsnLocation; _artifact?: XsnArtifact; value?: XsnExtensionName; $duplicates?: boolean | Thing[]; } export interface XsnValidName { kind: XsnKind; name: { absolute: string; id?: string; }; location: XsnLocation; builtin?: boolean; parameters?: string[]; } export type XsnSeverity = "Error" | "Warning" | "Info" | "Debug"; export interface XsnParseModel { dependencies?: Array<{ location: XsnLocation; val: UsingPath; }>; usings?: Array<{ location: XsnLocation; fileDep?: { location: XsnLocation; val: UsingPath; }; }>; options: CdscParseOptions; tokens: unknown[]; ruleTree: unknown; toolbox: IXsnToolbox; name: { id: string; }; kind: XsnKind; annotationAssignments?: XsnAnnotationAssignment[]; } export interface CdscParseOptions { parseOnly?: boolean; lintMode?: boolean; attachTokens?: boolean; ambigDetection?: boolean; fallbackParser?: string; messages: XsnMessage[]; parseListener?: unknown; newParser?: boolean; } export interface CdscCompileOptions { fallbackParser?: "cds"; attachValidNames?: boolean; attachTokens?: boolean; lspMode?: boolean; docComment?: boolean; messages?: XsnMessage[]; parseListener?: unknown; newParser?: boolean; } export interface ModuleOrigin { __loadedFrom: AbsolutePath; __logicalLocation: string; } export interface ICdsCompiler extends ModuleOrigin { parse(source: FileContent, filename: string, options?: CdscParseOptions): XsnParseModel; compile(fileNames: AbsolutePath[], dir?: AbsolutePath, options?: CdscCompileOptions, map?: CdscFileMap): Promise<XsnCompileModel>; version(): string; $lsp: ICdsCompiler; getArtifactName(thing: unknown): any; getSpecialFunctions?(): string[]; createToolbox(adapter: unknown): IXsnToolbox; traverseSemanticTokens?(model: XsnCompileModel, options: unknown): Generator<XsnIteratorEvent>; getSemanticTokenOrigin(o: XsnIteratorEvent): Generator<XsnArtifact>; } export interface CdscFileMap { [localPath: AbsolutePath]: FileContent; } export interface XsnArtifacts { [localName: string]: XsnArtifact; } export interface XsnElements { [localName: string]: XsnElement; } export interface XsnSources { [absoluteLocalPath: AbsolutePath]: XsnSource; } export type ResolutionStep = "ToDefinition" | "ToNextExplicitAlias"; export interface ResolutionOptions { step: ResolutionStep; } export interface IXsnToolbox { toUri(localPath: WorkspaceRelativePath | AbsolutePath): Uri; resolve(thing: any, options?: ResolutionOptions): any[]; nameLocation(thing: any): XsnLocation | undefined; absoluteNameOf(thing: Thing | XsnName | undefined, identifierCategory?: unknown): string | typeof UNKNOWN_NAME; getArtifactName(thing: unknown): any; locationOf(thing: any): XsnLocation; originOf(thing: any): any; getKind(thing: Thing): XsnKind; expectedKindOf(thing: Thing): XsnKind; nameLocationOf(thing: any): XsnLocation | undefined; filterMessagesInScope(position: LSP.Position, message: XsnMessage, relativeProvokerPosition: number): boolean; sourcesOf(ast: XsnCompileModel): XsnSources; isAutoexposed(thing: any): boolean; name(thing: unknown): XsnName; isReturnsCarrier(thing: any): boolean; usingsOf(source: XsnSource): XsnArtifactUsing[]; getSemanticTokenOrigin(o: XsnReferenceEvent): XsnArtifact[]; getDefinitionOrigin(o: XsnDefinitionEvent): unknown[]; getAnnotationParseTrees(o: any): XsnAnnotationAssignment[]; } export interface XsnCompileModel { definitions: XsnArtifacts; sources: XsnSources; version: { creator: string; csn: string; }; options: CdscCompileOptions & { messages: XsnMessage[]; }; workspaceRoot: AbsolutePath; rootFile: AbsolutePath; compilerVersion: string; compiler: ICdsCompiler; toolbox: IXsnToolbox; } export interface XsnMessage { home?: string; message: string; messageId?: string; expectedTokens?: string[]; validNames?: { [id: string]: XsnValidName; }; $location: XsnLocation; severity: XsnSeverity; } export interface XsnSource { vocabularies?: XsnArtifacts; kind: "source"; filename: WorkspaceRelativePath; dirname: AbsolutePath; realname: AbsolutePath; artifacts: XsnArtifacts; dependencies: XsnFileDependency[]; usings: XsnArtifactUsing[]; tokens: unknown[]; ruleTree?: unknown; options: CdscCompileOptions; namespace?: XsnSourceNamespace; } export type XsnNamespacePath = Array<{ id: string; location: XsnLocation; }>; export interface XsnSourceNamespace { path: XsnNamespacePath; } export type DollarInferred = "*" | "autoexposed" | "localized" | "localized-entity"; export interface XsnArtifact { doc?: XsnDocComment; kind: XsnKind; extern?: { location: XsnLocation; path: XsnPathSegment[]; _artifact?: XsnArtifact; }; location: XsnLocation; name: XsnName; elements?: XsnElements; returns?: any; params?: XsnElements; $inferred?: DollarInferred; builtin?: boolean; _main?: XsnArtifact; } export interface XsnAnnotationAssignment { kind?: "annotate"; location: XsnLocation; name: XsnExtensionName; value?: AnnotationValue; val?: string; path?: XsnPathSegment[]; } export interface XsnFileDependency { literal: string; location: XsnLocation; realname?: AbsolutePath; val: string; } export interface XsnDocComment { val: string; location: XsnLocation; } export interface XsnElement { doc?: XsnDocComment; kind: "element"; elements?: XsnElements; location: XsnLocation; name: XsnElementName; type: XsnExtensionElementType; target?: XsnExtensionElementType; returns?: XsnExtensionElementType; $inferred?: DollarInferred; } export interface XsnElementName { absolute: string; element: string; id: string; location: XsnLocation; } export interface XsnExtensionElementType { absolute: string; location: XsnLocation; path: XsnPathSegment[]; scope: number; _artifact?: Thing; } export interface XsnArtifactUsing { kind: "using"; annotationAssignments: XsnAnnotationAssignment[]; extern: { id: FullyQualifiedName; location: XsnLocation; path: XsnPathSegment[]; _artifact?: XsnArtifact; }; location: XsnLocation; name: XsnName; fileDep?: XsnFileDependency; usings?: XsnArtifactUsing[]; } export interface XsnBaseName { absolute: string; id: string; $inferred?: DollarInferred; location: XsnLocation; path?: XsnPathSegment[]; } export interface XsnExtensionName extends XsnBaseName { location: XsnLocation; path: XsnPathSegment[]; _artifact?: Thing; } export interface XsnName extends XsnBaseName { absolute: string; calculated?: boolean; action?: string; param?: string; element?: string; id: string; $inferred?: DollarInferred; location: XsnLocation; path?: XsnPathSegment[]; query?: number; _artifact?: Thing; } export interface XsnTokenReference { id: string; location: XsnLocation; _artifact: XsnArtifact; } export type XsnIteratorHint = "using-alias"; export interface XsnDefinitionEvent { hint?: XsnIteratorHint; node: XsnArtifact; event: "definition"; semanticToken: XsnTokenReference; } export interface XsnReferenceEvent { hint?: XsnIteratorHint; node: XsnExpression | XsnArtifact; event: "reference"; semanticToken: XsnTokenReference; } export type XsnIteratorEvent = XsnDefinitionEvent | XsnReferenceEvent; export interface XsnExpression { path?: object[]; _artifact?: XsnArtifact; } export interface XsnLocation { file: WorkspaceRelativePath; line: number; col: number; endLine: number; endCol: number; tokenIndex?: number; } export interface XsnPathSegment { id: string; location: XsnLocation; _artifact?: Thing; } export type FullyQualifiedName = string; export interface AnnotationValueBase { location: XsnLocation; name?: Name; } export interface Name { location: XsnLocation; path: XsnNameSegment3[]; variant?: Omit<Name, "variant">; } export interface LeafName extends Name { absolute?: string; } export interface NonLeafAnnotationValue extends AnnotationValueBase { $flatten?: AnnotationValue[]; } export interface LeafAnnotationValue extends AnnotationValueBase { $priority?: "annotate"; literal?: "string" | "number" | "enum" | "array" | "struct" | "hex" | "null" | "boolean" | "date" | "time" | "timestamp"; _block?: any; } export interface NamedLeafAnnotationValue extends LeafAnnotationValue { name: LeafName; } export interface StringValue extends NamedLeafAnnotationValue { literal: "string"; val: string; } export interface NumberValue extends NamedLeafAnnotationValue { literal: "number"; val: number | string; } export interface EnumValue extends NamedLeafAnnotationValue { literal: "enum"; sym: XsnNameSegment3; } export interface ArrayValue extends NamedLeafAnnotationValue { literal: "array"; val: AnnotationValue[]; } export interface StructValue extends AnnotationValueBase { literal: "struct"; struct: { [id: string]: AnnotationValue; }; } export interface HexValue extends NamedLeafAnnotationValue { literal: "hex"; val: `${HexChar}${HexChar}${HexChar}${HexChar}`; } export interface NullValue extends NamedLeafAnnotationValue { literal: "null"; val: null; } export interface BooleanValue extends NamedLeafAnnotationValue { literal: "boolean"; val: true | false; } export interface DateValue extends NamedLeafAnnotationValue { literal: "date"; val: DateYMDString; } export interface TimeValue extends NamedLeafAnnotationValue { literal: "time"; val: Time; } export interface TimestampValue extends NamedLeafAnnotationValue { literal: "timestamp"; val: string; } export type AnyAnnotationLeafValue = NullValue | BooleanValue | NumberValue | StringValue | DateValue | TimeValue | TimestampValue | HexValue | EnumValue | ArrayValue | StructValue; export type AnnotationValue = NonLeafAnnotationValue | AnyAnnotationLeafValue; export type OneToNine = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; export type ZeroOrOne = 0 | 1; export type ZeroToThree = 0 | 1 | 2 | 3; export type ZeroToFive = 0 | 1 | 2 | 3 | 4 | 5; export type d = OneToNine | 0; export type YYYY = `19${d}${d}` | `20${d}${d}`; export type DD = `${0}${OneToNine}` | `${1 | 2}${d}` | `3${ZeroOrOne}`; export type MM = `0${OneToNine}` | `1${0 | 1 | 2}`; export type HH = `${ZeroOrOne}${OneToNine}` | `2${ZeroToThree}`; export type MinSec = `${ZeroToFive}${d}`; export type HexLet = "a" | "b" | "c" | "d" | "e" | "f"; export type HexChar = d | HexLet; export type DateYMString = `${YYYY}-${MM}`; export type DateYMDString = `${DateYMString}-${DD}`; export type Time = `${HH}:${MinSec}:${MinSec}`; export interface XsnNameSegment3 { id: string; location: XsnLocation; } export interface CdsLocation extends LSP.Location { uri: Uri; } export interface IAnnotationAssignmentToken extends IGenericToken { readonly carrier: IIdentifierToken; readonly carrierName: string; readonly carrierNameRange?: LSP.Range; } export interface IGenericToken extends LSP.Position { readonly uri: Uri; readonly tokenIndex: number; readonly text: string; readonly annotationValue?: string; readonly range: LSP.Range; readonly location: LSP.Location; readonly start: LSP.Position; readonly end: LSP.Position; isIdentifier(): this is IIdentifierToken; isKeyword(): boolean; compare(position: LSP.Position): number; } export interface IStringLiteralToken extends IGenericToken { translationId?: string; isUsingPath?: boolean; } export interface IGenericDefinition { readonly symbolName: FullyQualifiedName; readonly fullyQualifiedName: FullyQualifiedName; readonly kind: XsnKind; readonly absoluteName: FullyQualifiedName; } export interface IIdentifierToken extends IGenericToken { readonly definitions?: IGenericDefinition | IGenericDefinition[]; } export interface IFileIndex { idTokens: IIdentifierToken[]; directDependentUris: FileUri[]; readonly annotationAssignments: IterableIterator<IAnnotationAssignmentToken>; } export interface IExplicitDefinition extends IGenericDefinition, LSP.Position { location: CdsLocation; nameLocation: CdsLocation; line: number; character: number; docComment?: string; isExtend?: boolean; isAspect?: boolean; } export interface IBlitzIndex { readonly builtUris: readonly string[]; getTransitiveDependencies(uri: string): Set<string>; forUri(uri: string, create?: undefined | "create" | "warnCreate"): IFileIndex; forUri(uri: string, create: "noCreate"): IFileIndex | undefined; } export interface IContribution { initialize?: (context: IContributionContext) => Promise<void>; } declare enum Setting { MarkMissingTranslations = "cds.compiler.markMissingI18nDefault", OmitRedundantTypesInSnippets = "cds.completion.annotations.omitRedundantTypesInSnippets", EnableAdditionalAnalyticalAnnotations = "cds.contributions.enablement.additionalAnalyticalAnnotations" } export interface Translation { uri: FileUri; line: number; character: number; id: string; text: string; } export interface ITranslationProvider { resolve(sourceUri: string, translationId: string): Translation | undefined; } export interface ISettingsProvider { get(setting: Setting): unknown; } export interface IContributionContext { trace: IContributionTracer; translation: ITranslationProvider; settings: ISettingsProvider; } export type ContributionTraceMessage = () => string; export interface IContributionTracer { debug(m: ContributionTraceMessage): void; verbose(m: ContributionTraceMessage): void; info(m: ContributionTraceMessage): void; warn(m: ContributionTraceMessage): void; error(m: ContributionTraceMessage): void; } export interface IAnnotationContribution extends IContribution { fetchCompletions?: (params: CdsCompletionParams) => Promise<CdsCompletionItem[]>; fetchDiagnostics?: (params: CdsDiagnosticParams) => Promise<CdsDiagnostics>; fetchQuickfixes?: (params: LSP.CodeActionParams) => Promise<CdsQuickfix[]>; fetchHover?: (params: CdsHoverParams) => Promise<CdsHover | undefined>; fetchDefinition?: (params: CdsDefinitionParams) => Promise<CdsLocation | CdsLocation[] | undefined>; fetchReferences?: (params: CdsDefinitionParams) => Promise<CdsLocation[]>; fetchSemanticTokens?: (params: CdsSemanticTokensParams) => Promise<SemanticToken[]>; indexAnnotationIdentifiers?: (params: CdsIndexingParams) => Promise<CdsAnnotationIndex>; indexAndValidate?: (params: CdsIndexingParams) => Promise<CdsAnnotationIndexAndDiagnostics>; } export interface CdsIndexingParams { uris: Uri[]; index: IBlitzIndex; ast: XsnCompileModel; } export interface CdsAnnotationIndexEntry { absoluteName: string; definition: LSP.Location; references: LSP.Location[]; } export type CdsDiagnostics = Map<Uri, LSP.Diagnostic[]>; export type CdsAnnotationIndex = CdsAnnotationIndexEntry[]; export interface CdsAnnotationIndexAndDiagnostics { annotationIndex: CdsAnnotationIndex; diagnostics: CdsDiagnostics; } export type CdsQuickfix = Omit<LSP.CodeAction, "command">; export interface CdsCompletionParams { cursorPosition: LSP.TextDocumentPositionParams; index: IBlitzIndex; annotation: IAnnotationAssignmentToken; ast: XsnCompileModel; relativeLocalPath: string; isCompoundAnnotation: boolean; completionItemsFromCompiler: LSP.CompletionItem[]; } export interface CdsDiagnosticParams { uris: Uri[]; index: IBlitzIndex; ast: XsnCompileModel; } export interface CdsHoverParams { cursorPosition: LSP.TextDocumentPositionParams; annotation: IAnnotationAssignmentToken; index: IBlitzIndex; } export interface CdsDefinitionParams { cursorPosition: LSP.TextDocumentPositionParams; annotation: IAnnotationAssignmentToken; index: IBlitzIndex; ast: XsnCompileModel; } export interface CdsHover extends LSP.Hover { contents: CdsMarkupContent; } export interface CdsMarkupContent extends LSP.MarkupContent { kind: "markdown"; } export interface CdsCompletionItem extends LSP.CompletionItem { data?: unknown; } export interface CdsSemanticTokensParams { uri: Uri; index: IBlitzIndex; } export interface SemanticToken { line: number; character: number; length: number; tokenType: LSP.SemanticTokenTypes; tokenModifiers: LSP.SemanticTokenModifiers[]; } export interface TestServer { listen(connection: LS.Connection): void; } export interface TestAnnotationContribution { name: string; description: string; version: string; handler: IAnnotationContribution; } export declare function createCdsLanguageTestServer(contributions: TestAnnotationContribution[]): Promise<TestServer>; declare const RelevantGrammarRuleNames: readonly [ "actionMainDef", "annoAssignBase", "annoAssignParen", "annoAssignStd", "annoAssignCol", "annoAssignMid", "annoStructValue", "annoValue", "annotateArtifact", "annotateElementsBlock", "annotateArtifactElements", "annotateElement", "annotationAssignment_atn", "annotationAssignment_fix", "annotationAssignment_ll1", "annoAssignStd", "annoAssignCol", "annoAssignMid", "annoAssignParen", "annoAssignBase", "annotationAssignment_1", "annotationAssignment_paren", "annotationDef", "annoValue", "annoSubValue", "artifactDefOrExtend", "aspectDef", "boundActionFunctionDef", "cardinalityAndFilter", "contextDef", "elementDef", "elementsBlock", "elementDefOrExtend", "elementsBlock", "entityDef", "eventDef", "excludingClause", "expression", "expressionOrQueryParens", "extendArtifact", "extendContext", "extendEntityOrAspect", "extendProjection", "extendType", "foreignKeysBlock", "functionMainDef", "filterClauses", "mixinElementDef", "namespaceDeclaration", "nestedSelectItemsList", "orderByExpression", "orderByLimitOffset", "paramDef", "paramsList", "projectionSpec", "queryExpression", "returnsSpec", "selectItemDef", "selectQuery", "serviceDef", "start", "tableExpression", "typeDef", "typeNamedArg", "typeNamedArgsList", "typeOrIncludesSpec", "typeOrIncludesSpec", "typeRefOptArgs", "usingDeclaration", "usingProxy", "valuePath", "viewDef", "whereGroupByHaving" ]; export type BlockRule = typeof RelevantGrammarRuleNames[number]; export interface ParserToken { tokenIndex: number; start: number; type: string; parsedAs?: IdentifierCategory; isIdentifier?: string; text: string; location: XsnLocation; } declare const IdentifierCategories: readonly [ "<n/a>", "Action", "anno", "AnnoDef", "annoref", "artref", "BoundAction", "Context", "Element", "Entity", "Enum", "enumref", "Ext", "ExtBoundAction", "ExtContext", "ExtElement", "ExtParam", "ExtService", "Event", "FromAlias", "FromElemImplicit", "FromImplicit", "func", "global", "ItemAlias", "ItemAssoc", "ItemImplicit", "Key", "KeyImplicit", "Mixin", "name", "Namespace", "Param", "paramname", "paramref", "ref", "Service", "Type", "typeparamname", "Using", "UsingAlias", "variant" ]; export type IdentifierCategory = typeof IdentifierCategories[number]; export type TokenCategory = "Identifier" | "Keyword" | "Operator" | "String" | "number" | "Number" | "Comment" | "LineComment" | "DocComment" | "<EOF>" | "<???>"; export type RelativeToCursor = "tokenAfterCursor" | "tokenStartsAtCursor" | "tokenContainsCursor" | "tokenEndsWithCursor" | "tokenBeforeCursor"; export interface IToken extends LSP.Range, LSP.Position { readonly uri: Uri; readonly category: TokenCategory; readonly text: string; flags: TokenFlags; startOffset: number; readonly endOffset: number; readonly line: number; readonly character: number; readonly endLine: number; readonly endCharacter: number; readonly tokenIndex: number; readonly start: LSP.Position; readonly end: LSP.Position; readonly location: CdsLocation; id: string; isIdentifier(): this is IBaseIdentifierToken; assertIdentifier(): asserts this is IBaseIdentifierToken; isStringLiteral(): this is IBaseStringLiteralToken; isOperator(): boolean; isKeyword(): boolean; isComment(): boolean; isLineComment(): boolean; isBlockComment(): boolean; isDocComment(): any; relativeToCursor(cursor: LSP.Position): RelativeToCursor; isSingleLined(): boolean; compare(position: LSP.Position): number; } export interface IBaseStringLiteralToken extends IToken { category: "String"; translationId?: string; } declare const Builtin: unique symbol; declare const Unknown: unique symbol; declare enum TokenFlags { unknown = 0, definition = 1, reference = 2, annotation = 4, explicitNamespace = 8, implicitNamespace = 16, translationString = 32, usingPath = 64 } export interface IBaseIdentifierToken extends IToken { readonly category: "Identifier"; identifierCategory: IdentifierCategory; localName?: string; absoluteName: FullyQualifiedName; kind: XsnKind; originName?: FullyQualifiedName; originUri?: Uri | typeof Builtin | typeof Unknown; definitionScope?: LSP.Range; isLastPathSegment: boolean; } export interface IRuleToken extends IToken { id: string; ejected?: boolean; text: string; readonly originalText: string; isErrorToken: boolean | unknown; finalizeCategory(rawToken: ParserToken, category: TokenCategory): void; parent: IRuleNode; parentUnmarked: IRuleNode | undefined; getParent(unmarked?: boolean): IRuleNode | undefined; getNextToken(predicate?: (token: IRuleToken) => boolean): IRuleToken | undefined; getPreviousToken(predicate?: (token: IRuleToken) => boolean): IRuleToken | undefined; isCqlKeyword(): boolean; isInlineComment(): boolean; isSingleLined(): boolean; isIdentifier(): this is IBaseIdentifierToken; isFollowUpComment(): boolean; clone(changes: { text?: string; line?: number; character?: number; startOffset?: number; }): IRuleToken; getFollowUpLineEndComment(): any; getLowerLexem(): string; readonly startTokenIndex: number; } export interface IRuleNode { readonly id: string; readonly ruleName: BlockRule; parent?: IRuleNode; children: IRuleItem[]; marked: boolean; parentUnmarked?: IRuleNode; childrenUnmarked: IRuleItem[]; getParent(unmarked?: boolean): IRuleNode | undefined; getChildren(unmarked?: boolean): IRuleItem[]; readonly startTokenIndex: number; readonly endTokenIndex: number; readonly containedTokens: IRuleToken[]; readonly allTokens: IRuleToken[]; readonly context: ITokenContext; data?: Record<string, unknown>; getFirstToken(predicate?: (child: IRuleToken) => boolean, subtreePredicate?: (child: IRuleNode) => boolean): IRuleToken | undefined; getLastToken(predicate?: (child: IRuleToken) => boolean, subtreePredicate?: (child: IRuleNode) => boolean): IRuleToken | undefined; toString(): string; } export type IRuleItem = IRuleNode | IRuleToken; export interface ITokenContext { readonly ruleTokens: IRuleToken[]; messages: XsnMessage[]; } export type ArgumentsRenderer<This> = (args: any, thisArg: This, currentTraceLevel: LspTraceLevel) => string | unknown; export type ResultRenderer<This, Return> = (res: Awaited<Return>, args: any, thisArg: This, currentTraceLevel: LspTraceLevel) => string | unknown; export interface FootprintCustomizer<This, _Return> { traceLevel?: LspTraceLevel; scope?: string; startScope?: string; endScope?: string; argumentsRenderer?: ArgumentsRenderer<This>; resultRenderer?: ResultRenderer<This, any>; trackMemory?: boolean; onlyTraceStart?: boolean; onlyTraceEnd?: boolean; onlyTraceEndIfTakesLongerMs?: number; } export interface ITelemetryData { type: "contributions ready" | "health" | "initialization completed" | "internal compiler error" | "errorTrace" | "statistics" | "scan"; trigger: "internal error trace" | "periodic" | "server start" | "server stop" | "contribution update" | "contribution install"; [x: string]: any; } export interface ITracer { isTracing(level: LspTraceLevel): boolean; debug(m: TraceMessage): void; verbose(m: TraceMessage): void; info(m: TraceMessage): void; warn(m: TraceMessage): void; error(m: TraceMessage): void; footprint<This, Return>(thisArg: This, action: Callback<Return>, args: any[], customizer: FootprintCustomizer<This, Return>): Return; conditionalTrace(_level: LspTraceLevel, _message: TraceMessage): void; } export type Callback<Return> = (...args: any[]) => Return; declare enum LspTraceLevel { invalid = 0, OFF = 1, INFRASTRUCTURE = 2, ERROR = 3, WARNING = 4, INFO = 5, VERBOSE = 6, DEBUG = 7, IGNORE = 8 } declare enum LspTraceComponent { ALL = "*", ADAPTER = "adapter", COMPLETION = "completion", COMPILER = "compiler", CONTRIBUTION = "contribution", DOCUMENTATION = "docs", FORMATTING = "format", MODEL = "model", MODEL_TODOS = "model-todos", REFACTOR = "refactor", REQUESTS = "requests", SETTINGS = "settings", UTIL = "util", TELEMETRY = "telemetry", WORKSPACE = "workspace", FILES = "files", ENV = "cdsenv", COMMAND = "command", CONTEXT_LOG = "context-log" } export interface ITraceConfiguration { name?: string; folder?: AbsolutePath; } export interface ITrace { configure(config: ITraceConfiguration): void; tracer(component: LspTraceComponent): ITracer; conditionalTrace(component: LspTraceComponent, level: LspTraceLevel, message: TraceMessage): void; doTraceToFile(message: string): void; renderMessage(level: LspTraceLevel, component: LspTraceComponent, message: TraceMessage): string; noTraceDuring<T>(f: () => Promise<T>): Promise<T>; traceLevel(component: LspTraceComponent): LspTraceLevel; } export type TraceMessage = () => string; export type WorkspaceRelativeUri = SpecificString<"WorkspaceRelativeUri">; export interface IStatistics { modelFiles: number; tokenCount: number; identifiers: number; definitions: number; references: number; translations: number; messages: number; directDependencies: number; } declare const FILE_DOES_NOT_EXIST: unique symbol; export type T_FILE_DOES_NOT_EXIST = typeof FILE_DOES_NOT_EXIST; export interface IImplicitDefinition extends IGenericDefinition { } export interface IBuiltinDefinition extends IImplicitDefinition { } export interface IFreeAnnotationDefinition extends IImplicitDefinition { } export interface IImplicitNamespaceDefinition extends IImplicitDefinition { location: CdsLocation; nameLocation: CdsLocation; } export interface IAutoexposedDefinition extends IImplicitDefinition { originName: FullyQualifiedName; originUri: Uri; readonly serviceLocation: LSP.Location; } export interface _IPositionIndex<Target> { addOccurrence(target: Target, position: LSP.Position): void; } export interface IRequests { createAndCache<T extends IRequest>(ctor: RequestConstructor<T>): T; } export interface CompilerEvents { internalCompilerError: (stack: string) => void; compilerChanged: (lastUsedCompiler: ICdsCompiler) => void; [x: string]: any; } export interface ICdsTyperWrapper { enqueueAndRun(absPath: AbsolutePath, workspace: _IWorkspaceFolder, fileVersion: number): Promise<void>; enabled: boolean; outputPath: AbsolutePath; } export interface _ICompiler extends TypedEmitter<CompilerEvents> { compile(localPath: AbsolutePath, adapter: _IPathAdapter, files: CdscFileMap, options?: CdscCompileOptions, cacheHandler?: ICacheHandler): Promise<XsnCompileModel>; parse(content: FileContent, localPath: string): { rootNode: IRuleNode; parseAst: XsnParseModel; }; invalidateCacheMisses(): void; } export interface ICacheHandler { onNewCacheEntry(filePath: AbsolutePath, content: FileContent): boolean; } export interface _IDependencyNet { transitiveDependenciesFor(uri: Uri): ReadonlySet<Uri>; onFileChanged(uri: Uri, content: FileContent | T_FILE_DOES_NOT_EXIST, snapshot: _IWorkspaceSnapshot): void; allPotentialUsers(uri: Uri): Generator<Uri>; initFiles(snapshot: _IWorkspaceSnapshot): void; getDirectDependencies(uri: Uri): ReadonlySet<Uri>; } export interface _IPlatformTester { isWindows(): boolean; } export interface Cds extends ModuleOrigin { env: { for: (context: string, cwd: AbsolutePath, _defaults?: boolean) => Env; }; home: AbsolutePath; resolve(modelFile: AbsolutePath, options: any): AbsolutePath[]; } export interface _IPathResolver { resolveId(id: string, rootFolder: AbsolutePath): AbsolutePath | undefined; } export interface _IModuleLoader { _resolvedGlobalSapCdsHome?: AbsolutePath; resolver: _IPathResolver; loadBuiltInCompiler(): ICdsCompiler; loadCompiler(projectRoot: AbsolutePath): ICdsCompiler | never; loadCds(projectRoot: AbsolutePath): Cds; getProjectCdsHome(projectRoot: AbsolutePath): AbsolutePath | undefined; getGlobalCdsHome(): AbsolutePath; } export interface _IPathAdapter { readonly rootUri: Uri; readonly localRootPath: AbsolutePath; toUri(absolutePath: AbsolutePath): Uri; toLocalPath(uri: Uri): AbsolutePath; ensureAbsolutePath(localPath: WorkspaceRelativePath | AbsolutePath): AbsolutePath; } export interface _IEmergencyHooks { install(): void; } export interface _ITelemetry { addTelemetry(data: ITelemetryData): void; start(): boolean; stop(): void; } export interface IInternalAnnotationContribution extends Required<IAnnotationContribution> { name: string; version: string; } export interface _IContributionLoader { loadAnnotationHandlers(afterInstallation: () => void): IInternalAnnotationContribution[] | undefined; } export interface _IWorkspaceDiagnostics { calculateAnnotationDiagnostics(index: IBlitzIndex, uris: Uri[], ast: XsnCompileModel): Promise<Map<Uri, LSP.Diagnostic[]>>; cleanDiagnostics(_workspaceFolderName: string): any; calculateCombinedDiagnosticsAndSend(uri: Uri, fileIndex: _IFileIndex, workspaceVersion: number): Promise<LSP.PublishDiagnosticsParams | null>; } declare const extendedLayers: readonly [ "/", "db", "srv", "app" ]; export interface Env { folders: { [kind in typeof extendedLayers[number]]?: WorkspaceRelativeUri; }; i18n: I18n; cdsc: unknown; rootModels: { [kind in typeof extendedLayers[number]]?: WorkspaceRelativeUri[]; }; lookupDirectories: string[]; } export interface I18n { file: string; folders: string[]; default_language: string; fallback_bundle: string; } declare enum ClientCapability { CLIENT_INFO_NAME = "clientInfo.name", CLIENT_INFO_VERSION = "clientInfo.version", CLIENT_NAME = "clientName", ACTIVE_EDITOR_CHANGED = "capabilities.workspace.cds.didChangeActiveEditor", CHANGE_WATCHED_FILES_REGISTRATION = "capabilities.workspace.didChangeWatchedFiles.dynamicRegistration", CODE_LENS = "capabilities.textDocument.codeLens", CONFIGURATION = "capabilities.workspace.configuration", SUPPORT_PROGRESS = "capabilities.window.workDoneProgress", SEMANTIC_TOKENS = "capabilities.textDocument.semanticTokens", SUPPORT_SNIPPETS = "capabilities.textDocument.completion.completionItem.snippetSupport", SUPPORTED_DOC_FORMATS = "capabilities.textDocument.completion.completionItem.documentationFormat", STATUS_MESSAGE = "capabilities.window.cds.statusMessage", USER_OUTPUT = "capabilities.window.cds.userOutput", WORKSPACEEDIT_DOCUMENTCHANGES = "capabilities.workspace.workspaceEdit.documentChanges" } declare enum UserSetting { CDS_TYPER_OUTPUT_PATH = "cds.typeGenerator.outputPath", CDS_TYPER_ENABLED = "cds.typeGenerator.enabled", CDS_TYPER_LOCAL_INSTALLATION_ONLY = "cds.typeGenerator.localInstallationOnly", CDS_TYPER_COMMAND = "cds.typeGenerator.command", DIAGNOSTICS_LEVEL = "cds.diagnosticsSeverity", WARN_MISSING_TRANSLATIONS = "cds.compiler.markMissingI18nDefault", SHOW_COMPILER_ERRORS = "cds.compiler.showInternalErrors", DOCS_IN_COMPLETION = "cds.completion.showDocumentation", DOCFILES_FOR_COMPLETION = "cds.completion.docFiles", FORMAT_SNIPPETS = "cds.completion.formatSnippets", DOCSYMBOLS_SEMANTICAL = "cds.outline.semantical", WORKSPACESYMBOLS_FOR_COMPLETION_MIN_PREFIX = "cds.completion.workspaceSymbols.minPrefixLength", WORKSPACESYMBOLS_FOR_COMPLETION_MAX_PROPOSALS = "cds.completion.workspaceSymbols.maxProposals", OMIT_REDUNDANT_TYPES_IN_SNIPPETS = "cds.completion.annotations.omitRedundantTypesInSnippets", CONTRIBUTIONS_REGISTRY = "cds.contributions.registry", CONTRIBUTIONS_ANALYTICS_ENABLED = "cds.contributions.enablement.additionalAnalyticalAnnotations", CONTRIBUTIONS_ODATA_ENABLED = "cds.contributions.enablement.odata", IMPORT_ARTIFACT_QUICKFIX = "cds.quickfix.importArtifact", CODE_LENS_STATISTICS = "cds.codeLensStatistics.enabled", SEMANTIC_HIGHLIGHTING = "cds.semanticHighlighting.enabled", REFACTOR_USINGS_ON_RENAME = "cds.refactoring.files.rename.enabled", REFACTOR_USINGS_ON_DELETE = "cds.refactoring.files.delete.enabled", SHOW_GENERIC_ANNOTATIONS = "cds.whereused.showGenericAnnotations", SHOW_STRING_LITERALS = "cds.whereused.showStringConstants", WORKSPACE_DEBOUNCE_FAST_CHANGES = "cds.workspace.debounceFastChanges", WORKSPACE_SCAN_CSN = "cds.workspace.scanCsn", WORKSPACE_SCAN_DEPENDENT_MODULES = "cds.workspace.scanDependentModules", WORKSPACE_VALIDATION_MODE = "cds.workspaceValidationMode", WORKSPACESYMBOLS_LAZY = "cds.workspaceSymbols.lazy", WORKSPACESYMBOLS_CASE_INSENSITIVE = "cds.workspaceSymbols.caseInsensitive", INSPECT_TOKENS = "cds.internal.inspectTokens" } export interface ILspOptions { setClientCapabilities(params: LSP.InitializeParams): void; setUserSettings(params: CdsDidChangeConfigurationParams): void; getClientCapability<T>(name: ClientCapability | string, defaultValue?: any): T; getUserSetting<T>(name: UserSetting): T; setUserSettingTemporarily(name: UserSetting, value: any): void; } export interface _IWorkspaceStateContext { readonly adapter: _IPathAdapter; readonly options: ILspOptions; getCdsEnv(): Env; beforeRescan(): void; dependencyLevel(uri: Uri): number; } export type IWorkspaceDocumentsWithPossibleDeletions = Map<Uri, { content: FileContent | T_FILE_DOES_NOT_EXIST; version: number | null; }>; declare enum WorkspaceValidationMode { ActiveEditorOnly = "ActiveEditorOnly", OpenEditorsOnly = "OpenEditorsOnly" } declare enum WorkspaceScanMode { OpenEditorsAndDirectSources = "OpenEditorsAndDirectSources", OpenEditorsDirectSourcesAndDirectDependencies = "OpenEditorsDirectSourcesAndDirectDependencies" } export interface IIndexContext { singleFile?: boolean; considerOnlyOpenFiles?: boolean; considerOnlyActiveFile?: boolean; onlyDefinitions?: boolean; debounce?: boolean; forceInvalidDependencyCheck?: boolean; uri?: Uri; } export interface _IWorkspaceSnapshot { activeEditor?: Uri; workspaceVersion: number; dependencyNet: _IDependencyNet; files: WorkspaceFiles; readonly context: _IWorkspaceStateContext; streamFiles<T>(predicate?: (file: _IWorkspaceFileVersion) => boolean, mode?: WorkspaceValidationMode | WorkspaceScanMode, mapper?: (file: _IWorkspaceFileVersion) => T): Generator<T>; contentOf(uri: Uri): FileContent | T_FILE_DOES_NOT_EXIST; change(changedDiskDocs?: IWorkspaceDocumentsWithPossibleDeletions, changedOpenDocs?: IWorkspaceDocumentsWithPossibleDeletions, clone?: boolean): _IWorkspaceSnapshot; adapter: _IPathAdapter; reset(): _IWorkspaceSnapshot; isIndexDirty(uri: Uri, context: IIndexContext): boolean; findDirtyUris(context: IIndexContext): Uri[]; sortByRank(uris: Uri[]): Uri[]; fileIndexFor(uri: Uri): _IFileIndex | undefined; ensureScanned(env: Env): Promise<_IWorkspaceSnapshot>; isIgnored(_uri: Uri): boolean; isScanned(): boolean; resolveExplicitPointer(def: IGenericDefinition | IGenericDefinition[]): IGenericDefinition | IGenericDefinition[]; } export type WorkspaceFolderKind = "normal" | "untitled" | "outsider"; export type IWorkspaceUpdated = { formerSnapshot: _IWorkspaceSnapshot; updatedSnapshot: _IWorkspaceSnapshot; }; export type TranslationMap = Map<string, Translation>; declare const annotationNamesForDocumentation: readonly [ "title", "description" ]; export type AnnotationNamesForDocumentation = typeof annotationNamesForDocumentation[number]; export type Domain = AnnotationNamesForDocumentation | "translation" | "annotation domain" | "documentation" | "imports" | "debug"; export interface _IDocumentation { domain: Domain; content: CdsMarkupContent; source?: string; } export interface _ITranslationBroker { translationOf(sourceUri: Uri, translationId: string): Translation | undefined; allTranslationsOf(sourceFileUri: Uri): Translation[]; onTranslationFileChanged(translationFileUri: Uri, content: FileContent | T_FILE_DOES_NOT_EXIST): void; mostRelevantMaintainableTranslationFileFor(sourceUri: Uri): FileUri | undefined; getTranslationIndex(translationFileUri: FileUri): _II18nIndex; resetTranslations(): void; } export interface _IMaintainTranslationArg { sourceFileUri: FileUri; translationFileUri: FileUri; tID: string; range: LSP.Range; text: string; replaceTextWithTranslationKey: boolean; translationType: TranslationType; doCreateTranslationFile: boolean; } export type TranslationType = "XTIT" | "XTOL" | "XMSG"; export interface _II18nIndex { map: TranslationMap; content: FileContent; readonly uri: FileUri; readonly entries: IterableIterator<Translation>; index(cdsEnv: Env, content: FileContent): void; getEntry(tId: string): Translation | undefined; createEntry(cdsEnv: Env, tID: string, translationType: TranslationType, text: string): LSP.TextEdit[]; } declare const ADD_TEXT_HERE = "<add text here>"; export type AddTextHere = typeof ADD_TEXT_HERE; export interface INpmPackageMeta { readonly packageJsonFolderPath: AbsolutePath; readonly name: string; readonly version: string; readonly dependencies: { readonly [name: string]: AbsolutePath | undefined; }; readonly devDependencies: { readonly [name: string]: AbsolutePath | undefined; }; } export interface INpmPackages { getPackageRootFolder(filePath: AbsolutePath): INpmPackageMeta | undefined; getImportPath(sourcePath: AbsolutePath, targetPath: AbsolutePath, folder: _IWorkspaceFolder): UsingPath | undefined; } export interface _IWorkspaceFolder { readonly kind: WorkspaceFolderKind; adapter: _IPathAdapter; name: string; uri: Uri; absolutePath: AbsolutePath; i18n: _ITranslationBroker; documentation: _IDocumentationProvider; readonly npmPackages: INpmPackages; snapshot: _IWorkspaceSnapshot; lastRequestIndependentSnapshot: _IWorkspaceSnapshot; diagnostics: _IWorkspaceDiagnostics; triggerRevalidation(urisChanged?: Uri[]): Promise<{ [uri: Uri]: LSP.Diagnostic[]; }>; readonly env: Env; fetchTransitiveIndex(uri: Uri, context?: IIndexContext): Promise<IBlitzIndex | undefined>; fetchFileIndex(uri: Uri, context?: IIndexContext): Promise<_IFileIndex>; fetchToken(uri: Uri, position: LSP.Position, fetchAnnotationToken?: false | undefined): Promise<IIdentifierToken | IStringLiteralToken | undefined>; fetchToken(uri: Uri, position: LSP.Position, fetchAnnotationToken: true): Promise<IAnnotationAssignmentToken | undefined>; fetchAst(uri: Uri, snapshot?: _IWorkspaceSnapshot): Promise<XsnCompileModel>; contentOf(uri: Uri): FileContent | T_FILE_DOES_NOT_EXIST; ensureScanned(): Promise<_IWorkspaceSnapshot>; progressSnapshot(changedDiskDocuments?: IWorkspaceDocumentsWithPossibleDeletions, changedOpenDocuments?: IWorkspaceDocumentsWithPossibleDeletions, updateCurrentRequestSnapshot?: boolean): IWorkspaceUpdated; readContent(uri: Uri): FileContent | T_FILE_DOES_NOT_EXIST; } export interface _IUsingPathResolver { resolveUsingPath(triggerUri: Uri, importPath: UsingPath, snapshot: _IWorkspaceSnapshot): FileUri | undefined; } export interface WorkspaceServiceEvents { onWorkspaceFolderAdded: (folder: _IWorkspaceFolder) => void; } export interface _IWorkspaceService extends TypedEmitter<WorkspaceServiceEvents> { folderFor(uri: Uri): _IWorkspaceFolder; fileFor(uri: Uri): _IWorkspaceFileVersion | undefined; folders(filter?: (wsf: _IWorkspaceFolder) => boolean): _IWorkspaceFolder[]; readonly workspaceSettingsPath: AbsolutePath | undefined; addFolder(workspaceFolderConfig: LSP.WorkspaceFolder): _IWorkspaceFolder | undefined; removeFolder(rootUri: Uri): void; } declare enum QuickFixCommands { IMPORT_ARTIFACT = "import-artifact", REMOVE_UNUSED_IMPORT = "remove-unused-import", MAINTAIN_TRANSLATION = "maintain-translation", MIGRATE_TO_DOCCOMMENT = "migrate-to-doccomment", MIGRATE_DEPRECATED_DELIMITER = "migrate-deprecated-delimiter", CUSTOM_ANNOTATION_QUICKFIX = "custom-annotation-quickfix" } export type CdsExecuteParams = Omit<MigrateDeprecatedDelimiterCommand | DocCommentCommand | TranslationCommand | RemoveUnusedImportArgsCommand | ImportArtifactCommand, "title"> | IFormatRangeParams | IAnalyzeDependenciesParams | IActiveEditorChangedParams; export interface IQuickFixHandler { readonly id: QuickFixCommands; calculateDiagnostics(uri: string, index: IFileIndex): LSP.Diagnostic[]; createCodeActions(params: LSP.CodeActionParams): Promise<LSP.CodeAction[]>; execute(params: CdsExecuteParams): Promise<any>; } declare const CommandNames: readonly [ "format-range", "analyze-dependencies", "active-editor-changed" ]; export type CommandName = typeof CommandNames[number]; export interface ICommandHandler { readonly id: CommandName; execute(params: LSP.ExecuteCommandParams): Promise<unknown>; } export interface ICdsExecuteCommandParams extends LSP.ExecuteCommandParams { command: CommandName | QuickFixCommands; } export interface IFormatRangeParams extends ICdsExecuteCommandParams { command: "format-range"; arguments: [ IFormatRangeArguments ]; } export interface IFormatRangeArguments { uri: Uri; position: LSP.Position; offsetFromEnd: number; } export interface IAnalyzeDependenciesParams extends ICdsExecuteCommandParams { command: "analyze-dependencies"; arguments: [ IAnalyzeDependenciesArguments ]; } export type IAnalyzeDependenciesArguments = { startModelUri: Uri; detailMode?: DetailMode; } & ({ outputUri: Uri; } | { outputFormat: "svg" | "json"; }); export type DetailMode = "file2file" | "file2folder" | "folder2folder"; export interface IActiveEditorChangedParams extends ICdsExecuteCommandParams { command: "active-editor-changed"; arguments: [ IActiveEditorChangedArguments ]; } export interface IActiveEditorChangedArguments { previousActiveUri: Uri | undefined; newActiveUri: Uri | undefined; } export interface DiagnosticsState { uri: string; workspaceVersion: number; diagnostics: LSP.Diagnostic[]; diagnosticsHash?: string; } export interface IClientProblems { updateFile(uri: Uri, newState: DiagnosticsState | null, currentWorkspaceVersion?: number): LSP.PublishDiagnosticsParams | null; cleanDiagnostics(): { [p: Uri]: LSP.Diagnostic[]; }; getDiagnostics(uri: Uri): LSP.Diagnostic[]; } export interface _ILanguageServer { fetchAnnotationHandlers(): Promise<IInternalAnnotationContribution[]>; formatter: unknown; trace: ITrace; telemetry: _ITelemetry; platformTester: _IPlatformTester; connection?: LS.Connection; requests: IRequests; sendDiagnostics(params: LSP.PublishDiagnosticsParams): Promise<void>; ui: IUserInterface; applyWorkspaceEdits(params: LSP.ApplyWorkspaceEditParams): Promise<LSP.ApplyWorkspaceEditResult>; readonly workspace: _IWorkspaceService; usingPathResolver: _IUsingPathResolver; moduleLoader: _IModuleLoader; options: ILspOptions; quickFixes: Map<QuickFixCommands, IQuickFixHandler>; commands: Map<CommandName, ICommandHandler>; compiler: _ICompiler; cdsTyperWrapper: ICdsTyperWrapper; fileSystem: _IFileSystem; clientProblems: IClientProblems; request<T extends IRequest>(t: RequestConstructor<T>): T; } export declare const UserOutputNotification = "cds/userOutput"; export interface IUserOutputNotification { message: string; revealOutputWindowlIfHidden: boolean; } export declare const StatusMessageNotification = "cds/statusMessage"; export interface IStatusMessageNotification { message: string; millisToShow: number; } export type PopupType = "Information" | "Warning" | "Error"; export interface IUserInterface { output(message: string, revealOutputWindowIfHidden?: boolean): void; status(message: string, millisToShow?: number): void; notification(message: string, type?: LSP.MessageType): void; popup(type: PopupType, message: string, ...buttons: string[]): Promise<string>; } export interface _ILanguageServerEx extends _ILanguageServer { registerRequestHandlers(connection: LS._Connection): void; } export type RequestConstructor<T extends IRequest> = new (ls: _ILanguageServer) => T; export interface IRequest { readonly server: _ILanguageServer; } export interface _IDocumentationProvider { streamTokenDocumentation(genericToken: IGenericToken, snapshot: _IWorkspaceSnapshot): IterableIterator<_IDocumentation>; streamDefinitionDocumentations(sourceUri: Uri, definitions: IGenericDefinition[]): IterableIterator<_IDocumentation>; } export interface _IWorkspaceFileVersion { content: FileContent; version: number | null; fileIndex?: _IFileIndex; readonly uri: Uri; readonly localPath: AbsolutePath; isOpen: boolean; readonly isOutsider: boolean; progress(newContent: FileContent, version: number | null, isOpen: boolean): _IWorkspaceFileVersion; } export type WorkspaceFiles = Map<Uri, _IWorkspaceFileVersion>; export interface IAnnotationHandlerProvider { getAnnotationHandlers(): IInternalAnnotationContribution[]; } export interface ImplicitDefinitions { builtIns: { [absoluteName: FullyQualifiedName]: IBuiltinDefinition; }; implicitNamespaces: { [absoluteName: FullyQualifiedName]: IImplicitNamespaceDefinition; }; annotationDefinitionPointers: { [absoluteName: FullyQualifiedName]: IFreeAnnotationDefinition; }; } export interface IFactory { createAnnotationHandlerProvider(server: _ILanguageServer): IAnnotationHandlerProvider; createOptions(): ILspOptions; getTrace(): ITrace; getEmergencyHooks(): _IEmergencyHooks; getPlatformTester(): _IPlatformTester; getModuleLoader(resolvedGlobalSapCdsHome?: AbsolutePath): _IModuleLoader; createPathAdapter(clientRootUri: Uri, localRootPath?: AbsolutePath): _IPathAdapter; createServer(): _ILanguageServerEx; createWorkspace(server: _ILanguageServer): _IWorkspaceService; createFolder(kind: "outsider" | "untitled", server: _ILanguageServer): _IWorkspaceFolder; createFolder(kind: "normal" | WorkspaceFolderKind, server: _ILanguageServer, name: string, adapter: _IPathAdapter): _IWorkspaceFolder; createSnapshot(context: _IWorkspaceStateContext, scanning: boolean): _IWorkspaceSnapshot; createCompiler(options: ILspOptions, loader: _IModuleLoader): _ICompiler; createCdsTyperWrapper(server: _ILanguageServer): ICdsTyperWrapper; createTelemetry(connection: _Connection): _ITelemetry; getContributionLoader(): _IContributionLoader; createDependencyNet(workspaceRoot: AbsolutePath): _IDependencyNet; createFileIndex(uri: Uri, workspaceVersion: number, _implicitDefinitions: ImplicitDefinitions): _IFileIndex; getFileSystem(): _IFileSystem; createToolbox(compiler: ICdsCompiler, adapter: _IPathAdapter): IXsnToolbox; } declare enum LspFileType { Unrelated = "Unrelated", PackageJson = "PackageJson", IgnoreFile = "IgnoreFile", TranslationDefinitions = "TranslationDefinitions", CdsSource = "CdsSource", CsnFile = "CsnFile", CdsEnv = ".cdsrc.json" } export interface _IFileSystem { isTranslationFile(cdsEnv: Env, uriOrFilepath: Uri | AbsolutePath): boolean; isPackageJsonFile(uriOrFilepath: Uri | AbsolutePath): boolean; typeofFile(uri: Uri, cdsEnv: Env, getContent: () => FileContent | T_FILE_DOES_NOT_EXIST): LspFileType; isCsnFileByExtension(uriOrFilepath: Uri | AbsolutePath): boolean; isCsnFile(uriOrFilepath: Uri | AbsolutePath, getContent: () => FileContent | T_FILE_DOES_NOT_EXIST): boolean; isCdsEnvFile(uri: Uri | AbsolutePath): boolean; isIgnoreFile(uriOrFilepath: Uri | AbsolutePath): boolean; isCdsSourceFile(uriOrFilepath: Uri | AbsolutePath): boolean; isCdsFile(uriOrFilepath: Uri | AbsolutePath, content?: FileContent | T_FILE_DOES_NOT_EXIST): boolean; isFileSystemRoot(abs: AbsolutePath): boolean; existsSync(p: AbsolutePath): boolean; readFile(path: AbsolutePath): Promise<FileContent>; readFileSync(path: AbsolutePath): FileContent; writeFileSync(path: PathLike, data: FileContent | NodeJS.ArrayBufferView, options?: WriteFileOptions): void; copyFile(src: PathLike, dest: PathLike, flags?: number): Promise<void>; unlinkSync(p: PathLike): void; mkdir(p: PathLike): Promise<AbsolutePath | undefined>; mkdirSync(p: PathLike): void; mkdtempSync(prefix: string): AbsolutePath; rmdir(p: PathLike): Promise<void>; rmdirSync(p: PathLike): void; readdirSync(path: PathLike, withFileTypes?: false, recursive?: boolean): string[]; readdirSync(path: PathLike, withFileTypes: true, recursive?: boolean): Dirent[]; readdirSync(path: PathLike, withFileTypes?: boolean, recursive?: boolean): string[] | Dirent[]; statSync(p: PathLike): Stats | undefined; lstatSync(p: PathLike): Stats | undefined; realpathSync(p: PathLike): AbsolutePath; realpathSyncNative(p: PathLike): AbsolutePath; stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; stat(path: PathLike, options: StatOptions & { bigint?: false | undefined; } | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; stat(path: PathLike, options: StatOptions & { bigint: true; }, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void; stat(path: PathLike, options: StatOptions | undefined, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void; homedir(): AbsolutePath; } export interf