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

Save source with HIE files #701

Merged
merged 1 commit into from
Sep 11, 2020
Merged

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Jul 17, 2020

Closes #671

Only manual testing done, yet. Not sure how this can be tested, suggestions welcome!

Copy link
Collaborator

@cocreature cocreature left a comment

Choose a reason for hiding this comment

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

Thanks! I agree that the GetSourceFileSource rule seems unnecessary. As for tests, maybe we could just spin up ghcide to generate the file and read it afterwards in a test and see if it contains the source?

@fendor
Copy link
Collaborator Author

fendor commented Jul 28, 2020

I think there is no real way of knowing the hie file location from outside ghcide. It looks to me like we would need unit-tests that can directly access inner rules to really test it.

case msource of
Nothing -> do
source <- readFile' (fromNormalizedFilePath nfp)
let bsSource = T.encodeUtf8 $ T.pack source
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a very roundabout way of reading a file: String -> Text -> BS.
Why not use BS.readFile like GHC does?

https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/Iface/Ext/Ast.hs#L284

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, thank you!

Side question, is there some invariant that this filepath exists in the filesystem? Do we need more exception handling here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I think existing error handling will deal with this if the file does not exist.

@wz1000
Copy link
Collaborator

wz1000 commented Aug 2, 2020

I think a better way to achieve this would be to save the file contents along with the parsed module, so that we can be sure that it is never out of sync.

This can be done along with the getFileContents rule in the parsed module definition.

@pepeiborra
Copy link
Collaborator

I think a better way to achieve this would be to save the file contents along with the parsed module, so that we can be sure that it is never out of sync.

This can be done along with the getFileContents rule in the parsed module definition.

The Shake graph already guarantees this property I think

@pepeiborra
Copy link
Collaborator

rebase needed

@pepeiborra pepeiborra merged commit 1ed280b into haskell:master Sep 11, 2020
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
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.

Generated .HIE files incompatible with STAN
4 participants