mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(span/source-type): make SourceType factories const (#5241)
I found myself wanting this while writing `no-unused-vars` and while using oxc in some downstream personal projects.
This commit is contained in:
parent
f5e05db302
commit
94f60e7748
1 changed files with 6 additions and 6 deletions
|
|
@ -69,7 +69,7 @@ impl SourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_script(mut self, yes: bool) -> Self {
|
pub const fn with_script(mut self, yes: bool) -> Self {
|
||||||
if yes {
|
if yes {
|
||||||
self.module_kind = ModuleKind::Script;
|
self.module_kind = ModuleKind::Script;
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ impl SourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_module(mut self, yes: bool) -> Self {
|
pub const fn with_module(mut self, yes: bool) -> Self {
|
||||||
if yes {
|
if yes {
|
||||||
self.module_kind = ModuleKind::Module;
|
self.module_kind = ModuleKind::Module;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -87,7 +87,7 @@ impl SourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_typescript(mut self, yes: bool) -> Self {
|
pub const fn with_typescript(mut self, yes: bool) -> Self {
|
||||||
if yes {
|
if yes {
|
||||||
self.language = Language::TypeScript;
|
self.language = Language::TypeScript;
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +95,7 @@ impl SourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_typescript_definition(mut self, yes: bool) -> Self {
|
pub const fn with_typescript_definition(mut self, yes: bool) -> Self {
|
||||||
if yes {
|
if yes {
|
||||||
self.language = Language::TypeScriptDefinition;
|
self.language = Language::TypeScriptDefinition;
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ impl SourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_jsx(mut self, yes: bool) -> Self {
|
pub const fn with_jsx(mut self, yes: bool) -> Self {
|
||||||
if yes {
|
if yes {
|
||||||
self.variant = LanguageVariant::Jsx;
|
self.variant = LanguageVariant::Jsx;
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ impl SourceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_always_strict(mut self, yes: bool) -> Self {
|
pub const fn with_always_strict(mut self, yes: bool) -> Self {
|
||||||
self.always_strict = yes;
|
self.always_strict = yes;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue