1
- import json
2
1
import re
3
- from typing import Dict , List , Optional
4
- from pydantic import BaseModel , field_validator , model_validator
2
+ import json
3
+ from ipdb import set_trace
5
4
from contextvars import ContextVar
5
+ from typing import Dict , List , Optional
6
6
from .constants_namespace import ConstantsNamespace
7
+ from pydantic import BaseModel , field_validator , model_validator
7
8
8
9
constants = ConstantsNamespace ()
9
10
context_concrete_class = ContextVar ("context_concrete_class" ) # context var to store class concreteness
10
- _CALLABLES_LOOKUP_TABLE = dict ()
11
11
12
12
13
13
class JField (BaseModel ):
@@ -340,18 +340,10 @@ class JGraphEdges(BaseModel):
340
340
@field_validator ("source" , "target" , mode = "before" )
341
341
@classmethod
342
342
def validate_source (cls , value ) -> JMethodDetail :
343
- if isinstance (value , str ):
344
- callable_dict = json .loads (value )
345
- j_callable = JCallable (** json .loads (callable_dict ["callable" ])) # parse the value which is a quoted string
346
- class_name = callable_dict ["class_interface_declarations" ]
347
- method_decl = j_callable .declaration
348
- elif isinstance (value , dict ):
349
- file_path , type_declaration , callable_declaration = value ["file_path" ], value ["type_declaration" ], value ["callable_declaration" ]
350
- j_callable = _CALLABLES_LOOKUP_TABLE .get ((file_path , type_declaration , callable_declaration ), None )
351
- if j_callable is None :
352
- raise ValueError (f"Callable not found in lookup table: { file_path } , { type_declaration } , { callable_declaration } " )
353
- class_name = type_declaration
354
- method_decl = j_callable .declaration
343
+ callable_dict = json .loads (value )
344
+ j_callable = JCallable (** json .loads (callable_dict ["callable" ])) # parse the value which is a quoted string
345
+ class_name = callable_dict ["class_interface_declarations" ]
346
+ method_decl = j_callable .declaration
355
347
mc = JMethodDetail (method_declaration = method_decl , klass = class_name , method = j_callable )
356
348
return mc
357
349
@@ -373,14 +365,3 @@ class JApplication(BaseModel):
373
365
374
366
symbol_table : Dict [str , JCompilationUnit ]
375
367
system_dependency_graph : List [JGraphEdges ] = None
376
-
377
- @field_validator ("symbol_table" , mode = "after" )
378
- @classmethod
379
- def validate_source (cls , symbol_table ):
380
- # from ipdb import set_trace
381
-
382
- # Populate the lookup table for callables
383
- for file_path , j_compulation_unit in symbol_table .items ():
384
- for type_declaration , jtype in j_compulation_unit .type_declarations .items ():
385
- for callable_declaration , j_callable in jtype .callable_declarations .items ():
386
- _CALLABLES_LOOKUP_TABLE [(file_path , type_declaration , callable_declaration )] = j_callable
0 commit comments