···4444### Language server
45454646- The language server now supports go-to-definition, find-references and rename
4747- for record fields. These work on labelled arguments, on labelled patterns, on
4848- record updates and on `record.field` accesses, both within a module and across
4949- modules. For example:
4747+ for record fields. These work on the field declaration, on labelled arguments,
4848+ on labelled patterns, on record updates and on `record.field` accesses, both
4949+ within a module and across modules. For example:
50505151 ```gleam
5252 pub type Person {
···484484 /// The type of the labelled argument value (used for hover).
485485 type_: std::sync::Arc<Type>,
486486 label: EcoString,
487487- /// The type being constructed/matched and the constructor name.
488488- /// Used for go-to-definition.
489489- container: Option<(std::sync::Arc<Type>, EcoString)>,
487487+ /// The record type the label belongs to, used for go-to-definition,
488488+ /// find-references and rename. `None` when it can't be determined.
489489+ container: Option<LabelContainer>,
490490 },
491491 ModuleName {
492492 location: SrcSpan,
···503503 ModuleImport(&'a TypedImport),
504504 ModuleCustomType(&'a TypedCustomType),
505505 ModuleTypeAlias(&'a TypedTypeAlias),
506506+}
507507+508508+/// The record type a field label belongs to. Used to resolve go-to-definition,
509509+/// find-references and rename for record fields.
510510+#[derive(Debug, Clone, PartialEq)]
511511+pub enum LabelContainer {
512512+ /// A label usage (`record.field`, a labelled argument or pattern, a record
513513+ /// update) where the value's type is known. The type carries the module
514514+ /// and name it belongs to.
515515+ Usage {
516516+ type_: std::sync::Arc<Type>,
517517+ constructor: EcoString,
518518+ },
519519+ /// A label at its declaration in a custom type. The type is being defined
520520+ /// in the current module, so only its name is needed.
521521+ Definition {
522522+ type_name: EcoString,
523523+ constructor: EcoString,
524524+ },
506525}
507526508527impl<'a> Located<'a> {
···609628 Self::Arg(_) => None,
610629 Self::Annotation { type_, .. } => self.type_location(importable_modules, type_.clone()),
611630 Self::Label {
612612- container: Some((container_type, constructor)),
631631+ container: Some(LabelContainer::Usage {
632632+ type_: container_type,
633633+ constructor,
634634+ }),
613635 label,
614636 ..
615637 } => self.label_definition_location(
···618640 label,
619641 Some(constructor),
620642 ),
643643+ // Already at the declaration; go-to-definition jumps to itself.
644644+ Self::Label {
645645+ container: Some(LabelContainer::Definition { .. }),
646646+ location,
647647+ ..
648648+ } => Some(DefinitionLocation {
649649+ module: None,
650650+ span: *location,
651651+ }),
621652 Self::Label { .. } => None,
622653 Self::TypeVariable { .. } => None,
623654 Self::ModuleName { module_name, .. } => Some(DefinitionLocation {