Skip to content

Commit

Permalink
Place 'built-in' Slice files at the front of the 'references' list. (#55
Browse files Browse the repository at this point in the history
)
  • Loading branch information
InsertCreativityHere authored Jul 22, 2024
1 parent 7a2b306 commit 7c1fecd
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions server/src/slice_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,28 @@ pub fn compute_slice_options(server_config: &ServerConfig, set_config: &SliceCon
let mut slice_options = SliceOptions::default();
let references = &mut slice_options.references;

// Add any user specified search paths at the front of the list.
for path in &set_config.slice_search_paths {
// If the path is absolute, add it as-is. Otherwise, preface it with the workspace root.
let absolute_path = match path.is_absolute() {
true => path.to_owned(),
false => root_path.join(path),
};
references.push(absolute_path.display().to_string());
// Add the built-in Slice files (WellKnownTypes, etc.) at the start of the list, if they should be included.
// Putting them first ensures that any redefinition conflicts will appear in the user's files, and not these.
// (Since `slicec` parses files in the order that they are provided).
if set_config.include_built_in_slice_files {
references.push(server_config.built_in_slice_path.clone());
}

// If the user didn't specify any paths, default to using the workspace root.
if references.is_empty() {
references.push(root_path.display().to_string());
}
match set_config.slice_search_paths.as_slice() {
// If the user didn't specify any paths, default to using the workspace root.
[] => references.push(root_path.display().to_string()),

// Add the built-in Slice files (WellKnownTypes, etc.) to the end of the list, if they should be included.
if set_config.include_built_in_slice_files {
references.push(server_config.built_in_slice_path.clone());
// Otherwise, add in the user-specified search paths.
user_paths => {
for path in user_paths {
// If the path is absolute, add it as-is. Otherwise, preface it with the workspace root.
let absolute_path = match path.is_absolute() {
true => path.to_owned(),
false => root_path.join(path),
};
references.push(absolute_path.display().to_string());
}
}
}

slice_options
Expand Down

0 comments on commit 7c1fecd

Please sign in to comment.