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

Method openElement

src/resolution/jsx-code.ts:207–234  ·  view source on GitHub ↗

Open the element whose `<` is at `lt`. False when it cannot be one.

(lt: number)

Source from the content-addressed store, hash-verified

205
206 /** Open the element whose `<` is at `lt`. False when it cannot be one. */
207 private openElement(lt: number): boolean {
208 const src = this.src;
209 if (src.charCodeAt(lt + 1) === 62) {
210 this.stack.push({ mode: 'children', braces: 0, name: '' });
211 this.i = lt + 2;
212 return true;
213 }
214 let k = nameEnd(src, lt + 1);
215 const name = src.slice(lt + 1, k);
216 // `<Entry extends BaseEntity>(…) =>`: a generic arrow function's type parameters.
217 const next = skipSpace(src, k);
218 if (next > k && src.startsWith('extends', next) && isSpace(src.charCodeAt(next + 7))) return false;
219 if (src.charCodeAt(k) === 60) {
220 // `<Select<Option> …>`: the element's type arguments.
221 let depth = 0;
222 const limit = Math.min(this.n, k + 1000);
223 for (; k < limit; k++) {
224 const c = src.charCodeAt(k);
225 if (c === 60) depth++;
226 else if (c === 62 && --depth === 0) break;
227 }
228 if (depth !== 0) return false;
229 k++;
230 }
231 this.stack.push({ mode: 'tag', braces: 0, name });
232 this.i = k;
233 return true;
234 }
235
236 /** Close the innermost element. Closing an element opened among code ends an expression. */
237 private closeElement(): void {

Callers 3

codeMethod · 0.95
tagMethod · 0.95
childrenMethod · 0.95

Calls 4

nameEndFunction · 0.85
pushMethod · 0.80
skipSpaceFunction · 0.70
isSpaceFunction · 0.70

Tested by

no test coverage detected