@papercraftgames/estragon 0.1.0-beta.2 → 0.1.0-beta.21
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 +7 -3
- package/README.md +11 -8
- package/addons/estragon/compiler/bindable.gd +3 -3
- package/addons/estragon/compiler/compiler.gd +8 -8
- package/addons/estragon/compiler/composition.gd +5 -4
- package/addons/estragon/compiler/emitter.gd +34 -8
- package/addons/estragon/compiler/frontend.gd +8 -8
- package/addons/estragon/compiler/lexer.gd +2 -2
- package/addons/estragon/compiler/model.gd +2 -0
- package/addons/estragon/compiler/native/resolver.gd +125 -29
- package/addons/estragon/compiler/parser.gd +3 -3
- package/addons/estragon/compiler/project_sources.gd +91 -0
- package/addons/estragon/compiler/project_sources.gd.uid +1 -0
- package/addons/estragon/compiler/script_validation.gd +3 -3
- package/addons/estragon/compiler/source.gd +19 -2
- package/addons/estragon/compiler/source_map.gd +3 -3
- package/addons/estragon/compiler/validator.gd +74 -10
- package/addons/estragon/editor/build_service.gd +91 -72
- package/addons/estragon/editor/color_property.gd +37 -0
- package/addons/estragon/editor/color_property.gd.uid +1 -0
- package/addons/estragon/editor/completion.gd +531 -0
- package/addons/estragon/editor/completion.gd.uid +1 -0
- package/addons/estragon/editor/completion_edit.gd +7 -0
- package/addons/estragon/editor/completion_edit.gd.uid +1 -0
- package/addons/estragon/editor/components.gd +20 -0
- package/addons/estragon/editor/components.gd.uid +1 -0
- package/addons/estragon/editor/creation_menu.gd.txt +14 -0
- package/addons/estragon/editor/generated_editors.gd +256 -0
- package/addons/estragon/editor/generated_editors.gd.uid +1 -0
- package/addons/estragon/editor/highlighter.gd +62 -103
- package/addons/estragon/editor/highlighter_association.gd +11 -2
- package/addons/estragon/editor/imports.gd +47 -0
- package/addons/estragon/editor/imports.gd.uid +1 -0
- package/addons/estragon/editor/language_services.gd +288 -0
- package/addons/estragon/editor/language_services.gd.uid +1 -0
- package/addons/estragon/editor/length_property.gd +22 -0
- package/addons/estragon/editor/length_property.gd.uid +1 -0
- package/addons/estragon/editor/lexical_context.gd +159 -0
- package/addons/estragon/editor/lexical_context.gd.uid +1 -0
- package/addons/estragon/editor/navigation.gd +30 -0
- package/addons/estragon/editor/navigation.gd.uid +1 -0
- package/addons/estragon/editor/new_script.gd +77 -0
- package/addons/estragon/editor/new_script.gd.uid +1 -0
- package/addons/estragon/editor/plugin.cfg +1 -1
- package/addons/estragon/editor/plugin.gd +113 -40
- package/addons/estragon/editor/scene_components.gd +267 -0
- package/addons/estragon/editor/scene_components.gd.uid +1 -0
- package/addons/estragon/editor/scene_inspector.gd +42 -0
- package/addons/estragon/editor/scene_inspector.gd.uid +1 -0
- package/addons/estragon/editor/script_dependencies.gd +5 -3
- package/addons/estragon/runtime/composition/binding.gd +1 -1
- package/addons/estragon/runtime/composition/computation.gd +141 -9
- package/addons/estragon/runtime/composition/element.gd +3 -1
- package/addons/estragon/runtime/composition/layout_host.gd +58 -0
- package/addons/estragon/runtime/composition/layout_host.gd.uid +1 -0
- package/addons/estragon/runtime/composition/profile.tres +1 -1
- package/addons/estragon/runtime/composition/projection.gd +32 -0
- package/addons/estragon/runtime/composition/projection.gd.uid +1 -0
- package/addons/estragon/runtime/composition/state.gd +13 -2
- package/addons/estragon/runtime/composition/state.tres +1 -1
- package/addons/estragon/runtime/node/box.gd +57 -0
- package/addons/estragon/runtime/node/box.gd.uid +1 -0
- package/addons/estragon/runtime/node/button.gd +44 -15
- package/addons/estragon/runtime/node/component_2d.gd +167 -24
- package/addons/estragon/runtime/node/component_3d.gd +54 -18
- package/addons/estragon/runtime/node/estragon_2d.gd +2 -11
- package/addons/estragon/runtime/node/estragon_3d.gd +1 -10
- package/addons/estragon/runtime/node/hbox.gd +4 -1
- package/addons/estragon/runtime/node/internal/component_2d_icon.tres +4 -0
- package/addons/estragon/runtime/node/internal/composition_hosts.gd +159 -0
- package/addons/estragon/runtime/node/internal/composition_hosts.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/composition_hosts.tres +6 -0
- package/addons/estragon/runtime/node/internal/control_participant.gd +164 -0
- package/addons/estragon/runtime/node/internal/control_participant.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/coordinator.gd +79 -27
- package/addons/estragon/runtime/node/internal/grid_definition.gd +75 -0
- package/addons/estragon/runtime/node/internal/grid_definition.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/layout_core.gd +205 -22
- package/addons/estragon/runtime/node/internal/length.gd +94 -0
- package/addons/estragon/runtime/node/internal/length.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/stack_contract.gd +21 -0
- package/addons/estragon/runtime/node/internal/stack_contract.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/stack_policy.gd +59 -0
- package/addons/estragon/runtime/node/internal/stack_policy.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/visual_style_2d.gd +75 -0
- package/addons/estragon/runtime/node/internal/visual_style_2d.gd.uid +1 -0
- package/addons/estragon/runtime/node/native_2d.gd +5 -5
- package/addons/estragon/runtime/node/native_3d.gd +5 -5
- package/addons/estragon/runtime/node/rect.gd +13 -13
- package/addons/estragon/runtime/node/spacer.gd +4 -0
- package/addons/estragon/runtime/node/spacer.gd.uid +1 -0
- package/addons/estragon/runtime/node/text.gd +5 -3
- package/addons/estragon/runtime/node/toggle.gd +18 -5
- package/addons/estragon/runtime/node/vbox.gd +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,531 @@
|
|
|
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
|
+
const ProjectSources = preload("../compiler/project_sources.gd")
|
|
11
|
+
const Resolver = preload("../compiler/native/resolver.gd")
|
|
12
|
+
var project_index
|
|
13
|
+
var _project_items_cache: Array = []
|
|
14
|
+
var _project_key := ""
|
|
15
|
+
var sources: Dictionary = {}
|
|
16
|
+
var metadata: Dictionary = {}
|
|
17
|
+
var metadata_reads := 0
|
|
18
|
+
var _script_cache: Dictionary = {}
|
|
19
|
+
var _classes: PackedStringArray = []
|
|
20
|
+
var _text := ""
|
|
21
|
+
var _path := ""
|
|
22
|
+
var _symbols: Dictionary = {}
|
|
23
|
+
var _aliases: Dictionary = {}
|
|
24
|
+
var _owners: Dictionary = {}
|
|
25
|
+
var _scoped: Dictionary = {}
|
|
26
|
+
var _blocks: Dictionary = {}
|
|
27
|
+
var _base := "Node"
|
|
28
|
+
var _native_cache: Dictionary = {}
|
|
29
|
+
var _types = Validator.new(Source.new(""))
|
|
30
|
+
|
|
31
|
+
func _init() -> void:
|
|
32
|
+
_classes = ClassDB.get_class_list()
|
|
33
|
+
func invalidate() -> void:
|
|
34
|
+
project_index = null
|
|
35
|
+
_project_key = ""
|
|
36
|
+
_text = ""
|
|
37
|
+
_native_cache.clear()
|
|
38
|
+
_script_cache.clear()
|
|
39
|
+
metadata.clear()
|
|
40
|
+
func _tokens(text: String) -> Array:
|
|
41
|
+
var context := Context.new()
|
|
42
|
+
context.update(text)
|
|
43
|
+
var result: Array = []
|
|
44
|
+
for index in range(context.lines.size()):
|
|
45
|
+
for token in context.line(index).tokens:
|
|
46
|
+
if token.kind in ["comment","tag","property"]: continue
|
|
47
|
+
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:
|
|
48
|
+
result[-1].text += token.text
|
|
49
|
+
result[-1].end = token.end
|
|
50
|
+
else:
|
|
51
|
+
var item: Dictionary = token.duplicate()
|
|
52
|
+
item.row = index
|
|
53
|
+
item.indent = context.lines[index].length()-context.lines[index].strip_edges(true,false).length()
|
|
54
|
+
result.append(item)
|
|
55
|
+
return result
|
|
56
|
+
func _resolve_path(raw: String, source: String) -> String:
|
|
57
|
+
if raw.length() < 2: return ""
|
|
58
|
+
var value := raw.substr(1,raw.length()-2).c_unescape()
|
|
59
|
+
if value.is_absolute_path(): return value.simplify_path()
|
|
60
|
+
var output := Build.output_for(source) if source.ends_with(".gogo") else source
|
|
61
|
+
return output.get_base_dir().path_join(value).simplify_path()
|
|
62
|
+
func _declared_type(tokens: Array, start: int) -> String:
|
|
63
|
+
if start>=tokens.size() or not tokens[start].text.is_valid_identifier(): return ""
|
|
64
|
+
var type: String = tokens[start].text
|
|
65
|
+
for index in range(start+1,mini(start+17,tokens.size()-1),2):
|
|
66
|
+
if tokens[index].text!="." or not tokens[index+1].text.is_valid_identifier(): break
|
|
67
|
+
type += "."+tokens[index+1].text
|
|
68
|
+
return type
|
|
69
|
+
func _declarations(text: String, source: String) -> Dictionary:
|
|
70
|
+
var tokens := _tokens(text)
|
|
71
|
+
# Indentation block identities distinguish a local declaration from names
|
|
72
|
+
# in an exited/sibling block. Compute once with the declaration index.
|
|
73
|
+
var blocks := {}
|
|
74
|
+
var stack: Array = []
|
|
75
|
+
for token in tokens:
|
|
76
|
+
if blocks.has(token.row): continue
|
|
77
|
+
while not stack.is_empty() and stack[-1].indent>token.indent: stack.pop_back()
|
|
78
|
+
if token.indent>0 and (stack.is_empty() or stack[-1].indent<token.indent): stack.append({"indent":token.indent,"id":token.row})
|
|
79
|
+
if token.indent==0: stack.clear()
|
|
80
|
+
blocks[token.row] = stack.map(func(block): return block.id)
|
|
81
|
+
var symbols: Dictionary = {}
|
|
82
|
+
var aliases: Dictionary = {}
|
|
83
|
+
var base := ""
|
|
84
|
+
var owner := ""
|
|
85
|
+
var owners: Dictionary = {}
|
|
86
|
+
var scoped: Dictionary = {}
|
|
87
|
+
var required_initializer := false
|
|
88
|
+
for index in range(tokens.size()):
|
|
89
|
+
var word: String = tokens[index].text
|
|
90
|
+
if tokens[index].indent == 0 and not owners.has(tokens[index].row): owners[tokens[index].row] = ""
|
|
91
|
+
elif not owners.has(tokens[index].row): owners[tokens[index].row] = owner
|
|
92
|
+
if word == "extends" and tokens[index].indent == 0 and index+1 < tokens.size():
|
|
93
|
+
base = _resolve_path(tokens[index+1].text,source) if tokens[index+1].kind == "string" else tokens[index+1].text
|
|
94
|
+
if word not in ["var","const","func","signal","class_name","class"] or index+1 >= tokens.size(): continue
|
|
95
|
+
var name: String = tokens[index+1].text
|
|
96
|
+
if not name.is_valid_identifier(): continue
|
|
97
|
+
var scope: String = owner if tokens[index].indent > 0 else ""
|
|
98
|
+
if word == "func" and tokens[index].indent == 0:
|
|
99
|
+
owner = name
|
|
100
|
+
owners[tokens[index].row] = owner
|
|
101
|
+
if name == "_init" and index+3 < tokens.size() and tokens[index+3].text != ")": required_initializer = true
|
|
102
|
+
var type := ""
|
|
103
|
+
if index+3 < tokens.size() and tokens[index+2].text == ":": type = _declared_type(tokens,index+3)
|
|
104
|
+
symbols[name] = {"type":type,"owner":scope,"row":tokens[index].row,"block":blocks.get(tokens[index].row,[]),"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))))}
|
|
105
|
+
if word == "func":
|
|
106
|
+
symbols[name].hint = text.split("\n")[tokens[index].row].strip_edges().trim_prefix("func ").trim_suffix(":")
|
|
107
|
+
var depth := 0
|
|
108
|
+
for cursor in range(index+2,mini(index+258,tokens.size()-2)):
|
|
109
|
+
if tokens[cursor].text == "(": depth += 1
|
|
110
|
+
elif tokens[cursor].text == ")":
|
|
111
|
+
depth -= 1
|
|
112
|
+
if depth == 0:
|
|
113
|
+
if tokens[cursor+1].text == "->": symbols[name].type = _declared_type(tokens,cursor+2)
|
|
114
|
+
break
|
|
115
|
+
if word == "signal":
|
|
116
|
+
var args: Array = []
|
|
117
|
+
for cursor in range(index+2,mini(index+28,tokens.size()-1)):
|
|
118
|
+
if tokens[cursor].text == ")": break
|
|
119
|
+
if tokens[cursor].text == ":": args.append(tokens[cursor+1].text)
|
|
120
|
+
symbols[name].args = args
|
|
121
|
+
if word == "var":
|
|
122
|
+
var getter := false
|
|
123
|
+
var setter := false
|
|
124
|
+
for cursor in range(index+2,tokens.size()-1):
|
|
125
|
+
if tokens[cursor].row > tokens[index].row and tokens[cursor].indent <= tokens[index].indent: break
|
|
126
|
+
if tokens[cursor].text == "get" and tokens[cursor+1].text == ":": getter = true
|
|
127
|
+
if tokens[cursor].text == "set": setter = true
|
|
128
|
+
symbols[name].writable = not getter or setter
|
|
129
|
+
if word == "const" and scope.is_empty():
|
|
130
|
+
if index+3<tokens.size() and tokens[index+2].text=="=" and ClassDB.class_exists(tokens[index+3].text): aliases[name] = tokens[index+3].text
|
|
131
|
+
for cursor in range(index+2,mini(index+7,tokens.size()-2)):
|
|
132
|
+
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)
|
|
133
|
+
if not scoped.has(scope): scoped[scope] = {}
|
|
134
|
+
scoped[scope][name] = symbols[name]
|
|
135
|
+
# Typed arguments/local declarations also contribute names, never inferred values.
|
|
136
|
+
for index in range(1,tokens.size()-2):
|
|
137
|
+
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:
|
|
138
|
+
var name: String = tokens[index-1].text
|
|
139
|
+
var scope: String = owners.get(tokens[index].row,"")
|
|
140
|
+
if not scoped.has(scope): scoped[scope] = {}
|
|
141
|
+
if not scoped[scope].has(name): scoped[scope][name] = {"type":_declared_type(tokens,index+1),"owner":scope,"row":tokens[index].row,"block":blocks.get(tokens[index].row,[]),"kind":CodeEdit.KIND_VARIABLE}
|
|
142
|
+
if not symbols.has(name): symbols[name] = scoped[scope][name]
|
|
143
|
+
return {"symbols":symbols,"scoped":scoped,"blocks":blocks,"aliases":aliases,"base":base,"owners":owners,"required_initializer":required_initializer}
|
|
144
|
+
func _index(text: String, source: String) -> void:
|
|
145
|
+
if text == _text and source == _path: return
|
|
146
|
+
_text = text
|
|
147
|
+
_path = source
|
|
148
|
+
var declarations := _declarations(text,source)
|
|
149
|
+
_symbols = declarations.symbols
|
|
150
|
+
_owners = declarations.owners
|
|
151
|
+
_scoped = declarations.scoped
|
|
152
|
+
_blocks = declarations.blocks
|
|
153
|
+
_aliases = declarations.aliases
|
|
154
|
+
_base = declarations.base
|
|
155
|
+
func _script(path: String) -> Dictionary:
|
|
156
|
+
var text: String = sources[path] if sources.has(path) else FileAccess.get_file_as_string(path)
|
|
157
|
+
if not _script_cache.has(path) or _script_cache[path].text != text:
|
|
158
|
+
_script_cache[path] = {"text":text,"declarations":_declarations(text,path)}
|
|
159
|
+
return _script_cache[path].declarations
|
|
160
|
+
func _type_name(info: Dictionary) -> String:
|
|
161
|
+
var class_name_value: String = str(info.get("class_name",""))
|
|
162
|
+
if not class_name_value.is_empty(): return class_name_value
|
|
163
|
+
if info.get("type",TYPE_NIL) == TYPE_NIL: return "Variant" if int(info.get("usage",0)) & PROPERTY_USAGE_NIL_IS_VARIANT else "void"
|
|
164
|
+
var normalized := info.duplicate()
|
|
165
|
+
normalized.type = info.get("type",TYPE_NIL)
|
|
166
|
+
return _types._native_type(normalized)
|
|
167
|
+
func _method_hint(method: Dictionary) -> String:
|
|
168
|
+
var args: Array = []
|
|
169
|
+
for arg in method.get("args",[]): args.append(str(arg.name)+": "+_type_name(arg))
|
|
170
|
+
return str(method.name)+"("+", ".join(args)+") -> "+_type_name(method.get("return",{}))
|
|
171
|
+
# Bounded cached tokens at the caret. Strings stay opaque; comments and GGX
|
|
172
|
+
# delimiters cannot masquerade as code. Never parse the whole file per request.
|
|
173
|
+
func _chain_tokens(lexical: RefCounted, row: int, column: int) -> Array:
|
|
174
|
+
var result: Array = []
|
|
175
|
+
var budget := 4096
|
|
176
|
+
for line in range(row,maxi(-1,row-16),-1):
|
|
177
|
+
var limit: int = column if line==row else lexical.lines[line].length()
|
|
178
|
+
budget -= limit
|
|
179
|
+
if budget<0: return []
|
|
180
|
+
var tokens: Array = []
|
|
181
|
+
for token in lexical.line(line).tokens:
|
|
182
|
+
if token.start>=limit: break
|
|
183
|
+
if token.kind=="comment": continue
|
|
184
|
+
var item: Dictionary = token.duplicate()
|
|
185
|
+
if item.end>limit: item.text = item.text.left(limit-item.start)
|
|
186
|
+
if item.kind=="string" and not tokens.is_empty() and tokens[-1].kind=="string" and tokens[-1].end==item.start:
|
|
187
|
+
tokens[-1].text += item.text
|
|
188
|
+
tokens[-1].end = item.end
|
|
189
|
+
else: tokens.append(item)
|
|
190
|
+
result = tokens+result
|
|
191
|
+
if result.size()>256: return []
|
|
192
|
+
return result
|
|
193
|
+
func _scope_members(row: int, self_only: bool = false) -> Dictionary:
|
|
194
|
+
var result := _members(_base,_aliases).duplicate()
|
|
195
|
+
result.merge(_scoped.get("",{}),true)
|
|
196
|
+
if not self_only:
|
|
197
|
+
for name in _scoped.get(_owners.get(row,""),{}):
|
|
198
|
+
var item: Dictionary = _scoped[_owners.get(row,"")][name]
|
|
199
|
+
var visible: bool = item.get("row",0)<=row
|
|
200
|
+
for block in item.get("block",[]):
|
|
201
|
+
if not _blocks.get(row,[]).has(block): visible = false
|
|
202
|
+
if visible: result[name] = item
|
|
203
|
+
return result
|
|
204
|
+
func _value_members(value: Dictionary) -> Dictionary:
|
|
205
|
+
if value.get("self",false): return _scope_members(value.row,true)
|
|
206
|
+
var type: String = value.get("type","")
|
|
207
|
+
if type in ["","Variant","void"] or value.get("kind",-1)==CodeEdit.KIND_FUNCTION: return {}
|
|
208
|
+
return _members(type,value.get("aliases",_aliases))
|
|
209
|
+
# Parse only a postfix expression ending at 'end'. Calls skip balanced argument
|
|
210
|
+
# tokens, and use the callable's proven return declaration, never argument values.
|
|
211
|
+
func _chain(tokens: Array, end: int, row: int, depth: int = 0) -> Dictionary:
|
|
212
|
+
if end<0 or depth>=24: return {}
|
|
213
|
+
var token: Dictionary = tokens[end]
|
|
214
|
+
if token.text==")":
|
|
215
|
+
var closes := []
|
|
216
|
+
var opening := -1
|
|
217
|
+
for index in range(end,-1,-1):
|
|
218
|
+
var word: String = tokens[index].text
|
|
219
|
+
if tokens[index].kind=="string": continue
|
|
220
|
+
if word in [")","]","}"]: closes.append(word)
|
|
221
|
+
elif word in ["(","[","{"]:
|
|
222
|
+
if closes.is_empty() or closes.pop_back()!={"(":")","[":"]","{":"}"}[word]: return {}
|
|
223
|
+
if closes.is_empty(): opening = index; break
|
|
224
|
+
if opening<0: return {}
|
|
225
|
+
if opening>0 and (tokens[opening-1].text.is_valid_identifier() and tokens[opening-1].text not in Context.KEYWORDS or tokens[opening-1].text==")"):
|
|
226
|
+
var callable := _chain(tokens,opening-1,row,depth+1)
|
|
227
|
+
if callable.is_empty() or callable.value.get("kind",-1)!=CodeEdit.KIND_FUNCTION: return {}
|
|
228
|
+
var value: Dictionary = callable.value.duplicate()
|
|
229
|
+
value.kind = CodeEdit.KIND_VARIABLE
|
|
230
|
+
return {"start":callable.start,"value":value}
|
|
231
|
+
var grouped := _chain(tokens,end-1,row,depth+1)
|
|
232
|
+
if grouped.is_empty() or grouped.start!=opening+1: return {}
|
|
233
|
+
grouped.start = opening
|
|
234
|
+
return grouped
|
|
235
|
+
if not token.text.is_valid_identifier() or token.kind in ["string","tag","property"]: return {}
|
|
236
|
+
if end>0 and tokens[end-1].text==".":
|
|
237
|
+
var receiver := _chain(tokens,end-2,row,depth+1)
|
|
238
|
+
if receiver.is_empty(): return {}
|
|
239
|
+
var members := _value_members(receiver.value)
|
|
240
|
+
if not members.has(token.text): return {}
|
|
241
|
+
return {"start":receiver.start,"value":members[token.text]}
|
|
242
|
+
if token.text=="self": return {"start":end,"value":{"self":true,"row":row}}
|
|
243
|
+
var scope := _scope_members(row)
|
|
244
|
+
if scope.has(token.text):
|
|
245
|
+
# A preload alias is also a const declaration. Its empty value type must
|
|
246
|
+
# not hide the Script receiver; local/typed shadows remain authoritative.
|
|
247
|
+
if _aliases.has(token.text) and scope[token.text].kind == CodeEdit.KIND_CONSTANT and scope[token.text].get("owner","").is_empty() and scope[token.text].get("type","").is_empty():
|
|
248
|
+
return {"start":end,"value":{"type":token.text}}
|
|
249
|
+
return {"start":end,"value":scope[token.text]}
|
|
250
|
+
if ClassDB.class_exists(token.text) or _aliases.has(token.text): return {"start":end,"value":{"type":token.text}}
|
|
251
|
+
return {}
|
|
252
|
+
func _receiver_members(tokens: Array, end: int, row: int) -> Dictionary:
|
|
253
|
+
var receiver := _chain(tokens,end,row)
|
|
254
|
+
if receiver.is_empty(): return {}
|
|
255
|
+
# Do not infer from a suffix of an unsupported binary/index/cast expression.
|
|
256
|
+
if receiver.start>0 and tokens[receiver.start-1].text in [".","]","+","-","*","/","%","as","is"]: return {}
|
|
257
|
+
return _value_members(receiver.value)
|
|
258
|
+
func _callable_attribute(lexical: RefCounted, context: Dictionary, row: int, column: int) -> bool:
|
|
259
|
+
if context.frames.is_empty() or context.frames[-1].mode!="tag": return false
|
|
260
|
+
var tokens := _chain_tokens(lexical,row,column)
|
|
261
|
+
for index in range(tokens.size()-1,-1,-1):
|
|
262
|
+
if tokens[index].kind!="expression" or tokens[index].text!="{": continue
|
|
263
|
+
if index<2 or tokens[index-1].text!="=" or tokens[index-2].kind!="property": return false
|
|
264
|
+
var member: Dictionary = _members(context.frames[-1].tag,_aliases).get(tokens[index-2].text,{})
|
|
265
|
+
return member.get("kind",-1)==CodeEdit.KIND_SIGNAL or member.get("type","")=="Callable"
|
|
266
|
+
return false
|
|
267
|
+
func call_hint(text: String, source: String, lexical: RefCounted, row: int, column: int) -> String:
|
|
268
|
+
_index(text,source)
|
|
269
|
+
lexical.update(text)
|
|
270
|
+
var state: Dictionary = lexical.context(row,column)
|
|
271
|
+
if state.suppressed or state.mode!="gd": return ""
|
|
272
|
+
var tokens := _chain_tokens(lexical,row,column)
|
|
273
|
+
var depth := 0
|
|
274
|
+
for index in range(tokens.size()-1,-1,-1):
|
|
275
|
+
if tokens[index].kind=="string": continue
|
|
276
|
+
if tokens[index].text==")": depth += 1
|
|
277
|
+
if tokens[index].text!="(": continue
|
|
278
|
+
if depth>0: depth -= 1; continue
|
|
279
|
+
var callable := _chain(tokens,index-1,row)
|
|
280
|
+
return str(callable.value.get("hint","")) if not callable.is_empty() and callable.value.get("kind",-1)==CodeEdit.KIND_FUNCTION else ""
|
|
281
|
+
return ""
|
|
282
|
+
func _members(type: String, aliases: Dictionary, visited: Array = []) -> Dictionary:
|
|
283
|
+
var name: String = aliases.get(type,type)
|
|
284
|
+
if name == type and not ClassDB.class_exists(type):
|
|
285
|
+
var project_path := _project_path(type)
|
|
286
|
+
if not project_path.is_empty(): name = project_path
|
|
287
|
+
if name.is_empty() or name in visited or visited.size() >= 12: return {}
|
|
288
|
+
if ClassDB.class_exists(name):
|
|
289
|
+
if _native_cache.has(name): return _native_cache[name]
|
|
290
|
+
var result: Dictionary = {}
|
|
291
|
+
for prop in ClassDB.class_get_property_list(name):
|
|
292
|
+
if str(prop.name).is_valid_identifier() and not (int(prop.usage) & (PROPERTY_USAGE_CATEGORY|PROPERTY_USAGE_GROUP|PROPERTY_USAGE_SUBGROUP)):
|
|
293
|
+
result[prop.name] = {"type":_type_name(prop),"kind":CodeEdit.KIND_MEMBER,"value_type":prop.type,"writable":not (int(prop.usage)&PROPERTY_USAGE_READ_ONLY)}
|
|
294
|
+
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)}
|
|
295
|
+
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)}
|
|
296
|
+
# Native return/property identities cannot be redirected by an authored
|
|
297
|
+
# alias that happens to have the same spelling as the native class.
|
|
298
|
+
for member in result.values(): member.aliases = {}
|
|
299
|
+
_native_cache[name] = result
|
|
300
|
+
return result
|
|
301
|
+
if not name.begins_with("res://"):
|
|
302
|
+
for entry in ProjectSettings.get_global_class_list():
|
|
303
|
+
if entry["class"] == name: return _members(str(entry.path),{},visited+[name])
|
|
304
|
+
return {}
|
|
305
|
+
var authored := name.get_base_dir().get_base_dir().path_join(name.get_file().get_basename()+".gogo")
|
|
306
|
+
if name.get_base_dir().get_file()=="generated" and FileAccess.file_exists(name+".map.json") and not FileAccess.file_exists(authored): return {}
|
|
307
|
+
if name.get_base_dir().get_file() == "generated" and FileAccess.file_exists(authored): name = authored
|
|
308
|
+
if not FileAccess.file_exists(name): return {}
|
|
309
|
+
var declarations := _script(name)
|
|
310
|
+
var result := _members(declarations.base,declarations.aliases,visited+[name])
|
|
311
|
+
# Existing cached metadata only; never reload/new authored scripts.
|
|
312
|
+
if not sources.has(name):
|
|
313
|
+
var cached = metadata.get(name)
|
|
314
|
+
if cached == null and ResourceLoader.has_method("get_cached_ref"): cached = ResourceLoader.call("get_cached_ref",name)
|
|
315
|
+
if cached is Script and cached.source_code == _script_cache[name].text:
|
|
316
|
+
metadata_reads += 1
|
|
317
|
+
for prop in cached.get_script_property_list():
|
|
318
|
+
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)}
|
|
319
|
+
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)}
|
|
320
|
+
for field in declarations.scoped.get("",{}):
|
|
321
|
+
result[field] = declarations.scoped[""][field].duplicate()
|
|
322
|
+
result[field].aliases = declarations.aliases
|
|
323
|
+
return result
|
|
324
|
+
func _node_type(type: String, aliases: Dictionary, visited: Array = []) -> bool:
|
|
325
|
+
var name: String = aliases.get(type,type)
|
|
326
|
+
if name == type and not ClassDB.class_exists(type):
|
|
327
|
+
var project_path := _project_path(type)
|
|
328
|
+
if not project_path.is_empty(): return true
|
|
329
|
+
if name in visited or visited.size() >= 12: return false
|
|
330
|
+
if ClassDB.class_exists(name): return ClassDB.is_parent_class(name,"Node") and ClassDB.can_instantiate(name)
|
|
331
|
+
if not name.begins_with("res://"):
|
|
332
|
+
for entry in ProjectSettings.get_global_class_list():
|
|
333
|
+
if entry["class"] == name: return _node_type(str(entry.path),{},visited+[name])
|
|
334
|
+
return false
|
|
335
|
+
for item in _project_items():
|
|
336
|
+
if item.path == name: return true
|
|
337
|
+
var authored := name.get_base_dir().get_base_dir().path_join(name.get_file().get_basename()+".gogo")
|
|
338
|
+
if name.get_base_dir().get_file()=="generated" and FileAccess.file_exists(name+".map.json") and not FileAccess.file_exists(authored): return false
|
|
339
|
+
if name.get_base_dir().get_file() == "generated" and FileAccess.file_exists(authored): name = authored
|
|
340
|
+
if not FileAccess.file_exists(name): return false
|
|
341
|
+
var declarations := _script(name)
|
|
342
|
+
return not declarations.required_initializer and _node_type(declarations.base,declarations.aliases,visited+[name])
|
|
343
|
+
func _project_items() -> Array:
|
|
344
|
+
if project_index == null:
|
|
345
|
+
project_index = ProjectSources.new()
|
|
346
|
+
project_index.discover()
|
|
347
|
+
project_index.overrides = sources.duplicate()
|
|
348
|
+
if _path.ends_with(".gogo"): project_index.overrides[_path] = _text
|
|
349
|
+
var cache_key := _path+str(project_index.overrides.hash())
|
|
350
|
+
if _project_key == cache_key: return _project_items_cache
|
|
351
|
+
_project_key = cache_key
|
|
352
|
+
_project_items_cache = []
|
|
353
|
+
if not project_index.errors.is_empty(): return []
|
|
354
|
+
var paths: Array = project_index.sources.keys()
|
|
355
|
+
paths.sort()
|
|
356
|
+
for path in paths:
|
|
357
|
+
var authored: String = project_index.resource(path)
|
|
358
|
+
var name: String = str(path).get_file().get_basename()
|
|
359
|
+
if authored == _path or not name.is_valid_identifier(): continue
|
|
360
|
+
var source := Source.new("",_path,"",project_index)
|
|
361
|
+
var resolver := Resolver.new(source)
|
|
362
|
+
resolver.source_only = true
|
|
363
|
+
var output: String = project_index.resource(ProjectSources.output_for(path))
|
|
364
|
+
var info: Dictionary = resolver._gogo(name,output,authored,source.span(0))
|
|
365
|
+
if info.is_empty(): continue
|
|
366
|
+
_project_items_cache.append({"alias":name,"canonical":name+"Component","path":output,"source":authored,"native":info.native})
|
|
367
|
+
return _project_items_cache
|
|
368
|
+
func _project_path(name: String) -> String:
|
|
369
|
+
if _symbols.has(name) or ClassDB.class_exists(name): return ""
|
|
370
|
+
var matches := []
|
|
371
|
+
for item in _project_items():
|
|
372
|
+
if item.alias == name: matches.append(item)
|
|
373
|
+
for entry in ProjectSettings.get_global_class_list():
|
|
374
|
+
if str(entry["class"])==name and FileAccess.file_exists(str(entry.path)) and (matches.size()!=1 or str(entry.path)!=matches[0].path): return ""
|
|
375
|
+
return matches[0].path if matches.size()==1 else ""
|
|
376
|
+
func _project_options(prefix: String) -> Dictionary:
|
|
377
|
+
var result := {}
|
|
378
|
+
for item in _project_items():
|
|
379
|
+
var alias: String = Imports.alias_for(item,_symbols,_aliases)
|
|
380
|
+
if not str(item.alias).begins_with(prefix) and not alias.begins_with(prefix): continue
|
|
381
|
+
var label: String = item.alias+" — Gogo Component — "+item.source+" ("+item.native+")"
|
|
382
|
+
result[label] = {"kind":CodeEdit.KIND_CLASS,"insert":alias,"import":{"alias":alias,"path":item.path},"match":prefix}
|
|
383
|
+
return result
|
|
384
|
+
func _catalog_options(prefix: String, tags: bool) -> Dictionary:
|
|
385
|
+
var result: Dictionary = {}
|
|
386
|
+
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)
|
|
387
|
+
for item in Catalog.ITEMS:
|
|
388
|
+
if tags and (item.dimension == 0 or dimension != 0 and item.dimension != dimension): continue
|
|
389
|
+
if not tags and item.dimension != 0: continue
|
|
390
|
+
var alias: String = Imports.alias_for(item,_symbols,_aliases)
|
|
391
|
+
var label: String = item.canonical if str(item.canonical).begins_with(prefix) and not str(item.alias).begins_with(prefix) else item.alias
|
|
392
|
+
if not label.begins_with(prefix) and not alias.begins_with(prefix): continue
|
|
393
|
+
if alias != item.alias: label += " (as "+alias+")"
|
|
394
|
+
result[label+" — "+item.canonical+" ("+item.origin+")"] = {"kind":CodeEdit.KIND_CLASS,"insert":alias,"import":{"alias":alias,"path":Catalog.path(item)},"match":prefix}
|
|
395
|
+
return result
|
|
396
|
+
func _path_options(left: String, context: Dictionary, source: String, row: int, column: int) -> Array:
|
|
397
|
+
if context.quote.length() != 1: return []
|
|
398
|
+
var start := -1
|
|
399
|
+
for token in context.tokens:
|
|
400
|
+
if token.kind == "string" and token.text == context.quote: start = token.start
|
|
401
|
+
if start < 0: return []
|
|
402
|
+
var before := left.left(start).strip_edges()
|
|
403
|
+
var tokens := _tokens(before)
|
|
404
|
+
if tokens.is_empty(): return []
|
|
405
|
+
var allowed: bool = tokens[-1].text == "extends" or tokens.size() >= 2 and tokens[-1].text == "(" and tokens[-2].text in ["load","preload"]
|
|
406
|
+
if not allowed: return []
|
|
407
|
+
var value := left.substr(start+1)
|
|
408
|
+
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 []
|
|
409
|
+
var base := Build.output_for(source).get_base_dir()
|
|
410
|
+
var slash := value.rfind("/")
|
|
411
|
+
var directory := value.left(slash+1) if slash >= 0 else ""
|
|
412
|
+
var prefix := value.substr(slash+1)
|
|
413
|
+
var target := directory if directory.begins_with("res://") else base.path_join(directory).simplify_path()
|
|
414
|
+
if not target.begins_with("res://") or target.contains("/../"): return []
|
|
415
|
+
for part in target.trim_prefix("res://").split("/"):
|
|
416
|
+
if part.begins_with("."): return []
|
|
417
|
+
if target != "res://":
|
|
418
|
+
var containment := Build.new()
|
|
419
|
+
containment._project = ProjectSettings.globalize_path("res://").trim_suffix("/")
|
|
420
|
+
if not containment._safe(ProjectSettings.globalize_path(target).trim_suffix("/")): return []
|
|
421
|
+
var access := DirAccess.open(target)
|
|
422
|
+
if access == null: return []
|
|
423
|
+
var result: Array = []
|
|
424
|
+
var extensions := ResourceLoader.get_recognized_extensions_for_type("")
|
|
425
|
+
access.list_dir_begin()
|
|
426
|
+
var name := access.get_next()
|
|
427
|
+
while not name.is_empty() and result.size() < 256:
|
|
428
|
+
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):
|
|
429
|
+
var is_dir := access.current_is_dir()
|
|
430
|
+
var insert: String = context.quote+directory+name+("/" if is_dir else context.quote)
|
|
431
|
+
result.append({"text":insert,"insert":insert,"kind":CodeEdit.KIND_FILE_PATH,"row":row,"start":start,"column":column,"path":true})
|
|
432
|
+
name = access.get_next()
|
|
433
|
+
access.list_dir_end()
|
|
434
|
+
return result
|
|
435
|
+
func import_plan(text: String, source: String, requests: Array = []) -> Dictionary:
|
|
436
|
+
_index(text,source)
|
|
437
|
+
if requests.is_empty():
|
|
438
|
+
var lexical := Context.new()
|
|
439
|
+
lexical.update(text)
|
|
440
|
+
for row in range(lexical.lines.size()):
|
|
441
|
+
for token in lexical.line(row).tokens:
|
|
442
|
+
if token.kind != "tag" or not token.text.is_valid_identifier(): continue
|
|
443
|
+
var item := Catalog.named(token.text)
|
|
444
|
+
if not item.is_empty() and item.dimension != 0 and not _symbols.has(token.text): requests.append({"alias":token.text,"path":Catalog.path(item)})
|
|
445
|
+
if item.is_empty() and not _project_path(token.text).is_empty(): requests.append({"alias":token.text,"path":_project_path(token.text)})
|
|
446
|
+
return Imports.plan(text,source,requests,_symbols,_aliases,_tokens(text))
|
|
447
|
+
func definition(text: String, source: String, symbol: String) -> String:
|
|
448
|
+
_index(text,source)
|
|
449
|
+
var target: String = _aliases.get(symbol,_project_path(symbol))
|
|
450
|
+
for item in _project_items():
|
|
451
|
+
if item.path == target: return item.source
|
|
452
|
+
return target
|
|
453
|
+
func candidates(text: String, source: String, lexical: RefCounted, row: int, column: int) -> Array:
|
|
454
|
+
_index(text,source)
|
|
455
|
+
lexical.update(text)
|
|
456
|
+
var context: Dictionary = lexical.context(row,column)
|
|
457
|
+
if context.suppressed: return _path_options(lexical.lines[row].left(column),context,source,row,column)
|
|
458
|
+
var left: String = lexical.lines[row].left(column)
|
|
459
|
+
var prefix := ""
|
|
460
|
+
var cursor := left.length()-1
|
|
461
|
+
while cursor >= 0 and (left[cursor].is_valid_identifier() or left[cursor].is_valid_int() or left[cursor] == ":"):
|
|
462
|
+
prefix = left[cursor]+prefix
|
|
463
|
+
cursor -= 1
|
|
464
|
+
if context.mode == "tag" and context.closing: prefix = "/"+prefix
|
|
465
|
+
var member_cursor := cursor
|
|
466
|
+
while member_cursor>=0 and left[member_cursor] in [" ","\t"]: member_cursor -= 1
|
|
467
|
+
var offered: Dictionary = {}
|
|
468
|
+
if context.mode == "tag":
|
|
469
|
+
if context.closing:
|
|
470
|
+
if not context.tags.is_empty(): offered["/"+context.tags[-1]] = {"kind":CodeEdit.KIND_CLASS}
|
|
471
|
+
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"):
|
|
472
|
+
for name in _classes:
|
|
473
|
+
if ClassDB.is_parent_class(name,"Node") and ClassDB.can_instantiate(name): offered[name] = {"kind":CodeEdit.KIND_CLASS}
|
|
474
|
+
for name in _aliases:
|
|
475
|
+
if _node_type(name,_aliases): offered[name] = {"kind":CodeEdit.KIND_CLASS,"origin":"explicit Node preload"}
|
|
476
|
+
for entry in ProjectSettings.get_global_class_list():
|
|
477
|
+
var known := Catalog.named(str(entry["class"]))
|
|
478
|
+
if not known.is_empty() and Catalog.path(known) == str(entry.path): continue
|
|
479
|
+
if str(entry["class"]).begins_with(prefix) and _node_type(str(entry["class"]),{}): offered[entry["class"]] = {"kind":CodeEdit.KIND_CLASS,"origin":"project Node"}
|
|
480
|
+
for item in Catalog.ITEMS:
|
|
481
|
+
for alias in _aliases:
|
|
482
|
+
if _aliases[alias] == Catalog.path(item): offered.erase(alias)
|
|
483
|
+
offered.merge(_catalog_options(prefix,true))
|
|
484
|
+
# A bare native/global spelling with a project collision would fail
|
|
485
|
+
# compilation. Offer a source-qualified explicit choice instead.
|
|
486
|
+
var project_items := _project_items()
|
|
487
|
+
if not project_items.is_empty():
|
|
488
|
+
for name in offered.keys():
|
|
489
|
+
if not _aliases.has(name) and not project_index.named(str(name)).is_empty(): offered.erase(name)
|
|
490
|
+
offered.merge(_project_options(prefix))
|
|
491
|
+
else:
|
|
492
|
+
if not _node_type(context.tag,_aliases): return []
|
|
493
|
+
var members := _members(context.tag,_aliases)
|
|
494
|
+
for name in members:
|
|
495
|
+
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]
|
|
496
|
+
if _node_type(context.tag,_aliases): offered.key = {"kind":CodeEdit.KIND_MEMBER}
|
|
497
|
+
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}
|
|
498
|
+
elif context.mode == "body": return []
|
|
499
|
+
elif member_cursor >= 0 and left[member_cursor] == ".":
|
|
500
|
+
var tokens := _chain_tokens(lexical,row,member_cursor)
|
|
501
|
+
offered = _receiver_members(tokens,tokens.size()-1,row)
|
|
502
|
+
|
|
503
|
+
else:
|
|
504
|
+
for word in Context.KEYWORDS: offered[word] = {"kind":CodeEdit.KIND_PLAIN_TEXT}
|
|
505
|
+
for name in _classes: offered[name] = {"kind":CodeEdit.KIND_CLASS}
|
|
506
|
+
for native_type in range(1,TYPE_MAX):
|
|
507
|
+
var type_name: String = _types._native_type({"type":native_type})
|
|
508
|
+
if not type_name.is_empty(): offered[type_name] = {"kind":CodeEdit.KIND_CLASS}
|
|
509
|
+
offered.Variant = {"kind":CodeEdit.KIND_CLASS}
|
|
510
|
+
for entry in ProjectSettings.get_global_class_list(): offered[entry["class"]] = {"kind":CodeEdit.KIND_CLASS}
|
|
511
|
+
for field in _symbols:
|
|
512
|
+
if _symbols[field].owner.is_empty() or _symbols[field].owner == _owners.get(row,""): offered[field] = _symbols[field]
|
|
513
|
+
offered.merge(_members(_base,_aliases),false)
|
|
514
|
+
offered.merge(_catalog_options(prefix,false))
|
|
515
|
+
if cursor >= 0 and left[cursor] == "@":
|
|
516
|
+
offered.clear()
|
|
517
|
+
for name in ["bindable","tool","export","export_range","onready","warning_ignore"]: offered[name] = {"kind":CodeEdit.KIND_PLAIN_TEXT}
|
|
518
|
+
var result: Array = []
|
|
519
|
+
var callable_attribute: bool = context.mode=="gd" and _callable_attribute(lexical,context,row,column)
|
|
520
|
+
for name in offered:
|
|
521
|
+
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)):
|
|
522
|
+
var item: Dictionary = offered[name]
|
|
523
|
+
var insert: String = item.get("insert",str(name).trim_prefix("bind:") if prefix.begins_with("bind:") else str(name))
|
|
524
|
+
if context.mode=="gd" and member_cursor>=0 and left[member_cursor]=="." and item.kind==CodeEdit.KIND_FUNCTION and not callable_attribute and not lexical.lines[row].substr(column).strip_edges().begins_with("("):
|
|
525
|
+
insert += "()"
|
|
526
|
+
var display: String = str(name) if item.has("import") else (str(name)+" — "+str(item.origin) if item.has("origin") else str(name))
|
|
527
|
+
if context.mode == "tag" and item.kind == CodeEdit.KIND_MEMBER and not str(item.get("type","")).is_empty(): display += " — "+str(item.type)
|
|
528
|
+
if context.mode == "tag" and not item.has("import") and ClassDB.class_exists(insert): display += " — Godot "+ClassDB.get_parent_class(insert)
|
|
529
|
+
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 []})
|
|
530
|
+
result.sort_custom(func(a,b): return a.text < b.text)
|
|
531
|
+
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,20 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends RefCounted
|
|
3
|
+
## Trusted installed resources, not guessed global classes or installation roots.
|
|
4
|
+
const ITEMS := [
|
|
5
|
+
{"alias":"Spacer","canonical":"EstragonSpacer","script":preload("../runtime/node/spacer.gd"),"dimension":2,"origin":"native layout"},
|
|
6
|
+
{"alias":"Box","canonical":"EstragonBox","script":preload("../runtime/node/box.gd"),"dimension":2,"origin":"native layout"},
|
|
7
|
+
{"alias":"Text","canonical":"EstragonText","script":preload("../runtime/node/text.gd"),"dimension":2,"origin":"native widget"},
|
|
8
|
+
{"alias":"Rect","canonical":"EstragonRect","script":preload("../runtime/node/rect.gd"),"dimension":2,"origin":"native widget"},
|
|
9
|
+
{"alias":"UiButton","canonical":"EstragonButton","script":preload("../runtime/node/button.gd"),"dimension":2,"origin":"native widget"},
|
|
10
|
+
{"alias":"VBox","canonical":"EstragonVBox","script":preload("../runtime/node/vbox.gd"),"dimension":2,"origin":"native layout"},
|
|
11
|
+
{"alias":"HBox","canonical":"EstragonHBox","script":preload("../runtime/node/hbox.gd"),"dimension":2,"origin":"native layout"},
|
|
12
|
+
{"alias":"Entry2D","canonical":"Estragon2D","script":preload("../runtime/node/estragon_2d.gd"),"dimension":2,"origin":"layout entry"},
|
|
13
|
+
{"alias":"Entry3D","canonical":"Estragon3D","script":preload("../runtime/node/estragon_3d.gd"),"dimension":3,"origin":"layout entry"},
|
|
14
|
+
{"alias":"Element","canonical":"Element","script":preload("../runtime/composition/element.gd"),"dimension":0,"origin":"GGX description type"}
|
|
15
|
+
]
|
|
16
|
+
static func path(item: Dictionary) -> String: return item.path if item.has("path") else (item.script as Script).resource_path
|
|
17
|
+
static func named(name: String) -> Dictionary:
|
|
18
|
+
for item in ITEMS:
|
|
19
|
+
if name in [item.alias,item.canonical]: return item
|
|
20
|
+
return {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://1lt6a67tepd
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends EditorContextMenuPlugin
|
|
3
|
+
## Parsed only when the public native context-menu API is available.
|
|
4
|
+
var create: Callable
|
|
5
|
+
var root_context := false
|
|
6
|
+
func _popup_menu(paths: PackedStringArray) -> void:
|
|
7
|
+
root_context = paths.is_empty()
|
|
8
|
+
var prefix := "New " if paths.is_empty() else ""
|
|
9
|
+
add_context_menu_item(prefix+"Gogo Component (2D)…",_selected.bind(false))
|
|
10
|
+
add_context_menu_item(prefix+"Gogo Component (3D)…",_selected.bind(true))
|
|
11
|
+
func _selected(paths: PackedStringArray, spatial: bool) -> void:
|
|
12
|
+
# The engine supplies a current directory to callbacks even when popup
|
|
13
|
+
# paths were empty. Empty-space creation deliberately starts at project root.
|
|
14
|
+
if create.is_valid(): create.call(paths[0] if not root_context and not paths.is_empty() else "res://",spatial)
|