Skip to content

Commit 8a2b1d5

Browse files
committed
Fix issue 67--symbol table is none.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent 32da358 commit 8a2b1d5

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

cldk/analysis/java/codeanalyzer/codeanalyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
################################################################################
16-
16+
from pdb import set_trace
1717
import re
1818
import json
1919
import shlex

cldk/models/java/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import re
2121
from contextvars import ContextVar
2222
from typing import Dict, List, Optional
23-
23+
from pdb import set_trace
2424
from pydantic import BaseModel, field_validator, model_validator
2525

2626
from .constants_namespace import ConstantsNamespace
@@ -412,9 +412,11 @@ class JApplication(BaseModel):
412412

413413
@field_validator("symbol_table", mode="after")
414414
@classmethod
415-
def validate_source(cls, symbol_table):
415+
def validate_source(cls, symbol_table) -> Dict[str, JCompilationUnit]:
416416
# Populate the lookup table for callables
417417
for _, j_compulation_unit in symbol_table.items():
418418
for type_declaration, jtype in j_compulation_unit.type_declarations.items():
419419
for __, j_callable in jtype.callable_declarations.items():
420420
_CALLABLES_LOOKUP_TABLE[(type_declaration, j_callable.signature)] = j_callable
421+
422+
return symbol_table

tests/analysis/java/test_java.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
from pdb import set_trace
12
from cldk import CLDK
23
from typing import List, Tuple
34
from cldk.analysis import AnalysisLevel
45
from cldk.models.java.models import JMethodDetail
56

67

8+
def test_get_symbol_table_is_not_null(test_fixture, codeanalyzer_jar_path):
9+
# Initialize the CLDK object with the project directory, language, and analysis_backend.
10+
cldk = CLDK(language="java")
11+
analysis = cldk.analysis(
12+
project_path=test_fixture,
13+
analysis_backend="codeanalyzer",
14+
analysis_backend_path=codeanalyzer_jar_path,
15+
eager=True,
16+
analysis_level=AnalysisLevel.call_graph,
17+
)
18+
assert analysis.get_symbol_table() is not None
19+
20+
721
def test_get_class_call_graph(test_fixture, codeanalyzer_jar_path):
822
# Initialize the CLDK object with the project directory, language, and analysis_backend.
923
cldk = CLDK(language="java")

0 commit comments

Comments
 (0)