Skip to content

Commit

Permalink
chore(turbopack): Delete dead code in next_core::{app,pages}_structure
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Aug 27, 2024
1 parent 46c6776 commit 5c1417e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 91 deletions.
41 changes: 2 additions & 39 deletions crates/next-core/src/app_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use tracing::Instrument;
use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, Completion, Completions, RcStr, TaskInput,
TryJoinIterExt, ValueToString, Vc,
debug::ValueDebugFormat, trace::TraceRawVcs, RcStr, TaskInput, TryJoinIterExt, ValueToString,
Vc,
};
use turbo_tasks_fs::{DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath};
use turbopack_core::issue::{
Expand All @@ -26,7 +26,6 @@ use crate::{
},
AppPage, AppPath, PageSegment, PageType,
},
next_config::NextConfig,
next_import_map::get_next_package,
};

Expand Down Expand Up @@ -218,18 +217,6 @@ struct PlainDirectoryTree {

#[turbo_tasks::value_impl]
impl DirectoryTree {
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(&self) -> Result<Vc<Completion>> {
let mut children = Vec::new();
children.push(Completion::new());
for child in self.subdirectories.values() {
children.push(child.routes_changed());
}
Ok(Vc::<Completions>::cell(children).completed())
}

#[turbo_tasks::function]
pub async fn into_plain(&self) -> Result<Vc<PlainDirectoryTree>> {
let mut subdirectories = BTreeMap::new();
Expand All @@ -249,23 +236,6 @@ impl DirectoryTree {
#[turbo_tasks::value(transparent)]
pub struct OptionAppDir(Option<Vc<FileSystemPath>>);

#[turbo_tasks::value_impl]
impl OptionAppDir {
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(
self: Vc<Self>,
next_config: Vc<NextConfig>,
) -> Result<Vc<Completion>> {
if let Some(app_dir) = *self.await? {
let directory_tree = get_directory_tree(app_dir, next_config.page_extensions());
directory_tree.routes_changed().await?;
}
Ok(Completion::new())
}
}

/// Finds and returns the [DirectoryTree] of the app directory if existing.
#[turbo_tasks::function]
pub async fn find_app_dir(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionAppDir>> {
Expand All @@ -284,13 +254,6 @@ pub async fn find_app_dir(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionA
Ok(Vc::cell(Some(app_dir)))
}

/// Finds and returns the [DirectoryTree] of the app directory if enabled and
/// existing.
#[turbo_tasks::function]
pub async fn find_app_dir_if_enabled(project_path: Vc<FileSystemPath>) -> Result<Vc<OptionAppDir>> {
Ok(find_app_dir(project_path))
}

#[turbo_tasks::function]
async fn get_directory_tree(
dir: Vc<FileSystemPath>,
Expand Down
53 changes: 1 addition & 52 deletions crates/next-core/src/pages_structure.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use tracing::Instrument;
use turbo_tasks::{Completion, RcStr, ValueToString, Vc};
use turbo_tasks::{RcStr, ValueToString, Vc};
use turbo_tasks_fs::{
DirectoryContent, DirectoryEntry, FileSystemEntryType, FileSystemPath, FileSystemPathOption,
};
Expand Down Expand Up @@ -58,15 +58,6 @@ impl PagesStructureItem {
Ok(self.base_path)
}
}

/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
let this = self.await?;
this.next_router_path.await?;
Ok(Completion::new())
}
}

/// A (sub)directory in the pages directory with all analyzed routes and
Expand All @@ -82,29 +73,6 @@ pub struct PagesStructure {

#[turbo_tasks::value_impl]
impl PagesStructure {
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
let PagesStructure {
ref app,
ref document,
ref error,
ref api,
ref pages,
} = &*self.await?;
app.routes_changed().await?;
document.routes_changed().await?;
error.routes_changed().await?;
if let Some(api) = api {
api.routes_changed().await?;
}
if let Some(pages) = pages {
pages.routes_changed().await?;
}
Ok(Completion::new())
}

#[turbo_tasks::function]
pub fn app(&self) -> Vc<PagesStructureItem> {
self.app
Expand All @@ -131,31 +99,12 @@ pub struct PagesDirectoryStructure {

#[turbo_tasks::value_impl]
impl PagesDirectoryStructure {
/// Returns the router path of this directory.
#[turbo_tasks::function]
pub async fn next_router_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
Ok(self.await?.next_router_path)
}

/// Returns the path to the directory of this structure in the project file
/// system.
#[turbo_tasks::function]
pub async fn project_path(self: Vc<Self>) -> Result<Vc<FileSystemPath>> {
Ok(self.await?.project_path)
}

/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks::function]
pub async fn routes_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
for item in self.await?.items.iter() {
item.routes_changed().await?;
}
for child in self.await?.children.iter() {
child.routes_changed().await?;
}
Ok(Completion::new())
}
}

/// Finds and returns the [PagesStructure] of the pages directory if existing.
Expand Down

0 comments on commit 5c1417e

Please sign in to comment.