Skip to content

Commit

Permalink
fix toSourceUnit a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
spatten committed Oct 20, 2023
1 parent 01091ad commit 5a4e7e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/App/Fossa/VSIDeps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import Graphing (Graphing)
import Graphing qualified
import Path (Abs, Dir, Path, toFilePath)
import Srclib.Converter qualified as Srclib
import Srclib.Types (AdditionalDepData (..), SourceUnit (..), SourceUserDefDep)
import Types (DiscoveredProjectType (..))
import Srclib.Types (AdditionalDepData (..), SourceUnit (..), SourceUserDefDep, textToOriginPath)
import Types (DiscoveredProjectType (..), GraphBreadth (Complete))

-- | VSI analysis is sufficiently different from other analysis types that it cannot be just another strategy.
-- Instead, VSI analysis is run separately over the entire scan directory, outputting its own source unit.
Expand Down Expand Up @@ -62,9 +62,8 @@ analyzeVSIDeps dir projectRevision filters skipResolving = do

-- These deps have to get up to the backend somehow on a 'SourceUnit's 'additionalData'.
-- This generates an empty-graph source unit and puts the userdeps on it.

let renderedPath = toText (toFilePath dir)
let userDepSrcUnits = toSourceUnit renderedPath mempty resolvedUserDeps
userDepSrcUnits = toSourceUnit renderedPath mempty resolvedUserDeps

pure . Just $ userDepSrcUnits : directSrcUnits

Expand All @@ -76,7 +75,7 @@ ruleToSourceUnit skipResolving VSI.VsiRule{..} = do

toSourceUnit :: Text -> Graphing Dependency -> Maybe [SourceUserDefDep] -> SourceUnit
toSourceUnit path deps additionalDeps = do
let unit = Srclib.toSourceUnit False path deps VsiProjectType
let unit = Srclib.toSourceUnit False path deps VsiProjectType Complete [textToOriginPath path]
unit{additionalData = fmap toDepData additionalDeps}
where
toDepData d = AdditionalDepData (Just d) Nothing
14 changes: 8 additions & 6 deletions src/Srclib/Converter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Graphing qualified
import Path (toFilePath)
import Srclib.Types (
Locator (..),
OriginPath,
SourceUnit (..),
SourceUnitBuild (
SourceUnitBuild,
Expand All @@ -43,18 +44,19 @@ import Srclib.Types (
buildSucceeded
),
SourceUnitDependency (..),
textToOriginPath,
somePathToOriginPath,
)
import Types (DiscoveredProjectType, GraphBreadth (..))

projectToSourceUnit :: Bool -> ProjectResult -> SourceUnit
projectToSourceUnit leaveUnfiltered ProjectResult{..} =
toSourceUnit leaveUnfiltered renderedPath projectResultGraph projectResultType
toSourceUnit leaveUnfiltered renderedPath projectResultGraph projectResultType projectResultGraphBreadth originPaths
where
renderedPath = toText (toFilePath projectResultPath)
originPaths = map somePathToOriginPath projectResultManifestFiles

toSourceUnit :: Bool -> Text -> Graphing Dependency -> DiscoveredProjectType -> SourceUnit
toSourceUnit leaveUnfiltered path dependencies projectType =
toSourceUnit :: Bool -> Text -> Graphing Dependency -> DiscoveredProjectType -> GraphBreadth -> [OriginPath] -> SourceUnit
toSourceUnit leaveUnfiltered path dependencies projectType graphBreadth originPaths =
SourceUnit
{ sourceUnitName = path
, sourceUnitType = toText projectType
Expand All @@ -67,8 +69,8 @@ toSourceUnit leaveUnfiltered path dependencies projectType =
, buildImports = imports
, buildDependencies = deps
}
, sourceUnitGraphBreadth = Complete
, sourceUnitOriginPaths = [textToOriginPath path]
, sourceUnitGraphBreadth = graphBreadth
, sourceUnitOriginPaths = originPaths
, additionalData = Nothing
}
where
Expand Down

0 comments on commit 5a4e7e6

Please sign in to comment.