Commit graph

1149 commits

Author SHA1 Message Date
Pedro J. Estébanez 51844febee Avoid warning about harmless unfulfilled yields 2020-09-06 22:26:16 +02:00
Hugo Locurcio afef89014b
Cross-reference GDScript built-in rounding methods to ease discovery
This closes #19315.

(cherry picked from commit 20d0f5bbd7)
2020-08-31 15:29:42 +02:00
Thakee Nathees d04d329a1f autocompletion inside comments bug fixed
Fix: #41438
2020-08-23 23:01:54 +05:30
Thakee Nathees d53f5b55ec Auto completion enhanced for extends and class level identifier 2020-08-17 12:54:01 +05:30
Francois Belair e3f16a83dc Fix line num of enums reported as the line before 2020-08-08 11:52:25 -04:00
Hugo Locurcio fc7451204e Improve JSON-related documentation
This closes https://github.com/godotengine/godot-docs/issues/3848.

(cherry picked from commit 930e10ffff)
2020-07-31 13:09:21 +02:00
Rémi Verschelde 6d2f8dd827 doc: Sync classref with current source 2020-07-30 16:26:45 +02:00
Aaron Franke 3ab5183ffa
[3.2] Backport core documentation changes to 3.2
Also add AABB.abs()
2020-07-21 21:22:54 -04:00
Ryan Roden-Corrent 4677502d7c Include gdscript warning name in LSP message.
My initial attempt changed this in the gdscript code, which resulted in
a duplicate warning name in the builtin editor. We should just append
the warning name in the LSP instead.

This uses parens to match what is shown in the builtin editor.

(cherry picked from commit 8dcc39ec91)
2020-07-15 12:15:16 +02:00
Ryan Roden-Corrent f7b994aef8 Revert "Include gdscript warning name in the warning message."
This reverts commit de3ad3b30e.

(cherry picked from commit d92fa3b547)
2020-07-15 12:15:12 +02:00
Ryan Roden-Corrent a8d4ca0e1b Include gdscript warning name in the warning message.
Occasionally you want to ignore a warning with a `warning-ignore`
comment, and you have to go into the settings to look up what the
actual name of the warning is. This patch appends the warning name to
the end of the warning so you know what string to use to ignore it,
similar to other linters like pylint.

For example

```
"The signal 'blah' is declared but never emitted.";
```

is now

```
"The signal 'blah' is declared but never emitted. (UNUSED_SIGNAL)";
```

(cherry picked from commit de3ad3b30e)
2020-07-06 16:51:17 +02:00
Thakee Nathees 9ce1fe59ea Fix: editor crash on super constructor called
Fix: #39909
(cherry picked from commit 023b3f2786)
2020-07-06 16:47:44 +02:00
Tomasz Chabora 5b7eb3fd3f Improve the preload and load descriptions
(cherry picked from commit 13298ed873)
2020-06-29 10:58:25 +02:00
Thakee Nathees 438f1a8238 Fix: Ctrl + Click not working for subclasses
(cherry picked from commit 95b0a00d2c)
2020-06-18 11:29:28 +02:00
Thakee Nathees fc92f83c30 Debugger stepping to incorrect line fix
Fix: #39296
(cherry picked from commit fc89c5c76d)
2020-06-18 11:29:28 +02:00
Thakee Nathees 931a927a40 shodowed var warning for for loop counter
Fix: #39268
(cherry picked from commit 54835a5302)
2020-06-18 10:51:45 +02:00
Thakee Nathees bf9df88a7c GDScript debugger incorrect error line fixed
if the first line of an else or an elif throws a runtime error the
debugger shows incorrect line number.

(cherry picked from commit 9325671faa)
2020-06-18 10:51:45 +02:00
Rémi Verschelde 1cf8652945
Merge pull request #39263 from ThakeeNathees/is-operation-fail
[3.2] Fix `is` operation fail on get_script()
2020-06-16 16:28:43 +02:00
Rémi Verschelde 93e20a4cd4 GDScript LSP: Fix wrong error checks added in #39385
Reverts `latest_client_id` back to 0, as I misunderstood how the client
IDs are assigned and, without further testing and debugging, I can't
say if this was a bug or a valid default value.
Similarly, a `latest_client_id` of -1 is no longer raising an error.

Fixes #39548.

(cherry picked from commit 786f4ada35)
2020-06-15 14:34:35 +02:00
Rémi Verschelde 7bf9787921 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.

(cherry picked from commit cd4e46ee65)
2020-06-10 15:30:52 +02:00
Rémi Verschelde 3edae035d5 GDScript LSP: Fix crash in notify_client
`latest_client_id` now defaults to `-1` (invalid ID) instead of `0`.

Also fix typo in notification `gdscrip_client/changeWorkspace`,
and fix argument names in method binds.

Fixes #39375.

(cherry picked from commit e34f33711b)
2020-06-10 15:30:52 +02:00
Hugo Locurcio aeb5513bab Tweak the GDScript error message about passed argument type mismatch
This makes it less confusing.

This closes https://github.com/godotengine/godot-proposals/issues/670.

(cherry picked from commit 30053de182)
2020-06-05 12:50:55 +02:00
Thakee Nathees 837cba7567 predefined var check for for loop counter
(cherry picked from commit e153772de2)
2020-06-05 12:45:12 +02:00
George Marques a8332e30f0 GDScript: Fix assert message when no custom message is set
(cherry picked from commit f29a2e2606)
2020-06-04 12:09:39 +02:00
Thakee Nathees 8f795cb38e Fix is operation fail on get_script()
Fix: #39244
2020-06-03 21:04:48 +05:30
George Marques a0983637cf
GDScript: Allow get_script() to be considered a type 2020-06-03 10:48:43 -03:00
Tan Wang Leng 48a2fd7a3d gdscript_parser: Fix "unreachable code" false positive for loops
Depending on the conditional statements of the 'for' and 'while' loops,
their body may not even execute once. For example:

    func a():
        var arr = []
        for i in arr:
            return i
        # can be reached, but analysis says cannot
        return -1

    func b():
        var should_loop = false
        while should_loop:
           return 1
        # can be reached, but analysis says cannot
        return 0

The parser will complain that the statements after the comment cannot
be reached, but it is clearly possible for our scenario. This is
because the parser falsely assumes that the loop body will always
execute at least once.

Fix the code to remove this assumption for both of those loops.

(cherry picked from commit 7b1423a61e)
2020-05-25 16:31:07 +02:00
James Buck 9347a6ad6a Trigger an error when trying to define a preexisting signal in GDScript
A class can't have multiple signals with the same name, but previously users
would not be alerted to a conflict while editing the script where it occurred.
Now a helpful error will appear in the editor during script parsing.

(cherry picked from commit 9e44739324)
2020-05-25 16:29:20 +02:00
Thakee Nathees d611bd970d regression: dictionary key no autocomplete fix
Fix: #38998
(cherry picked from commit 13c372b522)
2020-05-25 15:58:25 +02:00
Pedro J. Estébanez 8f90d423b9 Fix too eager GDScriptFunctionState stack cleanup
(cherry picked from commit 1f0548efd4)
2020-05-20 11:40:45 +02:00
Thakee Nathees 9ee77179b5 break, continue outside of a loop, match statement handled
(cherry picked from commit c076a2b7e9)
2020-05-16 00:08:37 +02:00
Oliver Frank 2173d041af Fix incorrect capabilities notification in LSP 2020-05-15 16:43:48 -04:00
Thakee Nathees d13f46bc41 shadowed var warning in nested block bug fix
Fix: #38552
(cherry picked from commit 79eee93b9a)
2020-05-14 22:01:45 +02:00
Thakee Nathees 40c43da96f set parser error when infer type is null
(cherry picked from commit 687b1941b4)
2020-05-14 22:01:26 +02:00
Thakee Nathees e42318e41c regression: var declaration type info parser bug fix
(cherry picked from commit e5d735851d)
2020-05-13 16:14:22 +02:00
Thakee Nathees 6d7fb3d322 regression: static func can't access const fix
(cherry picked from commit e7f056dfac)
2020-05-13 16:14:08 +02:00
Thakee Nathees 72aa9ce7fc range() with non-numeric const argument crash fix
(cherry picked from commit 3e10392d48)
2020-05-13 16:08:33 +02:00
Thakee Nathees 55b4e0c44a parser error for static func access non-static variables
Fix: #38408
(cherry picked from commit ce978517e0)
2020-05-11 11:01:13 +02:00
Thakee Nathees e417528f67 fix: dict2inst crash when constructor has arguments
(cherry picked from commit 9f6b20936e)
2020-05-11 11:01:12 +02:00
Thakee Nathees a446e8671d autocompleting with indexing for native types added
Fix: #37768
(cherry picked from commit 3c45377c6e)
2020-05-11 10:50:46 +02:00
Thakee Nathees 22053ed75f GDScript class var type resolve bug fixed
Fix: #37545
(cherry picked from commit e67eb5ca36)
2020-05-11 10:50:46 +02:00
Thakee Nathees 6b0cfc87af more clearer unexpected statement end error messages
(cherry picked from commit 5758d87f09)
2020-05-11 10:50:46 +02:00
Thakee Nathees 7111aa0688 pass keyword inside a class implemented
(cherry picked from commit 63ce1fc438)
2020-05-11 10:50:46 +02:00
Thakee Nathees f3149817ff fixed: saving gdscript with cyclic inheritance crash the editor
Fix: #9609
(cherry picked from commit c2ab35bdde)
2020-05-11 10:50:45 +02:00
janglee d16abbdee4 Improved go-to definition (Ctrl + Click)
Co-Authored-By: Bojidar Marinov <bojidar.marinov.bg@gmail.com>
(cherry picked from commit be7a353c70)
2020-05-11 09:33:21 +05:30
Rémi Verschelde aa57bb0473
Merge pull request #38482 from RandomShaper/improve_yield_3.2
Fix object leaks caused by unfulfilled yields (3.2)
2020-05-09 22:03:00 +02:00
Pedro J. Estébanez 64344e6d1d Fix object leaks caused by unfulfilled yields
Now the stack saved in a `GDScriptFunctionState` is cleared as soon as the `yield()` operation is known not to be resumed because either the script, the instance or both are deleted.

This clears problems like leaked objects by eliminating cases of circular references between `GDScriptFunctionState`s preventing them and the objects they refer to in their saved stacks from being released. As an example, this makes using `SceneTreeTimer` safer.

Furthermore, with this change it's now possible to print early warnings about `yield()`s to released script/instances, as now we know they won't be successfully resumed as the condition for that happens. However, this PR doesn't add such messages, to keep the observed behavior the same for the time being.

Also, now a backup of the function name in `GDScriptFunctionState` is used, since the script may not be valid by the time the function name is needed for the resume-after-yield error messages.
2020-05-05 17:53:47 +02:00
Steven Schoen 40125c7cce Mention offending function name in "Indented block expected" error
(cherry picked from commit e6e5ba32cd)
2020-05-04 16:10:22 +02:00
Tom Evans 2859ceec6f Fix for marking assert lines as safe bug
Calling _reduce_node_type from GDScriptParser::_parse_block for assert
was using a current class with a scope that didn't include all
functions. Now calling in GDScriptParser::_check_block_types uses the
right class type. We also now check the assert node message. The assert
line was added to the set_errors associated with assert, since before
the error would be reported on the next line

(cherry picked from commit bd081df519)
2020-05-01 10:56:58 +02:00
Thakee Nathees 1a4530e84c export var type reduce() implemented
(cherry picked from commit cd487201c6)
2020-05-01 10:56:58 +02:00
Pedro J. Estébanez 68cca6e619 Fix leaked objects when game ends with yields in progress 2020-04-29 14:13:36 +02:00
Tom Evans 3bd5fc2e5e Mark assert lines as safe in gdscript
Now calling _reduce_node_type with debugging enabled to determine
if assert line is safe. Part of doing this required the assert line
to be stored away. Now the AssertNode line is being correctly set.
Newlines are now marked safe always

(cherry picked from commit 8dc8833782)
2020-04-27 10:10:20 +02:00
Umang Kalra 94d0f34f70 Fixed the bool _static logic
(cherry picked from commit b192c7d1ac)
2020-04-27 10:09:49 +02:00
Thakee Nathees 95f6bdfa78 GDScript class name existance check enhanced
(cherry picked from commit 62280c3d47)
2020-04-23 11:10:51 +02:00
Thakee Nathees 12c776dba3 line unsafe for indexing with known base type & unkown identifier
(cherry picked from commit 0780ad2800)
2020-04-23 11:10:28 +02:00
Stoofin 243711e77f Pattern bind counts as assignment
Fixes #34697

(cherry picked from commit 44281f233d)
2020-04-23 11:10:06 +02:00
Rémi Verschelde 253fc093b8 DocData: Skip unexposed classes
Properly expose classes that we actually want accessible.

(cherry picked from commit 0ef8bcac4d)
2020-04-21 14:15:34 +02:00
Thakee Nathees 3d69fe95e5 autocomplete for disconnect, is_connected implemented
(cherry picked from commit efe90fce01)
2020-04-16 12:47:19 +02:00
Thakee Nathees 3658f7127e := fails on some nodes fix: #37357
(cherry picked from commit bdd7048cb5)
2020-04-16 11:46:23 +02:00
Thakee Nathees df87601c88 Fix for loop range bug: #37358
(cherry picked from commit 0b5bad78c0)
2020-04-06 20:58:21 +02:00
Thomas ten Cate c2469d0c6d Add missing docs for assert message in GDScript
Seems like this was overlooked in PR #31142. See also issue #17082.

(cherry picked from commit 4c3c73ef9c)
2020-04-06 18:17:59 +02:00
Rajat Goswami 19e71f94d8 Adding missing include guards to header files identified by LGTM.
This addresses the issue godotengine/godot#37143

(cherry picked from commit 2ecf928ae3)
2020-03-25 11:38:54 +01:00
Thakee Nathees 5798c8135f logic error in gdscript_parser.cpp for-loop-range
there was a logic error in for loop range argument that
check if all of the argument were constants, fixed

(cherry picked from commit bcbcf0f1ea)
2020-03-25 09:45:47 +01:00
Thakee Nathees 40b53bc29a duplicate arguments in a function handled
(cherry picked from commit 5424b626f9)
2020-03-25 09:44:51 +01:00
Rafael Delboni 5736e43fe4 fix: Return only scenes for script owners on LSP completion
Fix: #36680
(cherry picked from commit 2f08f4ef4e)
2020-03-25 09:44:09 +01:00
Rafael Delboni ecfe9c24a2 Improve LSP completion using scene owner
Fixes: #36473

(cherry picked from commit 06bce137e3)
2020-03-25 09:43:49 +01:00
Oliver Frank 41500249e3 Fix crash after closing a GDScript LSP session
(cherry picked from commit ed482f6167)
2020-03-25 09:43:28 +01:00
of9 511105be67 Migrating language server from Websockets to raw TCP
(cherry picked from commit 24b27043fe)
2020-03-25 09:43:05 +01:00
Thakee Nathees 708aab7920 typo in gdscript_workspace.cpp/remove_cache_parser() fixed
(cherry picked from commit 07c99340d1)
2020-03-09 09:51:59 +01:00
Hugo Locurcio d679edfa7f Add a practical example for @GDScript.linear2db()
One of its most common applications in games is for volume sliders.

See https://www.dr-lex.be/info-stuff/volumecontrols.html for
more information.

(cherry picked from commit a6fd6b78dd)
2020-03-04 12:40:14 +01:00
Hugo Locurcio 21a45dda7a Improve the @GDScript.inverse_lerp() documentation
This closes https://github.com/godotengine/godot-docs/issues/2589.

(cherry picked from commit 6b5573700b)
2020-03-04 12:40:14 +01:00
geequlim 57151c5e31 Fix hover symbol content position
(cherry picked from commit 03d2d01082)
2020-02-14 16:08:14 +01:00
Francois Belair f6968d5f17 Fix static functions loop using class' functions
Besides being incorrect, it also caused a hard editor crash for purely
static classes or classes with more static functions than methods.
2020-01-28 14:19:09 -05:00
Rémi Verschelde 4cee1cda5e
Merge pull request #35589 from akien-mga/doc-drop-category-property
doc: Drop unused 'category' property from header
2020-01-26 16:34:13 +01:00
Rémi Verschelde 09ced94dd4 doc: Do not expose Variant::NIL as a type in the class reference
Fix signals Variant arguments incorrectly listed as Nil.

Fixes #12520.
2020-01-26 16:08:11 +01:00
Rémi Verschelde 2d20fc39aa doc: Drop unused 'category' property from header
We already removed it from the online docs with #35132.

Currently it can only be "Built-In Types" (Variant types) or "Core"
(everything else), which is of limited use.

We might also want to consider dropping it from `ClassDB` altogether
in Godot 4.0.
2020-01-26 16:02:39 +01:00
Rémi Verschelde cbdbfb00ca doc: Document named color constants
Busywork but it's good for our completion rate :)
2020-01-26 12:08:16 +01:00
Rémi Verschelde 36e11d1c34
Merge pull request #35412 from DaividFrank/check_overriding_self
Disabled re-assigning 'self'
2020-01-22 20:47:52 +01:00
DaividFrank badabdf8b9 GDScript: Added checks in assign operations to disable re-assigning 'self' 2020-01-22 19:00:54 +02:00
Rémi Verschelde 4faaf6089a Remove unused #if 0'ed code 2020-01-21 21:41:54 +01:00
Dani Frank 8f5e424c66 Fix subclass finding in extend statement for sub-sub classes
lookup was always done on top level script instead of advancing to subclass each time.
this commit changes the lookup to always be at last found subclass
2020-01-18 11:55:27 +02:00
ChibiDenDen 9ffa9a6bac Fix constant access in base class through subclass instance
Fixes as issue where a subclass calls a base class method that tries to access a constant from the script.
The original code went through every ower class, and for each owner, went through its inheritance tree.
This seems like the wrong order, the modified code goes to each base class, and for each base class goes through the owner tree.
This is more in line with what the parser does, as the current impelemtation allows an access that the parser does not support.
This change should not negatively affect existing code due to the way the parser works
2020-01-17 00:12:45 +02:00
Rémi Verschelde 8b0e2a409b
Merge pull request #35218 from bojidar-bg/26691-parse-error-errors
Fix errors raised when showing parse errors in the editor
2020-01-16 22:32:49 +01:00
Bojidar Marinov da5b138e64
Fix errors raised when showing parse errors in the editor
Fixes #26691
2020-01-16 22:12:24 +02:00
Rémi Verschelde f2aa99a8e2
Merge pull request #35201 from bojidar-bg/27582-gdfunction-validate-instance
Validate instances of objects before trying to check their type in GDScript
2020-01-16 15:57:44 +01:00
Rémi Verschelde 4998983bd5
Merge pull request #35199 from dalexeev/master
Fix function arguments hint format in GDScript editor
2020-01-16 15:53:28 +01:00
Rémi Verschelde cd7b51b943
Merge pull request #35102 from ChibiDenDen/reuse_orphaned_subclass
#34161: Keep a weak reference to orphan subclasses to reuse on class reload
2020-01-16 15:49:52 +01:00
Bojidar Marinov dc4455d819
Validate instances of objects before trying to check their type in GDScript
Fixes #27582
2020-01-16 16:39:59 +02:00
Bojidar Marinov 19ce2d5159
Fix slight problems related to default values of exported typed arrays 2020-01-16 14:50:29 +02:00
Danil Alexeev 45b510b332 Fix function arguments hint format in GDScript editor
for consistency with the format of the documentation:
"type func_name(arg1: type, arg2: type)"
2020-01-16 15:41:02 +03:00
ChibiDenDen 86aa12e806 Keep a weak reference to orphan subclasses to reuse on class reload 2020-01-15 22:54:01 +02:00
Houkime e1a0ce5af9 Prevent GDScript language server from listening to external hosts by default
* Add bind_ip property to WebSocketServer defaulting to "*" (listen to everyone)
* Set default for GDscript Language Server to listen only to localhost

Fixes potential security issue with GDScript language server being exposed to the
broad net by default.
Since it is the server which primary usage is to provide utility to the local
editor there is no need to expose it.
2020-01-15 00:29:59 +00:00
Rémi Verschelde 40f0649e5b Fix typos with codespell
Using codespell 1.16.0.

See ab3bccdb78 for procedure.
2020-01-15 00:49:52 +01:00
Dani Frank d6f10cd08e Add fully_qualified_name for GDScript class 2020-01-14 17:33:33 +02:00
George Marques 1d129f9bec
GDScript: Check function arguments on release too
Needed because otherwise the certain type operations (such as type
casting) used as a function argument might become unresolved on release,
causing a compilation failure.

Fix #28680
2020-01-13 15:58:53 -03:00
Rémi Verschelde e32d232053
Merge pull request #35076 from vnen/gdscript-type-match-assign
Type match on assignment only if operators have type
2020-01-13 13:14:57 +01:00
George Marques e6060706ca
GDScript: Type match on assignment only if operators have type
This ensures that a value without type won't be wrongly assigned to a
typed variable when the types mismatch.
2020-01-13 08:51:24 -03:00
Geequlim d5e1890c85 Fix infinite loop error in document link parsing 2020-01-13 19:23:29 +08:00
geequlim e804eebfe5 Remove completion triggers for ',' and '(' which may conflict with signature helper 2020-01-11 23:51:25 +08:00
geequlim d901d5993b Allow enable/disable threading for LSP server
Restart LSP server when configurations change without restart the editor
2020-01-11 23:50:32 +08:00