Skip to content

Commit

Permalink
Merge pull request #68 from IBM/fix-issue-67
Browse files Browse the repository at this point in the history
Fix issue 67
  • Loading branch information
rahlk authored Nov 13, 2024
2 parents a7362bf + 8a2b1d5 commit 9730268
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cldk/analysis/java/codeanalyzer/codeanalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

from pdb import set_trace
import re
import json
import shlex
Expand Down
6 changes: 4 additions & 2 deletions cldk/models/java/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import re
from contextvars import ContextVar
from typing import Dict, List, Optional

from pdb import set_trace
from pydantic import BaseModel, field_validator, model_validator

from .constants_namespace import ConstantsNamespace
Expand Down Expand Up @@ -412,9 +412,11 @@ class JApplication(BaseModel):

@field_validator("symbol_table", mode="after")
@classmethod
def validate_source(cls, symbol_table):
def validate_source(cls, symbol_table) -> Dict[str, JCompilationUnit]:
# Populate the lookup table for callables
for _, j_compulation_unit in symbol_table.items():
for type_declaration, jtype in j_compulation_unit.type_declarations.items():
for __, j_callable in jtype.callable_declarations.items():
_CALLABLES_LOOKUP_TABLE[(type_declaration, j_callable.signature)] = j_callable

return symbol_table
14 changes: 14 additions & 0 deletions tests/analysis/java/test_java.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
from pdb import set_trace
from cldk import CLDK
from typing import List, Tuple
from cldk.analysis import AnalysisLevel
from cldk.models.java.models import JMethodDetail


def test_get_symbol_table_is_not_null(test_fixture, codeanalyzer_jar_path):
# Initialize the CLDK object with the project directory, language, and analysis_backend.
cldk = CLDK(language="java")
analysis = cldk.analysis(
project_path=test_fixture,
analysis_backend="codeanalyzer",
analysis_backend_path=codeanalyzer_jar_path,
eager=True,
analysis_level=AnalysisLevel.call_graph,
)
assert analysis.get_symbol_table() is not None


def test_get_class_call_graph(test_fixture, codeanalyzer_jar_path):
# Initialize the CLDK object with the project directory, language, and analysis_backend.
cldk = CLDK(language="java")
Expand Down

0 comments on commit 9730268

Please sign in to comment.