Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sap/cds-lsp

Package Overview
Dependencies
Maintainers
0
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap/cds-lsp - npm Package Compare versions

Comparing version 7.9.1 to 8.0.0

16

CHANGELOG.md

@@ -10,5 +10,19 @@ # Changelog

## 7.9.1 - 2024-05-06
## 8.0.0 - 2024-06-25
### Changed
- cds-lsp will use embedded cds-compiler (v5) if compiler in workspace is < v5
### Fixed
- highlighting of annotations after bracketed expressions
- exception in graphical file dependency analysis
- node version check now runs outside bundle
### Also see
- `@sap/cds-compiler` 5.0.4
## 7.9.1 - 2024-05-10
### Fixed
- `annotate` elements snippet now functions correctly near annotations to elements

@@ -15,0 +29,0 @@

342

dist/contributions.d.ts

@@ -17,8 +17,9 @@ import * as LSP from 'vscode-languageserver-protocol';

export declare function path_isAbsolute(p: string): p is AbsolutePath;
export declare function path_dirname(p: AbsolutePath): `/${string}`;
export declare function path_resolve(...paths: string[]): `/${string}`;
export declare function path_dirname(p: AbsolutePath): AbsolutePath;
export declare function path_resolve(...paths: string[]): AbsolutePath;
export declare function path_relative(from: AbsolutePath, to: AbsolutePath): RelativePath;
export declare function path_normalize<T extends AbsolutePath | RelativePath>(p: T): T;
export declare function process_cwd(): `/${string}`;
export type Kind = "context" | "service" | "namespace" | "entity" | "event" | "view" | "type" | "annotation" | "annotate" | "action" | "function" | "const" | "role" | "aspect" | "accesspolicy" | "mixin" | "element" | "query" | "param" | "enum" | "source" | "using" | "extend" | "qualifiedAnnotation";
export declare function process_cwd(): AbsolutePath;
export 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 {

@@ -32,35 +33,14 @@ kind: XsnKind;

}
export interface CdsvTextPosition {
line: number;
column: number;
}
export interface CdsvLocation {
start: CdsvTextPosition;
end: CdsvTextPosition;
filename?: string;
}
export interface CdsvDefinitionName {
absolute: string;
id?: string;
location?: CdsvLocation;
}
export interface WithXsnLocation {
export interface XsnValidName {
kind: XsnKind;
name: {
absolute: string;
id?: string;
};
location: XsnLocation;
}
export interface CdsvArtifact extends WithXsnLocation {
kind: CdsvKind;
name: CdsvDefinitionName;
}
export interface CdsvDefinition extends CdsvArtifact {
elements?: CdsvArtifact[];
builtin?: boolean;
internal?: boolean;
expectedKind?: string;
parameters?: string[];
annotationAssignments?: any[];
artifacts?: CdsvDefinitions;
vocabularies?: CdsvDefinitions;
}
export type CsnSeverity = "Error" | "Warning" | "Info" | "Debug";
export interface XsnParseModel extends CdsvAstNode {
export type XsnSeverity = "Error" | "Warning" | "Info" | "Debug";
export interface XsnParseModel {
dependencies?: Array<{

@@ -70,31 +50,13 @@ location: XsnLocation;

}>;
options: CdsvParseOptions;
options: CdscParseOptions;
tokens: unknown[];
ruleTree: unknown;
toolbox: IXsnToolbox;
namespace?: {
path?: Array<{
id: string;
}>;
name: {
id: string;
};
}
export interface CdsvAstNodeName {
id: string;
}
export interface CdsvAstNode {
artifacts?: {
[localName: string]: CdsvAstNode;
};
extensions?: CdsvAstNode[];
elements?: CdsvAstNode[];
name: CdsvAstNodeName;
kind: CdsvKind;
location: CdsvLocation;
kind: XsnKind;
annotationAssignments?: XsnAnnotationAssignment[];
}
export interface CdsvDefinitions {
[id: string]: CdsvDefinition;
}
export type CdsvKind = "context" | "entity" | "extend" | "element" | "namespace" | "using" | "service" | "source" | "type" | "view";
export interface CdsvParseOptions {
export interface CdscParseOptions {
parseOnly?: boolean;

@@ -108,6 +70,7 @@ lintMode?: boolean;

}
export interface CdsvCompileOptions {
export interface CdscCompileOptions {
fallbackParser?: "cds";
attachValidNames?: boolean;
attachTokens?: boolean;
lspMode?: boolean;
docComment?: boolean;

@@ -122,34 +85,15 @@ messages?: XsnMessage[];

export interface ICdsCompiler extends ModuleOrigin {
parse(source: FileContent, filename: string, options?: CdsvParseOptions): XsnParseModel;
compile(fileNames: AbsolutePath[], dir?: AbsolutePath, options?: CdsvCompileOptions, map?: CdsvSourceDictionary): Promise<XsnCompileModel>;
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: any): any;
getArtifactName(thing: unknown): any;
getSpecialFunctions?(): string[];
createToolbox(): IXsnToolbox;
createToolbox(adapter: unknown): IXsnToolbox;
traverseSemanticTokens?(model: XsnCompileModel, options: unknown): Generator<XsnIteratorEvent>;
getSemanticTokenOrigin(o: XsnIteratorEvent): Generator<XsnArtifact>;
}
export interface CdsvSourceDictionary {
export interface CdscFileMap {
[localPath: AbsolutePath]: FileContent;
}
export interface CsnDefinition {
type?: CsnType;
kind?: CsnKind;
elements?: CsnStructuredType;
items?: CsnArrayType;
enum?: CsnEnum;
}
export type CsnKind = "entity" | "type" | "context" | "const" | "annotation" | "extend" | "annotate" | "define";
export type CsnType = unknown;
export interface CsnStructuredType {
[localName: string]: CsnDefinition;
}
export interface CsnArrayType {
type: CsnType;
}
export interface CsnEnum {
[enumSymbol: string]: CsnEnumValue;
}
export interface CsnEnumValue {
value?: null | boolean | number | string;
}
export interface XsnArtifacts {

@@ -176,31 +120,25 @@ [localName: string]: XsnArtifact;

export interface IXsnToolbox {
toUri(localPath: WorkspaceRelativePath | AbsolutePath): Uri;
resolve(thing: any, options?: ResolutionOptions): any[];
nameLocation(thing: any): XsnLocation | undefined;
absoluteNameOf(thing: Thing | XsnName | undefined): string | "?";
getArtifactName(thing: any): any;
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): Kind;
getKind(thing: Thing): XsnKind;
expectedKindOf(thing: Thing): XsnKind;
fullyQualifiedNameOf(thing: Thing): any;
nameLocationOf(thing: any): XsnLocation | undefined;
filterMessagesInScope(position: LSP.Position, message: XsnMessage, relativeProvokerPosition: number): boolean;
queriesOf(t: any): XsnArtifact[];
excludesOf(t: any): any;
orderBys(t: any): any;
sourcesOf(ast: XsnCompileModel): XsnSources;
extract(model: XsnCompileModel, callback: IXsnExtraction): Error[];
isImplicitNamespace(thing: any): boolean;
isLocalizedInferred(artifact: any): boolean;
isAutoexposed(thing: any): boolean;
name(thing: any): XsnName;
name(thing: unknown): XsnName;
isReturnsCarrier(thing: any): boolean;
getImplicitNamespaceNameLocation(thing: any): any;
usingsOf(source: XsnSource): XsnArtifactUsing[];
getSemanticTokenOrigin(o: XsnReferenceEvent): XsnArtifact[];
getDefinitionOrigin(o: XsnDefinitionEvent): unknown[];
getAnnotationParseTrees(o: any): XsnAnnotationAssignment[];
}
export interface XsnCompileModel {
vocabularies?: XsnArtifacts;
definitions: XsnArtifacts;
sources: XsnSources;
$sources: XsnSources;
version: {

@@ -210,3 +148,3 @@ creator: string;

};
options: CdsvCompileOptions & {
options: CdscCompileOptions & {
messages: XsnMessage[];

@@ -226,6 +164,6 @@ };

validNames?: {
[id: string]: CdsvDefinition;
[id: string]: XsnValidName;
};
$location: XsnLocation;
severity: CsnSeverity;
severity: XsnSeverity;
}

@@ -240,7 +178,6 @@ export interface XsnSource {

dependencies: XsnFileDependency[];
extensions: XsnExtension[];
usings: XsnArtifactUsing[];
tokens: unknown[];
ruleTree?: unknown;
options: CdsvCompileOptions;
options: CdscCompileOptions;
namespace?: XsnSourceNamespace;

@@ -255,36 +192,19 @@ }

}
export type XsnKind = "__i18n" | "aspect" | "using" | "entity" | "view" | "annotation" | "annotate" | "context" | "type" | "element" | "extend" | "service" | "namespace" | "param" | "builtin" | "qualifiedAnnotation";
export type DollarInferred = "*" | "autoexposed" | "expand-element" | "expanded" | "include" | "localized" | "localized-entity" | "localized-texts" | "proxy" | "query";
export type DollarInferred = "*" | "autoexposed" | "localized" | "localized-entity";
export interface XsnArtifact {
doc?: XsnDocComment;
kind: XsnKind;
annotationAssignments: XsnAnnotationAssignment[];
extern?: {
location: XsnLocation;
path: XsnPathSegment[];
_artifact?: XsnArtifact;
};
location: XsnLocation;
name: XsnName;
artifacts?: XsnArtifacts;
$duplicates?: XsnArtifact[] | boolean;
blocks?: Array<{
kind: "block";
annotationAssignments: XsnAnnotationAssignment[];
artifacts: XsnArtifacts;
location: XsnLocation;
name: XsnName;
}>;
elements?: XsnElements;
enum?: XsnElements;
actions?: XsnElements;
returns?: any;
params?: XsnElements;
includes?: XsnArtifact[];
queries?: XsnArtifact[];
$queries?: XsnArtifact[];
extensions?: XsnExtension[];
$inferred?: DollarInferred;
localized?: any;
builtin?: boolean;
vocabularies?: XsnArtifacts;
_main?: XsnArtifact;
}

@@ -295,9 +215,5 @@ export interface XsnAnnotationAssignment {

name: XsnExtensionName;
value?: XsnFileDependency;
value?: AnnotationValue;
val?: string;
path?: XsnPathSegment[];
symbol?: {
id: string;
location: XsnLocation;
};
}

@@ -310,21 +226,2 @@ export interface XsnFileDependency {

}
export type XsnExtension = XsnExtendExtension | XsnAnnotateExtension;
export interface XsnExtendExtension {
kind: "extend";
expectedKind?: "service" | "context" | "entity" | "type" | "aspect" | "element";
annotationAssignments: XsnAnnotationAssignment[];
elements: XsnElements;
location: XsnLocation;
name: XsnExtensionName;
artifacts?: XsnArtifacts;
}
export interface XsnAnnotateExtension {
kind: "annotate";
annotationAssignments: XsnAnnotationAssignment[];
actions?: XsnElements;
elements?: XsnElements;
location: XsnLocation;
name: XsnExtensionName;
artifacts?: XsnArtifacts;
}
export interface XsnDocComment {

@@ -338,4 +235,2 @@ val: string;

elements?: XsnElements;
annotationAssignments: XsnAnnotationAssignment[];
indexNo: number;
location: XsnLocation;

@@ -368,2 +263,3 @@ name: XsnElementName;

path: XsnPathSegment[];
_artifact?: XsnArtifact;
};

@@ -400,2 +296,25 @@ location: XsnLocation;

}
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 {

@@ -408,7 +327,4 @@ file: WorkspaceRelativePath;

$weak?: boolean;
tokenIndex?: number;
}
export interface XsnPosition {
line: number;
column: number;
}
export interface XsnPathSegment {

@@ -419,12 +335,2 @@ id: string;

}
export interface IXsnExtraction {
onTokensFound<IPpToken>(absoluteLocalPath: AbsolutePath, tokens: IPpToken[], compilerVersion: string): void;
onMessagesFound(model: XsnCompileModel, relativePath: WorkspaceRelativePath, messages: XsnMessage[]): void;
onDefinitionFound(event: IXsnDefinitionEvent): void;
onReferenceFound(event: IXsnReferenceEvent): void;
onReferencesDone(event: IXsnExtractionEvent): void;
onDirectDependenciesFound(absoluteLocalPath: AbsolutePath, dependentAbsoluteLocalPaths: AbsolutePath[]): void;
onUsingStatementFound(absoluteLocalPath: AbsolutePath, extractor: IXsnUsingExtraction): void;
needsExtraction(sourcePath: AbsolutePath): boolean;
}
export interface IXsnUsingExtraction {

@@ -440,3 +346,2 @@ getUsingLocation(): XsnLocation;

getLocalName(): string;
isWrappedInBraces(): boolean;
getAbsoluteNameLocation(): XsnLocation;

@@ -446,15 +351,107 @@ getLocalNameLocation(): XsnLocation;

}
export interface IXsnExtractionEvent {
consumed: boolean;
model?: XsnCompileModel;
}
export type FullyQualifiedName = string;
export interface IXsnDefinitionEvent extends IXsnExtractionEvent {
export interface IXsnDefinitionEvent {
thing: any;
fullyQualifiedName: FullyQualifiedName;
hint?: "compilerAPI";
name?: any;
}
export interface IXsnReferenceEvent extends IXsnExtractionEvent {
export interface IXsnReferenceEvent {
model: XsnCompileModel;
thing: any;
hint?: 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 type AutoCreationMode = "create" | "noCreate" | "warnCreate";

@@ -506,4 +503,4 @@ export interface IAnnotationAssignmentToken extends IGenericToken {

export interface IExplicitDefinition extends IGenericDefinition, LSP.Position {
location: LSP.Location;
nameLocation: LSP.Location;
location: CdsLocation;
nameLocation: CdsLocation;
line: number;

@@ -566,5 +563,2 @@ character: number;

}
export interface CdsLocation extends LSP.Location {
uri: Uri;
}
export interface CdsIndexingParams {

@@ -571,0 +565,0 @@ uris: Uri[];

@@ -18,3 +18,4 @@ import { BigIntStats, Dirent, PathLike, StatOptions, Stats, WriteFileOptions } from 'node:fs';

export type UsingPath = SpecificString<"UsingPath">;
export type Kind = "context" | "service" | "namespace" | "entity" | "event" | "view" | "type" | "annotation" | "annotate" | "action" | "function" | "const" | "role" | "aspect" | "accesspolicy" | "mixin" | "element" | "query" | "param" | "enum" | "source" | "using" | "extend" | "qualifiedAnnotation";
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 {

@@ -28,35 +29,14 @@ kind: XsnKind;

}
export interface CdsvTextPosition {
line: number;
column: number;
}
export interface CdsvLocation {
start: CdsvTextPosition;
end: CdsvTextPosition;
filename?: string;
}
export interface CdsvDefinitionName {
absolute: string;
id?: string;
location?: CdsvLocation;
}
export interface WithXsnLocation {
export interface XsnValidName {
kind: XsnKind;
name: {
absolute: string;
id?: string;
};
location: XsnLocation;
}
export interface CdsvArtifact extends WithXsnLocation {
kind: CdsvKind;
name: CdsvDefinitionName;
}
export interface CdsvDefinition extends CdsvArtifact {
elements?: CdsvArtifact[];
builtin?: boolean;
internal?: boolean;
expectedKind?: string;
parameters?: string[];
annotationAssignments?: any[];
artifacts?: CdsvDefinitions;
vocabularies?: CdsvDefinitions;
}
export type CsnSeverity = "Error" | "Warning" | "Info" | "Debug";
export interface XsnParseModel extends CdsvAstNode {
export type XsnSeverity = "Error" | "Warning" | "Info" | "Debug";
export interface XsnParseModel {
dependencies?: Array<{

@@ -66,31 +46,13 @@ location: XsnLocation;

}>;
options: CdsvParseOptions;
options: CdscParseOptions;
tokens: unknown[];
ruleTree: unknown;
toolbox: IXsnToolbox;
namespace?: {
path?: Array<{
id: string;
}>;
name: {
id: string;
};
}
export interface CdsvAstNodeName {
id: string;
}
export interface CdsvAstNode {
artifacts?: {
[localName: string]: CdsvAstNode;
};
extensions?: CdsvAstNode[];
elements?: CdsvAstNode[];
name: CdsvAstNodeName;
kind: CdsvKind;
location: CdsvLocation;
kind: XsnKind;
annotationAssignments?: XsnAnnotationAssignment[];
}
export interface CdsvDefinitions {
[id: string]: CdsvDefinition;
}
export type CdsvKind = "context" | "entity" | "extend" | "element" | "namespace" | "using" | "service" | "source" | "type" | "view";
export interface CdsvParseOptions {
export interface CdscParseOptions {
parseOnly?: boolean;

@@ -104,6 +66,7 @@ lintMode?: boolean;

}
export interface CdsvCompileOptions {
export interface CdscCompileOptions {
fallbackParser?: "cds";
attachValidNames?: boolean;
attachTokens?: boolean;
lspMode?: boolean;
docComment?: boolean;

@@ -118,11 +81,13 @@ messages?: XsnMessage[];

export interface ICdsCompiler extends ModuleOrigin {
parse(source: FileContent, filename: string, options?: CdsvParseOptions): XsnParseModel;
compile(fileNames: AbsolutePath[], dir?: AbsolutePath, options?: CdsvCompileOptions, map?: CdsvSourceDictionary): Promise<XsnCompileModel>;
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: any): any;
getArtifactName(thing: unknown): any;
getSpecialFunctions?(): string[];
createToolbox(): IXsnToolbox;
createToolbox(adapter: unknown): IXsnToolbox;
traverseSemanticTokens?(model: XsnCompileModel, options: unknown): Generator<XsnIteratorEvent>;
getSemanticTokenOrigin(o: XsnIteratorEvent): Generator<XsnArtifact>;
}
export interface CdsvSourceDictionary {
export interface CdscFileMap {
[localPath: AbsolutePath]: FileContent;

@@ -144,31 +109,25 @@ }

export interface IXsnToolbox {
toUri(localPath: WorkspaceRelativePath | AbsolutePath): Uri;
resolve(thing: any, options?: ResolutionOptions): any[];
nameLocation(thing: any): XsnLocation | undefined;
absoluteNameOf(thing: Thing | XsnName | undefined): string | "?";
getArtifactName(thing: any): any;
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): Kind;
getKind(thing: Thing): XsnKind;
expectedKindOf(thing: Thing): XsnKind;
fullyQualifiedNameOf(thing: Thing): any;
nameLocationOf(thing: any): XsnLocation | undefined;
filterMessagesInScope(position: LSP.Position, message: XsnMessage, relativeProvokerPosition: number): boolean;
queriesOf(t: any): XsnArtifact[];
excludesOf(t: any): any;
orderBys(t: any): any;
sourcesOf(ast: XsnCompileModel): XsnSources;
extract(model: XsnCompileModel, callback: IXsnExtraction): Error[];
isImplicitNamespace(thing: any): boolean;
isLocalizedInferred(artifact: any): boolean;
isAutoexposed(thing: any): boolean;
name(thing: any): XsnName;
name(thing: unknown): XsnName;
isReturnsCarrier(thing: any): boolean;
getImplicitNamespaceNameLocation(thing: any): any;
usingsOf(source: XsnSource): XsnArtifactUsing[];
getSemanticTokenOrigin(o: XsnReferenceEvent): XsnArtifact[];
getDefinitionOrigin(o: XsnDefinitionEvent): unknown[];
getAnnotationParseTrees(o: any): XsnAnnotationAssignment[];
}
export interface XsnCompileModel {
vocabularies?: XsnArtifacts;
definitions: XsnArtifacts;
sources: XsnSources;
$sources: XsnSources;
version: {

@@ -178,3 +137,3 @@ creator: string;

};
options: CdsvCompileOptions & {
options: CdscCompileOptions & {
messages: XsnMessage[];

@@ -194,6 +153,6 @@ };

validNames?: {
[id: string]: CdsvDefinition;
[id: string]: XsnValidName;
};
$location: XsnLocation;
severity: CsnSeverity;
severity: XsnSeverity;
}

@@ -208,7 +167,6 @@ export interface XsnSource {

dependencies: XsnFileDependency[];
extensions: XsnExtension[];
usings: XsnArtifactUsing[];
tokens: unknown[];
ruleTree?: unknown;
options: CdsvCompileOptions;
options: CdscCompileOptions;
namespace?: XsnSourceNamespace;

@@ -223,36 +181,19 @@ }

}
export type XsnKind = "__i18n" | "aspect" | "using" | "entity" | "view" | "annotation" | "annotate" | "context" | "type" | "element" | "extend" | "service" | "namespace" | "param" | "builtin" | "qualifiedAnnotation";
export type DollarInferred = "*" | "autoexposed" | "expand-element" | "expanded" | "include" | "localized" | "localized-entity" | "localized-texts" | "proxy" | "query";
export type DollarInferred = "*" | "autoexposed" | "localized" | "localized-entity";
export interface XsnArtifact {
doc?: XsnDocComment;
kind: XsnKind;
annotationAssignments: XsnAnnotationAssignment[];
extern?: {
location: XsnLocation;
path: XsnPathSegment[];
_artifact?: XsnArtifact;
};
location: XsnLocation;
name: XsnName;
artifacts?: XsnArtifacts;
$duplicates?: XsnArtifact[] | boolean;
blocks?: Array<{
kind: "block";
annotationAssignments: XsnAnnotationAssignment[];
artifacts: XsnArtifacts;
location: XsnLocation;
name: XsnName;
}>;
elements?: XsnElements;
enum?: XsnElements;
actions?: XsnElements;
returns?: any;
params?: XsnElements;
includes?: XsnArtifact[];
queries?: XsnArtifact[];
$queries?: XsnArtifact[];
extensions?: XsnExtension[];
$inferred?: DollarInferred;
localized?: any;
builtin?: boolean;
vocabularies?: XsnArtifacts;
_main?: XsnArtifact;
}

@@ -263,9 +204,5 @@ export interface XsnAnnotationAssignment {

name: XsnExtensionName;
value?: XsnFileDependency;
value?: AnnotationValue;
val?: string;
path?: XsnPathSegment[];
symbol?: {
id: string;
location: XsnLocation;
};
}

@@ -278,21 +215,2 @@ export interface XsnFileDependency {

}
export type XsnExtension = XsnExtendExtension | XsnAnnotateExtension;
export interface XsnExtendExtension {
kind: "extend";
expectedKind?: "service" | "context" | "entity" | "type" | "aspect" | "element";
annotationAssignments: XsnAnnotationAssignment[];
elements: XsnElements;
location: XsnLocation;
name: XsnExtensionName;
artifacts?: XsnArtifacts;
}
export interface XsnAnnotateExtension {
kind: "annotate";
annotationAssignments: XsnAnnotationAssignment[];
actions?: XsnElements;
elements?: XsnElements;
location: XsnLocation;
name: XsnExtensionName;
artifacts?: XsnArtifacts;
}
export interface XsnDocComment {

@@ -306,4 +224,2 @@ val: string;

elements?: XsnElements;
annotationAssignments: XsnAnnotationAssignment[];
indexNo: number;
location: XsnLocation;

@@ -336,2 +252,3 @@ name: XsnElementName;

path: XsnPathSegment[];
_artifact?: XsnArtifact;
};

@@ -368,2 +285,25 @@ location: XsnLocation;

}
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 {

@@ -376,2 +316,3 @@ file: WorkspaceRelativePath;

$weak?: boolean;
tokenIndex?: number;
}

@@ -383,40 +324,96 @@ export interface XsnPathSegment {

}
export interface IXsnExtraction {
onTokensFound<IPpToken>(absoluteLocalPath: AbsolutePath, tokens: IPpToken[], compilerVersion: string): void;
onMessagesFound(model: XsnCompileModel, relativePath: WorkspaceRelativePath, messages: XsnMessage[]): void;
onDefinitionFound(event: IXsnDefinitionEvent): void;
onReferenceFound(event: IXsnReferenceEvent): void;
onReferencesDone(event: IXsnExtractionEvent): void;
onDirectDependenciesFound(absoluteLocalPath: AbsolutePath, dependentAbsoluteLocalPaths: AbsolutePath[]): void;
onUsingStatementFound(absoluteLocalPath: AbsolutePath, extractor: IXsnUsingExtraction): void;
needsExtraction(sourcePath: AbsolutePath): boolean;
export type FullyQualifiedName = string;
export interface AnnotationValueBase {
location: XsnLocation;
name?: Name;
}
export interface IXsnUsingExtraction {
getUsingLocation(): XsnLocation;
getTargetFilePath(): AbsolutePath | WorkspaceRelativePath | undefined;
getTargetImportPath(): UsingPath | undefined;
getImportedItems(): IXsnImportedItem[];
export interface Name {
location: XsnLocation;
path: XsnNameSegment3[];
variant?: Omit<Name, "variant">;
}
export interface IXsnImportedItem {
getItemImportLocation(): XsnLocation;
getAbsoluteName(): FullyQualifiedName;
getLocalName(): string;
isWrappedInBraces(): boolean;
getAbsoluteNameLocation(): XsnLocation;
getLocalNameLocation(): XsnLocation;
getTargetFilePath(): WorkspaceRelativePath | undefined;
export interface LeafName extends Name {
absolute?: string;
}
export interface IXsnExtractionEvent {
consumed: boolean;
model?: XsnCompileModel;
export interface NonLeafAnnotationValue extends AnnotationValueBase {
$flatten?: AnnotationValue[];
}
export type FullyQualifiedName = string;
export interface IXsnDefinitionEvent extends IXsnExtractionEvent {
thing: any;
fullyQualifiedName: FullyQualifiedName;
export interface LeafAnnotationValue extends AnnotationValueBase {
$priority?: "annotate";
literal?: "string" | "number" | "enum" | "array" | "struct" | "hex" | "null" | "boolean" | "date" | "time" | "timestamp";
_block?: any;
}
export interface IXsnReferenceEvent extends IXsnExtractionEvent {
thing: any;
hint?: string;
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 {

@@ -459,4 +456,4 @@ readonly carrier: IIdentifierToken;

export interface IExplicitDefinition extends IGenericDefinition, LSP.Position {
location: LSP.Location;
nameLocation: LSP.Location;
location: CdsLocation;
nameLocation: CdsLocation;
line: number;

@@ -519,5 +516,2 @@ character: number;

}
export interface CdsLocation extends LSP.Location {
uri: Uri;
}
export interface CdsIndexingParams {

@@ -673,41 +667,45 @@ uris: Uri[];

"<n/a>",
"Namespace",
"Using",
"global",
"Action",
"anno",
"AnnoDef",
"annoref",
"artref",
"BoundAction",
"Context",
"Service",
"Type",
"Element",
"Entity",
"Enum",
"Entity",
"enumref",
"Ext",
"ExtBoundAction",
"ExtContext",
"ExtElement",
"ExtParam",
"ExtService",
"Element",
"Action",
"BoundAction",
"Event",
"FromAlias",
"FromElemImplicit",
"FromImplicit",
"func",
"global",
"ItemAlias",
"ItemAssoc",
"ItemImplicit",
"Key",
"KeyImplicit",
"Mixin",
"name",
"Namespace",
"Param",
"paramname",
"paramref",
"ref",
"Service",
"Type",
"typeparamname",
"Event",
"AnnoDef",
"ExtBoundAction",
"ExtParam",
"anno",
"annoref",
"uncheckedAnno",
"uncheckedRef",
"uncheckedAnno",
"name",
"variant",
"ref",
"artref",
"enumref",
"paramref",
"FromAlias",
"Using",
"UsingAlias",
"Item",
"Mixin",
"Key",
"Without",
"func"
"variant"
];

@@ -717,5 +715,6 @@ export type IdentifierCategory = typeof IdentifierCategories[number];

export interface IToken extends LSP.Range, LSP.Position {
readonly uri: Uri;
readonly category: TokenCategory;
text: string;
readonly originalText: string;
readonly text: string;
flags: TokenFlags;
startOffset: number;

@@ -731,5 +730,6 @@ readonly endOffset: number;

readonly end: LSP.Position;
ejected: boolean;
readonly location: CdsLocation;
id: string;
isIdentifier(): this is IBaseIdentifierToken;
assertIdentifier(): asserts this is IBaseIdentifierToken;
isStringLiteral(): this is IBaseStringLiteralToken;

@@ -749,4 +749,15 @@ isOperator(): boolean;

translationId?: string;
isUsingPath?: boolean;
}
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 {

@@ -757,2 +768,6 @@ readonly category: "Identifier";

absoluteName: FullyQualifiedName;
kind: XsnKind;
originName?: FullyQualifiedName;
originUri?: Uri | typeof Builtin | typeof Unknown;
definitionScope?: LSP.Range;
isLastPathSegment: boolean;

@@ -762,4 +777,6 @@ }

id: string;
ejected?: boolean;
text: string;
readonly originalText: string;
readonly isErrorToken: boolean;
readonly context: ITokenContext;
finalizeCategory(antlrToken: AntlrToken, category: TokenCategory): void;

@@ -773,2 +790,3 @@ parent: IRuleNode;

isSingleLined(): boolean;
isIdentifier(): this is IBaseIdentifierToken;
isFollowUpComment(): boolean;

@@ -896,4 +914,4 @@ clone(changes: {

export interface IImplicitNamespaceDefinition extends IImplicitDefinition {
location: LSP.Location;
nameLocation: LSP.Location;
location: CdsLocation;
nameLocation: CdsLocation;
}

@@ -922,3 +940,3 @@ export interface IAutoexposedDefinition extends IImplicitDefinition {

export interface _ICompiler extends TypedEmitter<CompilerEvents> {
compile(localPath: AbsolutePath, workspaceRoot: AbsolutePath, files: CdsvSourceDictionary, options?: CdsvCompileOptions, cacheHandler?: ICacheHandler): Promise<XsnCompileModel>;
compile(localPath: AbsolutePath, adapter: _IPathAdapter, files: CdscFileMap, options?: CdscCompileOptions, cacheHandler?: ICacheHandler): Promise<XsnCompileModel>;
parse(content: FileContent, localPath: string): {

@@ -1018,3 +1036,2 @@ rootNode: IRuleNode;

ACTIVE_EDITOR_CHANGED = "capabilities.workspace.cds.didChangeActiveEditor",
CHANGE_CONFIG = "capabilities.workspace.didChangeConfiguration",
CHANGE_WATCHED_FILES_REGISTRATION = "capabilities.workspace.didChangeWatchedFiles.dynamicRegistration",

@@ -1063,3 +1080,4 @@ CODE_LENS = "capabilities.textDocument.codeLens",

WORKSPACESYMBOLS_LAZY = "cds.workspaceSymbols.lazy",
WORKSPACESYMBOLS_CASE_INSENSITIVE = "cds.workspaceSymbols.caseInsensitive"
WORKSPACESYMBOLS_CASE_INSENSITIVE = "cds.workspaceSymbols.caseInsensitive",
INSPECT_TOKENS = "cds.internal.inspectTokens"
}

@@ -1069,3 +1087,3 @@ export interface ILspOptions {

setUserSettings(params: CdsDidChangeConfigurationParams): void;
getClientCapability(name: ClientCapability | string, defaultValue?: any): any;
getClientCapability<T>(name: ClientCapability | string, defaultValue?: any): T;
getUserSetting<T>(name: UserSetting | string): T;

@@ -1130,3 +1148,3 @@ setUserSettingTemporarily(name: UserSetting, value: any): void;

export type AnnotationNamesForDocumentation = typeof annotationNamesForDocumentation[number];
export type Domain = AnnotationNamesForDocumentation | "translation" | "annotation domain" | "documentation" | "imports";
export type Domain = AnnotationNamesForDocumentation | "translation" | "annotation domain" | "documentation" | "imports" | "debug";
export interface _IDocumentation {

@@ -1367,3 +1385,3 @@ domain: Domain;

getFileSystem(): _IFileSystem;
createToolbox(compiler: ICdsCompiler): IXsnToolbox;
createToolbox(compiler: ICdsCompiler, adapter: _IPathAdapter): IXsnToolbox;
}

@@ -1518,6 +1536,5 @@ declare enum LspFileType {

static start(factory?: IFactory, options?: {
connectArgs: any[];
connectArgs: unknown[];
}): void;
private static createStarter;
static assertRequiredNodeVersion(): void;
private readonly tracer;

@@ -1528,3 +1545,3 @@ protected constructor(factory: IFactory);

installEmergencyHooks(): void;
protected createConnection(...args: any[]): IConnection<import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._>;
protected createConnection(...args: unknown[]): IConnection<import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._, import("vscode-languageserver")._>;
}

@@ -1619,5 +1636,5 @@ declare const FormatOptionNames: readonly [

}
export declare function formatCli(args?: string[], cwd?: `/${string}`): Promise<void>;
export declare function formatCli(args?: string[], cwd?: AbsolutePath): Promise<void>;
export declare function ruleName(child: IRuleItem): BlockRule | undefined;
export {};

@@ -6,3 +6,22 @@ #!/usr/bin/env node

assertNodeVersion()
const facade = require("./index.js");
facade.ServerStarter.start();
function assertNodeVersion() {
const runtime = process.version;
const required = require('../package.json').engines.node;
const canon = s => s.match(/(\d+)\.?(\d+)?\.?(\d+)?/)
.slice(1,4)
.map((d,i) => Number(d??0) * 10000**(2-i))
.reduce((sum,d) => sum+d, 0);
if( canon(runtime)-canon(required) < 0 ) {
throw new Error(`Minimum required node version is ${required} but runtime (${process.argv[0]}) is only ${runtime}`);
}
}
{
"name": "@sap/cds-lsp",
"description": "Language server for CDS",
"version": "7.9.1",
"version": "8.0.0",
"homepage": "https://cap.cloud.sap/",

@@ -38,6 +38,6 @@ "author": "SAP SE (https://www.sap.com)",

"dependencies": {
"@sap/cds-compiler": "4.9.0",
"@sap/cds-compiler": "5.0.x",
"ignore": "5.3.1",
"json-source-map": "0.6.1",
"marked": "12.0.2",
"marked": "13.0.1",
"tiny-typed-emitter": "2.1.0",

@@ -44,0 +44,0 @@ "vscode-languageserver": "9.0.1",

@@ -858,2 +858,5 @@ {

{
"include": "#bracketedExpression"
},
{
"include": "#annotationName"

@@ -868,2 +871,5 @@ },

{
"include": "#colonAndBracketedExpression"
},
{
"include": "#colonAndNumber"

@@ -878,6 +884,6 @@ },

{
"include": "#colonAndHashIdent"
"include": "#colonAndConstant"
},
{
"include": "#colonAndConstant"
"include": "#colonAndOptHashIdent"
},

@@ -924,6 +930,6 @@ {

{
"include": "#colonAndHashIdent"
"include": "#colonAndConstant"
},
{
"include": "#colonAndConstant"
"include": "#colonAndOptHashIdent"
},

@@ -1026,6 +1032,6 @@ {

{
"include": "#colonAndHashIdent"
"include": "#colonAndConstant"
},
{
"include": "#colonAndConstant"
"include": "#colonAndOptHashIdent"
},

@@ -1100,2 +1106,20 @@ {

},
"colonAndBracketedExpression": {
"name": "colonAndBracketedExpression",
"begin": "(:)\\s*(?=\\()",
"end": "(?<=\\))",
"beginCaptures": {
"1": {
"name": "keyword.operator.colon"
}
},
"patterns": [
{
"include": "#bracketedExpression"
},
{
"include": "#comment"
}
]
},
"colonAndNumber": {

@@ -1171,5 +1195,5 @@ "name": "colonAndNumber",

},
"colonAndHashIdent": {
"name": "colonAndHashIdent",
"match": "(:)\\s*(#)\\s*(\"[^\"]*(?:\"\"[^\"]*)*\"|!\\[[^\\]]*(?:\\]\\][^\\]]*)*\\]|[$_\\p{ID_Start}][$\\p{ID_Continue}\\u200C\\u200D]*)",
"colonAndOptHashIdent": {
"name": "colonAndOptHashIdent",
"match": "(:)\\s*(#)?\\s*(\"[^\"]*(?:\"\"[^\"]*)*\"|!\\[[^\\]]*(?:\\]\\][^\\]]*)*\\]|[$_\\p{ID_Start}][$\\p{ID_Continue}\\u200C\\u200D]*)",
"captures": {

@@ -1289,2 +1313,5 @@ "1": {

"include": "#operator"
},
{
"include": "#string"
}

@@ -1291,0 +1318,0 @@ ]

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc