Skip to content
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

Skip parsing without haddock for above GHC9.0 #2338

Merged

Conversation

yoshitsugu
Copy link
Contributor

@yoshitsugu yoshitsugu commented Nov 10, 2021

For #1892
Just skip by #if, is it enough for this issue? 🤔

@yoshitsugu yoshitsugu force-pushed the feature/skip_parse_without_haddock_ghc90 branch from 2e12e20 to 981635d Compare November 10, 2021 08:48
@jneira
Copy link
Member

jneira commented Nov 10, 2021

For #1892 Just skip by #if, is it enough for this issue? thinking

Thanks for the pr, i think we could use runtime checks instead cpp as both branches compile with all ghcs

Runtime checks are here:

data GhcVersion
= GHC86
| GHC88
| GHC810
| GHC90
| GHC92
deriving (Eq, Ord, Show)
ghcVersionStr :: String
ghcVersionStr = VERSION_ghc
ghcVersion :: GhcVersion
#if MIN_VERSION_GLASGOW_HASKELL(9,2,0,0)
ghcVersion = GHC92
#elif MIN_VERSION_GLASGOW_HASKELL(9,0,0,0)
ghcVersion = GHC90
#elif MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
ghcVersion = GHC810
#elif MIN_VERSION_GLASGOW_HASKELL(8,8,0,0)
ghcVersion = GHC88
#elif MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)
ghcVersion = GHC86
#endif

Example here:

when (Compat.ghcVersion < Compat.GHC90) $

@yoshitsugu
Copy link
Contributor Author

@jneira oh i see. i will fix to use runtime check

@jneira jneira requested a review from pepeiborra November 10, 2021 11:55
@jneira
Copy link
Member

jneira commented Nov 10, 2021

Looks good to me but i would like to know @pepeiborra thoughts

@pepeiborra
Copy link
Collaborator

This looks reasonable to me, but does it actually work?

  1. Do we still collect haddocks in GHC 9? There seems to be some problem here, according to the testsuite.
  2. Do we no longer parse twice in GHC 9 when there is a Haddock error? The testsuite cannot verify this, but maybe you can use a trace to verify empirically.

@yoshitsugu
Copy link
Contributor Author

Sorry but I don't have enough knowledge to answer @pepeiborra' s questions. Could anyone give me any advice where to start to investigate about these questions? ( @jneira )

yoshitsugu and others added 3 commits November 12, 2021 15:05
* sort completions

* add an example

* Include fuzzy scores in completions sort text

* hlints

* Extend completion documentation to inform whether an identifier is alreaady imported

* Ditch alphabetical ordering - it's incompatible with qualified completions

* Fix bugs in completion help text

This fixes the ugly "Imported from 'Just B'" and other inconsistencies

* added tests for qualified completions

* Fix redundant import

* Inline Fuzzy.match to apply [1] and to be case-sensitive on first match

[1] - joom/fuzzy#4

* fixup! Fix bugs in completion help text

* Sort qualified completions first

* Filter out global suggestions that overlap with local

For example, don't suggest GHC.Exts.fromList when Data.Map.fromList is in scope alraedy

* Sort completions alphabetically

* Show provenance in detail text

* Sort local/in-scope completions first

* Fix build with GHC 9

* Ignore func symbol tests

Co-authored-by: Alex Naspo <[email protected]>
Co-authored-by: Javier Neira <[email protected]>
@yoshitsugu yoshitsugu force-pushed the feature/skip_parse_without_haddock_ghc90 branch from 2f74519 to 7ce5681 Compare November 12, 2021 06:11
@jneira
Copy link
Member

jneira commented Nov 12, 2021

Sorry but I don't have enough knowledge to answer @pepeiborra' s questions. Could anyone give me any advice where to start to investigate about these questions? ( @jneira )

Hi, well there is a failing test which seems to be related with the pr:

https://github.com/haskell/haskell-language-server/runs/4165727646?check_suite_focus=true

ghcide
  get
    hover
      documentation                   #1129: FAIL (1.19s)
        test/exe/Main.hs:3705:
        failed to find: `Recognizable docs: kpqz` in hover message:
        
        '''haskell
        documented :: forall (m :: * -> *) a. Monad m => Either Int (m a)
        '''
        
        *Defined at /tmp/extra-dir-14222270143316/GotoHover.hs:46:1*
        
        Use -p '/documentation                   #1129/' to rerun this test only.

As mentioned by pepe maybe we were relying in the double parsing to effectively get docs so removing it seems to be not enough, i am afraid. The test fail has to be investigated and fixed.

Related with that is the second question. Add temporary some traces (using Debug.Trace for example) could help to:

  • know why the test is failing (so to observe the behaviour when there are docs without errors, which should be collected and send in the hover information to the client)
  • confirm we are not double parsing in front of docs with errors so we should get the test case with haddock errors and check the traces added inside the else branch are not printed.

@yoshitsugu
Copy link
Contributor Author

@jneira i see. thank you for your kind comment. i'll try.

Copy link
Contributor Author

@yoshitsugu yoshitsugu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pepeiborra @jneira
I've fixed code and confirmed ghcide test code passed in my local machine. (It seems to fail testing in Windows environment on GitHub Actions, but I don't know whether it's required to pass. Please notify me if I need to confirm the Windows environemnt.)

For question 2, I confirmed not to parse twice in GHC 9.0.1 with Debug.Trace by inserting trace to getParsedModuleDefinition function.

Please point out if I misunderstood something or need to do something else.

Comment on lines +220 to +221
res@(_,pmod) <- if Compat.ghcVersion >= Compat.GHC90 then
liftIO $ (fmap.fmap.fmap) reset_ms $ getParsedModuleDefinition hsc opt file (withOptHaddock ms)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed my code to collect haddock information even if Opt_Haddock returns False.
It seems to do so for display haddock information in the hover as the failed test suites indicated.
(for question 1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, with GHC >9.0 we want to parse with Opt_Haddock on always

-- non-interest are always parsed with Haddocks
-- If we can parse Haddocks, might as well use them
--
-- HLINT INTEGRATION: might need to save the other parsed module too
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is confusing , I think it can be deleted since GetParsedModuleWithComments was introduced. What do you think @jneira ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it was even not hlint specific and can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this comment 👍

Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failure looks unrelated, testsuite is flaky in Windows. I don't see any problems with the change, looks good. Thanks for testing @yoshitsugu !

@jneira
Copy link
Member

jneira commented Nov 15, 2021

circleci build is stuck, it says there is no circleci config, which is not true, let's see what is doing in the next branch update

@jneira
Copy link
Member

jneira commented Nov 15, 2021

I've opened a ticket with circleci support but the issue is not resolved so i am gonna merging it manually, as gh workflow is green

@jneira jneira merged commit 4e2a99e into haskell:master Nov 15, 2021
@Ailrun
Copy link
Member

Ailrun commented Nov 15, 2021

@jneira Sometimes it does, and you can reactivate it by close and reopen PR.

@yoshitsugu
Copy link
Contributor Author

@pepeiborra @jneira thanks for advising me!

@jneira
Copy link
Member

jneira commented Nov 15, 2021

@jneira Sometimes it does, and you can reactivate it by close and reopen PR.

yeah, but this time create a manual workflow run in all pr's fails due to a false positive:

We have detected an anomaly that violates the CircleCI Terms of Service.
We did not test this push because the project has been suspended. Please contact us if you think this is a mistake.

https://app.circleci.com/pipelines/github/haskell/haskell-language-server/4422/workflows/5aa08e6e-359e-4da8-8b8a-ed7a810935fe/jobs/38455

@jneira jneira linked an issue Nov 18, 2021 that may be closed by this pull request
pepeiborra added a commit that referenced this pull request Nov 19, 2021
* Skip parsing without haddock for above GHC9.0

* Use runtime ghc version check

* Need parse twice in getParsedModuleRule

* Include sortText in completions and improve suggestions (#2332)

* sort completions

* add an example

* Include fuzzy scores in completions sort text

* hlints

* Extend completion documentation to inform whether an identifier is alreaady imported

* Ditch alphabetical ordering - it's incompatible with qualified completions

* Fix bugs in completion help text

This fixes the ugly "Imported from 'Just B'" and other inconsistencies

* added tests for qualified completions

* Fix redundant import

* Inline Fuzzy.match to apply [1] and to be case-sensitive on first match

[1] - joom/fuzzy#4

* fixup! Fix bugs in completion help text

* Sort qualified completions first

* Filter out global suggestions that overlap with local

For example, don't suggest GHC.Exts.fromList when Data.Map.fromList is in scope alraedy

* Sort completions alphabetically

* Show provenance in detail text

* Sort local/in-scope completions first

* Fix build with GHC 9

* Ignore func symbol tests

Co-authored-by: Alex Naspo <[email protected]>
Co-authored-by: Javier Neira <[email protected]>

* Give unique names to post-jobs (#2337)

* Restore comment

* Parse only with Haddock above GHC90

* Remove obsolete comment

Co-authored-by: Pepe Iborra <[email protected]>
Co-authored-by: Alex Naspo <[email protected]>
Co-authored-by: Javier Neira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GHC 9.0] No need to parse without Haddocks
4 participants