Skip to content

Commit

Permalink
chore: Future framework for include completions
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake committed Jan 15, 2024
1 parent ccec22d commit 8a6cdca
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions compiler/src/language_server/completion.re
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ let send_completion =
};

type completionState =
| ComletableCode(string)
| CompletableCode(string)
| CompletableExpr(string)
| CompletableType(string);
| CompletableType(string)
| CompletableInclude(string);

let convert_position_to_offset = (source, position: Protocol.position) => {
let lines = String.split_on_char('\n', source);
Expand Down Expand Up @@ -172,9 +173,15 @@ let find_completable_state = (documents, uri, position: Protocol.position) => {
} else {
None;
}
| ['e', 'd', 'u', 'l', 'c', 'n', 'i', ...rest] when last_char_whitespace =>
Some(
CompletableInclude(
String_utils.slice(~first=slice_offset, ~last=offset, source),
),
)
| ['\n', ...rest] when !has_hit_info =>
Some(
ComletableCode(
CompletableCode(
String_utils.slice(~first=slice_offset, ~last=offset, source),
),
)
Expand Down Expand Up @@ -499,7 +506,7 @@ let process =
| None => []
| Some(completableState) =>
switch (completableState) {
| ComletableCode(str) =>
| CompletableCode(str) =>
let str = String.trim(str);
let completionPath = String.split_on_char('.', str);
get_top_level_completions(
Expand Down Expand Up @@ -532,6 +539,7 @@ let process =
compiled_code,
completionPath,
);
| CompletableInclude(str) => []
}
};
send_completion(~id, completions);
Expand Down

0 comments on commit 8a6cdca

Please sign in to comment.