diff options
author | alexwl <alexey.a.kiryushin@gmail.com> | 2018-10-20 22:26:52 +0300 |
---|---|---|
committer | alexwl <alexey.a.kiryushin@gmail.com> | 2018-10-20 22:26:52 +0300 |
commit | 78b1fa37d553f9094fe85d7a6afe24e4f0a82106 (patch) | |
tree | de14a7da3fe179bd09fb8cacfc7506f1c2c7cbbb /src/HaskellCodeExplorer/AST | |
parent | 5d6e827870baf57a02e11aeae08026214a5853be (diff) |
Index quoted identifiers (Template Haskell)
This makes identifiers in TH expression like 'value or ''Type clickable in Haskell code explorer
Diffstat (limited to 'src/HaskellCodeExplorer/AST')
-rw-r--r-- | src/HaskellCodeExplorer/AST/RenamedSource.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/HaskellCodeExplorer/AST/RenamedSource.hs b/src/HaskellCodeExplorer/AST/RenamedSource.hs index 46ecc8f..d3b67d3 100644 --- a/src/HaskellCodeExplorer/AST/RenamedSource.hs +++ b/src/HaskellCodeExplorer/AST/RenamedSource.hs @@ -42,6 +42,7 @@ import GHC , LSig , LTyClDecl , Located + , HsBracket(..) #if MIN_VERSION_GLASGOW_HASKELL(8,2,2,0) , HsMatchContext(..) , Match(..) @@ -76,6 +77,16 @@ import TysWiredIn , typeNatKind , typeSymbolKind ) +import SrcLoc + ( mkRealSrcSpan + , mkRealSrcLoc + , realSrcSpanEnd + , realSrcSpanStart + , srcLocCol + , srcLocFile + , srcLocLine + , SrcSpan(..) + ) data NameOccurrence = NameOccurrence { locatedName :: Located (Maybe Name) , description :: T.Text @@ -209,6 +220,28 @@ hsExprNames (L _span (HsRecFld (Ambiguous (L span _) _name))) = , isBinder = False } ] +hsExprNames (L span (HsRnBracketOut (VarBr quote name) _)) = + case span of + RealSrcSpan realSpan -> + let start = realSrcSpanStart realSpan + end = realSrcSpanEnd realSpan + offset = + if quote + then 1 -- 'x + else 2 -- ''T + start' = + mkRealSrcLoc + (srcLocFile start) + (srcLocLine start) + (srcLocCol start + offset) + span' = RealSrcSpan $ mkRealSrcSpan start' end + in [ NameOccurrence + { locatedName = L span' (Just name) + , description = "VarBr" + , isBinder = False + } + ] + _ -> [] hsExprNames _ = [] #if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0) |