Autocompletion: enable string literal completion in subscripts

This commit is contained in:
HolonProduction 2024-08-27 13:02:09 +02:00
parent db76de5de8
commit c824403853
19 changed files with 181 additions and 0 deletions

View File

@ -3122,6 +3122,12 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_subscript(ExpressionNode *
subscript->base = p_previous_operand;
subscript->index = parse_expression(false);
#ifdef TOOLS_ENABLED
if (subscript->index != nullptr && subscript->index->type == Node::LITERAL) {
override_completion_context(subscript->index, COMPLETION_SUBSCRIPT, subscript);
}
#endif
if (subscript->index == nullptr) {
push_error(R"(Expected expression after "[".)");
}

View File

@ -0,0 +1,9 @@
[output]
include=[
{"display": "outer"},
{"display": "inner"},
]
exclude=[
{"display": "append"},
{"display": "\"append\""},
]

View File

@ -0,0 +1,10 @@
extends Node
var outer
func _ready() -> void:
var inner
var array: Array
array[i]

View File

@ -0,0 +1,9 @@
[output]
include=[
{"display": "outer"},
{"display": "inner"},
]
exclude=[
{"display": "append"},
{"display": "\"append\""},
]

View File

@ -0,0 +1,10 @@
extends Node
var outer
func _ready() -> void:
var inner
var array = []
array[i]

View File

@ -0,0 +1,11 @@
[output]
include=[
{"display": "\"key1\""},
{"display": "\"key2\""},
]
exclude=[
{"display": "keys"},
{"display": "\"keys\""},
{"display": "key1"},
{"display": "key2"},
]

View File

@ -0,0 +1,13 @@
extends Node
var outer
const dict = {
"key1": "value",
"key2": null,
}
func _ready() -> void:
var inner
dict[""]

View File

@ -0,0 +1,9 @@
[output]
include=[
{"display": "outer"},
{"display": "inner"},
]
exclude=[
{"display": "keys"},
{"display": "\"keys\""},
]

View File

@ -0,0 +1,10 @@
extends Node
var outer
func _ready() -> void:
var inner
var dict: Dictionary
dict[i]

View File

@ -0,0 +1,9 @@
[output]
include=[
{"display": "outer"},
{"display": "inner"},
]
exclude=[
{"display": "keys"},
{"display": "\"keys\""},
]

View File

@ -0,0 +1,10 @@
extends Node
var outer
func _ready() -> void:
var inner
var dict = {}
dict[i]

View File

@ -0,0 +1,11 @@
[output]
include=[
{"display": "\"key1\""},
{"display": "\"key2\""},
]
exclude=[
{"display": "keys"},
{"display": "\"keys\""},
{"display": "key1"},
{"display": "key2"},
]

View File

@ -0,0 +1,13 @@
extends Node
var outer
func _ready() -> void:
var inner
var dict: Dictionary = {
"key1": "value",
"key2": null,
}
dict[""]

View File

@ -0,0 +1,9 @@
[output]
exclude=[
{"display": "keys"},
{"display": "\"keys\""},
{"display": "key1"},
{"display": "key2"},
{"display": "\"key1\""},
{"display": "\"key2\""},
]

View File

@ -0,0 +1,13 @@
extends Node
var outer
var dict = {
"key1": "value",
"key2": null,
}
func _ready() -> void:
var inner
dict[""]

View File

@ -0,0 +1,5 @@
[output]
include=[
{"display": "outer"},
{"display": "inner"},
]

View File

@ -0,0 +1,10 @@
extends Node
var outer
func _ready() -> void:
var inner
var array
array[i]

View File

@ -0,0 +1,5 @@
[output]
include=[
{"display": "outer"},
{"display": "inner"},
]

View File

@ -0,0 +1,9 @@
extends Node
var outer
var array
func _ready() -> void:
var inner
array[i]