@@ -702,6 +702,14 @@ nullToMaybe' (InR (InR _)) = Nothing
702
702
703
703
type Definitions = (Definition |? ([DefinitionLink ] |? Null ))
704
704
705
+ -- | Merges two definition responses (TextDocumentDefinition | TextDocumentTypeDefinition)
706
+ -- into one preserving all locations and their order (including order of the responses).
707
+ -- Upgrades Location(s) into LocationLink(s) when one of the responses is LocationLink(s). With following fields:
708
+ -- * LocationLink.originSelectionRange = Nothing
709
+ -- * LocationLink.targetUri = Location.Uri
710
+ -- * LocationLink.targetRange = Location.Range
711
+ -- * LocationLink.targetSelectionRange = Location.Range
712
+ -- Ignores Null responses.
705
713
mergeDefinitions :: Definitions -> Definitions -> Definitions
706
714
mergeDefinitions definitions1 definitions2 = case (definitions1, definitions2) of
707
715
(InR (InR Null ), def2) -> def2
@@ -712,11 +720,11 @@ mergeDefinitions definitions1 definitions2 = case (definitions1, definitions2) o
712
720
(InR (InL links1), InR (InL links2)) -> InR $ InL (links1 ++ links2)
713
721
where
714
722
defToLinks :: Definition -> [DefinitionLink ]
715
- defToLinks (Definition (InL location)) = [DefinitionLink $ locationToLocationLink location]
716
- defToLinks (Definition (InR locations)) = map ( DefinitionLink . locationToLocationLink) locations
723
+ defToLinks (Definition (InL location)) = [locationToDefinitionLink location]
724
+ defToLinks (Definition (InR locations)) = map locationToDefinitionLink locations
717
725
718
- locationToLocationLink :: Location -> LocationLink
719
- locationToLocationLink Location {_uri, _range} = LocationLink {_originSelectionRange = Nothing , _targetUri = _uri, _targetRange = _range, _targetSelectionRange = _range}
726
+ locationToDefinitionLink :: Location -> DefinitionLink
727
+ locationToDefinitionLink Location {_uri, _range} = DefinitionLink LocationLink {_originSelectionRange = Nothing , _targetUri = _uri, _targetRange = _range, _targetSelectionRange = _range}
720
728
721
729
mergeDefs :: Definition -> Definition -> Definition
722
730
mergeDefs (Definition (InL loc1)) (Definition (InL loc2)) = Definition $ InR [loc1, loc2]
0 commit comments