···429429 /// The location excluding the potential `as ...` clause, or the `type` keyword.
430430 /// For example, in `type Wibble as Wobble`, it covers `Wibble`.
431431 pub imported_name_location: &'a SrcSpan,
432432+ pub as_name: Option<&'a EcoString>,
432433}
433434434435impl<'a> UnqualifiedImport<'a> {
436436+ /// If the import is aliased, it is the start of the alias. Otherwise, it is
437437+ /// the start of the imported name.
438438+ ///
439439+ /// For example, in `type Wibble as Wobble`, the used name will start at
440440+ /// `Wobble`. In `type Wibble`, it will start at `Wibble`.
441441+ pub fn used_name_start(&self) -> u32 {
442442+ match self.as_name {
443443+ // For aliases, the location span will cover the whole of `type
444444+ // Wibble as Wobble`.
445445+ // So, the used name will start 6 chars (length of `Wobble`) before
446446+ // the span ends.
447447+ Some(as_name) => self.location.end - as_name.len() as u32,
448448+ // For non-aliased imports, use the start of the imported name
449449+ // location. It covers `Wibble` in `type Wibble as Wobble`.
450450+ None => self.imported_name_location.start,
451451+ }
452452+ }
453453+435454 pub fn name_kind(&self) -> Named {
436455 let is_upname = match self.name.chars().next() {
437456 Some(c) => c.is_uppercase(),
···888888 Referenced::ModuleValue {
889889 module,
890890 location,
891891+ name_start,
891892 target_kind,
892893 ..
893894 }
894895 | Referenced::ModuleType {
895896 module,
896897 location,
898898+ name_start,
897899 target_kind,
898900 ..
899901 },
···904906 RenameTarget::Unqualified | RenameTarget::Definition => true,
905907 };
906908 if rename_allowed {
909909+ // The location field is sometimes larger than the
910910+ // location of the actual name. In most cases they are
911911+ // the same, but in import statements that are for types
912912+ // and/or are aliased, the location is larger than the
913913+ // name.
914914+ //
915915+ // For example, in `import m.{type Wibble as Wobble}`,
916916+ // location will cover `type Wibble as Wobble` but
917917+ // the name is just `Wobble`. In every case (including
918918+ // non-imports), the name is at the very end of the
919919+ // location span.
920920+ let location = SrcSpan {
921921+ start: name_start,
922922+ end: location.end,
923923+ };
907924 success_response(location)
908925 } else {
909926 None
···11341151 ))
11351152 }
11361153 },
11371137- Some(Referenced::ModuleType {
11381138- module,
11391139- name,
11401140- location,
11411141- ..
11421142- }) if location.contains(byte_index) => match search_scope {
11541154+ Some(Referenced::ModuleType { module, name, .. }) => match search_scope {
11431155 FindReferencesSearchScope::AllModules => Some(find_module_references(
11441156 module,
11451157 name,
···13121324 is_type,
13131325 location,
13141326 imported_name_location: _,
13271327+ as_name: _,
13151328 }) => this
13161329 .compiler
13171330 .get_module_interface(module_name.as_str())