-
Notifications
You must be signed in to change notification settings - Fork 17
Add symbols imported in packages to workspace #872
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
Open
lionel-
wants to merge
6
commits into
feature/static-imports
Choose a base branch
from
feature/static-imports-package
base: feature/static-imports
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+328
−71
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6c6f328
Add symbols imported in packages to workspace
lionel- d5afdcc
Add top-level variables to diagnostics context
lionel- 49ff949
Fix race conditions between indexer and diagnostics
lionel- 1180194
Import testthat in test files
lionel- 3971ebf
Improve batching of indexer tasks
lionel- 3949507
Refresh all diagnostics when a single file is updated
lionel- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,12 @@ pub struct Package { | |
} | ||
|
||
impl Package { | ||
/// Attempts to load a package from the given path and name. | ||
pub fn load(lib_path: &std::path::Path, name: &str) -> anyhow::Result<Option<Self>> { | ||
let package_path = lib_path.join(name); | ||
|
||
/// Load a package from a given path. | ||
pub fn load(package_path: &std::path::Path) -> anyhow::Result<Option<Self>> { | ||
let description_path = package_path.join("DESCRIPTION"); | ||
let namespace_path = package_path.join("NAMESPACE"); | ||
|
||
// Only consider libraries that have a folder named after the | ||
// requested package and that contains a description file | ||
// Only consider directories that contain a description file | ||
if !description_path.is_file() { | ||
return Ok(None); | ||
} | ||
|
@@ -41,12 +38,6 @@ impl Package { | |
let description_contents = fs::read_to_string(&description_path)?; | ||
let description = Description::parse(&description_contents)?; | ||
|
||
if description.name != name { | ||
return Err(anyhow::anyhow!( | ||
"`Package` field in `DESCRIPTION` doesn't match folder name '{name}'" | ||
)); | ||
} | ||
Comment on lines
-44
to
-48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What violates this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see you moved this. Why would non-library-path packages be any different? |
||
|
||
let namespace_contents = fs::read_to_string(&namespace_path)?; | ||
let namespace = Namespace::parse(&namespace_contents)?; | ||
|
||
|
@@ -56,4 +47,25 @@ impl Package { | |
namespace, | ||
})) | ||
} | ||
|
||
/// Load a package from the given library path and name. | ||
pub fn load_from_library( | ||
lib_path: &std::path::Path, | ||
name: &str, | ||
) -> anyhow::Result<Option<Self>> { | ||
let package_path = lib_path.join(name); | ||
|
||
// For library packages, ensure the invariant that the package name | ||
// matches the folder name | ||
if let Some(pkg) = Self::load(&package_path)? { | ||
if pkg.description.name != name { | ||
return Err(anyhow::anyhow!( | ||
"`Package` field in `DESCRIPTION` doesn't match folder name '{name}'" | ||
)); | ||
} | ||
Ok(Some(pkg)) | ||
} else { | ||
Ok(None) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
For a second I thought there was a single file that
package_path
points to, but it looks like it is intended to point to a folder. So this plus a name of justpath: &Path
seems good imo