Skip to content

Commit 07fe4f7

Browse files
robertoaloimeta-codesync[bot]
authored andcommitted
Define is_in_otp as a File method
Summary: Small follow-up from D44162698. Define the `is_in_otp` helper as part of `File`, to make it more discoverable. Reviewed By: jcpetruzza Differential Revision: D84890853 fbshipit-source-id: 7e57f58c75a6db506196318f9e93afdefc03fd1d
1 parent bca196c commit 07fe4f7

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

crates/hir/src/module_data.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ impl File {
9191
pub fn def_map(&self, db: &dyn DefDatabase) -> Arc<DefMap> {
9292
db.def_map(self.file_id)
9393
}
94+
95+
pub fn is_in_otp(&self, db: &dyn DefDatabase) -> bool {
96+
let file_id = self.file_id;
97+
// Context for T171541590
98+
let _ = stdx::panic_context::enter(format!("\nis_in_otp:2: {file_id:?}"));
99+
match db.file_app_data(file_id) {
100+
Some(app_data) => {
101+
let project_id = app_data.project_id;
102+
db.project_data(project_id).otp_project_id == Some(project_id)
103+
}
104+
None => false,
105+
}
106+
}
94107
}
95108

96109
/// Represents a module definition
@@ -111,7 +124,7 @@ impl Module {
111124
}
112125

113126
pub fn is_in_otp(&self, db: &dyn DefDatabase) -> bool {
114-
is_in_otp(self.file.file_id, db)
127+
self.file.is_in_otp(db)
115128
}
116129

117130
pub fn has_moduledoc(&self, db: &dyn DefDatabase) -> bool {
@@ -270,7 +283,7 @@ impl FunctionDef {
270283
}
271284

272285
pub fn is_in_otp(&self, db: &dyn DefDatabase) -> bool {
273-
is_in_otp(self.file.file_id, db)
286+
self.file.is_in_otp(db)
274287
}
275288

276289
pub fn edoc_comments(&self, db: &dyn DefDatabase) -> Option<EdocHeader> {
@@ -697,15 +710,3 @@ impl VarDef {
697710
db.lookup_var(self.hir_var).clone()
698711
}
699712
}
700-
701-
fn is_in_otp(file_id: FileId, db: &dyn DefDatabase) -> bool {
702-
// Context for T171541590
703-
let _ = stdx::panic_context::enter(format!("\nis_in_otp:2: {file_id:?}"));
704-
match db.file_app_data(file_id) {
705-
Some(app_data) => {
706-
let project_id = app_data.project_id;
707-
db.project_data(project_id).otp_project_id == Some(project_id)
708-
}
709-
None => false,
710-
}
711-
}

0 commit comments

Comments
 (0)