diff --git a/proto/semantic/api/v1/code_analysis.proto b/proto/semantic/api/v1/code_analysis.proto index 11ff46940..010c241de 100644 --- a/proto/semantic/api/v1/code_analysis.proto +++ b/proto/semantic/api/v1/code_analysis.proto @@ -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 { diff --git a/src/Semantic/Api/Bridge.hs b/src/Semantic/Api/Bridge.hs index 0a657a469..d20989e38 100644 --- a/src/Semantic/Api/Bridge.hs +++ b/src/Semantic/Api/Bridge.hs @@ -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 diff --git a/src/Semantic/Api/Symbols.hs b/src/Semantic/Api/Symbols.hs index a514d9851..d2a866c1f 100644 --- a/src/Semantic/Api/Symbols.hs +++ b/src/Semantic/Api/Symbols.hs @@ -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{..} diff --git a/src/Semantic/Api/V1/CodeAnalysisPB.hs b/src/Semantic/Api/V1/CodeAnalysisPB.hs index d9675814d..0a3e8b0bc 100644 --- a/src/Semantic/Api/V1/CodeAnalysisPB.hs +++ b/src/Semantic/Api/V1/CodeAnalysisPB.hs @@ -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