Skip to content

Commit 3c6e3e2

Browse files
committed
Set version to über json.
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
1 parent 420cccb commit 3c6e3e2

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

cldk/models/java/models.py

+9-26
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import json
21
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
54
from contextvars import ContextVar
5+
from typing import Dict, List, Optional
66
from .constants_namespace import ConstantsNamespace
7+
from pydantic import BaseModel, field_validator, model_validator
78

89
constants = ConstantsNamespace()
910
context_concrete_class = ContextVar("context_concrete_class") # context var to store class concreteness
@@ -340,18 +341,11 @@ class JGraphEdges(BaseModel):
340341
@field_validator("source", "target", mode="before")
341342
@classmethod
342343
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
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+
355349
mc = JMethodDetail(method_declaration=method_decl, klass=class_name, method=j_callable)
356350
return mc
357351

@@ -373,14 +367,3 @@ class JApplication(BaseModel):
373367

374368
symbol_table: Dict[str, JCompilationUnit]
375369
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

Comments
 (0)