|
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 2 | +<class name="GodotProjectContext" inherits="RefCounted" api_type="extension" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd"> |
| 3 | + <brief_description> |
| 4 | + Native API entry point for GoTool Center project registration, scanning, and inventory queries. |
| 5 | + </brief_description> |
| 6 | + <description> |
| 7 | + [GodotProjectContext] bridges editor-side scripts to the native GoTool Center backend. It owns database initialization, project identity registration, asynchronous and fast inventory scans, file watcher integration, and read APIs over persisted scan results. |
| 8 | + |
| 9 | + Call [method initialize_database] before starting scans or querying inventory. Methods return empty arrays or dictionaries on failure, and [method get_last_error] provides the latest error message when available. |
| 10 | + </description> |
| 11 | + <tutorials> |
| 12 | + </tutorials> |
| 13 | + <methods> |
| 14 | + <method name="benchmark_native_scan"> |
| 15 | + <return type="Dictionary" /> |
| 16 | + <param index="0" name="options" type="Dictionary" /> |
| 17 | + <description> |
| 18 | + Runs the native scanner in benchmark mode without materializing file rows into Godot dictionaries. The [param options] dictionary supports [code]include_hidden[/code], [code]include_custom_classes[/code], [code]force_rescan[/code], [code]load_existing_snapshot[/code], [code]include_database_snapshot[/code], [code]use_dirty_path_filter[/code], [code]dirty_paths[/code], [code]enable_parallel_traversal[/code], and [code]max_parallel_workers[/code]. |
| 19 | + |
| 20 | + Returns a dictionary containing [code]scan_summary[/code], [code]metrics[/code], [code]entry_record_count[/code], [code]parsed_script_count[/code], [code]files_seen[/code], [code]dirs_seen[/code], and [code]materialized[/code] (always [code]false[/code]). |
| 21 | + </description> |
| 22 | + </method> |
| 23 | + <method name="cancel_scan"> |
| 24 | + <return type="bool" /> |
| 25 | + <param index="0" name="scan_id" type="int" /> |
| 26 | + <description> |
| 27 | + Requests cancellation for the active asynchronous scan with id [param scan_id]. Returns [code]true[/code] only when the scan is currently queued or running. |
| 28 | + </description> |
| 29 | + </method> |
| 30 | + <method name="consume_watcher_changes"> |
| 31 | + <return type="Array" /> |
| 32 | + <description> |
| 33 | + Drains pending file watcher events and returns them as an array of dictionaries. Each event includes [code]project_relative_path[/code], [code]path[/code] ([code]res://[/code] form), [code]removed[/code], and [code]is_directory[/code]. |
| 34 | + </description> |
| 35 | + </method> |
| 36 | + <method name="export_full_inventory_for_debug" qualifiers="const"> |
| 37 | + <return type="Dictionary" /> |
| 38 | + <description> |
| 39 | + Exports the entire persisted inventory for debugging. Returns [code]files[/code], [code]custom_classes[/code], [code]file_count[/code], [code]custom_class_count[/code], and [code]scan_summary[/code]. |
| 40 | + </description> |
| 41 | + </method> |
| 42 | + <method name="get_custom_class_count" qualifiers="const"> |
| 43 | + <return type="int" /> |
| 44 | + <param index="0" name="filter" type="Dictionary" /> |
| 45 | + <description> |
| 46 | + Returns the number of persisted custom class records matching [param filter]. Supported filter keys are [code]language[/code], [code]base_type[/code], and [code]search[/code]. |
| 47 | + </description> |
| 48 | + </method> |
| 49 | + <method name="get_custom_classes_page" qualifiers="const"> |
| 50 | + <return type="Array" /> |
| 51 | + <param index="0" name="offset" type="int" /> |
| 52 | + <param index="1" name="limit" type="int" /> |
| 53 | + <param index="2" name="sort" type="String" /> |
| 54 | + <param index="3" name="filter" type="Dictionary" /> |
| 55 | + <description> |
| 56 | + Returns a page of persisted custom class rows. Uses [param offset] and [param limit] for paging, forwards [param sort] to the repository sort key, and applies [param filter] keys [code]language[/code], [code]base_type[/code], and [code]search[/code]. |
| 57 | + </description> |
| 58 | + </method> |
| 59 | + <method name="get_database_absolute_path" qualifiers="const"> |
| 60 | + <return type="String" /> |
| 61 | + <description> |
| 62 | + Returns the resolved absolute filesystem path to the GoTool metadata database. |
| 63 | + </description> |
| 64 | + </method> |
| 65 | + <method name="get_database_virtual_path" qualifiers="const"> |
| 66 | + <return type="String" /> |
| 67 | + <description> |
| 68 | + Returns the virtualized database path when available ([code]user://[/code] or [code]res://[/code]), otherwise returns the absolute path string. |
| 69 | + </description> |
| 70 | + </method> |
| 71 | + <method name="get_directory_children" qualifiers="const"> |
| 72 | + <return type="Array" /> |
| 73 | + <param index="0" name="directory_id" type="int" /> |
| 74 | + <param index="1" name="offset" type="int" /> |
| 75 | + <param index="2" name="limit" type="int" /> |
| 76 | + <param index="3" name="sort" type="String" /> |
| 77 | + <param index="4" name="filter" type="Dictionary" /> |
| 78 | + <description> |
| 79 | + Returns a page of inventory rows whose parent directory is [param directory_id]. A negative [param directory_id] maps to the root level. Paging, sorting, and filter behavior are the same as [method get_files_page]. |
| 80 | + </description> |
| 81 | + </method> |
| 82 | + <method name="get_dirty_paths"> |
| 83 | + <return type="Array" /> |
| 84 | + <description> |
| 85 | + Returns [code]res://[/code] paths derived from drained watcher events. Calling this method consumes the current pending watcher event queue. |
| 86 | + </description> |
| 87 | + </method> |
| 88 | + <method name="get_file_count" qualifiers="const"> |
| 89 | + <return type="int" /> |
| 90 | + <param index="0" name="filter" type="Dictionary" /> |
| 91 | + <description> |
| 92 | + Returns the number of persisted inventory entries matching [param filter]. Supported filter keys are [code]include_deleted[/code], [code]parent_id[/code], [code]is_directory[/code], [code]extension[/code], [code]file_type[/code], [code]godot_type[/code], and [code]search[/code]. |
| 93 | + </description> |
| 94 | + </method> |
| 95 | + <method name="get_file_details" qualifiers="const"> |
| 96 | + <return type="Dictionary" /> |
| 97 | + <param index="0" name="file_id" type="int" /> |
| 98 | + <description> |
| 99 | + Returns a single persisted inventory row for [param file_id], including identifiers, path fields, file classification, timestamps, directory and hidden flags, and dirty-state metadata. Returns an empty dictionary when not found. |
| 100 | + </description> |
| 101 | + </method> |
| 102 | + <method name="get_files_page" qualifiers="const"> |
| 103 | + <return type="Array" /> |
| 104 | + <param index="0" name="offset" type="int" /> |
| 105 | + <param index="1" name="limit" type="int" /> |
| 106 | + <param index="2" name="sort" type="String" /> |
| 107 | + <param index="3" name="filter" type="Dictionary" /> |
| 108 | + <description> |
| 109 | + Returns a page of persisted inventory entries. Uses [param offset] and [param limit] for paging, forwards [param sort] to the repository sort key, and applies [param filter] keys [code]include_deleted[/code], [code]parent_id[/code], [code]is_directory[/code], [code]extension[/code], [code]file_type[/code], [code]godot_type[/code], and [code]search[/code]. |
| 110 | + </description> |
| 111 | + </method> |
| 112 | + <method name="get_last_error" qualifiers="const"> |
| 113 | + <return type="String" /> |
| 114 | + <description> |
| 115 | + Returns the latest error message produced by this context, or an empty string when no error is recorded. |
| 116 | + </description> |
| 117 | + </method> |
| 118 | + <method name="get_last_scan_results" qualifiers="const"> |
| 119 | + <return type="Dictionary" /> |
| 120 | + <description> |
| 121 | + Returns the latest completed scan summary dictionary, including status and metrics when available. |
| 122 | + </description> |
| 123 | + </method> |
| 124 | + <method name="get_project_summary" qualifiers="const"> |
| 125 | + <return type="Dictionary" /> |
| 126 | + <param index="0" name="project_id" type="int" /> |
| 127 | + <description> |
| 128 | + Returns summary data for [param project_id], including project identity details and aggregate counts for files, autoloads, custom classes, and unknown entries. |
| 129 | + </description> |
| 130 | + </method> |
| 131 | + <method name="get_scan_metrics" qualifiers="const"> |
| 132 | + <return type="Dictionary" /> |
| 133 | + <param index="0" name="scan_id" type="int" /> |
| 134 | + <description> |
| 135 | + Returns detailed metrics for [param scan_id]. The dictionary includes timing breakdowns, counters, and status fields such as [code]scan_id[/code], [code]scan_run_id[/code], and [code]status[/code]. |
| 136 | + </description> |
| 137 | + </method> |
| 138 | + <method name="get_scan_status" qualifiers="const"> |
| 139 | + <return type="Dictionary" /> |
| 140 | + <param index="0" name="scan_id" type="int" /> |
| 141 | + <description> |
| 142 | + Returns status information for [param scan_id]. For active scans, includes live summary fields, [code]started_at_unix[/code], [code]finished_at_unix[/code], [code]last_error[/code], and [code]metrics[/code]. For completed persisted scans, returns stored status and metrics. |
| 143 | + </description> |
| 144 | + </method> |
| 145 | + <method name="get_watcher_status" qualifiers="const"> |
| 146 | + <return type="Dictionary" /> |
| 147 | + <description> |
| 148 | + Returns watcher runtime state. The dictionary includes [code]running[/code], [code]supported[/code], [code]requires_full_rescan[/code], [code]backend[/code], [code]pending_events[/code], and optional [code]last_error[/code]. |
| 149 | + </description> |
| 150 | + </method> |
| 151 | + <method name="initialize_database"> |
| 152 | + <return type="bool" /> |
| 153 | + <description> |
| 154 | + Initializes the GoTool metadata database under the OS data directory, creates required schema tables, registers the current project, and resolves database path fields. Returns [code]true[/code] on success. |
| 155 | + </description> |
| 156 | + </method> |
| 157 | + <method name="list_projects" qualifiers="const"> |
| 158 | + <return type="Array" /> |
| 159 | + <description> |
| 160 | + Returns all registered projects as dictionaries with identity, display name, root paths, Godot version, and first/last seen timestamps. |
| 161 | + </description> |
| 162 | + </method> |
| 163 | + <method name="register_current_project"> |
| 164 | + <return type="int" /> |
| 165 | + <description> |
| 166 | + Registers or refreshes the current [code]res://[/code] project in the database and returns its project id. The method reads or creates [code].godot/gotool_center/project.uid[/code], falling back to a path-derived identity when UID persistence is unavailable. |
| 167 | + </description> |
| 168 | + </method> |
| 169 | + <method name="scan_current_project"> |
| 170 | + <return type="bool" /> |
| 171 | + <description> |
| 172 | + Starts a persisted asynchronous scan with default options and blocks until that scan completes or fails. Returns [code]true[/code] only when the scan finishes with [code]completed[/code] status. |
| 173 | + </description> |
| 174 | + </method> |
| 175 | + <method name="scan_current_project_fast"> |
| 176 | + <return type="Dictionary" /> |
| 177 | + <param index="0" name="options" type="Dictionary" /> |
| 178 | + <description> |
| 179 | + Alias for [method scan_project_inventory_fast]. |
| 180 | + </description> |
| 181 | + </method> |
| 182 | + <method name="scan_project"> |
| 183 | + <return type="bool" /> |
| 184 | + <description> |
| 185 | + Alias for [method scan_current_project]. |
| 186 | + </description> |
| 187 | + </method> |
| 188 | + <method name="scan_project_inventory_fast"> |
| 189 | + <return type="Dictionary" /> |
| 190 | + <param index="0" name="options" type="Dictionary" /> |
| 191 | + <description> |
| 192 | + Runs a detailed non-persisted inventory scan and returns materialized results. The [param options] dictionary supports [code]include_hidden[/code], [code]include_custom_classes[/code], [code]materialize_files[/code], [code]materialize_custom_classes[/code], [code]include_autoloads[/code], [code]force_rescan[/code], [code]load_existing_snapshot[/code], [code]use_dirty_path_filter[/code], [code]dirty_paths[/code], [code]enable_parallel_traversal[/code], [code]max_parallel_workers[/code], and [code]max_results[/code]. |
| 193 | + |
| 194 | + Returns [code]files[/code], [code]autoloads[/code], [code]custom_classes[/code], [code]entry_record_count[/code], [code]custom_class_count[/code], [code]autoload_count[/code], [code]metrics[/code], and [code]scan_summary[/code]. |
| 195 | + </description> |
| 196 | + </method> |
| 197 | + <method name="start_scan"> |
| 198 | + <return type="Dictionary" /> |
| 199 | + <param index="0" name="options" type="Dictionary" /> |
| 200 | + <description> |
| 201 | + Starts an asynchronous persisted scan and returns immediate scan metadata. The [param options] dictionary supports [code]include_hidden[/code], [code]force_rescan[/code], [code]include_custom_classes[/code], [code]include_deleted[/code], [code]load_existing_snapshot[/code], [code]prefer_watcher_dirty_paths[/code], [code]dirty_paths[/code], [code]enable_parallel_traversal[/code], and [code]max_parallel_workers[/code]. |
| 202 | + |
| 203 | + On success, returns [code]scan_id[/code], [code]scan_run_id[/code], [code]scan_generation[/code], [code]status[/code], and [code]started_at_unix[/code]. If another scan is already active, returns [code]status = "already_running"[/code] with the active scan identifiers. |
| 204 | + </description> |
| 205 | + </method> |
| 206 | + <method name="start_watcher"> |
| 207 | + <return type="bool" /> |
| 208 | + <description> |
| 209 | + Starts the project file watcher for the current project root. Returns [code]true[/code] when watcher startup succeeds. |
| 210 | + </description> |
| 211 | + </method> |
| 212 | + <method name="stop_watcher"> |
| 213 | + <return type="void" /> |
| 214 | + <description> |
| 215 | + Stops the project file watcher if it is active. |
| 216 | + </description> |
| 217 | + </method> |
| 218 | + </methods> |
| 219 | +</class> |
0 commit comments