完成世界书、骰子、apiconfig页面处理
This commit is contained in:
45
frontend/node_modules/langium/lib/lsp/call-hierarchy-provider.d.ts
generated
vendored
Normal file
45
frontend/node_modules/langium/lib/lsp/call-hierarchy-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2022 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import type { CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem, CallHierarchyOutgoingCall, CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams } from 'vscode-languageserver';
|
||||
import type { CancellationToken } from '../utils/cancellation.js';
|
||||
import type { GrammarConfig } from '../languages/grammar-config.js';
|
||||
import type { NameProvider } from '../references/name-provider.js';
|
||||
import type { References } from '../references/references.js';
|
||||
import type { LangiumServices } from './lsp-services.js';
|
||||
import type { AstNode } from '../syntax-tree.js';
|
||||
import type { Stream } from '../utils/stream.js';
|
||||
import type { ReferenceDescription } from '../workspace/ast-descriptions.js';
|
||||
import type { LangiumDocument, LangiumDocuments } from '../workspace/documents.js';
|
||||
import type { MaybePromise } from '../utils/promise-utils.js';
|
||||
/**
|
||||
* Language-specific service for handling call hierarchy requests.
|
||||
*/
|
||||
export interface CallHierarchyProvider {
|
||||
prepareCallHierarchy(document: LangiumDocument, params: CallHierarchyPrepareParams, cancelToken?: CancellationToken): MaybePromise<CallHierarchyItem[] | undefined>;
|
||||
incomingCalls(params: CallHierarchyIncomingCallsParams, cancelToken?: CancellationToken): MaybePromise<CallHierarchyIncomingCall[] | undefined>;
|
||||
outgoingCalls(params: CallHierarchyOutgoingCallsParams, cancelToken?: CancellationToken): MaybePromise<CallHierarchyOutgoingCall[] | undefined>;
|
||||
}
|
||||
export declare abstract class AbstractCallHierarchyProvider implements CallHierarchyProvider {
|
||||
protected readonly grammarConfig: GrammarConfig;
|
||||
protected readonly nameProvider: NameProvider;
|
||||
protected readonly documents: LangiumDocuments;
|
||||
protected readonly references: References;
|
||||
constructor(services: LangiumServices);
|
||||
prepareCallHierarchy(document: LangiumDocument<AstNode>, params: CallHierarchyPrepareParams): MaybePromise<CallHierarchyItem[] | undefined>;
|
||||
protected getCallHierarchyItems(targetNode: AstNode, document: LangiumDocument<AstNode>): CallHierarchyItem[] | undefined;
|
||||
protected getCallHierarchyItem(_targetNode: AstNode): Partial<CallHierarchyItem> | undefined;
|
||||
incomingCalls(params: CallHierarchyIncomingCallsParams): Promise<CallHierarchyIncomingCall[] | undefined>;
|
||||
/**
|
||||
* Override this method to collect the incoming calls for your language
|
||||
*/
|
||||
protected abstract getIncomingCalls(node: AstNode, references: Stream<ReferenceDescription>): MaybePromise<CallHierarchyIncomingCall[] | undefined>;
|
||||
outgoingCalls(params: CallHierarchyOutgoingCallsParams): Promise<CallHierarchyOutgoingCall[] | undefined>;
|
||||
/**
|
||||
* Override this method to collect the outgoing calls for your language
|
||||
*/
|
||||
protected abstract getOutgoingCalls(node: AstNode): MaybePromise<CallHierarchyOutgoingCall[] | undefined>;
|
||||
}
|
||||
//# sourceMappingURL=call-hierarchy-provider.d.ts.map
|
||||
7
frontend/node_modules/langium/lib/lsp/code-action.js
generated
vendored
Normal file
7
frontend/node_modules/langium/lib/lsp/code-action.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
export {};
|
||||
//# sourceMappingURL=code-action.js.map
|
||||
7
frontend/node_modules/langium/lib/lsp/code-lens-provider.js
generated
vendored
Normal file
7
frontend/node_modules/langium/lib/lsp/code-lens-provider.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2022 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
export {};
|
||||
//# sourceMappingURL=code-lens-provider.js.map
|
||||
312
frontend/node_modules/langium/lib/lsp/completion/follow-element-computation.js
generated
vendored
Normal file
312
frontend/node_modules/langium/lib/lsp/completion/follow-element-computation.js
generated
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import * as ast from '../../languages/generated/ast.js';
|
||||
import { getCrossReferenceTerminal, getExplicitRuleType, getTypeName, isArrayCardinality, isOptionalCardinality, terminalRegex } from '../../utils/grammar-utils.js';
|
||||
import { getContainerOfType } from '../../utils/ast-utils.js';
|
||||
/**
|
||||
* Calculates any features that can follow the given feature stack.
|
||||
* This also includes features following optional features and features from previously called rules that could follow the last feature.
|
||||
* @param featureStack A stack of features starting at the entry rule and ending at the feature of the current cursor position.
|
||||
* @param unparsedTokens All tokens which haven't been parsed successfully yet. This is the case when we call this function inside an alternative or before parsing any tokens.
|
||||
* @returns Any `AbstractElement` that could be following the given feature stack.
|
||||
*/
|
||||
export function findNextFeatures(featureStack, unparsedTokens) {
|
||||
const context = {
|
||||
stacks: featureStack,
|
||||
tokens: unparsedTokens
|
||||
};
|
||||
interpretTokens(context);
|
||||
// Reset the container property
|
||||
context.stacks.flat().forEach(feature => { feature.property = undefined; });
|
||||
const nextStacks = findNextFeatureStacks(context.stacks);
|
||||
// We only need the last element of each stack
|
||||
return nextStacks.map(e => e[e.length - 1]);
|
||||
}
|
||||
function findNextFeaturesInternal(stack) {
|
||||
const features = [];
|
||||
if (stack.length === 0) {
|
||||
return features;
|
||||
}
|
||||
const top = stack[stack.length - 1];
|
||||
const { group, child } = findGroupAndChild(top.feature);
|
||||
if (isArrayCardinality(child.cardinality)) {
|
||||
// The feature can appear again, so we try to find its first features again
|
||||
const repeatingFeatures = findFirstFeaturesInternal({
|
||||
feature: child,
|
||||
type: top.type,
|
||||
property: top.property
|
||||
});
|
||||
features.push(...repeatingFeatures);
|
||||
}
|
||||
let groupIndex = -1;
|
||||
if (group) {
|
||||
groupIndex = group.elements.indexOf(child);
|
||||
}
|
||||
const parentStack = stack.slice(0, -1);
|
||||
if (!group) {
|
||||
const parent = getAbstractElementParent(child);
|
||||
if (parent) {
|
||||
// The feature is not part of a group
|
||||
// But the parent might be
|
||||
features.push(...findNextFeaturesInternal([
|
||||
...parentStack,
|
||||
{
|
||||
feature: parent,
|
||||
}
|
||||
]));
|
||||
}
|
||||
else {
|
||||
// The feature is "standalone", meaning it is the top-level feature of a rule
|
||||
// The next elements are defined by the previous stack elements
|
||||
features.push(...findNextFeaturesInternal(parentStack));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The feature is somewhere within the group
|
||||
const nextIndex = groupIndex + 1;
|
||||
const { stacks, end } = findNextFeaturesInGroup({
|
||||
feature: group,
|
||||
type: top.type
|
||||
}, nextIndex);
|
||||
for (const newStack of stacks) {
|
||||
features.push([...parentStack, ...newStack]);
|
||||
}
|
||||
// If we reached the end of the group, continue searching for following features
|
||||
if (end) {
|
||||
// Set groupIndex to the last element index to indicate that we are at the end of the group
|
||||
// This will trigger the parent search below
|
||||
groupIndex = group.elements.length - 1;
|
||||
}
|
||||
}
|
||||
if (group && groupIndex === group.elements.length - 1) {
|
||||
// The feature is the last element of a group
|
||||
// The next elements are defined by the parent group
|
||||
features.push(...findNextFeaturesInternal([
|
||||
...parentStack,
|
||||
{
|
||||
feature: group,
|
||||
}
|
||||
]));
|
||||
}
|
||||
return features;
|
||||
}
|
||||
/**
|
||||
* Calculates the first child feature of any `AbstractElement`.
|
||||
* @param next The `AbstractElement` whose first child features should be calculated.
|
||||
*/
|
||||
export function findFirstFeatures(next) {
|
||||
return findFirstFeaturesInternal({ feature: next });
|
||||
}
|
||||
function findFirstFeaturesInternal(next) {
|
||||
const { feature, type } = next;
|
||||
if (ast.isGroup(feature)) {
|
||||
return findNextFeaturesInGroup(next, 0).stacks;
|
||||
}
|
||||
else if (ast.isAlternatives(feature) || ast.isUnorderedGroup(feature)) {
|
||||
return feature.elements.flatMap(e => findFirstFeaturesInternal({
|
||||
feature: e,
|
||||
type,
|
||||
property: next.property
|
||||
}));
|
||||
}
|
||||
else if (ast.isAssignment(feature)) {
|
||||
return findFirstFeaturesInternal({
|
||||
feature: feature.terminal,
|
||||
type,
|
||||
property: next.property ?? feature.feature
|
||||
});
|
||||
}
|
||||
else if (ast.isAction(feature)) {
|
||||
return findNextFeaturesInternal([{
|
||||
feature,
|
||||
type: getTypeName(feature),
|
||||
property: next.property ?? feature.feature
|
||||
}]);
|
||||
}
|
||||
else if (ast.isRuleCall(feature) && ast.isParserRule(feature.rule.ref)) {
|
||||
const rule = feature.rule.ref;
|
||||
const stacks = findFirstFeaturesInternal({
|
||||
feature: rule.definition,
|
||||
type: rule.fragment || rule.dataType ? undefined : (getExplicitRuleType(rule) ?? rule.name),
|
||||
property: next.property
|
||||
});
|
||||
for (const stack of stacks) {
|
||||
stack.unshift(next);
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
else if (ast.isRuleCall(feature) && ast.isInfixRule(feature.rule.ref)) {
|
||||
const rule = feature.rule.ref;
|
||||
const call = rule.call.rule.ref;
|
||||
if (!ast.isParserRule(call)) {
|
||||
console.error('Failed to resolve reference to ' + rule.call.rule.$refText);
|
||||
return [];
|
||||
}
|
||||
const stacks = findFirstFeaturesInternal({
|
||||
feature: call.definition,
|
||||
type: getExplicitRuleType(call) ?? call.name,
|
||||
property: 'parts'
|
||||
});
|
||||
for (const stack of stacks) {
|
||||
stack.unshift(next);
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
else {
|
||||
return [[next]];
|
||||
}
|
||||
}
|
||||
function findNextFeaturesInGroup(next, index) {
|
||||
const features = [];
|
||||
let firstFeature;
|
||||
while (index < next.feature.elements.length) {
|
||||
const feature = next.feature.elements[index];
|
||||
firstFeature = {
|
||||
feature,
|
||||
type: next.type
|
||||
};
|
||||
const stacks = findFirstFeaturesInternal(firstFeature);
|
||||
features.push(...stacks);
|
||||
if (isElementOptional(feature, new Map())) {
|
||||
// Continue with the next element
|
||||
index++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
stacks: features,
|
||||
end: index >= next.feature.elements.length
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Determines recursively whether an element is optional. It is not sufficient to check only the cardinality of the element itself,
|
||||
* because it could a group or alternative that contains only optional elements.
|
||||
*/
|
||||
function isElementOptional(feature, visited) {
|
||||
const visitedResult = visited.get(feature);
|
||||
if (visitedResult !== undefined) {
|
||||
return visitedResult;
|
||||
}
|
||||
visited.set(feature, false);
|
||||
if (isOptionalCardinality(feature.cardinality, feature)) {
|
||||
visited.set(feature, true);
|
||||
return true;
|
||||
}
|
||||
if (ast.isGroup(feature)) {
|
||||
for (const element of feature.elements) {
|
||||
if (!isElementOptional(element, visited)) {
|
||||
visited.set(feature, false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
visited.set(feature, true);
|
||||
return true;
|
||||
}
|
||||
else if (ast.isAlternatives(feature) || ast.isUnorderedGroup(feature)) {
|
||||
for (const element of feature.elements) {
|
||||
if (isElementOptional(element, visited)) {
|
||||
visited.set(feature, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
visited.set(feature, false);
|
||||
return false;
|
||||
}
|
||||
else if (ast.isRuleCall(feature) && ast.isParserRule(feature.rule.ref)) {
|
||||
const rule = feature.rule.ref;
|
||||
const result = isElementOptional(rule.definition, visited);
|
||||
visited.set(feature, result);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function interpretTokens(context) {
|
||||
for (const token of context.tokens) {
|
||||
const nextFeatureStacks = findNextFeatureStacks(context.stacks, token);
|
||||
context.stacks = nextFeatureStacks;
|
||||
}
|
||||
}
|
||||
function findNextFeatureStacks(stacks, token) {
|
||||
const newStacks = [];
|
||||
for (const stack of stacks) {
|
||||
newStacks.push(...interpretStackToken(stack, token));
|
||||
}
|
||||
return newStacks;
|
||||
}
|
||||
function interpretStackToken(stack, token) {
|
||||
const allNextFeatures = findNextFeaturesInternal(stack);
|
||||
const matchingNextFeatures = allNextFeatures.filter(next => token ? featureMatches(next[next.length - 1].feature, token) : true);
|
||||
return matchingNextFeatures;
|
||||
}
|
||||
export function findGroupAndChild(feature) {
|
||||
let parent;
|
||||
let item = feature;
|
||||
while (item.$container) {
|
||||
if (ast.isGroup(item.$container)) {
|
||||
parent = item.$container;
|
||||
break;
|
||||
}
|
||||
else if (ast.isAbstractElement(item.$container)) {
|
||||
item = item.$container;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
return { group: parent, child: item };
|
||||
}
|
||||
return {
|
||||
group: undefined,
|
||||
// Even if there is no group, return the feature parent if it is an assignment
|
||||
// We need this later to handle the cardinality of the feature correctly
|
||||
child: getContainerOfType(feature, ast.isAssignment) ?? feature
|
||||
};
|
||||
}
|
||||
function getAbstractElementParent(element) {
|
||||
const parent = element.$container;
|
||||
const assignment = getContainerOfType(parent, ast.isAssignment);
|
||||
if (assignment) {
|
||||
return getAbstractElementParent(assignment);
|
||||
}
|
||||
else {
|
||||
if (parent && ast.isAbstractElement(parent)) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function featureMatches(feature, token) {
|
||||
if (ast.isKeyword(feature)) {
|
||||
const content = feature.value;
|
||||
return content === token.tokenType.name;
|
||||
}
|
||||
else if (ast.isRuleCall(feature)) {
|
||||
return ruleMatches(feature.rule.ref, token);
|
||||
}
|
||||
else if (ast.isCrossReference(feature)) {
|
||||
const crossRefTerminal = getCrossReferenceTerminal(feature);
|
||||
if (crossRefTerminal) {
|
||||
return featureMatches(crossRefTerminal, token);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function ruleMatches(rule, token) {
|
||||
if (ast.isParserRule(rule)) {
|
||||
const ruleFeatures = findFirstFeatures(rule.definition);
|
||||
return ruleFeatures.some(e => featureMatches(e[e.length - 1].feature, token));
|
||||
}
|
||||
else if (ast.isTerminalRule(rule)) {
|
||||
return terminalRegex(rule).test(token.image);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=follow-element-computation.js.map
|
||||
1
frontend/node_modules/langium/lib/lsp/completion/follow-element-computation.js.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/completion/follow-element-computation.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
frontend/node_modules/langium/lib/lsp/declaration-provider.js
generated
vendored
Normal file
7
frontend/node_modules/langium/lib/lsp/declaration-provider.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2022 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
export {};
|
||||
//# sourceMappingURL=declaration-provider.js.map
|
||||
43
frontend/node_modules/langium/lib/lsp/default-lsp-module.d.ts
generated
vendored
Normal file
43
frontend/node_modules/langium/lib/lsp/default-lsp-module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import type { Connection } from 'vscode-languageserver';
|
||||
import { type DefaultCoreModuleContext, type DefaultSharedCoreModuleContext } from '../default-module.js';
|
||||
import { Module } from '../dependency-injection.js';
|
||||
import type { LangiumDefaultCoreServices, LangiumDefaultSharedCoreServices } from '../services.js';
|
||||
import type { LangiumLSPServices, LangiumServices, LangiumSharedLSPServices, LangiumSharedServices } from './lsp-services.js';
|
||||
/**
|
||||
* Context required for creating the default language-specific dependency injection module.
|
||||
*/
|
||||
export interface DefaultModuleContext extends DefaultCoreModuleContext {
|
||||
readonly shared: LangiumSharedServices;
|
||||
}
|
||||
/**
|
||||
* Creates a dependency injection module configuring the default Core & LSP services for a Langium-based language implementation.
|
||||
* This is a set of services that are dedicated to a specific language.
|
||||
*/
|
||||
export declare function createDefaultModule(context: DefaultModuleContext): Module<LangiumServices, LangiumDefaultCoreServices & LangiumLSPServices>;
|
||||
/**
|
||||
* Creates a dependency injection module configuring the default LSP services.
|
||||
* This is a set of services that are dedicated to a specific language.
|
||||
*/
|
||||
export declare function createDefaultLSPModule(context: DefaultModuleContext): Module<LangiumServices, LangiumLSPServices>;
|
||||
export interface DefaultSharedModuleContext extends DefaultSharedCoreModuleContext {
|
||||
/**
|
||||
* Represents an abstract language server connection
|
||||
*/
|
||||
readonly connection?: Connection;
|
||||
}
|
||||
/**
|
||||
* Creates a dependency injection module configuring the default core & LSP services shared among languages supported by a Langium-based language server.
|
||||
* This is the set of services that are shared between multiple languages.
|
||||
*/
|
||||
export declare function createDefaultSharedModule(context: DefaultSharedModuleContext): Module<LangiumSharedServices, LangiumDefaultSharedCoreServices & LangiumSharedLSPServices>;
|
||||
/**
|
||||
* Creates a dependency injection module configuring the default shared LSP services.
|
||||
* This is the set of services that are shared between multiple languages.
|
||||
*/
|
||||
export declare function createDefaultSharedLSPModule(context: DefaultSharedModuleContext): Module<LangiumSharedServices, LangiumSharedLSPServices>;
|
||||
//# sourceMappingURL=default-lsp-module.d.ts.map
|
||||
1
frontend/node_modules/langium/lib/lsp/default-lsp-module.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/default-lsp-module.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"default-lsp-module.d.ts","sourceRoot":"","sources":["../../src/lsp/default-lsp-module.ts"],"names":[],"mappings":"AAAA;;;;+EAI+E;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAA0D,KAAK,wBAAwB,EAAE,KAAK,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAClK,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAWnG,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO9H;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IAClE,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;CAC1C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,eAAe,EAAE,0BAA0B,GAAG,kBAAkB,CAAC,CAK3I;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAcjH;AAED,MAAM,WAAW,0BAA2B,SAAQ,8BAA8B;IAC9E;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAAC,qBAAqB,EAAE,gCAAgC,GAAG,wBAAwB,CAAC,CAKzK;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,CAezI"}
|
||||
1
frontend/node_modules/langium/lib/lsp/definition-provider.js.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/definition-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"definition-provider.js","sourceRoot":"","sources":["../../src/lsp/definition-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAWhF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA0BrF,MAAM,OAAO,yBAAyB;IAMlC,YAAY,QAAyB;QACjC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC;IACvD,CAAC;IAED,aAAa,CAAC,QAAyB,EAAE,MAAwB,EAAE,YAAgC;QAC/F,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC;QAC5C,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC;YAC9B,MAAM,aAAa,GAAG,2BAA2B,CAAC,GAAG,EAAE,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YACvI,IAAI,aAAa,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YAC5D,CAAC;QACL,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAES,oBAAoB,CAAC,aAAsB,EAAE,OAAyB;QAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAC5C,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,EACpC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EACnD,IAAI,CAAC,MAAM,CAAC,KAAK,EACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CACpB,CAAC,CAAC;QACP,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAES,SAAS,CAAC,MAAe;QAC/B,MAAM,kBAAkB,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,KAAK,GAAe,EAAE,CAAC;QAC7B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACnD,IAAI,OAAO,IAAI,cAAc,EAAE,CAAC;gBAC5B,KAAK,CAAC,IAAI,CAAC;oBACP,MAAM,EAAE,kBAAkB;oBAC1B,MAAM;oBACN,cAAc;iBACjB,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
|
||||
43
frontend/node_modules/langium/lib/lsp/document-highlight-provider.d.ts
generated
vendored
Normal file
43
frontend/node_modules/langium/lib/lsp/document-highlight-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import type { DocumentHighlightParams } from 'vscode-languageserver';
|
||||
import type { CancellationToken } from '../utils/cancellation.js';
|
||||
import type { GrammarConfig } from '../languages/grammar-config.js';
|
||||
import type { NameProvider } from '../references/name-provider.js';
|
||||
import type { References } from '../references/references.js';
|
||||
import type { LangiumServices } from './lsp-services.js';
|
||||
import type { MaybePromise } from '../utils/promise-utils.js';
|
||||
import type { ReferenceDescription } from '../workspace/ast-descriptions.js';
|
||||
import type { LangiumDocument } from '../workspace/documents.js';
|
||||
import { DocumentHighlight } from 'vscode-languageserver';
|
||||
/**
|
||||
* Language-specific service for handling document highlight requests.
|
||||
*/
|
||||
export interface DocumentHighlightProvider {
|
||||
/**
|
||||
* Handle a document highlight request.
|
||||
*
|
||||
* @param document The document in which the request was received.
|
||||
* @param params The parameters of the document highlight request.
|
||||
* @param cancelToken A cancellation token that can be used to cancel the request.
|
||||
* @returns The document highlights or `undefined` if no highlights are available.
|
||||
* @throws `OperationCancelled` if cancellation is detected during execution
|
||||
* @throws `ResponseError` if an error is detected that should be sent as response to the client
|
||||
*/
|
||||
getDocumentHighlight(document: LangiumDocument, params: DocumentHighlightParams, cancelToken?: CancellationToken): MaybePromise<DocumentHighlight[] | undefined>;
|
||||
}
|
||||
export declare class DefaultDocumentHighlightProvider implements DocumentHighlightProvider {
|
||||
protected readonly references: References;
|
||||
protected readonly nameProvider: NameProvider;
|
||||
protected readonly grammarConfig: GrammarConfig;
|
||||
constructor(services: LangiumServices);
|
||||
getDocumentHighlight(document: LangiumDocument, params: DocumentHighlightParams, _cancelToken?: CancellationToken): MaybePromise<DocumentHighlight[] | undefined>;
|
||||
/**
|
||||
* Override this method to determine the highlight kind of the given reference.
|
||||
*/
|
||||
protected createDocumentHighlight(reference: ReferenceDescription): DocumentHighlight;
|
||||
}
|
||||
//# sourceMappingURL=document-highlight-provider.d.ts.map
|
||||
1
frontend/node_modules/langium/lib/lsp/document-link-provider.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/document-link-provider.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"document-link-provider.d.ts","sourceRoot":"","sources":["../../src/lsp/document-link-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;CAC1I"}
|
||||
40
frontend/node_modules/langium/lib/lsp/document-symbol-provider.d.ts
generated
vendored
Normal file
40
frontend/node_modules/langium/lib/lsp/document-symbol-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import type { DocumentSymbol, DocumentSymbolParams } from 'vscode-languageserver-protocol';
|
||||
import type { CancellationToken } from '../utils/cancellation.js';
|
||||
import type { NameProvider } from '../references/name-provider.js';
|
||||
import type { LangiumServices } from './lsp-services.js';
|
||||
import type { AstNode, CstNode } from '../syntax-tree.js';
|
||||
import type { MaybePromise } from '../utils/promise-utils.js';
|
||||
import type { LangiumDocument } from '../workspace/documents.js';
|
||||
import type { NodeKindProvider } from './node-kind-provider.js';
|
||||
/**
|
||||
* Language-specific service for handling document symbols requests.
|
||||
*/
|
||||
export interface DocumentSymbolProvider {
|
||||
/**
|
||||
* Handle a document symbols request.
|
||||
*
|
||||
* @param document The document in the workspace.
|
||||
* @param params The parameters of the request.
|
||||
* @param cancelToken A cancellation token that migh be used to cancel the request.
|
||||
* @returns The symbols for the given document.
|
||||
*
|
||||
* @throws `OperationCancelled` if cancellation is detected during execution
|
||||
* @throws `ResponseError` if an error is detected that should be sent as response to the client
|
||||
*/
|
||||
getSymbols(document: LangiumDocument, params: DocumentSymbolParams, cancelToken?: CancellationToken): MaybePromise<DocumentSymbol[]>;
|
||||
}
|
||||
export declare class DefaultDocumentSymbolProvider implements DocumentSymbolProvider {
|
||||
protected readonly nameProvider: NameProvider;
|
||||
protected readonly nodeKindProvider: NodeKindProvider;
|
||||
constructor(services: LangiumServices);
|
||||
getSymbols(document: LangiumDocument, _params: DocumentSymbolParams, _cancelToken?: CancellationToken): MaybePromise<DocumentSymbol[]>;
|
||||
protected getSymbol(document: LangiumDocument, astNode: AstNode): DocumentSymbol[];
|
||||
protected createSymbol(document: LangiumDocument, astNode: AstNode, cstNode: CstNode, nameNode: CstNode, computedName?: string): DocumentSymbol;
|
||||
protected getChildSymbols(document: LangiumDocument, astNode: AstNode): DocumentSymbol[] | undefined;
|
||||
}
|
||||
//# sourceMappingURL=document-symbol-provider.d.ts.map
|
||||
1
frontend/node_modules/langium/lib/lsp/document-symbol-provider.js.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/document-symbol-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"document-symbol-provider.js","sourceRoot":"","sources":["../../src/lsp/document-symbol-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAOhF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAuBvD,MAAM,OAAO,6BAA6B;IAKtC,YAAY,QAAyB;QACjC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACjE,CAAC;IAED,UAAU,CAAC,QAAyB,EAAE,OAA6B,EAAE,YAAgC;QACjG,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAES,SAAS,CAAC,QAAyB,EAAE,OAAgB;QAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACxD,OAAO,CAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAE,CAAC;QAC9F,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QACzD,CAAC;IACL,CAAC;IAES,YAAY,CAAC,QAAyB,EAAE,OAAgB,EAAE,OAAgB,EAAE,QAAiB,EAAE,YAAqB;QAC1H,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC;YAClD,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,IAAI;YACnC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,cAAc,EAAE,QAAQ,CAAC,KAAK;YAC9B,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC;SACpD,CAAC;IACN,CAAC;IAES,eAAe,CAAC,QAAyB,EAAE,OAAgB;QACjE,MAAM,QAAQ,GAAqB,EAAE,CAAC;QAEtC,KAAK,MAAM,KAAK,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC/C,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
|
||||
110
frontend/node_modules/langium/lib/lsp/folding-range-provider.js
generated
vendored
Normal file
110
frontend/node_modules/langium/lib/lsp/folding-range-provider.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { FoldingRange, FoldingRangeKind } from 'vscode-languageserver';
|
||||
import { streamAllContents } from '../utils/ast-utils.js';
|
||||
import { flattenCst } from '../utils/cst-utils.js';
|
||||
export class DefaultFoldingRangeProvider {
|
||||
constructor(services) {
|
||||
this.commentNames = services.parser.GrammarConfig.multilineCommentRules;
|
||||
}
|
||||
getFoldingRanges(document, _params, _cancelToken) {
|
||||
const foldings = [];
|
||||
const acceptor = (foldingRange) => foldings.push(foldingRange);
|
||||
this.collectFolding(document, acceptor);
|
||||
return foldings;
|
||||
}
|
||||
collectFolding(document, acceptor) {
|
||||
const root = document.parseResult?.value;
|
||||
if (root) {
|
||||
if (this.shouldProcessContent(root)) {
|
||||
const treeIterator = streamAllContents(root).iterator();
|
||||
let result;
|
||||
do {
|
||||
result = treeIterator.next();
|
||||
if (!result.done) {
|
||||
const node = result.value;
|
||||
if (this.shouldProcess(node)) {
|
||||
this.collectObjectFolding(document, node, acceptor);
|
||||
}
|
||||
if (!this.shouldProcessContent(node)) {
|
||||
treeIterator.prune();
|
||||
}
|
||||
}
|
||||
} while (!result.done);
|
||||
}
|
||||
this.collectCommentFolding(document, root, acceptor);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Template method to determine whether the specified `AstNode` should be handled by the folding range provider.
|
||||
* Returns true by default for all nodes. Returning false only ignores the specified node and not its content.
|
||||
* To ignore the content of a node use `shouldProcessContent`.
|
||||
*/
|
||||
shouldProcess(_node) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Template method to determine whether the content/children of the specified `AstNode` should be handled by the folding range provider.
|
||||
* Returns true by default for all nodes. Returning false ignores _all_ content of this node, even transitive ones.
|
||||
* For more precise control over foldings use the `shouldProcess` method.
|
||||
*/
|
||||
shouldProcessContent(_node) {
|
||||
return true;
|
||||
}
|
||||
collectObjectFolding(document, node, acceptor) {
|
||||
const cstNode = node.$cstNode;
|
||||
if (cstNode) {
|
||||
const foldingRange = this.toFoldingRange(document, cstNode);
|
||||
if (foldingRange) {
|
||||
acceptor(foldingRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
collectCommentFolding(document, node, acceptor) {
|
||||
const cstNode = node.$cstNode;
|
||||
if (cstNode) {
|
||||
for (const node of flattenCst(cstNode)) {
|
||||
if (this.commentNames.includes(node.tokenType.name)) {
|
||||
const foldingRange = this.toFoldingRange(document, node, FoldingRangeKind.Comment);
|
||||
if (foldingRange) {
|
||||
acceptor(foldingRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
toFoldingRange(document, node, kind) {
|
||||
const range = node.range;
|
||||
const start = range.start;
|
||||
let end = range.end;
|
||||
// Don't generate foldings for nodes that are less than 3 lines
|
||||
if (end.line - start.line < 2) {
|
||||
return undefined;
|
||||
}
|
||||
// As we don't want to hide the end token like 'if { ... --> } <--',
|
||||
// we simply select the end of the previous line as the end position
|
||||
if (!this.includeLastFoldingLine(node, kind)) {
|
||||
end = document.textDocument.positionAt(document.textDocument.offsetAt({ line: end.line, character: 0 }) - 1);
|
||||
}
|
||||
return FoldingRange.create(start.line, end.line, start.character, end.character, kind);
|
||||
}
|
||||
/**
|
||||
* Template method to determine whether the folding range for this cst node should include its last line.
|
||||
* Returns false by default for ast nodes which end in braces and for comments.
|
||||
*/
|
||||
includeLastFoldingLine(node, kind) {
|
||||
if (kind === FoldingRangeKind.Comment) {
|
||||
return false;
|
||||
}
|
||||
const nodeText = node.text;
|
||||
const endChar = nodeText.charAt(nodeText.length - 1);
|
||||
if (endChar === '}' || endChar === ')' || endChar === ']') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=folding-range-provider.js.map
|
||||
664
frontend/node_modules/langium/lib/lsp/formatter.js
generated
vendored
Normal file
664
frontend/node_modules/langium/lib/lsp/formatter.js
generated
vendored
Normal file
@@ -0,0 +1,664 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { findNodeForKeyword, findNodesForKeyword, findNodeForProperty, findNodesForProperty } from '../utils/grammar-utils.js';
|
||||
import { isCompositeCstNode, isLeafCstNode } from '../syntax-tree.js';
|
||||
import { streamAllContents } from '../utils/ast-utils.js';
|
||||
import { getInteriorNodes, getNextNode } from '../utils/cst-utils.js';
|
||||
import { DONE_RESULT, EMPTY_STREAM, StreamImpl, TreeStreamImpl } from '../utils/stream.js';
|
||||
export class AbstractFormatter {
|
||||
constructor() {
|
||||
this.collector = () => { };
|
||||
}
|
||||
/**
|
||||
* Creates a formatter scoped to the supplied AST node.
|
||||
* Allows to define fine-grained formatting rules for elements.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```ts
|
||||
* export class CustomFormatter extends AbstractFormatter {
|
||||
* protected override format(node: AstNode): void {
|
||||
* if (isPerson(node)) {
|
||||
* const formatter = this.getNodeFormatter(node);
|
||||
* formatter.property('name').prepend(Formatting.oneSpace());
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @param node The specific node the formatter should be scoped to. Every call to properties or keywords will only select those which belong to the supplied AST node.
|
||||
*/
|
||||
getNodeFormatter(node) {
|
||||
return new DefaultNodeFormatter(node, this.collector);
|
||||
}
|
||||
formatDocument(document, params) {
|
||||
const pr = document.parseResult;
|
||||
if (pr.lexerErrors.length === 0 && pr.parserErrors.length === 0) {
|
||||
// safe to format
|
||||
return this.doDocumentFormat(document, params.options);
|
||||
}
|
||||
else {
|
||||
// don't format a potentially broken document, return no edits
|
||||
return [];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns whether a range for a given document is error free, i.e. safe to format
|
||||
*
|
||||
* @param document Document to inspect for lexer & parser errors that may produce an unsafe range
|
||||
* @param range Formatting range to check for safety
|
||||
* @returns Whether the given formatting range does not overlap with or follow any regions with an error
|
||||
*/
|
||||
isFormatRangeErrorFree(document, range) {
|
||||
const pr = document.parseResult;
|
||||
if (pr.lexerErrors.length || pr.parserErrors.length) {
|
||||
// collect the earliest error line from either
|
||||
const earliestErrLine = Math.min(...pr.lexerErrors.map(e => e.line ?? Number.MAX_VALUE), ...pr.parserErrors.map(e => e.token.startLine ?? Number.MAX_VALUE));
|
||||
// if the earliest error line occurs before or at the end line of the range, then don't format
|
||||
return earliestErrLine > range.end.line;
|
||||
}
|
||||
else {
|
||||
// no errors, ok to format
|
||||
return true;
|
||||
}
|
||||
}
|
||||
formatDocumentRange(document, params) {
|
||||
if (this.isFormatRangeErrorFree(document, params.range)) {
|
||||
return this.doDocumentFormat(document, params.options, params.range);
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
formatDocumentOnType(document, params) {
|
||||
// Format the current line after typing something
|
||||
const range = {
|
||||
start: {
|
||||
character: 0,
|
||||
line: params.position.line
|
||||
},
|
||||
end: params.position
|
||||
};
|
||||
if (this.isFormatRangeErrorFree(document, range)) {
|
||||
return this.doDocumentFormat(document, params.options, range);
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
get formatOnTypeOptions() {
|
||||
return undefined;
|
||||
}
|
||||
doDocumentFormat(document, options, range) {
|
||||
const map = new Map();
|
||||
const collector = (node, mode, formatting) => {
|
||||
const key = this.nodeModeToKey(node, mode);
|
||||
const existing = map.get(key);
|
||||
const priority = formatting.options.priority ?? 0;
|
||||
const existingPriority = existing?.options.priority ?? 0;
|
||||
if (!existing || existingPriority <= priority) {
|
||||
map.set(key, formatting);
|
||||
}
|
||||
};
|
||||
this.collector = collector;
|
||||
this.iterateAstFormatting(document, range);
|
||||
const edits = this.iterateCstFormatting(document, map, options, range);
|
||||
return this.avoidOverlappingEdits(document.textDocument, edits);
|
||||
}
|
||||
avoidOverlappingEdits(textDocument, textEdits) {
|
||||
const edits = [];
|
||||
for (const edit of textEdits) {
|
||||
let last = edits[edits.length - 1];
|
||||
while (last) {
|
||||
const currentStart = textDocument.offsetAt(edit.range.start);
|
||||
const lastEnd = textDocument.offsetAt(last.range.end);
|
||||
if (currentStart < lastEnd) {
|
||||
edits.pop();
|
||||
last = edits[edits.length - 1];
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
edits.push(edit);
|
||||
}
|
||||
return edits.filter(edit => this.isNecessary(edit, textDocument));
|
||||
}
|
||||
iterateAstFormatting(document, range) {
|
||||
const root = document.parseResult.value;
|
||||
this.format(root);
|
||||
const treeIterator = streamAllContents(root).iterator();
|
||||
let result;
|
||||
do {
|
||||
result = treeIterator.next();
|
||||
if (!result.done) {
|
||||
const node = result.value;
|
||||
const inside = this.insideRange(node.$cstNode.range, range);
|
||||
if (inside) {
|
||||
this.format(node);
|
||||
}
|
||||
else {
|
||||
treeIterator.prune();
|
||||
}
|
||||
}
|
||||
} while (!result.done);
|
||||
}
|
||||
nodeModeToKey(node, mode) {
|
||||
return `${node.offset}:${node.end}:${mode}`;
|
||||
}
|
||||
insideRange(inside, total) {
|
||||
if (!total) {
|
||||
return true;
|
||||
}
|
||||
if ((inside.start.line <= total.start.line && inside.end.line >= total.end.line) ||
|
||||
(inside.start.line >= total.start.line && inside.end.line <= total.end.line) ||
|
||||
(inside.start.line <= total.end.line && inside.end.line >= total.end.line)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
isNecessary(edit, document) {
|
||||
return edit.newText !== document.getText(edit.range).replace(/\r/g, '');
|
||||
}
|
||||
iterateCstFormatting(document, formattings, options, range) {
|
||||
const context = {
|
||||
indentation: 0,
|
||||
options,
|
||||
document: document.textDocument
|
||||
};
|
||||
const edits = [];
|
||||
const cstTreeStream = this.iterateCstTree(document, context);
|
||||
const iterator = cstTreeStream.iterator();
|
||||
let lastNode;
|
||||
let result;
|
||||
do {
|
||||
result = iterator.next();
|
||||
if (!result.done) {
|
||||
const node = result.value;
|
||||
const isLeaf = isLeafCstNode(node);
|
||||
const prependKey = this.nodeModeToKey(node, 'prepend');
|
||||
const prependFormatting = formattings.get(prependKey);
|
||||
formattings.delete(prependKey);
|
||||
if (prependFormatting) {
|
||||
const nodeEdits = this.createTextEdit(lastNode, node, prependFormatting, context);
|
||||
for (const edit of nodeEdits) {
|
||||
if (edit && this.insideRange(edit.range, range)) {
|
||||
edits.push(edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
const appendKey = this.nodeModeToKey(node, 'append');
|
||||
const appendFormatting = formattings.get(appendKey);
|
||||
formattings.delete(appendKey);
|
||||
if (appendFormatting) {
|
||||
const nextNode = getNextNode(node);
|
||||
if (nextNode) {
|
||||
const nodeEdits = this.createTextEdit(node, nextNode, appendFormatting, context);
|
||||
for (const edit of nodeEdits) {
|
||||
if (edit && this.insideRange(edit.range, range)) {
|
||||
edits.push(edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!prependFormatting && node.hidden) {
|
||||
const hiddenEdits = this.createHiddenTextEdits(lastNode, node, undefined, context);
|
||||
for (const edit of hiddenEdits) {
|
||||
if (edit && this.insideRange(edit.range, range)) {
|
||||
edits.push(edit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isLeaf) {
|
||||
lastNode = node;
|
||||
}
|
||||
}
|
||||
} while (!result.done);
|
||||
return edits;
|
||||
}
|
||||
createHiddenTextEdits(previous, hidden, formatting, context) {
|
||||
// Don't format the hidden node if it is on the same line as its previous node
|
||||
const startLine = hidden.range.start.line;
|
||||
if (previous && previous.range.end.line === startLine) {
|
||||
return [];
|
||||
}
|
||||
const edits = [];
|
||||
const startRange = {
|
||||
start: {
|
||||
character: 0,
|
||||
line: startLine
|
||||
},
|
||||
end: hidden.range.start
|
||||
};
|
||||
const hiddenStartText = context.document.getText(startRange);
|
||||
const move = this.findFittingMove(startRange, formatting?.moves ?? [], context);
|
||||
const hiddenStartChar = this.getExistingIndentationCharacterCount(hiddenStartText, context);
|
||||
const expectedStartChar = this.getIndentationCharacterCount(context, move);
|
||||
const characterIncrease = expectedStartChar - hiddenStartChar;
|
||||
if (characterIncrease === 0) {
|
||||
return [];
|
||||
}
|
||||
let newText = '';
|
||||
if (characterIncrease > 0) {
|
||||
newText = (context.options.insertSpaces ? ' ' : '\t').repeat(characterIncrease);
|
||||
}
|
||||
const lines = hidden.text.split('\n');
|
||||
lines[0] = hiddenStartText + lines[0];
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const currentLine = startLine + i;
|
||||
const pos = {
|
||||
character: 0,
|
||||
line: currentLine
|
||||
};
|
||||
if (characterIncrease > 0) {
|
||||
edits.push({
|
||||
newText,
|
||||
range: {
|
||||
start: pos,
|
||||
end: pos
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
const currentText = lines[i];
|
||||
let j = 0;
|
||||
for (; j < currentText.length; j++) {
|
||||
const char = currentText.charAt(j);
|
||||
if (char !== ' ' && char !== '\t') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
edits.push({
|
||||
newText: '',
|
||||
range: {
|
||||
start: pos,
|
||||
end: {
|
||||
line: currentLine,
|
||||
// Remove as much whitespace characters as necessary
|
||||
// In some cases `characterIncrease` is actually larger than the amount of whitespace available
|
||||
// So we simply remove all whitespace characters `j`
|
||||
character: Math.min(j, Math.abs(characterIncrease))
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return edits;
|
||||
}
|
||||
getExistingIndentationCharacterCount(text, context) {
|
||||
const tabWhitespace = ' '.repeat(context.options.tabSize);
|
||||
let replacement = '';
|
||||
let regex;
|
||||
if (context.options.insertSpaces) {
|
||||
regex = new RegExp('\\t', 'g');
|
||||
replacement = tabWhitespace;
|
||||
}
|
||||
else {
|
||||
regex = new RegExp(tabWhitespace, 'g');
|
||||
replacement = '\t';
|
||||
}
|
||||
const normalized = text.replace(regex, replacement);
|
||||
return normalized.length;
|
||||
}
|
||||
getIndentationCharacterCount(context, formattingMove) {
|
||||
let indentation = context.indentation;
|
||||
if (formattingMove && formattingMove.tabs) {
|
||||
indentation += formattingMove.tabs;
|
||||
}
|
||||
return (context.options.insertSpaces ? context.options.tabSize : 1) * indentation;
|
||||
}
|
||||
createTextEdit(a, b, formatting, context) {
|
||||
if (b.hidden) {
|
||||
return this.createHiddenTextEdits(a, b, formatting, context);
|
||||
}
|
||||
// Ignore the edit if the previous node ends after the current node starts
|
||||
if (a && (a.range.end.line > b.range.start.line ||
|
||||
(a.range.end.line === b.range.start.line && a.range.end.character > b.range.start.character))) {
|
||||
return [];
|
||||
}
|
||||
const betweenRange = {
|
||||
start: a?.range.end ?? {
|
||||
character: 0,
|
||||
line: 0
|
||||
},
|
||||
end: b.range.start
|
||||
};
|
||||
const move = this.findFittingMove(betweenRange, formatting.moves, context);
|
||||
if (!move) {
|
||||
return [];
|
||||
}
|
||||
const chars = move.characters;
|
||||
const lines = move.lines;
|
||||
const tabs = move.tabs;
|
||||
const existingIndentation = context.indentation;
|
||||
context.indentation += (tabs ?? 0);
|
||||
const edits = [];
|
||||
if (chars !== undefined) {
|
||||
// Do not apply formatting on the same line if preceding node is hidden
|
||||
if (!a?.hidden) {
|
||||
edits.push(this.createSpaceTextEdit(betweenRange, chars, formatting.options));
|
||||
}
|
||||
}
|
||||
else if (lines !== undefined) {
|
||||
edits.push(this.createLineTextEdit(betweenRange, lines, context, formatting.options));
|
||||
}
|
||||
else if (tabs !== undefined) {
|
||||
edits.push(this.createTabTextEdit(betweenRange, Boolean(a), context));
|
||||
}
|
||||
if (isLeafCstNode(b)) {
|
||||
context.indentation = existingIndentation;
|
||||
}
|
||||
return edits;
|
||||
}
|
||||
createSpaceTextEdit(range, spaces, options) {
|
||||
if (range.start.line === range.end.line) {
|
||||
const existingSpaces = range.end.character - range.start.character;
|
||||
spaces = this.fitIntoOptions(spaces, existingSpaces, options);
|
||||
}
|
||||
const newText = ' '.repeat(spaces);
|
||||
return {
|
||||
newText,
|
||||
range
|
||||
};
|
||||
}
|
||||
createLineTextEdit(range, lines, context, options) {
|
||||
const existingLines = range.end.line - range.start.line;
|
||||
lines = this.fitIntoOptions(lines, existingLines, options);
|
||||
const indent = context.options.insertSpaces ? ' '.repeat(context.options.tabSize) : '\t';
|
||||
const nodeIndent = indent.repeat(context.indentation);
|
||||
const newText = `${'\n'.repeat(lines)}${nodeIndent}`;
|
||||
return {
|
||||
newText,
|
||||
range
|
||||
};
|
||||
}
|
||||
createTabTextEdit(range, hasPrevious, context) {
|
||||
const indent = context.options.insertSpaces ? ' '.repeat(context.options.tabSize) : '\t';
|
||||
const nodeIndent = indent.repeat(context.indentation);
|
||||
const minimumLines = hasPrevious ? 1 : 0;
|
||||
const lines = Math.max(range.end.line - range.start.line, minimumLines);
|
||||
const newText = `${'\n'.repeat(lines)}${nodeIndent}`;
|
||||
return {
|
||||
newText,
|
||||
range
|
||||
};
|
||||
}
|
||||
fitIntoOptions(value, existing, options) {
|
||||
if (options.allowMore) {
|
||||
value = Math.max(existing, value);
|
||||
}
|
||||
else if (options.allowLess) {
|
||||
value = Math.min(existing, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
findFittingMove(range, moves, _context) {
|
||||
if (moves.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
else if (moves.length === 1) {
|
||||
return moves[0];
|
||||
}
|
||||
const existingLines = range.end.line - range.start.line;
|
||||
for (const move of moves) {
|
||||
if (move.lines !== undefined && existingLines <= move.lines) {
|
||||
return move;
|
||||
}
|
||||
else if (move.lines === undefined && existingLines === 0) {
|
||||
return move;
|
||||
}
|
||||
}
|
||||
// Return the last move
|
||||
return moves[moves.length - 1];
|
||||
}
|
||||
iterateCstTree(document, context) {
|
||||
const root = document.parseResult.value;
|
||||
const rootCst = root.$cstNode;
|
||||
if (!rootCst) {
|
||||
return EMPTY_STREAM;
|
||||
}
|
||||
return new TreeStreamImpl(rootCst, node => this.iterateCst(node, context));
|
||||
}
|
||||
iterateCst(node, context) {
|
||||
if (!isCompositeCstNode(node)) {
|
||||
return EMPTY_STREAM;
|
||||
}
|
||||
const initial = context.indentation;
|
||||
return new StreamImpl(() => ({ index: 0 }), (state) => {
|
||||
if (state.index < node.content.length) {
|
||||
return { done: false, value: node.content[state.index++] };
|
||||
}
|
||||
else {
|
||||
// Reset the indentation to the level when we entered the node
|
||||
context.indentation = initial;
|
||||
return DONE_RESULT;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
export class DefaultNodeFormatter {
|
||||
constructor(astNode, collector) {
|
||||
this.astNode = astNode;
|
||||
this.collector = collector;
|
||||
}
|
||||
node(node) {
|
||||
return new FormattingRegion(node.$cstNode ? [node.$cstNode] : [], this.collector);
|
||||
}
|
||||
nodes(...nodes) {
|
||||
const cstNodes = [];
|
||||
for (const node of nodes) {
|
||||
if (node.$cstNode) {
|
||||
cstNodes.push(node.$cstNode);
|
||||
}
|
||||
}
|
||||
return new FormattingRegion(cstNodes, this.collector);
|
||||
}
|
||||
property(feature, index) {
|
||||
const cstNode = findNodeForProperty(this.astNode.$cstNode, feature, index);
|
||||
return new FormattingRegion(cstNode ? [cstNode] : [], this.collector);
|
||||
}
|
||||
properties(...features) {
|
||||
const nodes = [];
|
||||
for (const feature of features) {
|
||||
const cstNodes = findNodesForProperty(this.astNode.$cstNode, feature);
|
||||
nodes.push(...cstNodes);
|
||||
}
|
||||
return new FormattingRegion(nodes, this.collector);
|
||||
}
|
||||
keyword(keyword, index) {
|
||||
const cstNode = findNodeForKeyword(this.astNode.$cstNode, keyword, index);
|
||||
return new FormattingRegion(cstNode ? [cstNode] : [], this.collector);
|
||||
}
|
||||
keywords(...keywords) {
|
||||
const nodes = [];
|
||||
for (const feature of keywords) {
|
||||
const cstNodes = findNodesForKeyword(this.astNode.$cstNode, feature);
|
||||
nodes.push(...cstNodes);
|
||||
}
|
||||
return new FormattingRegion(nodes, this.collector);
|
||||
}
|
||||
cst(nodes) {
|
||||
return new FormattingRegion([...nodes], this.collector);
|
||||
}
|
||||
interior(start, end) {
|
||||
const startNodes = start.nodes;
|
||||
const endNodes = end.nodes;
|
||||
if (startNodes.length !== 1 || endNodes.length !== 1) {
|
||||
return new FormattingRegion([], this.collector);
|
||||
}
|
||||
let startNode = startNodes[0];
|
||||
let endNode = endNodes[0];
|
||||
if (startNode.offset > endNode.offset) {
|
||||
const intermediate = startNode;
|
||||
startNode = endNode;
|
||||
endNode = intermediate;
|
||||
}
|
||||
return new FormattingRegion(getInteriorNodes(startNode, endNode), this.collector);
|
||||
}
|
||||
}
|
||||
export class FormattingRegion {
|
||||
constructor(nodes, collector) {
|
||||
this.nodes = nodes;
|
||||
this.collector = collector;
|
||||
}
|
||||
/**
|
||||
* Prepends the specified formatting to all nodes of this region.
|
||||
*/
|
||||
prepend(formatting) {
|
||||
for (const node of this.nodes) {
|
||||
this.collector(node, 'prepend', formatting);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Appends the specified formatting to all nodes of this region.
|
||||
*/
|
||||
append(formatting) {
|
||||
for (const node of this.nodes) {
|
||||
this.collector(node, 'append', formatting);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sorrounds all nodes of this region with the specified formatting.
|
||||
* Functionally the same as invoking `prepend` and `append` with the same formatting.
|
||||
*/
|
||||
surround(formatting) {
|
||||
for (const node of this.nodes) {
|
||||
this.collector(node, 'prepend', formatting);
|
||||
this.collector(node, 'append', formatting);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Creates a copy of this region with a slice of the selected nodes.
|
||||
* For both start and end, a negative index can be used to indicate an offset from the end of the array.
|
||||
* For example, -2 refers to the second to last element of the array.
|
||||
* @param start The beginning index of the specified portion of the region. If start is undefined, then the slice begins at index 0.
|
||||
* @param end The end index of the specified portion of the region. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the region.
|
||||
*/
|
||||
slice(start, end) {
|
||||
return new FormattingRegion(this.nodes.slice(start, end), this.collector);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Contains utilities to easily create formatting actions that can be applied to a {@link FormattingRegion}.
|
||||
*/
|
||||
export var Formatting;
|
||||
(function (Formatting) {
|
||||
/**
|
||||
* Creates a new formatting that tries to fit the existing text into one of the specified formattings.
|
||||
* @param formattings All possible formattings.
|
||||
*/
|
||||
function fit(...formattings) {
|
||||
return {
|
||||
options: {},
|
||||
moves: formattings.flatMap(e => e.moves).sort(compareMoves)
|
||||
};
|
||||
}
|
||||
Formatting.fit = fit;
|
||||
/**
|
||||
* Creates a new formatting that removes all spaces
|
||||
*/
|
||||
function noSpace(options) {
|
||||
return spaces(0, options);
|
||||
}
|
||||
Formatting.noSpace = noSpace;
|
||||
/**
|
||||
* Creates a new formatting that creates a single space
|
||||
*/
|
||||
function oneSpace(options) {
|
||||
return spaces(1, options);
|
||||
}
|
||||
Formatting.oneSpace = oneSpace;
|
||||
/**
|
||||
* Creates a new formatting that creates the specified amount of spaces
|
||||
*
|
||||
* @param count The amount of spaces to be inserted
|
||||
*/
|
||||
function spaces(count, options) {
|
||||
return {
|
||||
options: options ?? {},
|
||||
moves: [{
|
||||
characters: count
|
||||
}]
|
||||
};
|
||||
}
|
||||
Formatting.spaces = spaces;
|
||||
/**
|
||||
* Creates a new formatting that moves an element to the next line
|
||||
*/
|
||||
function newLine(options) {
|
||||
return newLines(1, options);
|
||||
}
|
||||
Formatting.newLine = newLine;
|
||||
/**
|
||||
* Creates a new formatting that creates the specified amount of new lines.
|
||||
*/
|
||||
function newLines(count, options) {
|
||||
return {
|
||||
options: options ?? {},
|
||||
moves: [{
|
||||
lines: count
|
||||
}]
|
||||
};
|
||||
}
|
||||
Formatting.newLines = newLines;
|
||||
/**
|
||||
* Creates a new formatting that moves the element to a new line and indents that line.
|
||||
*/
|
||||
function indent(options) {
|
||||
return {
|
||||
options: options ?? {},
|
||||
moves: [{
|
||||
tabs: 1,
|
||||
lines: 1
|
||||
}]
|
||||
};
|
||||
}
|
||||
Formatting.indent = indent;
|
||||
/**
|
||||
* Creates a new formatting that removes all indentation.
|
||||
*/
|
||||
function noIndent(options) {
|
||||
return {
|
||||
options: options ?? {},
|
||||
moves: [{
|
||||
tabs: 0
|
||||
}]
|
||||
};
|
||||
}
|
||||
Formatting.noIndent = noIndent;
|
||||
function compareMoves(a, b) {
|
||||
const aLines = a.lines ?? 0;
|
||||
const bLines = b.lines ?? 0;
|
||||
const aTabs = a.tabs ?? 0;
|
||||
const bTabs = b.tabs ?? 0;
|
||||
const aSpaces = a.characters ?? 0;
|
||||
const bSpaces = b.characters ?? 0;
|
||||
if (aLines < bLines) {
|
||||
return -1;
|
||||
}
|
||||
else if (aLines > bLines) {
|
||||
return 1;
|
||||
}
|
||||
else if (aTabs < bTabs) {
|
||||
return -1;
|
||||
}
|
||||
else if (aTabs > bTabs) {
|
||||
return 1;
|
||||
}
|
||||
else if (aSpaces < bSpaces) {
|
||||
return -1;
|
||||
}
|
||||
else if (aSpaces > bSpaces) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
})(Formatting || (Formatting = {}));
|
||||
//# sourceMappingURL=formatter.js.map
|
||||
48
frontend/node_modules/langium/lib/lsp/fuzzy-matcher.js
generated
vendored
Normal file
48
frontend/node_modules/langium/lib/lsp/fuzzy-matcher.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
export class DefaultFuzzyMatcher {
|
||||
match(query, text) {
|
||||
if (query.length === 0) {
|
||||
return true;
|
||||
}
|
||||
let matchedFirstCharacter = false;
|
||||
let previous;
|
||||
let character = 0;
|
||||
const len = text.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const strChar = text.charCodeAt(i);
|
||||
const testChar = query.charCodeAt(character);
|
||||
if (strChar === testChar || this.toUpperCharCode(strChar) === this.toUpperCharCode(testChar)) {
|
||||
matchedFirstCharacter || (matchedFirstCharacter = previous === undefined || // Beginning of word
|
||||
this.isWordTransition(previous, strChar));
|
||||
if (matchedFirstCharacter) {
|
||||
character++;
|
||||
}
|
||||
if (character === query.length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
previous = strChar;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
isWordTransition(previous, current) {
|
||||
return a <= previous && previous <= z && A <= current && current <= Z || // camelCase transition
|
||||
previous === _ && current !== _; // snake_case transition
|
||||
}
|
||||
toUpperCharCode(charCode) {
|
||||
if (a <= charCode && charCode <= z) {
|
||||
return charCode - 32;
|
||||
}
|
||||
return charCode;
|
||||
}
|
||||
}
|
||||
const a = 'a'.charCodeAt(0);
|
||||
const z = 'z'.charCodeAt(0);
|
||||
const A = 'A'.charCodeAt(0);
|
||||
const Z = 'Z'.charCodeAt(0);
|
||||
const _ = '_'.charCodeAt(0);
|
||||
//# sourceMappingURL=fuzzy-matcher.js.map
|
||||
77
frontend/node_modules/langium/lib/lsp/hover-provider.js
generated
vendored
Normal file
77
frontend/node_modules/langium/lib/lsp/hover-provider.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { findCommentNode, findDeclarationNodeAtOffset } from '../utils/cst-utils.js';
|
||||
import { isKeyword } from '../languages/generated/ast.js';
|
||||
import { isJSDoc, parseJSDoc } from '../documentation/jsdoc.js';
|
||||
import { isAstNodeWithComment } from '../serializer/json-serializer.js';
|
||||
export class AstNodeHoverProvider {
|
||||
constructor(services) {
|
||||
this.references = services.references.References;
|
||||
this.grammarConfig = services.parser.GrammarConfig;
|
||||
}
|
||||
async getHoverContent(document, params) {
|
||||
const rootNode = document.parseResult?.value?.$cstNode;
|
||||
if (rootNode) {
|
||||
const offset = document.textDocument.offsetAt(params.position);
|
||||
const cstNode = findDeclarationNodeAtOffset(rootNode, offset, this.grammarConfig.nameRegexp);
|
||||
if (cstNode && cstNode.offset + cstNode.length > offset) {
|
||||
const contents = [];
|
||||
const targetNodes = this.references.findDeclarations(cstNode);
|
||||
for (const targetNode of targetNodes) {
|
||||
const content = await this.getAstNodeHoverContent(targetNode);
|
||||
if (typeof content === 'string') {
|
||||
contents.push(content);
|
||||
}
|
||||
}
|
||||
if (contents.length > 0) {
|
||||
return {
|
||||
contents: {
|
||||
kind: 'markdown',
|
||||
value: contents.join(' ')
|
||||
}
|
||||
};
|
||||
}
|
||||
// Add support for documentation on keywords
|
||||
if (isKeyword(cstNode.grammarSource)) {
|
||||
return this.getKeywordHoverContent(cstNode.grammarSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
getKeywordHoverContent(node) {
|
||||
let comment = isAstNodeWithComment(node) ? node.$comment : undefined;
|
||||
if (!comment) {
|
||||
comment = findCommentNode(node.$cstNode, ['ML_COMMENT'])?.text;
|
||||
}
|
||||
if (comment && isJSDoc(comment)) {
|
||||
const content = parseJSDoc(comment).toMarkdown();
|
||||
if (content) {
|
||||
return {
|
||||
contents: {
|
||||
kind: 'markdown',
|
||||
value: content
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
export class MultilineCommentHoverProvider extends AstNodeHoverProvider {
|
||||
constructor(services) {
|
||||
super(services);
|
||||
this.documentationProvider = services.documentation.DocumentationProvider;
|
||||
}
|
||||
getAstNodeHoverContent(node) {
|
||||
const content = this.documentationProvider.getDocumentation(node);
|
||||
if (content) {
|
||||
return content;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=hover-provider.js.map
|
||||
28
frontend/node_modules/langium/lib/lsp/inlay-hint-provider.d.ts
generated
vendored
Normal file
28
frontend/node_modules/langium/lib/lsp/inlay-hint-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import type { InlayHint, InlayHintParams } from 'vscode-languageserver';
|
||||
import type { AstNode } from '../syntax-tree.js';
|
||||
import { CancellationToken } from '../utils/cancellation.js';
|
||||
import type { MaybePromise } from '../utils/promise-utils.js';
|
||||
import type { LangiumDocument } from '../workspace/documents.js';
|
||||
export type InlayHintAcceptor = (inlayHint: InlayHint) => void;
|
||||
/**
|
||||
* Provider for the inlay hint LSP type.
|
||||
*/
|
||||
export interface InlayHintProvider {
|
||||
/**
|
||||
* Handle the `textDocument.inlayHint` language server request.
|
||||
*
|
||||
* @throws `OperationCancelled` if cancellation is detected during execution
|
||||
* @throws `ResponseError` if an error is detected that should be sent as response to the client
|
||||
*/
|
||||
getInlayHints(document: LangiumDocument, params: InlayHintParams, cancelToken?: CancellationToken): MaybePromise<InlayHint[] | undefined>;
|
||||
}
|
||||
export declare abstract class AbstractInlayHintProvider implements InlayHintProvider {
|
||||
getInlayHints(document: LangiumDocument, params: InlayHintParams, cancelToken?: CancellationToken): Promise<InlayHint[] | undefined>;
|
||||
abstract computeInlayHint(astNode: AstNode, acceptor: InlayHintAcceptor): void;
|
||||
}
|
||||
//# sourceMappingURL=inlay-hint-provider.d.ts.map
|
||||
21
frontend/node_modules/langium/lib/lsp/inlay-hint-provider.js
generated
vendored
Normal file
21
frontend/node_modules/langium/lib/lsp/inlay-hint-provider.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { CancellationToken } from '../utils/cancellation.js';
|
||||
import { streamAst } from '../utils/ast-utils.js';
|
||||
import { interruptAndCheck } from '../utils/promise-utils.js';
|
||||
export class AbstractInlayHintProvider {
|
||||
async getInlayHints(document, params, cancelToken = CancellationToken.None) {
|
||||
const root = document.parseResult.value;
|
||||
const inlayHints = [];
|
||||
const acceptor = hint => inlayHints.push(hint);
|
||||
for (const node of streamAst(root, { range: params.range })) {
|
||||
await interruptAndCheck(cancelToken);
|
||||
this.computeInlayHint(node, acceptor);
|
||||
}
|
||||
return inlayHints;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=inlay-hint-provider.js.map
|
||||
1
frontend/node_modules/langium/lib/lsp/inlay-hint-provider.js.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/inlay-hint-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"inlay-hint-provider.js","sourceRoot":"","sources":["../../src/lsp/inlay-hint-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAIhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAiB9D,MAAM,OAAgB,yBAAyB;IAC3C,KAAK,CAAC,aAAa,CAAC,QAAyB,EAAE,MAAuB,EAAE,WAAW,GAAG,iBAAiB,CAAC,IAAI;QACxG,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC;QACxC,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAsB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClE,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;YAC1D,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;YACrC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CAGJ"}
|
||||
1
frontend/node_modules/langium/lib/lsp/lsp-services.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/lsp-services.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"lsp-services.d.ts","sourceRoot":"","sources":["../../src/lsp/lsp-services.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAEhF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,GAAG,wBAAwB,CAAC;AAEzF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,CAAC,GAAG,EAAE;QACV,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;QAChD,QAAQ,CAAC,yBAAyB,CAAC,EAAE,yBAAyB,CAAA;QAC9D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;QACxD,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAA;QACtC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;QACpD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;QAChD,QAAQ,CAAC,YAAY,CAAC,EAAE,sBAAsB,CAAA;QAC9C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,sBAAsB,CAAA;QACxD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;QAChD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;QAChD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;QACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAA;QACxC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;QAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,qBAAqB,CAAA;QAC9C,QAAQ,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;QACtD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;QACtD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;QAClD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;QAC9C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;QAC5C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;KACvD,CAAC;IACF,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;CACzC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,QAAQ,CAAC,GAAG,EAAE;QACV,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAA;QAChC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAA;QACrD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;QACtD,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;QACpD,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;QACnC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;QACvC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;QAC3C,QAAQ,CAAC,uBAAuB,CAAC,EAAE,uBAAuB,CAAA;KAC7D,CAAC;IACF,QAAQ,CAAC,SAAS,EAAE;QAChB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;QACnD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAA;KAC9D,CAAA;CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAA;AAEvE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,eAAe,CAAC,CAAA;AAEjE;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,WAAW,CAAC,wBAAwB,CAAC,CAAA;AAEnF;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAA"}
|
||||
7
frontend/node_modules/langium/lib/lsp/lsp-services.js
generated
vendored
Normal file
7
frontend/node_modules/langium/lib/lsp/lsp-services.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
export {};
|
||||
//# sourceMappingURL=lsp-services.js.map
|
||||
25
frontend/node_modules/langium/lib/lsp/node-kind-provider.js
generated
vendored
Normal file
25
frontend/node_modules/langium/lib/lsp/node-kind-provider.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { CompletionItemKind, SymbolKind } from 'vscode-languageserver';
|
||||
/**
|
||||
* Default implementation of the `NodeKindProvider` interface.
|
||||
* @remarks This implementation returns `SymbolKind.Field` for all nodes and `CompletionItemKind.Reference` for all nodes. Extend this class to customize symbol and completion types your langauge.
|
||||
*/
|
||||
export class DefaultNodeKindProvider {
|
||||
/**
|
||||
* @remarks The default implementation returns `SymbolKind.Field` for all nodes.
|
||||
*/
|
||||
getSymbolKind(_node) {
|
||||
return SymbolKind.Field;
|
||||
}
|
||||
/**
|
||||
* @remarks The default implementation returns `CompletionItemKind.Reference` for all nodes.
|
||||
*/
|
||||
getCompletionItemKind(_node) {
|
||||
return CompletionItemKind.Reference;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=node-kind-provider.js.map
|
||||
1
frontend/node_modules/langium/lib/lsp/references-provider.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/references-provider.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"references-provider.d.ts","sourceRoot":"","sources":["../../src/lsp/references-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;;;;;;OAUG;IACH,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;CACjI;AAED,qBAAa,yBAA0B,YAAW,kBAAkB;IAChE,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;gBAEpC,QAAQ,EAAE,eAAe;IAMrC,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAc9H,SAAS,CAAC,aAAa,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,GAAG,QAAQ,EAAE;CAWtH"}
|
||||
54
frontend/node_modules/langium/lib/lsp/rename-provider.d.ts
generated
vendored
Normal file
54
frontend/node_modules/langium/lib/lsp/rename-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import type { Position, Range, RenameParams, TextDocumentPositionParams, WorkspaceEdit } from 'vscode-languageserver-protocol';
|
||||
import type { CancellationToken } from '../utils/cancellation.js';
|
||||
import type { GrammarConfig } from '../languages/grammar-config.js';
|
||||
import type { NameProvider } from '../references/name-provider.js';
|
||||
import type { References } from '../references/references.js';
|
||||
import type { LangiumServices } from './lsp-services.js';
|
||||
import type { CstNode } from '../syntax-tree.js';
|
||||
import type { MaybePromise } from '../utils/promise-utils.js';
|
||||
import type { LangiumDocument } from '../workspace/documents.js';
|
||||
/**
|
||||
* Language-specific service for handling rename requests and prepare rename requests.
|
||||
*/
|
||||
export interface RenameProvider {
|
||||
/**
|
||||
* Handle a rename request.
|
||||
*
|
||||
* @param document The document in which the rename request was triggered.
|
||||
* @param params The rename parameters.
|
||||
* @param cancelToken A cancellation token that can be used to cancel the request.
|
||||
* @returns A workspace edit that describes the changes to be applied to the workspace.
|
||||
*
|
||||
* @throws `OperationCancelled` if cancellation is detected during execution
|
||||
* @throws `ResponseError` if an error is detected that should be sent as response to the client
|
||||
*/
|
||||
rename(document: LangiumDocument, params: RenameParams, cancelToken?: CancellationToken): MaybePromise<WorkspaceEdit | undefined>;
|
||||
/**
|
||||
* Handle a prepare rename request.
|
||||
*
|
||||
* @param document The document in which the prepare rename request was triggered.
|
||||
* @param params The prepare rename parameters.
|
||||
* @param cancelToken A cancellation token that can be used to cancel the request.
|
||||
* @returns A range that describes the range of the symbol to be renamed.
|
||||
*
|
||||
* @throws `OperationCancelled` if cancellation is detected during execution
|
||||
* @throws `ResponseError` if an error is detected that should be sent as response to the client
|
||||
*/
|
||||
prepareRename(document: LangiumDocument, params: TextDocumentPositionParams, cancelToken?: CancellationToken): MaybePromise<Range | undefined>;
|
||||
}
|
||||
export declare class DefaultRenameProvider implements RenameProvider {
|
||||
protected readonly references: References;
|
||||
protected readonly nameProvider: NameProvider;
|
||||
protected readonly grammarConfig: GrammarConfig;
|
||||
constructor(services: LangiumServices);
|
||||
rename(document: LangiumDocument, params: RenameParams, _cancelToken?: CancellationToken): Promise<WorkspaceEdit | undefined>;
|
||||
prepareRename(document: LangiumDocument, params: TextDocumentPositionParams, _cancelToken?: CancellationToken): MaybePromise<Range | undefined>;
|
||||
protected renameNodeRange(doc: LangiumDocument, position: Position): Range | undefined;
|
||||
protected isNameNode(leafNode: CstNode | undefined): boolean | undefined;
|
||||
}
|
||||
//# sourceMappingURL=rename-provider.d.ts.map
|
||||
1
frontend/node_modules/langium/lib/lsp/rename-provider.d.ts.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/rename-provider.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"rename-provider.d.ts","sourceRoot":"","sources":["../../src/lsp/rename-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAEhF,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/H,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAKjE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAElI;;;;;;;;;;OAUG;IACH,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,0BAA0B,EAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;CAClJ;AAED,qBAAa,qBAAsB,YAAW,cAAc;IAExD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;gBAEpC,QAAQ,EAAE,eAAe;IAM/B,MAAM,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAgCnI,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,0BAA0B,EAAE,YAAY,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;IAI/I,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,GAAG,SAAS;IAiBtF,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS;CAG3E"}
|
||||
70
frontend/node_modules/langium/lib/lsp/rename-provider.js
generated
vendored
Normal file
70
frontend/node_modules/langium/lib/lsp/rename-provider.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2021 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { TextEdit } from 'vscode-languageserver-types';
|
||||
import { isNamed } from '../references/name-provider.js';
|
||||
import { findDeclarationNodeAtOffset } from '../utils/cst-utils.js';
|
||||
export class DefaultRenameProvider {
|
||||
constructor(services) {
|
||||
this.references = services.references.References;
|
||||
this.nameProvider = services.references.NameProvider;
|
||||
this.grammarConfig = services.parser.GrammarConfig;
|
||||
}
|
||||
async rename(document, params, _cancelToken) {
|
||||
const changes = {};
|
||||
const rootNode = document.parseResult.value.$cstNode;
|
||||
if (!rootNode) {
|
||||
return undefined;
|
||||
}
|
||||
const offset = document.textDocument.offsetAt(params.position);
|
||||
const leafNode = findDeclarationNodeAtOffset(rootNode, offset, this.grammarConfig.nameRegexp);
|
||||
if (!leafNode) {
|
||||
return undefined;
|
||||
}
|
||||
const targetNodes = this.references.findDeclarations(leafNode);
|
||||
if (targetNodes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
// We only need to find the references to a single target node
|
||||
// All other nodes should be found via `findReferences` if done correctly
|
||||
const targetNode = targetNodes[0];
|
||||
const options = { onlyLocal: false, includeDeclaration: true };
|
||||
const references = this.references.findReferences(targetNode, options);
|
||||
for (const ref of references) {
|
||||
const change = TextEdit.replace(ref.segment.range, params.newName);
|
||||
const uri = ref.sourceUri.toString();
|
||||
if (changes[uri]) {
|
||||
changes[uri].push(change);
|
||||
}
|
||||
else {
|
||||
changes[uri] = [change];
|
||||
}
|
||||
}
|
||||
return { changes };
|
||||
}
|
||||
prepareRename(document, params, _cancelToken) {
|
||||
return this.renameNodeRange(document, params.position);
|
||||
}
|
||||
renameNodeRange(doc, position) {
|
||||
const rootNode = doc.parseResult.value.$cstNode;
|
||||
const offset = doc.textDocument.offsetAt(position);
|
||||
if (rootNode) {
|
||||
const leafNode = findDeclarationNodeAtOffset(rootNode, offset, this.grammarConfig.nameRegexp);
|
||||
if (!leafNode) {
|
||||
return undefined;
|
||||
}
|
||||
const isCrossRef = this.references.findDeclarations(leafNode).length > 0;
|
||||
// return range if selected CstNode is the name node or it is a crosslink which points to a declaration
|
||||
if (isCrossRef || this.isNameNode(leafNode)) {
|
||||
return leafNode.range;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
isNameNode(leafNode) {
|
||||
return leafNode?.astNode && isNamed(leafNode.astNode) && leafNode === this.nameProvider.getNameNode(leafNode.astNode);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=rename-provider.js.map
|
||||
415
frontend/node_modules/langium/lib/lsp/semantic-token-provider.js
generated
vendored
Normal file
415
frontend/node_modules/langium/lib/lsp/semantic-token-provider.js
generated
vendored
Normal file
@@ -0,0 +1,415 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2022 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { SemanticTokensBuilder as BaseSemanticTokensBuilder, SemanticTokenModifiers, SemanticTokenTypes } from 'vscode-languageserver';
|
||||
import { CancellationToken } from '../utils/cancellation.js';
|
||||
import { streamAst } from '../utils/ast-utils.js';
|
||||
import { inRange } from '../utils/cst-utils.js';
|
||||
import { findNodeForKeyword, findNodeForProperty, findNodesForKeyword, findNodesForProperty } from '../utils/grammar-utils.js';
|
||||
import { interruptAndCheck } from '../utils/promise-utils.js';
|
||||
export const AllSemanticTokenTypes = {
|
||||
[SemanticTokenTypes.class]: 0,
|
||||
[SemanticTokenTypes.comment]: 1,
|
||||
[SemanticTokenTypes.enum]: 2,
|
||||
[SemanticTokenTypes.enumMember]: 3,
|
||||
[SemanticTokenTypes.event]: 4,
|
||||
[SemanticTokenTypes.function]: 5,
|
||||
[SemanticTokenTypes.interface]: 6,
|
||||
[SemanticTokenTypes.keyword]: 7,
|
||||
[SemanticTokenTypes.macro]: 8,
|
||||
[SemanticTokenTypes.method]: 9,
|
||||
[SemanticTokenTypes.modifier]: 10,
|
||||
[SemanticTokenTypes.namespace]: 11,
|
||||
[SemanticTokenTypes.number]: 12,
|
||||
[SemanticTokenTypes.operator]: 13,
|
||||
[SemanticTokenTypes.parameter]: 14,
|
||||
[SemanticTokenTypes.property]: 15,
|
||||
[SemanticTokenTypes.regexp]: 16,
|
||||
[SemanticTokenTypes.string]: 17,
|
||||
[SemanticTokenTypes.struct]: 18,
|
||||
[SemanticTokenTypes.type]: 19,
|
||||
[SemanticTokenTypes.typeParameter]: 20,
|
||||
[SemanticTokenTypes.variable]: 21,
|
||||
[SemanticTokenTypes.decorator]: 22
|
||||
};
|
||||
export const AllSemanticTokenModifiers = {
|
||||
[SemanticTokenModifiers.abstract]: 1 << 0,
|
||||
[SemanticTokenModifiers.async]: 1 << 1,
|
||||
[SemanticTokenModifiers.declaration]: 1 << 2,
|
||||
[SemanticTokenModifiers.defaultLibrary]: 1 << 3,
|
||||
[SemanticTokenModifiers.definition]: 1 << 4,
|
||||
[SemanticTokenModifiers.deprecated]: 1 << 5,
|
||||
[SemanticTokenModifiers.documentation]: 1 << 6,
|
||||
[SemanticTokenModifiers.modification]: 1 << 7,
|
||||
[SemanticTokenModifiers.readonly]: 1 << 8,
|
||||
[SemanticTokenModifiers.static]: 1 << 9
|
||||
};
|
||||
/**
|
||||
* @deprecated Since 3.2.0. `SemanticTokenProvider` now supplies its own options.
|
||||
*/
|
||||
export const DefaultSemanticTokenOptions = {
|
||||
legend: {
|
||||
tokenTypes: Object.keys(AllSemanticTokenTypes),
|
||||
tokenModifiers: Object.keys(AllSemanticTokenModifiers)
|
||||
},
|
||||
full: {
|
||||
delta: false
|
||||
},
|
||||
range: true
|
||||
};
|
||||
export function mergeSemanticTokenProviderOptions(options) {
|
||||
const tokenTypes = [];
|
||||
const tokenModifiers = [];
|
||||
let full = true;
|
||||
let delta = true;
|
||||
let range = true;
|
||||
for (const option of options) {
|
||||
if (!option) {
|
||||
continue;
|
||||
}
|
||||
option.legend.tokenTypes.forEach((tokenType, index) => {
|
||||
const existing = tokenTypes[index];
|
||||
if (existing && existing !== tokenType) {
|
||||
throw new Error(`Cannot merge '${existing}' and '${tokenType}' token types. They use the same index ${index}.`);
|
||||
}
|
||||
else {
|
||||
tokenTypes[index] = tokenType;
|
||||
}
|
||||
});
|
||||
option.legend.tokenModifiers.forEach((tokenModifier, index) => {
|
||||
const existing = tokenModifiers[index];
|
||||
if (existing && existing !== tokenModifier) {
|
||||
throw new Error(`Cannot merge '${existing}' and '${tokenModifier}' token modifier. They use the same index ${index}.`);
|
||||
}
|
||||
else {
|
||||
tokenModifiers[index] = tokenModifier;
|
||||
}
|
||||
});
|
||||
if (!option.full) {
|
||||
full = false;
|
||||
}
|
||||
else if (typeof option.full === 'object' && !option.full.delta) {
|
||||
delta = false;
|
||||
}
|
||||
if (!option.range) {
|
||||
range = false;
|
||||
}
|
||||
}
|
||||
return {
|
||||
legend: {
|
||||
tokenTypes,
|
||||
tokenModifiers,
|
||||
},
|
||||
full: full && { delta },
|
||||
range,
|
||||
};
|
||||
}
|
||||
export class SemanticTokensBuilder extends BaseSemanticTokensBuilder {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._tokens = [];
|
||||
}
|
||||
push(line, char, length, tokenType, tokenModifiers) {
|
||||
this._tokens.push({
|
||||
line,
|
||||
char,
|
||||
length,
|
||||
tokenType,
|
||||
tokenModifiers
|
||||
});
|
||||
}
|
||||
build() {
|
||||
this.applyTokens();
|
||||
return super.build();
|
||||
}
|
||||
buildEdits() {
|
||||
this.applyTokens();
|
||||
return super.buildEdits();
|
||||
}
|
||||
/**
|
||||
* Flushes the cached delta token values
|
||||
*/
|
||||
flush() {
|
||||
this.previousResult(this.id);
|
||||
}
|
||||
applyTokens() {
|
||||
for (const token of this._tokens.sort(this.compareTokens)) {
|
||||
super.push(token.line, token.char, token.length, token.tokenType, token.tokenModifiers);
|
||||
}
|
||||
this._tokens = [];
|
||||
}
|
||||
compareTokens(a, b) {
|
||||
// Branchless comparison for line and character
|
||||
return (a.line - b.line) || (a.char - b.char);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A basic super class for providing semantic token data.
|
||||
* Users of Langium should extend this class to create their own `SemanticTokenProvider`.
|
||||
*
|
||||
* The entry method for generating semantic tokens based on an `AstNode` is the `highlightElement` method.
|
||||
*/
|
||||
export class AbstractSemanticTokenProvider {
|
||||
constructor(services) {
|
||||
/**
|
||||
* Store a token builder for each open document.
|
||||
*/
|
||||
this.tokensBuilders = new Map();
|
||||
// Delete the token builder once the text document has been closed
|
||||
services.shared.workspace.TextDocuments.onDidClose(e => {
|
||||
this.tokensBuilders.delete(e.document.uri);
|
||||
});
|
||||
services.shared.lsp.LanguageServer.onInitialize(params => {
|
||||
this.initialize(params.capabilities.textDocument?.semanticTokens);
|
||||
});
|
||||
}
|
||||
initialize(clientCapabilities) {
|
||||
this.clientCapabilities = clientCapabilities;
|
||||
}
|
||||
get tokenTypes() {
|
||||
return AllSemanticTokenTypes;
|
||||
}
|
||||
get tokenModifiers() {
|
||||
return AllSemanticTokenModifiers;
|
||||
}
|
||||
get semanticTokensOptions() {
|
||||
return {
|
||||
legend: {
|
||||
tokenTypes: Object.keys(this.tokenTypes),
|
||||
tokenModifiers: Object.keys(this.tokenModifiers),
|
||||
},
|
||||
full: {
|
||||
// The semantic token delta support is disabled by default in Langium.
|
||||
// Since Langium recomputes the whole document on every change, we cannot provide a good delta.
|
||||
// Adopters can override this if they support it.
|
||||
delta: false
|
||||
},
|
||||
range: true,
|
||||
};
|
||||
}
|
||||
async semanticHighlight(document, _params, cancelToken = CancellationToken.None) {
|
||||
this.currentRange = undefined;
|
||||
this.currentDocument = document;
|
||||
this.currentTokensBuilder = this.getDocumentTokensBuilder(document);
|
||||
this.currentTokensBuilder.flush();
|
||||
await this.computeHighlighting(document, this.createAcceptor(), cancelToken);
|
||||
return this.currentTokensBuilder.build();
|
||||
}
|
||||
async semanticHighlightRange(document, params, cancelToken = CancellationToken.None) {
|
||||
this.currentRange = params.range;
|
||||
this.currentDocument = document;
|
||||
this.currentTokensBuilder = this.getDocumentTokensBuilder(document);
|
||||
this.currentTokensBuilder.flush();
|
||||
await this.computeHighlighting(document, this.createAcceptor(), cancelToken);
|
||||
return this.currentTokensBuilder.build();
|
||||
}
|
||||
async semanticHighlightDelta(document, params, cancelToken = CancellationToken.None) {
|
||||
this.currentRange = undefined;
|
||||
this.currentDocument = document;
|
||||
this.currentTokensBuilder = this.getDocumentTokensBuilder(document);
|
||||
this.currentTokensBuilder.previousResult(params.previousResultId);
|
||||
await this.computeHighlighting(document, this.createAcceptor(), cancelToken);
|
||||
return this.currentTokensBuilder.buildEdits();
|
||||
}
|
||||
createAcceptor() {
|
||||
const acceptor = options => {
|
||||
if ('line' in options) {
|
||||
this.highlightToken({
|
||||
range: {
|
||||
start: {
|
||||
line: options.line,
|
||||
character: options.char
|
||||
},
|
||||
end: {
|
||||
line: options.line,
|
||||
character: options.char + options.length
|
||||
}
|
||||
},
|
||||
type: options.type,
|
||||
modifier: options.modifier
|
||||
});
|
||||
}
|
||||
else if ('range' in options) {
|
||||
this.highlightToken(options);
|
||||
}
|
||||
else if ('keyword' in options) {
|
||||
this.highlightKeyword(options);
|
||||
}
|
||||
else if ('property' in options) {
|
||||
this.highlightProperty(options);
|
||||
}
|
||||
else {
|
||||
this.highlightNode({
|
||||
node: options.cst,
|
||||
type: options.type,
|
||||
modifier: options.modifier
|
||||
});
|
||||
}
|
||||
};
|
||||
return acceptor;
|
||||
}
|
||||
getDocumentTokensBuilder(document) {
|
||||
const existing = this.tokensBuilders.get(document.uri.toString());
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
const builder = new SemanticTokensBuilder();
|
||||
this.tokensBuilders.set(document.uri.toString(), builder);
|
||||
return builder;
|
||||
}
|
||||
async computeHighlighting(document, acceptor, cancelToken) {
|
||||
const root = document.parseResult.value;
|
||||
const treeIterator = streamAst(root, { range: this.currentRange }).iterator();
|
||||
let result;
|
||||
do {
|
||||
result = treeIterator.next();
|
||||
if (!result.done) {
|
||||
await interruptAndCheck(cancelToken);
|
||||
const node = result.value;
|
||||
if (this.highlightElement(node, acceptor) === 'prune') {
|
||||
treeIterator.prune();
|
||||
}
|
||||
}
|
||||
} while (!result.done);
|
||||
}
|
||||
highlightToken(options) {
|
||||
const { range, type } = options;
|
||||
let modifiers = options.modifier;
|
||||
if ((this.currentRange && !inRange(range, this.currentRange)) || !this.currentDocument || !this.currentTokensBuilder) {
|
||||
return;
|
||||
}
|
||||
const intType = this.tokenTypes[type];
|
||||
let totalModifier = 0;
|
||||
if (modifiers !== undefined) {
|
||||
if (typeof modifiers === 'string') {
|
||||
modifiers = [modifiers];
|
||||
}
|
||||
for (const modifier of modifiers) {
|
||||
const intModifier = this.tokenModifiers[modifier];
|
||||
totalModifier |= intModifier;
|
||||
}
|
||||
}
|
||||
const startLine = range.start.line;
|
||||
const endLine = range.end.line;
|
||||
if (startLine === endLine) {
|
||||
// Token only spans a single line
|
||||
const char = range.start.character;
|
||||
const length = range.end.character - char;
|
||||
this.currentTokensBuilder.push(startLine, char, length, intType, totalModifier);
|
||||
}
|
||||
else if (this.clientCapabilities?.multilineTokenSupport) {
|
||||
// Let token span multiple lines
|
||||
const startChar = range.start.character;
|
||||
const startOffset = this.currentDocument.textDocument.offsetAt(range.start);
|
||||
const endOffset = this.currentDocument.textDocument.offsetAt(range.end);
|
||||
this.currentTokensBuilder.push(startLine, startChar, endOffset - startOffset, intType, totalModifier);
|
||||
}
|
||||
else {
|
||||
// Token spans multiple lines, but the client doesn't support it
|
||||
// Split the range into multiple semantic tokens
|
||||
const firstLineStart = range.start;
|
||||
let nextLineOffset = this.currentDocument.textDocument.offsetAt({
|
||||
line: startLine + 1,
|
||||
character: 0
|
||||
});
|
||||
// Build first line
|
||||
this.currentTokensBuilder.push(firstLineStart.line, firstLineStart.character, nextLineOffset - firstLineStart.character - 1, intType, totalModifier);
|
||||
// Build all lines in between first and last
|
||||
for (let i = startLine + 1; i < endLine; i++) {
|
||||
const currentLineOffset = nextLineOffset;
|
||||
nextLineOffset = this.currentDocument.textDocument.offsetAt({
|
||||
line: i + 1,
|
||||
character: 0
|
||||
});
|
||||
this.currentTokensBuilder.push(i, 0, nextLineOffset - currentLineOffset - 1, intType, totalModifier);
|
||||
}
|
||||
// Build last line
|
||||
this.currentTokensBuilder.push(endLine, 0, range.end.character, intType, totalModifier);
|
||||
}
|
||||
}
|
||||
highlightProperty(options) {
|
||||
const nodes = [];
|
||||
if (typeof options.index === 'number') {
|
||||
const node = findNodeForProperty(options.node.$cstNode, options.property, options.index);
|
||||
if (node) {
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodes.push(...findNodesForProperty(options.node.$cstNode, options.property));
|
||||
}
|
||||
const { type, modifier } = options;
|
||||
for (const node of nodes) {
|
||||
this.highlightNode({
|
||||
node,
|
||||
type,
|
||||
modifier
|
||||
});
|
||||
}
|
||||
}
|
||||
highlightKeyword(options) {
|
||||
const { node, keyword, type, index, modifier } = options;
|
||||
const nodes = [];
|
||||
if (typeof index === 'number') {
|
||||
const keywordNode = findNodeForKeyword(node.$cstNode, keyword, index);
|
||||
if (keywordNode) {
|
||||
nodes.push(keywordNode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodes.push(...findNodesForKeyword(node.$cstNode, keyword));
|
||||
}
|
||||
for (const keywordNode of nodes) {
|
||||
this.highlightNode({
|
||||
node: keywordNode,
|
||||
type,
|
||||
modifier
|
||||
});
|
||||
}
|
||||
}
|
||||
highlightNode(options) {
|
||||
const { node, type, modifier } = options;
|
||||
const range = node.range;
|
||||
this.highlightToken({
|
||||
range,
|
||||
type,
|
||||
modifier
|
||||
});
|
||||
}
|
||||
}
|
||||
export var SemanticTokensDecoder;
|
||||
(function (SemanticTokensDecoder) {
|
||||
function decode(tokens, tokenTypes, document) {
|
||||
const typeMap = new Map();
|
||||
Object.entries(tokenTypes).forEach(([type, index]) => typeMap.set(index, type));
|
||||
let line = 0;
|
||||
let character = 0;
|
||||
return sliceIntoChunks(tokens.data, 5).map(t => {
|
||||
line += t[0];
|
||||
if (t[0] !== 0) {
|
||||
character = 0;
|
||||
}
|
||||
character += t[1];
|
||||
const length = t[2];
|
||||
const offset = document.textDocument.offsetAt({ line, character });
|
||||
return {
|
||||
offset,
|
||||
tokenType: typeMap.get(t[3]),
|
||||
tokenModifiers: t[4],
|
||||
text: document.textDocument.getText({ start: { line, character }, end: { line, character: character + length } })
|
||||
};
|
||||
});
|
||||
}
|
||||
SemanticTokensDecoder.decode = decode;
|
||||
function sliceIntoChunks(arr, chunkSize) {
|
||||
const res = [];
|
||||
for (let i = 0; i < arr.length; i += chunkSize) {
|
||||
const chunk = arr.slice(i, i + chunkSize);
|
||||
res.push(chunk);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
})(SemanticTokensDecoder || (SemanticTokensDecoder = {}));
|
||||
//# sourceMappingURL=semantic-token-provider.js.map
|
||||
78
frontend/node_modules/langium/lib/lsp/type-hierarchy-provider.js
generated
vendored
Normal file
78
frontend/node_modules/langium/lib/lsp/type-hierarchy-provider.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/******************************************************************************
|
||||
* Copyright 2023 TypeFox GmbH
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License, which is available in the project root.
|
||||
******************************************************************************/
|
||||
import { SymbolKind } from 'vscode-languageserver';
|
||||
import { findDeclarationNodeAtOffset } from '../utils/cst-utils.js';
|
||||
import { URI } from '../utils/uri-utils.js';
|
||||
export class AbstractTypeHierarchyProvider {
|
||||
constructor(services) {
|
||||
this.grammarConfig = services.parser.GrammarConfig;
|
||||
this.nameProvider = services.references.NameProvider;
|
||||
this.documents = services.shared.workspace.LangiumDocuments;
|
||||
this.references = services.references.References;
|
||||
}
|
||||
prepareTypeHierarchy(document, params, _cancelToken) {
|
||||
const rootNode = document.parseResult.value;
|
||||
const targetNode = findDeclarationNodeAtOffset(rootNode.$cstNode, document.textDocument.offsetAt(params.position), this.grammarConfig.nameRegexp);
|
||||
if (!targetNode) {
|
||||
return undefined;
|
||||
}
|
||||
const declarationNodes = this.references.findDeclarationNodes(targetNode);
|
||||
const items = [];
|
||||
for (const declarationNode of declarationNodes) {
|
||||
items.push(...(this.getTypeHierarchyItems(declarationNode.astNode, document) ?? []));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
getTypeHierarchyItems(targetNode, document) {
|
||||
const nameNode = this.nameProvider.getNameNode(targetNode);
|
||||
const name = this.nameProvider.getName(targetNode);
|
||||
if (!nameNode || !targetNode.$cstNode || name === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return [
|
||||
{
|
||||
kind: SymbolKind.Class,
|
||||
name,
|
||||
range: targetNode.$cstNode.range,
|
||||
selectionRange: nameNode.range,
|
||||
uri: document.uri.toString(),
|
||||
...this.getTypeHierarchyItem(targetNode),
|
||||
},
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Override this method to change default properties of the type hierarchy item or add additional ones like `tags`
|
||||
* or `details`.
|
||||
*
|
||||
* @example
|
||||
* // Change the node kind to SymbolKind.Interface
|
||||
* return { kind: SymbolKind.Interface }
|
||||
*
|
||||
* @see NodeKindProvider
|
||||
*/
|
||||
getTypeHierarchyItem(_targetNode) {
|
||||
return undefined;
|
||||
}
|
||||
async supertypes(params, _cancelToken) {
|
||||
const document = await this.documents.getOrCreateDocument(URI.parse(params.item.uri));
|
||||
const rootNode = document.parseResult.value;
|
||||
const targetNode = findDeclarationNodeAtOffset(rootNode.$cstNode, document.textDocument.offsetAt(params.item.range.start), this.grammarConfig.nameRegexp);
|
||||
if (!targetNode) {
|
||||
return undefined;
|
||||
}
|
||||
return this.getSupertypes(targetNode.astNode);
|
||||
}
|
||||
async subtypes(params, _cancelToken) {
|
||||
const document = await this.documents.getOrCreateDocument(URI.parse(params.item.uri));
|
||||
const rootNode = document.parseResult.value;
|
||||
const targetNode = findDeclarationNodeAtOffset(rootNode.$cstNode, document.textDocument.offsetAt(params.item.range.start), this.grammarConfig.nameRegexp);
|
||||
if (!targetNode) {
|
||||
return undefined;
|
||||
}
|
||||
return this.getSubtypes(targetNode.astNode);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=type-hierarchy-provider.js.map
|
||||
1
frontend/node_modules/langium/lib/lsp/workspace-symbol-provider.js.map
generated
vendored
Normal file
1
frontend/node_modules/langium/lib/lsp/workspace-symbol-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"workspace-symbol-provider.js","sourceRoot":"","sources":["../../src/lsp/workspace-symbol-provider.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAShF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA8B9D,MAAM,OAAO,8BAA8B;IAMvC,YAAY,QAA+B;QACvC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAA6B,EAAE,WAAW,GAAG,iBAAiB,CAAC,IAAI;QAChF,MAAM,gBAAgB,GAAsB,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACzC,KAAK,MAAM,WAAW,IAAI,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;YACxD,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;YACrC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnD,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;gBACpD,IAAI,MAAM,EAAE,CAAC;oBACT,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAClC,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAES,kBAAkB,CAAC,cAAkC;QAC3D,MAAM,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC;QAC/C,IAAI,WAAW,EAAE,CAAC;YACd,OAAO;gBACH,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,cAAc,CAAC;gBACzD,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,QAAQ,EAAE;oBACN,KAAK,EAAE,WAAW,CAAC,KAAK;oBACxB,GAAG,EAAE,cAAc,CAAC,WAAW,CAAC,QAAQ,EAAE;iBAC7C;aACJ,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;CACJ"}
|
||||
Reference in New Issue
Block a user