@papercraftgames/estragon 0.1.0-beta.4 → 0.1.0-beta.6

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/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Release notes
2
2
 
3
- ## Next automated prerelease
3
+ ## Gogo editor experience — upcoming beta
4
4
 
5
- P02 makes runtime/compiler/editor dependencies location-independent and derives injected Gogo dependencies from the installed Resources and actual generated destination. Yarn packages run directly in node_modules; full-path plugin activation, cold editor/Play, nonstandard relocation and standard addon placement are covered by native consumer acceptance. This change is not yet published. The **one** release version is set in the Godot plugin configuration; the npm manifest is generated from it during packaging. The owner-controlled GitHub prerelease will exercise npm OIDC trusted publishing, provenance, byte-for-byte package verification and the approved Linux Godot consumer checks. These publication checks remain pending until the release actually runs.
5
+ The native Gogo editor now provides theme-aware GDScript/GGX syntax highlighting, context-sensitive CodeEdit completion and insertion/undo, source-positioned diagnostics/navigation, and **Project > Tools > New Gogo Script** templates for 2D/3D. No external compiler, language server or custom Godot build is needed for editing and Play. Dedicated native editor and Play checks passed on the two approved Linux Godot engines. Completion intentionally supports bounded lexical/ClassDB information rather than full GDScript type inference; the documented hidden, never-associated tab exception remains.
6
+
7
+ ## Previous direct Yarn installation beta
8
+
9
+ P02 made compiler/runtime/editor dependencies location-independent: packages work directly from Yarn `node_modules` without addon copying/symlinks. Internal references and generated dependencies resolve against installed Resources and actual destinations; Godot's enabled-plugin project setting accepts the full addon configuration path. That previous beta was published using the owner-controlled GitHub prerelease, with npm trusted-publisher OIDC, provenance/byte checks and native registry consumers. CI02 subsequently reduced mandatory certification to bounded direct-install validation; the full native regression suite remains opt-in.
6
10
 
7
11
  ## Initial public beta
8
12
 
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Pre-1.0 Godot addon: native Gogo/GGX compilation/editor, signal-driven descriptions reconciled with retained Nodes, layout-first Node2D UI and bounded Node3D adapters. Godot owns rendering, physics and scene lifetime. No Node/Bun compiler or runtime is required for authoring or Play.
4
4
 
5
+ Tagged npm packages carry the exact GitHub prerelease-tag version in both npm and Godot plugin metadata. Git source checkouts use a development marker; a local development pack is not a tagged release.
6
+
5
7
  ## Install into a Godot project
6
8
 
7
9
  P02 direct-install support is pending an owner-published release; earlier public betas may not contain this fix. The following contract applies to a package containing P02. Install the current beta in the Godot project root:
@@ -49,11 +49,7 @@ func _init(module: Model.Module, file: Source) -> void:
49
49
  while _module.identifiers.has(_element_class): _element_class += "_"
50
50
 
51
51
  func _resource(resource: Resource) -> String:
52
- var origin := ProjectSettings.globalize_path(_output_directory).simplify_path().split("/", false)
53
- var target := ProjectSettings.globalize_path(resource.resource_path).simplify_path().split("/", false)
54
- var shared := 0
55
- while shared < mini(origin.size(), target.size()) and origin[shared] == target[shared]: shared += 1
56
- return _string("../".repeat(origin.size() - shared) + "/".join(target.slice(shared)))
52
+ return _string(Source.relative_path(_output_directory,resource.resource_path))
57
53
 
58
54
  func emit() -> MappedWriter:
59
55
  _parts(_module.parts)
@@ -70,3 +70,11 @@ func index_at_offset(offset_value: int) -> int:
70
70
 
71
71
  func offset(line: int, column: int = 1) -> int:
72
72
  return mini(_utf16[-1], _utf16[line_start(line)] + maxi(0, column - 1))
73
+
74
+ ## Relative resource references shared by emission and editor starter templates.
75
+ static func relative_path(directory: String, resource_path: String) -> String:
76
+ var origin := ProjectSettings.globalize_path(directory).simplify_path().split("/", false)
77
+ var target := ProjectSettings.globalize_path(resource_path).simplify_path().split("/", false)
78
+ var shared := 0
79
+ while shared < mini(origin.size(), target.size()) and origin[shared] == target[shared]: shared += 1
80
+ return "../".repeat(origin.size() - shared) + "/".join(target.slice(shared))
@@ -7,7 +7,7 @@ const Dependencies = preload("script_dependencies.gd")
7
7
  const CONFIG := "gogo.config.json"
8
8
  const EXCLUDED := ["generated", "node_modules", "tests", "vendor"]
9
9
  var _project: String
10
- var _report := {"ok": false, "outputs": [], "changed": [], "diagnostics": [], "isolated_preflight": {"status": "UNTESTED"}}
10
+ var _report := {"ok": false, "outputs": [], "changed": [], "diagnostics": [], "source_diagnostics": [], "isolated_preflight": {"status": "UNTESTED"}}
11
11
  var _sources: Dictionary = {}
12
12
  var _staging: String
13
13
  var _previous_code: Dictionary = {}
@@ -20,6 +20,10 @@ static func run_build(project: String = "res://") -> Dictionary:
20
20
  func _fail(message: String) -> void:
21
21
  _report.diagnostics.append(message)
22
22
 
23
+ func _fail_source(diagnostic) -> void:
24
+ _fail(diagnostic.format())
25
+ _report.source_diagnostics.append({"source":diagnostic.source_name,"line":diagnostic.span.start.line,"column":diagnostic.span.start.column,"end_line":diagnostic.span.end.line,"end_column":diagnostic.span.end.column,"message":diagnostic.message})
26
+
23
27
  func _safe(path: String) -> bool:
24
28
  if not path.begins_with(_project + "/"):
25
29
  _fail("Generated/source path escapes the project: " + path)
@@ -93,7 +97,7 @@ func _run() -> Dictionary:
93
97
  continue
94
98
  var result := Compiler.compile(input.get_as_text(), source, _resource_path(output_for(source)))
95
99
  if not result.ok:
96
- for diagnostic in result.diagnostics: _fail(diagnostic.format())
100
+ for diagnostic in result.diagnostics: _fail_source(diagnostic)
97
101
  else: compiled.append({"source": source, "output": output_for(source), "result": result})
98
102
  if not _report.diagnostics.is_empty(): return _report
99
103
  var writes: Dictionary = {}
@@ -166,7 +170,7 @@ func _run() -> Dictionary:
166
170
  for item in compiled:
167
171
  if isolated:
168
172
  var checked := Validation.validate(item.result, _resource_path(item.output))
169
- for diagnostic in checked.diagnostics: _fail(diagnostic.format())
173
+ for diagnostic in checked.diagnostics: _fail_source(diagnostic)
170
174
  if not checked.ok:
171
175
  _report.isolated_preflight.status = "FAIL"
172
176
  break
@@ -223,7 +227,7 @@ func _refresh_cache(item: Dictionary, state: Array[Dictionary]) -> void:
223
227
  # Reload the actual Script even on no-op builds; keep_state preserves owners.
224
228
  state.append({"script": script, "previous": script.source_code if was_cached else _previous_code.get(item.output), "output": item.output})
225
229
  var checked := Validation.reload_script(item.result, script, true)
226
- for diagnostic in checked.diagnostics: _fail(diagnostic.format())
230
+ for diagnostic in checked.diagnostics: _fail_source(diagnostic)
227
231
 
228
232
  func _restore_cache(state: Array[Dictionary]) -> void:
229
233
  for item in state:
@@ -250,3 +254,31 @@ func _visit_dependencies(item: Dictionary, by_path: Dictionary, visited: Diction
250
254
  for path in item.dependencies:
251
255
  if by_path.has(path): _visit_dependencies(by_path[path], by_path, visited, ordered)
252
256
  ordered.append(item)
257
+
258
+ ## Same discovery exclusions/containment as builds; no writes or config changes.
259
+ static func creation_check(path: String) -> Dictionary:
260
+ var relative := path.trim_prefix("res://")
261
+ if not path.begins_with("res://") or path.get_extension() != "gogo" or "\\" in relative or ":" in relative:
262
+ return {"ok":false,"message":"Choose a .gogo file beneath res://."}
263
+ for part in relative.split("/"):
264
+ if part.begins_with(".") or part in EXCLUDED: return {"ok":false,"message":"This path is excluded from Gogo compilation. Choose a configured source root."}
265
+ if FileAccess.file_exists(path) or DirAccess.dir_exists_absolute(path):
266
+ return {"ok":false,"message":"A file or directory already exists. New Gogo Script never overwrites existing source; choose another filename."}
267
+ if not DirAccess.dir_exists_absolute(path.get_base_dir()): return {"ok":false,"message":"Create/select an existing project directory first."}
268
+ var check := new()
269
+ check._project = ProjectSettings.globalize_path("res://").trim_suffix("/")
270
+ if not check._safe(ProjectSettings.globalize_path(path)): return {"ok":false,"message":"Unsafe source path: "+str(check._report.diagnostics)}
271
+ if not FileAccess.file_exists("res://"+CONFIG):
272
+ return {"ok":not relative.begins_with("addons/"),"message":"Default discovery excludes the top-level addons directory; choose a project source directory."}
273
+ var json := JSON.new()
274
+ if json.parse(FileAccess.get_file_as_string("res://"+CONFIG)) != OK: return {"ok":false,"message":CONFIG+": "+json.get_error_message()}
275
+ var config: Variant = json.data
276
+ if not config is Dictionary or config.size() != 2 or config.get("version") != 1 or not config.get("source_roots") is Array or config.source_roots.is_empty():
277
+ return {"ok":false,"message":CONFIG+": expected version 1 and nonempty source_roots."}
278
+ var eligible := false
279
+ for root in config.source_roots:
280
+ if not root is String or root.is_empty() or root.is_absolute_path() or ":" in root or "\\" in root: return {"ok":false,"message":CONFIG+": invalid source root"}
281
+ for part in root.split("/"):
282
+ if part.begins_with(".") or part in EXCLUDED: return {"ok":false,"message":CONFIG+": invalid source root"}
283
+ if relative == root or relative.begins_with(root.trim_suffix("/")+"/"): eligible = true
284
+ return {"ok":eligible,"message":"Choose a location included by gogo.config.json source_roots: "+str(config.source_roots)}
@@ -0,0 +1,334 @@
1
+ @tool
2
+ extends RefCounted
3
+ ## Lexical declarations + public ClassDB metadata. No authored Script loads/new().
4
+ const Validator = preload("../compiler/validator.gd")
5
+ const Source = preload("../compiler/source.gd")
6
+ const Context = preload("lexical_context.gd")
7
+ const Catalog = preload("components.gd")
8
+ const Imports = preload("imports.gd")
9
+ const Build = preload("build_service.gd")
10
+ var sources: Dictionary = {}
11
+ var metadata: Dictionary = {}
12
+ var metadata_reads := 0
13
+ var _script_cache: Dictionary = {}
14
+ var _classes: PackedStringArray = []
15
+ var _text := ""
16
+ var _path := ""
17
+ var _symbols: Dictionary = {}
18
+ var _aliases: Dictionary = {}
19
+ var _owners: Dictionary = {}
20
+ var _base := "Node"
21
+ var _native_cache: Dictionary = {}
22
+ var _types = Validator.new(Source.new(""))
23
+
24
+ func _init() -> void:
25
+ _classes = ClassDB.get_class_list()
26
+ func invalidate() -> void:
27
+ _text = ""
28
+ _native_cache.clear()
29
+ _script_cache.clear()
30
+ metadata.clear()
31
+ func _tokens(text: String) -> Array:
32
+ var context := Context.new()
33
+ context.update(text)
34
+ var result: Array = []
35
+ for index in range(context.lines.size()):
36
+ for token in context.line(index).tokens:
37
+ if token.kind in ["comment","tag","property"]: continue
38
+ if token.kind == "string" and not result.is_empty() and result[-1].kind == "string" and result[-1].row == index and result[-1].end == token.start:
39
+ result[-1].text += token.text
40
+ result[-1].end = token.end
41
+ else:
42
+ var item: Dictionary = token.duplicate()
43
+ item.row = index
44
+ item.indent = context.lines[index].length()-context.lines[index].strip_edges(true,false).length()
45
+ result.append(item)
46
+ return result
47
+ func _resolve_path(raw: String, source: String) -> String:
48
+ if raw.length() < 2: return ""
49
+ var value := raw.substr(1,raw.length()-2).c_unescape()
50
+ if value.is_absolute_path(): return value.simplify_path()
51
+ var output := Build.output_for(source) if source.ends_with(".gogo") else source
52
+ return output.get_base_dir().path_join(value).simplify_path()
53
+ func _declarations(text: String, source: String) -> Dictionary:
54
+ var tokens := _tokens(text)
55
+ var symbols: Dictionary = {}
56
+ var aliases: Dictionary = {}
57
+ var base := ""
58
+ var owner := ""
59
+ var owners: Dictionary = {}
60
+ var required_initializer := false
61
+ for index in range(tokens.size()):
62
+ var word: String = tokens[index].text
63
+ if tokens[index].indent == 0: owners[tokens[index].row] = ""
64
+ elif not owners.has(tokens[index].row): owners[tokens[index].row] = owner
65
+ if word == "extends" and tokens[index].indent == 0 and index+1 < tokens.size():
66
+ base = _resolve_path(tokens[index+1].text,source) if tokens[index+1].kind == "string" else tokens[index+1].text
67
+ if word not in ["var","const","func","signal","class_name","class"] or index+1 >= tokens.size(): continue
68
+ var name: String = tokens[index+1].text
69
+ if not name.is_valid_identifier(): continue
70
+ var scope: String = owner if tokens[index].indent > 0 else ""
71
+ if word == "func" and tokens[index].indent == 0:
72
+ owner = name
73
+ owners[tokens[index].row] = owner
74
+ if name == "_init" and index+3 < tokens.size() and tokens[index+3].text != ")": required_initializer = true
75
+ var type := ""
76
+ if index+3 < tokens.size() and tokens[index+2].text == ":": type = tokens[index+3].text
77
+ symbols[name] = {"type":type,"owner":scope,"writable":true,"kind":CodeEdit.KIND_FUNCTION if word == "func" else (CodeEdit.KIND_SIGNAL if word == "signal" else (CodeEdit.KIND_CONSTANT if word == "const" else (CodeEdit.KIND_CLASS if word in ["class","class_name"] else (CodeEdit.KIND_VARIABLE if not scope.is_empty() else CodeEdit.KIND_MEMBER))))}
78
+ if word == "func": symbols[name].hint = text.split("\n")[tokens[index].row].strip_edges().trim_prefix("func ").trim_suffix(":")
79
+ if word == "signal":
80
+ var args: Array = []
81
+ for cursor in range(index+2,mini(index+28,tokens.size()-1)):
82
+ if tokens[cursor].text == ")": break
83
+ if tokens[cursor].text == ":": args.append(tokens[cursor+1].text)
84
+ symbols[name].args = args
85
+ if word == "var":
86
+ var getter := false
87
+ var setter := false
88
+ for cursor in range(index+2,tokens.size()-1):
89
+ if tokens[cursor].row > tokens[index].row and tokens[cursor].indent <= tokens[index].indent: break
90
+ if tokens[cursor].text == "get" and tokens[cursor+1].text == ":": getter = true
91
+ if tokens[cursor].text == "set": setter = true
92
+ symbols[name].writable = not getter or setter
93
+ if word == "const" and scope.is_empty():
94
+ for cursor in range(index+2,mini(index+7,tokens.size()-2)):
95
+ if tokens[cursor].text == "preload" and tokens[cursor+1].text == "(" and tokens[cursor+2].kind == "string": aliases[name] = _resolve_path(tokens[cursor+2].text,source)
96
+ # Typed arguments/local declarations also contribute names, never inferred values.
97
+ for index in range(1,tokens.size()-2):
98
+ if tokens[index].text == ":" and tokens[index-1].text.is_valid_identifier() and tokens[index+1].text.is_valid_identifier() and tokens[index+1].kind != "keyword" and tokens[index].row == tokens[index+1].row:
99
+ var name: String = tokens[index-1].text
100
+ if not symbols.has(name): symbols[name] = {"type":tokens[index+1].text,"owner":owners.get(tokens[index].row,""),"kind":CodeEdit.KIND_VARIABLE}
101
+ return {"symbols":symbols,"aliases":aliases,"base":base,"owners":owners,"required_initializer":required_initializer}
102
+ func _index(text: String, source: String) -> void:
103
+ if text == _text and source == _path: return
104
+ _text = text
105
+ _path = source
106
+ var declarations := _declarations(text,source)
107
+ _symbols = declarations.symbols
108
+ _owners = declarations.owners
109
+ _aliases = declarations.aliases
110
+ _base = declarations.base
111
+ func _script(path: String) -> Dictionary:
112
+ var text: String = sources[path] if sources.has(path) else FileAccess.get_file_as_string(path)
113
+ if not _script_cache.has(path) or _script_cache[path].text != text:
114
+ _script_cache[path] = {"text":text,"declarations":_declarations(text,path)}
115
+ return _script_cache[path].declarations
116
+ func _type_name(info: Dictionary) -> String:
117
+ var class_name_value: String = str(info.get("class_name",""))
118
+ if not class_name_value.is_empty(): return class_name_value
119
+ if info.get("type",TYPE_NIL) == TYPE_NIL: return "Variant" if int(info.get("usage",0)) & PROPERTY_USAGE_NIL_IS_VARIANT else "void"
120
+ var normalized := info.duplicate()
121
+ normalized.type = info.get("type",TYPE_NIL)
122
+ return _types._native_type(normalized)
123
+ func _method_hint(method: Dictionary) -> String:
124
+ var args: Array = []
125
+ for arg in method.get("args",[]): args.append(str(arg.name)+": "+_type_name(arg))
126
+ return str(method.name)+"("+", ".join(args)+") -> "+_type_name(method.get("return",{}))
127
+ func call_hint(text: String, source: String, lexical: RefCounted, row: int, column: int) -> String:
128
+ _index(text,source)
129
+ lexical.update(text)
130
+ var state: Dictionary = lexical.context(row,column)
131
+ if state.suppressed or state.mode != "gd": return ""
132
+ var tokens := _tokens(lexical.lines[row].left(column))
133
+ var depth := 0
134
+ for index in range(tokens.size()-1,-1,-1):
135
+ if tokens[index].text == ")": depth += 1
136
+ if tokens[index].text != "(": continue
137
+ if depth > 0: depth -= 1; continue
138
+ if index == 0: return ""
139
+ var name: String = tokens[index-1].text
140
+ var members := _members(_base,_aliases)
141
+ if index >= 3 and tokens[index-2].text == ".":
142
+ var receiver: String = tokens[index-3].text
143
+ if receiver != "self": members = _members(str(_symbols.get(receiver,{}).get("type",receiver)),_aliases)
144
+ else: members.merge(_symbols,true)
145
+ return str(members.get(name,{}).get("hint",""))
146
+ return ""
147
+ func _members(type: String, aliases: Dictionary, visited: Array = []) -> Dictionary:
148
+ var name: String = aliases.get(type,type)
149
+ if name.is_empty() or name in visited or visited.size() >= 12: return {}
150
+ if ClassDB.class_exists(name):
151
+ if _native_cache.has(name): return _native_cache[name]
152
+ var result: Dictionary = {}
153
+ for prop in ClassDB.class_get_property_list(name):
154
+ if str(prop.name).is_valid_identifier() and not (int(prop.usage) & (PROPERTY_USAGE_CATEGORY|PROPERTY_USAGE_GROUP|PROPERTY_USAGE_SUBGROUP)):
155
+ result[prop.name] = {"type":_type_name(prop),"kind":CodeEdit.KIND_MEMBER,"value_type":prop.type,"writable":not (int(prop.usage)&PROPERTY_USAGE_READ_ONLY)}
156
+ for method in ClassDB.class_get_method_list(name): result[method.name] = {"type":_type_name(method.get("return",{})),"kind":CodeEdit.KIND_FUNCTION,"hint":_method_hint(method)}
157
+ for sig in ClassDB.class_get_signal_list(name): result[sig.name] = {"type":"","kind":CodeEdit.KIND_SIGNAL,"args":sig.args.map(func(arg): return arg.type)}
158
+ _native_cache[name] = result
159
+ return result
160
+ if not name.begins_with("res://"):
161
+ for entry in ProjectSettings.get_global_class_list():
162
+ if entry["class"] == name: return _members(str(entry.path),{},visited+[name])
163
+ return {}
164
+ var authored := name.get_base_dir().get_base_dir().path_join(name.get_file().get_basename()+".gogo")
165
+ if name.get_base_dir().get_file() == "generated" and FileAccess.file_exists(authored): name = authored
166
+ if not FileAccess.file_exists(name): return {}
167
+ var declarations := _script(name)
168
+ var result := _members(declarations.base,declarations.aliases,visited+[name])
169
+ # Existing cached metadata only; never reload/new authored scripts.
170
+ if not sources.has(name):
171
+ var cached = metadata.get(name)
172
+ if cached == null and ResourceLoader.has_method("get_cached_ref"): cached = ResourceLoader.call("get_cached_ref",name)
173
+ if cached is Script and cached.source_code == _script_cache[name].text:
174
+ metadata_reads += 1
175
+ for prop in cached.get_script_property_list():
176
+ if str(prop.name).is_valid_identifier() and not (int(prop.usage) & (PROPERTY_USAGE_CATEGORY|PROPERTY_USAGE_GROUP|PROPERTY_USAGE_SUBGROUP)): result[prop.name] = {"type":_type_name(prop),"kind":CodeEdit.KIND_MEMBER,"writable":not (int(prop.usage)&PROPERTY_USAGE_READ_ONLY)}
177
+ for method in cached.get_script_method_list(): result[method.name] = {"type":_type_name(method.get("return",{})),"kind":CodeEdit.KIND_FUNCTION,"hint":_method_hint(method)}
178
+ for field in declarations.symbols:
179
+ if declarations.symbols[field].owner.is_empty(): result[field] = declarations.symbols[field]
180
+ return result
181
+ func _node_type(type: String, aliases: Dictionary, visited: Array = []) -> bool:
182
+ var name: String = aliases.get(type,type)
183
+ if name in visited or visited.size() >= 12: return false
184
+ if ClassDB.class_exists(name): return ClassDB.is_parent_class(name,"Node") and ClassDB.can_instantiate(name)
185
+ if not name.begins_with("res://"):
186
+ for entry in ProjectSettings.get_global_class_list():
187
+ if entry["class"] == name: return _node_type(str(entry.path),{},visited+[name])
188
+ return false
189
+ var authored := name.get_base_dir().get_base_dir().path_join(name.get_file().get_basename()+".gogo")
190
+ if name.get_base_dir().get_file() == "generated" and FileAccess.file_exists(authored): name = authored
191
+ if not FileAccess.file_exists(name): return false
192
+ var declarations := _script(name)
193
+ return not declarations.required_initializer and _node_type(declarations.base,declarations.aliases,visited+[name])
194
+ func _catalog_options(prefix: String, tags: bool) -> Dictionary:
195
+ var result: Dictionary = {}
196
+ var dimension := 3 if _base == "Node3D" or ClassDB.class_exists(_base) and ClassDB.is_parent_class(_base,"Node3D") else (2 if _base == "Node2D" or ClassDB.class_exists(_base) and ClassDB.is_parent_class(_base,"Node2D") else 0)
197
+ for item in Catalog.ITEMS:
198
+ if tags and (item.dimension == 0 or dimension != 0 and item.dimension != dimension): continue
199
+ if not tags and item.dimension != 0: continue
200
+ var alias: String = Imports.alias_for(item,_symbols,_aliases)
201
+ var label: String = item.canonical if str(item.canonical).begins_with(prefix) and not str(item.alias).begins_with(prefix) else item.alias
202
+ if not label.begins_with(prefix) and not alias.begins_with(prefix): continue
203
+ if alias != item.alias: label += " (as "+alias+")"
204
+ result[label+" — "+item.canonical+" ("+item.origin+")"] = {"kind":CodeEdit.KIND_CLASS,"insert":alias,"import":{"alias":alias,"path":Catalog.path(item)},"match":prefix}
205
+ return result
206
+ func _path_options(left: String, context: Dictionary, source: String, row: int, column: int) -> Array:
207
+ if context.quote.length() != 1: return []
208
+ var start := -1
209
+ for token in context.tokens:
210
+ if token.kind == "string" and token.text == context.quote: start = token.start
211
+ if start < 0: return []
212
+ var before := left.left(start).strip_edges()
213
+ var tokens := _tokens(before)
214
+ if tokens.is_empty(): return []
215
+ var allowed: bool = tokens[-1].text == "extends" or tokens.size() >= 2 and tokens[-1].text == "(" and tokens[-2].text in ["load","preload"]
216
+ if not allowed: return []
217
+ var value := left.substr(start+1)
218
+ if "\\" in value or value.contains("\"") or value.contains("'") or value.begins_with("user://") or value.is_absolute_path() and not value.begins_with("res://"): return []
219
+ var base := Build.output_for(source).get_base_dir()
220
+ var slash := value.rfind("/")
221
+ var directory := value.left(slash+1) if slash >= 0 else ""
222
+ var prefix := value.substr(slash+1)
223
+ var target := directory if directory.begins_with("res://") else base.path_join(directory).simplify_path()
224
+ if not target.begins_with("res://") or target.contains("/../"): return []
225
+ for part in target.trim_prefix("res://").split("/"):
226
+ if part.begins_with("."): return []
227
+ if target != "res://":
228
+ var containment := Build.new()
229
+ containment._project = ProjectSettings.globalize_path("res://").trim_suffix("/")
230
+ if not containment._safe(ProjectSettings.globalize_path(target).trim_suffix("/")): return []
231
+ var access := DirAccess.open(target)
232
+ if access == null: return []
233
+ var result: Array = []
234
+ var extensions := ResourceLoader.get_recognized_extensions_for_type("")
235
+ access.list_dir_begin()
236
+ var name := access.get_next()
237
+ while not name.is_empty() and result.size() < 256:
238
+ if not name.begins_with(".") and name.begins_with(prefix) and (not access.has_method("is_link") or not access.call("is_link",name)) and (access.current_is_dir() or name.get_extension() in extensions):
239
+ var is_dir := access.current_is_dir()
240
+ var insert: String = context.quote+directory+name+("/" if is_dir else context.quote)
241
+ result.append({"text":insert,"insert":insert,"kind":CodeEdit.KIND_FILE_PATH,"row":row,"start":start,"column":column,"path":true})
242
+ name = access.get_next()
243
+ access.list_dir_end()
244
+ return result
245
+ func import_plan(text: String, source: String, requests: Array = []) -> Dictionary:
246
+ _index(text,source)
247
+ if requests.is_empty():
248
+ var lexical := Context.new()
249
+ lexical.update(text)
250
+ for row in range(lexical.lines.size()):
251
+ for token in lexical.line(row).tokens:
252
+ if token.kind != "tag" or not token.text.is_valid_identifier(): continue
253
+ var item := Catalog.named(token.text)
254
+ if not item.is_empty() and item.dimension != 0 and not _symbols.has(token.text): requests.append({"alias":token.text,"path":Catalog.path(item)})
255
+ return Imports.plan(text,source,requests,_symbols,_aliases,_tokens(text))
256
+ func definition(text: String, source: String, symbol: String) -> String:
257
+ _index(text,source)
258
+ return _aliases.get(symbol,"")
259
+ func candidates(text: String, source: String, lexical: RefCounted, row: int, column: int) -> Array:
260
+ _index(text,source)
261
+ lexical.update(text)
262
+ var context: Dictionary = lexical.context(row,column)
263
+ if context.suppressed: return _path_options(lexical.lines[row].left(column),context,source,row,column)
264
+ var left: String = lexical.lines[row].left(column)
265
+ var prefix := ""
266
+ var cursor := left.length()-1
267
+ while cursor >= 0 and (left[cursor].is_valid_identifier() or left[cursor].is_valid_int() or left[cursor] == ":"):
268
+ prefix = left[cursor]+prefix
269
+ cursor -= 1
270
+ if context.mode == "tag" and context.closing: prefix = "/"+prefix
271
+ var offered: Dictionary = {}
272
+ if context.mode == "tag":
273
+ if context.closing:
274
+ if not context.tags.is_empty(): offered["/"+context.tags[-1]] = {"kind":CodeEdit.KIND_CLASS}
275
+ elif context.name_pending or not left.substr(maxi(0,left.rfind("<"))+1).contains(" ") and not left.substr(maxi(0,left.rfind("<"))+1).contains("\t"):
276
+ for name in _classes:
277
+ if ClassDB.is_parent_class(name,"Node") and ClassDB.can_instantiate(name): offered[name] = {"kind":CodeEdit.KIND_CLASS}
278
+ for name in _aliases:
279
+ if _node_type(name,_aliases): offered[name] = {"kind":CodeEdit.KIND_CLASS,"origin":"explicit Node preload"}
280
+ for entry in ProjectSettings.get_global_class_list():
281
+ var known := Catalog.named(str(entry["class"]))
282
+ if not known.is_empty() and Catalog.path(known) == str(entry.path): continue
283
+ if str(entry["class"]).begins_with(prefix) and _node_type(str(entry["class"]),{}): offered[entry["class"]] = {"kind":CodeEdit.KIND_CLASS,"origin":"project Node"}
284
+ for item in Catalog.ITEMS:
285
+ for alias in _aliases:
286
+ if _aliases[alias] == Catalog.path(item): offered.erase(alias)
287
+ offered.merge(_catalog_options(prefix,true))
288
+ else:
289
+ if not _node_type(context.tag,_aliases): return []
290
+ var members := _members(context.tag,_aliases)
291
+ for name in members:
292
+ if members[name].kind in [CodeEdit.KIND_MEMBER,CodeEdit.KIND_SIGNAL] and members[name].get("writable",true) and name not in ["owner","script"]: offered[name] = members[name]
293
+ if _node_type(context.tag,_aliases): offered.key = {"kind":CodeEdit.KIND_MEMBER}
294
+ if members.has("value") and (members.value.get("value_type") == TYPE_BOOL or members.value.get("type") == "bool") and members.has("value_changed") and members.value_changed.get("args",[]).size() == 1 and members.value_changed.args[0] in ["bool",TYPE_BOOL]: offered["bind:value"] = {"kind":CodeEdit.KIND_MEMBER}
295
+ elif context.mode == "body": return []
296
+ elif cursor >= 0 and left[cursor] == ".":
297
+ var begin := cursor-1
298
+ while begin >= 0 and (left[begin].is_valid_identifier() or left[begin].is_valid_int() or left[begin] == "."): begin -= 1
299
+ var receiver := left.substr(begin+1,cursor-begin-1)
300
+ var chain := receiver.split(".")
301
+ var members: Dictionary = {}
302
+ if chain[0] == "self":
303
+ for field in _symbols:
304
+ if _symbols[field].owner.is_empty(): members[field] = _symbols[field]
305
+ if chain[0] == "self": members.merge(_members(_base,_aliases),false)
306
+ elif _symbols.has(chain[0]): members = _members(_symbols[chain[0]].type,_aliases)
307
+ else: members = _members(chain[0],_aliases)
308
+ for index in range(1,chain.size()): members = _members(str(members.get(chain[index],{}).get("type","")),_aliases)
309
+ offered = members
310
+ else:
311
+ for word in Context.KEYWORDS: offered[word] = {"kind":CodeEdit.KIND_PLAIN_TEXT}
312
+ for name in _classes: offered[name] = {"kind":CodeEdit.KIND_CLASS}
313
+ for native_type in range(1,TYPE_MAX):
314
+ var type_name: String = _types._native_type({"type":native_type})
315
+ if not type_name.is_empty(): offered[type_name] = {"kind":CodeEdit.KIND_CLASS}
316
+ offered.Variant = {"kind":CodeEdit.KIND_CLASS}
317
+ for entry in ProjectSettings.get_global_class_list(): offered[entry["class"]] = {"kind":CodeEdit.KIND_CLASS}
318
+ for field in _symbols:
319
+ if _symbols[field].owner.is_empty() or _symbols[field].owner == _owners.get(row,""): offered[field] = _symbols[field]
320
+ offered.merge(_members(_base,_aliases),false)
321
+ offered.merge(_catalog_options(prefix,false))
322
+ if cursor >= 0 and left[cursor] == "@":
323
+ offered.clear()
324
+ for name in ["bindable","tool","export","export_range","onready","warning_ignore"]: offered[name] = {"kind":CodeEdit.KIND_PLAIN_TEXT}
325
+ var result: Array = []
326
+ for name in offered:
327
+ if (str(name).begins_with(prefix) or offered[name].has("match")) and (not str(name).begins_with("_") or prefix.begins_with("_") or _symbols.has(name)):
328
+ var item: Dictionary = offered[name]
329
+ var insert: String = item.get("insert",str(name).trim_prefix("bind:") if prefix.begins_with("bind:") else str(name))
330
+ var display: String = str(name) if item.has("import") else (insert+" — "+str(item.origin) if item.has("origin") else insert)
331
+ if context.mode == "tag" and not item.has("import") and ClassDB.class_exists(insert): display += " — Godot "+ClassDB.get_parent_class(insert)
332
+ result.append({"text":display,"insert":insert,"kind":item.kind,"row":row,"start":cursor if context.mode == "tag" and context.closing else cursor+1,"column":column,"hint":item.get("hint",""),"imports":[item["import"]] if item.has("import") else []})
333
+ result.sort_custom(func(a,b): return a.text < b.text)
334
+ return result
@@ -0,0 +1 @@
1
+ uid://bajyq4kqi1
@@ -0,0 +1,7 @@
1
+ @tool
2
+ extends CodeEdit
3
+ ## Documented public virtual. Attached only to otherwise scriptless Gogo editors.
4
+ ## Popup navigation and confirmation gestures remain native; commit is synchronous.
5
+ var estragon_accept: Callable
6
+ func _confirm_code_completion(replace: bool) -> void:
7
+ if estragon_accept.is_valid(): estragon_accept.call(replace)
@@ -0,0 +1 @@
1
+ uid://6anm2in7ldm
@@ -0,0 +1,18 @@
1
+ @tool
2
+ extends RefCounted
3
+ ## Trusted installed resources, not guessed global classes or installation roots.
4
+ const ITEMS := [
5
+ {"alias":"Text","canonical":"EstragonText","script":preload("../runtime/node/text.gd"),"dimension":2,"origin":"native widget"},
6
+ {"alias":"Rect","canonical":"EstragonRect","script":preload("../runtime/node/rect.gd"),"dimension":2,"origin":"native widget"},
7
+ {"alias":"UiButton","canonical":"EstragonButton","script":preload("../runtime/node/button.gd"),"dimension":2,"origin":"native widget"},
8
+ {"alias":"VBox","canonical":"EstragonVBox","script":preload("../runtime/node/vbox.gd"),"dimension":2,"origin":"native layout"},
9
+ {"alias":"HBox","canonical":"EstragonHBox","script":preload("../runtime/node/hbox.gd"),"dimension":2,"origin":"native layout"},
10
+ {"alias":"Entry2D","canonical":"Estragon2D","script":preload("../runtime/node/estragon_2d.gd"),"dimension":2,"origin":"layout entry"},
11
+ {"alias":"Entry3D","canonical":"Estragon3D","script":preload("../runtime/node/estragon_3d.gd"),"dimension":3,"origin":"layout entry"},
12
+ {"alias":"Element","canonical":"Element","script":preload("../runtime/composition/element.gd"),"dimension":0,"origin":"GGX description type"}
13
+ ]
14
+ static func path(item: Dictionary) -> String: return (item.script as Script).resource_path
15
+ static func named(name: String) -> Dictionary:
16
+ for item in ITEMS:
17
+ if name in [item.alias,item.canonical]: return item
18
+ return {}
@@ -0,0 +1 @@
1
+ uid://1lt6a67tepd