vmunier/sbt-web-scalajs

IntelliJ flagging method calls when using selectScript

rators opened this issue · 4 comments

I would like to know if there is any way to have IntelliJ recognize method calls from within the Play templates. I was able to get the method to run and work as expected but I would like to have IntelliJ autocomplete method calls for me. Is there anyway to set this up? All I get is an unresolved function or method.

NOTE: Everything work fine its an IntelliJ issue. The plugin is awesome.

This is how I am calling the method: onclick="example.ScalaJSExample().addClickedMessage

And this is the playscalajs call in the template. @playscalajs.html.selectScript("client","/assets")

Again...it's a small issue, it's just that the yellow underline is bugging me :)

Autocompletion should work in IntelliJ.
Here's a screenshot, don't pay attention to the html in red, it goes away once you've selected a method:
play-scalajs-scripts-intellij-autocomplete
And I don't have the yellow underline. I am using play-scalajs-scripts v0.3.0 along with Play v2.4.0 and IntelliJ v14.1.4.
What version of play-scalajs-scripts are you using?

image

It's not the plugin that isn't working properly. I am able to make calls to the compiled JS methods just fine. The only problem is that IntelliJ does add to scope the compiled script for auto-completion. The button action method runs just fine in the example code above, but IntelliJ doesn't realize that.

I did however find a way around. By adding the -fastOpt.js file as a library in the settings for the entire views folder you get auto-completion for all the HTML files in the folder for the fastOpt file. Only thing is that now the scripts methods will be in auto-complete for all views html files even if I don't remember to import them using your scripts plugin.

image

tl:dr : IntelliJ autocompletes your plugin just fine. The problem is the file isn't in scope as far as the IDE is concerned for auto-completion when calling the @JSExported methods within the HTML. Everything else works just fine.

I looked at the showcase example here https://github.com/hussachai/play-scalajs-showcase
and the scala.js exported methods are not recognized by intelliJ here either unless I import them as a library to the server folder. The workaround still work's pretty well anyways. Is there anyway to fix this in sbt so that IntelliJ knows to add the compiled scala.js code to the views folder?

Glad to know you managed to find a workaround. The fastopt.js file is outputted to target/web/public/main and I thought IntelliJ would have looked inside this folder to know what's available and what can be used in the views. I don't know what we can do in the sbt config to make IntelliJ works here.