Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dotnet Wrapper #390

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions glean.cabal.in
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ library indexers
glean/lang/lsif/indexer
glean/lang/scip/indexer
glean/lang/python-scip
glean/lang/dotnet-scip
glean/lang/rust-lsif
glean/lang/rust-scip
glean/lang/typescript
Expand All @@ -1010,6 +1011,7 @@ library indexers
Glean.Indexer.RustScip
Glean.Indexer.Typescript
Glean.Indexer.PythonScip
Glean.Indexer.DotnetScip
Glean.Indexer.List
build-depends:
glean:client-hs,
Expand Down
2 changes: 2 additions & 0 deletions glean/index/list/Glean/Indexer/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import qualified Glean.Indexer.LSIF as LSIF
import qualified Glean.Indexer.SCIP as SCIP
import qualified Glean.Indexer.Haskell as Hs
import qualified Glean.Indexer.PythonScip as PythonScip
import qualified Glean.Indexer.DotnetScip as DotnetScip

data SomeIndexer = forall opts . SomeIndexer (Indexer opts)

Expand All @@ -61,6 +62,7 @@ indexers =
, SomeIndexer RustScip.indexer
, SomeIndexer Typescript.indexer
, SomeIndexer PythonScip.indexer
, SomeIndexer DotnetScip.indexer
]

cmdLineParser :: Parser RunIndexer
Expand Down
44 changes: 44 additions & 0 deletions glean/lang/dotnet-scip/Glean/Indexer/DotnetScip.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{-
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.

This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
-}

{-# LANGUAGE ApplicativeDo #-}
module Glean.Indexer.DotnetScip ( indexer ) where

import Options.Applicative

import Glean.Indexer
import Glean.Indexer.External (sendJsonBatches)
import Glean.Indexer.SCIP (derive)
import Glean.SCIP.Driver as SCIP

newtype DotnetScip = DotnetScip { dotnetScipBinary :: FilePath }

options :: Parser DotnetScip
options = do
dotnetScipBinary <- strOption $
long "scip-dotnet" <>
value "scip-dotnet" <>
help "path to scip-dotnet binary"
return DotnetScip{..}

indexer :: Indexer DotnetScip
indexer = Indexer {
indexerShortName = "dotnet-scip",
indexerDescription = "Index C# code with `scip-dotnet`",
indexerOptParser = options,
indexerRun = \DotnetScip{..} backend repo IndexerParams{..} -> do
val <- SCIP.runIndexer ScipIndexerParams {
scipBinary = dotnetScipBinary,
scipArgs = const [ "index"],
scipRoot = indexerRoot,
scipWritesLocal = True,
scipLanguage = Just SCIP.CSharp
}
sendJsonBatches backend repo (dotnetScipBinary <> "/scip") val
derive backend repo
}
21 changes: 21 additions & 0 deletions glean/lang/dotnet-scip/tests/Glean/Regression/DotnetScip/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.

This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree.
-}

module Glean.Regression.DotnetScip.Main ( main ) where

import System.Environment

import Glean.Indexer.DotnetScip as DotnetScip
import Glean.Regression.Snapshot
import Glean.Regression.Snapshot.Driver

main :: IO ()
main = getArgs >>= \args -> withArgs (args ++ ["--root", path]) $
testMain (driverFromIndexer DotnetScip.indexer)
where
path = "glean/lang/dotnet-scip/tests/cases"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new line to end of file or linter will complain when we import it.