Skip to content

Commit 7a74bec

Browse files
committed
Fix function refactor
1 parent 3f33c50 commit 7a74bec

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

modules/gdscript/gdscript_parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,6 @@ GDScriptParser::FunctionNode *GDScriptParser::parse_function(bool p_is_static) {
18021802
function->is_static = p_is_static;
18031803

18041804
make_completion_context(COMPLETION_OVERRIDE_METHOD, function);
1805-
refactor_rename_register(REFACTOR_RENAME_TYPE_METHOD, function);
18061805

18071806
#ifdef TOOLS_ENABLED
18081807
// The signature is something like `(a: int, b: int = 0) -> void`.
@@ -1819,6 +1818,7 @@ GDScriptParser::FunctionNode *GDScriptParser::parse_function(bool p_is_static) {
18191818
current_function = function;
18201819

18211820
function->identifier = parse_identifier();
1821+
refactor_rename_register(REFACTOR_RENAME_TYPE_IDENTIFIER, function->identifier);
18221822

18231823
SuiteNode *body = alloc_node<SuiteNode>();
18241824

@@ -1852,6 +1852,9 @@ GDScriptParser::FunctionNode *GDScriptParser::parse_function(bool p_is_static) {
18521852

18531853
current_function = previous_function;
18541854
complete_extents(function);
1855+
1856+
refactor_rename_register(REFACTOR_RENAME_TYPE_DECLARATION, function);
1857+
18551858
return function;
18561859
}
18571860

modules/gdscript/gdscript_tokenizer.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,34 @@ class GDScriptTokenizer {
488488

489489
CodeArea get_code_area() const { return CodeArea(start_line, start_column, end_line, end_column); }
490490

491+
constexpr bool operator==(const Token &p_right) {
492+
if (type != p_right.type) {
493+
return false;
494+
}
495+
if (literal != p_right.literal) {
496+
return false;
497+
}
498+
if (start_line != p_right.start_line || start_column != p_right.start_column) {
499+
return false;
500+
}
501+
if (end_line != p_right.end_line || end_column != p_right.end_column) {
502+
return false;
503+
}
504+
if (cursor_position != p_right.cursor_position) {
505+
return false;
506+
}
507+
if (cursor_place != p_right.cursor_place) {
508+
return false;
509+
}
510+
if (source != p_right.source) {
511+
return false;
512+
}
513+
return true;
514+
}
515+
constexpr bool operator!=(const Token &p_right) {
516+
return !operator==(p_right);
517+
}
518+
491519
Token(Type p_type) {
492520
type = p_type;
493521
}

modules/gdscript/tests/scripts/refactor/rename/tests/keyword/rename_func.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[input]
33
refactor={
44
"file": "res://scripts/class_a.gd",
5-
"line": 33,
5+
"line": 35,
66
"column": 1,
77
"symbol": "func",
88
}

0 commit comments

Comments
 (0)