1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Consider all files as entry points if the strategy is unknown

This commit is contained in:
joshvera 2018-05-03 19:28:23 -04:00
parent 32d66a6947
commit 702b7fb1b7
2 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, ScopedTypeVariables, TypeFamilies, TypeOperators, UndecidableInstances #-}
module Analysis.Abstract.PythonPackage
( PythonPackaging, Strategy ) where
( PythonPackaging, Strategy(..) ) where
import Analysis.Abstract.Graph
import Control.Abstract.Analysis

View File

@ -62,9 +62,9 @@ parsePackage parser preludeFile project@Project{..} = do
where
n = name (projectName project)
-- | Parse all files in a project into 'Module's.
parseModules :: Members '[Distribute WrappedTask, Files, Task] effs => Parser term -> Project -> Eff effs [Module term]
parseModules parser Project{..} = distributeFor (projectEntryPoints <> projectFiles) (WrapTask . parseModule parser (Just projectRootDir))
-- | Parse all files in a project into 'Module's.
parseModules :: Members '[Distribute WrappedTask, Files, Task] effs => Parser term -> Project -> Eff effs [Module term]
parseModules parser Project{..} = distributeFor (projectEntryPoints <> projectFiles) (WrapTask . parseModule parser (Just projectRootDir))
-- | Parse a list of packages from a python project.
@ -76,13 +76,18 @@ parsePythonPackage :: (Show ann
-> Maybe File -- ^ Prelude (optional).
-> Project -- ^ Project to parse into a package.
-> Eff effs (Package term)
parsePythonPackage parser preludeFile Project{..} = do
parsePythonPackage parser preludeFile project@Project{..} = do
prelude <- traverse (parseModule parser Nothing) preludeFile
setupFile <- maybe (error "no setup.py found in project") pure (find ((== (projectRootDir </> "setup.py")) . filePath) projectFiles)
setupModule <- parseModule parser (Just projectRootDir) setupFile
strat <- extractStrategy setupModule
traceShowM strat
undefined
case strat of
Unknown -> do
p <- parseModules parser project
pure (Package.fromModules n Nothing prelude (length projectEntryPoints) p)
_ -> undefined
where
n = name (projectName project)
extractStrategy :: ( Show ann
, Apply Show1 syntax