Skip to content

Commit 1353422

Browse files
committed
add IF/FOR as keywords to completion
1 parent d84185d commit 1353422

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

robotcode/language_server/robotframework/diagnostics/library_doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
RUN_KEYWORDS = [*RUN_KEYWORD_NAMES, *RUN_KEYWORD_WITH_CONDITION_NAMES, RUN_KEYWORDS_NAME, RUN_KEYWORD_IF_NAME]
7070

7171
BUILTIN_LIBRARY_NAME = "BuiltIn"
72-
73-
DEFAULT_LIBRARIES = (BUILTIN_LIBRARY_NAME, "Reserved", "Easter")
72+
RESERVED_LIBRARY_NAME = "Reserved"
73+
DEFAULT_LIBRARIES = (BUILTIN_LIBRARY_NAME, RESERVED_LIBRARY_NAME, "Easter")
7474
ROBOT_LIBRARY_PACKAGE = "robot.libraries"
7575

7676
ALLOWED_LIBRARY_FILE_EXTENSIONS = [".py"]

robotcode/language_server/robotframework/parts/completion.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,19 @@ async def resolve(self, sender: Any, completion_item: CompletionItem) -> Complet
119119
"IF": [r"IF \${${1}}", "$0", "END", ""],
120120
}
121121

122+
RESERVERD_KEYWORDS = [
123+
"FOR",
124+
# "WHILE",
125+
# "BREAK",
126+
# "CONTINUE",
127+
"END",
128+
"IF",
129+
"ELSE",
130+
"ELIF",
131+
"ELSE IF",
132+
# "RETURN",
133+
]
134+
122135

123136
class CompletionCollector(ModelHelperMixin):
124137
_logger = LoggingDescriptor()
@@ -532,6 +545,16 @@ def enumerate_indexes(s: str, c: str) -> Iterator[int]:
532545
)
533546
result.append(c)
534547

548+
for k in RESERVERD_KEYWORDS:
549+
c = CompletionItem(
550+
label=k,
551+
kind=CompletionItemKind.KEYWORD,
552+
sort_text=f"040_{k}",
553+
insert_text_format=InsertTextFormat.PLAINTEXT,
554+
text_edit=TextEdit(range=r, new_text=k) if r is not None else None,
555+
)
556+
result.append(c)
557+
535558
return result
536559

537560
async def complete_default(

0 commit comments

Comments
 (0)