@@ -9,13 +9,9 @@ import { LCEClassDeclaration } from "../../core/concepts/class-declaration.conce
99import { LCEVariableDeclaration } from "../../core/concepts/variable-declaration.concept" ;
1010import { LCEFunctionDeclaration } from "../../core/concepts/function-declaration.concept" ;
1111import { VariableDeclarationProcessor } from "../../core/processors/variable-declaration.processor" ;
12+ import { ReactContextKeys } from "../context.keys" ;
1213
1314export class JSXDependencyContextProcessor extends Processor {
14- /**
15- * represents a list of JSX tags that is used in some environment, e.g. inside the code of a function
16- */
17- public static readonly JSX_DEPENDENCY_CONTEXT = "jsx-dependency-context" ;
18-
1915 public static readonly JSX_DEPENDENCY_METADATA : "jsx-dependencies" ;
2016
2117 public executionCondition : ExecutionCondition = new ExecutionCondition (
@@ -34,13 +30,11 @@ export class JSXDependencyContextProcessor extends Processor {
3430 ) ;
3531
3632 public override preChildrenProcessing ( processingContext : ProcessingContext ) {
37- processingContext . localContexts . currentContexts . set ( JSXDependencyContextProcessor . JSX_DEPENDENCY_CONTEXT , new Array < LCEJSXDependency > ( ) ) ;
33+ processingContext . localContexts . currentContexts . set ( ReactContextKeys . JSX_DEPENDENCIES , new Array < LCEJSXDependency > ( ) ) ;
3834 }
3935
4036 public override postChildrenProcessing ( { localContexts, metadataAssignments } : ProcessingContext ) : ConceptMap {
41- const jsxContext : LCEJSXDependency [ ] = (
42- localContexts . getNextContext ( JSXDependencyContextProcessor . JSX_DEPENDENCY_CONTEXT ) as [ LCEJSXDependency [ ] , number ]
43- ) [ 0 ] ;
37+ const jsxContext : LCEJSXDependency [ ] = ( localContexts . getNextContext ( ReactContextKeys . JSX_DEPENDENCIES ) as [ LCEJSXDependency [ ] , number ] ) [ 0 ] ;
4438
4539 const aggregatedDependencies = new Map < string , LCEJSXDependency > ( ) ;
4640 for ( const dep of jsxContext ) {
@@ -72,23 +66,23 @@ export class JSXDependencyProcessor extends Processor {
7266 let name = "" ;
7367
7468 // try to determine name of the tag, abort processing, if not possible
75- if ( node . name . type === AST_NODE_TYPES . JSXIdentifier ) {
69+ if ( node . name . type === AST_NODE_TYPES . JSXIdentifier ) {
7670 name = node . name . name ;
7771 } else if ( node . name . type === AST_NODE_TYPES . JSXMemberExpression ) {
7872 let depth = 0 ;
7973 name = node . name . property . name ;
8074 let currentExpression = node . name . object ;
81- while ( currentExpression . type === AST_NODE_TYPES . JSXMemberExpression ) {
82- if ( depth > 20 ) {
83- console . log ( "ERROR: Could not resolve JSX member expression:" )
75+ while ( currentExpression . type === AST_NODE_TYPES . JSXMemberExpression ) {
76+ if ( depth > 20 ) {
77+ console . log ( "ERROR: Could not resolve JSX member expression:" ) ;
8478 console . log ( name ) ;
8579 return new Map ( ) ;
8680 }
8781 name = currentExpression . property . name + "." + name ;
8882 currentExpression = currentExpression . object ;
8983 depth ++ ;
9084 }
91- if ( currentExpression . type === AST_NODE_TYPES . JSXIdentifier ) {
85+ if ( currentExpression . type === AST_NODE_TYPES . JSXIdentifier ) {
9286 name = currentExpression . name + "." + name ;
9387 } else {
9488 name = currentExpression . namespace . name + "." + name ;
@@ -98,17 +92,16 @@ export class JSXDependencyProcessor extends Processor {
9892 }
9993
10094 const dep = new LCEJSXDependency ( new FQN ( name ) , name , 1 ) ;
101- if ( ! STANDARD_HTML_ELEMENTS . includes ( name ) ) {
95+ if ( ! STANDARD_HTML_ELEMENTS . includes ( name ) ) {
10296 // Custom Element: try to resolve reference and register dependency
10397 DependencyResolutionProcessor . scheduleFqnResolution ( localContexts , name , dep ) ;
10498 DependencyResolutionProcessor . registerDependency ( localContexts , name ) ;
10599 }
106100
107- const jsxDependencyContext = ( localContexts . getNextContext ( JSXDependencyContextProcessor . JSX_DEPENDENCY_CONTEXT ) as [ LCEJSXDependency [ ] , number ] ) ;
108- if ( jsxDependencyContext ) {
101+ const jsxDependencyContext = localContexts . getNextContext ( ReactContextKeys . JSX_DEPENDENCIES ) as [ LCEJSXDependency [ ] , number ] ;
102+ if ( jsxDependencyContext ) {
109103 jsxDependencyContext [ 0 ] . push ( dep ) ;
110104 }
111-
112105 }
113106 return new Map ( ) ;
114107 }
0 commit comments