Skip to content

Commit

Permalink
[*] Add static typing to loops
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE committed Jan 3, 2024
1 parent 533ddc5 commit 4495013
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion addons/licenses/component.gd
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func duplicate():
dup.contact = self.contact
dup.web = self.web
dup.paths = self.paths.duplicate()
for license in self.licenses:
for license: License in self.licenses:
dup.licenses.append(license.duplicate())

return dup
8 changes: 4 additions & 4 deletions addons/licenses/internal/file_system_watcher.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func _init(components: ComponentsContainer):

func _on_file_moved(old_file: String, new_file: String) -> void:
var changed: bool = false
for comp in self._components.components():
for idx in range(comp.paths.size()):
for comp: Component in self._components.components():
for idx: int in range(comp.paths.size()):
if comp.paths[idx] == old_file:
changed = true
comp.paths[idx] = new_file
Expand All @@ -28,8 +28,8 @@ func _on_file_moved(old_file: String, new_file: String) -> void:
func _on_folder_moved(old_folder: String, new_folder: String) -> void:
var old_folder_no_slash: String = old_folder.rstrip("/")
var changed: bool = false
for comp in self._components.components():
for idx in range(comp.paths.size()):
for comp: Component in self._components.components():
for idx: int in range(comp.paths.size()):
var path: String = comp.paths[idx]
if path == old_folder_no_slash:
changed = true
Expand Down
22 changes: 11 additions & 11 deletions addons/licenses/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ const LicensesDialogScene: PackedScene = preload("internal/licenses_dialog.tscn"
const Licenses := preload("licenses.gd")
const ExportPlugin := preload("export_plugin.gd")

var export_plugin: ExportPlugin
var licenses_dialog: Window
var _export_plugin: ExportPlugin
var _licenses_dialog: Window

func _get_plugin_name() -> String:
return "Licenses"

func _enter_tree() -> void:
set_project_setting(Licenses.DATA_FILE, "res://licenses.json", TYPE_STRING, PROPERTY_HINT_FILE)

self.export_plugin = ExportPlugin.new()
self.add_export_plugin(self.export_plugin)
self._export_plugin = ExportPlugin.new()
self.add_export_plugin(self._export_plugin)

self.licenses_dialog = LicensesDialogScene.instantiate()
EditorInterface.get_base_control().add_child(self.licenses_dialog)
self._licenses_dialog = LicensesDialogScene.instantiate()
EditorInterface.get_base_control().add_child(self._licenses_dialog)
self.add_tool_menu_item(self._get_plugin_name() + "...", self._show_popup)

func _exit_tree() -> void:
self.remove_tool_menu_item(self._get_plugin_name() + "...")
self.licenses_dialog.queue_free()
self.remove_export_plugin(self.export_plugin)
self._licenses_dialog.queue_free()
self.remove_export_plugin(self._export_plugin)

func _show_popup() -> void:
if licenses_dialog.visible:
self.licenses_dialog.grab_focus()
if _licenses_dialog.visible:
self._licenses_dialog.grab_focus()
else:
self.licenses_dialog.popup_centered_ratio(0.4)
self._licenses_dialog.popup_centered_ratio(0.4)

static func set_project_setting(key: String, initial_value, type: int, type_hint: int) -> void:
if not ProjectSettings.has_setting(key):
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_theme_overrides/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func _notification(what: int) -> void:
self._update_layout()

func _update_layout() -> void:
for child in self.get_children():
for child: Node in self.get_children():
if child is Label:
if self.has_theme_color_override("my_font_color"):
child.add_theme_color_override("font_color", self.get_theme_color("my_font_color"))
Expand Down
2 changes: 1 addition & 1 deletion examples/glogging/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func _ready() -> void:
GLogging.info("ready and initialize GUI")
self._logger.append(GLogging.root_logger.create_child("network"))
self._logger.append(GLogging.root_logger.create_child("gui", GLogging.LEVEL_WARNING))
for logger in self._logger:
for logger: GLogging.Logger in self._logger:
self._logger_options.add_item(logger.name)
self._log_level_options.select(GLogging.root_logger.log_level() / 10)
GLogging.info("initialized logger %s %s", ["root", "and other"])
Expand Down
2 changes: 1 addition & 1 deletion examples/licenses/license_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func set_component(component: Component) -> void:
self._web.text = component.web
self._license.text = ""
self._license_text.text = ""
for idx in range(len(component.licenses)):
for idx: int in range(len(component.licenses)):
var license: Component.License = component.licenses[idx]
if idx > 0:
self._license.text = self._license.text + " & "
Expand Down

0 comments on commit 4495013

Please sign in to comment.