Skip to content

Allow ide module rebuilds without touching fs output/cache-db#4362

Closed
wclr wants to merge 3 commits intopurescript:masterfrom
wclr:pure-ide-rebuild
Closed

Allow ide module rebuilds without touching fs output/cache-db#4362
wclr wants to merge 3 commits intopurescript:masterfrom
wclr:pure-ide-rebuild

Conversation

@wclr
Copy link
Copy Markdown
Contributor

@wclr wclr commented Jul 4, 2022

Description of the change

This PR allows ide rebuilds without involving the file system by directly sending module source code (instead of file path) and expecting that it will affect ide state, but not file system output (compiled source, externs, and cache-db.json).

This is needed to enable a more robust version of getting IDE diagnostics on type feature.

Summary of actual changes

src\Language\PureScript\Make\Actions.hs
added ffiCodegen' exported function that allows performing FFI check with/without actual codegen (copying the foreign module to the output).

src\Language\PureScript\Ide\Rebuild.hs
Added check if in place of file name to rebuild we got text data:... expecting actual module source after data: prefix. If so, assume to make a "pure rebuild" i.e., without any file system codegen and modifying cache-db.json.

Prior work: #4178


Checklist:

  • Added a file to CHANGELOG.d for this PR (see CHANGELOG.d/README.md)
  • Added myself to CONTRIBUTORS.md (if this is my first contribution)
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@i-am-the-slime
Copy link
Copy Markdown
Contributor

i-am-the-slime commented Aug 24, 2022

@wclr Could you add the change to the protocol here?
https://github.com/purescript/purescript/blob/master/psc-ide/PROTOCOL.md#rebuild

Would also be great if anybody on the core team could review this.

@i-am-the-slime
Copy link
Copy Markdown
Contributor

If anybody would like to try this here's a build of the vscode extension:

You can install it via cmd-shift-p "install from vsix".

ide-purescript-0.26.0-beta.vsix.zip

Comment on lines +454 to +458
copyForeign path mn =
case makeOutputPath of
Nothing -> pure ()
Just outputFilename ->
copyFile path (outputFilename mn "foreign.js")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this traverse_ makeOutputPath \outputFileName -> copyFile path (outputFilename mn "foreign.js")?

Comment on lines +78 to +82
& (if pureRebuild then shushCodegen else identity)
& ( if pureRebuild
then enableForeignCheck foreigns codegenTargets
else identity
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should these two if expressions be merged?

if pureRebuild then
  enableForeignCheck foreigns codegenTargets . shushCodegen
else
  identity

@JordanMartinez
Copy link
Copy Markdown
Contributor

This otherwise looks fine to me.

@i-am-the-slime
Copy link
Copy Markdown
Contributor

@wclr May I take this over and address @JordanMartinez 's comments?

@wclr
Copy link
Copy Markdown
Contributor Author

wclr commented Oct 28, 2022

Sorry I missed this out a bit.

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.

3 participants