MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / blockToken

Function blockToken

src/resolution/ambient-modules.ts:129–168  ·  view source on GitHub ↗
(kind: Kind, text: string, depth: number)

Source from the content-addressed store, hash-verified

127 };
128
129 const blockToken = (kind: Kind, text: string, depth: number): void => {
130 if (exportState === 5) {
131 if (kind === Kind.Punct && text === '}' && depth === 1) {
132 closeClause();
133 exportState = 0;
134 } else if (kind === Kind.Word) {
135 clause.push(text);
136 }
137 return;
138 }
139 if (depth !== 1) return;
140 switch (exportState) {
141 case 0:
142 if (kind === Kind.Word && text === 'export') exportState = 1;
143 return;
144 case 1:
145 if (kind === Kind.Word && text === 'default') exportState = 2;
146 else if (kind === Kind.Punct && text === '=') exportState = 4;
147 else if (kind === Kind.Punct && text === '{') exportState = 5;
148 else exportState = 0;
149 return;
150 case 2:
151 if (kind === Kind.Word && DEFAULT_DECLARATION_WORDS.has(text)) exportState = 3;
152 else {
153 if (kind === Kind.Word) open!.defaultName ??= text;
154 exportState = 0;
155 }
156 return;
157 case 3:
158 // `export default abstract class X`, `export default async function X`, `function* X`.
159 if ((kind === Kind.Word && DEFAULT_DECLARATION_WORDS.has(text)) || (kind === Kind.Punct && text === '*')) return;
160 if (kind === Kind.Word) open!.defaultName ??= text;
161 exportState = 0;
162 return;
163 case 4:
164 if (kind === Kind.Word) open!.defaultName ??= text;
165 exportState = 0;
166 return;
167 }
168 };
169
170 const token = (kind: Kind, text: string, line: number, column: number, depth: number): void => {
171 if (importTokens) {

Callers 1

tokenFunction · 0.85

Calls 3

closeClauseFunction · 0.85
pushMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected