Skip to content

Commit 8d9a58f

Browse files
Kinga Bojarczukfacebook-github-bot
Kinga Bojarczuk
authored andcommitted
query specific revision / service_id / binary_name
Summary: allow to retrieve specific: - revision - binaryName - serviceID via Glass API TODO: this is not fully correct as the right weight needs to be retrieved as well, this will be added on top; i need to catch up with asaflav whetehr taht's already in Hive; but it's fine no one will call this yet anyway Differential Revision: D71310942 fbshipit-source-id: c7f4fa5bfd295229c1254365d400695836a7b349
1 parent 20d031a commit 8d9a58f

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

glean/glass/Glean/Glass/Attributes/Class.hs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class LogResult (AttrLog key) => ToAttributes key where
4242
:: key
4343
-> Maybe Int
4444
-> Glean.IdOf Src.File
45+
-> AttributeOptions
4546
-> Glean.RepoHaxl u w [AttrRep key]
4647

4748
-- | Add attributes to symbols

glean/glass/Glean/Glass/Attributes/SymbolKind.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ instance ToAttributes SymbolKindAttr where
4848
type AttrRep SymbolKindAttr = EntityKindLabel
4949
type AttrLog SymbolKindAttr = ()
5050

51-
queryForFile _ lim fileId =
51+
queryForFile _ lim fileId _ =
5252
fst <$> Utils.searchRecursiveWithLimit lim q
5353
where
5454
-- We actually make two queries!

glean/glass/Glean/Glass/Handler/Documents.hs

+12-8
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ fetchDocumentSymbols [email protected]{..} (FileReference scsrepo path)
488488
fileId
489489
-- todo this could be done in Glean in a single pass
490490
(kinds, merr) <- withRepo fileRepo $
491-
documentSymbolKinds mlimit mlang fileId
491+
documentSymbolKinds mlimit mlang fileId attrOpts
492492

493493
let revision = getDBRevision (scmRevisions dbInfo) fileRepo scsrepo
494494
contentMatch <- case wantedRevision of
@@ -667,27 +667,29 @@ documentSymbolKinds
667667
:: Maybe Int
668668
-> Maybe Language
669669
-> Glean.IdOf Src.File
670+
-> AttributeOptions
670671
-> Glean.RepoHaxl u w
671672
([Attributes.AttrRep Attributes.SymbolKindAttr], Maybe ErrorLogger)
672673

673674
-- It's not sound to key for all entities in file in C++ , due to traces
674675
-- So we can't use the generic a attribute technique
675-
documentSymbolKinds _mlimit (Just Language_Cpp) _fileId =
676+
documentSymbolKinds _mlimit (Just Language_Cpp) _fileId _ =
676677
return mempty
677678

678679
-- Anything else, just load from Glean
679-
documentSymbolKinds mlimit _ fileId =
680-
searchFileAttributes Attributes.SymbolKindAttr mlimit fileId
680+
documentSymbolKinds mlimit _ fileId attrOptions =
681+
searchFileAttributes Attributes.SymbolKindAttr mlimit fileId attrOptions
681682

682683
searchFileAttributes
683684
:: Attributes.ToAttributes key
684685
=> key
685686
-> Maybe Int
686687
-> Glean.IdOf Src.File
688+
-> AttributeOptions
687689
-> Glean.RepoHaxl u w
688690
([Attributes.AttrRep key], Maybe ErrorLogger)
689-
searchFileAttributes key mlimit fileId = do
690-
eraw <- try $ Attributes.queryForFile key mlimit fileId
691+
searchFileAttributes key mlimit fileId attrOpts = do
692+
eraw <- try $ Attributes.queryForFile key mlimit fileId attrOpts
691693
repo <- Glean.haxlRepo
692694
case eraw of
693695
Left (err::SomeException) -- logic errors or transient errors
@@ -918,6 +920,7 @@ getSymbolAttributes env dbInfo repo opts repofile mlimit
918920
attrKey
919921
(theGleanPath repofile)
920922
mlimit
923+
(requestOptions_attribute_opts opts)
921924
return $ \refs defs ->
922925
case Attributes.augmentSymbols attrKey attrs refs defs
923926
(requestOptions_attribute_opts opts) of
@@ -930,12 +933,13 @@ genericFetchFileAttributes
930933
=> key
931934
-> GleanPath
932935
-> Maybe Int
936+
-> AttributeOptions
933937
-> RepoHaxl u w ([Attributes.AttrRep key], Maybe ErrorLogger)
934-
genericFetchFileAttributes key path mlimit = do
938+
genericFetchFileAttributes key path mlimit attrOptions = do
935939
efile <- getFile path
936940
repo <- Glean.haxlRepo
937941
case efile of
938942
Left err ->
939943
return (mempty, Just (logError err <> logError repo))
940944
Right fileId -> do
941-
searchFileAttributes key mlimit (Glean.getId fileId)
945+
searchFileAttributes key mlimit (Glean.getId fileId) attrOptions

glean/glass/if/glass.thrift

+7
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,15 @@ struct SymbolLocation {
8383

8484
struct AttributeOptions {
8585
1: bool fetch_per_line_data = false;
86+
2: optional Revision revision;
87+
3: optional ServiceID service_id;
88+
4: optional BinaryName binary_name;
8689
}
8790

91+
typedef string ServiceID (hs.newtype)
92+
93+
typedef string BinaryName (hs.newtype)
94+
8895
// Generic request options, supported by most calls
8996
struct RequestOptions {
9097
// repo-global preferred revision identifier

0 commit comments

Comments
 (0)