Skip to content

Commit 2c8ac74

Browse files
Rename variable extraction routine
1 parent e0c31d1 commit 2c8ac74

5 files changed

Lines changed: 19 additions & 15 deletions

File tree

libs/parsing/syntax-tree/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export * from './lib/populate-index';
4444
export * from './lib/populate-scope';
4545
export * from './lib/populate-scope-detail';
4646
export * from './lib/populate-scope-detail-and-reset-token-cache';
47-
export * from './lib/populators/get-unique-variables';
4847
export * from './lib/populators/populate-global';
4948
export * from './lib/populators/populate-global.interface';
5049
export * from './lib/populators/populate-local.interface';
50+
export * from './lib/populators/populate-variables';
5151
export * from './lib/post-process-problems';
5252
export * from './lib/post-processor.interface';
5353
export * from './lib/recursion-and-callbacks/tree-callback-handler.class';

libs/parsing/syntax-tree/src/lib/build-syntax-tree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
import { DEFAULT_PARSED, IParsed } from './parsed.interface';
2525
import { PopulateIndex } from './populate-index';
2626
import { PopulateScope } from './populate-scope';
27-
import { GetUniqueVariables } from './populators/get-unique-variables';
27+
import { PopulateVariables } from './populators/populate-variables';
2828
import { IDL_SYNTAX_TREE_POST_PROCESSOR } from './post-processor.interface';
2929
import { DEFAULT_CURRENT } from './recursion-and-callbacks/tree-recurser.interface';
3030
import { SyntaxProblemWithTranslation } from './syntax-problem-with';
@@ -335,7 +335,7 @@ export function PopulateLocal(parsed: IParsed) {
335335
// inside of "populate-global.ts" or you can search for the name of the
336336
// function "GetUniqueVariables("
337337
case TOKEN_NAMES.MAIN_LEVEL:
338-
local.main = GetUniqueVariables(
338+
local.main = PopulateVariables(
339339
branch as IBranch<MainLevelToken>,
340340
parsed,
341341
parsed.compile.main

libs/parsing/syntax-tree/src/lib/populators/populate-global.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ import { GenerateRoutineMetadataFast } from '../docs/generate-routine-metadata-f
2929
import { IParsed } from '../parsed.interface';
3030
import { FindStructureDefs } from './find-structure-defs';
3131
import { GetCompileOpts } from './get-compile-opts';
32-
import { GetUniqueVariables } from './get-unique-variables';
3332
import { MAIN_LEVEL_NAME } from './populate-global.interface';
3433
import { LOCAL_TOKEN_LOOKUP } from './populate-local.interface';
3534
import { PopulateLocalForMain } from './populate-local-for-main';
35+
import { PopulateVariables } from './populate-variables';
3636

3737
/**
3838
* Populates a lookup with quick information for where things are defined
@@ -137,7 +137,7 @@ export function PopulateGlobalLocalCompileOpts(
137137
global.push(add);
138138
parsed.compile.func[name] = full ? GetCompileOpts(branch) : [];
139139
parsed.local.func[name] = full
140-
? GetUniqueVariables(
140+
? PopulateVariables(
141141
branch as IBranch<RoutineFunctionToken>,
142142
parsed,
143143
parsed.compile.func[name],
@@ -187,7 +187,7 @@ export function PopulateGlobalLocalCompileOpts(
187187

188188
parsed.compile.func[name] = full ? GetCompileOpts(branch) : [];
189189
parsed.local.func[name] = full
190-
? GetUniqueVariables(
190+
? PopulateVariables(
191191
branch as IBranch<RoutineFunctionToken>,
192192
parsed,
193193
parsed.compile.func[name],
@@ -276,7 +276,7 @@ export function PopulateGlobalLocalCompileOpts(
276276
global.push(add);
277277
parsed.compile.pro[name] = full ? GetCompileOpts(branch) : [];
278278
parsed.local.pro[name] = full
279-
? GetUniqueVariables(
279+
? PopulateVariables(
280280
branch as IBranch<RoutineProcedureToken>,
281281
parsed,
282282
parsed.compile.pro[name],
@@ -303,7 +303,7 @@ export function PopulateGlobalLocalCompileOpts(
303303
global.push(add);
304304
parsed.compile.pro[name] = full ? GetCompileOpts(branch) : [];
305305
parsed.local.pro[name] = full
306-
? GetUniqueVariables(
306+
? PopulateVariables(
307307
branch as IBranch<RoutineProcedureToken>,
308308
parsed,
309309
parsed.compile.pro[name],

libs/parsing/syntax-tree/src/lib/populators/populate-local-for-main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MainLevelToken, TOKEN_NAMES } from '@idl/tokenizer';
22

33
import { IBranch } from '../branches.interface';
44
import { IParsed } from '../parsed.interface';
5-
import { GetUniqueVariables } from './get-unique-variables';
5+
import { PopulateVariables } from './populate-variables';
66

77
/**
88
* Populates a lookup with quick information for where local things are defined
@@ -25,7 +25,7 @@ export function PopulateLocalForMain(parsed: IParsed) {
2525
// inside of "populate-global.ts" or you can search for the name of the
2626
// function "GetUniqueVariables("
2727
case TOKEN_NAMES.MAIN_LEVEL:
28-
local.main = GetUniqueVariables(
28+
local.main = PopulateVariables(
2929
branch as IBranch<MainLevelToken>,
3030
parsed,
3131
parsed.compile.main

libs/parsing/syntax-tree/src/lib/populators/get-unique-variables.ts renamed to libs/parsing/syntax-tree/src/lib/populators/populate-variables.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { ReplaceFunctionsAsVariables } from './replace-functions-as-variables';
3636
* idl2 or strictarr, then we check and see if there are functions that should
3737
* really be represented as variables.
3838
*/
39-
export function GetUniqueVariables(
39+
export function PopulateVariables(
4040
branch: IBranch<
4141
RoutineProcedureToken | RoutineFunctionToken | MainLevelToken
4242
>,
@@ -106,6 +106,7 @@ export function GetUniqueVariables(
106106
meta: {
107107
display: variable.match[0],
108108
isDefined: true,
109+
canReset: false,
109110
usage: [], // dont init, populated below
110111
docs: kw.docs,
111112
source: GLOBAL_TOKEN_SOURCE_LOOKUP.USER,
@@ -137,6 +138,7 @@ export function GetUniqueVariables(
137138
meta: {
138139
display: origName,
139140
isDefined: true,
141+
canReset: false,
140142
usage: [args[i].pos], // dont init, populated below
141143
docs: name in gArgs ? gArgs[name].docs : '',
142144
source: GLOBAL_TOKEN_SOURCE_LOOKUP.USER,
@@ -195,17 +197,19 @@ export function GetUniqueVariables(
195197
vars[i].token.scope[1] === TOKEN_NAMES.ROUTINE_NAME ||
196198
vars[i].token.scope[1] === TOKEN_NAMES.ROUTINE_METHOD_NAME;
197199

200+
/** Check if the variable is defined */
201+
const isDefined =
202+
(inDef && name !== 'self') || parent === TOKEN_NAMES.CONTROL_COMMON;
203+
198204
// define what we add, do this so it is strictly typed
199205
const add: ILocalIndexedToken<LocalVariableToken> = {
200206
type: LOCAL_TOKEN_LOOKUP.VARIABLE,
201207
name: name,
202208
pos: vars[i].token.pos,
203209
meta: {
204210
display: origName,
205-
isDefined:
206-
(inDef && name !== 'self') || parent === TOKEN_NAMES.CONTROL_COMMON
207-
? true
208-
: false,
211+
isDefined: isDefined ? true : false,
212+
canReset: isDefined ? false : true,
209213
usage: [vars[i].token.pos],
210214
docs: docs,
211215
source: GLOBAL_TOKEN_SOURCE_LOOKUP.USER,

0 commit comments

Comments
 (0)