forked from github/semantic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython.hs
More file actions
29 lines (23 loc) · 950 Bytes
/
Python.hs
File metadata and controls
29 lines (23 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- | Semantic functionality for Python programs.
module Language.Python
( Term(..)
, Language.Python.Grammar.tree_sitter_python
) where
import qualified AST.Unmarshal as TS
import Data.Proxy
import qualified Language.Python.AST as Py
import qualified Language.Python.Grammar (tree_sitter_python)
import Language.Python.ScopeGraph
import qualified Language.Python.Tags as PyTags
import Scope.Graph.Convert
import qualified Tags.Tagging.Precise as Tags
newtype Term a = Term { getTerm :: Py.Module a }
instance TS.SymbolMatching Term where
matchedSymbols _ = TS.matchedSymbols (Proxy :: Proxy Py.Module)
showFailure _ = TS.showFailure (Proxy :: Proxy Py.Module)
instance TS.Unmarshal Term where
matchers = fmap (fmap (TS.hoist Term)) TS.matchers
instance Tags.ToTags Term where
tags src = Tags.runTagging src . PyTags.tags . getTerm
instance ToScopeGraph Term where
scopeGraph = scopeGraphModule . getTerm