Commit graph

626 commits

Author SHA1 Message Date
George Marques 4cb17191b8
GDScript: Allow inherited method to add optional arguments
Also show the parent method signature in the error message.
2018-07-25 20:50:11 -03:00
George Marques cd6ad5462c
GDScript: Fix returned value of get_default_argument_count() 2018-07-25 20:50:11 -03:00
George Marques 65c069c8d9
GDScript: Fix main script detection 2018-07-25 20:50:11 -03:00
George Marques b7bd85e70c
GDScript: Look up local scope first for detecting type 2018-07-25 20:50:11 -03:00
Hein-Pieter van Braam 0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
George Marques 3e87ad5187
Rewrite code completion
- Use data type struct from the parser.
- Avail from type hints when type can't be guessed.
- Consider inner classes and other scripts when looking for candidates.
2018-07-20 21:55:18 -03:00
George Marques 3445dca01d
Add ability to infer variable type from assigned value
Syntax: var x : = 42
Infers the type of "x" to be an integer.
2018-07-20 21:55:18 -03:00
George Marques 03746da73f
Add editor highlight for type-safe lines
The line number is hightlighted to indicate that the line contains only
type-safe code.
2018-07-20 21:55:18 -03:00
George Marques a2305cd8b2
Fix line number detection in some parser nodes 2018-07-20 21:55:17 -03:00
George Marques 75f395c2a0
Use type hints to improve completion
- Allow type hints to be completed.
- Use type information to infer completion candidates.
- Show typed function signature in tooltip.
- Add type hints when completing declaration from virtual functions
(optional).
2018-07-20 21:55:17 -03:00
George Marques 95351ac867
Add syntax highlighting to type hints 2018-07-20 21:55:17 -03:00
George Marques e3d72d14ff
Use type information to enable GDScript introspection
This makes the Script API provide accurate information when requesting
property or method info.
2018-07-20 21:55:17 -03:00
George Marques 4b18c4e448
Add typed instructions to GDScript
- Typed assignment (built-in, native, and script).
- Cast (built-in conversion; native and script checks).
- Check type of functions arguments on call.
- Check type of members on set.
2018-07-20 21:55:17 -03:00
George Marques 743053734f
Add static type checks in the parser
- Resolve types for all identifiers.
- Error when identifier is not found.
- Match return type and error when not returning a value when it should.
- Check unreachable code (code after sure return).
- Match argument count and types for function calls.
- Determine if return type of function call matches the assignment.
- Do static type check with match statement when possible.
- Use type hints to determine export type.
- Check compatibility between type hint and explicit export type.
2018-07-20 21:55:16 -03:00
George Marques f7793fc5c9
Store type hint of declared identifiers 2018-07-20 21:55:16 -03:00
George Marques b7a00aead0
Move inheritance resolution to the parser 2018-07-20 21:55:16 -03:00
George Marques 8aab9a06d4
Add typing syntax 2018-07-20 21:55:16 -03:00
Rémi Verschelde 7c9f7452f4 Style: Format code with clang-format 6.0.1 2018-07-18 16:27:03 +02:00
Juan Linietsky a3f1ee5c57 Global class names (and GDScript support for it) 2018-07-15 19:29:00 -03:00
Max Hilbrunner 3f272c6ae6
Merge pull request #19637 from dragmz/19548
Fix onready vars / vars accessing class members if _ready / _init not present
2018-07-05 04:15:47 +02:00
Max Hilbrunner d988d188ad
Merge pull request #18966 from chanon/new-debug-print
Add new debug print method that shows line number where the print came from
2018-07-04 23:50:45 +02:00
Max Hilbrunner aad475937b
Merge pull request #19828 from jjay/fix_yield_leak
Fix memory leak in GDScript during infinnity loops with yields
2018-07-03 18:51:13 +02:00
Max Hilbrunner 5885e1c6dd
Merge pull request #18976 from chanon/new-get-stack
Add new get_stack function to get GDScript stack trace as array
2018-07-03 17:50:05 +02:00
Max Hilbrunner 0705eb904a
Merge pull request #19251 from YeldhamDev/script_templates_changes
Small changes to the comments in the script templates
2018-07-03 16:48:03 +02:00
Yasha Borevich 30317296af Fix memory leak in GDScript during infinnity loops with yields 2018-06-28 23:55:30 +03:00
Marcin Zawiejski 317dcb084b Fix onready vars / vars accessing class members if _ready / _init not present 2018-06-18 23:31:48 +02:00
Bojidar Marinov 8ecef3496c
Add proper type information to array property
Part of #19158
2018-06-18 22:24:31 +03:00
Paulb23 08c036b706 Removed duplicate default colours and removed GDScriptHighligher colours from main editor. 2018-06-13 18:25:02 +01:00
Rémi Verschelde f0fa590210
Merge pull request #19526 from robojumper/fix_tutorials
Add support for tutorial links to makerst.py
2018-06-13 14:29:45 +02:00
robojumper 98b59cf2a3 Add support for tutorial links to makerst.py
Also change the <tutorials> structure to make use of individual <link> tags
2018-06-12 17:40:24 +02:00
Jairo Honorio afcac41d31 Inner classes' functions now appear in the editor's functions panel
Fixes #19386
2018-06-12 10:43:37 -03:00
Michael Alexsander Silva Dias fd17b960e9 Small changes to the comments in the script templates. 2018-06-11 02:04:51 -03:00
Rémi Verschelde 3334209a73 SCons: Pass env to modules can_build method
This allows to disable modules based on the environment,
in particular `env[tools]` which tells us if we are
building the editor or not.
2018-05-30 19:11:36 +02:00
Fabio Alessandrelli 8e35d937a9 New sync keywords in GDScript, NativeScript, Mono 2018-05-29 20:26:41 +02:00
Fabio Alessandrelli 1400f6fdc4 Refactor RPCMode enum and checks 2018-05-29 20:26:41 +02:00
Max Hilbrunner 4c69a495c9
Revert "RPCMode refactor, more sync modes" 2018-05-29 11:47:52 +02:00
Max Hilbrunner d0b62ce155
Merge pull request #19021 from Faless/rpc_sync_fix
RPCMode refactor, more sync modes
2018-05-29 09:44:03 +02:00
George Marques 38284bc6da
Enable singletons to be recognized as constant expressions
Fix #14681
2018-05-28 13:40:16 -03:00
chanon 3ea6d9f37d add new print_debug method which shows source and line number 2018-05-28 18:37:07 +07:00
Fabio Alessandrelli a5e8a3be5e New sync keywords in GDScript, NativeScript, Mono 2018-05-26 10:49:33 +02:00
Fabio Alessandrelli 9de4ffde61 Refactor RPCMode enum and checks 2018-05-26 10:43:43 +02:00
Max Hilbrunner aee8d26252
Merge pull request #19131 from YeldhamDev/connection_comment_capitalize
Capitalized comments of methods created by the Connect Signal dialog
2018-05-24 01:21:17 +02:00
Michael Alexsander Silva Dias 4e257293d9 Capitalized comments of methods created by the Connect Signal dialog. 2018-05-23 18:11:00 -03:00
George Marques 3cec24baa8
Fix positive operator in GDScript compiler 2018-05-23 17:43:56 -03:00
chanon a56d6ff35f add new get_stack function to get GDScript stack trace as array 2018-05-17 21:06:30 +07:00
Rémi Verschelde b0649d2718
Merge pull request #18405 from flashyincceo/gdscript-constants-help
Fix Ctrl+click on @GDScript constants
2018-05-17 09:36:55 +02:00
Juan Linietsky 47d4a011d8
Merge pull request #18545 from vnen/editor-autoload
Enable autoload in editor
2018-05-14 17:59:34 -03:00
Rémi Verschelde 919d802e66
Merge pull request #18183 from Paulb23/gdscript_highlighter_inital_changes
GDScript function definition and get_node shortcut syntax highlighting
2018-05-10 01:25:51 +02:00
Juan Linietsky 299d8a80ba
Merge pull request #16106 from poke1024/gdscript-lerp
GDScript: generalize lerp
2018-05-07 20:36:31 -03:00
Juan Linietsky ff1e7cfbf4 Add is_instance_valid() method to GDScript, ending more than a decade of pain. 2018-05-07 17:30:03 -03:00
Max Hilbrunner ffb6f8f1ca
Merge pull request #18406 from YeldhamDev/script_templates_period
Changed periods in the script templates
2018-05-04 11:20:16 +02:00
Rémi Verschelde 460e551ddf
Merge pull request #16418 from bojidar-bg/15961-gdscript-array-export
Allow exporting arrays of resources in GDScript
2018-05-03 21:19:15 +02:00
Michael Alexsander Silva Dias 093b069bf6 Changed periods in the script templates. 2018-05-02 11:42:09 -03:00
Rémi Verschelde d33308921d
Merge pull request #18553 from bzztbomb/fix/stack_underflow_when_debuggin_in_release
Fix a crash when trying to run Godot debugger on a release build.
2018-05-02 10:48:45 +02:00
Rémi Verschelde b0cf3628aa
Merge pull request #18452 from flashyincceo/enum-no-class
Fix enums without class name not opening docs page
2018-05-02 10:32:19 +02:00
Rémi Verschelde fb917b5568
Merge pull request #18531 from KidRigger/issue5972
Adds keywords to autocomplete predictions.
2018-05-02 10:22:08 +02:00
Brian Richardson 9149b11973 Fix a crash when trying to run Godot debugger on a release build.
The GDScriptLanguage::enter_function is wrapped in #ifdef DEBUG but the exit_function is not, resulting in a stack underflow error.
2018-05-01 15:40:30 -07:00
Rémi Verschelde de97339a2d
Merge pull request #18291 from akien-mga/coverity-uninitialized-scalar-var
Fix Coverity reports of uninitialized scalar variable
2018-05-01 19:14:07 +02:00
George Marques decf178033
Enable autoload in editor
- Tool scripts will be executed and can be accessed by plugins.
- Other script languages can implement add/remove_named_global_constant
to make use of this functionality.
2018-05-01 11:44:08 -03:00
Peter Folkins ccd986f53e Fix enums without class name not opening docs page 2018-05-01 07:57:53 -05:00
Anish 6e32157a65 Adds keywords to autocomplete predictions.
Adds keywords to the autocomplete prediction in GDScript so
they are not replaced by irrelevant predictions.

Fixes: #5972
2018-05-01 11:48:16 +05:30
Peter Folkins 825d49dfe2 Fix Ctrl+click on @GDScript constants 2018-04-24 20:50:21 -05:00
Hugo Locurcio 1c419531a0 Change ".." punctuation for "..." in editor strings (#16507) 2018-04-22 19:36:01 +02:00
Paulb23 adeed58477 Added GDScript NodePath highlighting 2018-04-20 21:00:07 +01:00
Paulb23 4cd16f6ba9 Added GDScript function definition highlighting 2018-04-20 20:54:31 +01:00
Paulb23 28dfc7f915 GDScript highlighter now remembers previous state 2018-04-20 20:46:08 +01:00
Paulb23 c3d93edf3d Exclude GDScriptSyntaxHighlighter from non-tool builds 2018-04-20 20:45:57 +01:00
Rémi Verschelde bf7ca623a6 Fix Coverity reports of uninitialized scalar variable
Fixes most current reports on Coverity Scan of uninitialized scalar
variable (CWE-457): https://cwe.mitre.org/data/definitions/457.html

These happen most of the time (in our code) when instanciating structs
without a constructor (or with an incomplete one), and later returning
the instance. This is sometimes intended though, as some parameters are
only used in some situations and should not be double-initialized for
performance reasons (e.g. `constant` in ShaderLanguage::Token).
2018-04-19 15:20:45 +02:00
Rémi Verschelde 36552c2c90
Merge pull request #18040 from Paulb23/color_region_cache
Fixed colour regions and added local colour region cache
2018-04-09 16:05:26 +02:00
Juan Linietsky 34e367597d
Merge pull request #16556 from aragar/master
For-in loop variable added to autocompletion
2018-04-08 17:25:01 -03:00
Paulb23 b571a29df5 Fixed color regions and added local color region cache 2018-04-07 14:14:19 +01:00
Paulb23 63c8d0f455 Renamed GDSyntaxHighlighter to GDScriptSyntaxHighlighter 2018-04-04 20:02:42 +01:00
Rémi Verschelde 5ede505f14
Merge pull request #17923 from Paulb23/add_abstract_syntax_highlighter
Abstracted the syntax highlighter from text edit.
2018-04-04 09:50:51 +02:00
Felix Yang 7d5a40c3e6 Ctrl+Clicking a enum now scrolls down to it in the docs. 2018-04-03 21:56:54 +02:00
Paulb23 f7c727e6c3 Abstracted the syntax highlighter from text edit 2018-04-02 12:41:44 +01:00
Hein-Pieter van Braam aed2fedd16
Merge pull request #17291 from Warlaan/master
completed-signal for coroutines with more than one yield
2018-03-15 23:11:37 +01:00
Poommetee Ketson 01ec06d9ae
Fix script template on _ready behavior 2018-03-15 18:38:53 +07:00
Lars Kokemohr 3dfef37628 completed-signal is emitted by all GDScriptFunctionStates of a coroutine now, allowing to yield for completion of a function with more than one yield inside. 2018-03-14 16:42:13 +01:00
x1212 d2dc8fd423 fix enum from preloaded script in export
without triggering unnecessary reloads and parsing.
2018-03-04 18:01:15 +01:00
Rémi Verschelde 3fa77b3172 doc: Remove status from hardcoded version string
It has no practical use case and just generates noise for each alpha, beta, etc.
2018-02-27 13:40:49 +01:00
anakimluke bd3b958a25 Removed whitespaces around arguments of functions.
Functions automatically generated by conneting
signals via GUI put whitespaces around the
arguments of the generated function. This is
inconsistent with the style guide.

This commit fixes that.

(cherry picked from commit 370f84f41c)
2018-02-24 01:34:26 +01:00
luz.paz 612ab4bbc6 Fix typos with codespell
Found via `codespell -q 3 --skip="./thirdparty,./editor/translations" -I ../godot-word-whitelist.txt`
Whitelist consists of:
```
ang
doubleclick
lod
nd
que
te
unselect
```
2018-02-21 19:46:06 +01:00
Rémi Verschelde 7455244866
Merge pull request #15852 from poke1024/color_hsv
Add Color.from_hsv()
2018-02-19 21:51:04 +01:00
Rémi Verschelde 43de4eb4d2
Merge pull request #15933 from x1212/fix_preload_in_exports
fix spurious error messages during autocomplete and validate
2018-02-19 21:46:26 +01:00
Rémi Verschelde aeed774fef
Merge pull request #16173 from vnen/gdscript-arguments
Add argument count check for some GDScript functions
2018-02-19 21:35:53 +01:00
Rémi Verschelde 3c7a39b40c doc: Update version string in header 2018-02-19 10:46:33 +01:00
x1212 48c9ed4545 fix spurious error messages during autocomplete and validate
_parse() caused resets on members like validating and
for_completion by calling clear().
2018-02-14 18:13:00 +01:00
Rémi Verschelde 11441e1556
Merge pull request #16176 from vnen/gdscript-default-args
Show default values in docs for GDScript built-in functions
2018-02-14 15:48:48 +01:00
Rado'sPC\aRaGaR f97ebdcab3 For-in loop variable added to autocompletion
Fix for #16494
2018-02-11 11:29:30 +02:00
Bojidar Marinov d855fdb451
Allow exporting arrays of resources in GDScript
Fixes #15961
2018-02-05 16:41:13 +02:00
Andreas Haas 95cfa9bf74
GDScriptParser: Remove debug prints. 2018-02-02 20:37:59 +01:00
George Marques dca2ae78dd
Show default values in docs for GDScript built-in functions 2018-01-30 02:08:12 -02:00
George Marques 802d5c4c6c
Add argument count check for some GDScript functions
- Print functions have no check.
- Also remove extra apostrophe from the error report.
2018-01-30 01:32:08 -02:00
Bernhard Liebl 05a16549ef GDScript: generalize lerp 2018-01-27 08:14:13 +01:00
Rémi Verschelde f2e3825616 doc: Fix references to online tutorials after godotengine/godot-docs#1015 2018-01-25 09:03:59 +01:00
Rémi Verschelde d516aab8fa doc: Sync with current source
Also enhance RigidBody docs as per https://github.com/godotengine/godot-docs/pull/1018
and fix the version tag in all files (not really stable yet, but it makes no sense
to hardcode rc3 at this stage).
2018-01-25 08:50:56 +01:00
Bernhard Liebl ec98e0b715 GDScript: always call ResourceLoader::load() in non-completion mode 2018-01-21 09:32:52 +01:00
Juan Linietsky c58891ff4c Allow shadowing class members with local variables in GDScript, closes #15896 2018-01-20 17:45:19 -03:00
Rémi Verschelde 0359fed313
Merge pull request #15849 from poke1024/preload-completion
GDScript: fix autocompletion for preload() (issue 15766)
2018-01-18 23:21:41 +01:00
Bernhard Liebl 67ae443c56 Suppress errors on autocompletion for preload() 2018-01-18 22:29:45 +01:00