Parameters
- context: DefaultSharedModuleContext
Optional
sharedModule: Module<LangiumSharedServices, {
AstReflection?: AstReflection;
lsp?: {
Connection?: Connection;
DocumentUpdateHandler?: {
didChangeContent?(event: TextDocumentChangeEvent<TextDocument>): void;
didChangeWatchedFiles?(params: DidChangeWatchedFilesParams): void;
didCloseDocument?(event: TextDocumentChangeEvent<TextDocument>): void;
didOpenDocument?(event: TextDocumentChangeEvent<TextDocument>): void;
didSaveDocument?(event: TextDocumentChangeEvent<TextDocument>): void;
willSaveDocument?(event: TextDocumentWillSaveEvent<TextDocument>): void;
willSaveDocumentWaitUntil?(event: TextDocumentWillSaveEvent<TextDocument>): MaybePromise<TextEdit[]>;
};
ExecuteCommandHandler?: ExecuteCommandHandler;
FileOperationHandler?: FileOperationHandler;
FuzzyMatcher?: FuzzyMatcher;
LanguageServer?: LanguageServer;
NodeKindProvider?: NodeKindProvider;
WorkspaceSymbolProvider?: WorkspaceSymbolProvider;
};
ServiceRegistry?: {
all?: readonly (undefined | {
documentation?: {
CommentProvider?: ...;
DocumentationProvider?: ...;
};
Grammar?: {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
definesHiddenTokens?: ...;
hiddenTokens?: ...;
imports?: ...;
interfaces?: ...;
isDeclared?: ...;
name?: ...;
rules?: ...;
types?: ...;
usedGrammars?: ...;
};
LanguageMetaData?: {
caseInsensitive?: ...;
fileExtensions?: ...;
languageId?: ...;
mode?: ...;
};
parser?: {
AsyncParser?: ...;
CompletionParser?: ...;
GrammarConfig?: ...;
LangiumParser?: ...;
Lexer?: ...;
LexerErrorMessageProvider?: ...;
ParserConfig?: ...;
ParserErrorMessageProvider?: ...;
TokenBuilder?: ...;
ValueConverter?: ...;
};
references?: {
Linker?: ...;
NameProvider?: ...;
References?: ...;
ScopeComputation?: ...;
ScopeProvider?: ...;
};
serializer?: {
Hydrator?: ...;
JsonSerializer?: ...;
};
shared?: {
AstReflection?: ...;
ServiceRegistry?: ...;
workspace?: ...;
};
validation?: {
DocumentValidator?: ...;
ValidationRegistry?: ...;
};
workspace?: {
AstNodeDescriptionProvider?: ...;
AstNodeLocator?: ...;
ReferenceDescriptionProvider?: ...;
};
})[];
getServices?(uri: URI): LangiumCoreServices;
hasServices?(uri: URI): boolean;
register?(language: LangiumCoreServices): void;
};
workspace?: {
ConfigurationProvider?: {
ready?: {
[toStringTag]?: string;
catch?<TResult>(onrejected?: null | ((reason: ...) => ...)): Promise<(...) | (...)>;
finally?(onfinally?: null | (() => ...)): Promise<void>;
then?<TResult1, TResult2>(onfulfilled?: null | ((value: ...) => ...), onrejected?: null | ((reason: ...) => ...)): Promise<(...) | (...)>;
};
getConfiguration?(language: string, configuration: string): Promise<any>;
initialize?(params: InitializeParams): void;
initialized?(params: ConfigurationInitializedParams): Promise<void>;
onConfigurationSectionUpdate?(callback: ConfigurationSectionUpdateListener): Disposable;
updateConfiguration?(change: DidChangeConfigurationParams): void;
};
DocumentBuilder?: {
updateBuildOptions?: {
validation?: boolean | ValidationOptions;
};
build?<T>(documents: LangiumDocument<T>[], options?: BuildOptions, cancelToken?: CancellationToken): Promise<void>;
onBuildPhase?(targetState: DocumentState, callback: DocumentBuildListener): Disposable;
onDocumentPhase?(targetState: DocumentState, callback: DocumentPhaseListener): Disposable;
onUpdate?(callback: DocumentUpdateListener): Disposable;
update?(changed: URI[], deleted: URI[], cancelToken?: CancellationToken): Promise<void>;
waitUntil?(state: DocumentState, cancelToken?: CancellationToken): Promise<void>;
waitUntil?(state: DocumentState, uri?: URI, cancelToken?: CancellationToken): Promise<undefined | URI>;
};
FileSystemProvider?: FileSystemProvider;
IndexManager?: IndexManager;
LangiumDocumentFactory?: LangiumDocumentFactory;
LangiumDocuments?: {
all?: Stream<LangiumDocument<AstNode>>;
addDocument?(document: LangiumDocument<AstNode>): void;
createDocument?(uri: URI, text: string): LangiumDocument<AstNode>;
createDocument?(uri: URI, text: string, cancellationToken: CancellationToken): Promise<LangiumDocument<AstNode>>;
deleteDocument?(uri: URI): undefined | LangiumDocument<AstNode>;
getDocument?(uri: URI): undefined | LangiumDocument<AstNode>;
getOrCreateDocument?(uri: URI, cancellationToken?: CancellationToken): Promise<LangiumDocument<AstNode>>;
hasDocument?(uri: URI): boolean;
invalidateDocument?(uri: URI): undefined | LangiumDocument<AstNode>;
};
TextDocuments?: TextDocumentProvider & TextDocuments<TextDocument>;
WorkspaceLock?: WorkspaceLock;
WorkspaceManager?: {
initialBuildOptions?: BuildOptions;
ready?: {
[toStringTag]?: string;
catch?<TResult>(onrejected?: null | ((reason: ...) => ...)): Promise<(...) | (...)>;
finally?(onfinally?: null | (() => ...)): Promise<void>;
then?<TResult1, TResult2>(onfulfilled?: null | ((value: ...) => ...), onrejected?: null | ((reason: ...) => ...)): Promise<(...) | (...)>;
};
workspaceFolders: undefined | readonly WorkspaceFolder[];
initialize?(params: InitializeParams): void;
initialized?(params: InitializedParams): Promise<void>;
initializeWorkspace?(folders: WorkspaceFolder[], cancelToken?: CancellationToken): Promise<void>;
};
};
}>Optional
module: Module<LangiumServices, {
documentation?: {
CommentProvider?: CommentProvider;
DocumentationProvider?: DocumentationProvider;
};
Grammar?: {
$container?: AstNode;
$containerIndex?: number;
$containerProperty?: string;
$cstNode?: CstNode;
$document?: LangiumDocument<AstNode>;
$type?: "Grammar";
definesHiddenTokens?: boolean;
hiddenTokens?: (undefined | {
$nodeDescription?: AstNodeDescription;
$refNode?: CstNode;
$refText?: string;
error?: LinkingError;
ref?: GrammarAST.AbstractRule;
})[];
imports?: (undefined | {
$container?: { readonly $type?: "Grammar" | undefined; definesHiddenTokens?: boolean | undefined; hiddenTokens?: ({ readonly ref?: AbstractRule | undefined; readonly error?: LinkingError | undefined; readonly $refNode?: CstNode | undefined; readonly $refText?: string | undefined; readonly $nodeDescription?: AstNodeDescription | ...;
$containerIndex?: number;
$containerProperty?: string;
$cstNode?: CstNode;
$document?: LangiumDocument<(...)>;
$type?: "GrammarImport";
path?: string;
})[];
interfaces?: (undefined | {
$container?: { readonly $type?: "Grammar" | undefined; definesHiddenTokens?: boolean | undefined; hiddenTokens?: ({ readonly ref?: AbstractRule | undefined; readonly error?: LinkingError | undefined; readonly $refNode?: CstNode | undefined; readonly $refText?: string | undefined; readonly $nodeDescription?: AstNodeDescription | ...;
$containerIndex?: number;
$containerProperty?: string;
$cstNode?: CstNode;
$document?: LangiumDocument<(...)>;
$type?: "Interface";
attributes?: (...)[];
name?: string;
superTypes?: (...)[];
})[];
isDeclared?: boolean;
name?: string;
rules?: (undefined | {
$container?: { readonly $type?: "Grammar" | undefined; definesHiddenTokens?: boolean | undefined; hiddenTokens?: ({ readonly ref?: AbstractRule | undefined; readonly error?: LinkingError | undefined; readonly $refNode?: CstNode | undefined; readonly $refText?: string | undefined; readonly $nodeDescription?: AstNodeDescription | ...;
$containerIndex?: number;
$containerProperty?: string;
$cstNode?: CstNode;
$document?: LangiumDocument<(...)>;
$type?: "ParserRule";
dataType?: GrammarAST.PrimitiveType;
definesHiddenTokens?: boolean;
definition?: {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
cardinality?: ...;
lookahead?: ...;
};
entry?: boolean;
fragment?: boolean;
hiddenTokens?: (...)[];
inferredType?: GrammarAST.InferredType;
name?: string;
parameters?: (...)[];
returnType?: Reference<(...)>;
wildcard?: boolean;
} | {
$container?: { readonly $type?: "Grammar" | undefined; definesHiddenTokens?: boolean | undefined; hiddenTokens?: ({ readonly ref?: AbstractRule | undefined; readonly error?: LinkingError | undefined; readonly $refNode?: CstNode | undefined; readonly $refText?: string | undefined; readonly $nodeDescription?: AstNodeDescription | ...;
$containerIndex?: number;
$containerProperty?: string;
$cstNode?: CstNode;
$document?: LangiumDocument<(...)>;
$type?: "TerminalRule";
definition?: {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
cardinality?: ...;
lookahead?: ...;
};
fragment?: boolean;
hidden?: boolean;
name?: string;
type?: GrammarAST.ReturnType;
})[];
types?: (undefined | {
$container?: { readonly $type?: "Grammar" | undefined; definesHiddenTokens?: boolean | undefined; hiddenTokens?: ({ readonly ref?: AbstractRule | undefined; readonly error?: LinkingError | undefined; readonly $refNode?: CstNode | undefined; readonly $refText?: string | undefined; readonly $nodeDescription?: AstNodeDescription | ...;
$containerIndex?: number;
$containerProperty?: string;
$cstNode?: CstNode;
$document?: LangiumDocument<(...)>;
$type?: "Type";
name?: string;
type?:
| {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
elementType?: ...;
}
| {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
referenceType?: ...;
}
| {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
primitiveType?: ...;
stringType?: ...;
typeRef?: ...;
}
| {
$container?: ...;
$containerIndex?: ...;
$containerProperty?: ...;
$cstNode?: ...;
$document?: ...;
$type?: ...;
types?: ...;
};
})[];
usedGrammars?: (undefined | {
$nodeDescription?: AstNodeDescription;
$refNode?: CstNode;
$refText?: string;
error?: LinkingError;
ref?: Grammar;
})[];
};
LanguageMetaData?: {
caseInsensitive?: boolean;
fileExtensions?: readonly (undefined | string)[];
languageId?: string;
mode?: "development" | "production";
};
lsp?: {
CallHierarchyProvider?: CallHierarchyProvider;
CodeActionProvider?: CodeActionProvider;
CodeLensProvider?: CodeLensProvider;
CompletionProvider?: CompletionProvider;
DeclarationProvider?: DeclarationProvider;
DefinitionProvider?: DefinitionProvider;
DocumentHighlightProvider?: DocumentHighlightProvider;
DocumentLinkProvider?: DocumentLinkProvider;
DocumentSymbolProvider?: DocumentSymbolProvider;
FoldingRangeProvider?: FoldingRangeProvider;
Formatter?: Formatter;
HoverProvider?: HoverProvider;
ImplementationProvider?: ImplementationProvider;
InlayHintProvider?: InlayHintProvider;
ReferencesProvider?: ReferencesProvider;
RenameProvider?: RenameProvider;
SemanticTokenProvider?: SemanticTokenProvider;
SignatureHelp?: SignatureHelpProvider;
TypeHierarchyProvider?: TypeHierarchyProvider;
TypeProvider?: TypeDefinitionProvider;
};
parser?: {
AsyncParser?: AsyncParser;
CompletionParser?: {
currIdx: undefined | number;
unorderedGroups: undefined | {
[toStringTag]?: string;
size?: number;
[iterator]?(): IterableIterator<[(...), (...)]>;
clear?(): void;
delete?(key: string): boolean;
entries?(): IterableIterator<[(...), (...)]>;
forEach?(callbackfn: ((value: (...)[], key: string, map: Map<(...), (...)>) => void), thisArg?: any): void;
get?(key: string): undefined | (...)[];
has?(key: string): boolean;
keys?(): IterableIterator<string>;
set?(key: string, value: boolean[]): this;
values?(): IterableIterator<(...)[]>;
};
action?(): void;
after?(element: GrammarAST.AbstractElement): void;
alternatives?(idx: number, choices: IOrAlt<any>[]): void;
atLeastOne?(idx: number, callback: DSLMethodOpts<unknown>): void;
before?(element: GrammarAST.AbstractElement): void;
construct?(): unknown;
consume?(idx: number, tokenType: TokenType, feature: GrammarAST.AbstractElement): void;
finalize?(): void;
getRule?(name: string): undefined | RuleResult;
getRuleStack?(): number[];
isRecording?(): boolean;
keepStackSize?(): number;
many?(idx: number, callback: DSLMethodOpts<unknown>): void;
optional?(idx: number, callback: DSLMethodOpts<unknown>): void;
parse?(input: string): CompletionParserResult;
resetStackSize?(size: number): void;
rule?(rule: GrammarAST.ParserRule, impl: RuleImpl): RuleResult;
subrule?(idx: number, rule: RuleResult, feature: GrammarAST.AbstractElement, args: Args): void;
};
GrammarConfig?: {
multilineCommentRules?: (undefined | string)[];
nameRegexp?: {
dotAll?: boolean;
flags?: string;
global?: boolean;
hasIndices?: boolean;
ignoreCase?: boolean;
lastIndex?: number;
multiline?: boolean;
source?: string;
sticky?: boolean;
unicode?: boolean;
[match]?(string: string): null | RegExpMatchArray;
[matchAll]?(str: string): IterableIterator<RegExpMatchArray>;
[replace]?(string: string, replaceValue: string): string;
[replace]?(string: string, replacer: ((substring: string, ...args: (...)[]) => string)): string;
[search]?(string: string): number;
[split]?(string: string, limit?: number): string[];
compile?(pattern: string, flags?: string): this;
exec?(string: string): null | RegExpExecArray;
test?(string: string): boolean;
};
};
LangiumParser?: {
definitionErrors: undefined | (undefined | {
message?: ...;
ruleName?: ...;
type?: ...;
})[];
unorderedGroups: undefined | {
[toStringTag]?: string;
size?: number;
[iterator]?(): IterableIterator<[(...), (...)]>;
clear?(): void;
delete?(key: string): boolean;
entries?(): IterableIterator<[(...), (...)]>;
forEach?(callbackfn: ((value: (...)[], key: string, map: Map<(...), (...)>) => void), thisArg?: any): void;
get?(key: string): undefined | (...)[];
has?(key: string): boolean;
keys?(): IterableIterator<string>;
set?(key: string, value: boolean[]): this;
values?(): IterableIterator<(...)[]>;
};
action?($type: string, action: GrammarAST.Action): void;
alternatives?(idx: number, choices: IOrAlt<any>[]): void;
atLeastOne?(idx: number, callback: DSLMethodOpts<unknown>): void;
construct?(): unknown;
consume?(idx: number, tokenType: TokenType, feature: GrammarAST.AbstractElement): void;
finalize?(): void;
getRule?(name: string): undefined | RuleResult;
getRuleStack?(): number[];
isRecording?(): boolean;
many?(idx: number, callback: DSLMethodOpts<unknown>): void;
optional?(idx: number, callback: DSLMethodOpts<unknown>): void;
parse?<T>(input: string, options?: ParserOptions): ParseResult<T>;
rule?(rule: GrammarAST.ParserRule, impl: RuleImpl): RuleResult;
subrule?(idx: number, rule: RuleResult, feature: GrammarAST.AbstractElement, args: Args): void;
};
Lexer?: {
definition?: {};
tokenize?(text: string, options?: TokenizeOptions): LexerResult;
};
LexerErrorMessageProvider?: ILexerErrorMessageProvider;
ParserConfig?: IParserConfig;
ParserErrorMessageProvider?: IParserErrorMessageProvider;
TokenBuilder?: {
buildTokens?(grammar: Grammar, options?: TokenBuilderOptions): TokenVocabulary;
flushLexingReport?(text: string): LexingReport;
};
ValueConverter?: ValueConverter;
};
references?: {
Linker?: Linker;
NameProvider?: NameProvider;
References?: References;
ScopeComputation?: ScopeComputation;
ScopeProvider?: ScopeProvider;
};
serializer?: {
Hydrator?: Hydrator;
JsonSerializer?: JsonSerializer;
};
shared?: {
AstReflection?: AstReflection;
lsp?: {
Connection?: Connection;
DocumentUpdateHandler?: {
didChangeContent?(event: TextDocumentChangeEvent<TextDocument>): void;
didChangeWatchedFiles?(params: DidChangeWatchedFilesParams): void;
didCloseDocument?(event: TextDocumentChangeEvent<TextDocument>): void;
didOpenDocument?(event: TextDocumentChangeEvent<TextDocument>): void;
didSaveDocument?(event: TextDocumentChangeEvent<TextDocument>): void;
willSaveDocument?(event: TextDocumentWillSaveEvent<TextDocument>): void;
willSaveDocumentWaitUntil?(event: TextDocumentWillSaveEvent<TextDocument>): MaybePromise<(...)[]>;
};
ExecuteCommandHandler?: ExecuteCommandHandler;
FileOperationHandler?: FileOperationHandler;
FuzzyMatcher?: FuzzyMatcher;
LanguageServer?: LanguageServer;
NodeKindProvider?: NodeKindProvider;
WorkspaceSymbolProvider?: WorkspaceSymbolProvider;
};
ServiceRegistry?: {
all?: readonly (undefined | {
documentation?: ...;
Grammar?: ...;
LanguageMetaData?: ...;
parser?: ...;
references?: ...;
serializer?: ...;
shared?: ...;
validation?: ...;
workspace?: ...;
})[];
getServices?(uri: URI): LangiumCoreServices;
hasServices?(uri: URI): boolean;
register?(language: LangiumCoreServices): void;
};
workspace?: {
ConfigurationProvider?: {
ready?: {
[toStringTag]?: ...;
catch?<TResult>(onrejected?: ...): ...;
finally?(onfinally?: ...): ...;
then?<TResult1, TResult2>(onfulfilled?: ..., onrejected?: ...): ...;
};
getConfiguration?(language: string, configuration: string): Promise<any>;
initialize?(params: InitializeParams): void;
initialized?(params: ConfigurationInitializedParams): Promise<void>;
onConfigurationSectionUpdate?(callback: ConfigurationSectionUpdateListener): Disposable;
updateConfiguration?(change: DidChangeConfigurationParams): void;
};
DocumentBuilder?: {
updateBuildOptions?: {
validation?: ...;
};
build?<T>(documents: LangiumDocument<(...)>[], options?: BuildOptions, cancelToken?: CancellationToken): Promise<void>;
onBuildPhase?(targetState: DocumentState, callback: DocumentBuildListener): Disposable;
onDocumentPhase?(targetState: DocumentState, callback: DocumentPhaseListener): Disposable;
onUpdate?(callback: DocumentUpdateListener): Disposable;
update?(changed: URI[], deleted: URI[], cancelToken?: CancellationToken): Promise<void>;
waitUntil?(state: DocumentState, cancelToken?: CancellationToken): Promise<void>;
waitUntil?(state: DocumentState, uri?: URI, cancelToken?: CancellationToken): Promise<(...) | (...)>;
};
FileSystemProvider?: FileSystemProvider;
IndexManager?: IndexManager;
LangiumDocumentFactory?: LangiumDocumentFactory;
LangiumDocuments?: {
all?: Stream<(...)>;
addDocument?(document: LangiumDocument<AstNode>): void;
createDocument?(uri: URI, text: string): LangiumDocument<AstNode>;
createDocument?(uri: URI, text: string, cancellationToken: CancellationToken): Promise<LangiumDocument<(...)>>;
deleteDocument?(uri: URI): undefined | LangiumDocument<(...)>;
getDocument?(uri: URI): undefined | LangiumDocument<(...)>;
getOrCreateDocument?(uri: URI, cancellationToken?: CancellationToken): Promise<LangiumDocument<(...)>>;
hasDocument?(uri: URI): boolean;
invalidateDocument?(uri: URI): undefined | LangiumDocument<(...)>;
};
TextDocuments?: TextDocumentProvider & TextDocuments<TextDocument>;
WorkspaceLock?: WorkspaceLock;
WorkspaceManager?: {
initialBuildOptions?: BuildOptions;
ready?: {
[toStringTag]?: ...;
catch?<TResult>(onrejected?: ...): ...;
finally?(onfinally?: ...): ...;
then?<TResult1, TResult2>(onfulfilled?: ..., onrejected?: ...): ...;
};
workspaceFolders: undefined | readonly (...)[];
initialize?(params: InitializeParams): void;
initialized?(params: InitializedParams): Promise<void>;
initializeWorkspace?(folders: WorkspaceFolder[], cancelToken?: CancellationToken): Promise<void>;
};
};
};
validation?: {
DocumentValidator?: DocumentValidator;
ValidationRegistry?: {
checksAfter: undefined | (undefined | ValidationPreparation)[];
checksBefore: undefined | (undefined | ValidationPreparation)[];
getChecks?(type: string, categories?: ValidationCategory[]): Stream<ValidationCheck<AstNode>>;
register?<T>(checksRecord: ValidationChecks<T>, thisObj?: unknown, category?: ValidationCategory): void;
registerAfterDocument?(checkAfter: ValidationPreparation, thisObj?: unknown): void;
registerBeforeDocument?(checkBefore: ValidationPreparation, thisObj?: unknown): void;
};
};
workspace?: {
AstNodeDescriptionProvider?: AstNodeDescriptionProvider;
AstNodeLocator?: AstNodeLocator;
ReferenceDescriptionProvider?: ReferenceDescriptionProvider;
};
}>
Shared services enriched with LSP services + Grammar services, per usual
Creates Langium grammar services, enriched with LSP functionality