@@ -31,7 +31,8 @@ import Development.IDE.Spans.Common
31
31
import Development.IDE.Types.Options
32
32
33
33
-- GHC API imports
34
- import FastString (unpackFS )
34
+ -- GHC API imports
35
+ import FastString (unpackFS , lengthFS )
35
36
import IfaceType
36
37
import Name
37
38
import NameEnv
@@ -173,14 +174,18 @@ documentHighlight hf rf pos = pure highlights
173
174
highlights = do
174
175
n <- ns
175
176
ref <- fromMaybe [] (M. lookup (Right n) rf)
176
- pure $ makeHighlight ref
177
- makeHighlight (sp,dets) =
178
- DocumentHighlight (realSrcSpanToRange sp) (Just $ highlightType $ identInfo dets)
177
+ maybeToList (makeHighlight n ref)
178
+ makeHighlight n (sp,dets)
179
+ | isTvNameSpace (nameNameSpace n) && isBadSpan n sp = Nothing
180
+ | otherwise = Just $ DocumentHighlight (realSrcSpanToRange sp) (Just $ highlightType $ identInfo dets)
179
181
highlightType s =
180
182
if any (isJust . getScopeFromContext) s
181
183
then HkWrite
182
184
else HkRead
183
185
186
+ isBadSpan :: Name -> RealSrcSpan -> Bool
187
+ isBadSpan n sp = srcSpanStartLine sp /= srcSpanEndLine sp || (srcSpanEndCol sp - srcSpanStartCol sp > lengthFS (occNameFS $ nameOccName n))
188
+
184
189
gotoTypeDefinition
185
190
:: MonadIO m
186
191
=> HieDb
@@ -271,30 +276,29 @@ atPoint IdeOptions{} (HAR _ (hf :: HieASTs a) _rf _ kind) (DKMap dm km) pos = li
271
276
renderEvidenceTree (T. Node (EvidenceInfo {evidenceDetails= Just (EvLetBind _,_,_)}) [x])
272
277
= renderEvidenceTree x
273
278
renderEvidenceTree (T. Node (EvidenceInfo {evidenceDetails= Just (EvLetBind _,_,_), .. }) xs)
274
- = hang (text " - Evidence of constraint `" O. <> expandType evidenceType O. <> " `" ) 2 $
275
- vcat $ text " depending on:" : map renderEvidenceTree' xs
276
- renderEvidenceTree x = renderEvidenceTree' x
279
+ = hang (text " Evidence of constraint `" O. <> expandType evidenceType O. <> " `" ) 2 $
280
+ vcat $ text " constructed using:" : map renderEvidenceTree' xs
281
+ renderEvidenceTree (T. Node (EvidenceInfo {.. }) _)
282
+ = hang (text " Evidence of constraint `" O. <> expandType evidenceType O. <> " `" ) 2 $
283
+ vcat $ printDets evidenceSpan evidenceDetails : map (text . T. unpack) (definedAt evidenceVar)
277
284
278
285
-- renderEvidenceTree' skips let bound evidence variables and prints the children directly
279
286
renderEvidenceTree' (T. Node (EvidenceInfo {evidenceDetails= Just (EvLetBind _,_,_)}) xs)
280
287
= vcat (map renderEvidenceTree' xs)
281
- renderEvidenceTree' (T. Node (EvidenceInfo {.. }) xs)
282
- = hang (text " - Evidence of constraint `" O. <> expandType evidenceType O. <> " `" ) 2 $
283
- vcat $ map (text . T. unpack) (definedAt evidenceVar)
284
- ++ [printDets evidenceSpan evidenceDetails (null xs)]
285
- ++ map renderEvidenceTree' xs
286
-
287
- printDets :: RealSrcSpan -> Maybe (EvVarSource , Scope , Maybe Span ) -> Bool -> SDoc
288
- printDets _ Nothing True = text " "
289
- printDets _ Nothing False = text " constructed using:"
290
- printDets ospn (Just (src,_,mspn)) _ = pprSrc
288
+ renderEvidenceTree' (T. Node (EvidenceInfo {.. }) _)
289
+ = hang (text " - `" O. <> expandType evidenceType O. <> " `" ) 2 $
290
+ vcat $ printDets evidenceSpan evidenceDetails : map (text . T. unpack) (definedAt evidenceVar)
291
+
292
+ printDets :: RealSrcSpan -> Maybe (EvVarSource , Scope , Maybe Span ) -> SDoc
293
+ printDets _ Nothing = text " using an external instance"
294
+ printDets ospn (Just (src,_,mspn)) = pprSrc
291
295
$$ text " at" <+> ppr spn
292
296
where
293
297
-- Use the bind span if we have one, else use the occurence span
294
298
spn = fromMaybe ospn mspn
295
299
pprSrc = case src of
296
300
-- Users don't know what HsWrappers are
297
- EvWrapperBind -> " bound by type signature or pattern "
301
+ EvWrapperBind -> " bound by a context "
298
302
_ -> ppr src
299
303
#endif
300
304
0 commit comments