Skip to content

Commit 67eb236

Browse files
authored
Merge pull request #42 from IBM/version-uber-json
Set version to über json
2 parents 32c8498 + c9e965d commit 67eb236

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

Diff for: cldk/models/java/models.py

+8-27
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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
10-
_CALLABLES_LOOKUP_TABLE = dict()
1111

1212

1313
class JField(BaseModel):
@@ -340,18 +340,10 @@ class JGraphEdges(BaseModel):
340340
@field_validator("source", "target", mode="before")
341341
@classmethod
342342
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
355347
mc = JMethodDetail(method_declaration=method_decl, klass=class_name, method=j_callable)
356348
return mc
357349

@@ -373,14 +365,3 @@ class JApplication(BaseModel):
373365

374366
symbol_table: Dict[str, JCompilationUnit]
375367
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)