### Install Python SDK Source: https://github.com/codellm-devkit/python-sdk/blob/main/README.md Install the Python SDK using pip. Optional extras like Neo4j support can be installed with specific package names. ```bash pip install cldk ``` ```bash pip install "cldk[neo4j]" ``` -------------------------------- ### Install Node.js and npm for TypeScript Analysis Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Install Node.js and npm to resolve 'Node.js/npm not found' errors, then reinstall cldk. ```bash # macOS brew install node # Ubuntu sudo apt-get install nodejs npm # Then reinstall cldk to re-download dependencies pip install --upgrade cldk ``` -------------------------------- ### Get entry point methods Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Retrieves a nested dictionary of methods identified as entry points in the codebase. Useful for identifying starting points of execution. ```python entry_points = analysis.get_entry_point_methods() for class_name, methods in entry_points.items(): for method_sig in methods: print(f"Entry point: {class_name}.{method_sig}") ``` -------------------------------- ### Install CLDK Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md Install the CLDK package using pip. ```bash pip install cldk ``` -------------------------------- ### Install CLDK Package Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Ensure the cldk package is installed and up-to-date to resolve 'Classanalyzer not found' errors. ```bash pip install --upgrade cldk ``` -------------------------------- ### Get Entry Point Methods Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Identifies and returns methods that are considered entry points within the codebase. ```python def get_entry_point_methods(self) -> Dict[str, Dict[str, JCallable]]: ``` -------------------------------- ### Get Entry Point Classes Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Identifies and returns classes that serve as entry points, such as those with main methods or servlet implementations. ```python def get_entry_point_classes(self) -> Dict[str, JType]: ``` -------------------------------- ### Start Neo4j Server and Verify Connection Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Ensure the Neo4j server is running and accessible. Verify the connection using 'cypher-shell'. ```bash # Verify Neo4j is running neo4j start # or docker run neo4j # Check connection cypher-shell -a bolt://localhost:7687 "RETURN 1" ``` ```python config = Neo4jConnectionConfig( uri="bolt://localhost:7687", username="neo4j", password="password" ) ``` -------------------------------- ### Get All Interfaces Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a dictionary of all interfaces defined in the project. ```python interfaces = analysis.get_interfaces() print(f"Found {len(interfaces)} interfaces") ``` -------------------------------- ### Error Handling for SDK Initialization Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md Shows how to handle potential initialization errors using try-except blocks. Catches `CldkInitializationException` for setup failures and `NotImplementedError` for unsupported features. ```python from cldk.utils.exceptions import CldkInitializationException try: analysis = CLDK.java(project_path="/path/to/project") except CldkInitializationException as e: print(f"Failed: {e}") except NotImplementedError as e: print(f"Feature not supported: {e}") ``` -------------------------------- ### Example Usage of C Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Demonstrates how to initialize the C analysis facade and retrieve function and type information from a C/C++ project. It iterates through the found functions, printing their signatures and parameter details. ```python from cldk import CLDK analysis = CLDK.c(project_path="/path/to/c/project") functions = analysis.get_all_functions() types = analysis.get_all_types() for func_name, cfunc in functions.items(): print(f"{func_name}: {cfunc.signature}") for param in cfunc.parameters: print(f" param: {param.type} {param.name}") ``` -------------------------------- ### Get All Create Operations Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Filters and returns only the create operations, such as INSERT statements or constructor calls. ```python def get_all_create_operations(self) -> List[Dict[str, Union[JType, JCallable, List[JCRUDOperation]]]]: ``` -------------------------------- ### Get Include Directives in C Project Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Retrieves a list of all include directives used in the C/C++ project. ```python def get_includes(self) -> List[str]: ``` -------------------------------- ### Build and Traverse Call Graph (Python) Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md Analyze a Python project to build and traverse its call graph. This example uses the networkx library to count nodes and edges, and find descendants. ```python import networkx as nx from cldk import CLDK analysis = CLDK.python( project_path="/path/to/project", analysis_level="call_graph" ) graph = analysis.get_call_graph() print(f"Callables: {graph.number_of_nodes()}") print(f"Calls: {graph.number_of_edges()}") # Find all descendants (transitive callees) descendants = nx.descendants(graph, "mymodule.main_function") ``` -------------------------------- ### Handle ValueError for Python Analysis Configuration Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md This example demonstrates a ValueError that can occur during Python analysis if the project_path is missing and a non-Neo4j backend is specified. ```python # Error: project_dir is required; source_code mode is not supported for Python. analysis = CLDK.python(backend=Neo4jConnectionConfig(...)) # Missing project_path, non-Neo4j backend ``` -------------------------------- ### Specify Custom Java Development Kit Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md Configure the Java Development Kit (JDK) to be used for Java analysis by setting the JAVA_HOME environment variable. Ensure the specified path points to a valid JDK installation. ```bash export JAVA_HOME=/path/to/jdk ``` -------------------------------- ### Get Application View Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves the complete JApplication model, including the symbol table, call graph, and metadata. This method is not available in single-file mode. ```python analysis = CLDK.java(project_path="/path/to/project") app = analysis.get_application_view() symbol_table = app.symbol_table ``` -------------------------------- ### Default Cache Location Example Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Demonstrates the default cache directory structure when not explicitly specified. The cache is language-specific and located within the project's .codeanalyzer directory. ```python analysis = CLDK.java(project_path="/home/user/myproject") # Cache location: /home/user/myproject/.codeanalyzer/java/ ``` -------------------------------- ### Get Application View Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves the complete TSApplication model, which includes the symbol table and call graph. This is useful for a comprehensive understanding of the project's structure and dependencies. ```python app = analysis.get_application_view() ``` -------------------------------- ### Get Complete Application Model Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Retrieve the complete `PyApplication` model, which includes the symbol table and call graph, using the `get_application_view` method. ```python app = analysis.get_application_view() modules = app.modules ``` -------------------------------- ### Get Entry Point Methods (Not Implemented) Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Attempts to retrieve entry point methods. This functionality is not yet supported in codeanalyzer-typescript and will raise a NotImplementedError. ```typescript def get_entry_point_methods(self) -> Dict[str, Dict[str, TSCallable]]: ``` -------------------------------- ### Get All Functions in C Project Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Retrieves a dictionary of all functions within the analyzed C/C++ project. Each function entry includes its signature, parameters, return type, and source location. ```python def get_all_functions(self) -> Dict[str, CFunction]: ``` -------------------------------- ### Get Symbol Table Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Returns a dictionary mapping file paths to JCompilationUnit objects, providing detailed information about each compilation unit, including package name, imports, and type declarations. ```python symbol_table = analysis.get_symbol_table() for file_path, compilation_unit in symbol_table.items(): print(f"{file_path}: {compilation_unit.package_name}") for type_name, jtype in compilation_unit.type_declarations.items(): print(f ``` -------------------------------- ### Create TypeScript Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Use `CLDK.typescript()` to create a TypeScript analysis facade. You can specify the `project_path` and configure the backend, for example, using `TSCodeAnalyzerConfig` with `tsc_only=True`. ```python from cldk import CLDK from cldk.analysis.commons.backend_config import TSCodeAnalyzerConfig analysis = CLDK.typescript( project_path="/path/to/ts/project", backend=TSCodeAnalyzerConfig(tsc_only=True) ) modules = analysis.get_modules() ``` -------------------------------- ### Get All Enums Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a dictionary of all enums defined in the project. ```python enums = analysis.get_enums() print(f"Found {len(enums)} enums") ``` -------------------------------- ### Import Backend Configuration Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md Import configuration classes for setting up code analyzers and Neo4j connections. ```python from cldk.analysis.commons.backend_config import CodeAnalyzerConfig, Neo4jConnectionConfig, ... ``` -------------------------------- ### Get Service Entry Point Methods (Not Implemented) Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Attempts to retrieve service entry point methods. This functionality is not yet supported in codeanalyzer-typescript and will raise a NotImplementedError. ```typescript def get_service_entry_point_methods(self, **kwargs) -> Dict[str, Dict[str, TSCallable]]: ``` -------------------------------- ### Handle NotImplementedError for Single-File Analysis Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md This example shows a NotImplementedError that occurs when trying to perform single-file analysis in project mode, specifically when requesting a call graph. ```python analysis = CLDK.java(project_path="/path/to/project") graph = analysis.get_call_graph_json() # If source_code was used instead # NotImplementedError: Producing a call graph over a single file is not implemented yet. ``` -------------------------------- ### Import Backend Configuration Classes and Types Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md Import configuration classes for different backends and helper functions for cache directory computation. ```python from cldk.analysis.commons.backend_config import ( CodeAnalyzerConfig, PyCodeAnalyzerConfig, TSCodeAnalyzerConfig, Neo4jConnectionConfig, cache_subdir, JavaBackend, PyBackend, TSBackend, ) ``` -------------------------------- ### Get Calling Lines Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Finds all line numbers where a target method is invoked. ```python def get_calling_lines(self, target_method_name: str) -> List[int]: ``` -------------------------------- ### Get Java Compilation Unit Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Generates a JCompilationUnit object for a specified file path. ```python def get_java_compilation_unit(self, file_path: str) -> JCompilationUnit: ``` -------------------------------- ### Get Symbol Table in C Project Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Retrieves a dictionary that maps compilation unit file paths to their respective symbol information for the C/C++ project. ```python def get_symbol_table(self) -> Dict[str, CCompilationUnit]: ``` -------------------------------- ### Get Test Methods Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a dictionary of test methods identified by annotations like @Test. ```python def get_test_methods(self) -> Dict[str, str]: ``` -------------------------------- ### Create C Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Use `CLDK.c()` to create a C analysis facade by providing the required `project_path` to the C project directory. ```python from cldk import CLDK analysis = CLDK.c(project_path="/path/to/c/project") ``` -------------------------------- ### Get Nested Classes Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Lists all nested classes within a given qualified class name. ```python def get_nested_classes(self, qualified_class_name: str) -> List[JType]: ``` -------------------------------- ### Get Raw AST from Java Code Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Parses Java source code using Tree-sitter and returns the resulting Abstract Syntax Tree (AST). Use this for deep syntactic analysis. ```python def get_raw_ast(self, source_code: str) -> Tree: ``` -------------------------------- ### Get Constructors in a Class Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves all constructors for a given class, mapping their signatures to JCallable objects. ```python def get_constructors(self, qualified_class_name: str) -> Dict[str, JCallable]: ``` -------------------------------- ### Catch CldkInitializationException Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Demonstrates how to catch `CldkInitializationException` during CLDK initialization. Ensure necessary imports are present. ```python from cldk import CLDK from cldk.utils.exceptions import CldkInitializationException try: analysis = CLDK.java(project_path="/nonexistent/path") except CldkInitializationException as e: print(f"Initialization failed: {e}") ``` -------------------------------- ### Get Subclasses Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a dictionary of direct subclasses for a given class, including their JType objects. ```python analysis.get_sub_classes(qualified_class_name="com.example.BaseClass") ``` -------------------------------- ### get_entry_point_classes() Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a dictionary of classes identified as entry points (e.g., main methods, servlets). ```APIDOC ## get_entry_point_classes() ### Description Retrieves a dictionary of classes identified as entry points (e.g., main methods, servlets). ### Method ```python def get_entry_point_classes(self) -> Dict[str, JType]: ``` ### Returns Dict of classes identified as entry points (main methods, servlets, etc.) ``` -------------------------------- ### Get Extended Classes Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a list of fully qualified superclass names for a given class. ```python analysis.get_extended_classes(qualified_class_name="com.example.MyClass") ``` -------------------------------- ### Initialize tsconfig.json for TypeScript Projects Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Ensure the project root has a tsconfig.json file. If not, initialize it using 'npx tsc --init'. ```bash cd /path/to/ts/project npx tsc --init ``` -------------------------------- ### Create Java Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Use `CLDK.java()` to create a Java analysis facade. You can analyze a full project by providing `project_path` or use a Neo4j backend for read-only analysis if the graph is pre-populated. ```python from cldk import CLDK # Full project analysis analysis = CLDK.java(project_path="/path/to/java/project") symbol_table = analysis.get_symbol_table() ``` ```python from cldk.analysis.commons.backend_config import Neo4jConnectionConfig # Neo4j-backed read-only analysis (graph pre-populated out of band) analysis = CLDK.java( backend=Neo4jConnectionConfig( uri="bolt://localhost:7687", application_name="my-app" ) ) ``` -------------------------------- ### Get All Delete Operations Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Filters and returns only the delete operations, such as DELETE statements or data removal methods. ```python def get_all_delete_operations(self) -> List[Dict[str, Union[JType, JCallable, List[JCRUDOperation]]]]: ``` -------------------------------- ### Get All Update Operations Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Filters and returns only the update operations, including UPDATE statements and data mutations. ```python def get_all_update_operations(self) -> List[Dict[str, Union[JType, JCallable, List[JCRUDOperation]]]]: ``` -------------------------------- ### Backend Selection for Code Analysis Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md Demonstrates how to select different backends for code analysis. Use `CodeAnalyzerConfig` for in-process analysis or `Neo4jConnectionConfig` for a read-only Neo4j backend. ```python from cldk import CLDK from cldk.analysis.commons.backend_config import CodeAnalyzerConfig, Neo4jConnectionConfig # In-process analysis = CLDK.java( project_path="/path/to/project", backend=CodeAnalyzerConfig(cache_dir="/tmp/cache") ) # Read-only Neo4j analysis = CLDK.java( backend=Neo4jConnectionConfig(uri="bolt://localhost:7687") ) ``` -------------------------------- ### Handle Missing Project Directory Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Illustrates an error scenario where the `project_path` does not exist or is not a directory. The fix involves verifying the path and ensuring it is a valid directory before proceeding. ```python # Error: project_path does not exist or is not a directory: /path/to/project analysis = CLDK.java(project_path="/path/that/does/not/exist") ``` ```python from pathlib import Path project_path = Path("/path/to/project") if not project_path.is_dir(): raise ValueError(f"Project directory not found: {project_path}") analysis = CLDK.java(project_path=project_path) ``` -------------------------------- ### Get Implemented Interfaces Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a list of fully qualified interface names implemented by a given class. ```python analysis.get_implemented_interfaces(qualified_class_name="com.example.MyInterface") ``` -------------------------------- ### get_entry_point_methods() Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a nested dictionary of methods identified as entry points. ```APIDOC ## get_entry_point_methods() ### Description Retrieves a nested dictionary of methods identified as entry points. ### Method ```python def get_entry_point_methods(self) -> Dict[str, Dict[str, JCallable]]: ``` ### Returns Nested dict of methods identified as entry points ``` -------------------------------- ### Clone Repository Source: https://github.com/codellm-devkit/python-sdk/blob/main/CONTRIBUTING.md Clone your forked repository to your local machine to begin making changes. ```bash git clone https://github.com/your-username/repository-name.git ``` -------------------------------- ### Get all classes and their methods Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Retrieves a dictionary of all classes and their associated methods. Useful for understanding the structure of the codebase. ```python classes = analysis.get_classes() for class_name, pyclass in classes.items(): print(f"{class_name}: {len(pyclass.callables)} methods") ``` -------------------------------- ### Import C Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md Import the CAnalysis class for performing code analysis on C projects. ```python from cldk.analysis.c import CAnalysis ``` -------------------------------- ### CLDK.c() Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Creates a C analysis facade. This method requires the path to the C project directory. ```APIDOC ## CLDK.c() ### Description Creates a C analysis facade. This method requires the path to the C project directory. ### Method Signature ```python @staticmethod def c(project_path: str | Path) -> CAnalysis: ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `project_path` | `str \| Path` | — | Path to C project directory (required) | ### Returns `CAnalysis` facade ``` -------------------------------- ### Get All Read Operations Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Filters and returns only the read operations, typically involving SELECT statements or data queries. ```python def get_all_read_operations(self) -> List[Dict[str, Union[JType, JCallable, List[JCRUDOperation]]]]: ``` -------------------------------- ### Get Fields in a Class Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a list of JField objects representing all fields declared within a specified class. ```python def get_fields(self, qualified_class_name: str) -> List[JField]: ``` -------------------------------- ### Get All Methods in a Class Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves all methods within a specified class. Useful for understanding the behavior and structure of a class. ```python def get_methods(self) -> Dict[str, Dict[str, JCallable]]: ``` ```python all_methods = analysis.get_methods() for class_name, methods in all_methods.items(): for method_sig, jcallable in methods.items(): print(f"{class_name}.{method_sig}") ``` -------------------------------- ### Handle NotImplementedError for Entry Point Detection (TypeScript) Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Illustrates a NotImplementedError when entry point detection is not supported by the TypeScript backend. ```python analysis = CLDK.typescript(project_path="/path/to/ts/project") entry_points = analysis.get_entry_point_methods() # NotImplementedError: Entrypoint detection is not implemented in the codeanalyzer-typescript backend yet. ``` -------------------------------- ### Get All Decorators Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves all decorators defined in the project. Returns a dictionary mapping decorator names to TSDecorator objects. ```typescript def get_decorators(self) -> Dict[str, TSDecorator]: ``` -------------------------------- ### Get Call Graph Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves the call graph of the project. Requires analysis_level set to "call_graph". ```python graph = analysis.get_call_graph() print(f"Callables: {graph.number_of_nodes()}") print(f"Calls: {graph.number_of_edges()}") ``` -------------------------------- ### Import Analysis Module Facades and Enums Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md Import facades for various language analyses and the AnalysisLevel enum. ```python from cldk.analysis import AnalysisLevel from cldk.analysis.java import JavaAnalysis from cldk.analysis.python import PythonAnalysis from cldk.analysis.typescript import TypeScriptAnalysis from cldk.analysis.c import CAnalysis ``` -------------------------------- ### Get All Global Variables in C Project Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Retrieves a dictionary of all global variables declared within the C/C++ project. ```python def get_all_variables(self) -> Dict[str, CVariable]: ``` -------------------------------- ### CLDK.c() Configuration Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Configure the C analysis factory method. It requires the project path for analysis. ```APIDOC ## CLDK.c() ### Description Analyzes C projects. Requires the project path for analysis. ### Method Signature ```python @staticmethod def c( project_path: str | Path ) -> CAnalysis: ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Default | Description | |---|---|---|---| | `project_path` | `str | Path` | — | C project directory (required) | ``` -------------------------------- ### Get Java File Path Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves the file path of the Java source file for a given qualified class name. ```python def get_java_file(self, qualified_class_name: str) -> str: ``` -------------------------------- ### C Project Analysis Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Initiates analysis for a C project. The `project_path` parameter is required. ```python def c(project_path: str | Path) -> CAnalysis: ``` -------------------------------- ### Get Methods in a Single Class Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves all methods within a specified class, returning them as a dictionary of signatures to JCallable objects. ```python def get_methods_in_class(self, qualified_class_name: str) -> Dict[str, JCallable]: ``` -------------------------------- ### Analyze C Project with CLDK Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md Use the CLDK.c() factory method to analyze a C project. Retrieve all functions from the analysis result. ```python # Analyze C project analysis = CLDK.c(project_path="/path/to/c/project") functions = analysis.get_all_functions() ``` -------------------------------- ### Get All Imports Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves all import statements present in the project. Returns a dictionary mapping import identifiers to TSImport objects. ```typescript def get_imports(self) -> Dict[str, TSImport]: ``` -------------------------------- ### Populate Neo4j Graph with codeanalyzer-java Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Pre-populate the Neo4j graph using the `codeanalyzer-java` binary before using the SDK with a Neo4j backend. This is a one-time, out-of-band operation. ```bash # Populate Neo4j graph (run once, out of band) codeanalyzer-java \ --project-path /path/to/java/project \ --emit neo4j \ --neo4j-uri bolt://localhost:7687 \ --neo4j-username neo4j \ --neo4j-password neo4j \ --app-name myapp # Now use SDK with read-only backend cldk.java(backend=Neo4jConnectionConfig(...)) ``` -------------------------------- ### Get Single Enum Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a single TSEnum object by its fully qualified name. Returns None if the enum is not found. ```python my_enum = analysis.get_enum("com.example.MyEnum") if my_enum: print(f"Found enum: {my_enum.name}") ``` -------------------------------- ### Create Language-Specific Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/README.md Instantiate a language-specific analysis facade using factory methods provided by CLDK. Each method corresponds to a supported programming language. ```python from cldk import CLDK # Pick a language — each returns a typed analysis facade. analysis = CLDK.java(project_path="/path/to/java/project") # analysis = CLDK.python(project_path="/path/to/python/project") # analysis = CLDK.typescript(project_path="/path/to/ts/project") ``` -------------------------------- ### Get Single Interface Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a single TSInterface object by its fully qualified name. Returns None if the interface is not found. ```python my_interface = analysis.get_interface("com.example.MyInterface") if my_interface: print(f"Found interface: {my_interface.name}") ``` -------------------------------- ### Configure Python Analysis Backend Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md The `backend` parameter allows for custom configuration of Python analysis. A `project_path` is required for the in-process backend. ```python def python( project_path: str | Path | None = None, *, analysis_level: str = AnalysisLevel.symbol_table, target_files: List[str] | None = None, eager: bool = False, backend: PyBackend | None = None, ) -> PythonAnalysis: ``` -------------------------------- ### Configure Java Analysis Backend Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Use the `backend` parameter to specify a custom configuration for Java analysis. Defaults to an in-process analyzer with a cache. ```python def java( project_path: str | Path | None = None, source_code: str | None = None, *, analysis_level: str = AnalysisLevel.symbol_table, target_files: List[str] | None = None, eager: bool = False, backend: JavaBackend | None = None, ) -> JavaAnalysis: ``` -------------------------------- ### Get Single Class Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a single TSClass object by its fully qualified name. Returns None if the class is not found. ```python my_class = analysis.get_class("com.example.MyClass") if my_class: print(f"Found class: {my_class.name}") ``` -------------------------------- ### Get List of All Python Modules Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Retrieve a list of all `PyModule` objects within the analyzed project using the `get_modules` method. ```python modules = analysis.get_modules() ``` -------------------------------- ### Entry Point Detection Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Methods for identifying entry point methods in the analyzed code. ```APIDOC ## get_entry_point_methods() ### Description Identifies and retrieves methods designated as entry points. ### Method `get_entry_point_methods(self) -> Dict[str, Dict[str, PyCallable]]` ### Returns - Dict[str, Dict[str, PyCallable]]: A nested dictionary where the outer keys are class names and the inner dictionaries map method signatures to `PyCallable` objects, representing entry points. ### Example ```python entry_points = analysis.get_entry_point_methods() for class_name, methods in entry_points.items(): for method_sig in methods: print(f"Entry point: {class_name}.{method_sig}") ``` ``` -------------------------------- ### Get All CRUD Operations Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a comprehensive list of all detected CRUD (Create, Read, Update, Delete) operations across the codebase. ```python def get_all_crud_operations(self) -> List[Dict[str, Union[JType, JCallable, List[JCRUDOperation]]]]: ``` -------------------------------- ### Create Python Analysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Use `CLDK.python()` to create a Python analysis facade. Specify the `project_path` and optionally the `analysis_level` for deeper analysis. ```python from cldk import CLDK from cldk.analysis.commons.backend_config import PyCodeAnalyzerConfig analysis = CLDK.python( project_path="/path/to/python/project", analysis_level="call_graph" ) call_graph = analysis.get_call_graph() ``` -------------------------------- ### Get Method Parameters Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a list of parameter type strings for a given method in a class. Useful for understanding method signatures. ```python def get_method_parameters( self, qualified_class_name: str, qualified_method_name: str, ) -> List[str]: ``` -------------------------------- ### Top-Level CLDK Package Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md The core factory class `CLDK` is the main entry point for interacting with the SDK. ```APIDOC ## Top-Level: cldk package ```python from cldk import CLDK ``` **Exports**: - `CLDK` — Core factory class ``` -------------------------------- ### Get All Module-Level Variables Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves all module-level variable declarations in the project. Returns a dictionary mapping variable names to TSVariableDeclaration objects. ```typescript def get_variables(self) -> Dict[str, TSVariableDeclaration]: ``` -------------------------------- ### CLDK Constructor Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Initializes the CLDK core with a specified programming language. ```APIDOC ## Class: CLDK ### Constructor ```python def __init__(self, language: str) -> None: ``` #### Parameters - `language` (str) - Required - Target programming language for analysis: "java", "python", "c", or "typescript" (case-sensitive) #### Returns - CLDK instance #### Attributes after initialization - `language` (str): The selected programming language ``` -------------------------------- ### Get All Module Exports Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves all module exports within the project. Returns a dictionary mapping export names to TSExport objects. ```typescript def get_exports(self) -> Dict[str, TSExport]: ``` -------------------------------- ### Get Callees Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Finds all methods or functions called by a specific source. The source can be specified by class name and optionally by method declaration. ```python callees = analysis.get_callees("mysource.MySourceClass", "sourceMethod()") for callee_info in callees.get("callees", []): print(f"Calls: {callee_info}") ``` -------------------------------- ### Instantiate PythonAnalysis Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Use the CLDK.python() static factory method to instantiate the PythonAnalysis class. Direct instantiation is not supported for single-file source code analysis. ```python analysis = CLDK.python(project_path="/path/to/project") ``` -------------------------------- ### Get Callers Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Finds all methods or functions that call a specific target. The target can be specified by class name and optionally by method declaration. ```python callers = analysis.get_callers("mymodule.MyClass", "method()") for caller_info in callers.get("callers", []): print(f"Called by: {caller_info}") ``` -------------------------------- ### Handle ValueError for Invalid Analysis Level Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Shows how a ValueError is raised when an unrecognized analysis level is provided during Java analysis setup. ```python analysis = CLDK.java( project_path="/path/to/project", analysis_level="invalid_level" ) # Backend will raise ValueError for unrecognized analysis level ``` -------------------------------- ### Deprecated CLDK Analysis Method Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md The old `CLDK.analysis()` entry point is retained for compatibility but emits a DeprecationWarning. Use the static factory methods instead. ```python # Deprecated cldk = CLDK("java") analysis = cldk.analysis( project_path="/path/to/project", cache_dir="/tmp/cache" ) # Preferred analysis = CLDK.java( project_path="/path/to/project", backend=CodeAnalyzerConfig(cache_dir="/tmp/cache") ) ``` -------------------------------- ### Get Methods with Annotations Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Finds methods decorated with specific annotations. Useful for identifying methods with particular roles, like API endpoints. ```python def get_methods_with_annotations(self, annotations: List[str]) -> Dict[str, List[Dict]]: ``` ```python rest_methods = analysis.get_methods_with_annotations(["GetMapping", "PostMapping"]) ``` -------------------------------- ### Get Tree-sitter Java Sanitizer Utilities Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Obtain Tree-sitter-based utilities for sanitizing Java source code. This functionality is currently limited to Java. ```python cldk = CLDK("java") sanitizer = cldk.tree_sitter_utils(java_source_code) cleaned = sanitizer.remove_unused_imports() ``` -------------------------------- ### CAnalysis.get_includes Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Retrieves a list of all include directives found in the C/C++ project. ```APIDOC ## get_includes() ### Description Retrieves a list of include directives used in the project. ### Returns List[str] - A list of strings, each representing an include directive. ``` -------------------------------- ### Get Tree-sitter Java Parser Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/cldk-core.md Retrieve a Tree-sitter parser instance for Java. This method currently only supports Java and will raise `NotImplementedError` for other languages. ```python cldk = CLDK("java") parser = cldk.treesitter_parser() is_valid = parser.is_parsable("public class Test {}") ``` -------------------------------- ### CLDK.java() Configuration Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Configure the Java analysis factory method. It accepts parameters for project path, source code, analysis level, target files, eager analysis, and backend configuration. ```APIDOC ## CLDK.java() ### Description Analyzes Java projects. Accepts configuration for project path, source code, analysis level, target files, eager analysis, and backend. ### Method Signature ```python @staticmethod def java( project_path: str | Path | None = None, source_code: str | None = None, *, analysis_level: str = AnalysisLevel.symbol_table, target_files: List[str] | None = None, eager: bool = False, backend: JavaBackend | None = None, ) -> JavaAnalysis: ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Default | Description | |---|---|---|---| | `project_path` | `str | Path | None` | Java project directory | | `source_code` | `str | None` | `None` | Single Java source file (deprecated) | | `analysis_level` | `str` | `AnalysisLevel.symbol_table` | Analysis depth: `"symbol table"`, `"call_graph"`, `"program_dependency_graph"`, `"system_dependency_graph"` | | `target_files` | `List[str] | None` | `None` | Restrict analysis to files (relative paths) | | `eager` | `bool` | `False` | Force regeneration of cached analysis | | `backend` | `JavaBackend | None` | `CodeAnalyzerConfig()` | Backend config (`CodeAnalyzerConfig` or `Neo4jConnectionConfig`). Defaults to in-process with cache at `/.codeanalyzer` | ### Analysis Levels - `symbol_table` — Fast: extracts symbols only (classes, methods, fields) - `call_graph` — Full: includes method call relationships - `program_dependency_graph` — Extended: adds data/control dependencies - `system_dependency_graph` — Comprehensive: system-level module dependencies ``` -------------------------------- ### Import Core CLDK Factory Class Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md Import the main factory class for interacting with the CodeLLM DevKit. ```python from cldk import CLDK ``` -------------------------------- ### Get Module by Name Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a single module by its name or file path. Returns the TSModule object if found, otherwise returns None. ```typescript def get_module(self, module_name: str) -> TSModule | None: ``` -------------------------------- ### CLDK.python() Configuration Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/configuration.md Configure the Python analysis factory method. It accepts parameters for project path, analysis level, target files, eager analysis, and backend configuration. ```APIDOC ## CLDK.python() ### Description Analyzes Python projects. Accepts configuration for project path, analysis level, target files, eager analysis, and backend. Note: Python does not support single-file `source_code` mode; use `project_path`. ### Method Signature ```python @staticmethod def python( project_path: str | Path | None = None, *, analysis_level: str = AnalysisLevel.symbol_table, target_files: List[str] | None = None, eager: bool = False, backend: PyBackend | None = None, ) -> PythonAnalysis: ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Default | Description | |---|---|---|---| | `project_path` | `str | Path | None` | Python project directory (required for in-process backend) | | `analysis_level` | `str` | `AnalysisLevel.symbol_table` | Analysis depth | | `target_files` | `List[str] | None` | `None` | Restrict analysis to files | | `eager` | `bool` | `False` | Force regeneration | | `backend` | `PyBackend | None` | `PyCodeAnalyzerConfig()` | Backend config (`PyCodeAnalyzerConfig` or `Neo4jConnectionConfig`) | ``` -------------------------------- ### Get Class Hierarchy Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a NetworkX DiGraph representing inheritance and implementation relationships between classes and interfaces. Edges point from child to base. ```python hierarchy = analysis.get_class_hierarchy() print(f"Hierarchy nodes: {hierarchy.number_of_nodes()}") print(f"Hierarchy edges: {hierarchy.number_of_edges()}") ``` -------------------------------- ### get_application_view() Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/python-analysis.md Retrieves a complete PyApplication model containing the symbol table and call graph. ```APIDOC ## get_application_view() ### Description Retrieves the complete `PyApplication` model, which includes the symbol table and call graph. ### Signature ```python def get_application_view(self) -> PyApplication: ``` ### Returns - `PyApplication` - Complete application model containing symbol table and call graph. ### Example ```python app = analysis.get_application_view() modules = app.modules ``` ``` -------------------------------- ### CAnalysis Facade Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/INDEX.md The CAnalysis facade is designed for analyzing C projects, facilitating function and type extraction, call graph construction, and tracking include directives. ```APIDOC ## CAnalysis Facade ### Description Facade for performing analysis on C projects. It focuses on extracting core C constructs and understanding code relationships. ### Methods - `get_all_functions()`: Retrieves a list of all functions in the C project. - `get_type_extraction()`: Provides extracted type information. - `get_call_graph_construction()`: Returns the constructed call graph. - `get_include_directive_tracking()`: Tracks and provides information about include directives. ``` -------------------------------- ### Get All Types in C Project Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/c-analysis.md Retrieves a dictionary of all type declarations, including structs, unions, enums, and typedefs, present in the C/C++ project. ```python def get_all_types(self) -> Dict[str, CType]: ``` -------------------------------- ### Instantiate JavaAnalysis Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Use the CLDK.java() static factory method for instantiation. This method simplifies the creation of a JavaAnalysis object, abstracting away direct constructor calls. ```python def __init__( self, project_dir: str | Path | None, source_code: str | None, analysis_level: str, target_files: List[str] | None, eager_analysis: bool, backend: JavaBackend | None = None, ) -> None: ``` -------------------------------- ### Get Specific Class by Name Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Retrieves a single JType object for a given fully qualified class name. Raises an error if the class is not found. ```python jtype = analysis.get_class("java.util.ArrayList") print(f"Methods: {list(jtype.callable_declarations.keys())}") ``` -------------------------------- ### Get Callees of a Method Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Finds all methods called by a specific source method. You can optionally use the symbol table for faster but less accurate results. ```python callees = analysis.get_callees( source_class_name="com.example.Controller", source_method_declaration="handleRequest(Request)" ) ``` -------------------------------- ### Get Callers of a Method Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/java-analysis.md Finds all methods that call a specific target method. You can optionally use the symbol table for faster but less accurate results. ```python callers = analysis.get_callers( target_class_name="com.example.Service", target_method_declaration="getValue()" ) for caller_info in callers.get("callers", []): print(f"Called by: {caller_info}") ``` -------------------------------- ### Get Call Targets from a Source Callable Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves all callee signatures invoked from a given source callable signature. Returns a set of callee signatures. ```typescript def get_call_targets(self, source_signature: str) -> Set[str]: ``` -------------------------------- ### Get Specific Callable by Name Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/api-reference/typescript-analysis.md Retrieves a single callable entity by its qualified name. Returns the TSCallable object if found, otherwise returns None. ```typescript def get_callable(self, qualified_callable_name: str) -> TSCallable | None: ``` -------------------------------- ### Backend Configuration Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/module-structure.md Configuration classes for various backends used in analysis, including in-process and Neo4j options. ```APIDOC ## Backend Configuration: cldk.analysis.commons.backend_config ```python from cldk.analysis.commons.backend_config import ( CodeAnalyzerConfig, PyCodeAnalyzerConfig, TSCodeAnalyzerConfig, Neo4jConnectionConfig, cache_subdir, JavaBackend, PyBackend, TSBackend, ) ``` **Exports**: - `CodeAnalyzerConfig` — In-process backend for Java/TypeScript - `PyCodeAnalyzerConfig` — In-process backend for Python (with Ray option) - `TSCodeAnalyzerConfig` — In-process backend for TypeScript (with tsc_only option) - `Neo4jConnectionConfig` — Read-only Neo4j backend (all languages) - `cache_subdir()` — Helper to compute cache directory paths - Type aliases: `JavaBackend`, `PyBackend`, `TSBackend` ``` -------------------------------- ### Populate Neo4j Graph with Application Name Source: https://github.com/codellm-devkit/python-sdk/blob/main/_autodocs/errors.md Ensure the Neo4j graph is populated with the correct application name using 'codeanalyzer-java' and that the SDK uses the matching name. ```bash # Populate graph with correct app name codeanalyzer-java \ --project-path /path/to/project \ --emit neo4j \ --app-name myapp ``` ```python # Ensure SDK uses matching name config = Neo4jConnectionConfig( uri="bolt://localhost:7687", application_name="myapp" ) ```