Skip to content

Commit

Permalink
Address style comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GearsDatapacks committed Mar 6, 2025
1 parent ac06122 commit 222b83f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion compiler-core/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ impl TypedDefinition {
return Some(annotation);
}

return Some(Located::RecordConstructor(constructor));
return Some(Located::VariantConstructorDefinition(constructor));
}

// Note that the custom type `.location` covers the function
Expand Down
6 changes: 3 additions & 3 deletions compiler-core/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub enum Located<'a> {
Statement(&'a TypedStatement),
Expression(&'a TypedExpr),
ModuleStatement(&'a TypedDefinition),
RecordConstructor(&'a TypedRecordConstructor),
VariantConstructorDefinition(&'a TypedRecordConstructor),
FunctionBody(&'a TypedFunction),
Arg(&'a TypedArg),
Annotation(SrcSpan, std::sync::Arc<Type>),
Expand Down Expand Up @@ -383,7 +383,7 @@ impl<'a> Located<'a> {
module: None,
span: statement.location(),
}),
Self::RecordConstructor(record) => Some(DefinitionLocation {
Self::VariantConstructorDefinition(record) => Some(DefinitionLocation {
module: None,
span: record.location,
}),
Expand Down Expand Up @@ -425,7 +425,7 @@ impl<'a> Located<'a> {

Located::PatternSpread { .. } => None,
Located::ModuleStatement(definition) => None,
Located::RecordConstructor(_) => None,
Located::VariantConstructorDefinition(_) => None,
Located::FunctionBody(function) => None,
Located::UnqualifiedImport(unqualified_import) => None,
Located::ModuleName { .. } => None,
Expand Down
24 changes: 14 additions & 10 deletions compiler-core/src/language_server/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ where
Located::FunctionBody(_) => Some(completer.completion_values()),

Located::ModuleStatement(Definition::TypeAlias(_) | Definition::CustomType(_))
| Located::RecordConstructor(_) => Some(completer.completion_types()),
| Located::VariantConstructorDefinition(_) => Some(completer.completion_types()),

// If the import completions returned no results and we are in an import then
// we should try to provide completions for unqualified values
Expand Down Expand Up @@ -635,7 +635,9 @@ where
})
| Definition::ModuleConstant(ModuleConstant { name_location, .. }),
)
| Located::RecordConstructor(RecordConstructor { name_location, .. }) => {
| Located::VariantConstructorDefinition(RecordConstructor {
name_location, ..
}) => {
// When we locate a module statement, we don't know where exactly the cursor
// is positioned. In this example, we want to rename the first but not the second:
// ```gleam
Expand Down Expand Up @@ -827,13 +829,15 @@ where
&this.compiler.modules,
Named::CustomTypeVariant,
),
Located::RecordConstructor(RecordConstructor { name, .. }) => rename_module_value(
&params,
&module.name,
name,
&this.compiler.modules,
Named::CustomTypeVariant,
),
Located::VariantConstructorDefinition(RecordConstructor { name, .. }) => {
rename_module_value(
&params,
&module.name,
name,
&this.compiler.modules,
Named::CustomTypeVariant,
)
}
Located::Pattern(Pattern::Constructor {
constructor: analyse::Inferred::Known(constructor),
..
Expand Down Expand Up @@ -900,7 +904,7 @@ where
))
}
Located::ModuleStatement(_) => None,
Located::RecordConstructor(_) => None,
Located::VariantConstructorDefinition(_) => None,
Located::UnqualifiedImport(UnqualifiedImport {
name,
module: module_name,
Expand Down
4 changes: 3 additions & 1 deletion compiler-core/src/language_server/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ pub fn rename_module_value(
name_kind: Named,
) -> Option<WorkspaceEdit> {
if name::check_name_case(
Default::default(),
// We don't care about the actual error here, just whether the name is valid,
// so we just use the default span.
SrcSpan::default(),
&params.new_name.as_str().into(),
name_kind,
)
Expand Down

0 comments on commit 222b83f

Please sign in to comment.