-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamline code for getDocumentationTryGhc #2349
Conversation
32f9de1
to
19f65cb
Compare
That IO gathering/handling seems strange to me, it catches IO exceptions from There is a lot of |
4402d47
to
df95e6b
Compare
This comment has been minimized.
This comment has been minimized.
b5dd8e8
to
11e198b
Compare
This comment has been minimized.
This comment has been minimized.
a94a2f3
to
cc4d333
Compare
Separately have proper bulk-optimized retrieval: I currently think singleton process should be kept, but element retrieval should be written as it is used - not for a list but for one element: |
5801b68
to
5be04f7
Compare
Since HLS uses per-1-element retrieval from GHC: The implementations for according mode are now provided. And switched the code into it. HLS now loads docs from module interfaces though proper mode implementation. |
da06f06
to
2f6553e
Compare
5c5744d
to
0a31e64
Compare
0a31e64
to
ba58953
Compare
Make code easier to reason about & functionally enhancable.
Turn `[]` into idiomatic Map.
Throw was vacuous - it was thrown & catched & ignored. At least it shows explicit type to process further.
We can not process/reason on the ArgDoc logic - if we pretend no docs are docs. It is also aligns with main doc blocks processing.
Showing error should be explicit, & conversion of error type should be a separate handling. This would also allow to establish proper processing for all these exception types.
This function was "inspired" from GHC code of `getDocs`. Since `getDocsBatch` is not really used for batch - only for singleton elements, lets make 1 element processing function & use it.
`getDocsBatch` cuurently (& before) used only for single name retrieval function. Use of it is in `Documentation` module `getDocumentationTryGhc` where it wraps arg into singleton & gives to `getDocsBatch` & then recieves a Map with 1 entry & unsafely "lookups" doc in it. This work is to supply the proper single name retrieval-optimized version to stop that `getDocsBatch` there. & further ideally `getDocumentationTryGhc` uses single-retrieval & `getDocumentationsTryGhc` uses a batch mode & batch mode gets optimized along the lines of: haskell#2371
d13c4a9
to
334188a
Compare
at least trying to
Work towards #2348 & cleaning-up worked-with code on the go.
PR solves:
haskell-language-server/ghcide/src/Development/IDE/Spans/Documentation.hs
Lines 64 to 67 in bd0046b
As
getDocumentationTryGhc
is the main code that retrieves the docs from GHC - the PR provides the element retrieval code.This PR is a stage toward provisioning the argument docs into the LSP interface. PR addressed some underlying code.
Initial
master
code conditions:getDocsBatch
had a doc:haskell-language-server/ghcide/src/Development/IDE/Core/Compile.hs
Lines 994 to 996 in 854d2c5
getDocsBatch
not optimized for batch retrieval, it does 1 element retrieval for every element. (Locates & loads a module interface, retrieves 1 element, locates & loads another module interface, retrieves 1 element ...).getDocumentationsTryGhc
(plural*s*
) - in the project had only one use - ingetDocumentationTryGhc
(single) & so was its implementation.So, over the project only (single) (meaning
getDocumentationTryGhc
) was used - & all doc requests to GHC - were 1 element requests, which got wrapped into singleton & processed as a list & by list function down the codepath.So
getDocsBatch
both was externally invoked for 1 elem & internally was processing lists per 1 elem. Batch processing optimization is addressed in getDocsBatch for bulk processing #2371.The results of the PR:
getDocs
-getDocsNonInteractive
is created (for purposes mentioned in the initial doc above) it is designed for (all current requests) case of looking-up an entity.getDocsNonInteractive
allows to stop usinggetDocumentationsTryGhcs
(plural) forgetDocumentationTryGhc
(single), which makes possible to remove unsafehead
from the main code path.getDocsNonInteractive
&getDocsBatch
formedgetDocsNonInteractive'
&initTypecheckEnv
which self-explained the code.