@sap/cds-lsp
Version:
Language server for CDS
1,470 lines (1,469 loc) • 60.6 kB
TypeScript
import { BigIntStats, Dirent, PathLike, StatOptions, Stats, WriteFileOptions } from 'node:fs';
import { TypedEmitter } from 'tiny-typed-emitter';
import * as LS from 'vscode-languageserver';
import { Connection, _, _Connection } from 'vscode-languageserver';
import * as LSP from 'vscode-languageserver-protocol';
import { ConnectionOptions, ConnectionStrategy } from 'vscode-languageserver-protocol/node';
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 type XsnDependencies = Array<{
location: XsnLocation;
val: UsingPath;
}>;
export interface XsnParseModel {
dependencies?: XsnDependencies;
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;
withCst?: boolean;
}
export interface CdscCompileOptions {
fallbackParser?: "cds";
attachValidNames?: boolean;
attachTokens?: boolean;
lspMode?: boolean;
docComment?: boolean;
messages?: XsnMessage[];
parseListener?: unknown;
newParser?: boolean;
abortSignal?: AbortSignal;
}
export interface ModuleOrigin {
__loadedFrom: AbsolutePath;
__logicalLocation: string;
}
export interface ICdsCompiler extends ModuleOrigin {
parse(source: FileContent, filename: string, options?: CdscParseOptions): XsnParseModel;
parse(source: FileContent, filename: string, options: CdscParseOptions & {
withCst: true;
}): XsnParseModel;
compile(fileNames: AbsolutePath[], dir?: AbsolutePath, options?: CdscCompileOptions, map?: CdscFileMap): Promise<XsnCompileModel>;
version(): string;
$lsp: ICdsCompiler;
explainMessage: (messageId: string) => string | undefined;
getMessageExplanationUri: (messageId: string) => Uri | undefined;
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 interface IXsnToolbox {
toUri(localPath: WorkspaceRelativePath | AbsolutePath): Uri;
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;
usingsOf(source: XsnSource): XsnArtifactUsing[];
getSemanticTokenOrigin(o: XsnReferenceEvent): XsnArtifact[];
getDefinitionOrigin(o: XsnDefinitionEvent): unknown[];
getAnnotationParseTrees(o: any): XsnAnnotationAssignment[];
toLspLocation(csnLocation: XsnLocation): CdsLocation;
}
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: UsingPath;
}
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;
_parent: XsnArtifact;
localized?: {
location: XsnLocation;
val: unknown;
};
}
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" | "namespace-statement";
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 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 IGenericDefinition {
readonly symbolName: FullyQualifiedName;
readonly fullyQualifiedName: FullyQualifiedName;
readonly kind: XsnKind;
readonly absoluteName: FullyQualifiedName;
}
export interface IIdentifierToken extends IGenericToken {
}
export interface IFileIndex {
directDependentUris: FileUri[];
readonly annotationAssignments: IterableIterator<IAnnotationAssignmentToken>;
readonly content: FileContent;
readonly tokens: IToken[];
}
export interface IToken extends LSP.Position {
readonly text: string;
startOffset: number;
readonly endOffset: number;
readonly line: number;
readonly character: number;
readonly endLine: number;
readonly endCharacter: number;
readonly tokenIndex: number;
isIdentifier(): boolean;
isOperator(): boolean;
isKeyword(): boolean;
isStringLiteral(): boolean;
isComment(): boolean;
}
export interface IBlitzIndex {
readonly builtUris: readonly Uri[];
getTransitiveDependencies(uri: Uri): Set<Uri>;
forUri(uri: Uri, create?: undefined | "create" | "warnCreate"): IFileIndex;
forUri(uri: Uri, 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;
signal?: AbortSignal;
}
export interface CdsAnnotationIndexEntry {
absoluteName: string;
definition: CdsLocation;
references: CdsLocation[];
}
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;
signal?: AbortSignal;
}
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>;
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" | "errorTrace" | "statistics" | "scan" | "cap-project-insights" | "user settings";
trigger: "internal error trace" | "periodic" | "server start" | "server stop" | "contribution update" | "contribution install";
status: "report" | "success" | "error" | "success(installed)" | "success(updated)" | "error(installation failed)" | "report(outdated)";
[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",
PERSISTENCY = "persistency",
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;
declare const TokenCategories: readonly [
"Identifier",
"Keyword",
"Operator",
"String",
"Number",
"Comment",
"LineComment",
"DocComment",
"<???>"
];
export type TokenCategory = typeof TokenCategories[number] | "<EOF>";
export type RelativeToCursor = "tokenAfterCursor" | "tokenStartsAtCursor" | "tokenContainsCursor" | "tokenEndsWithCursor" | "tokenBeforeCursor";
declare enum TokenFlags {
unknown = 0,
definition = 1,
reference = 2,
annotation = 4,
explicitNamespace = 8,
implicitNamespace = 16,
translationString = 32,
usingPath = 64,
extend = 128,
aspect = 256,
texts = 512,
hasAutoexposedEntities = 1024,
annotationModelerXRef = 2048,
association = 4096,
composition = 8192,
federated = 16384,
codeList = 32768,
externalService = 65536,
domainModel = 131072,
autoexposedEntity = 262144,
action = 524288,
view = 1048576
}
export interface _IToken extends IToken, LSP.Range {
readonly uri: Uri;
readonly category: TokenCategory;
flags: TokenFlags;
readonly start: LSP.Position;
readonly end: LSP.Position;
readonly location: CdsLocation;
readonly range: LSP.Range;
isIdentifier(): this is IBaseIdentifierToken;
assertIdentifier(): asserts this is IBaseIdentifierToken;
isLocalizedDefinition(): this is IBaseLocalizedDefinitionToken;
isStringLiteral(): this is IBaseStringLiteralToken;
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 = "<<builtin>>";
declare const Unknown = "<<unknown>>";
export interface IIdentifierTokenInfo {
category: "Identifier";
identifierCategory: IdentifierCategory;
localName?: string;
absoluteName: FullyQualifiedName;
kind?: XsnKind;
originName?: FullyQualifiedName;
originUri?: Uri | typeof Builtin | typeof Unknown;
definitionRange?: LSP.Range;
isLastPathSegment: boolean;
}
export interface IBaseIdentifierToken extends _IToken {
_id: IIdentifierTokenInfo;
}
export interface IBaseLocalizedDefinitionToken extends _IToken {
absoluteName: FullyQualifiedName;
}
export interface IBaseDefinitionToken extends IBaseIdentifierToken {
_id: IBaseIdentifierToken["_id"] & {
_doc?: {
comment?: string;
title?: string;
description?: string;
};
};
}
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 interface ParserToken {
tokenIndex: number;
start: number;
type: string;
parsedAs?: IdentifierCategory;
isIdentifier?: string;
text: string;
location: XsnLocation;
}
declare const RelevantGrammarRuleNames: readonly [
"actionMainDef",
"annoAssignBase",
"annoAssignParen",
"annoAssignStd",
"annoAssignCol",
"annoAssignMid",
"annotateArtifact",
"annotateElementsBlock",
"annotateElement",
"annotationDef",
"annoValue",
"annoSubValue",
"annoStructValue",
"artifactDefOrExtend",
"aspectDef",
"boundActionFunctionDef",
"cardinalityAndFilter",
"caseExpression",
"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 IRuleToken extends _IToken {
readonly id: string;
ejected?: boolean;
text: string;
readonly originalText: string;
isErrorToken: unknown | undefined;
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 interface _IEmergencyHooks {
install(): void;
}
export interface IAnnotationHandlerProvider {
getAnnotationHandlers(): IInternalAnnotationContribution[] | undefined;
}
export interface _ILanguageServerEx extends _ILanguageServer {
clientInfo?: {
name: string;
version?: string;
};
registerRequestHandlers(connection: LS._Connection): void;
}
export interface IPersistency {
persist(fileIndex: _IFileIndex, force?: boolean): Promise<AbsolutePath | undefined>;
restore(fileVersion: _IWorkspaceFileVersion): Promise<_IFileIndex | undefined>;
}
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(id?: string): _ILanguageServerEx;
createWorkspace(server: _ILanguageServer): _IWorkspaceService;
createFormatter(tracer: ITracer): unknown;
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(adapter: _IPathAdapter): _IDependencyNet;
getFileSystem(): _IFileSystem;
createToolbox(compiler: ICdsCompiler, adapter: _IPathAdapter): IXsnToolbox;
createPersistency(): IPersistency;
}
export interface _IContributionLoader {
loadAnnotationHandlers(afterInstallation: () => void): IInternalAnnotationContribution[] | undefined;
}
export interface _ITelemetry {
addTelemetry(data: ITelemetryData): void;
start(): void;
stop(): void;
reportError(err: string): void;
fetchEnabled(): Promise<boolean>;
}
export interface ICacheHandler {
onNewCacheEntry(filePath: AbsolutePath, content: FileContent): boolean;
}
export interface _ICompiler extends TypedEmitter<CompilerEvents> {
compile(localPath: AbsolutePath, adapter: _IPathAdapter, files: CdscFileMap, options?: CdscCompileOptions, cacheHandler?: ICacheHandler): Promise<XsnCompileModel>;
parse(content: FileContent, localPath: string, withCst: true): {
rootNode: IRuleNode;
parseAst: XsnParseModel;
};
parse(content: FileContent, localPath: string, withCst?: false): {
parseAst: XsnParseModel;
};
invalidateCacheMisses(): void;
}
export interface _IFileSystem {
isTranslationFile(cdsEnv: Env, uriOrFilepath: Uri | AbsolutePath): boolean;
isPackageJsonFile(uriOrFilepath: Uri | AbsolutePath): boolean;
typeofFile(uri: Uri, cdsEnv: Env): LspFileType;
isCsnFileByFileName(uriOrFilepath: Uri | AbsolutePath): boolean;
isCsnFile(uriOrFilepath: Uri | AbsolutePath): boolean;
setCsnFile(absolutePath: AbsolutePath): void;
isCdsEnvFile(uri: Uri | AbsolutePath): boolean;
isIgnoreFile(uriOrFilepath: Uri | AbsolutePath): boolean;
isCdsSourceFile(uriOrFilepath: Uri | AbsolutePath): boolean;
isCdsFile(uriOrFilepath: Uri | AbsolutePath): 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 interface IRequests {
assembleServerCapabilities(clientCapabilities: LSP.ClientCapabilities): LSP.ServerCapabilities;
}
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 _IPlatformTester {
isWindows(): boolean;
}
export interface _IUsingPathResolver {
resolveUsingPath(triggerUri: Uri, importPath: UsingPath, snapshot: _IWorkspaceSnapshot): FileUri | undefined;
}
export interface _IWorkspaceFolder {
readonly kind: WorkspaceFolderKind;
adapter: _IPathAdapter;
name: string;
uri: Uri;
absolutePath: AbsolutePath;
i18n: _ITranslationBroker;
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): Promise<_IToken | 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;
registerFileWatching(enable: boolean): 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;
}
export type AnnotationContributionFeature = "__force__" | UserSetting.CONTRIBUTIONS_HOVER | UserSetting.CONTRIBUTIONS_COMPLETION | UserSetting.CONTRIBUTIONS_INDEX | UserSetting.CONTRIBUTIONS_DIAGNOSTICS | UserSetting.CONTRIBUTIONS_QUICKFIXES | UserSetting.CONTRIBUTIONS_SEMANTICTOKENS;
export interface IOneTimeEvent<T, U> {
emit(val: T): void;
then(handler: (val: T) => U): Promise<U>;
}
export interface _ILanguageServer {
clientProcessId?: number | null;
clientLocale?: string;
readonly clientName: string;
readonly clientVersion: string;
initialized: IOneTimeEvent<void, void>;
fetchAnnotationHandlers(...requiredFeatures: AnnotationContributionFeature[]): 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 | undefined>;
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;
documentation: _IDocumentationProvider;
request<T extends IRequest>(t: RequestConstructor<T>): T;
safeTriggerAsync(p: Promise<unknown>, stack?: string): void;
}
export interface IgnoreRule {
pattern: string;
mark?: string;
negative: boolean;
}
export interface _IgnoreManager {
isIgnored(absolutePath: AbsolutePath): boolean | IgnoreRule;
}
export interface _IPathAdapter {
readonly ignoreManager: _IgnoreManager;
readonly rootUri: Uri;
readonly localRootPath: AbsolutePath;
toUri(absolutePath: AbsolutePath): Uri;
toLocalPath(uri: Uri): AbsolutePath;
ensureAbsolutePath(localPath: WorkspaceRelativePath | AbsolutePath): AbsolutePath;
}
declare enum UserSetting {
CDS_TYPER_OUTPUT_PATH = "cds.typeGenerator.outputPath",
CDS_TYPER_ENABLED = "cds.typeGenerator.enabled",
CDS_TYPER_COMMAND = "cds.typeGenerator.command",
DIAGNOSTICS_LEVEL = "cds.diagnosticsSeverity",
WARN_MISSING_TRANSLATIONS = "cds.compiler.markMissingI18nDefault",
SHOW_COMPILER_ERRORS = "cds.compiler.showInternalErrors",
SHOW_COMPILED_FILES_IN_USER_OUTPUT = "cds.compiler.showCompiledFilesInUserOutput",
DOCS_IN_COMPLETION = "cds.completion.showDocumentation",
DOCFILES_FOR_COMPLETION = "cds.completion.docFiles",
FORMAT_SNIPPETS = "cds.completion.formatSnippets",
DOCSYMBOLS_SEMANTICAL = "cds.outline.semantical",
DOCSYMBOLS_ASSOCIATION_COMPOSITION = "cds.outline.elements.associationComposition",
WORKSPACESYMBOLS_FOR_COMPLETION_MIN_PREFIX = "cds.completion.workspaceSymbols.minPrefixLength",
WORKSPACESYMBOLS_FOR_COMPLETION_MAX_PROPOSALS = "cds.completion.workspaceSymbols.maxProposals",
WORKSPACESYMBOLS_FOR_COMPLETION_USE_SHORTNAME = "cds.completion.workspaceSymbols.useShortname",
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",
CONTRIBUTIONS_HOVER = "cds.contributions.features.hover",
CONTRIBUTIONS_INDEX = "cds.contributions.features.index",
CONTRIBUTIONS_DIAGNOSTICS = "cds.contributions.features.diagnostics",
CONTRIBUTIONS_COMPLETION = "cds.contributions.features.completion",
CONTRIBUTIONS_SEMANTICTOKENS = "cds.contributions.features.semanticHighlighting",
CONTRIBUTIONS_QUICKFIXES = "cds.contributions.features.quickFixes",
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_PERSISTENCY_ENABLED = "cds.workspace.persistency.enabled",
WORKSPACE_PERSIST_INDEX_AFTER_SAVE = "cds.workspace.persistency.persistAfterSave",
WORKSPACE_PERSIST_INDEX_AFTER_COMPILE = "cds.workspace.persistency.persistAfterCompile",
WORKSPACE_RESTORE_INDEX_BEFORE_COMPILE = "cds.workspace.persistency.restoreBeforeCompile",
WORKSPACE_RESTORE_INDEX_AFTER_STARTUP = "cds.workspace.persistency.restoreAfterStartup",
WORKSPACE_INDEX_AFTER_STARTUP = "cds.workspace.persistency.indexAllAfterStartup",
WORKSPACE_GARBAGE_COLLECT_INDEX_AFTER_STARTUP = "cds.workspace.persistency.garbageCollectOrphanedIndexesAfterStartup",
WORKSPACE_GARBAGE_COLLECT_INDEX_AFTER_N_SAVES = "cds.workspace.persistency.garbageCollectOrphanedIndexesAfterNSaves",
WORKSPACE_INDEX_ALWAYS_AFTER_COMPILE_IF_RESTORED = "cds.workspace.persistency.reindexAfterCompileIfRestored",
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",
TELEMETRY_ENABLED = "sapbas.telemetryEnabled",
INSPECT_TOKENS = "cds.internal.inspectTokens"
}
export interface CompilerEvents {
internalCompilerError: (stack: string) => void;
compilerChanged: (lastUsedCompiler: ICdsCompiler) => void;
[x: string]: any;
}
export type WorkspaceRelativeUri = SpecificString<"WorkspaceRelativeUri">;
declare const EXTENDED_LAYERS: readonly [
"/",
"db",
"srv",
"app"
];
export interface Env {
folders: {
[kind in typeof EXTENDED_LAYERS[number]]?: WorkspaceRelativeUri;
};
i18n: I18n;
cdsc: unknown;
rootModels: {
[kind in typeof EXTENDED_LAYERS[number]]?: WorkspaceRelativeUri[];
};
build?: {
tasks?: Array<{
for?: "hana" | "nodejs" | "java" | "mtx" | "mtx-sidecar" | "mtx-extension" | "sqlite";
src?: WorkspaceRelativePath;
options?: {
model?: WorkspaceRelativePath[];
};
}>;
};
requires?: {
[name: string]: {
model?: string;
};
};
lookupDirectories: string[];
}
export interface I18n {
file: string;
folders: string[];
default_language: string;
fallback_bundle: string;
}
declare const FILE_DOES_NOT_EXIST: unique symbol;
export type T_FILE_DOES_NOT_EXIST = typeof FILE_DOES_NOT_EXIST;
declare enum LspFileType {
Unrelated = "Unrelated",
PackageJson = "PackageJson",
IgnoreFile = "IgnoreFile",
TranslationDefinitions = "TranslationDefinitions",
CdsSource = "CdsSource",
CsnFile = "CsnFile",
CdsEnv = ".cdsrc.json"
}
export interface IRequest {
serverCapabilitiesFor(clientCapabilities: LSP.ClientCapabilities): LSP.ServerCapabilities;
readonly server: _ILanguageServer;
onConnect(connection: Connection): void;
}
export type RequestConstructor<T extends IRequest> = new (ls: _ILanguageServer) => T;
export interface Cds extends ModuleOrigin {
env: {
for: (context: string, cwd: AbsolutePath, _defaults?: boolean) => Env;
};
home: AbsolutePath;
resolve(modelFile: AbsolutePath, options: any): AbsolutePath[];
}
export interface _IDependencyNet {
transitiveDependenciesFor(uri: Uri): ReadonlySet<Uri>;
onFileChanged(uri: Uri, content: FileContent | T_FILE_DOES_NOT_EXIST, snapshot: _IWorkspaceSnapshot, model?: XsnCompileModel): void;
allPotentialUsers(uri: Uri): Generator<Uri>;
initFiles(snapshot: _IWorkspaceSnapshot): void;
getDirectDependencies(uri: Uri): ReadonlySet<Uri>;
}
export type WorkspaceFiles = Map<Uri, _IWorkspaceFileVersion>;
export interface _IWorkspaceStateContext {
readonly adapter: _IPathAdapter;
readonly options: ILspOptions;
getCdsEnv(uri: Uri): Env;
beforeRescan(): void;
dependencyLevel(uri: Uri): number;
}
declare enum WorkspaceValidationMode {
ActiveEditorOnly = "ActiveEditorOnly",
OpenEditorsOnly = "OpenEditorsOnly"
}
declare enum WorkspaceScanMode {
OpenEditorsAndDirectSources = "OpenEditorsAndDirectSources",
OpenEditorsDirectSourcesAndDirectDependencies = "OpenEditorsDirectSourcesAndDirectDependencies"
}
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>;
isScanned(): boolean;
definitionOf(token: _IToken): IBaseDefinitionToken | typeof Builtin | undefined;
}
export type WorkspaceFolderKind = "normal" | "untitled" | "outsider";
export type IWorkspaceUpdated = {
formerSnapshot: _IWorkspaceSnapshot;
updatedSnapshot: _IWorkspaceSnapshot;
};
export interface IStatistics {
modelFiles: number;
tokenCount: number;
identifiers: number;
definitions: number;
references: number;
translations: number;
messages: number;
directDependencies: number;
}
export interface _IFileIndex extends IFileIndex {
usingStatistics: ImportedItem[];
_diagnosticState?: DiagnosticsState;
compilerVersion: string;
compilerMessages: LSP.Diagnostic[];
readonly workspaceVersion: number;
readonly isInvalidByChangedContent: boolean;
getAnnotationDiagnostics(): Readonly<LSP.Diagnostic[]>;
setAnnotationDiagnostics(diags: Readonly<LSP.Diagnostic[]>): void;
_statistics: IStatistics;
readonly _implicitDefinitions: ImplicitDefinitions;
tokens: _IToken[];
readonly uri: Uri;
staleContent(): void;
identifierAt(position: LSP.Position): IBaseIdentifierToken | undefined;
addAnnotationAssignment(location: LSP.Location, embeddedAnnotation: string, carrier: IBaseDefinitionToken, carrierName: string, carrierNameRange: LSP.Range): void;
correspondingStringTokens(text: string): IBaseStringLiteralToken[];
stringAt(position: LSP.Position): IBaseStringLiteralToken | undefined;
streamDefinitions(): Generator<IBaseDefinitionToken, void, undefined>;
readonly identifierTokens: IBaseIdentifierToken[];
readonly definitionTokens: IBaseDefinitionToken[];
readonly stringLiteralTokens: IBaseStringLiteralToken[];
readonly translationTokens: IBaseStringLiteralToken[];
readonly usingPathTokens: IBaseStringLiteralToken[];
}
export interface ImplicitDefinitions {
implicitNamespaces: {
[absoluteName: FullyQualifiedName]: IImplicitNamespaceDefinition;
};
}
export interface IImplicitDefinition extends IGenericDefinition {
}
export interface IImplicitNamespaceDefinition extends IImplicitDefinition {
location: CdsLocation;
nameLocation: CdsLocation;
}
export interface CdsDidChangeConfigurationParams extends LSP.DidChangeConfigurationParams {
settings: {
cds?: {
autoInstallDependencies?: boolean;
compiler?: {
markMissingI18nDefault?: boolean;
showInternalErrors?: boolean;
};
completion?: {
showDocumentation?: boolean;
docFiles?: string[];
annotations?: {
omitRedundantTypesInSnippets?: boolean;
};
};
contributions?: {
registry?: string;
enablement?: {
odata?: boolean;
};
features?: {
hover?: boolean;
index?: boolean;
diagnostics?: boolean;
completion?: boolean;
semanticTokens?: boolean;
quickFixes?: boolean;
};
};
diagnosticsSeverity?: DiagnosticSeverity;
workspace?: {
scanDependentModules: boolean;
};
workspaceSymbols?: {
lazy: boolean;
};
workspaceValidationMode?: WorkspaceValidationMode;
};
};
}
export type DiagnosticSeverity = "Error" | "Warning" | "Info" | "Debug";
export interface ImportedItem {
statementId: number;
absoluteName: FullyQualifiedName;
localName: string;
localImportLocation: LSP.Range;
from: {
statementRange?: LSP.Range;
targetUri?: Uri;
targetImportPath?: UsingPath;
};
references: _IToken[];
}
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 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[];
}
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 _IWorkspaceDiagnostics {
calculateAnnotationDiagnostics(index: IBlitzIndex, uris: Uri[], ast: XsnCompileModel, signal: AbortSignal): Promise<Map<Uri, LSP.Diagnostic[]>>;
cleanDiagnostics(_workspaceFolderName: string): any;
calculateCombinedDiagnosticsAndSend(uri: Uri, fileIndex: _IFileIndex, workspaceVersion: number): Promise<LSP.PublishDiagnosticsParams | null>;
}
export interface IIndexContext {
singleFile?: boolean;
considerOnlyOpenFiles?: boolean;
considerOnlyActiveFile?: boolean;
onlyDefinitions?: boolean;
forceInvalidDependencyCheck?: boolean;
uri?: Uri;
}
export type IWorkspaceDocumentsWithPossibleDeletions = Map<Uri, {
content: FileContent | T_FILE_DOES_NOT_EXIST;
textDocumentVersion: number | null;
}>;
export interface WorkspaceServiceEvents {
onWorkspaceFolderAdded: (folder: _IWorkspaceFolder) => void;
}
export interface _IWorkspaceFileVersion {
content: FileContent;
textDocumentVersion: number | null;
fileIndex?: _IFileIndex;
readonly uri: Uri;
readonly localPath: AbsolutePath;
isOpen: boolean;
readonly isOutsider: boolean;
progress(newContent: FileContent, textDocumentVersion: number | null, isOpen: boolean): _IWorkspaceFileVersion;
}
export interface IInternalAnnotationContribution extends Required<IAnnotationContribution> {
name: string;
version: string;
}
export type PopupType = "Information" | "Warning" | "Error";
export interface IUserInterface {
output(message: string, revealOutputWindowIfHidden?: boolean): void;
status(message: string, id: string, millisToShow?: number): void;
noti