mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
make semantic-python build
This commit is contained in:
parent
ba8b5b05a9
commit
56145869a4
@ -42,13 +42,13 @@ The graph should be
|
||||
-}
|
||||
|
||||
|
||||
runScopeGraph :: ToScopeGraph t => Path.AbsRelFile -> Source.Source -> t Loc -> (ScopeGraph.ScopeGraph ScopeGraph.Info, Result)
|
||||
runScopeGraph p _src item = run . runSketch @ScopeGraph.Info (Just p) $ scopeGraph item
|
||||
runScopeGraph :: ToScopeGraph t => Path.AbsRelFile -> Source.Source -> t Loc -> (ScopeGraph.ScopeGraph Addr, Result)
|
||||
runScopeGraph p _src item = run . runSketch @Addr (Just p) $ scopeGraph item
|
||||
|
||||
sampleGraphThing :: (Has (Sketch ScopeGraph.Info) sig m) => m Result
|
||||
sampleGraphThing :: (Has (Sketch Addr) sig m) => m Result
|
||||
sampleGraphThing = do
|
||||
declare @ScopeGraph.Info "hello" DeclProperties
|
||||
declare @ScopeGraph.Info "goodbye" DeclProperties
|
||||
declare @Addr "hello" DeclProperties
|
||||
declare @Addr "goodbye" DeclProperties
|
||||
pure Complete
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ main = do
|
||||
file <- ByteString.readFile path
|
||||
tree <- TS.parseByteString @Py.Module @Loc TSP.tree_sitter_python file
|
||||
pyModule <- either die pure tree
|
||||
let (expecto, Complete) = run $ runSketch @ScopeGraph.Info Nothing sampleGraphThing
|
||||
let (expecto, Complete) = run $ runSketch @Addr Nothing sampleGraphThing
|
||||
let (result, Complete) = runScopeGraph (Path.absRel path) (Source.fromUTF8 file) pyModule
|
||||
print result
|
||||
assertEqual expecto result
|
||||
|
@ -21,7 +21,6 @@ import Control.Effect.Sketch
|
||||
import Convert.ToScopeGraph
|
||||
import Data.Foldable
|
||||
import qualified Data.List.NonEmpty as NonEmpty
|
||||
import qualified Data.ScopeGraph as ScopeGraph
|
||||
import Language.Python.Core (pattern SingleIdentifier)
|
||||
import qualified Language.Python.Tags as PyTags
|
||||
import qualified Tags.Tagging.Precise as Tags
|
||||
@ -49,7 +48,7 @@ instance ToScopeGraph Term where
|
||||
instance ToScopeGraph Py.AssertStatement where scopeGraph = onChildren
|
||||
|
||||
instance ToScopeGraph Py.Assignment where
|
||||
scopeGraph (Py.Assignment _ (SingleIdentifier t) _val _typ) = complete <* declare @ScopeGraph.Info t DeclProperties
|
||||
scopeGraph (Py.Assignment _ (SingleIdentifier t) _val _typ) = complete <* declare @Addr t DeclProperties
|
||||
scopeGraph x = todo x
|
||||
|
||||
instance ToScopeGraph Py.Await where
|
||||
|
@ -15,7 +15,6 @@ module Convert.ToScopeGraph
|
||||
|
||||
import Control.Effect.Sketch
|
||||
import Data.Foldable
|
||||
import Data.ScopeGraph
|
||||
import GHC.Generics
|
||||
import GHC.Records
|
||||
import Source.Loc
|
||||
@ -24,7 +23,7 @@ type Addr = Int
|
||||
|
||||
class ToScopeGraph t where
|
||||
scopeGraph ::
|
||||
( Has (Sketch (Info Addr)) sig m
|
||||
( Has (Sketch Addr) sig m
|
||||
)
|
||||
=> t Loc
|
||||
-> m Result
|
||||
@ -45,7 +44,7 @@ instance (ToScopeGraph l, ToScopeGraph r) => ToScopeGraph (l :+: r) where
|
||||
|
||||
onField ::
|
||||
forall field syn sig m r .
|
||||
( Has (Sketch (Info Addr)) sig m
|
||||
( Has (Sketch Addr) sig m
|
||||
, HasField field (r Loc) (syn Loc)
|
||||
, ToScopeGraph syn
|
||||
)
|
||||
@ -58,7 +57,7 @@ onField
|
||||
onChildren ::
|
||||
( Traversable t
|
||||
, ToScopeGraph syn
|
||||
, Has (Sketch (Info Addr)) sig m
|
||||
, Has (Sketch Addr) sig m
|
||||
, HasField "extraChildren" (r Loc) (t (syn Loc))
|
||||
)
|
||||
=> r Loc
|
||||
|
Loading…
Reference in New Issue
Block a user