Commit Graph

342 Commits

Author SHA1 Message Date
Yuri Rubinsky 35802374ac Add coloring for completion of vector components 2023-08-30 21:13:25 +03:00
ajreckof 4b724c9252 Fix completion option location not found 2023-08-05 02:15:45 +02:00
Yuri Sizov 68a49c4959 Merge pull request #79935 from dalexeev/gds-validate-node-path-annotation
GDScript: Add validation for `@export_node_path` annotation arguments
2023-08-01 17:25:44 +02:00
Yuri Sizov 3de7dd902c Merge pull request #79880 from dalexeev/gds-fix-id-shadowing-below
GDScript: Fix bug with identifier shadowed below in current scope
2023-07-31 21:01:36 +02:00
Danil Alexeev 5b4403c9a5
GDScript: Add validation for `@export_node_path` annotation arguments
Co-authored-by: George Marques <george@gmarqu.es>
2023-07-26 20:36:47 +03:00
Juan Linietsky 5e512b705e Support threads in the script debugger
* This implementation adds threads on the side of the client (script debugger).
* Some functions of the debugger are optimized.
* The profile is also now thread safe using atomics.
* The editor can switch between multiple threads when debugging.

This PR adds threaded support for the script language debugger. Every thread has its own thread local data and it will connect to the debugger using multiple thread IDs.
This means that, now, the editor can receive multiple threads entering debug mode at the same time.
2023-07-26 12:06:45 +02:00
Danil Alexeev d53fc92b4c
GDScript: Fix bug with identifier shadowed below in current scope 2023-07-26 11:26:57 +03:00
Yuri Sizov 74d20fe17e Merge pull request #75216 from rune-scape/rune-dependancy-errors
Script editor (GDScript): Show depended script errors
2023-07-24 19:32:20 +02:00
Yuri Sizov 2bd904e3db Merge pull request #73196 from Vilcrow/fix-lookup-symbol
Fix jumping to function definition using `Ctrl+LMB` or the "Lookup Symbol" button
2023-07-24 19:32:12 +02:00
rune-scape 83b01708b2 Script editor: Show depended script errors 2023-07-24 15:49:39 +02:00
S.V.I. Vilcrow 56e2fad319 Fixed the jumping to function definition using 'Ctrl+LMB' and the 'Lookup Symbol' button. 2023-07-12 21:30:35 +03:00
Ben 0803467334
Fix "Go to definition" for GDScript type hints
Fixes #68475.
2023-06-19 15:29:25 +02:00
Rémi Verschelde 11ee6fcef0
Merge pull request #68311 from RobertMasek/fix-go-to-definition
Fix functionality of Go To Definition for properties set/get
2023-06-18 16:26:42 +02:00
Rémi Verschelde 25b2f1780a
Style: Harmonize header includes in modules
This applies our existing style guide, and adds a new rule to that style
guide for modular components such as platform ports and modules:

Includes from the platform port or module ("local" includes) should be listed
first in their own block using relative paths, before Godot's "core" includes
which use "absolute" (project folder relative) paths, and finally thirdparty
includes.

Includes in `#ifdef`s come after their relevant section, i.e. the overall
structure is:

- Local includes
  * Conditional local includes
- Core includes
  * Conditional core includes
- Thirdparty includes
  * Conditional thirdparty includes
2023-06-15 14:35:45 +02:00
ajreckof 006e899bb3 sort code completions with rules
Fixups

Add levenshtein distance for comparisons, remove kind sort order, try to improve as many different use cases as possible

Trying again to improve code completion

Sort code autocompletion options by similarity based on input

To make it really brief, uses a combination `String.similiary`, the category system introduced in a previous PR, and some filtering to yield more predictable results, instead of scattering every completion option at seemingly random.

It also gives much higher priority to strings that contain the base in full, closer to the beginning or are perfect matches.

Also moves CodeCompletionOptionCompare to code_edit.cpp

Co-Authored-By: Micky <66727710+Mickeon@users.noreply.github.com>
Co-Authored-By: Eric M <41730826+EricEzaM@users.noreply.github.com>
2023-05-23 05:12:34 +02:00
Clay John 610877e326
Merge pull request #72288 from MewPurPur/use-string-repeat
Use `String.repeat()` to optimize several String methods
2023-05-05 09:56:48 -07:00
VolTer 6b84e258d2 Use String.repeat() in more places 2023-05-01 02:27:46 +02:00
George Marques 0ba6048ad3
Add support for static variables in GDScript
Which allows editable data associated with a particular class instead of
the instance. Scripts with static variables are kept in memory
indefinitely unless the `@static_unload` annotation is used or the
`static_unload()` method is called on the GDScript.

If the custom function `_static_init()` exists it will be called when
the class is loaded, after the static variables are set.
2023-04-27 09:51:44 -03:00
Yuri Sizov f3033da97d
Merge pull request #76170 from HolonProduction/string-highlight
Fix multi-line string highlighting with single quotes.
2023-04-18 18:01:02 +02:00
RedMser 2330ffb5a1 Add GDScript template to RichTextEffect 2023-04-18 14:02:04 +02:00
HolonProduction bdb7045e2c Fix multi-line string highlighting with single quotes. 2023-04-17 15:58:39 +02:00
Danil Alexeev 9df96e97ea
GDScript: Misc fixes and improvements for signature generation
* Use type hints for `@GlobalScope` enums.
* Use plain `int` for `BitMask<T>`.
* Fix type hints for typed arrays.
* Use `Variant` and `void` type hints.
* Discard unnecessary class prefix.
2023-04-07 10:43:21 +03:00
Dmitrii Maganov 4e34cf238a GDScript: Change parser representation of class extends 2023-03-13 01:40:13 +02:00
Dmitrii Maganov e289a4ab2c GDScript: Fix autocomplete inside a block with a type test condition 2023-03-09 23:53:27 +02:00
George Marques c9e49c487d
GDScript: Limit recursion depth for completion functions
Avoid crashing if the completion gets stuck in infinite recursion while
trying to guess the expression type.
2023-02-20 14:55:13 -03:00
Dmitrii Maganov 8fe023ad93 GDScript: Rework type check 2023-02-17 19:57:18 +02:00
Rémi Verschelde d405392847
Revert "Fixed the jumping to function definition using 'Ctrl+LMB'."
This reverts commit 7eb6367d5c.

Fixes #73058.
Fixes #73167.

This caused regressions, we'll retry with fixes for 4.1.
2023-02-13 17:58:59 +01:00
Rémi Verschelde 3f95b39cb3
Merge pull request #72789 from Vilcrow/fix-jump-to-definition
Fixed the jumping to function definition using 'Ctrl+LMB'.
2023-02-07 19:37:50 +01:00
S.V.I. Vilcrow 7eb6367d5c Fixed the jumping to function definition using 'Ctrl+LMB'. 2023-02-07 05:29:48 +03:00
Yuri Sizov 9d16250353
Merge pull request #70002 from poohcom1/fix/static-subscript-autocomplete
Fix code-completion suggesting non-static members for custom classes
2023-02-06 23:02:12 +03:00
Danil Alexeev 31749de128
GDScript: Better handling of `@rpc` annotation and autocompletion 2023-02-05 21:21:37 +03:00
Eric M 9b93bdb4e7 Fix crash in gdscript when autocompleting virtual function and signature does not match base. 2023-02-02 22:52:08 +10:00
Danil Alexeev b004f8180e
GDScript: Allow constant expressions in annotations 2023-01-25 18:43:56 +03:00
George Marques 629796c333
Merge pull request #69970 from poohcom1/fix/autocomplete-custom-class
Fixes https://github.com/godotengine/godot/issues/69941
2023-01-16 09:44:23 -03:00
poohcom1 2e53bf3d36 Fix code-completion suggesting non-static members
In GDScript code-completion:
 - Fixes class symbols not being marked as meta
 - Remove signal in static contexts

Fixes #69928
2023-01-16 00:41:20 +07:00
poohcom1 aa4bceff3e Add identifier completion for custom classes.
Previously, custom class would only auto-complete for types in GDScript.
This applies it to identifiers as well.
2023-01-16 00:25:24 +07:00
Yuri Rubinsky 9bd5ef1836 Fix GDScript script templates to use a PascalCase style for `_CLASS_` 2023-01-14 16:21:05 +03:00
ocean (they/them) 366ec895b1 Assorted enum and native type fixes 2023-01-09 11:08:07 -05:00
jordi d5e1b4a857 Force double quotes for NodePaths with apostrophes 2023-01-07 20:23:26 -06:00
Dmitrii Maganov a1d06749f1 Unify typing of variables, constants and parameters in GDScript 2023-01-06 01:10:04 +02:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Yuri Rubinsky abaedb54f1 Remove unused code paragraph from gdscript_editor.cpp/complete_code 2022-12-22 11:10:11 +03:00
poohcom1 1845d927dc Fix autocomplete on functions returning variants
- When guessing return type, check type hints before last return value
2022-12-11 14:17:27 +07:00
Adam Scott da65b61edb Fix autocomplete crash as it would infinite loop 2022-12-08 23:40:17 -05:00
Yuri Rubinsky b229a19688 Fix lookup to docs for variables initialized with `get_node` 2022-12-07 15:16:04 +03:00
Yuri Rubinsky 20660bb23a Fix completion for the raw `get_node` call 2022-12-06 10:42:44 +03:00
Yuri Rubinsky afbea19a22 Fix lookup code to pass functions with the same name as built-ins 2022-11-28 15:53:14 +03:00
Yuri Rubinsky 4a8276a773 Fix GDScript completion crash 2022-11-21 16:34:03 +03:00
Yuri Rubinsky 65d14679e7 Fix completion popup for the variables created with `get_node` call 2022-11-14 23:27:59 +03:00
Rémi Verschelde 4d9adfea23
Merge pull request #65712 from Chaosus/gds_fix_completion
fix https://github.com/godotengine/godot/issues/64477
2022-11-14 17:20:54 +01:00
Rune bce6f1792e GDScript compiler subclass bugfixes 2022-11-13 02:29:21 -08:00
RobertMasek 79234d8916 Add case for COMPLETION_PROPERTY_METHOD 2022-11-05 21:39:45 -05:00
kobewi e48c5daddf Unify usage of GLOBAL/EDITOR_GET 2022-10-18 19:01:48 +02:00
bruvzg 0103af1ddd
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4. 2022-10-07 11:32:33 +03:00
VolTer ac1761c8cd Fix outdated keywords autocompletion 2022-10-06 23:47:19 +02:00
Aaron Franke 094e8db97c
Fix hide_slider vs no_slider inconsistency in editor property code 2022-10-03 13:40:31 -05:00
Yuri Rubinsky b20aed2812 Fix completion for variables initialized by `get_node` call 2022-09-12 19:54:55 +03:00
Hugo Locurcio f7292dbeb3
Rename `or_lesser` range property hint to `or_less`
"less" should be used for quantity, rather than "lesser".

Existing scripts that use `or_lesser` in `_get_property_list()`
will need to be updated to account for this change.
2022-09-02 19:08:20 +02:00
Haoyu Qiu 660c700f9c Fix action name completion for `Input` 2022-08-15 23:28:49 +08:00
Rémi Verschelde a946768151
Merge pull request #63015 from Xwdit/fix_gds_editor_tooltip_arg_type 2022-08-10 16:31:32 +02:00
Xwdit e25c86bf5d Fixed incorrect type display of function argument in GDScript editor tooltips 2022-08-10 15:06:21 +02:00
Xwdit 7e262310a2 Fixed incorrect type display of void return in GDScript editor tooltips 2022-08-10 15:05:47 +02:00
Yuri Rubinsky df85c9871f Prevent global functions from overriding completion of subscript 2022-08-10 11:51:53 +03:00
Antonio Dell'Annunziata 7b975b50dc
fix(gdscript): Fix infinite loop on type inferernce from super method calls
When infering the type from a `super()` call, the gdscript_editor didn't use the base class to search for the original implementation of the method, but instead searched in the extending class.
This caused the same function to be analyzed for type inference which created the infinite loop.

Solves #63592
2022-07-29 10:22:55 +02:00
cdemirer e9a5beeb01 Fix crash while trying to autocomplete non-global Autoload 2022-07-18 16:35:25 +03:00
Rémi Verschelde fdff28e1a2
Merge pull request #62699 from cdemirer/fix-autocomplete-var-assigned-same-statement 2022-07-06 15:57:19 +02:00
Rémi Verschelde 4c56885bc0
Merge pull request #62690 from cdemirer/fix-infinite-guess-recursion 2022-07-06 15:54:16 +02:00
Rémi Verschelde 4873886830
Merge pull request #62760 from cdemirer/fix-annotation-initializer-conflict
Fix priority of annotated type vs initializer type
2022-07-06 15:47:56 +02:00
Rémi Verschelde 635d447a69
Merge pull request #62713 from YuriSizov/docs-scripting-annotations 2022-07-06 15:31:19 +02:00
Rémi Verschelde ea61cd3b32
Merge pull request #62707 from YuriSizov/gdscript-group-those-props 2022-07-06 15:24:07 +02:00
cdemirer f280975bf1 Fix priority of annotated type vs initializer type 2022-07-06 04:25:44 +03:00
reduz 5ac42cf576 Implement a BitField hint
Allows to specify the binder that an enum must be treated as a bitfield.
2022-07-05 22:13:37 +02:00
Yuri Sizov f85bafaa11 Add grouping annotations for class properties in GDScript 2022-07-05 22:01:40 +03:00
Yuri Sizov a9098e6147 Add support for documenting built-in annotations 2022-07-04 20:21:39 +03:00
cdemirer 3a827349bf Fix autocomplete for variable which is assigned to in the current statement 2022-07-04 10:08:41 +03:00
cdemirer bd518f6b11 Fix infinite recursion when guessing type of variable which is being assigned to 2022-07-04 02:49:36 +03:00
Marcus Elg 6c1ac9f3be Rename export_range's noslider option to no_slider 2022-06-24 10:45:34 +02:00
Marcus Elg 46bbbd9770 Allow autocompletion of "noslider" in export_range 2022-06-19 17:11:49 +02:00
Rémi Verschelde e465b72b9b
Merge pull request #61389 from snailrhymer/lookup-fix 2022-05-25 18:38:29 +02:00
SnailRhymer 3a87d1acae Make Lookup Symbol recognize assert and preload in the script editor 2022-05-25 16:41:10 +01:00
SnailRhymer 688a62d841 Fix lookup_code to properly handle symbols at start of assignments 2022-05-25 11:45:57 +01:00
reduz 45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
Yuri Rubinsky a439832035 Fix signal completion in GDScript editor 2022-05-12 16:10:48 +03:00
reduz 8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Hugo Locurcio 180e5d3028
Remove `RES` and `REF` typedefs in favor of spelled out `Ref<>`
These typedefs don't save much typing compared to the full `Ref<Resource>`
and `Ref<RefCounted>`, yet they sometimes introduce confusion among
new contributors.
2022-05-03 01:43:50 +02:00
Markus Sauermann a793960a10 Fix cppcheck const parameters
Convert method signature parameters to const where it is possible

# Conflicts:
#	drivers/gles3/rasterizer_canvas_gles3.cpp
#	drivers/gles3/rasterizer_canvas_gles3.h
#	editor/plugins/animation_state_machine_editor.cpp
#	editor/plugins/animation_state_machine_editor.h
2022-04-28 11:35:39 +02:00
David Maziarka 1f62965d26 Add built-in Variant types to autocompletion list
Co-authored-by: Gustav <gusan092@student.liu.se>
2022-04-07 11:10:19 -05:00
George Marques 4710e2b278
GDScript: Add support for static method calls in native types 2022-04-06 14:14:38 -03:00
Rémi Verschelde c630c2001d
Merge pull request #59633 from EricEzaM/better-code-complete-update
Improve sorting of Code Completion options.
2022-04-03 12:34:00 +02:00
Eric M 4ab605d14d Improve sorting of Code Completion options.
Done by ordering options by their location in the code - e.g. local, parent class, global, etc.
2022-04-01 20:39:09 +10:00
Yuri Roubinsky 0584387918 Fix autocompletion of static methods in built-in types in GDScript 2022-03-30 17:40:41 +03:00
Rémi Verschelde c9b75431f3 Refactor GDScript/C# script templates logic to be editor-only
Not a full refactor as it still goes through ScriptLanguage so it's hacky,
but at least it can now compile without this.
2022-03-28 16:21:00 +02:00
Rémi Verschelde 143d13717b
Merge pull request #59553 from reduz/script-extension-support 2022-03-28 13:35:21 +02:00
Juan Linietsky ed14ff5a08
Revert "Sort autocomplete/code completion options in a better way" 2022-03-28 13:31:32 +02:00
Rémi Verschelde 795304e34f
Merge pull request #59612 from YeldhamDev/style_and_grace 2022-03-28 11:36:27 +02:00
Michael Alexsander 42df9ed059 Make script templates follow the GDScript style guide 2022-03-28 01:32:12 -03:00
reduz 360dea5348 Add GDExtension support to Script
* Ability to create script languages from GDExtension
* Some additions to gdnative_extension.h to make this happen
* Moved the GDExtension binder to core

This now allows creating scripting languages from GDExtension, with the same ease as if it was a module. It replaces the old PluginScript from Godot 3.x.
Warning: GodotCPP will need to be updated to support this (it may be a bit of work as ScriptInstance needs to be created over there again).
2022-03-27 16:13:00 +02:00
Eric M f9e1c094a2 Improve sorting of Code Completion options.
Done by ordering options by their location in the code - e.g. local, parent class, global, etc.
2022-03-24 22:24:14 +10:00
kobewi 2057ea2883 Remove duplicate editor settings definitions 2022-03-06 22:05:49 +01:00