Skip to content

Commit ba225ee

Browse files
committed
chore: Future framework for include completions
1 parent c277f07 commit ba225ee

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

compiler/src/language_server/completion.re

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ let send_completion =
108108
};
109109

110110
type completionState =
111-
| ComletableCode(string)
111+
| CompletableCode(string)
112112
| CompletableExpr(string)
113-
| CompletableType(string);
113+
| CompletableType(string)
114+
| CompletableInclude(string);
114115

115116
let convert_position_to_offset = (source, position: Protocol.position) => {
116117
let lines = String.split_on_char('\n', source);
@@ -172,9 +173,15 @@ let find_completable_state = (documents, uri, position: Protocol.position) => {
172173
} else {
173174
None;
174175
}
176+
| ['e', 'd', 'u', 'l', 'c', 'n', 'i', ...rest] when last_char_whitespace =>
177+
Some(
178+
CompletableInclude(
179+
String_utils.slice(~first=slice_offset, ~last=offset, source),
180+
),
181+
)
175182
| ['\n', ...rest] when !has_hit_info =>
176183
Some(
177-
ComletableCode(
184+
CompletableCode(
178185
String_utils.slice(~first=slice_offset, ~last=offset, source),
179186
),
180187
)
@@ -499,7 +506,7 @@ let process =
499506
| None => []
500507
| Some(completableState) =>
501508
switch (completableState) {
502-
| ComletableCode(str) =>
509+
| CompletableCode(str) =>
503510
let str = String.trim(str);
504511
let completionPath = String.split_on_char('.', str);
505512
get_top_level_completions(
@@ -532,6 +539,7 @@ let process =
532539
compiled_code,
533540
completionPath,
534541
);
542+
| CompletableInclude(str) => []
535543
}
536544
};
537545
send_completion(~id, completions);

0 commit comments

Comments
 (0)