mirror of
https://github.com/github/semantic.git
synced 2024-11-23 08:27:56 +03:00
Add bloboid (if exists) to proto output
This commit is contained in:
parent
abd0bf08af
commit
e381f4d95d
@ -165,6 +165,7 @@ message File {
|
||||
string language = 2;
|
||||
repeated Symbol symbols = 3;
|
||||
repeated ParseError errors = 4;
|
||||
string blob_oid = 5;
|
||||
}
|
||||
|
||||
message Symbol {
|
||||
|
@ -65,7 +65,7 @@ parseSymbols blobs = ParseTreeSymbolResponse . V.fromList . toList <$> distribut
|
||||
go :: (Member (Error SomeException) sig, Member Task sig, Carrier sig m) => Blob -> m File
|
||||
go blob@Blob{..} = (doParse blob >>= withSomeTerm (renderToSymbols blob)) `catchError` (\(SomeException e) -> pure $ errorFile (show e))
|
||||
where
|
||||
errorFile e = File (pack blobPath) (bridging # blobLanguage) mempty (V.fromList [ParseError (T.pack e)])
|
||||
errorFile e = File (pack blobPath) (bridging # blobLanguage) mempty (V.fromList [ParseError (T.pack e)]) blobOid
|
||||
|
||||
symbolsToSummarize :: [Text]
|
||||
symbolsToSummarize = ["Function", "Method", "Class", "Module", "Call", "Send"]
|
||||
@ -74,7 +74,7 @@ parseSymbols blobs = ParseTreeSymbolResponse . V.fromList . toList <$> distribut
|
||||
renderToSymbols blob@Blob{..} term = pure $ either (errorFile . show) (tagsToFile blob) (runTagging blob symbolsToSummarize term)
|
||||
|
||||
tagsToFile :: Blob -> [Tag] -> File
|
||||
tagsToFile Blob{..} tags = File (pack blobPath) (bridging # blobLanguage) (V.fromList (fmap tagToSymbol tags)) mempty
|
||||
tagsToFile Blob{..} tags = File (pack blobPath) (bridging # blobLanguage) (V.fromList (fmap tagToSymbol tags)) mempty blobOid
|
||||
|
||||
tagToSymbol :: Tag -> Symbol
|
||||
tagToSymbol Tag{..}
|
||||
|
@ -1108,6 +1108,7 @@ data File = File
|
||||
, language :: Text
|
||||
, symbols :: Vector Symbol
|
||||
, errors :: Vector ParseError
|
||||
, blobOid :: Text
|
||||
} deriving stock (Eq, Ord, Show, Generic)
|
||||
deriving anyclass (Proto3.Named, NFData)
|
||||
|
||||
@ -1117,6 +1118,7 @@ instance FromJSONPB File where
|
||||
<*> obj .: "language"
|
||||
<*> obj .: "symbols"
|
||||
<*> obj .: "errors"
|
||||
<*> obj .: "blobOid"
|
||||
|
||||
instance ToJSONPB File where
|
||||
toJSONPB File{..} = object
|
||||
@ -1125,6 +1127,7 @@ instance ToJSONPB File where
|
||||
, "language" .= language
|
||||
, "symbols" .= symbols
|
||||
, "errors" .= errors
|
||||
, "blobOid" .= blobOid
|
||||
]
|
||||
toEncodingPB File{..} = pairs
|
||||
[
|
||||
@ -1132,6 +1135,7 @@ instance ToJSONPB File where
|
||||
, "language" .= language
|
||||
, "symbols" .= symbols
|
||||
, "errors" .= errors
|
||||
, "blobOid" .= blobOid
|
||||
]
|
||||
|
||||
instance FromJSON File where
|
||||
@ -1148,12 +1152,14 @@ instance Proto3.Message File where
|
||||
, encodeMessageField 2 language
|
||||
, encodeMessageField 3 (Proto3.NestedVec symbols)
|
||||
, encodeMessageField 4 (Proto3.NestedVec errors)
|
||||
, encodeMessageField 5 blobOid
|
||||
]
|
||||
decodeMessage _ = File
|
||||
<$> at decodeMessageField 1
|
||||
<*> at decodeMessageField 2
|
||||
<*> (nestedvec <$> at decodeMessageField 3)
|
||||
<*> (nestedvec <$> at decodeMessageField 4)
|
||||
<*> at decodeMessageField 5
|
||||
dotProto = undefined
|
||||
|
||||
data Symbol = Symbol
|
||||
|
Loading…
Reference in New Issue
Block a user