gdharness 1.3.7 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.js +999 -864
- package/build/godot/addons/gdharness_editor/file_reads.gd +13 -0
- package/build/godot/addons/gdharness_editor/reading.gd +61 -5
- package/build/godot/addons/gdharness_editor/scene_file.gd +41 -35
- package/build/godot/addons/gdharness_editor/serialisation.gd +8 -7
- package/build/godot/addons/gdharness_editor/tool_executor.gd +12 -2
- package/build/godot/addons/gdharness_editor/tools/animation_states.gd +244 -0
- package/build/godot/addons/gdharness_editor/tools/animation_states.gd.uid +1 -0
- package/build/godot/addons/gdharness_editor/tools/animation_tools.gd +105 -157
- package/build/godot/addons/gdharness_editor/tools/resource_tools.gd +25 -1
- package/build/godot/addons/gdharness_editor/tools/scene_kin.gd +4 -1
- package/build/godot/addons/gdharness_editor/tools/scene_placing.gd +10 -0
- package/build/godot/addons/gdharness_editor/tools/scene_tools.gd +72 -3
- package/build/godot/addons/gdharness_editor/tools/signal_tools.gd +7 -1
- package/build/godot/addons/gdharness_runtime/call_errors.gd +8 -2
- package/build/godot/addons/gdharness_runtime/reading.gd +61 -5
- package/build/godot/addons/gdharness_runtime/runtime_capture.gd +5 -0
- package/build/godot/addons/gdharness_runtime/runtime_changes.gd +6 -1
- package/build/godot/addons/gdharness_runtime/runtime_input.gd +74 -54
- package/build/godot/addons/gdharness_runtime/runtime_paths.gd +38 -6
- package/build/godot/addons/gdharness_runtime/runtime_queries.gd +2 -0
- package/build/godot/addons/gdharness_runtime/runtime_targets.gd +26 -0
- package/build/godot/addons/gdharness_runtime/runtime_values.gd +105 -6
- package/build/godot/addons/gdharness_runtime/serialisation.gd +8 -7
- package/build/godot/operations/dependencies.gd +61 -10
- package/build/godot/operations/editor_tools.gd +8 -0
- package/build/godot/operations/file_reads.gd +13 -0
- package/build/godot/operations/gdscript_analysis.gd +76 -6
- package/build/godot/operations/gdscript_authoring.gd +5 -2
- package/build/godot/operations/godot_operations.gd +4 -0
- package/build/godot/operations/import_pipeline.gd +45 -1
- package/build/godot/operations/input_actions.gd +22 -7
- package/build/godot/operations/project_config.gd +31 -0
- package/build/godot/operations/project_diagnostics.gd +6 -5
- package/build/godot/operations/reading.gd +61 -5
- package/build/godot/operations/serialisation.gd +8 -7
- package/build/keeper.js +44 -13
- package/package.json +1 -1
|
@@ -168,6 +168,16 @@ func find_resource_usages(params: Dictionary) -> Dictionary:
|
|
|
168
168
|
var by_class: RegEx = null
|
|
169
169
|
if not class_name_declared.is_empty():
|
|
170
170
|
by_class = GdhPatterns.compiled("\\b" + _regex_escaped(class_name_declared) + "\\b")
|
|
171
|
+
# The script of an autoload is used wherever code names the autoload, and asked what uses it,
|
|
172
|
+
# the answer was its line in project.godot alone, beside the scripts calling it.
|
|
173
|
+
var autoload_named: String = ""
|
|
174
|
+
var autoloads: Dictionary = autoloads_declared()
|
|
175
|
+
for name: String in autoloads:
|
|
176
|
+
if str(autoloads[name]) == resource_path:
|
|
177
|
+
autoload_named = name
|
|
178
|
+
var by_autoload: RegEx = null
|
|
179
|
+
if not autoload_named.is_empty():
|
|
180
|
+
by_autoload = GdhPatterns.compiled("\\b" + _regex_escaped(autoload_named) + "\\b")
|
|
171
181
|
var target: Dictionary = {
|
|
172
182
|
"path": resource_path,
|
|
173
183
|
"uid": str(GdhResourceFiles.uid_of(resource_path).get("uid", "")) if exists else ""
|
|
@@ -203,7 +213,12 @@ func find_resource_usages(params: Dictionary) -> Dictionary:
|
|
|
203
213
|
# Strings are text, so a class named in one is not a use of it.
|
|
204
214
|
by_its_name = by_class.search(_code_of(line)) != null
|
|
205
215
|
name_in_comment = not by_its_name and by_class.search(_comment_of(line)) != null
|
|
206
|
-
|
|
216
|
+
var by_its_autoload: bool = false
|
|
217
|
+
if not by_its_path and not by_its_name and code and by_autoload != null:
|
|
218
|
+
by_its_autoload = by_autoload.search(_code_of(line)) != null
|
|
219
|
+
if not by_its_autoload and not name_in_comment:
|
|
220
|
+
name_in_comment = by_autoload.search(_comment_of(line)) != null
|
|
221
|
+
if not by_its_path and not by_its_name and not by_its_autoload and not name_in_comment:
|
|
207
222
|
continue
|
|
208
223
|
var trimmed: String = line.strip_edges()
|
|
209
224
|
var kind: String = ""
|
|
@@ -219,6 +234,8 @@ func find_resource_usages(params: Dictionary) -> Dictionary:
|
|
|
219
234
|
kind = "comment"
|
|
220
235
|
elif by_its_path:
|
|
221
236
|
kind = _path_reference_kind(line, file_path)
|
|
237
|
+
elif by_its_autoload:
|
|
238
|
+
kind = "autoload"
|
|
222
239
|
else:
|
|
223
240
|
kind = (
|
|
224
241
|
"extends"
|
|
@@ -244,7 +261,7 @@ func find_resource_usages(params: Dictionary) -> Dictionary:
|
|
|
244
261
|
var declared: Variant = null
|
|
245
262
|
if not class_name_declared.is_empty():
|
|
246
263
|
declared = class_name_declared
|
|
247
|
-
|
|
264
|
+
var answer: Dictionary = {
|
|
248
265
|
"resource_path": resource_path,
|
|
249
266
|
"exists": exists,
|
|
250
267
|
"class_name": declared,
|
|
@@ -260,6 +277,9 @@ func find_resource_usages(params: Dictionary) -> Dictionary:
|
|
|
260
277
|
"by_kind": by_kind,
|
|
261
278
|
},
|
|
262
279
|
}
|
|
280
|
+
if not autoload_named.is_empty():
|
|
281
|
+
answer["autoload"] = autoload_named
|
|
282
|
+
return answer
|
|
263
283
|
|
|
264
284
|
|
|
265
285
|
# The class_name a script declares, or empty for a scene, a resource or a script without one.
|
|
@@ -477,15 +497,19 @@ func _analyze_resource(path: String, current_depth: int, walk: GdhDependencyWalk
|
|
|
477
497
|
if not walk.include_built_in and dep_path.begins_with("res://."):
|
|
478
498
|
continue
|
|
479
499
|
|
|
480
|
-
_depend(deps, path, dep_path,
|
|
500
|
+
_depend(deps, path, dep_path, {}, current_depth, walk)
|
|
481
501
|
|
|
482
502
|
# A script uses another by its class_name as surely as by a preload, and only the reverse walk
|
|
483
503
|
# looked for that: asked what a script depends on, the answer left out the script it typed a
|
|
484
|
-
# variable with, while asking what used that script named this one.
|
|
504
|
+
# variable with, while asking what used that script named this one. An autoload's global
|
|
505
|
+
# name is the same kind of use, of the script registered under it.
|
|
485
506
|
if path.get_extension() == "gd":
|
|
486
507
|
var classes: Dictionary = classes_declared()
|
|
487
508
|
for used: String in classes_used_in(content, classes):
|
|
488
|
-
_depend(deps, path, str(classes[used]), used, current_depth, walk)
|
|
509
|
+
_depend(deps, path, str(classes[used]), {"by_class": used}, current_depth, walk)
|
|
510
|
+
var autoloads: Dictionary = autoloads_declared()
|
|
511
|
+
for used: String in classes_used_in(content, autoloads):
|
|
512
|
+
_depend(deps, path, str(autoloads[used]), {"by_autoload": used}, current_depth, walk)
|
|
489
513
|
|
|
490
514
|
walk.path_stack.pop_back()
|
|
491
515
|
walk.visited[path] = {"deps": deps, "remaining": remaining}
|
|
@@ -493,13 +517,13 @@ func _analyze_resource(path: String, current_depth: int, walk: GdhDependencyWalk
|
|
|
493
517
|
|
|
494
518
|
|
|
495
519
|
# Adds [param dep_path] to [param deps], what [param path] depends on, walked as far as the depth left
|
|
496
|
-
# allows, once however many times it is named. [param
|
|
497
|
-
# or empty for a path.
|
|
520
|
+
# allows, once however many times it is named. [param named_by] is the class or autoload name it was
|
|
521
|
+
# named by, as by_class or by_autoload, or empty for a path.
|
|
498
522
|
func _depend(
|
|
499
523
|
deps: Array[Dictionary],
|
|
500
524
|
path: String,
|
|
501
525
|
dep_path: String,
|
|
502
|
-
|
|
526
|
+
named_by: Dictionary,
|
|
503
527
|
current_depth: int,
|
|
504
528
|
walk: GdhDependencyWalk
|
|
505
529
|
) -> void:
|
|
@@ -509,8 +533,7 @@ func _depend(
|
|
|
509
533
|
if existing.get("path", "") == dep_path:
|
|
510
534
|
return
|
|
511
535
|
var dep_info: Dictionary = {"path": dep_path, "exists": FileAccess.file_exists(dep_path)}
|
|
512
|
-
|
|
513
|
-
dep_info["by_class"] = by_class
|
|
536
|
+
dep_info.merge(named_by)
|
|
514
537
|
if dep_info["exists"] and current_depth + 1 < walk.max_depth:
|
|
515
538
|
var sub_deps: Array[Dictionary] = _analyze_resource(dep_path, current_depth + 1, walk)
|
|
516
539
|
if sub_deps.size() > 0:
|
|
@@ -518,6 +541,22 @@ func _depend(
|
|
|
518
541
|
deps.append(dep_info)
|
|
519
542
|
|
|
520
543
|
|
|
544
|
+
## Every autoload the project registers as a global name, with its script. One that is not global
|
|
545
|
+
## is no name code can use.
|
|
546
|
+
static func autoloads_declared() -> Dictionary:
|
|
547
|
+
var autoloads: Dictionary = {}
|
|
548
|
+
for property: Dictionary in ProjectSettings.get_property_list():
|
|
549
|
+
var setting: String = str(property.get("name", ""))
|
|
550
|
+
if not setting.begins_with("autoload/"):
|
|
551
|
+
continue
|
|
552
|
+
var value: String = str(ProjectSettings.get_setting(setting))
|
|
553
|
+
if value.begins_with("*"):
|
|
554
|
+
autoloads[setting.trim_prefix("autoload/")] = _resolved(
|
|
555
|
+
value.trim_prefix("*"), "res://project.godot"
|
|
556
|
+
)
|
|
557
|
+
return autoloads
|
|
558
|
+
|
|
559
|
+
|
|
521
560
|
## Every class_name the project's scripts declare, with the script declaring it.
|
|
522
561
|
func classes_declared() -> Dictionary:
|
|
523
562
|
if _classes_read:
|
|
@@ -530,6 +569,18 @@ func classes_declared() -> Dictionary:
|
|
|
530
569
|
return _classes_declared
|
|
531
570
|
|
|
532
571
|
|
|
572
|
+
## Every class the project's scripts declare with class_name, sorted by name, with the script
|
|
573
|
+
## declaring it. Read from the files rather than the class cache, which only a scan rewrites.
|
|
574
|
+
func list_script_classes(_params: Dictionary) -> Dictionary:
|
|
575
|
+
var declared: Dictionary = classes_declared()
|
|
576
|
+
var names: Array = declared.keys()
|
|
577
|
+
names.sort()
|
|
578
|
+
var classes: Array[Dictionary] = []
|
|
579
|
+
for name: Variant in names:
|
|
580
|
+
classes.append({"name": str(name), "path": str(declared[name])})
|
|
581
|
+
return {"classes": classes, "count": classes.size()}
|
|
582
|
+
|
|
583
|
+
|
|
533
584
|
## The names in [param classes] that the code in [param content] uses, in the order first used: words
|
|
534
585
|
## outside strings and comments, so a class named in prose or in a message is not a use of it.
|
|
535
586
|
static func classes_used_in(content: String, classes: Dictionary) -> Array[String]:
|
|
@@ -7,6 +7,7 @@ extends RefCounted
|
|
|
7
7
|
## made here passes the same checks and answers in the same shape. What the engine does that an
|
|
8
8
|
## editor does not, running every script, is put back in scene_file.gd and headless_check.gd.
|
|
9
9
|
|
|
10
|
+
const GdhAnimationStates = preload("../addons/gdharness_editor/tools/animation_states.gd")
|
|
10
11
|
const GdhAnimationTools = preload("../addons/gdharness_editor/tools/animation_tools.gd")
|
|
11
12
|
const GdhResourceTools = preload("../addons/gdharness_editor/tools/resource_tools.gd")
|
|
12
13
|
const GdhSceneTools = preload("../addons/gdharness_editor/tools/scene_tools.gd")
|
|
@@ -36,11 +37,16 @@ const RESOURCE_COMMANDS: Array[String] = [
|
|
|
36
37
|
const ANIMATION_COMMANDS: Array[String] = [
|
|
37
38
|
"create_animation",
|
|
38
39
|
"add_animation_track",
|
|
40
|
+
"remove_animation_track",
|
|
39
41
|
"set_animation",
|
|
40
42
|
"rename_animation",
|
|
41
43
|
"remove_animation",
|
|
44
|
+
]
|
|
45
|
+
const ANIMATION_STATE_COMMANDS: Array[String] = [
|
|
42
46
|
"add_animation_state",
|
|
43
47
|
"connect_animation_states",
|
|
48
|
+
"remove_animation_state",
|
|
49
|
+
"disconnect_animation_states",
|
|
44
50
|
]
|
|
45
51
|
|
|
46
52
|
|
|
@@ -60,6 +66,8 @@ static func run(params: Dictionary) -> Dictionary:
|
|
|
60
66
|
tools = GdhResourceTools.new()
|
|
61
67
|
elif command in ANIMATION_COMMANDS:
|
|
62
68
|
tools = GdhAnimationTools.new()
|
|
69
|
+
elif command in ANIMATION_STATE_COMMANDS:
|
|
70
|
+
tools = GdhAnimationStates.new()
|
|
63
71
|
else:
|
|
64
72
|
return {"ok": false, "error": "No editor tool runs headless as " + command}
|
|
65
73
|
var answer: Variant = tools.call(command, arguments)
|
|
@@ -119,6 +119,9 @@ static func _laid(scene_path: String) -> Dictionary:
|
|
|
119
119
|
return {"ok": false, "error": refused}
|
|
120
120
|
if not nodes.has("."):
|
|
121
121
|
return {"ok": false, "error": "%s holds no nodes" % scene_path}
|
|
122
|
+
var base: SceneState = packed.get_state().get_base_scene_state()
|
|
123
|
+
if base != null:
|
|
124
|
+
nodes["."]["inherits"] = base.get_path()
|
|
122
125
|
return {"ok": true, "nodes": nodes}
|
|
123
126
|
|
|
124
127
|
|
|
@@ -175,6 +178,10 @@ static func _lay(
|
|
|
175
178
|
nodes[path] = _made(str(state.get_node_type(index)))
|
|
176
179
|
if ids[index] >= 0:
|
|
177
180
|
nodes[path]["uniqueId"] = ids[index]
|
|
181
|
+
# Laid at the root with no scene handed in is a scene the one being read inherits, and the
|
|
182
|
+
# deepest is laid first, so this is the file that makes the node.
|
|
183
|
+
if prefix == "." and loaded == null:
|
|
184
|
+
nodes[path]["inheritedFrom"] = state.get_path()
|
|
178
185
|
# The name is the state's even for an entry laid already, since an inherited scene names its
|
|
179
186
|
# root itself; a root instanced inside another scene is renamed by that scene once laid.
|
|
180
187
|
if not recovered:
|
|
@@ -324,6 +331,12 @@ static func _entry(
|
|
|
324
331
|
data["instanceOf"] = node["instanceOf"]
|
|
325
332
|
if node.has("editableChildren"):
|
|
326
333
|
data["editableChildren"] = node["editableChildren"]
|
|
334
|
+
# An inherited scene's file holds only what it changes, so the read says what it inherits and
|
|
335
|
+
# which nodes come from there, as the editor greys them.
|
|
336
|
+
if node.has("inherits"):
|
|
337
|
+
data["inherits"] = node["inherits"]
|
|
338
|
+
elif node.has("inheritedFrom"):
|
|
339
|
+
data["inheritedFrom"] = node["inheritedFrom"]
|
|
327
340
|
var groups: Array[String] = node["groups"]
|
|
328
341
|
if not groups.is_empty():
|
|
329
342
|
var sorted: Array[String] = groups.duplicate()
|
|
@@ -23,6 +23,8 @@ class GdhMembers:
|
|
|
23
23
|
var constants: Array[Dictionary] = []
|
|
24
24
|
var enums: Array[Dictionary] = []
|
|
25
25
|
var inner_classes: Array[Dictionary] = []
|
|
26
|
+
## The `##` comment the class is documented with, empty when it has none.
|
|
27
|
+
var doc: String = ""
|
|
26
28
|
## The index of the last line the body holds.
|
|
27
29
|
var last: int = -1
|
|
28
30
|
## An inner class's name and the line its `class` is on.
|
|
@@ -43,6 +45,22 @@ class GdhMembers:
|
|
|
43
45
|
"inner_classes": inner_classes,
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
## Whether a member is declared yet, past which a `##` block no longer documents the class.
|
|
49
|
+
func declares_members() -> bool:
|
|
50
|
+
return not (
|
|
51
|
+
signals.is_empty()
|
|
52
|
+
and variables.is_empty()
|
|
53
|
+
and functions.is_empty()
|
|
54
|
+
and constants.is_empty()
|
|
55
|
+
and enums.is_empty()
|
|
56
|
+
and inner_classes.is_empty()
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
## [param lines] as the class's documentation, when it has none yet.
|
|
60
|
+
func take_doc(lines: Array[String]) -> void:
|
|
61
|
+
if doc.is_empty() and not lines.is_empty():
|
|
62
|
+
doc = "\n".join(PackedStringArray(lines))
|
|
63
|
+
|
|
46
64
|
|
|
47
65
|
func _init(p_log: GdhLog) -> void:
|
|
48
66
|
_log = p_log
|
|
@@ -58,6 +76,9 @@ func get_gdscript_info(params: Dictionary) -> Dictionary:
|
|
|
58
76
|
if not full_script_path.begins_with("res://"):
|
|
59
77
|
full_script_path = "res://" + full_script_path
|
|
60
78
|
|
|
79
|
+
# Read as GDScript, a scene came back as a script extending RefCounted with nothing in it.
|
|
80
|
+
if full_script_path.get_extension().to_lower() != "gd":
|
|
81
|
+
return _log.failure(_not_a_script(full_script_path))
|
|
61
82
|
if not FileAccess.file_exists(full_script_path):
|
|
62
83
|
return _log.failure(
|
|
63
84
|
GdhFileWalk.new().with_nearest_files(
|
|
@@ -130,6 +151,8 @@ func get_gdscript_info(params: Dictionary) -> Dictionary:
|
|
|
130
151
|
"autoloads_used": autoloads_used,
|
|
131
152
|
"line_count": lines.size() - 1 if content.is_empty() or content.ends_with("\n") else lines.size()
|
|
132
153
|
}
|
|
154
|
+
if not own.doc.is_empty():
|
|
155
|
+
answer["class_doc"] = own.doc
|
|
133
156
|
if GdhRead.as_bool(params.get("include_inherited", false)):
|
|
134
157
|
_add_inherited(answer, [full_script_path])
|
|
135
158
|
return answer
|
|
@@ -143,6 +166,7 @@ func _members(
|
|
|
143
166
|
) -> GdhMembers:
|
|
144
167
|
var own: GdhMembers = GdhMembers.new()
|
|
145
168
|
var in_multiline_string: bool = false
|
|
169
|
+
var doc: Array[String] = []
|
|
146
170
|
|
|
147
171
|
var i: int = first - 1
|
|
148
172
|
while i + 1 < lines.size():
|
|
@@ -158,9 +182,25 @@ func _members(
|
|
|
158
182
|
if _triple_quotes(raw) % 2 == 1:
|
|
159
183
|
in_multiline_string = false
|
|
160
184
|
continue
|
|
185
|
+
# A `##` block documents what it sits directly above: the class when that is its class_name
|
|
186
|
+
# or extends line, or when a blank line follows it before any member, and otherwise the next
|
|
187
|
+
# member. One at a shallower indent is the outer body's, for what follows this inner class.
|
|
188
|
+
var trimmed: String = raw.strip_edges()
|
|
189
|
+
if trimmed.begins_with("##"):
|
|
190
|
+
if not raw.begins_with(margin):
|
|
191
|
+
own.last = i - 1
|
|
192
|
+
return own
|
|
193
|
+
if _indentation(raw).length() <= margin.length():
|
|
194
|
+
var said: String = trimmed.substr(2)
|
|
195
|
+
doc.append(said.substr(1) if said.begins_with(" ") else said)
|
|
196
|
+
continue
|
|
161
197
|
var stripped: String = GdhPatterns.without_comment(raw)
|
|
162
198
|
|
|
163
199
|
if stripped.is_empty():
|
|
200
|
+
if trimmed.is_empty() and not doc.is_empty():
|
|
201
|
+
if not own.declares_members():
|
|
202
|
+
own.take_doc(doc)
|
|
203
|
+
doc.clear()
|
|
164
204
|
continue
|
|
165
205
|
|
|
166
206
|
# A line back at a shallower indent closes an inner class's body, and is the outer body's
|
|
@@ -210,6 +250,7 @@ func _members(
|
|
|
210
250
|
stripped = (stripped + " " + GdhPatterns.without_comment(lines[i])).strip_edges()
|
|
211
251
|
header = GdhPatterns.without_annotations(stripped)
|
|
212
252
|
var declaration: RegExMatch = GdhPatterns.declared_class(header)
|
|
253
|
+
var entry: Dictionary = {}
|
|
213
254
|
if declaration != null:
|
|
214
255
|
own.declared_class_name = declaration.get_string(1)
|
|
215
256
|
# `class_name X extends Y` is also one line, and taking the rest of it as the name
|
|
@@ -217,29 +258,47 @@ func _members(
|
|
|
217
258
|
# `RefCounted`: the name unusable and the base flatly wrong.
|
|
218
259
|
if not declaration.get_string(2).is_empty():
|
|
219
260
|
own.extends_name = declaration.get_string(2)
|
|
261
|
+
own.take_doc(doc)
|
|
220
262
|
elif header.begins_with("extends "):
|
|
221
263
|
own.extends_name = header.substr(8).strip_edges()
|
|
264
|
+
own.take_doc(doc)
|
|
222
265
|
elif header.begins_with("signal "):
|
|
223
266
|
# `at`, not `i`: a wrapped declaration starts where it starts, and `i` is now sitting on
|
|
224
267
|
# the line that closed it.
|
|
225
|
-
|
|
268
|
+
entry = _parse_signal(header, at + 1)
|
|
269
|
+
own.signals.append(entry)
|
|
226
270
|
elif header.begins_with("const "):
|
|
227
|
-
|
|
271
|
+
entry = _parse_constant(header, at + 1)
|
|
272
|
+
own.constants.append(entry)
|
|
228
273
|
elif header.begins_with("enum "):
|
|
229
|
-
|
|
274
|
+
entry = _parse_enum(header, at + 1)
|
|
275
|
+
own.enums.append(entry)
|
|
230
276
|
elif header.begins_with("var ") or header.begins_with("static var "):
|
|
231
277
|
# The whole line here, not the header: which annotations a variable carries is the
|
|
232
278
|
# answer rather than noise in front of it, and `@export_range(0, 1)` is the hint.
|
|
233
|
-
|
|
279
|
+
entry = _parse_variable(stripped, at + 1)
|
|
280
|
+
own.variables.append(entry)
|
|
234
281
|
elif header.begins_with("func ") or header.begins_with("static func "):
|
|
235
|
-
|
|
282
|
+
entry = _parse_function(header, at + 1, stripped)
|
|
283
|
+
own.functions.append(entry)
|
|
236
284
|
elif header.begins_with("class "):
|
|
237
285
|
_collect_dependencies(stripped, dependencies)
|
|
238
286
|
var inner: GdhMembers = _inner_class(lines, i, margin, header, dependencies)
|
|
239
|
-
|
|
287
|
+
entry = inner.as_inner()
|
|
288
|
+
if not doc.is_empty():
|
|
289
|
+
entry["doc"] = "\n".join(PackedStringArray(doc))
|
|
290
|
+
doc.clear()
|
|
291
|
+
own.inner_classes.append(entry)
|
|
240
292
|
i = inner.last
|
|
241
293
|
continue
|
|
242
294
|
|
|
295
|
+
if not entry.is_empty() and not doc.is_empty():
|
|
296
|
+
entry["doc"] = "\n".join(PackedStringArray(doc))
|
|
297
|
+
# A line of annotations alone, `@tool` or `@export` above its variable, is between a comment
|
|
298
|
+
# and what it documents rather than after it.
|
|
299
|
+
if not header.is_empty():
|
|
300
|
+
doc.clear()
|
|
301
|
+
|
|
243
302
|
_collect_dependencies(stripped, dependencies)
|
|
244
303
|
|
|
245
304
|
own.last = lines.size() - 1
|
|
@@ -278,6 +337,17 @@ func _inner_class(
|
|
|
278
337
|
return body
|
|
279
338
|
|
|
280
339
|
|
|
340
|
+
## The refusal for [param path], which is not a .gd file, with the tool that reads what it is.
|
|
341
|
+
static func _not_a_script(path: String) -> String:
|
|
342
|
+
var said: String = "%s is not a GDScript file, and script_info reads .gd files only" % path
|
|
343
|
+
match path.get_extension().to_lower():
|
|
344
|
+
"tscn", "scn":
|
|
345
|
+
return said + ": scene_tree reads a scene's nodes, and with properties the script each carries."
|
|
346
|
+
"tres", "res":
|
|
347
|
+
return said + ": resource_edit read reads a resource."
|
|
348
|
+
return said + "."
|
|
349
|
+
|
|
350
|
+
|
|
281
351
|
static func _indentation(line: String) -> String:
|
|
282
352
|
return line.substr(0, line.length() - line.strip_edges(true, false).length())
|
|
283
353
|
|
|
@@ -196,7 +196,10 @@ func modify_gdscript(params: Dictionary) -> Dictionary:
|
|
|
196
196
|
if not problems.is_empty():
|
|
197
197
|
var refusal: String = "Nothing was changed: " + "; ".join(problems)
|
|
198
198
|
if _redeclares(modifications, declared):
|
|
199
|
-
refusal +=
|
|
199
|
+
refusal += (
|
|
200
|
+
". modify only adds members; to change one the script declares already,"
|
|
201
|
+
+ " edit its lines in the file"
|
|
202
|
+
)
|
|
200
203
|
return _log.failure(refusal)
|
|
201
204
|
# Each placed line as a zero-based index that moves down whenever a later insertion lands above
|
|
202
205
|
# it, so the numbers answered are where the lines are in the file written, not where each went
|
|
@@ -256,7 +259,7 @@ func modify_gdscript(params: Dictionary) -> Dictionary:
|
|
|
256
259
|
)
|
|
257
260
|
return _log.failure(
|
|
258
261
|
(
|
|
259
|
-
"Nothing was changed: %s parses
|
|
262
|
+
"Nothing was changed: %s parses now, and would not with these additions: %s"
|
|
260
263
|
% [script_path, _reasons(caught.raised, full_script_path)]
|
|
261
264
|
)
|
|
262
265
|
)
|
|
@@ -237,6 +237,8 @@ func _run(operation: String, params: Dictionary) -> Dictionary:
|
|
|
237
237
|
payload = GdhDependencies.new(_log).get_dependencies(params)
|
|
238
238
|
"find_resource_usages":
|
|
239
239
|
payload = GdhDependencies.new(_log).find_resource_usages(params)
|
|
240
|
+
"list_script_classes":
|
|
241
|
+
payload = GdhDependencies.new(_log).list_script_classes(params)
|
|
240
242
|
"get_project_health":
|
|
241
243
|
payload = GdhProjectDiagnostics.new(_log).get_project_health(params)
|
|
242
244
|
|
|
@@ -245,6 +247,8 @@ func _run(operation: String, params: Dictionary) -> Dictionary:
|
|
|
245
247
|
payload = GdhProjectConfig.new(_log).get_project_setting(params)
|
|
246
248
|
"set_project_setting":
|
|
247
249
|
payload = GdhProjectConfig.new(_log).set_project_setting(params)
|
|
250
|
+
"unset_project_setting":
|
|
251
|
+
payload = GdhProjectConfig.new(_log).unset_project_setting(params)
|
|
248
252
|
"add_autoload":
|
|
249
253
|
payload = GdhProjectConfig.new(_log).add_autoload(params)
|
|
250
254
|
"remove_autoload":
|
|
@@ -227,6 +227,7 @@ func set_import_options(params: Dictionary) -> Dictionary:
|
|
|
227
227
|
# One already holding the value given changes nothing, and listing it as updated said it had.
|
|
228
228
|
var updated_keys: Array[String] = []
|
|
229
229
|
var unchanged_keys: Array[String] = []
|
|
230
|
+
var changes: Dictionary = {}
|
|
230
231
|
for name: String in fitted_values:
|
|
231
232
|
var held: Variant = config.get_value("params", name, null)
|
|
232
233
|
var value: Variant = fitted_values[name]
|
|
@@ -235,6 +236,10 @@ func set_import_options(params: Dictionary) -> Dictionary:
|
|
|
235
236
|
continue
|
|
236
237
|
config.set_value("params", name, value)
|
|
237
238
|
updated_keys.append(name)
|
|
239
|
+
changes[name] = {
|
|
240
|
+
"was": null if held == null else _values.serialize_value(held),
|
|
241
|
+
"now": _values.serialize_value(value),
|
|
242
|
+
}
|
|
238
243
|
_log.debug("Set " + name + " = " + str(value))
|
|
239
244
|
|
|
240
245
|
if not updated_keys.is_empty():
|
|
@@ -244,6 +249,8 @@ func set_import_options(params: Dictionary) -> Dictionary:
|
|
|
244
249
|
|
|
245
250
|
# The reimport that applies them is the server's, through the editor or the engine's import.
|
|
246
251
|
var answer: Dictionary = {"resource_path": resource_path, "updated_options": updated_keys}
|
|
252
|
+
if not changes.is_empty():
|
|
253
|
+
answer["changed"] = changes
|
|
247
254
|
if not unchanged_keys.is_empty():
|
|
248
255
|
answer["unchanged_options"] = unchanged_keys
|
|
249
256
|
return answer
|
|
@@ -387,6 +394,25 @@ func validate_project(params: Dictionary) -> Dictionary:
|
|
|
387
394
|
)
|
|
388
395
|
)
|
|
389
396
|
|
|
397
|
+
# A file never imported is on disk, so the reference checks pass it, and still nothing loads it:
|
|
398
|
+
# a scene using one fails to load in a run or an export.
|
|
399
|
+
checks_performed.append("imports")
|
|
400
|
+
var never: Array[String] = []
|
|
401
|
+
for path: String in _files.find_files_with_extensions("res://", IMPORTABLE_EXTENSIONS):
|
|
402
|
+
if not FileAccess.file_exists(path + ".import"):
|
|
403
|
+
never.append(path)
|
|
404
|
+
if not never.is_empty():
|
|
405
|
+
never.sort()
|
|
406
|
+
warnings.append(
|
|
407
|
+
_finding(
|
|
408
|
+
"warning",
|
|
409
|
+
"imports",
|
|
410
|
+
never_imported_line(never),
|
|
411
|
+
"Run project_import reimport, or open the project in the editor, whose scan imports them",
|
|
412
|
+
include_suggestions
|
|
413
|
+
)
|
|
414
|
+
)
|
|
415
|
+
|
|
390
416
|
checks_performed.append("export_presets")
|
|
391
417
|
if not FileAccess.file_exists("res://export_presets.cfg"):
|
|
392
418
|
warnings.append(
|
|
@@ -602,7 +628,25 @@ func _no_sidecar(resource_path: String) -> String:
|
|
|
602
628
|
return resource_path + " has no import options: " + never
|
|
603
629
|
return (
|
|
604
630
|
resource_path
|
|
605
|
-
+ " has not been imported yet, so it has no import file: project_import reimport imports
|
|
631
|
+
+ " has not been imported yet, so it has no import file: project_import reimport imports"
|
|
632
|
+
+ " it with the importer's defaults and writes that file"
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
## [param paths], files the engine imports and never has, as health and validation say it: at most
|
|
637
|
+
## five named, since a project never opened in an editor has every one of its assets here.
|
|
638
|
+
static func never_imported_line(paths: Array[String]) -> String:
|
|
639
|
+
var named: String = ", ".join(paths.slice(0, 5))
|
|
640
|
+
if paths.size() > 5:
|
|
641
|
+
named += " and %d more" % (paths.size() - 5)
|
|
642
|
+
if paths.size() == 1:
|
|
643
|
+
return (
|
|
644
|
+
named
|
|
645
|
+
+ " has never been imported, so nothing can load it until project_import reimport imports it"
|
|
646
|
+
)
|
|
647
|
+
return (
|
|
648
|
+
"%d files have never been imported, so nothing can load them until project_import reimport imports them: %s"
|
|
649
|
+
% [paths.size(), named]
|
|
606
650
|
)
|
|
607
651
|
|
|
608
652
|
|
|
@@ -3,6 +3,8 @@ extends RefCounted
|
|
|
3
3
|
const GdhRead = preload("reading.gd")
|
|
4
4
|
const GdhLog = preload("logger.gd")
|
|
5
5
|
const GdhProjectFile = preload("project_file.gd")
|
|
6
|
+
## The device an event matches every device with, InputMap's ALL_DEVICES, which GDScript is not given.
|
|
7
|
+
const ALL_DEVICES: int = -1
|
|
6
8
|
|
|
7
9
|
# The key names a caller may write, and what the engine calls them.
|
|
8
10
|
const KEY_NAMES: Dictionary = {
|
|
@@ -108,7 +110,13 @@ func _init(p_log: GdhLog) -> void:
|
|
|
108
110
|
func add_input_action(params: Dictionary) -> Dictionary:
|
|
109
111
|
var action_name: String = str(params.get("action_name", ""))
|
|
110
112
|
var events: Array = params.get("events", [])
|
|
111
|
-
var
|
|
113
|
+
var setting: String = "input/" + action_name
|
|
114
|
+
var held: Variant = ProjectSettings.get_setting(setting) if ProjectSettings.has_setting(setting) else null
|
|
115
|
+
var old: Dictionary = held if held is Dictionary else {}
|
|
116
|
+
var old_deadzone: float = GdhRead.as_float(old.get("deadzone", 0.5), 0.5)
|
|
117
|
+
# A rebind that names no deadzone keeps the one the action has, which a caller adding a key did
|
|
118
|
+
# not mean to change.
|
|
119
|
+
var deadzone: float = GdhRead.as_float(params.get("deadzone", old_deadzone), old_deadzone)
|
|
112
120
|
|
|
113
121
|
_log.info("Adding input action: " + action_name)
|
|
114
122
|
# The editor's Input Map refuses these, since project.godot keys an action by its name and
|
|
@@ -150,7 +158,9 @@ func add_input_action(params: Dictionary) -> Dictionary:
|
|
|
150
158
|
if key_value == KEY_NONE:
|
|
151
159
|
return _log.failure(_unknown_key(keycode))
|
|
152
160
|
|
|
153
|
-
var event_config: Dictionary = {"class_name": "InputEventKey"
|
|
161
|
+
var event_config: Dictionary = {"class_name": "InputEventKey"}
|
|
162
|
+
var physical: bool = GdhRead.as_bool(fields.get("physical", false))
|
|
163
|
+
event_config["physical_keycode" if physical else "keycode"] = key_value
|
|
154
164
|
if fields.get("ctrl", false):
|
|
155
165
|
event_config["ctrl_pressed"] = true
|
|
156
166
|
if fields.get("alt", false):
|
|
@@ -190,7 +200,6 @@ func add_input_action(params: Dictionary) -> Dictionary:
|
|
|
190
200
|
|
|
191
201
|
# An action that exists is rebound, which is how one of the engine's ui_ actions is changed, so
|
|
192
202
|
# what it held is answered rather than lost without a word.
|
|
193
|
-
var setting: String = "input/" + action_name
|
|
194
203
|
var answer: Dictionary = {
|
|
195
204
|
"action_name": action_name,
|
|
196
205
|
"events_count": events_config.size(),
|
|
@@ -199,8 +208,6 @@ func add_input_action(params: Dictionary) -> Dictionary:
|
|
|
199
208
|
"was_new": not ProjectSettings.has_setting(setting),
|
|
200
209
|
}
|
|
201
210
|
if not answer["was_new"]:
|
|
202
|
-
var held: Variant = ProjectSettings.get_setting(setting)
|
|
203
|
-
var old: Dictionary = held if held is Dictionary else {}
|
|
204
211
|
var old_events: Array[Dictionary] = []
|
|
205
212
|
var listed: Variant = old.get("events", [])
|
|
206
213
|
if listed is Array:
|
|
@@ -210,7 +217,7 @@ func add_input_action(params: Dictionary) -> Dictionary:
|
|
|
210
217
|
var bound: InputEvent = event
|
|
211
218
|
old_events.append(_shaped(bound))
|
|
212
219
|
answer["old_events"] = old_events
|
|
213
|
-
answer["old_deadzone"] =
|
|
220
|
+
answer["old_deadzone"] = old_deadzone
|
|
214
221
|
|
|
215
222
|
# Through ProjectSettings so the file is saved the way the editor saves it, header and
|
|
216
223
|
# every other line kept; a ConfigFile of project.godot drops the comments on the way out.
|
|
@@ -226,9 +233,12 @@ func add_input_action(params: Dictionary) -> Dictionary:
|
|
|
226
233
|
## under text, which also covers a kind of event that form has no fields for.
|
|
227
234
|
static func _shaped(event: InputEvent) -> Dictionary:
|
|
228
235
|
var shaped: Dictionary = {"class_name": event.get_class(), "text": event.as_text()}
|
|
236
|
+
if event.device != ALL_DEVICES:
|
|
237
|
+
shaped["device"] = event.device
|
|
229
238
|
if event is InputEventKey:
|
|
230
239
|
var key: InputEventKey = event
|
|
231
|
-
|
|
240
|
+
if key.keycode != KEY_NONE or key.physical_keycode == KEY_NONE:
|
|
241
|
+
shaped["keycode"] = key.keycode
|
|
232
242
|
if key.physical_keycode != KEY_NONE:
|
|
233
243
|
shaped["physical_keycode"] = key.physical_keycode
|
|
234
244
|
for modifier: String in ["ctrl_pressed", "alt_pressed", "shift_pressed"]:
|
|
@@ -328,6 +338,7 @@ func build_input_action(deadzone: float, events: Array) -> Dictionary:
|
|
|
328
338
|
"InputEventKey":
|
|
329
339
|
var key: InputEventKey = InputEventKey.new()
|
|
330
340
|
key.keycode = GdhRead.as_int(event.get("keycode", 0)) as Key
|
|
341
|
+
key.physical_keycode = GdhRead.as_int(event.get("physical_keycode", 0)) as Key
|
|
331
342
|
key.ctrl_pressed = GdhRead.as_bool(event.get("ctrl_pressed", false))
|
|
332
343
|
key.alt_pressed = GdhRead.as_bool(event.get("alt_pressed", false))
|
|
333
344
|
key.shift_pressed = GdhRead.as_bool(event.get("shift_pressed", false))
|
|
@@ -354,6 +365,10 @@ func build_input_action(deadzone: float, events: Array) -> Dictionary:
|
|
|
354
365
|
|
|
355
366
|
_:
|
|
356
367
|
return _log.failure("Unknown input event class: " + evt_class)
|
|
368
|
+
# Every device, as the editor's Input Map binds an event: a new event names one device, and
|
|
369
|
+
# an action bound to it ignored a second joypad.
|
|
370
|
+
var bound: InputEvent = built.back()
|
|
371
|
+
bound.device = ALL_DEVICES
|
|
357
372
|
|
|
358
373
|
return {"deadzone": deadzone, "events": built}
|
|
359
374
|
|
|
@@ -166,6 +166,37 @@ func set_project_setting(params: Dictionary) -> Dictionary:
|
|
|
166
166
|
return answer
|
|
167
167
|
|
|
168
168
|
|
|
169
|
+
# Takes a setting's line out of project.godot, so the engine's default holds again, or nothing at all
|
|
170
|
+
# for one the engine does not declare: the way back from a set, which writes a misspelt name as given.
|
|
171
|
+
func unset_project_setting(params: Dictionary) -> Dictionary:
|
|
172
|
+
var setting_path: String = str(params.get("setting", ""))
|
|
173
|
+
if setting_path.is_empty():
|
|
174
|
+
return _log.failure("setting is required")
|
|
175
|
+
var default_value: Variant = ProjectSettings.property_get_revert(setting_path)
|
|
176
|
+
var held: bool = ProjectSettings.has_setting(setting_path)
|
|
177
|
+
var value: Variant = ProjectSettings.get_setting(setting_path) if held else null
|
|
178
|
+
var answer: Dictionary = {
|
|
179
|
+
"setting_path": setting_path,
|
|
180
|
+
"default_value": _values.serialize_value(default_value) if default_value != null else null,
|
|
181
|
+
}
|
|
182
|
+
# A setting at the engine's default has no line to take out, as the engine leaves it out of the file.
|
|
183
|
+
if not held or (default_value != null and value == default_value):
|
|
184
|
+
answer["removed"] = false
|
|
185
|
+
answer["saved"] = false
|
|
186
|
+
answer["note"] = "project.godot does not set %s, so there was nothing to take out." % setting_path
|
|
187
|
+
return answer
|
|
188
|
+
answer["old_value"] = _values.serialize_value(value)
|
|
189
|
+
# The default rather than null for a setting the engine declares: null takes the declaration away
|
|
190
|
+
# as well, and a value at its default is left out of the file all the same.
|
|
191
|
+
ProjectSettings.set_setting(setting_path, default_value)
|
|
192
|
+
var err: Error = GdhProjectFile.save()
|
|
193
|
+
if err != OK:
|
|
194
|
+
return _log.failure("Failed to save project.godot: " + error_string(err))
|
|
195
|
+
answer["removed"] = true
|
|
196
|
+
answer["saved"] = true
|
|
197
|
+
return answer
|
|
198
|
+
|
|
199
|
+
|
|
169
200
|
# The settings in the same section as [param setting_path] named nearest it, for a new one that is
|
|
170
201
|
# likely a misspelt one: a setting nothing declares is written all the same, and is never read.
|
|
171
202
|
static func _settings_near(setting_path: String) -> PackedStringArray:
|
|
@@ -50,14 +50,15 @@ func get_project_health(params: Dictionary) -> Dictionary:
|
|
|
50
50
|
"res://", GdhImportPipeline.IMPORTABLE_EXTENSIONS
|
|
51
51
|
)
|
|
52
52
|
|
|
53
|
-
var missing_imports:
|
|
53
|
+
var missing_imports: Array[String] = []
|
|
54
54
|
for res: String in resources:
|
|
55
55
|
if not FileAccess.file_exists(res + ".import"):
|
|
56
|
-
missing_imports
|
|
56
|
+
missing_imports.append(res)
|
|
57
57
|
|
|
58
|
-
if missing_imports
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
if not missing_imports.is_empty():
|
|
59
|
+
missing_imports.sort()
|
|
60
|
+
details.append(GdhImportPipeline.never_imported_line(missing_imports))
|
|
61
|
+
deductions += missing_imports.size()
|
|
61
62
|
|
|
62
63
|
checks["resources"] = {
|
|
63
64
|
"name": "Resources",
|