Skip to content

Commit a8344c0

Browse files
committed
[haskell indexer facebookincubator#5] Optionally store file content
1 parent 3dd4ba8 commit a8344c0

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

glean/lang/haskell/HieIndexer/Index.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ indexHieFile writer HieIndexerOptions{..} path hie = do
398398
let fileLines = mkFileLines filefact offs
399399
Glean.makeFact_ @Src.FileLines fileLines
400400

401+
when storeSrc $
402+
Glean.makeFactV_ @Src.FileContent filefact $
403+
Text.decodeUtf8Lenient (hie_hs_src hie)
404+
401405
Glean.makeFact_ @Hs.ModuleSource $
402406
Hs.ModuleSource_key modfact filefact
403407

glean/lang/haskell/HieIndexer/Options.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ data HieIndexerOptions = HieIndexerOptions
3636
-- ^ Prefix to add to source paths
3737
, unitName :: UnitName
3838
-- ^ How to handle unit names
39+
, storeSrc :: Bool
40+
-- ^ Whether to store the indexed source in src.FileContent
3941
, verbosity :: Int
4042
}
4143

@@ -82,6 +84,10 @@ options = info (helper <*> parser) fullDesc
8284
metavar "PATH" <>
8385
help "Prefix to add to source paths in the DB"))
8486

87+
storeSrc <- switch (
88+
long "store-src" <>
89+
help "Store the full source file in src.FileContent")
90+
8591
unitName <- option (maybeReader parseUnit) (
8692
long "unit" <>
8793
metavar "key|id" <>

glean/schema/source/src.angle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ predicate File : string
88
# Source code digests produced by unspecified hash function
99
predicate FileDigest : File -> string
1010

11+
# Source code content (if the indexer stored it)
12+
predicate FileContent : File -> string
13+
1114
# Common source code location type
1215
type Loc = {
1316
file : File,

0 commit comments

Comments
 (0)