Skip to content

Commit

Permalink
fix: apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Jun 13, 2024
1 parent 537c975 commit ff3e154
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
7 changes: 1 addition & 6 deletions crates/dojo-lang/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,7 @@ impl DojoContract {
param_list: ast::ParamList,
fn_diagnostic_item: ids::SyntaxStablePtrId,
) -> (String, bool) {
self_param::check_self_parameter(
db,
&param_list,
fn_diagnostic_item,
&mut self.diagnostics,
);
self_param::check_parameter(db, &param_list, fn_diagnostic_item, &mut self.diagnostics);

let world_injection = world_param::parse_world_injection(
db,
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo-lang/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl DojoInterface {
.map(|e| e.as_syntax_node().get_text(db))
.collect::<Vec<_>>();

self_param::check_self_parameter(db, &param_list, diagnostic_item, &mut self.diagnostics);
self_param::check_parameter(db, &param_list, diagnostic_item, &mut self.diagnostics);

let world_injection = world_param::parse_world_injection(
db,
Expand Down
5 changes: 3 additions & 2 deletions crates/dojo-lang/src/syntax/self_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ use crate::syntax::utils as syntax_utils;

const SELF_PARAM_NAME: &str = "self";

/// Checks if the given function is not using `self` param.
/// Checks if the given function parameter is using `self` instead of `world` param.
/// Adds diagnostic if that case.
///
/// # Arguments
///
/// - `db` - The syntax group.
/// - `param_list` - The parameter list of the function.
/// - `fn_diagnostic_item` - The diagnostic item of the function.
/// - `diagnostics` - The diagnostics vector.
pub fn check_self_parameter(
pub fn check_parameter(
db: &dyn SyntaxGroup,
param_list: &ast::ParamList,
fn_diagnostic_item: ids::SyntaxStablePtrId,
Expand Down
10 changes: 5 additions & 5 deletions crates/dojo-lang/src/syntax/world_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum WorldParamInjectionKind {

/// Checks if the given parameter is the `world` parameter.
///
/// The `world` must be named `world`, and be placed first in the argument list, without type.
/// The `world` must be named `world`, and be placed first in the argument list.
pub fn is_world_param(param_name: &str, param_type: &str) -> bool {
param_name == WORLD_PARAM_NAME
&& (param_type == WORLD_PARAM_TYPE || param_type == WORLD_PARAM_TYPE_SNAPSHOT)
Expand All @@ -27,11 +27,11 @@ pub fn is_world_param(param_name: &str, param_type: &str) -> bool {
/// Extracts the state mutability of a function from the `world` parameter.
///
/// Checks if the function has only one `world` parameter (or None).
/// The `world` must be named `world`, and be placed first in the argument list, without type.
/// The `world` must be named `world`, and be placed first in the argument list.
///
/// `fn ext(ref world)` -> external.
/// `fn view(world)` -> view.
/// `fn noworld()` -> view.
/// `fn func1(ref world)` // would be external.
/// `fn func2(world)` // would be view.
/// `fn func3()` // would be view.
///
/// Returns
/// * The [`WorldParamInjectionKind`] determined from the function's params list.
Expand Down

0 comments on commit ff3e154

Please sign in to comment.