-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend symbolLocation with the repo revision used
Summary: Glass.symbolLocation should also provide a repo_hash. This diff adds the hash. ``` fbdbg> =await GleanGlass::genSymbolLocation($glass, "www/php/GleanGlass", null) GleanGlass\SymbolLocation Object ( [location] => GleanGlass\LocationRange Object ( [repository] => "www" [filepath] => "flib/intern/glean/GleanGlass.php" [range] => GleanGlass\Range Object ( [lineBegin] => 21 [columnBegin] => 1 [lineEnd] => 438 [columnEnd] => 2 ) ) [revision] => "f25c89ae41f2a367d59fb7d7bc14949b0f08e3d9" ) ``` Reviewed By: phlalx Differential Revision: D60025655 fbshipit-source-id: 1fa87718be82926ab8ce4c1d53999bd107f1c26e
- Loading branch information
1 parent
94046a9
commit 51a9031
Showing
49 changed files
with
436 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,23 +214,32 @@ findReferenceRanges [email protected]{..} sym opts@RequestOptions{..} = | |
where | ||
limit = fmap fromIntegral requestOptions_limit | ||
|
||
|
||
-- | Resolve a symbol identifier to its range-based location in the latest db | ||
symbolLocation | ||
:: Glass.Env | ||
-> SymbolId | ||
-> RequestOptions | ||
-> IO LocationRange | ||
symbolLocation env@Glass.Env{..} sym opts = do | ||
withSymbol "symbolLocation" env opts sym | ||
$ \gleanDBs _dbInfo (repo, lang, toks) -> | ||
findSymbolLocationRange env GleanBackend{..} repo lang toks | ||
-- This is about 10x cheaper than a full describeSymbol() call | ||
symbolLocation :: Glass.Env -> SymbolId -> RequestOptions -> IO SymbolLocation | ||
symbolLocation env@Glass.Env{..} sym opts = | ||
withSymbol "symbolLocation" env opts sym $ | ||
\gleanDBs dbInfo (scmRepo, lang, toks) -> | ||
backendRunHaxl GleanBackend{..} env $ do | ||
r <- Search.searchEntityLocation lang toks | ||
(entity, err) <- case r of | ||
None t -> throwM (ServerException t) | ||
One e -> return (e, Nothing) | ||
Many { initial = e, message = t } -> | ||
return (e, Just (GlassExceptionReason_entitySearchFail t)) | ||
let SearchEntity { entityRepo, decl = (_,file,rangespan,_) } = entity | ||
let scmRevs = scmRevisions dbInfo | ||
(, fmap logError err) <$> withRepo entityRepo (do | ||
location <- rangeSpanToLocationRange scmRepo file rangespan | ||
repo_hash <- getRepoHashForLocation location scmRevs <$> Glean.haxlRepo | ||
return $ SymbolLocation { | ||
symbolLocation_location = location, | ||
symbolLocation_revision = repo_hash | ||
}) | ||
|
||
-- | Describe characteristics of a symbol | ||
describeSymbol | ||
:: Glass.Env | ||
-> SymbolId | ||
-> RequestOptions | ||
:: Glass.Env -> SymbolId -> RequestOptions | ||
-> IO SymbolDescription | ||
describeSymbol env@Glass.Env{..} symId opts = | ||
withSymbol "describeSymbol" env opts symId $ | ||
|
@@ -642,18 +651,6 @@ toFileReference :: RepoName -> Path -> FileReference | |
toFileReference repo path = | ||
FileReference repo (toGleanPath $ SymbolRepoPath repo path) | ||
|
||
-- | Symbol search: try to resolve the line/col range of an entity | ||
findSymbolLocationRange | ||
:: Glean.Backend b | ||
=> Glass.Env | ||
-> GleanBackend b | ||
-> RepoName | ||
-> Language | ||
-> [Text] | ||
-> IO (LocationRange, Maybe ErrorLogger) | ||
findSymbolLocationRange env b repo lang toks = backendRunHaxl b env $ | ||
withEntity rangeSpanToLocationRange repo lang toks | ||
|
||
-- | Symbol search for references | ||
fetchSymbolReferences | ||
:: Glean.Backend b | ||
|
@@ -732,23 +729,6 @@ symbolToAngleEntities lang toks = do | |
Left err -> Left (logError (GlassExceptionReason_entityNotSupported err)) | ||
Right results -> Right (results, searchErr) | ||
|
||
|
||
-- | Run an action on the result of looking up a symbol id | ||
withEntity | ||
:: (RepoName -> Src.File -> Code.RangeSpan -> RepoHaxl u w a) | ||
-> RepoName | ||
-> Language | ||
-> [Text] | ||
-> Glean.ReposHaxl u w (a, Maybe ErrorLogger) | ||
withEntity f scsrepo lang toks = do | ||
r <- Search.searchEntityLocation lang toks | ||
(SearchEntity{entityRepo, decl=(_,file,rangespan,_)}, err) <- case r of | ||
None t -> throwM (ServerException t) | ||
One e -> return (e, Nothing) | ||
Many { initial = e, message = t } -> | ||
return (e, Just (GlassExceptionReason_entitySearchFail t)) | ||
(, fmap logError err) <$> withRepo entityRepo (f scsrepo file rangespan) | ||
|
||
fetchSymbolsAndAttributesGlean | ||
:: Glean.Backend b | ||
=> Glass.Env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/buck/resolveSymbolRange_target.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "buck_project/TEST_TARGETS", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 12, | ||
"lineEnd": 18 | ||
"location": { | ||
"filepath": "buck_project/TEST_TARGETS", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 12, | ||
"lineEnd": 18 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/buck/resolveSymbol_def.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "buck_project/my_defs.bzl", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 6, | ||
"lineBegin": 9, | ||
"lineEnd": 12 | ||
"location": { | ||
"filepath": "buck_project/my_defs.bzl", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 6, | ||
"lineBegin": 9, | ||
"lineEnd": 12 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/buck/resolveSymbol_file.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "buck_project/toto.c", | ||
"range": { | ||
"columnBegin": 0, | ||
"columnEnd": 0, | ||
"lineBegin": 0, | ||
"lineEnd": 0 | ||
"location": { | ||
"filepath": "buck_project/toto.c", | ||
"range": { | ||
"columnBegin": 0, | ||
"columnEnd": 0, | ||
"lineBegin": 0, | ||
"lineEnd": 0 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/buck/resolveSymbol_target.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "buck_project/TEST_TARGETS", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 12, | ||
"lineEnd": 18 | ||
"location": { | ||
"filepath": "buck_project/TEST_TARGETS", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 12, | ||
"lineEnd": 18 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 59, | ||
"lineEnd": 67 | ||
"location": { | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 59, | ||
"lineEnd": 67 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/cpp/resolveSymbolRange.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 59, | ||
"lineEnd": 67 | ||
"location": { | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 59, | ||
"lineEnd": 67 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/cpp/resolveSymbolRange_Nothing.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 74, | ||
"lineEnd": 78 | ||
"location": { | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 1, | ||
"columnEnd": 2, | ||
"lineBegin": 74, | ||
"lineEnd": 78 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/cpp/resolveSymbolRange_Nothing_ctor.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 3, | ||
"columnEnd": 41, | ||
"lineBegin": 77, | ||
"lineEnd": 77 | ||
"location": { | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 3, | ||
"columnEnd": 41, | ||
"lineBegin": 77, | ||
"lineEnd": 77 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
17 changes: 10 additions & 7 deletions
17
glean/glass/test/regression/tests/cpp/resolveSymbolRange_Nothing_ctor_decl.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
[ | ||
"@generated", | ||
{ | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 30, | ||
"columnEnd": 37, | ||
"lineBegin": 77, | ||
"lineEnd": 77 | ||
"location": { | ||
"filepath": "test.cpp", | ||
"range": { | ||
"columnBegin": 30, | ||
"columnEnd": 37, | ||
"lineBegin": 77, | ||
"lineEnd": 77 | ||
}, | ||
"repository": "test" | ||
}, | ||
"repository": "test" | ||
"revision": "testhash" | ||
} | ||
] |
Oops, something went wrong.