@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 +6 -2
- package/README.md +2 -0
- package/addons/estragon/compiler/emitter.gd +1 -5
- package/addons/estragon/compiler/source.gd +8 -0
- package/addons/estragon/editor/build_service.gd +36 -4
- package/addons/estragon/editor/completion.gd +334 -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 +18 -0
- package/addons/estragon/editor/components.gd.uid +1 -0
- package/addons/estragon/editor/highlighter.gd +62 -103
- package/addons/estragon/editor/highlighter_association.gd +10 -1
- package/addons/estragon/editor/imports.gd +47 -0
- package/addons/estragon/editor/imports.gd.uid +1 -0
- package/addons/estragon/editor/language_services.gd +286 -0
- package/addons/estragon/editor/language_services.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 +88 -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 +53 -4
- package/package.json +1 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends RefCounted
|
|
3
|
+
## Tolerant, line-cached editor contexts. Shares native identifier/operator and
|
|
4
|
+
## expression-start rules; never substitutes source or executes authored code.
|
|
5
|
+
const Lexer = preload("../compiler/lexer.gd")
|
|
6
|
+
const Source = preload("../compiler/source.gd")
|
|
7
|
+
const Parser = preload("../compiler/parser.gd")
|
|
8
|
+
const KEYWORDS := ["extends", "class_name", "class", "func", "static", "var", "const", "return", "if", "elif", "else", "for", "in", "while", "await", "signal", "true", "false", "null", "pass", "and", "or", "not", "as", "is", "self", "match", "break", "continue", "assert", "enum", "preload", "load", "super", "get", "set", "when", "void"]
|
|
9
|
+
var lines: PackedStringArray = []
|
|
10
|
+
var records: Array = []
|
|
11
|
+
var scanned_lines := 0
|
|
12
|
+
|
|
13
|
+
func update(text: String) -> void:
|
|
14
|
+
var next := text.split("\n")
|
|
15
|
+
var same := 0
|
|
16
|
+
while same < mini(lines.size(), next.size()) and lines[same] == next[same]: same += 1
|
|
17
|
+
records.resize(mini(same, records.size()))
|
|
18
|
+
lines = next
|
|
19
|
+
|
|
20
|
+
static func initial() -> Dictionary:
|
|
21
|
+
return {"mode":"gd", "quote":"", "comment":false, "tags":[], "islands":[], "frames":[], "operand":true, "depth":0, "declared":[], "tag":"", "closing":false, "name_pending":false}
|
|
22
|
+
|
|
23
|
+
func line(index: int) -> Dictionary:
|
|
24
|
+
while records.size() <= index and records.size() < lines.size():
|
|
25
|
+
var state: Dictionary = initial() if records.is_empty() else records[-1].state.duplicate(true)
|
|
26
|
+
records.append(scan(lines[records.size()], state))
|
|
27
|
+
scanned_lines += 1
|
|
28
|
+
return records[index] if index >= 0 and index < records.size() else {"tokens":[], "state":initial()}
|
|
29
|
+
|
|
30
|
+
func context(index: int, column: int) -> Dictionary:
|
|
31
|
+
if index > 0: line(index - 1)
|
|
32
|
+
var state: Dictionary = initial() if index == 0 else records[index - 1].state.duplicate(true)
|
|
33
|
+
var result := scan(lines[index].left(column), state, false)
|
|
34
|
+
var end: Dictionary = result.state
|
|
35
|
+
end["tokens"] = result.tokens
|
|
36
|
+
end["suppressed"] = end.comment or not end.quote.is_empty()
|
|
37
|
+
return end
|
|
38
|
+
|
|
39
|
+
static func _add(tokens: Array, kind: String, start: int, end: int, word: String, native: bool = true) -> void:
|
|
40
|
+
if end > start: tokens.append({"kind":kind, "start":start, "end":end, "text":word,"native":native})
|
|
41
|
+
|
|
42
|
+
func scan(text: String, state: Dictionary, newline: bool = true) -> Dictionary:
|
|
43
|
+
var tokens: Array = []
|
|
44
|
+
var lexer := Lexer.new(Source.new(text))
|
|
45
|
+
var i := 0
|
|
46
|
+
var previous := ""
|
|
47
|
+
while i < text.length():
|
|
48
|
+
var start := i
|
|
49
|
+
var ch := text[i]
|
|
50
|
+
if state.comment:
|
|
51
|
+
var end := text.find("-->", i)
|
|
52
|
+
i = text.length() if end < 0 else end + 3
|
|
53
|
+
_add(tokens,"comment",start,i,text.substr(start,i-start),false)
|
|
54
|
+
if end >= 0: state.comment = false
|
|
55
|
+
continue
|
|
56
|
+
if not state.quote.is_empty():
|
|
57
|
+
var delimiter: String = state.quote
|
|
58
|
+
while i < text.length():
|
|
59
|
+
if text[i] == "\\": i = mini(text.length(), i + 2)
|
|
60
|
+
elif text.substr(i,delimiter.length()) == delimiter:
|
|
61
|
+
i += delimiter.length()
|
|
62
|
+
state.quote = ""
|
|
63
|
+
break
|
|
64
|
+
else: i += 1
|
|
65
|
+
_add(tokens,"string",start,i,text.substr(start,i-start),state.mode == "gd")
|
|
66
|
+
state.operand = false
|
|
67
|
+
continue
|
|
68
|
+
if ch in [" ","\t","\r"]: i += 1; continue
|
|
69
|
+
if state.mode != "gd" and text.substr(i,4) == "<!--":
|
|
70
|
+
state.comment = true
|
|
71
|
+
i += 4
|
|
72
|
+
_add(tokens,"comment",start,i,"<!--",false)
|
|
73
|
+
continue
|
|
74
|
+
if state.mode == "gd" and ch == "#":
|
|
75
|
+
_add(tokens,"comment",i,text.length(),text.substr(i))
|
|
76
|
+
if not newline: state.comment = true
|
|
77
|
+
i = text.length()
|
|
78
|
+
continue
|
|
79
|
+
if ch in ['"',"'"]:
|
|
80
|
+
state.quote = ch.repeat(3) if text.substr(i,3) == ch.repeat(3) else ch
|
|
81
|
+
i += state.quote.length()
|
|
82
|
+
_add(tokens,"string",start,i,text.substr(start,i-start))
|
|
83
|
+
continue
|
|
84
|
+
if ch == "<" and (state.mode == "body" or state.mode == "gd" and state.operand and (i+1 == text.length() or lexer.identifier_start(lexer.char_at(i+1)))):
|
|
85
|
+
if state.mode == "gd": state.islands.append(state.tags.size())
|
|
86
|
+
state.mode = "tag"
|
|
87
|
+
state.closing = text.substr(i,2) == "</"
|
|
88
|
+
state.tag = ""
|
|
89
|
+
state.name_pending = true
|
|
90
|
+
i += 2 if state.closing else 1
|
|
91
|
+
_add(tokens,"tag",start,i,text.substr(start,i-start),false)
|
|
92
|
+
continue
|
|
93
|
+
if state.mode == "tag":
|
|
94
|
+
if text.substr(i,2) == "/>" or ch == ">":
|
|
95
|
+
var self_closing := text.substr(i,2) == "/>"
|
|
96
|
+
i += 2 if self_closing else 1
|
|
97
|
+
_add(tokens,"tag",start,i,text.substr(start,i-start))
|
|
98
|
+
if state.closing:
|
|
99
|
+
if not state.tags.is_empty(): state.tags.pop_back()
|
|
100
|
+
elif not self_closing: state.tags.append(state.tag)
|
|
101
|
+
if not state.islands.is_empty() and state.tags.size() == state.islands[-1]:
|
|
102
|
+
state.islands.pop_back()
|
|
103
|
+
state.mode = "gd"
|
|
104
|
+
else: state.mode = "body" if not state.tags.is_empty() else "gd"
|
|
105
|
+
state.operand = false
|
|
106
|
+
continue
|
|
107
|
+
if lexer.identifier_start(ch):
|
|
108
|
+
i += 1
|
|
109
|
+
while i < text.length() and (lexer.identifier_part(text[i]) or text[i] in [".",":","-"]): i += 1
|
|
110
|
+
var name := text.substr(start,i-start)
|
|
111
|
+
_add(tokens,"tag" if state.name_pending else "property",start,i,name,false)
|
|
112
|
+
if state.name_pending: state.tag = name; state.name_pending = false
|
|
113
|
+
continue
|
|
114
|
+
if state.mode != "gd" and ch == "{":
|
|
115
|
+
state.frames.append({"mode":state.mode,"depth":state.depth,"tag":state.tag,"closing":state.closing,"name_pending":state.name_pending})
|
|
116
|
+
state.mode = "gd"
|
|
117
|
+
state.depth = 0
|
|
118
|
+
state.operand = true
|
|
119
|
+
_add(tokens,"expression",i,i+1,ch,false)
|
|
120
|
+
i += 1
|
|
121
|
+
continue
|
|
122
|
+
if state.mode == "gd" and ch == "}" and state.depth == 0 and not state.frames.is_empty():
|
|
123
|
+
var frame: Dictionary = state.frames.pop_back()
|
|
124
|
+
state.mode = frame.mode
|
|
125
|
+
state.depth = frame.depth
|
|
126
|
+
state.tag = frame.tag
|
|
127
|
+
state.closing = frame.closing
|
|
128
|
+
state.name_pending = frame.name_pending
|
|
129
|
+
_add(tokens,"expression",i,i+1,ch)
|
|
130
|
+
i += 1
|
|
131
|
+
continue
|
|
132
|
+
if state.mode == "body":
|
|
133
|
+
_add(tokens,"code",i,i+1,ch,false)
|
|
134
|
+
i += 1
|
|
135
|
+
continue
|
|
136
|
+
var token = lexer.next_token(i)
|
|
137
|
+
if token == null: i += 1; continue
|
|
138
|
+
i = token.span.end.index
|
|
139
|
+
var word: String = token.text
|
|
140
|
+
var kind := "symbol"
|
|
141
|
+
if token.kind == "identifier":
|
|
142
|
+
kind = "keyword" if word in KEYWORDS else "code"
|
|
143
|
+
if previous == "@": kind = "annotation"
|
|
144
|
+
elif previous in ["func","signal"] or text.substr(i).strip_edges().begins_with("(") and kind == "code": kind = "function"
|
|
145
|
+
elif kind == "code" and (ClassDB.class_exists(word) or word in state.declared or word in ["int","float","bool","String","Array","Dictionary","Vector2","Vector3","Color","Callable","StringName","NodePath"] or previous in [":","->","extends","class_name","class"]): kind = "type"
|
|
146
|
+
if previous in ["class_name","class"] or previous == "const" and text.substr(i).strip_edges().begins_with("= preload("):
|
|
147
|
+
if word not in state.declared: state.declared.append(word)
|
|
148
|
+
state.operand = word in Parser.OPERANDS
|
|
149
|
+
elif token.kind == "number": kind = "number"; state.operand = false
|
|
150
|
+
else:
|
|
151
|
+
if word in ["(","[","{"]: state.depth += 1
|
|
152
|
+
elif word in [")","]","}"]: state.depth = maxi(0,state.depth-1)
|
|
153
|
+
state.operand = word not in [".",")","]","}"]
|
|
154
|
+
_add(tokens,kind,start,i,word,state.mode == "gd")
|
|
155
|
+
previous = word
|
|
156
|
+
if newline:
|
|
157
|
+
if state.quote.length() == 1: state.quote = ""
|
|
158
|
+
if state.mode == "gd" and state.depth == 0 and state.frames.is_empty(): state.operand = true
|
|
159
|
+
return {"tokens":tokens,"state":state}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://8z7w8jx076b
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends RefCounted
|
|
3
|
+
## TextFile opening has no public ScriptEditor entry point on 4.0.
|
|
4
|
+
## Activate only a native FileSystemDock item authenticated by its full path.
|
|
5
|
+
## No private method, guessed basename/index, or menu injection is used.
|
|
6
|
+
var interface: EditorInterface
|
|
7
|
+
var active := true
|
|
8
|
+
func _init(editor_interface: EditorInterface) -> void: interface = editor_interface
|
|
9
|
+
func stop() -> void: active = false
|
|
10
|
+
func open(path: String) -> void:
|
|
11
|
+
if not active or not path.begins_with("res://") or not FileAccess.file_exists(path): return
|
|
12
|
+
var version := Engine.get_version_info()
|
|
13
|
+
if version.major != 4 or version.minor > 7:
|
|
14
|
+
interface.select_file(path)
|
|
15
|
+
return
|
|
16
|
+
var dock := interface.get_file_system_dock()
|
|
17
|
+
dock.navigate_to_path(path)
|
|
18
|
+
var deadline := Time.get_ticks_msec()+5000
|
|
19
|
+
while active and Time.get_ticks_msec() < deadline:
|
|
20
|
+
for tree in dock.find_children("*","Tree",true,false):
|
|
21
|
+
var selected: TreeItem = tree.get_selected()
|
|
22
|
+
if selected != null and selected.get_metadata(0) is String and selected.get_metadata(0) == path:
|
|
23
|
+
tree.item_activated.emit()
|
|
24
|
+
return
|
|
25
|
+
for list in dock.find_children("*","ItemList",true,false):
|
|
26
|
+
for index in list.get_selected_items():
|
|
27
|
+
if list.get_item_metadata(index) is String and list.get_item_metadata(index) == path:
|
|
28
|
+
list.item_activated.emit(index)
|
|
29
|
+
return
|
|
30
|
+
await dock.get_tree().process_frame
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://i3yzit6qp5q
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends RefCounted
|
|
3
|
+
## User-invoked creation only. Never overwrites source or edits project config.
|
|
4
|
+
const Build = preload("build_service.gd")
|
|
5
|
+
const Source = preload("../compiler/source.gd")
|
|
6
|
+
const Element = preload("../runtime/composition/element.gd")
|
|
7
|
+
const Entry2D = preload("../runtime/node/estragon_2d.gd")
|
|
8
|
+
const Entry3D = preload("../runtime/node/estragon_3d.gd")
|
|
9
|
+
const Text = preload("../runtime/node/text.gd")
|
|
10
|
+
var dialog: Variant
|
|
11
|
+
var dimension: OptionButton
|
|
12
|
+
var error: AcceptDialog
|
|
13
|
+
var interface: EditorInterface
|
|
14
|
+
var navigation: RefCounted
|
|
15
|
+
var active := true
|
|
16
|
+
func _init(editor_interface: EditorInterface, navigator: RefCounted) -> void:
|
|
17
|
+
interface = editor_interface
|
|
18
|
+
navigation = navigator
|
|
19
|
+
func start(parent: Node) -> void:
|
|
20
|
+
# 4.0 registers EditorFileDialog abstract; do not reference its unavailable
|
|
21
|
+
# constructor even in a dead branch. Both paths use public native dialogs.
|
|
22
|
+
dialog = ClassDB.instantiate("EditorFileDialog") if ClassDB.can_instantiate("EditorFileDialog") else FileDialog.new()
|
|
23
|
+
dialog.name = "NewGogoScript"
|
|
24
|
+
if dialog is FileDialog: dialog.mode_overrides_title = false
|
|
25
|
+
dialog.title = "New Gogo Script (never overwrites source)"
|
|
26
|
+
dialog.access = EditorFileDialog.ACCESS_RESOURCES
|
|
27
|
+
dialog.file_mode = EditorFileDialog.FILE_MODE_SAVE_FILE
|
|
28
|
+
if dialog is EditorFileDialog: dialog.disable_overwrite_warning = true
|
|
29
|
+
dialog.add_filter("*.gogo","Gogo Script")
|
|
30
|
+
dimension = OptionButton.new()
|
|
31
|
+
dimension.name = "GogoTemplate"
|
|
32
|
+
dimension.add_item("Node2D — native layout and text")
|
|
33
|
+
dimension.add_item("Node3D — native spatial layout")
|
|
34
|
+
dialog.get_vbox().add_child(dimension)
|
|
35
|
+
dialog.file_selected.connect(_selected)
|
|
36
|
+
parent.add_child(dialog)
|
|
37
|
+
error = AcceptDialog.new()
|
|
38
|
+
error.title = "New Gogo Script"
|
|
39
|
+
parent.add_child(error)
|
|
40
|
+
func show_dialog() -> void:
|
|
41
|
+
if not active: return
|
|
42
|
+
var directory := interface.get_current_directory()
|
|
43
|
+
if not directory.begins_with("res://"): directory = "res://"
|
|
44
|
+
if FileAccess.file_exists("res://gogo.config.json"):
|
|
45
|
+
var config = JSON.parse_string(FileAccess.get_file_as_string("res://gogo.config.json"))
|
|
46
|
+
if config is Dictionary and config.get("source_roots") is Array and not config.source_roots.is_empty():
|
|
47
|
+
var root = config.source_roots[0]
|
|
48
|
+
if root is String:
|
|
49
|
+
var preferred: String = "res://"+root
|
|
50
|
+
if preferred.ends_with(".gogo"): preferred = preferred.get_base_dir()
|
|
51
|
+
if DirAccess.dir_exists_absolute(preferred): directory = preferred
|
|
52
|
+
dialog.current_dir = directory
|
|
53
|
+
dialog.current_file = "NewScript.gogo"
|
|
54
|
+
dialog.popup_centered_ratio(0.65)
|
|
55
|
+
static func template(path: String, spatial: bool) -> String:
|
|
56
|
+
var directory := Build.output_for(path).get_base_dir()
|
|
57
|
+
var element := JSON.stringify(Source.relative_path(directory,(Element as Script).resource_path))
|
|
58
|
+
var entry := JSON.stringify(Source.relative_path(directory,((Entry3D if spatial else Entry2D) as Script).resource_path))
|
|
59
|
+
var result := "extends "+("Node3D" if spatial else "Node2D")+"\nconst Element = preload("+element+")\nconst Entry = preload("+entry+")\n"
|
|
60
|
+
if spatial:
|
|
61
|
+
return result+"\nfunc build_view() -> Element:\n\treturn <Entry name=\"Layout\" width={4.0} height={2.0} depth={1.0} />\n"
|
|
62
|
+
var text := JSON.stringify(Source.relative_path(directory,(Text as Script).resource_path))
|
|
63
|
+
return result+"const Text = preload("+text+")\n\nfunc build_view() -> Element:\n\treturn <Entry name=\"UI\" viewport_width_scale={0.9}>\n\t\t<Text name=\"Greeting\" text=\"Hello Gogo\" />\n\t</Entry>\n"
|
|
64
|
+
func _selected(path: String) -> void:
|
|
65
|
+
if not active: return
|
|
66
|
+
if path.get_extension().is_empty(): path += ".gogo"
|
|
67
|
+
var check := Build.creation_check(path)
|
|
68
|
+
if not check.ok:
|
|
69
|
+
error.dialog_text = check.message
|
|
70
|
+
error.popup_centered()
|
|
71
|
+
return
|
|
72
|
+
var file := FileAccess.open(path,FileAccess.WRITE)
|
|
73
|
+
if file == null:
|
|
74
|
+
error.dialog_text = "Cannot create "+path+": "+error_string(FileAccess.get_open_error())
|
|
75
|
+
error.popup_centered()
|
|
76
|
+
return
|
|
77
|
+
file.store_string(template(path,dimension.selected == 1))
|
|
78
|
+
file.close()
|
|
79
|
+
interface.get_resource_filesystem().scan()
|
|
80
|
+
_open_after_scan(path)
|
|
81
|
+
func _open_after_scan(path: String) -> void:
|
|
82
|
+
var filesystem := interface.get_resource_filesystem()
|
|
83
|
+
while active and filesystem.is_scanning(): await dialog.get_tree().process_frame
|
|
84
|
+
if active: navigation.open(path)
|
|
85
|
+
func stop() -> void:
|
|
86
|
+
active = false
|
|
87
|
+
if dialog != null: dialog.free(); dialog = null
|
|
88
|
+
if error != null: error.free(); error = null
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://b96jihgasld
|
|
@@ -6,6 +6,12 @@ const BufferGuard = preload("buffer_guard.gd")
|
|
|
6
6
|
const BuildService = preload("build_service.gd")
|
|
7
7
|
const HighlighterAssociation = preload("highlighter_association.gd")
|
|
8
8
|
const Highlighter = preload("highlighter.gd")
|
|
9
|
+
const Services = preload("language_services.gd")
|
|
10
|
+
const Navigation = preload("navigation.gd")
|
|
11
|
+
const NewScript = preload("new_script.gd")
|
|
12
|
+
var _services: Node
|
|
13
|
+
var _navigation: RefCounted
|
|
14
|
+
var _new_script: RefCounted
|
|
9
15
|
const TEXT_EXTENSIONS_SETTING := "docks/filesystem/textfile_extensions"
|
|
10
16
|
|
|
11
17
|
var _highlighter: EditorSyntaxHighlighter
|
|
@@ -37,10 +43,19 @@ func _enter_tree() -> void:
|
|
|
37
43
|
registered = true
|
|
38
44
|
if not registered:
|
|
39
45
|
settings.set_setting(TEXT_EXTENSIONS_SETTING, existing + ("," if not existing.is_empty() else "") + "gogo")
|
|
40
|
-
_highlighter = Highlighter.new()
|
|
46
|
+
_highlighter = Highlighter.new(settings)
|
|
41
47
|
_interface.get_script_editor().register_syntax_highlighter(_highlighter)
|
|
42
48
|
_highlighter_association = HighlighterAssociation.new()
|
|
49
|
+
_navigation = Navigation.new(_interface)
|
|
50
|
+
_services = Services.new(_interface,_navigation)
|
|
51
|
+
add_child(_services)
|
|
52
|
+
_services.diagnostics_changed.connect(_typing_report)
|
|
53
|
+
_highlighter_association.associated.connect(_services.attach)
|
|
43
54
|
_highlighter_association.start(_interface)
|
|
55
|
+
_new_script = NewScript.new(_interface,_navigation)
|
|
56
|
+
_new_script.start(self)
|
|
57
|
+
add_tool_menu_item("New Gogo Script…",_new_script.show_dialog)
|
|
58
|
+
add_tool_menu_item("Add Missing Gogo Imports",_services.add_missing_imports)
|
|
44
59
|
_timer = Timer.new()
|
|
45
60
|
_timer.one_shot = true
|
|
46
61
|
_timer.wait_time = 0.4
|
|
@@ -50,9 +65,12 @@ func _enter_tree() -> void:
|
|
|
50
65
|
_diagnostics.name = "EstragonDiagnostics"
|
|
51
66
|
_diagnostics.custom_minimum_size = Vector2(0, 120)
|
|
52
67
|
_diagnostics.selection_enabled = true
|
|
68
|
+
_diagnostics.bbcode_enabled = true
|
|
69
|
+
_diagnostics.meta_clicked.connect(_diagnostic_clicked)
|
|
53
70
|
add_control_to_bottom_panel(_diagnostics, "Gogo")
|
|
54
|
-
_interface.get_resource_filesystem().filesystem_changed.connect(
|
|
71
|
+
_interface.get_resource_filesystem().filesystem_changed.connect(_filesystem_changed)
|
|
55
72
|
_interface.get_resource_filesystem().sources_changed.connect(_sources_changed)
|
|
73
|
+
scene_changed.connect(_scene_context_changed)
|
|
56
74
|
resource_saved.connect(_resource_saved)
|
|
57
75
|
_interface.get_script_editor().editor_script_changed.connect(_script_changed)
|
|
58
76
|
# Native GGX with explicit imports can build before the editor restores
|
|
@@ -128,7 +146,17 @@ func _refresh_generated_editors() -> void:
|
|
|
128
146
|
code.tag_saved_version()
|
|
129
147
|
|
|
130
148
|
|
|
149
|
+
func _filesystem_changed() -> void:
|
|
150
|
+
if _services != null: _services.invalidate()
|
|
151
|
+
_schedule()
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
func _scene_context_changed(_root: Node) -> void:
|
|
155
|
+
if _services != null: _services.invalidate()
|
|
156
|
+
|
|
157
|
+
|
|
131
158
|
func _sources_changed(_changed: bool) -> void:
|
|
159
|
+
_services.invalidate()
|
|
132
160
|
_schedule()
|
|
133
161
|
|
|
134
162
|
|
|
@@ -183,8 +211,23 @@ func _compile() -> bool:
|
|
|
183
211
|
return last_report.ok
|
|
184
212
|
|
|
185
213
|
|
|
214
|
+
func _typing_report(records: Array, phase: String) -> void:
|
|
215
|
+
if not _active or _building: return
|
|
216
|
+
_diagnostics.clear()
|
|
217
|
+
_diagnostics.add_text(phase+"\n")
|
|
218
|
+
for record in records: _diagnostic_link(record)
|
|
219
|
+
func _diagnostic_link(record: Dictionary) -> void:
|
|
220
|
+
_diagnostics.push_meta(record)
|
|
221
|
+
_diagnostics.add_text("%s:%d:%d: %s\n" % [record.source,record.line,record.column,record.message])
|
|
222
|
+
_diagnostics.pop()
|
|
223
|
+
func _diagnostic_clicked(record: Variant) -> void:
|
|
224
|
+
if record is Dictionary: _services.navigate(record)
|
|
186
225
|
func _show_report() -> void:
|
|
226
|
+
_services.report_build(last_report)
|
|
187
227
|
_diagnostics.text = "Gogo build succeeded." if last_report.ok else "\n\n".join(PackedStringArray(last_report.diagnostics))
|
|
228
|
+
if not last_report.get("source_diagnostics",[]).is_empty():
|
|
229
|
+
_diagnostics.clear()
|
|
230
|
+
for record in last_report.source_diagnostics: _diagnostic_link(record)
|
|
188
231
|
if not last_report.ok:
|
|
189
232
|
make_bottom_panel_item_visible(_diagnostics)
|
|
190
233
|
push_warning("Estragon: Gogo compilation failed; Play blocked.\n" + _diagnostics.text)
|
|
@@ -192,13 +235,19 @@ func _show_report() -> void:
|
|
|
192
235
|
|
|
193
236
|
func _exit_tree() -> void:
|
|
194
237
|
_active = false
|
|
238
|
+
remove_tool_menu_item("New Gogo Script…")
|
|
239
|
+
remove_tool_menu_item("Add Missing Gogo Imports")
|
|
240
|
+
if _navigation != null: _navigation.stop()
|
|
241
|
+
if _new_script != null: _new_script.stop(); _new_script = null
|
|
242
|
+
if _services != null: _services.stop(); _services.free(); _services = null
|
|
243
|
+
_navigation = null
|
|
195
244
|
_building = false
|
|
196
245
|
_rescan_pending = false
|
|
197
246
|
_play_save_failed = false
|
|
198
247
|
if is_instance_valid(_interface):
|
|
199
248
|
var filesystem := _interface.get_resource_filesystem()
|
|
200
|
-
if filesystem.filesystem_changed.is_connected(
|
|
201
|
-
filesystem.filesystem_changed.disconnect(
|
|
249
|
+
if filesystem.filesystem_changed.is_connected(_filesystem_changed):
|
|
250
|
+
filesystem.filesystem_changed.disconnect(_filesystem_changed)
|
|
202
251
|
if filesystem.sources_changed.is_connected(_sources_changed):
|
|
203
252
|
filesystem.sources_changed.disconnect(_sources_changed)
|
|
204
253
|
if is_instance_valid(_interface):
|
package/package.json
CHANGED