完成世界书、骰子、apiconfig页面处理

This commit is contained in:
2026-04-30 01:35:10 +08:00
parent a3e3711b2b
commit ba9b925c32
4602 changed files with 785225 additions and 23 deletions

View File

@@ -0,0 +1,12 @@
/******************************************************************************
* 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 * from './linker.js';
export * from './name-provider.js';
export * from './references.js';
export * from './scope.js';
export * from './scope-computation.js';
export * from './scope-provider.js';
//# sourceMappingURL=index.d.ts.map

12
frontend/node_modules/langium/lib/references/index.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/******************************************************************************
* 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 * from './linker.js';
export * from './name-provider.js';
export * from './references.js';
export * from './scope.js';
export * from './scope-computation.js';
export * from './scope-provider.js';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1,21 @@
/******************************************************************************
* 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 { findNodeForProperty } from '../utils/grammar-utils.js';
export function isNamed(node) {
return typeof node.name === 'string';
}
export class DefaultNameProvider {
getName(node) {
if (isNamed(node)) {
return node.name;
}
return undefined;
}
getNameNode(node) {
return findNodeForProperty(node.$cstNode, 'name');
}
}
//# sourceMappingURL=name-provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"scope-computation.js","sourceRoot":"","sources":["../../src/references/scope-computation.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAIhF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA2C9D;;;;;;;;;;;GAW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BAAmB,CAAC,QAAyB,EAAE,WAAW,GAAG,iBAAiB,CAAC,IAAI;QACrF,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC;QAC5C,MAAM,OAAO,GAAG,IAAI,QAAQ,EAA+B,CAAC;QAC5D,wFAAwF;QACxF,KAAK,MAAM,IAAI,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7C,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,cAAc,CAAC,IAAa,EAAE,QAAyB,EAAE,OAA8C;QAC7G,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,SAAS,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;YACtF,CAAC;QACL,CAAC;IACL,CAAC;CAEJ"}

View File

@@ -0,0 +1,64 @@
/******************************************************************************
* Copyright 2021-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 { MultiMapScope, StreamScope } from './scope.js';
import { getDocument } from '../utils/ast-utils.js';
import { stream } from '../utils/stream.js';
import { WorkspaceCache } from '../utils/caching.js';
export class DefaultScopeProvider {
constructor(services) {
this.reflection = services.shared.AstReflection;
this.nameProvider = services.references.NameProvider;
this.descriptions = services.workspace.AstNodeDescriptionProvider;
this.indexManager = services.shared.workspace.IndexManager;
this.globalScopeCache = new WorkspaceCache(services.shared);
}
getScope(context) {
const scopes = [];
const referenceType = this.reflection.getReferenceType(context);
const localSymbols = getDocument(context.container).localSymbols;
if (localSymbols) {
let currentNode = context.container;
do {
if (localSymbols.has(currentNode)) {
scopes.push(localSymbols.getStream(currentNode).filter(desc => this.reflection.isSubtype(desc.type, referenceType)));
}
currentNode = currentNode.$container;
} while (currentNode);
}
let result = this.getGlobalScope(referenceType, context);
for (let i = scopes.length - 1; i >= 0; i--) {
result = this.createScope(scopes[i], result);
}
return result;
}
/**
* Create a scope for the given collection of AST node descriptions.
*/
createScope(elements, outerScope, options) {
return new StreamScope(stream(elements), outerScope, options);
}
/**
* Create a scope for the given collection of AST nodes, which need to be transformed into respective
* descriptions first. This is done using the `NameProvider` and `AstNodeDescriptionProvider` services.
*/
createScopeForNodes(elements, outerScope, options) {
const s = stream(elements).map(e => {
const name = this.nameProvider.getName(e);
if (name) {
return this.descriptions.createDescription(e, name);
}
return undefined;
}).nonNullable();
return new StreamScope(s, outerScope, options);
}
/**
* Create a global scope filtered for the given reference type.
*/
getGlobalScope(referenceType, _context) {
return this.globalScopeCache.get(referenceType, () => new MultiMapScope(this.indexManager.allElements(referenceType)));
}
}
//# sourceMappingURL=scope-provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/references/scope.ts"],"names":[],"mappings":"AAAA;;;;gFAIgF;AAEhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,KAAK;IAElB;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAAC;IAEzD;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,kBAAkB,CAAC,CA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AAkB,CAAC;IAWrD,cAAc,IAAI,MAAM,CAAC,kBAAkB,CAAC;CAQ/C;AAED,qBAAa,aAAc,YAAW,KAAK;IACvC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxD,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;gBAEvB,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,YAAY;IAa9F,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAYxD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,kBAAkB,CAAC;IAUrD,cAAc,IAAI,MAAM,CAAC,kBAAkB,CAAC;CAQ/C;AAED,eAAO,MAAM,WAAW,EAAE,KAUzB,CAAC"}

150
frontend/node_modules/langium/lib/references/scope.js generated vendored Normal file
View File

@@ -0,0 +1,150 @@
/******************************************************************************
* 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 { MultiMap } from '../utils/collections.js';
import { EMPTY_STREAM, stream } from '../utils/stream.js';
/**
* The default scope implementation is based on a `Stream`. It has an optional _outer scope_ describing
* the next level of elements, which are queried when a target element is not found in the stream provided
* to this scope.
*/
export class StreamScope {
constructor(elements, outerScope, options) {
this.elements = elements;
this.outerScope = outerScope;
this.caseInsensitive = options?.caseInsensitive ?? false;
this.concatOuterScope = options?.concatOuterScope ?? true;
}
getAllElements() {
if (this.outerScope) {
return this.elements.concat(this.outerScope.getAllElements());
}
else {
return this.elements;
}
}
getElement(name) {
const lowerCaseName = this.caseInsensitive ? name.toLowerCase() : name;
const local = this.caseInsensitive
? this.elements.find(e => e.name.toLowerCase() === lowerCaseName)
: this.elements.find(e => e.name === name);
if (local) {
return local;
}
if (this.outerScope) {
return this.outerScope.getElement(name);
}
return undefined;
}
getElements(name) {
const lowerCaseName = this.caseInsensitive ? name.toLowerCase() : name;
const local = this.caseInsensitive
? this.elements.filter(e => e.name.toLowerCase() === lowerCaseName)
: this.elements.filter(e => e.name === name);
if ((this.concatOuterScope || local.isEmpty()) && this.outerScope) {
return local.concat(this.outerScope.getElements(name));
}
else {
return local;
}
}
}
export class MapScope {
constructor(elements, outerScope, options) {
this.elements = new Map();
this.caseInsensitive = options?.caseInsensitive ?? false;
this.concatOuterScope = options?.concatOuterScope ?? true;
for (const element of elements) {
const name = this.caseInsensitive
? element.name.toLowerCase()
: element.name;
this.elements.set(name, element);
}
this.outerScope = outerScope;
}
getElement(name) {
const localName = this.caseInsensitive ? name.toLowerCase() : name;
const local = this.elements.get(localName);
if (local) {
return local;
}
if (this.outerScope) {
return this.outerScope.getElement(name);
}
return undefined;
}
getElements(name) {
const localName = this.caseInsensitive ? name.toLowerCase() : name;
const local = this.elements.get(localName);
const arr = local ? [local] : [];
if ((this.concatOuterScope || arr.length > 0) && this.outerScope) {
return stream(arr).concat(this.outerScope.getElements(name));
}
else {
return stream(arr);
}
}
getAllElements() {
let elementStream = stream(this.elements.values());
if (this.outerScope) {
elementStream = elementStream.concat(this.outerScope.getAllElements());
}
return elementStream;
}
}
export class MultiMapScope {
constructor(elements, outerScope, options) {
this.elements = new MultiMap();
this.caseInsensitive = options?.caseInsensitive ?? false;
this.concatOuterScope = options?.concatOuterScope ?? true;
for (const element of elements) {
const name = this.caseInsensitive
? element.name.toLowerCase()
: element.name;
this.elements.add(name, element);
}
this.outerScope = outerScope;
}
getElement(name) {
const localName = this.caseInsensitive ? name.toLowerCase() : name;
const local = this.elements.get(localName)[0];
if (local) {
return local;
}
if (this.outerScope) {
return this.outerScope.getElement(name);
}
return undefined;
}
getElements(name) {
const localName = this.caseInsensitive ? name.toLowerCase() : name;
const local = this.elements.get(localName);
if ((this.concatOuterScope || local.length === 0) && this.outerScope) {
return stream(local).concat(this.outerScope.getElements(name));
}
else {
return stream(local);
}
}
getAllElements() {
let elementStream = stream(this.elements.values());
if (this.outerScope) {
elementStream = elementStream.concat(this.outerScope.getAllElements());
}
return elementStream;
}
}
export const EMPTY_SCOPE = {
getElement() {
return undefined;
},
getElements() {
return EMPTY_STREAM;
},
getAllElements() {
return EMPTY_STREAM;
}
};
//# sourceMappingURL=scope.js.map