Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Import paths are relative to cradle #781

Merged
merged 17 commits into from
Sep 12, 2020

Conversation

pepeiborra
Copy link
Collaborator

I noticed ghcide HEAD was broken on the ghcide submodule of the haskell-language-server repo, after the recent changes to import paths. Hopefully this fixes the issue

Fixes #780

@pepeiborra
Copy link
Collaborator Author

Once again I had to special case the implicit cradle...

@pepeiborra pepeiborra force-pushed the relative-import-paths branch 2 times, most recently from 450e8a9 to 94d25ba Compare September 11, 2020 08:01
@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Sep 11, 2020

@wz1000 check that my change to not filter by doesFileExist when extending the known files doesn't break anything

@wz1000
Copy link
Collaborator

wz1000 commented Sep 11, 2020

Why remove the check that the files exist? The file paths are still coming from the same source as far as I can tell, last I remember they were generated by something like a cartesian product of import paths and module names.

@wz1000
Copy link
Collaborator

wz1000 commented Sep 11, 2020

I think the files eventually go here, so this is not correct: https://github.com/haskell/ghcide/blob/master/src/Development/IDE/Core/Rules.hs#L374

@jneira
Copy link
Member

jneira commented Sep 11, 2020

Once again I had to special case the implicit cradle...

would that be needed after #782?

@pepeiborra
Copy link
Collaborator Author

Why remove the check that the files exist? The file paths are still coming from the same source as far as I can tell, last I remember they were generated by something like a cartesian product of import paths and module names.

I'm removing the check that the files exist (when extending the set of known files) because otherwise ghcide doesn't pick up new modules created after updating the cradle.

Is the Cartesian product logic in hie-bios or in ghc?

@pepeiborra
Copy link
Collaborator Author

I think the files eventually go here, so this is not correct: https://github.com/haskell/ghcide/blob/master/src/Development/IDE/Core/Rules.hs#L374

this doesn't seem related

@pepeiborra
Copy link
Collaborator Author

Once again I had to special case the implicit cradle...

would that be needed after #782?

I don't know, it depends on what is changed in #782.

@wz1000
Copy link
Collaborator

wz1000 commented Sep 11, 2020

I think the files eventually go here, so this is not correct: https://github.com/haskell/ghcide/blob/master/src/Development/IDE/Core/Rules.hs#L374

this doesn't seem related

It is. We call use_ GetModSummaryWithoutTimestamps on each file name put into the known files list, which will fail every time if any of those files don't exist.

@wz1000
Copy link
Collaborator

wz1000 commented Sep 11, 2020

Why remove the check that the files exist? The file paths are still coming from the same source as far as I can tell, last I remember they were generated by something like a cartesian product of import paths and module names.

I'm removing the check that the files exist (when extending the set of known files) because otherwise ghcide doesn't pick up new modules created after updating the cradle.

Is the Cartesian product logic in hie-bios or in ghc?

It's in ghcide: https://github.com/haskell/ghcide/blob/master/session-loader/Development/IDE/Session.hs#L359

@pepeiborra pepeiborra force-pushed the relative-import-paths branch from b3d074f to 44c0cc5 Compare September 11, 2020 16:58
@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Sep 11, 2020

Is the Cartesian product logic in hie-bios or in ghc?

It's in ghcide: https://github.com/haskell/ghcide/blob/master/session-loader/Development/IDE/Session.hs#L359

I see your point now. I've restored the filtering and implemented an alternative solution for missing modules which preserves the old behaviour.

EDIT: Hmm, I don't think the alternative solution works. ghcide will not locate a missing module when it is created because it is not in the set of known files. Perhaps extending the set of known files to a map of candidates will do it.

@pepeiborra pepeiborra force-pushed the relative-import-paths branch from 7484e34 to 68d1cfe Compare September 11, 2020 19:37
@pepeiborra
Copy link
Collaborator Author

The problem is that we are trying to use the KnownFiles to determine what imports are part of the local project, and the KnownFiles do not have enough information for that.

The solution is to enrich the KnownFiles to become KnownTargets, which provides a mapping from every target to a list of normalised file paths that do exist for them. The keys of the mapping are the targets and can be used to determine local imports, whereas the values of the mapping are still used to drive the module graph

@pepeiborra pepeiborra force-pushed the relative-import-paths branch from 68d1cfe to 9c788d5 Compare September 11, 2020 19:39
@wz1000
Copy link
Collaborator

wz1000 commented Sep 11, 2020

Won't we still end up calling rawDependencyInformation with a bunch of non existent files?

I noticed ghcide HEAD was broken on the ghcide submodule of the hls repo.
The implicit cradle comes without import paths, so we need to preserve the old
logic that synthetised them from the current module
@pepeiborra
Copy link
Collaborator Author

Won't we still end up calling rawDependencyInformation with a bunch of non existent files?

I restored the filtering, so I don't think so

@azure-pipelines
Copy link

Command 'ru' is not supported by Azure Pipelines.

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@pepeiborra
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pepeiborra pepeiborra force-pushed the relative-import-paths branch from 9c788d5 to e46f21d Compare September 11, 2020 21:24
@pepeiborra
Copy link
Collaborator Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pepeiborra
Copy link
Collaborator Author

I have disabled a flaky test that was blocking this PR. Have you noticed this test failing before?

@wz1000
Copy link
Collaborator

wz1000 commented Sep 12, 2020 via email

@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Sep 12, 2020

Yes, I saw it for the first time yesterday. Rerunning the job fixed it. Maybe saving ifaces exposed this? Switching the order of iface-error-1 and iface-error-2 could be one way to tell.

I think it's likely related to saving ifaces, I don't recall seeing it before, but maybe CI history can confirm. Could you investigate? The failure could be indicative of a real bug.

I have not managed to reproduce it locally though, it's very annoying.

@pepeiborra pepeiborra merged commit 7dacc23 into haskell:master Sep 12, 2020
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Import paths are relative to cradle

I noticed ghcide HEAD was broken on the ghcide submodule of the hls repo.

* remove unused

* Fix comment placement

* Special case the implicit cradle

The implicit cradle comes without import paths, so we need to preserve the old
logic that synthetised them from the current module

* Hlint

* Fix timing issue: update known files before restarting the session

Also, DO NOT filter out missing targets

* Use --verbose when running tests

* Log test outputs on 3rd attempt

* Fall back to filtering known files

* hlint

* Upgrade KnownFiles to KnownTargets

* Use KnownTargets to filter modules, not module paths

* Fix test cradle

* Increase pauses in flaky test

* remove no longer needed check

* Disable ansi color codes in CI

* Disable flaky test
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Import paths are relative to cradle

I noticed ghcide HEAD was broken on the ghcide submodule of the hls repo.

* remove unused

* Fix comment placement

* Special case the implicit cradle

The implicit cradle comes without import paths, so we need to preserve the old
logic that synthetised them from the current module

* Hlint

* Fix timing issue: update known files before restarting the session

Also, DO NOT filter out missing targets

* Use --verbose when running tests

* Log test outputs on 3rd attempt

* Fall back to filtering known files

* hlint

* Upgrade KnownFiles to KnownTargets

* Use KnownTargets to filter modules, not module paths

* Fix test cradle

* Increase pauses in flaky test

* remove no longer needed check

* Disable ansi color codes in CI

* Disable flaky test
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* Import paths are relative to cradle

I noticed ghcide HEAD was broken on the ghcide submodule of the hls repo.

* remove unused

* Fix comment placement

* Special case the implicit cradle

The implicit cradle comes without import paths, so we need to preserve the old
logic that synthetised them from the current module

* Hlint

* Fix timing issue: update known files before restarting the session

Also, DO NOT filter out missing targets

* Use --verbose when running tests

* Log test outputs on 3rd attempt

* Fall back to filtering known files

* hlint

* Upgrade KnownFiles to KnownTargets

* Use KnownTargets to filter modules, not module paths

* Fix test cradle

* Increase pauses in flaky test

* remove no longer needed check

* Disable ansi color codes in CI

* Disable flaky test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird errors with imports in subcomponents
3 participants