From dd09ae50e117f618381480d4f1281536b557ae0b Mon Sep 17 00:00:00 2001 From: Ovnuniarchos Date: Mon, 20 Jul 2015 20:02:46 +0200 Subject: Added FLAGS to int hint to make an int a bitmask on the editor. --- modules/gdscript/gd_parser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index afe8c9aa71..50036e7b83 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2315,6 +2315,17 @@ void GDParser::_parse_class(ClassNode *p_class) { case Variant::INT: { + if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="FLAGS") { + + current_export.hint=PROPERTY_HINT_ALL_FLAGS; + tokenizer->advance(); + if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) { + _set_error("Expected ')' in hint."); + return; + } + break; + } + if (tokenizer->get_token()==GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type()==Variant::STRING) { //enumeration current_export.hint=PROPERTY_HINT_ENUM; -- cgit v1.2.3 From 7843ec6633625455e689e711aa62e9d8337689fa Mon Sep 17 00:00:00 2001 From: Gen Date: Sat, 1 Aug 2015 14:02:10 +0800 Subject: add flag and multiline hits in GDScript `export (flag) var test` for PROPERTY_HINT_ALL_FLAGS `export (multiline) var test` for PROPERTY_HINT_MULTILINE_TEXT --- modules/gdscript/gd_parser.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index afe8c9aa71..755997ef31 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2542,16 +2542,23 @@ void GDParser::_parse_class(ClassNode *p_class) { } else if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) { String identifier = tokenizer->get_token_identifier(); - if (!ObjectTypeDB::is_type(identifier,"Resource")) { - - current_export=PropertyInfo(); - _set_error("Export hint not a type or resource."); + if (identifier == "flag") { + current_export.type=Variant::INT; + current_export.hint=PROPERTY_HINT_ALL_FLAGS; + }else if (identifier == "multiline"){ + current_export.type=Variant::STRING; + current_export.hint=PROPERTY_HINT_MULTILINE_TEXT; + } else { + if (!ObjectTypeDB::is_type(identifier,"Resource")) { + + current_export=PropertyInfo(); + _set_error("Export hint not a type or resource."); + } + + current_export.type=Variant::OBJECT; + current_export.hint=PROPERTY_HINT_RESOURCE_TYPE; + current_export.hint_string=identifier; } - - current_export.type=Variant::OBJECT; - current_export.hint=PROPERTY_HINT_RESOURCE_TYPE; - current_export.hint_string=identifier; - tokenizer->advance(); } -- cgit v1.2.3 From 04cb3c9eb13b3824f676bc29e037802bffc3bdac Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 25 Aug 2015 20:45:51 -0300 Subject: Ability to edit all kinds of arrays from the property editor. Yes, I'm trying to convince you to test the alpha release by adding all these now :) --- modules/gdscript/gd_parser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index f7aaaf7ee5..283b50f966 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2625,14 +2625,14 @@ void GDParser::_parse_class(ClassNode *p_class) { Node *subexpr=NULL; - subexpr = _parse_and_reduce_expression(p_class,false); + subexpr = _parse_and_reduce_expression(p_class,false,autoexport); if (!subexpr) return; member.expression=subexpr; if (autoexport) { - if (subexpr->type==Node::TYPE_ARRAY) { + if (1)/*(subexpr->type==Node::TYPE_ARRAY) { member._export.type=Variant::ARRAY; @@ -2640,7 +2640,7 @@ void GDParser::_parse_class(ClassNode *p_class) { member._export.type=Variant::DICTIONARY; - } else { + } else*/ { if (subexpr->type!=Node::TYPE_CONSTANT) { -- cgit v1.2.3 From 319cc7e3aec12fee28b3ea750d5ce1bf7a27bd8d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 30 Aug 2015 11:50:10 -0300 Subject: detect node and variable assignments in _ready, _init, etc for further code completion --- modules/gdscript/gd_parser.cpp | 82 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 10 deletions(-) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 283b50f966..571d340957 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -170,6 +170,7 @@ void GDParser::_make_completable_call(int p_arg) { completion_line=tokenizer->get_token_line(); completion_argument=p_arg; completion_block=current_block; + completion_found=true; tokenizer->advance(); } @@ -190,6 +191,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type,StringName& ide completion_function=current_function; completion_line=tokenizer->get_token_line(); completion_block=current_block; + completion_found=true; tokenizer->advance(); if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) { @@ -1414,6 +1416,20 @@ GDParser::Node* GDParser::_parse_and_reduce_expression(Node *p_parent,bool p_sta return expr; } +bool GDParser::_recover_from_completion() { + + if (!completion_found) { + return false; //can't recover if no completion + } + //skip stuff until newline + while(tokenizer->get_token()!=GDTokenizer::TK_NEWLINE && tokenizer->get_token()!=GDTokenizer::TK_EOF) { + tokenizer->advance(); + } + completion_found=false; + error_set=false; + return true; +} + void GDParser::_parse_block(BlockNode *p_block,bool p_static) { int indent_level = tab_level.back()->get(); @@ -1511,8 +1527,14 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { Node *subexpr=NULL; subexpr = _parse_and_reduce_expression(p_block,p_static); - if (!subexpr) + if (!subexpr) { + if (_recover_from_completion()) { + break; + } return; + } + + lv->assign=subexpr; assigned=subexpr; @@ -1543,8 +1565,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { tokenizer->advance(); Node *condition = _parse_and_reduce_expression(p_block,p_static); - if (!condition) + if (!condition) { + if (_recover_from_completion()) { + break; + } return; + } ControlFlowNode *cf_if = alloc_node(); @@ -1598,8 +1624,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { //condition Node *condition = _parse_and_reduce_expression(p_block,p_static); - if (!condition) + if (!condition) { + if (_recover_from_completion()) { + break; + } return; + } cf_else->arguments.push_back(condition); cf_else->cf_type=ControlFlowNode::CF_IF; @@ -1660,8 +1690,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { tokenizer->advance(); Node *condition = _parse_and_reduce_expression(p_block,p_static); - if (!condition) + if (!condition) { + if (_recover_from_completion()) { + break; + } return; + } ControlFlowNode *cf_while = alloc_node(); @@ -1706,8 +1740,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { tokenizer->advance(); Node *container = _parse_and_reduce_expression(p_block,p_static); - if (!container) + if (!container) { + if (_recover_from_completion()) { + break; + } return; + } ControlFlowNode *cf_for = alloc_node(); @@ -1771,8 +1809,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { } else { //expect expression Node *retexpr = _parse_and_reduce_expression(p_block,p_static); - if (!retexpr) + if (!retexpr) { + if (_recover_from_completion()) { + break; + } return; + } cf_return->arguments.push_back(retexpr); p_block->statements.push_back(cf_return); if (!_end_statement()) { @@ -1787,8 +1829,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { tokenizer->advance(); Node *condition = _parse_and_reduce_expression(p_block,p_static); - if (!condition) + if (!condition) { + if (_recover_from_completion()) { + break; + } return; + } AssertNode *an = alloc_node(); an->condition=condition; p_block->statements.push_back(an); @@ -1801,8 +1847,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) { default: { Node *expression = _parse_and_reduce_expression(p_block,p_static,false,true); - if (!expression) + if (!expression) { + if (_recover_from_completion()) { + break; + } return; + } p_block->statements.push_back(expression); if (!_end_statement()) { _set_error("Expected end of statement after expression."); @@ -2626,8 +2676,12 @@ void GDParser::_parse_class(ClassNode *p_class) { Node *subexpr=NULL; subexpr = _parse_and_reduce_expression(p_class,false,autoexport); - if (!subexpr) + if (!subexpr) { + if (_recover_from_completion()) { + break; + } return; + } member.expression=subexpr; @@ -2756,8 +2810,12 @@ void GDParser::_parse_class(ClassNode *p_class) { Node *subexpr=NULL; subexpr = _parse_and_reduce_expression(p_class,true,true); - if (!subexpr) + if (!subexpr) { + if (_recover_from_completion()) { + break; + } return; + } if (subexpr->type!=Node::TYPE_CONSTANT) { _set_error("Expected constant expression"); @@ -2852,6 +2910,7 @@ Error GDParser::parse_bytecode(const Vector &p_bytecode,const String& p completion_class=NULL; completion_function=NULL; completion_block=NULL; + completion_found=false; current_block=NULL; current_class=NULL; current_function=NULL; @@ -2874,6 +2933,7 @@ Error GDParser::parse(const String& p_code, const String& p_base_path, bool p_ju completion_class=NULL; completion_function=NULL; completion_block=NULL; + completion_found=false; current_block=NULL; current_class=NULL; @@ -2917,6 +2977,8 @@ void GDParser::clear() { current_block=NULL; current_class=NULL; + completion_found=false; + current_function=NULL; validating=false; -- cgit v1.2.3 From f34c3e249ba7b28aec451d62d5b44f31349eaa29 Mon Sep 17 00:00:00 2001 From: crr0004 Date: Wed, 2 Sep 2015 13:56:51 +1000 Subject: Fixes editor freeze --- modules/gdscript/gd_parser.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 571d340957..9c39051b7f 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -1422,11 +1422,15 @@ bool GDParser::_recover_from_completion() { return false; //can't recover if no completion } //skip stuff until newline - while(tokenizer->get_token()!=GDTokenizer::TK_NEWLINE && tokenizer->get_token()!=GDTokenizer::TK_EOF) { + while(tokenizer->get_token()!=GDTokenizer::TK_NEWLINE && tokenizer->get_token()!=GDTokenizer::TK_EOF && tokenizer->get_token()!=GDTokenizer::TK_ERROR) { tokenizer->advance(); } completion_found=false; error_set=false; + if(tokenizer->get_token() == GDTokenizer::TK_ERROR){ + error_set = true; + } + return true; } -- cgit v1.2.3 From e18c1ba05b5a92c15b987d604a84749b26929ded Mon Sep 17 00:00:00 2001 From: eska Date: Fri, 16 Oct 2015 16:18:46 +0200 Subject: Revert "add flag and multiline hits in GDScript" This reverts commit 7843ec6633625455e689e711aa62e9d8337689fa. --- modules/gdscript/gd_parser.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 9c39051b7f..32c24909a8 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2607,23 +2607,16 @@ void GDParser::_parse_class(ClassNode *p_class) { } else if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER) { String identifier = tokenizer->get_token_identifier(); - if (identifier == "flag") { - current_export.type=Variant::INT; - current_export.hint=PROPERTY_HINT_ALL_FLAGS; - }else if (identifier == "multiline"){ - current_export.type=Variant::STRING; - current_export.hint=PROPERTY_HINT_MULTILINE_TEXT; - } else { - if (!ObjectTypeDB::is_type(identifier,"Resource")) { - - current_export=PropertyInfo(); - _set_error("Export hint not a type or resource."); - } - - current_export.type=Variant::OBJECT; - current_export.hint=PROPERTY_HINT_RESOURCE_TYPE; - current_export.hint_string=identifier; + if (!ObjectTypeDB::is_type(identifier,"Resource")) { + + current_export=PropertyInfo(); + _set_error("Export hint not a type or resource."); } + + current_export.type=Variant::OBJECT; + current_export.hint=PROPERTY_HINT_RESOURCE_TYPE; + current_export.hint_string=identifier; + tokenizer->advance(); } -- cgit v1.2.3 From 57b2c4b0c6334b37d150a1945dfef45fb0783e94 Mon Sep 17 00:00:00 2001 From: eska Date: Fri, 16 Oct 2015 16:39:59 +0200 Subject: Add multiline string GDScript export hint `export(String, MULTILINE)` --- modules/gdscript/gd_parser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 32c24909a8..47f39e9e81 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2571,6 +2571,17 @@ void GDParser::_parse_class(ClassNode *p_class) { } break; } + + if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="MULTILINE") { + + current_export.hint=PROPERTY_HINT_MULTILINE_TEXT; + tokenizer->advance(); + if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) { + _set_error("Expected ')' in hint."); + return; + } + break; + } } break; case Variant::COLOR: { -- cgit v1.2.3 From eb9621624fbb508635d192f29089b043e8bee5d0 Mon Sep 17 00:00:00 2001 From: eska Date: Fri, 16 Oct 2015 20:37:13 +0200 Subject: Add GDScript export hint for real numbers with easing `export(float, EASE)` --- modules/gdscript/gd_parser.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'modules/gdscript/gd_parser.cpp') diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 47f39e9e81..313fb57d0e 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2421,6 +2421,16 @@ void GDParser::_parse_class(ClassNode *p_class) { }; //fallthrough to use the same case Variant::REAL: { + if (tokenizer->get_token()==GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier()=="EASE") { + current_export.hint=PROPERTY_HINT_EXP_EASING; + tokenizer->advance(); + if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) { + _set_error("Expected ')' in hint."); + return; + } + break; + } + float sign=1.0; if (tokenizer->get_token()==GDTokenizer::TK_OP_SUB) { -- cgit v1.2.3