Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 8cf62fa

Browse files
author
Hendrik van Antwerpen
committed
Move language configuration to top, now that it is used by all loaders
1 parent 67c930a commit 8cf62fa

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

tree-sitter-stack-graphs/src/loader.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ lazy_static! {
3434
vec![LoadPath::Grammar("queries/builtins".into())];
3535
}
3636

37+
/// Data type that holds all information to recognize and analyze files for a language
38+
pub struct LanguageConfiguration {
39+
pub language: Language,
40+
pub scope: Option<String>,
41+
pub content_regex: Option<Regex>,
42+
pub file_types: Vec<String>,
43+
pub sgl: StackGraphLanguage,
44+
pub builtins: StackGraph,
45+
}
46+
47+
impl LanguageConfiguration {
48+
pub fn matches_file(&self, path: &Path, content: Option<&str>) -> bool {
49+
matches_file(&self.file_types, &self.content_regex, path, content).is_some()
50+
}
51+
}
52+
3753
/// A load path specifies a file to load from, either as a regular path or relative to the grammar location.
3854
#[derive(Clone, Debug)]
3955
pub enum LoadPath {
@@ -238,21 +254,6 @@ impl From<crate::LoadError> for LoadError {
238254
// ------------------------------------------------------------------------------------------------
239255
// provided languages loader
240256

241-
pub struct LanguageConfiguration {
242-
pub language: Language,
243-
pub scope: Option<String>,
244-
pub content_regex: Option<Regex>,
245-
pub file_types: Vec<String>,
246-
pub sgl: StackGraphLanguage,
247-
pub builtins: StackGraph,
248-
}
249-
250-
impl LanguageConfiguration {
251-
pub fn matches_file(&self, path: &Path, content: Option<&str>) -> bool {
252-
matches_file(&self.file_types, &self.content_regex, path, content).is_some()
253-
}
254-
}
255-
256257
struct LanguageConfigurationsLoader {
257258
configurations: Vec<LanguageConfiguration>,
258259
}

0 commit comments

Comments
 (0)