1 | import {isTopLevelDeclaration} from "../parser/tokenizer";
|
2 | import {TokenType as tt} from "../parser/tokenizer/types";
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export const EMPTY_DECLARATION_INFO = {
|
11 | typeDeclarations: new Set(),
|
12 | valueDeclarations: new Set(),
|
13 | };
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export default function getDeclarationInfo(tokens) {
|
27 | const typeDeclarations = new Set();
|
28 | const valueDeclarations = new Set();
|
29 | for (let i = 0; i < tokens.tokens.length; i++) {
|
30 | const token = tokens.tokens[i];
|
31 | if (token.type === tt.name && isTopLevelDeclaration(token)) {
|
32 | if (token.isType) {
|
33 | typeDeclarations.add(tokens.identifierNameForToken(token));
|
34 | } else {
|
35 | valueDeclarations.add(tokens.identifierNameForToken(token));
|
36 | }
|
37 | }
|
38 | }
|
39 | return {typeDeclarations, valueDeclarations};
|
40 | }
|