Commit graph

1279 commits

Author SHA1 Message Date
Rémi Verschelde
a418d09617
Merge pull request #51166 from RandomShaper/fix_can_reset_3.x 2021-08-09 09:19:25 +02:00
Francois Belair
6db17a523e Fix LSP completion crashing on sceneless scripts 2021-08-06 15:31:04 -04:00
Yuri Sizov
fcbe5a3fde Add theme item descriptions to the online documentation 2021-08-06 18:20:51 +03:00
Francois Belair
1f0fa16a15
Fix LSP parsing get_node only from the scene root
(cherry picked from commit 03f8fa9f62)
2021-08-06 11:45:08 +02:00
Rémi Verschelde
63047093c9
Merge pull request #48616 from Razoric480/lsp-3x-rename
Implement LSP didSave notify and rename request [3.x]
2021-08-04 20:28:16 +02:00
Rémi Verschelde
f5836b40d4
doc: Use self-closing tags for return and argument
For the time being we don't support writing a description for those, preferring
having all details in the method's description.

Using self-closing tags saves half the lines, and prevents contributors from
thinking that they should write the argument or return documentation there.

(cherry picked from commit 7adf4cc9b5)
2021-08-03 10:20:19 +02:00
Pedro J. Estébanez
7426b3fa91 Add Script::inherits_script()
Partial cherry-pick of 5d4dc2d45c.

Co-authored-by: Juan Linietsky <reduzio@gmail.com>
2021-08-02 15:18:30 +02:00
Francois Belair
02bc1bf355 Fix LSP SymbolKind reporting wrong types
Classes were properties, functions interfaces, etc.
2021-07-24 16:25:47 -04:00
Hugo Locurcio
069281d58f
Improve documentation for GDScript constants
(cherry picked from commit 8ff8c1e5f8)
2021-07-24 00:59:35 +02:00
Francois Belair
802bb9c01f Implement LSP didSave notify and rename request 2021-07-17 11:50:17 -04:00
Francois Belair
5774098a91
Implement didClose notification in LSP
(cherry picked from commit 10429019ad)
2021-07-13 10:20:02 +02:00
Francois Belair
59d72279ae
Translate file path to URI on LSP symbol requests
(cherry picked from commit a56c2e459b)
2021-06-29 13:12:15 +02:00
Marcel Admiraal
7e03bd1671 Remove duplicate WARN_PRINTS macro 2021-06-18 12:57:59 +01:00
Pedro J. Estébanez
2d1943b8d1
Fix slow load/save of scenes with many instances of the same script
(cherry picked from commit 2ca6b9c610)
2021-06-17 12:47:54 +02:00
Marcel Admiraal
5a58516231 Remove duplicate ERR_PRINTS macro 2021-06-16 11:56:25 +01:00
Hugo Locurcio
a38b447413
Highlight control flow keywords with a different color
This makes them easier to distinguish from other keywords.
2021-05-25 00:31:39 +02:00
Rémi Verschelde
eb78f80f03
Fix typos with codespell
Using codespell 2.0.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
GIRD
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2021-05-20 12:56:56 +02:00
Rémi Verschelde
6355877c0d
Merge pull request #47863 from mphe/same_line_warning_ignore
Allow warning-ignore in the same line as the respective warning
2021-05-18 15:08:00 +02:00
Pedro J. Estébanez
817ffc01e1
Make all file access 64-bit (uint64_t)
This changes the types of a big number of variables.

General rules:
- Using `uint64_t` in general. We also considered `int64_t` but eventually
  settled on keeping it unsigned, which is also closer to what one would expect
  with `size_t`/`off_t`.
- We only keep `int64_t` for `seek_end` (takes a negative offset from the end)
  and for the `Variant` bindings, since `Variant::INT` is `int64_t`. This means
  we only need to guard against passing negative values in `core_bind.cpp`.
- Using `uint32_t` integers for concepts not needing such a huge range, like
  pages, blocks, etc.

In addition:
- Improve usage of integer types in some related places; namely, `DirAccess`,
  core binds.

Note:
- On Windows, `_ftelli64` reports invalid values when using 32-bit MinGW with
  version < 8.0. This was an upstream bug fixed in 8.0. It breaks support for
  big files on 32-bit Windows builds made with that toolchain. We might add a
  workaround.

Fixes #44363.
Fixes godotengine/godot-proposals#400.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2021-05-16 17:52:31 +02:00
Rémi Verschelde
4185a22ca8
Merge pull request #48131 from LightningAA/fix-48113-3.x
[3.x] Fix Array.max() navigating to @GDScript.max()
2021-05-06 20:42:23 +02:00
Rémi Verschelde
140350d767
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2021-05-05 15:02:01 +02:00
Rémi Verschelde
a828398655
Style: Replaces uses of 0/NULL by nullptr (C++11)
Using clang-tidy's `modernize-use-nullptr`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
2021-05-04 16:30:23 +02:00
Rémi Verschelde
b5e1e05ef2
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks 2021-05-04 14:45:16 +02:00
Rémi Verschelde
64a63e0861
Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde
3d15f04668
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine 2021-05-04 14:45:15 +02:00
Rémi Verschelde
6e600cb3f0
Style: Set clang-format Standard to c++14 2021-05-04 14:45:15 +02:00
kleonc
f04a964627 Make posmod use int64_t instead of int 2021-05-03 22:03:16 +02:00
Rémi Verschelde
70ae90e0e8
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.

Backport of #48239.
2021-04-29 12:34:11 +02:00
Rémi Verschelde
c3272997cd
doc: Update classref headers with 3.4 version 2021-04-26 13:15:29 +02:00
Francois Belair
1f54a75310
Make LSP update the filesystem of changed scripts
This updates global classes and exposes base member variables.
Fixes #39713

(cherry picked from commit b16bb33a5b)
2021-04-26 12:20:28 +02:00
Lightning_A
2c4aa50648 Fix Array.max() navigating to @GDScript.max() etc. 2021-04-23 09:40:24 -06:00
Marvin Ewald
3715ea268f Allow warning-ignore in same line 2021-04-13 13:55:33 +02:00
Rémi Verschelde
ed44e2806f
doc: Fix markup issues in classref 2021-04-07 11:52:44 +02:00
Francois Belair
4e8e887748 Implement LSP didDeleteFiles to clear diagnostics
Fixes #43133
2021-04-01 13:41:53 -04:00
Rémi Verschelde
015973df04
doc: Make all tutorial links point to 3.3 branch of docs 2021-03-26 10:43:43 +01:00
Paul Joannon
596169d7df
class reference proofreading
(cherry picked from commit 8455e901f3)
2021-03-26 09:49:07 +01:00
Francois Belair
7f8fe58825 Make LSP parser aware of variables in sub-blocks
Fixes #43164 and Fixes godotengine/godot-vscode-plugin#207
2021-03-24 16:52:38 -04:00
Rémi Verschelde
1aba997d75
doc: Sync classref with 3.3 version bump 2021-03-23 13:40:34 +01:00
Hugo Locurcio
ee8661158c
Document the valid input range for acos() and atan()
(cherry picked from commit d359e159da)
2021-03-16 11:37:26 +01:00
Taylor C. Richberger
59b82e1b6a remove invalid codeLensProvider value from lsp
codeLensProvider was false, it may not be a boolean like some of the other providers can, only optionally present.

(cherry picked from commit 91ce8d5fff)
2021-02-25 22:34:56 +01:00
Angad Kambli
327586f582 fix minor issue in smooth step function's documentation
(cherry picked from commit 892060fa47)
2021-02-22 14:16:42 +01:00
Vignesh1-art
13871deb57 Fixed Invalid function bindings #46135
Fixed  GDScriptLanguageProtocol::notify_client - have 3 arguments, but only 2 are binded

(cherry picked from commit a5d931033e)
2021-02-18 23:46:54 +01:00
Pedro J. Estébanez
6d89f675b1 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez
4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Meriipu
347a9df0a1
GDScript: Clarified/fixed inaccuracies in the built-in function docs.
The input to smoothstep is not actually a weight, and the decscription
of smoothstep was pretty hard to understand and easy to misinterpret.

Clarified what it means to be approximately equal.

nearest_po2 does not do what the descriptions says it does. For one,
it returns the same power if the input is a power of 2. Second, it
returns 0 if the input is negative or 0, while the smallest possible
integral power of 2 actually is 1 (2^0 = 1). Due to the implementation
and how it is used in a lot of places, it does not seem wise to change
such a core function however, and I decided it is better to alter the
description of the built-in.

Added a few examples/clarifications/edge-cases.

(cherry picked from commit 7f9bfee0ac)
2021-02-11 13:12:06 +01:00
lucasvanmol
6742f6894e
Fix highlight color for class attributes that are also keywords
Fixes #45338. 
This PR also makes any word after a "." not highlight as a keyword, i.e. the cos
in Color.cos will highlight the same as any other class constant. Additionally,
trying to do things like ".print()" will not highlight print as a keyword but as
a class function.
2021-01-21 11:46:32 +00:00
Rémi Verschelde
49646383f1
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Rémi Verschelde
0a8cc0a565
Merge pull request #44006 from RandomShaper/gds_needless_check_3.2
Remove useless check in GDScript (3.2)
2021-01-11 13:53:42 +01:00
Rémi Verschelde
3d31433229
doc: Remove links to RNG tutorial, not yet in 3.2 branch 2021-01-07 14:33:36 +01:00
LoipesMas
0fc433d046
More explicit wording for str() and print() functions
(cherry picked from commit 9c65927aeb)
2021-01-05 21:33:34 +01:00
skyace65
e072b3db82
Pow method doc fix
(cherry picked from commit 4fd20015f3)
2020-12-29 16:01:59 +01:00
PouleyKetchoupp
e1561a6f29 Fix regression in gdscript initialization
A case was missing when cherry-picking PR #44093 from 4.0 to 3.2 branch.
2020-12-09 17:11:03 -07:00
PouleyKetchoupp
9d2c012f23
Fix base script not initialized properly in some cases
Storing script references to pointer only in result.script_type could
lead to losing the last reference, causing further conversions from
Script* to Ref<Script> to fail.

Now result.script_type_ref is always set first, and then cleared in the
specific case of the script being the owner, to avoid cyclic reference
issues.

(cherry picked from commit 87d73faa66)
2020-12-09 11:22:05 +01:00
Danil Alexeev
6c3a0e3a5a
Several edits to the GDScript docs
(cherry picked from commit bf96056ad0)
2020-12-09 11:22:03 +01:00
Pedro J. Estébanez
46fc451b9c Remove useless check in GDScript
The removed check was adding a protection for the case where a `Reference` has not yet got its reference count initialized and a script is called on it. That would cause the object to be released after the call. The removed code was constructing the `Variant` via the `Object` constructor so it didn't deal with the reference count and so the release was prevented.

 However, `Variant` no longer works that way so that check was useless. Now it's just illegal to run GDScript on a Reference whose reference count has not been initialized.
2020-12-01 12:35:06 +01:00
Rémi Verschelde
94c31175de
Merge pull request #43152 from Chaosus/color_autocompletion_3.2
[3.2] Shows ColorRect in Color constants autocompletion
2020-11-26 09:32:32 +01:00
Hugo Locurcio
913afd843b
Clarify that code in assert() should avoid side effects
(cherry picked from commit d6c7073bd7)
2020-11-11 15:44:18 +01:00
Aaron Franke
1bb81488bb
Minor clamp and float fixes
(cherry picked from commit ee79fc627c)
2020-11-11 15:30:57 +01:00
Umang Kalra
f40d46bafc
Fixes the misleading error message for call_recursive method for TreeItems
(cherry picked from commit c37f633216)
2020-11-11 15:12:02 +01:00
George Marques
798ee982ac Actually set GDScript static reference
(cherry picked from commit 0f1da72492)
2020-10-29 21:04:57 +01:00
George Marques
e360dc9a79 GDScript: Remove self static reference and create one on calls
This is needed because of the new changes to Variant. The reference
counter is increased by adding it to a Variant, which means no GDScript
will be freed (or will be double freed if manually freed somewhere).

(cherry picked from commit 4d960efafc)
2020-10-29 21:04:57 +01:00
Yuri Roubinsky
374253242d [3.2] Shows ColorRect in Color constants autocompletion 2020-10-28 12:39:41 +03:00
Mateo de Mayo
edb79e584a Fix misleading editor message when redeclaring variables 2020-10-22 18:32:34 -03:00
Haoyu Qiu
82900e54ea Fixes crash after using enums in export variables 2020-10-20 18:41:41 +08:00
Rémi Verschelde
4287af5148
doc: Make docs.godotengine.org links point to 3.2 branch 2020-10-19 16:10:01 +02:00
Hugo Locurcio
8d445f3f9f
Link the Random number generation tutorial in the class reference
(cherry picked from commit 802c1e4df1)
2020-10-19 16:10:00 +02:00
Serhat
09a8dd7b3b
Fixed padding bug of sprintf function
(cherry picked from commit 9f2cdfea82)
2020-10-04 20:51:58 +02:00
Andrii Doroshenko (Xrayez)
1a71792655
Cross-reference GDScript load and ResourceLoader.load in classref
The GDScript `load` mention is moved from the class `ResourceLoader`
description to the `ResourceLoader.load` method description instead,
where it is more likely to be found.

(cherry picked from commit a8404cf56c)
2020-10-04 20:51:40 +02:00
Paulb23
2ef8aba8e9 Fix gdscript multiline string nested highlighting 2020-10-03 16:16:34 +01:00
Rémi Verschelde
8d36b7206c
Merge pull request #42460 from ThakeeNathees/signal-lines-marked-safe
[3.2] GDScript signal lines marked as safe
2020-10-01 14:18:22 +02:00
Rémi Verschelde
b83f9d47a0
Merge pull request #41830 from RandomShaper/fix_40353_3.2
Avoid warning about harmless unfulfilled yields (3.2)
2020-10-01 14:17:56 +02:00
Thakee Nathees
a69c3cace2 GDScript signal lines marked as safe
Fix: #33927
2020-10-01 17:01:11 +05:30
Pedro J. Estébanez
d56112005f
Avoid infinite loop in GDScript at shutdown
(cherry picked from commit de4e54dd91)
2020-09-29 13:57:55 +02:00
Hugo Locurcio
880ab559ec
Improve documentation related to printing error/warning messages
(cherry picked from commit 50f3a8e312)
2020-09-29 08:54:45 +02:00
Pedro J. Estébanez
4cab6452d9 Fix GDScript leak avoidance
Modify usage of types so that the `Ref` created from `base_type.script_type` doesn't involve converting first to `Variant`, which will use the constructor for `Object *`, as if the argument wasn't a `Reference`, and therefore will convert back to null.
2020-09-25 01:41:31 +02:00
Rémi Verschelde
bca2633f93
Merge pull request #41931 from RandomShaper/fix_gdscript_leaks_3.2
Fix leaks in GDScript (3.2)
2020-09-24 08:33:04 +02:00
Rémi Verschelde
c8859f0463
Fix typos with codespell
Using codespell 1.17.1.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2020-09-18 14:09:51 +02:00
Danil Alexeev
06f3cd8bd8
Several documentation improvements
(cherry picked from commit a4c5790350)
2020-09-15 19:26:40 +02:00
Pedro J. Estébanez
8e64969184 Ensure cyclic dependencies between scripts are broken at exit 2020-09-09 14:57:34 +02:00
Pedro J. Estébanez
a0969662cd Prevent cyclic reference between script and its members 2020-09-09 13:51:53 +02:00
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