-
Notifications
You must be signed in to change notification settings - Fork 256
Conversation
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.
Thanks for this PR! I think the idea of factoring out stuff from build
in actions.rs is a good one, however, I think there a few places where we can improve on the design in this PR. I left a few comments inline as a first pass, but this is kind of a hard PR to review because of the diff, so we might have to iterate on it a bit...
src/actions/build/mod.rs
Outdated
|
||
fn lock_previous_results(&self) -> MutexGuard<Results> { | ||
self.previous_results.lock().expect("previous results lock failed") |
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.
I would inline this function - I think repeating the message string is OK and makes it a bit clearer what is going on
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.
I am not quite sure whether you are agree with this change or not)
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.
I agree with changing unwrap to expect, but not with factoring out a function.
src/actions/build/mod.rs
Outdated
@@ -76,11 +71,10 @@ impl Build { | |||
} | |||
} | |||
|
|||
fn convert_build_results_to_notifications(build_results: &Results, | |||
project_path: &Path) | |||
fn convert_results_to_notifications(results: &Results, project_path: &Path) |
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.
It's not really your fault, more a weakness in Git, but this diff is really hard to review. When you're doing refactoring, could you make your commits as small as possible please? E.g., here, I think factoring out process_build_result
should be its own commit, deleting the structs one commit, and the other renaming another commit.
@@ -0,0 +1,96 @@ | |||
use std::path::PathBuf; |
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.
Again, not your fault, but for easier review, could you separate the moving of code to another file into a separate commit from any changes?
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.
These new files should have the copyright boilerplate
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.
I'm a bit confused about the module structure here - we have build.rs at the root, plus a complex build submodule of actions. That seems confusing. I assume that actions/build is just the stuff from the build action. I think it would be better just to have this module inside actions, and not have a build
submodule of actions.
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.
@nrc,
I moved it in another file because I like small files)
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.
You can keep it another file, just not in a new module/directory, i.e., add actions/compiler_message_parser.rs
src/actions/build/mod.rs
Outdated
|
||
type Results = HashMap<PathBuf, Vec<Diagnostic>>; | ||
|
||
pub struct Build { |
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.
I'm not sure if this is just a naming thing or whether this abstraction could be improved, but it seems kind of wrong at the moment. A Build
is not a single build, it seems to be more like a BuildManager
or BuildHandler
, but that has some overlap with the BuildQueue
. I think I'm not convinced that there is something worth abstracting out of ActionHandler
here.
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.
To be clear, I think you are correct about pulling out some of the build-related functions from inside build
, but I don't think pulling out the data into a Build
struct is the right approach to doing this.
src/actions/build/mod.rs
Outdated
results.clear(); | ||
} | ||
|
||
pub fn execute(&self, project_path: &Path, priority: BuildPriority, out: &Output) { |
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.
Similar to the last comment, this is method is just handling the build request and so I think it should be in the action handler. It is not executing the build, it is enqueing it, and then handling the result.
} | ||
} | ||
|
||
pub struct CompilerMessageParser {} |
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.
If there is no data, this struct should not exist.
pub struct CompilerMessageParser {} | ||
|
||
impl CompilerMessageParser { | ||
pub fn parse(message: &str) -> Result<FileDiagnostic, ParseError> { |
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.
This could be a module-level function
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.
@nrc,
Yes it could.
I unlearned to use functions.
@nrc, |
force push would be good, thanks |
@nrc, |
@nrc, |
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.
Looks good, just needs the copyright notice on the new file.
@@ -0,0 +1,92 @@ | |||
use std::path::PathBuf; |
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.
Needs copyright notice
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.
Okay.
Thank you! |
Hi everybody.
I made small refactoring.
Moved actions.rs to actions/mod.rs.
Extracted parsing compiler messages into actions/compiler_message_parsing.rs