Skip to content

Commit c552bae

Browse files
kassensfacebook-github-bot
authored andcommitted
remove unused fn watch_with_callback
Summary: This was added at some point while iterating on the LSP implementation, but is no longer used. Reviewed By: tyao1 Differential Revision: D22824249 fbshipit-source-id: 4863979a563e0c0e4b945b970ab478dc35d5f157
1 parent 8b957ae commit c552bae

File tree

1 file changed

+1
-104
lines changed

1 file changed

+1
-104
lines changed

compiler/crates/relay-compiler/src/compiler.rs

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
use crate::build_project::{build_project, build_schema, check_project, commit_project};
8+
use crate::build_project::{build_project, build_schema, commit_project};
99
use crate::compiler_state::{ArtifactMapKind, CompilerState, ProjectName};
1010
use crate::config::Config;
1111
use crate::errors::{BuildProjectError, Error, Result};
@@ -67,63 +67,6 @@ impl<TPerfLogger: PerfLogger> Compiler<TPerfLogger> {
6767
schemas
6868
}
6969

70-
pub async fn watch_with_callback<F>(&self, mut callback: F) -> Result<()>
71-
where
72-
F: FnMut(Result<()>),
73-
{
74-
let setup_event = self.perf_logger.create_event("compiler_setup");
75-
76-
let file_source = FileSource::connect(&self.config, &setup_event).await?;
77-
let (mut compiler_state, mut subscription) = file_source
78-
.subscribe(&setup_event, self.perf_logger.as_ref())
79-
.await?;
80-
let schemas = self.build_schemas(&compiler_state, &setup_event);
81-
callback(
82-
self.check_projects(&mut compiler_state, &schemas, &setup_event)
83-
.await,
84-
);
85-
86-
self.perf_logger.complete_event(setup_event);
87-
88-
loop {
89-
if let Some(file_source_changes) = subscription.next_change().await? {
90-
let incremental_check_event =
91-
self.perf_logger.create_event("incremental_check_event");
92-
let incremental_check_time =
93-
incremental_check_event.start("incremental_check_time");
94-
95-
// TODO Single change to file in VSCode sometimes produces
96-
// 2 watchman change events for the same file
97-
let had_new_changes = compiler_state.merge_file_source_changes(
98-
&self.config,
99-
&file_source_changes,
100-
&incremental_check_event,
101-
self.perf_logger.as_ref(),
102-
)?;
103-
if had_new_changes {
104-
// Clear out existing errors
105-
callback(Ok(()));
106-
// Report any new errors
107-
callback(
108-
self.check_projects(
109-
&mut compiler_state,
110-
&schemas,
111-
&incremental_check_event,
112-
)
113-
.await,
114-
);
115-
} else {
116-
info!("[watch-mode] No re-compilation required");
117-
}
118-
incremental_check_event.stop(incremental_check_time);
119-
self.perf_logger.complete_event(incremental_check_event);
120-
// We probably don't want the messages queue to grow indefinitely
121-
// and we need to flush then, as the check/build is completed
122-
self.perf_logger.flush();
123-
}
124-
}
125-
}
126-
12770
pub async fn watch(&self) -> Result<()> {
12871
let setup_event = self.perf_logger.create_event("compiler_setup");
12972

@@ -183,52 +126,6 @@ impl<TPerfLogger: PerfLogger> Compiler<TPerfLogger> {
183126
}
184127
}
185128

186-
async fn check_projects(
187-
&self,
188-
compiler_state: &mut CompilerState,
189-
schemas: &HashMap<ProjectName, Arc<Schema>>,
190-
setup_event: &impl PerfLogEvent,
191-
) -> Result<()> {
192-
let graphql_asts = setup_event.time("parse_sources_time", || {
193-
compiler_state
194-
.graphql_sources
195-
.iter()
196-
.map(|(&source_set_name, sources)| {
197-
let asts = GraphQLAsts::from_graphql_sources(sources)?;
198-
Ok((source_set_name, asts))
199-
})
200-
.collect::<Result<_>>()
201-
})?;
202-
203-
let mut build_project_errors = vec![];
204-
205-
for project_config in self.config.enabled_projects() {
206-
if compiler_state.project_has_pending_changes(project_config.name) {
207-
let schema = Arc::clone(schemas.get(&project_config.name).unwrap());
208-
// TODO: consider running all projects in parallel
209-
check_project(
210-
project_config,
211-
compiler_state,
212-
&graphql_asts,
213-
schema,
214-
Arc::clone(&self.perf_logger),
215-
)
216-
.map_err(|err| {
217-
build_project_errors.push(err);
218-
})
219-
.ok();
220-
}
221-
}
222-
223-
if build_project_errors.is_empty() {
224-
Ok(())
225-
} else {
226-
Err(Error::BuildProjectsErrors {
227-
errors: build_project_errors,
228-
})
229-
}
230-
}
231-
232129
async fn build_projects(
233130
&self,
234131
compiler_state: &mut CompilerState,

0 commit comments

Comments
 (0)