Skip to content

Commit 333f94d

Browse files
committed
Rename NameContext to NameScope
Context is a rather overloaded and overused term. Scope is more appropriate here.
1 parent f91df75 commit 333f94d

7 files changed

Lines changed: 27 additions & 27 deletions

File tree

rusty_linter/src/built_ins/data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use rusty_common::{AtPos, Position};
22
use rusty_parser::{Expression, ExpressionPos, Expressions};
33

4-
use crate::core::{LintError, LintErrorPos, NameContext};
4+
use crate::core::{LintError, LintErrorPos, NameScope};
55

66
pub fn lint(
77
args: &Expressions,
8-
name_context: NameContext,
8+
name_scope: NameScope,
99
pos: Position,
1010
) -> Result<(), LintErrorPos> {
11-
if name_context == NameContext::Global {
11+
if name_scope == NameScope::Global {
1212
args.iter().try_for_each(require_constant)
1313
} else {
1414
Err(LintError::IllegalInSubFunction.at_pos(pos))

rusty_linter/src/built_ins/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ mod width;
4949
use rusty_common::Position;
5050
use rusty_parser::{BuiltInFunction, BuiltInSub, Expressions};
5151

52-
use crate::core::{LintErrorPos, NameContext};
52+
use crate::core::{LintErrorPos, NameScope};
5353

5454
pub fn lint_sub_call(
5555
built_in_sub: &BuiltInSub,
5656
pos: Position,
5757
args: &Expressions,
58-
name_context: NameContext,
58+
name_scope: NameScope,
5959
) -> Result<(), LintErrorPos> {
6060
match built_in_sub {
6161
BuiltInSub::Beep => beep::lint(args, pos),
6262
BuiltInSub::CallAbsolute => Ok(()),
6363
BuiltInSub::Close => close::lint(args),
6464
BuiltInSub::Cls => cls::lint(args, pos),
6565
BuiltInSub::Color => color::lint(args, pos),
66-
BuiltInSub::Data => data::lint(args, name_context, pos),
66+
BuiltInSub::Data => data::lint(args, name_scope, pos),
6767
BuiltInSub::DefSeg => def_seg::lint(args, pos),
6868
BuiltInSub::Environ => environ_sub::lint(args, pos),
6969
BuiltInSub::Field => field::lint(args, pos),

rusty_linter/src/converter/statement/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rusty_parser::{ExitObject, Statement};
33

44
use crate::converter::common::{Context, Convertible, ConvertibleIn, DimContext, ExprContext};
55
use crate::converter::statement::{assignment, const_rules};
6-
use crate::core::{LintError, LintErrorPos, NameContext};
6+
use crate::core::{LintError, LintErrorPos, NameScope};
77

88
impl ConvertibleIn<Position> for Statement {
99
fn convert_in(self, ctx: &mut Context, pos: Position) -> Result<Self, LintErrorPos> {
@@ -37,16 +37,16 @@ impl ConvertibleIn<Position> for Statement {
3737
Ok(Self::Resume(resume_option))
3838
}
3939
}
40-
Self::Exit(exit_object) => match ctx.names.get_name_context() {
41-
NameContext::Global => Err(LintError::IllegalOutsideSubFunction.at_pos(pos)),
42-
NameContext::Sub => {
40+
Self::Exit(exit_object) => match ctx.names.get_name_scope() {
41+
NameScope::Global => Err(LintError::IllegalOutsideSubFunction.at_pos(pos)),
42+
NameScope::Sub => {
4343
if exit_object == ExitObject::Sub {
4444
Ok(Self::Exit(exit_object))
4545
} else {
4646
Err(LintError::IllegalInSubFunction.at_pos(pos))
4747
}
4848
}
49-
NameContext::Function => {
49+
NameScope::Function => {
5050
if exit_object == ExitObject::Function {
5151
Ok(Self::Exit(exit_object))
5252
} else {

rusty_linter/src/core/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod casting;
22
mod const_value_resolver;
33
mod error;
4-
mod name_context;
4+
mod name_scope;
55
mod qb_casting;
66
mod qualify_variant;
77
mod ref_to_value_visitor;
@@ -17,7 +17,7 @@ mod visitor;
1717
pub use self::casting::*;
1818
pub use self::const_value_resolver::*;
1919
pub use self::error::*;
20-
pub use self::name_context::*;
20+
pub use self::name_scope::*;
2121
pub use self::qb_casting::*;
2222
pub use self::qualify_variant::*;
2323
pub use self::ref_to_value_visitor::*;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2-
pub enum NameContext {
2+
pub enum NameScope {
33
Global,
44
Sub,
55
Function,

rusty_linter/src/names/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rusty_parser::{
66
};
77
use rusty_variant::Variant;
88

9-
use crate::core::{ConstLookup, NameContext, SubprogramName};
9+
use crate::core::{ConstLookup, NameScope, SubprogramName};
1010
use crate::names::ImplicitVars;
1111
use crate::names::names_inner::NamesInner;
1212
use crate::names::traits::ManyNamesTrait;
@@ -169,11 +169,11 @@ impl Names {
169169
self.current_key.is_some()
170170
}
171171

172-
pub fn get_name_context(&self) -> NameContext {
172+
pub fn get_name_scope(&self) -> NameScope {
173173
match &self.current_key {
174-
Some(SubprogramName::Function(_)) => NameContext::Function,
175-
Some(SubprogramName::Sub(_)) => NameContext::Sub,
176-
None => NameContext::Global,
174+
Some(SubprogramName::Function(_)) => NameScope::Function,
175+
Some(SubprogramName::Sub(_)) => NameScope::Sub,
176+
None => NameScope::Global,
177177
}
178178
}
179179

rusty_linter/src/post_linter/built_in_linter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use rusty_parser::*;
33

44
use super::post_conversion_linter::PostConversionLinter;
55
use crate::built_ins::{lint_function_call, lint_sub_call};
6-
use crate::core::{LintErrorPos, NameContext};
6+
use crate::core::{LintErrorPos, NameScope};
77

88
/// Lints built-in functions and subs.
99
pub struct BuiltInLinter {
10-
name_context: NameContext,
10+
name_scope: NameScope,
1111
}
1212

1313
impl BuiltInLinter {
1414
pub fn new() -> Self {
1515
Self {
16-
name_context: NameContext::Global,
16+
name_scope: NameScope::Global,
1717
}
1818
}
1919
}
@@ -23,16 +23,16 @@ impl PostConversionLinter for BuiltInLinter {
2323
&mut self,
2424
f: &FunctionImplementation,
2525
) -> Result<(), LintErrorPos> {
26-
self.name_context = NameContext::Function;
26+
self.name_scope = NameScope::Function;
2727
let result = self.visit_statements(&f.body);
28-
self.name_context = NameContext::Global;
28+
self.name_scope = NameScope::Global;
2929
result
3030
}
3131

3232
fn visit_sub_implementation(&mut self, s: &SubImplementation) -> Result<(), LintErrorPos> {
33-
self.name_context = NameContext::Sub;
33+
self.name_scope = NameScope::Sub;
3434
let result = self.visit_statements(&s.body);
35-
self.name_context = NameContext::Global;
35+
self.name_scope = NameScope::Global;
3636
result
3737
}
3838

@@ -43,7 +43,7 @@ impl PostConversionLinter for BuiltInLinter {
4343
) -> Result<(), LintErrorPos> {
4444
let (built_in_sub, args) = built_in_sub_call.into();
4545
self.visit_expressions(args)?;
46-
lint_sub_call(built_in_sub, pos, args, self.name_context)
46+
lint_sub_call(built_in_sub, pos, args, self.name_scope)
4747
}
4848

4949
fn visit_expression(&mut self, expr_pos: &ExpressionPos) -> Result<(), LintErrorPos> {

0 commit comments

Comments
 (0)