evanw / skew

A web-first, cross-platform programming language with an optimizing compiler
https://evanw.github.io/skew-lang.org/
MIT License
410 stars 16 forks source link

Skew sources and the VS Code IDE plug-in #12

Closed mindplay-dk closed 7 years ago

mindplay-dk commented 8 years ago

I tried opening the Skew compiler sources in VS Code with the Skew plug-in installed.

It seems to error on pretty much any attempt to "go to definition", usually with an error message about a missing file, but I've seen different error messages while trying it out. I haven't successfully managed to go to any definition in the source-code.

I noticed you're using a pretty big python script to build the compiler. Perhaps this is part of the reason why the VS Code plug-in can't navigate the codebase?

Can I expect I'd have to write complex build-scripts and sacrifice IDE support to build larger complex projects myself, or is part of this remnants from a time when Skew was less capable than it is now? (source in need of refactoring/updates to make use of current language features?)

evanw commented 8 years ago

I haven't looked into this too much but I believe the reason is because the plugin runs require('skew') and VSCode gets confused between the version of the Skew compiler that comes with the plugin which it should be using and the project it just opened that also has a package.json file for the Skew package. My guess is that this is a bug in VSCode. I have been using the plugin with other Skew projects and it's been working fine for me.

The only issue with the IDE plugin and large projects is that right now the plugin assumes that every *.sk file it can see is part of the same project (I haven't made an IDE project file format yet with multiple build targets). Luckily, Skew's conditional code compilation makes this limitation very easy to work around and I haven't found this to be an issue in practice. I usually use something like this to support multiple build targets from within a single project:

enum Build {
  MAIN_THREAD
  WORKER_THREAD
  UNIT_TESTS
}

const BUILD = Build.MAIN_THREAD

@entry if BUILD == .MAIN_THREAD
def mainThreadEntry { ... }

@entry if BUILD == .WORKER_THREAD
def workerThreadEntry { ... }

@entry if BUILD == .UNIT_TESTS
def unitTestsEntry { ... }

You can compile different builds by changing the value of BUILD on the command line (--define:BUILD=UNIT_TESTS for example). That way multiple build targets can all use the same code and IDE support works fine.

mindplay-dk commented 7 years ago

Closing this old issue, as it works much better now :-)