Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place 'built-in' Slice files at the front of the 'references' list. #55

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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