mirror of
https://github.com/github/semantic.git
synced 2024-12-18 12:21:57 +03:00
Add blob oids into the symbols interface
This commit is contained in:
parent
0e288e52bb
commit
532c0e3770
@ -153,6 +153,7 @@ message Blob {
|
||||
string content = 1;
|
||||
string path = 2;
|
||||
string language = 3;
|
||||
string oid = 4;
|
||||
}
|
||||
|
||||
message BlobPair {
|
||||
@ -165,6 +166,7 @@ message File {
|
||||
string language = 2;
|
||||
repeated Symbol symbols = 3;
|
||||
repeated ParseError errors = 4;
|
||||
string blob_oid = 5;
|
||||
}
|
||||
|
||||
message Symbol {
|
||||
|
@ -97,8 +97,8 @@ instance APIBridge T.Text Data.Language where
|
||||
|
||||
instance APIBridge API.Blob Data.Blob where
|
||||
bridging = iso apiBlobToBlob blobToApiBlob where
|
||||
blobToApiBlob Data.Blob{..} = API.Blob (toText blobSource) (T.pack blobPath) (bridging # blobLanguage)
|
||||
apiBlobToBlob API.Blob{..} = Data.Blob (fromText content) (T.unpack path) (language ^. bridging) mempty
|
||||
blobToApiBlob Data.Blob{..} = API.Blob (toText blobSource) (T.pack blobPath) (bridging # blobLanguage) blobOid
|
||||
apiBlobToBlob API.Blob{..} = Data.Blob (fromText content) (T.unpack path) (language ^. bridging) oid
|
||||
|
||||
|
||||
instance APIConvert API.BlobPair Data.BlobPair where
|
||||
|
@ -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{..}
|
||||
|
@ -1019,6 +1019,7 @@ data Blob = Blob
|
||||
{ content :: Text
|
||||
, path :: Text
|
||||
, language :: Text
|
||||
, oid :: Text
|
||||
} deriving stock (Eq, Ord, Show, Generic)
|
||||
deriving anyclass (Proto3.Named, NFData)
|
||||
|
||||
@ -1027,6 +1028,7 @@ instance FromJSONPB Blob where
|
||||
<$> obj .: "content"
|
||||
<*> obj .: "path"
|
||||
<*> obj .: "language"
|
||||
<*> obj .: "oid"
|
||||
|
||||
instance ToJSONPB Blob where
|
||||
toJSONPB Blob{..} = object
|
||||
@ -1034,12 +1036,14 @@ instance ToJSONPB Blob where
|
||||
"content" .= content
|
||||
, "path" .= path
|
||||
, "language" .= language
|
||||
, "oid" .= oid
|
||||
]
|
||||
toEncodingPB Blob{..} = pairs
|
||||
[
|
||||
"content" .= content
|
||||
, "path" .= path
|
||||
, "language" .= language
|
||||
, "oid" .= oid
|
||||
]
|
||||
|
||||
instance FromJSON Blob where
|
||||
@ -1055,11 +1059,13 @@ instance Proto3.Message Blob where
|
||||
encodeMessageField 1 content
|
||||
, encodeMessageField 2 path
|
||||
, encodeMessageField 3 language
|
||||
, encodeMessageField 4 oid
|
||||
]
|
||||
decodeMessage _ = Blob
|
||||
<$> at decodeMessageField 1
|
||||
<*> at decodeMessageField 2
|
||||
<*> at decodeMessageField 3
|
||||
<*> at decodeMessageField 4
|
||||
dotProto = undefined
|
||||
|
||||
data BlobPair = BlobPair
|
||||
@ -1108,6 +1114,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 +1124,7 @@ instance FromJSONPB File where
|
||||
<*> obj .: "language"
|
||||
<*> obj .: "symbols"
|
||||
<*> obj .: "errors"
|
||||
<*> obj .: "blobOid"
|
||||
|
||||
instance ToJSONPB File where
|
||||
toJSONPB File{..} = object
|
||||
@ -1125,6 +1133,7 @@ instance ToJSONPB File where
|
||||
, "language" .= language
|
||||
, "symbols" .= symbols
|
||||
, "errors" .= errors
|
||||
, "blobOid" .= blobOid
|
||||
]
|
||||
toEncodingPB File{..} = pairs
|
||||
[
|
||||
@ -1132,6 +1141,7 @@ instance ToJSONPB File where
|
||||
, "language" .= language
|
||||
, "symbols" .= symbols
|
||||
, "errors" .= errors
|
||||
, "blobOid" .= blobOid
|
||||
]
|
||||
|
||||
instance FromJSON File where
|
||||
@ -1148,12 +1158,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