Skip to content

Commit 316e0c3

Browse files
authored
Update guides for scope computation changes (#281)
1 parent 7819ea5 commit 316e0c3

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

hugo/content/docs/learn/workflow/resolve_cross_references.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ The _index manager_ is keeping in mind the global symbols of your language. It c
135135

136136
```ts
137137
export interface ScopeComputation {
138-
computeExports(document: LangiumDocument, cancelToken?: CancellationToken): Promise<AstNodeDescription[]>;
139-
computeLocalScopes(document: LangiumDocument, cancelToken?: CancellationToken): Promise<PrecomputedScopes>;
138+
collectExportedSymbols(document: LangiumDocument, cancelToken?: CancellationToken): Promise<AstNodeDescription[]>;
139+
collectLocalSymbols(document: LangiumDocument, cancelToken?: CancellationToken): Promise<LocalSymbols>;
140140
}
141141
```
142142

hugo/content/docs/recipes/scoping/file-based.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ npm run langium:generate
5858

5959
## Step 2: Exporting persons to the global scope
6060

61-
The index manager shall get all persons that are marked with the export keyword. In Langium this is done by overriding the `ScopeComputation.getExports(…)` function. Here is the implementation:
61+
The index manager shall get all persons that are marked with the export keyword. In Langium this is done by overriding the `ScopeComputation.collectExportedSymbols(…)` function. Here is the implementation:
6262

6363
```typescript
6464
export class HelloWorldScopeComputation extends DefaultScopeComputation {
65-
override async computeExports(document: LangiumDocument<AstNode>): Promise<AstNodeDescription[]> {
65+
override async collectExportedSymbols(document: LangiumDocument<AstNode>): Promise<AstNodeDescription[]> {
6666
const model = document.parseResult.value as Model;
6767
return model.persons
6868
.filter(p => p.published)
@@ -217,7 +217,7 @@ import { HelloWorldAstType, Model, Person } from "./generated/ast.js";
217217
import { dirname, join } from "node:path";
218218

219219
export class HelloWorldScopeComputation extends DefaultScopeComputation {
220-
override async computeExports(document: LangiumDocument<AstNode>): Promise<AstNodeDescription[]> {
220+
override async collectExportedSymbols(document: LangiumDocument<AstNode>): Promise<AstNodeDescription[]> {
221221
const model = document.parseResult.value as Model;
222222
return model.persons
223223
.filter(p => p.published)

hugo/content/docs/recipes/scoping/qualified-name.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const CppModule: Module<CppServices, PartialLangiumServices & CppAddedSer
4949
}
5050
```
5151

52-
Next, we can start implementing our custom scoping by overriding the `computeExports` function. This function is particularly important, as it allows us to change export nodes of our model using qualified names: We'll also want to annotate this function with `override`, since there's already a default definition provided.
52+
Next, we can start implementing our custom scoping by overriding the `collectExportedSymbols` function. This function is particularly important, as it allows us to change export nodes of our model using qualified names: We'll also want to annotate this function with `override`, since there's already a default definition provided.
5353

5454
```ts
5555
export class CppScopeComputation extends DefaultScopeComputation {
@@ -59,7 +59,7 @@ export class CppScopeComputation extends DefaultScopeComputation {
5959
/**
6060
* Export all functions using their fully qualified name
6161
*/
62-
override async computeExports(document: LangiumDocument): Promise<AstNodeDescription[]> {
62+
override async collectExportedSymbols(document: LangiumDocument): Promise<AstNodeDescription[]> {
6363
const exportedDescriptions: AstNodeDescription[] = [];
6464
for (const childNode of streamAllContents(document.parseResult.value)) {
6565
if (isFunctionDeclaration(childNode)) {
@@ -108,7 +108,7 @@ export class CppScopeComputation extends DefaultScopeComputation {
108108

109109
// Emitting previous implementation for brevity
110110

111-
override async computeLocalScopes(document: LangiumDocument): Promise<PrecomputedScopes> {
111+
override async collectLocalSymbols(document: LangiumDocument): Promise<LocalSymbols> {
112112
const model = document.parseResult.value as CppProgram;
113113
// This map stores a list of descriptions for each node in our document
114114
const scopes = new MultiMap<AstNode, AstNodeDescription>();
@@ -166,7 +166,7 @@ export class CppScopeComputation extends DefaultScopeComputation {
166166
/**
167167
* Export all functions using their fully qualified name
168168
*/
169-
override async computeExports(document: LangiumDocument): Promise<AstNodeDescription[]> {
169+
override async collectExportedSymbols(document: LangiumDocument): Promise<AstNodeDescription[]> {
170170
const exportedDescriptions: AstNodeDescription[] = [];
171171
for (const childNode of streamAllContents(document.parseResult.value)) {
172172
if (isFunctionDeclaration(childNode)) {
@@ -179,7 +179,7 @@ export class CppScopeComputation extends DefaultScopeComputation {
179179
return exportedDescriptions;
180180
}
181181

182-
override async computeLocalScopes(document: LangiumDocument): Promise<PrecomputedScopes> {
182+
override async collectLocalSymbols(document: LangiumDocument): Promise<LocalSymbols> {
183183
const model = document.parseResult.value as CppProgram;
184184
// This multi-map stores a list of descriptions for each node in our document
185185
const scopes = new MultiMap<AstNode, AstNodeDescription>();

0 commit comments

Comments
 (0)