Commit graph

1986 commits

Author SHA1 Message Date
Rémi Verschelde 7fe5bece45
Merge pull request #58931 from EricEzaM/proposals/4189-better-code-completion
Sort autocomplete/code completion options in a better way
2022-03-28 08:56:27 +02:00
Rémi Verschelde c422dc5feb
Merge pull request #59064 from Chaosus/gds_fix_narrowing_conv_warning
Prevent NARROWING_CONVERSION warning for `int(float)` function in GDScript
2022-03-28 08:55:52 +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
Rémi Verschelde d7d528c15f
Merge pull request #59065 from fabriceci/script-template-condition-too-wide 2022-03-23 12:13:07 +01:00
fabriceci dae97909bd Restrict the condition when checking if a script is a template 2022-03-23 11:03:44 +01:00
Yuri Roubinsky c14043b166 Prevent NARROWING_CONVERSION warning for int(float) function in GDScript 2022-03-22 09:17:00 +03:00
Yuri Rubinsky 6cba2143de
Merge pull request #59056 from Chaosus/gds_fix_extends_crash 2022-03-22 08:27:03 +03:00
Yuri Rubinsky 7befa7234d
Merge pull request #58971 from Chaosus/gds_multiline_annotation 2022-03-22 08:25:37 +03:00
Rémi Verschelde 188fa0c846
Merge pull request #59194 from Chaosus/gds_export_flags_limit_error
Add an error emitting when the `@export_flags` arg count is exceeded
2022-03-21 21:21:49 +01:00
Yuri Roubinsky 8a6ab899ec Add an error emitting when the @export_flags arg count is exceeded 2022-03-16 17:12:15 +03:00
Yuri Roubinsky 5a99aa3b3a Fix default value count checking for inherited function 2022-03-14 18:00:42 +03:00
Yuri Roubinsky d009d96a92 Prevent crash due to empty error message on empty extends in GDScript 2022-03-12 09:46:51 +03:00
Yuri Roubinsky 85488f12f3 Allow making multiline annotations in GDScript 2022-03-10 10:56:14 +03:00
reduz 21637dfc25 Remove VARIANT_ARG* macros
* Very old macros from the time Godot was created.
* Limited arguments to 5 (then later changed to 8) in many places.
* They were replaced by C++11 Variadic Templates.
* Renamed methods that take argument pointers to have a "p" suffix. This was used in some places and not in others, so made it standard.
* Also added a dereference check for Variant*. Helped catch a couple of bugs.
2022-03-09 18:39:13 +01:00
Yuri Roubinsky 4fee0e3b7d Fix VisualShaderNodeCustom script template 2022-03-09 09:45:20 +03:00
Rémi Verschelde 8c3d8b12ed
Merge pull request #58853 from V-Sekai/default-arg-values 2022-03-07 10:40:42 +01:00
K. S. Ernest (iFire) Lee 2eaadb1b52 Restore building web platform by enclosing resolve_function_signature. 2022-03-07 00:35:11 -08:00
Rémi Verschelde 53cf5eff9a
Merge pull request #58847 from KoBeWi/editor_settings_mess 2022-03-07 08:38:15 +01:00
kobewi 2057ea2883 Remove duplicate editor settings definitions 2022-03-06 22:05:49 +01:00
George Marques 1ebcb58e69
GDScript: Check if method signature matches the parent
To guarantee polymorphism, a method signature must be compatible with
the parent. This checks if:

1. Return type is the same.
2. The subclass method takes at least the same amount of parameters.
3. The matching parameters have the same type.
4. If the subclass takes more parameters, all of the extra ones have a
default value.
5. If the superclass has default values, so must have the subclass.

There's a few test cases to ensure this holds up.
2022-03-06 11:16:20 -03:00
strank 7d48afa96d Add test cases for accessing parent elements from child class 2022-03-04 12:41:20 -05:00
Rémi Verschelde 79bbe57244
Merge pull request #56830 from strank/parent-signals 2022-03-04 17:29:49 +01:00
Rémi Verschelde bb8c4acdc9
Merge pull request #58185 from V-Sekai/explicit_variant_assignment_fix 2022-03-04 14:56:38 +01:00
Rémi Verschelde e133adeb8c
Merge pull request #58201 from V-Sekai/debugger_locals 2022-03-04 14:50:56 +01:00
Rémi Verschelde 4bbd7417c4
Merge pull request #58320 from mphe/fix_object_typed_arrays 2022-03-04 14:49:06 +01:00
Rémi Verschelde a4195a3ea8
Merge pull request #58250 from V-Sekai/typed_array_fix 2022-03-04 14:48:40 +01:00
Rémi Verschelde d31aaed172
Merge pull request #58626 from groud/fix_gdscript_analyser_crash 2022-03-04 14:15:59 +01:00
Rémi Verschelde 9b94a1dc4a
Merge pull request #58670 from KoBeWi/internal_debugger 2022-03-04 10:44:56 +01:00
Max Hilbrunner 57838fc0ee
Merge pull request #58262 from Sauermann/fix-range-doc
Describe usage of float in range documentation
2022-03-03 13:12:29 +01:00
kobewi 98dd04c38c Fix debugger not opening built-in scripts 2022-03-02 17:57:56 +01:00
Gilles Roudière 7ae988ce5e Fix a crash in GDScriptAnalyzer when a script class's file is not found 2022-02-28 12:20:00 +01:00
Rémi Verschelde e3b70f3582
Merge pull request #58244 from V-Sekai/typed_fail_case_return 2022-02-23 14:12:14 +01:00
Rémi Verschelde 95783f7bfc
Merge pull request #58415 from V-Sekai/cyclic_assignment_gdscript_fixes 2022-02-23 12:09:44 +01:00
Chris Bradfield 849d34ba8e Rename motion_velocity to velocity 2022-02-22 23:31:33 -08:00
SaracenOne b6aa4ed55d Fixes cyclic detection from variables assigning themselves to themselves in autocomplete, and restricts initialization of variables from other variables which have not been declared above it in class body 2022-02-22 01:21:21 +00:00
Marvin Ewald cea0630fef Fix typed arrays for Object based types
Fixes https://github.com/godotengine/godot/issues/53771.
2022-02-19 16:27:06 +01:00
SaracenOne ae0026bc7b Make 'is_attribute' false during parse error to prevent crash 2022-02-18 12:52:46 +00:00
Markus Sauermann bac8e451c0 Describe usage of float in range documentation 2022-02-18 00:59:22 +01:00
SaracenOne ab2a8bd1d8 Fix using typed arrays based on script classes 2022-02-17 17:34:53 +00:00
SaracenOne 62d87fbd8b Return a correctly typed variant in case of a function error to prevent hard crashes 2022-02-17 15:45:19 +00:00
SaracenOne 657b9b6596 Fix local variables not showing when breaking on final line 2022-02-16 18:12:38 +00:00
Jakob Bouchard 6553f5c242
Convert _notification methods to switch - Chunk C 2022-02-16 13:03:05 -05:00
SaracenOne d45c3cdd1d Fix error when assigning to an explicitly annotated variant from an ambiguous source 2022-02-16 13:25:27 +00:00
Hugo Locurcio b68dd2e189
Add an XML schema for documentation
This makes it easier to spot syntax errors when editing the
class reference. The schema is referenced locally so validation
can still work offline.

Each class XML's schema conformance is also checked on GitHub Actions.
2022-02-15 00:03:31 +01:00
Hendrik Brucker b396fd4eef Improve compilation speed (forward declarations/includes cleanup) 2022-02-12 02:46:22 +01:00
strank dcf19f8914 Fix "Identifier not found" compiler error when accessing inherited signals or functions as callables. 2022-02-11 20:45:04 -05:00
Rémi Verschelde 317cd0b19a
Refactor some object type checking code with cast_to
Less stringly typed logic, and less String allocations and comparisons.
2022-02-08 10:08:34 +01:00
Fabio Alessandrelli 086256431a [Net] Add type check to GDScriptRPCCallable.
It will print an error when using an RPC defined on an object which does
not extend Node.
2022-02-07 13:39:45 +01:00
Fabio Alessandrelli 994638da4f [Net] Implement GDScript custom RPC callable. 2022-02-07 13:39:10 +01:00
Rémi Verschelde 6a56314eab
Merge pull request #57748 from fabriceci/rename-script-template-variable 2022-02-07 13:22:23 +01:00
fabriceci e81ccaf270 rename jump force to jump velocity 2022-02-07 11:46:30 +01:00
Yuri Roubinsky a6e280c5de Add some more fixes to visual shader 2022-02-07 11:28:42 +03:00
Hugo Locurcio de45534fed
Highlight "namespace" as a GDScript keyword in the syntax highlighter
Like "trait" and "yield", "namespace" is currently not implemented
but is still reserved for future use.
2022-02-04 17:46:13 +01:00
Rémi Verschelde 89eb6d372d
Merge pull request #57591 from vnen/gdscript-enum-fixes 2022-02-04 13:49:15 +01:00
bruvzg 244db37508
Cleanup and move char functions to the char_utils.h header. 2022-02-04 11:35:01 +02:00
Anilforextra adbe948bda String: Add contains(). 2022-02-04 01:28:02 +05:45
George Marques ceafdf347e
GDScript: Treat enum values as int and enum types as dictionary
Since enums resolve to a dictionary at runtime, calling dictionary
methods on an enum type is a valid use case. This ensures this is true
by adding test cases. This also makes enum values be treated as ints
when used in operations.
2022-02-03 13:32:34 -03:00
George Marques b013c0d544
GDScript: Allow tests to run on release builds
- Fix compilation issues by disabling warnings on release builds. This
  also strips warnings from expected result before the comparison to
  avoid false mismatches.
- Add a `#debug-only` flag to tests. Must be the first line of the test
  script. Those won't run with release builds. Can be used for test
  cases that rely on checks only available on debug builds.
2022-02-03 13:32:33 -03:00
George Marques ad6e2e82a9
GDScript: Consolidate behavior for assigning enum types
This makes sure that assigning values to enum-typed variables are
consistent. Same enum is always valid, different enum is always
invalid (without casting) and assigning `int` creates a warning
if there is no casting.

There are new test cases to ensure this behavior doesn't break in
the future.
2022-02-03 13:32:16 -03:00
bruvzg 8e79c5fb8d
Add support for the escaped UTF-16 and UTF-32 Unicode characters in the scripts and expressions. 2022-01-30 20:16:04 +02:00
Rémi Verschelde e6caaf4c80
Merge pull request #57205 from TechnoPorg/variant-template-cast
Allow method binds to take Object subclasses as arguments
2022-01-27 23:46:37 +01:00
Rémi Verschelde 899cd34426
Merge pull request #57281 from Rubonnek/rename-subsequence 2022-01-27 11:03:13 +01:00
Wilson E. Alvarez 3eb5e0ac50
Rename String::is_subsequence_ofi to String::is_subsequence_ofn 2022-01-26 18:03:56 -05:00
cdemirer 28ac4d8b7d Fix crash with non-constant keys in match statement Dictionary pattern 2022-01-26 04:10:07 +08:00
TechnoPorg 051ef479c9 Allow method binds to take Object subclasses as arguments
This commit adds a condition to VariantCaster that casts Variants of type OBJECT to any type T, if T is derived from Object.
This change enables a fair bit of code cleanup. First, the Variant implicit cast operators for Node and Control can be removed, which allows for some invalid includes to be removed. Second, helper methods in Tree whose sole purpose was to cast arguments to TreeItem * are no longer necessary.
A few small changes also had to be made to other files, due to the changes cascading down all the includes.
2022-01-25 09:03:36 -07:00
K. S. Ernest (iFire) Lee b69b526b7c GDScript cache crashfix. 2022-01-22 17:42:54 -08:00
Rémi Verschelde e1706be25d
Merge pull request #57052 from KoBeWi/nosort 2022-01-23 00:27:01 +01:00
Rémi Verschelde b5f524d4c0
Merge pull request #55433 from V-Sekai/prev_operand_nullptr_check
Check for nullptr expression in parse_precedence function
2022-01-22 20:31:45 +01:00
Rémi Verschelde 182a36db47
Merge pull request #55214 from Scony/fix-gdscript-crash-2
Fix GDScript parser crash on 'dollar mixed with assignment' expression
2022-01-22 20:30:54 +01:00
kobewi f056cb8ebc Don't sort printed Dictionary 2022-01-22 13:45:02 +01:00
Pedro J. Estébanez 7b0ed2aa5e Rename Variant::is_ref() to is_ref_counted() 2022-01-20 18:46:25 +01:00
Rémi Verschelde 846c14eee9
Merge pull request #56739 from strank/master
GDScript: Fix parsing default parameter values from function calls
2022-01-17 21:38:01 +01:00
Rémi Verschelde 4cfade6212
Merge pull request #55995 from Xwdit/enum_fix
Fix enum int comparison
2022-01-17 20:20:16 +01:00
Rémi Verschelde 91909ef801
Merge pull request #55625 from cdemirer/fix-type-guessing-and-gdscript-parser-printing
Fix `--test gdscript-parser` crash
2022-01-17 20:17:02 +01:00
Rémi Verschelde 12ab19fa26
Merge pull request #55616 from cdemirer/master
Fix nested ternary-if codegen
2022-01-17 20:16:26 +01:00
Paulb23 fffeecfd68 Improvments for SyntaxHighlighters
- Fix immedate Funcion in lamba highlight
- Highlight signals as one colour
- Highlight node paths as one colour
- Highlight escape chars in strings
2022-01-15 15:39:55 +00:00
Rémi Verschelde 3efa6644c4
Merge pull request #55541 from KoBeWi/outcognito_scripts 2022-01-14 21:04:13 +01:00
luz paz 858bcd5058 Fix various typos
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,expct,fave,findn,gird,hist,inh,inout,leapyear,lod,nd,numer,ois,ony,paket,ro,seeked,sinc,switchs,te,uint,varn,vew`
2022-01-13 23:20:01 -05:00
strank 960a26f6c0 GDScript: Fix parsing default parameter values from function calls 2022-01-13 19:28:39 -05:00
Rémi Verschelde f0382530a7
Merge pull request #56268 from KoBeWi/🚗complete_setters 2022-01-13 12:40:48 +01:00
kobewi f524ddebd5 Make script type distinguishable by icon 2022-01-13 12:29:05 +01:00
SaracenOne 64d8b3aef2 Assign member type when parsing setters to prevent
'Compiler bug: unresolved assign' errors
2022-01-11 11:23:17 +00:00
Rémi Verschelde b3513cffc5
Merge pull request #56326 from NNesh/fix/unknown_default_value_callable
Extended the _make_arguments_hint function to get default values for function arguments in hint
2022-01-10 21:29:13 +01:00
NNesh 374baff747 Fixed <unknown> text for callable default value for a function arguments hint
Format switch

Added a case for constant subscripts

Fixed default value hinting for the enum type

Removed is_null checking for value

Added a case for dictionary
2022-01-10 23:22:35 +05:00
Rémi Verschelde 49482966ec
Merge pull request #55715 from nathanfranke/enum-ordered 2022-01-10 17:19:52 +01:00
Rémi Verschelde 1989120d3f
Merge pull request #56194 from cdemirer/fix-operation-result-type-inference 2022-01-10 17:18:32 +01:00
Rémi Verschelde 4acc819f9b
Merge pull request #56232 from V-Sekai/invalid_explicit_variant_assign_fix 2022-01-10 17:12:56 +01:00
Rémi Verschelde cc7f634066
Merge pull request #56260 from cdemirer/fix-type-mutation-upon-assignment-with-operation 2022-01-10 17:12:34 +01:00
Rémi Verschelde c8b4fe3b8d
Merge pull request #56287 from cdemirer/fix-member-property-only-getter-cant-be-set 2022-01-10 17:12:06 +01:00
Rémi Verschelde 1fd5954962
Merge pull request #56288 from cdemirer/fix-member-property-getter-dont-update-subscript-chain-root 2022-01-10 17:10:57 +01:00
Rémi Verschelde 8f8c3f4b4c
Merge pull request #56342 from NNesh/fix/class-completion 2022-01-10 17:07:08 +01:00
Rémi Verschelde b3d208385f
Merge pull request #56409 from cdemirer/fix-unexpected-copying-when-parameter-is-typed 2022-01-10 17:03:47 +01:00
Ger Hean 609964848d Fix leak when function returning self type
Leak is caused by cyclic reference
2022-01-10 02:14:48 +08:00
NNesh 1a1ee43e3e Fixed completion showing for class members 2022-01-08 01:49:18 +05:00
Rémi Verschelde 393a44b275
Merge pull request #55213 from Scony/fix-gdscript-crash 2022-01-06 20:54:03 +01:00
bruvzg c69e0d16bc
Fix multiple missing UTF-8 decoding. 2022-01-06 14:35:22 +02:00
Yuri Roubinsky 21cfcaa129 Add a GDScript template for VisualShaderNodeCustom 2022-01-06 12:06:33 +03:00
Rémi Verschelde 6d4ed65f4c
Merge pull request #56483 from vnen/gdscript-warning-annotation
Add annotation to ignore warnings
2022-01-05 09:05:56 +01:00