Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

match codebase naming conventions for record field labels

+38 -44
+12 -12
compiler-core/src/ast.rs
··· 17 17 use crate::analyse::Inferred; 18 18 use crate::ast::typed::pairwise_all; 19 19 use crate::bit_array; 20 - use crate::build::{ExpressionPosition, LabelContainer, Located, Target, module_erlang_name}; 20 + use crate::build::{ExpressionPosition, LabelOwner, Located, Target, module_erlang_name}; 21 21 use crate::exhaustiveness::CompiledCase; 22 22 use crate::parse::{LiteralFloatValue, SpannedString}; 23 23 use crate::type_::error::VariableOrigin; ··· 1159 1159 location: *label_location, 1160 1160 type_: argument.type_.clone(), 1161 1161 label: label.clone(), 1162 - container: Some(LabelContainer::Definition { 1162 + owner: Some(LabelOwner::Definition { 1163 1163 type_name: self.name.clone(), 1164 1164 constructor: constructor.name.clone(), 1165 1165 }), ··· 1735 1735 None => { 1736 1736 if self.location.contains(byte_index) && let Some(label) = &self.label { 1737 1737 let fn_type = called_function.type_(); 1738 - let container_type = fn_type.return_type().unwrap_or(fn_type); 1738 + let record_type = fn_type.return_type().unwrap_or(fn_type); 1739 1739 Some(Located::Label { 1740 1740 location: self.location, 1741 1741 type_: self.value.type_(), 1742 1742 label: label.clone(), 1743 - container: called_function.record_constructor_name().map(|c| { 1744 - LabelContainer::Usage { 1745 - type_: container_type, 1743 + owner: called_function.record_constructor_name().map(|c| { 1744 + LabelOwner::Usage { 1745 + type_: record_type, 1746 1746 constructor: c, 1747 1747 } 1748 1748 }), ··· 1800 1800 pub fn find_node( 1801 1801 &self, 1802 1802 byte_index: u32, 1803 - container_type: &Arc<Type>, 1803 + record_type: &Arc<Type>, 1804 1804 constructor: Option<&EcoString>, 1805 1805 ) -> Option<Located<'_>> { 1806 1806 match self.value.find_node(byte_index) { ··· 1813 1813 location: self.location, 1814 1814 type_: self.value.type_(), 1815 1815 label: label.clone(), 1816 - container: constructor.map(|c| LabelContainer::Usage { 1817 - type_: container_type.clone(), 1816 + owner: constructor.map(|c| LabelOwner::Usage { 1817 + type_: record_type.clone(), 1818 1818 constructor: c.clone(), 1819 1819 }), 1820 1820 }) ··· 1830 1830 pub fn find_node( 1831 1831 &self, 1832 1832 byte_index: u32, 1833 - container_type: &Arc<Type>, 1833 + record_type: &Arc<Type>, 1834 1834 constructor: Option<&EcoString>, 1835 1835 ) -> Option<Located<'_>> { 1836 1836 match self.value.find_node(byte_index) { ··· 1843 1843 location: self.location, 1844 1844 type_: self.value.type_(), 1845 1845 label: label.clone(), 1846 - container: constructor.map(|c| LabelContainer::Usage { 1847 - type_: container_type.clone(), 1846 + owner: constructor.map(|c| LabelOwner::Usage { 1847 + type_: record_type.clone(), 1848 1848 constructor: c.clone(), 1849 1849 }), 1850 1850 })
+9 -8
compiler-core/src/build.rs
··· 486 486 label: EcoString, 487 487 /// The record type the label belongs to, used for go-to-definition, 488 488 /// find-references and rename. `None` when it can't be determined. 489 - container: Option<LabelContainer>, 489 + owner: Option<LabelOwner>, 490 490 }, 491 491 ModuleName { 492 492 location: SrcSpan, ··· 508 508 /// The record type a field label belongs to. Used to resolve go-to-definition, 509 509 /// find-references and rename for record fields. 510 510 #[derive(Debug, Clone, PartialEq)] 511 - pub enum LabelContainer { 511 + pub enum LabelOwner { 512 512 /// A label usage (`record.field`, a labelled argument or pattern, a record 513 513 /// update) where the value's type is known. The type carries the module 514 514 /// and name it belongs to. ··· 628 628 Self::Arg(_) => None, 629 629 Self::Annotation { type_, .. } => self.type_location(importable_modules, type_.clone()), 630 630 Self::Label { 631 - container: Some(LabelContainer::Usage { 632 - type_: container_type, 633 - constructor, 634 - }), 631 + owner: 632 + Some(LabelOwner::Usage { 633 + type_: record_type, 634 + constructor, 635 + }), 635 636 label, 636 637 .. 637 638 } => self.label_definition_location( 638 639 importable_modules, 639 - container_type, 640 + record_type, 640 641 label, 641 642 Some(constructor), 642 643 ), 643 644 // Already at the declaration; go-to-definition jumps to itself. 644 645 Self::Label { 645 - container: Some(LabelContainer::Definition { .. }), 646 + owner: Some(LabelOwner::Definition { .. }), 646 647 location, 647 648 .. 648 649 } => Some(DefinitionLocation {
+2 -2
language-server/src/engine.rs
··· 66 66 progress::ProgressReporter, 67 67 reference::{ 68 68 FindVariableReferences, Referenced, VariableReferenceKind, find_label_references, 69 - find_label_references_in_current_module, find_module_references, reference_for_ast_node, 69 + find_label_references_in_module, find_module_references, reference_for_ast_node, 70 70 }, 71 71 rename::{ 72 72 RenameOutcome, RenameTarget, Renamed, rename_label, rename_local_variable, ··· 1103 1103 FindReferencesSearchScope::CurrentModule => { 1104 1104 let source_information = self.compiler.get_source(&source_module.name)?; 1105 1105 let source_module = self.compiler.get_module_interface(&source_module.name)?; 1106 - Some(find_label_references_in_current_module( 1106 + Some(find_label_references_in_module( 1107 1107 type_module, 1108 1108 type_name, 1109 1109 label,
+15 -22
language-server/src/reference.rs
··· 12 12 self, ArgNames, AssignName, BitArraySize, ClauseGuard, CustomType, Function, 13 13 ModuleConstant, Pattern, RecordConstructor, SrcSpan, TypedExpr, TypedModule, visit::Visit, 14 14 }, 15 - build::{LabelContainer, Located}, 15 + build::{LabelOwner, Located}, 16 16 type_::{ 17 17 ModuleInterface, ModuleValueConstructor, Type, ValueConstructor, ValueConstructorVariant, 18 18 error::{Named, VariableOrigin}, ··· 401 401 }), 402 402 403 403 Located::Label { 404 - container: Some(LabelContainer::Usage { type_, .. }), 404 + owner: Some(LabelOwner::Usage { type_, .. }), 405 405 label, 406 406 location, 407 407 .. ··· 417 417 // A label at its declaration in a custom type, which lives in the 418 418 // current module. 419 419 Located::Label { 420 - container: Some(LabelContainer::Definition { type_name, .. }), 420 + owner: Some(LabelOwner::Definition { type_name, .. }), 421 421 label, 422 422 location, 423 423 .. ··· 500 500 sources: &HashMap<EcoString, ModuleSourceInformation>, 501 501 ) -> Vec<Location> { 502 502 let mut reference_locations = Vec::new(); 503 - let key = (type_module.clone(), type_name, label); 504 503 505 504 for module in modules.values() { 506 505 if module.name == type_module || module.references.imported_modules.contains(&type_module) { 507 506 let Some(source_information) = sources.get(&module.name) else { 508 507 continue; 509 508 }; 510 - find_label_references_in_module( 511 - &key, 509 + reference_locations.extend(find_label_references_in_module( 510 + type_module.clone(), 511 + type_name.clone(), 512 + label.clone(), 512 513 module, 513 514 source_information, 514 - &mut reference_locations, 515 - ); 515 + )); 516 516 } 517 517 } 518 518 519 519 reference_locations 520 520 } 521 521 522 - pub fn find_label_references_in_current_module( 522 + pub fn find_label_references_in_module( 523 523 type_module: EcoString, 524 524 type_name: EcoString, 525 525 label: EcoString, ··· 527 527 source_information: &ModuleSourceInformation, 528 528 ) -> Vec<Location> { 529 529 let mut reference_locations = Vec::new(); 530 - let key = (type_module, type_name, label); 531 - find_label_references_in_module(&key, module, source_information, &mut reference_locations); 532 - reference_locations 533 - } 534 530 535 - fn find_label_references_in_module( 536 - key: &(EcoString, EcoString, EcoString), 537 - module: &ModuleInterface, 538 - source_information: &ModuleSourceInformation, 539 - reference_locations: &mut Vec<Location>, 540 - ) { 541 531 let Some(uri) = url_from_path(source_information.path.as_str()) else { 542 - return; 532 + return reference_locations; 543 533 }; 544 534 545 - let Some(references) = module.references.label_references.get(key) else { 546 - return; 535 + let key = (type_module, type_name, label); 536 + let Some(references) = module.references.label_references.get(&key) else { 537 + return reference_locations; 547 538 }; 548 539 549 540 for reference in references { ··· 552 543 range: src_span_to_lsp_range(reference.location, &source_information.line_numbers), 553 544 }); 554 545 } 546 + 547 + reference_locations 555 548 } 556 549 557 550 fn find_references_in_module(