Skip to content

Commit 95d1457

Browse files
Catherine Gasnierfacebook-github-bot
authored andcommitted
the indexer emits glean facts directly
Summary: In this diff, the swift indexer not only emits SCIP index, but also some glean facts for the new swift.angle schema. For now the facts emitted are for predicate SymbolLanguage. We'll add more in future diffs. This is based on the info obtained from demangling the USR. Note: for now, these new facts are ignored by the indexing workflow Rabbit hole: Demangling the USRs was using std::regex which has really bad perf. The indexing time for my test went from 5 seconds to 5 minutes. I rewrote the code to do some basic parsing instead. Regression is now only 13%. While I was at it, I added support for clang structs and enum USRs. I also added a unit test for demangling. Differential Revision: D79262434 fbshipit-source-id: e3048134756478b663513d85b9df4dd80809a6e9
1 parent 8d77473 commit 95d1457

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

glean/lang/swift/Glean/Indexer/Swift.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import Glean.Indexer
1515
import Glean.Indexer.External
1616
import Glean.Indexer.SCIP ( derive )
1717
import qualified Glean.SCIP.Driver as SCIP
18-
import System.FilePath (takeDirectory)
18+
import System.FilePath ( (</>), takeDirectory)
19+
import Glean.LocalOrRemote ( serializeInventory )
20+
import qualified Data.ByteString as BS
1921

2022
data Swift = Swift
2123
{ scipGen :: FilePath
@@ -40,6 +42,9 @@ indexer = Indexer {
4042
indexerDescription = "Index Swift code",
4143
indexerOptParser = options,
4244
indexerRun = \Swift{..} backend repo IndexerParams{..} -> do
45+
let tmpDir = indexerOutput
46+
inventoryFile = tmpDir </> "inventory.data"
47+
serializeInventory backend repo >>= BS.writeFile inventoryFile
4348
val <- SCIP.runIndexer SCIP.ScipIndexerParams {
4449
scipBinary = scipGen,
4550
scipArgs = \outFile ->
@@ -48,6 +53,7 @@ indexer = Indexer {
4853
, "--target", target
4954
, "--swift-only"
5055
, "--output-type", "scip"
56+
, "--inventory", inventoryFile
5157
, "--build-indexer" ],
5258
scipRoot = indexerRoot,
5359
scipWritesLocal = False,

0 commit comments

Comments
 (0)