Tell interface files from implementation files again in editor analysis
Why
Since #8436, Uri.is_interface passes its arguments to Filename.check_suffix in the wrong order, so it always returns false. Editor analysis then pairs a .resi declaration with itself instead of with its .res side: references list the .resi location twice and miss the .res one, rename edits the .resi twice and leaves the .res unchanged, and go to definition from a .resi declaration stays in the interface.
modifiedReferences a value with an interface
// ReferencesWithInterface.reslet x = 2// ReferencesWithInterface.resilet x: int
text
Before references of x from the .resi
After references of x from the .resi
……ReferencesWithInterface.resi 0:4ReferencesWithInterface.resi 0:4ReferencesWithInterface.resi 0:4ReferencesWithInterface.res 0:4
modifiedDefinition from a declaration in a .resi
text
Before tests/analysis_tests/tests/src/DefinitionWithInterface.resi
After tests/analysis_tests/tests/src/DefinitionWithInterface.resi
DefinitionWithInterface.resiDefinitionWithInterface.res
Review
- Why
String.ends_with ~suffix:Literals.suffix_resi? Its labeled argument cannot be swapped the way the positional arguments ofFilename.check_suffixwere, and the compiler's.resiconstant says what is meant. It tests the URI's path (Lsp.Uri.to_path), which ignores query and fragment, instead of the whole encoded URI.Shared_types.get_cmt_path, which picks the.cmtifor an interface URI, had its own copy of the test and now callsUri.is_interface. - Which snapshots change? Cross, DefinitionWithInterface.resi, Jsx2, References, ReferencesWithInterface.resi and RenameWithInterface.resi: each duplicate
.resientry becomes the.resentry, and definitions from a.resireach the implementation, as they did before #8436.