Using Play Framework 2.1.0 with NetBeans - netbeans

I have started using Play 2.1.0 and I would like to be able to use NetBeans to develop Play Java applications. I'm not really interested in using the IDE to run or test the applications since I can do that from the command line (not that I would mind if I could also have IDE support for that) but I would like to be able to open and edit my project in NetBeans without getting annoying errors where they don't really exist. I am currently using NetBeans 7.3 so I first tried to use the nbplay plugin, however it wouldn't recognise all my imports or managed classes produced by Play. I then tried to import the project as Eclipse project, as described in this and this question, which worked better, but while working my way through one of Play's Java tutorials I am still getting the following errors which make it really annoying to work with NetBeans:
I get an "Expected an operand but found error" error in main.scala.html where #content is used, although I have instructed the IDE to disable HTML error checking for this file.
In my model classes I get errors because the classes do not declare a no-argument constructor and have public variables for persistent attributes.
Any other errors I have not come across yet?
Has anyone managed to make Play 2.1.0 work with NetBeans without getting any of the above errors? I could probably live with the first one (although it would really annoy me) but the rest are showstoppers.

Be aware that the Java hints can be enable or disable in Tools -> Options -> Editor -> Hints -> Select java language.
NetBeans now has Native Support for Play Framework 2.3.x and above: http://nbpleasureplugin.com/documentation/installation.html No Command line needed at all.
The most important features are:
Create, run, debug and test your app directly in the IDE
Routes files support (Syntax coloring, Syntax Error highlighting, Autocompletion, Code navigation, Show implementation code (without navigate to source), Hint to Create method when it doesn’t exist, formatting, Mark occurrences)
Scala Template support (Syntax coloring, Syntax Error highlighting, Autocompletion, Code navigation, Show implementation code (without navigate to source), formatting, Mark occurrences)
application.conf support (Syntax coloring, autocompletion with documentation, formatting, mark occurrences)
Dependency Management (Search on Maven and add them to build.sbt)
2 Code Coverage too.s supported (jacoco and scoverage)
Test Single File
SBT file minimal support
Configurations (Formatting indentation, syntax coloring, port to use, activator parameters, etc.)
*Support play version from 2.3.x and above
Note: I created this plugin.
Also I see this could help you: How do I use Play Framework 2.0 in netbeans

Related

How to configure IntelliJ Scala Plugin to use Scala's native presentation compiler?

Although IntelliJ Scala Plugin uses Scala compiler proper to generate the actual bytecode, it seems to use its own implementation of presentation compiler to provide real-time type-aware error highlighting in the editor:
syntax highlighting feature that is implemented by Idea's Scala
plugin and it requires immediate re-processing of all the files you
change in a way similar but now exactly the same as what the real
compiler does.
This might be the reason why sometimes projects build successfully and yet IntelliJ shows false positive red underlines in the editor. This seems to be the case even if use sbt shell is selected as evident by open ticket SCL-11079
By default, the sbt compile should mark additional errors it finds in
the editor and project view. False positive errors reported by the
internal annotator should be removed if possible. There should be an
option to use sbt output as the "single source of truth" for
highlighting errors, at the cost of instant error highlighting.
or if project is imported as BSP project
sbt shell indeed won't help with error highlighting in the editor, nor
will BSP (for the time being). In-ide highlighting uses a method that
is completely separate from regular compilation
Is there anyway to configure IntelliJ to use Scala out-of-the-box presentation compiler instead of its own custom implementation such that we can decrease the chance false positive errors akin to what Metals provides?
According to show bsp diagnostics in editor SCL-16610 there exists a IntelliJ registry flag
scala.highlighting.compiler.errors.in.editor
which enables experimental feature
As error highlighting using the built-in parser and type-checker
continues to be a problem for the Scala plugin, we can experiment with
using compiler output from BSP... Potential downsides: Less rich error highlighting on type mismatch
problems: BSP and the compiler expose only raw string messages and
positions. We would lose type diffs and type error hints.
Here are the steps that made it work on my machine
Install JetBrains Toolbox which enables installation of Early Access Programs alongside releases (such that you can revert to your working system if anything goes wrong)
Install 2020.1
Make sure Nightly Builds update channel is set under Preferences | Languages & Frameworks | Scala | Updates
Remove .idea from the root of the project: rm -fr .idea
Re-import the project and select BSP project
There should be .bloop directory under project root if all OK
Open IntelliJ registry: Help | Find Action... | Registry
Set key scala.highlighting.compiler.errors.in.editor

How to eliminate error underlining in IntelliJ 14.0.3 for Play 2.3.7 application?

I am using IntelliJ IDEA 14.0.3 to develop a Play 2.3.7 application using the Scala 1.3.3 plugin.
The attached screenshot shows that IntelliJ underlines the parameter to a render method as invalid when, in fact, the system compiles and runs successfully both in IntelliJ and at the command line (using Activator):
Another user has reported this problem in IntelliJ when the view template file uses Scala-specific syntax (i.e. Form[formdata.ContactFormData]) while the controller uses Java-specific syntax (i.e. Form<formdata.ContactFormdata>). That is the case here as well.
The sources to illustrate this problem are available at: https://github.com/philipmjohnson/intellij-play-error-highlight-problem
Is this indeed a bug in IntelliJ or its Scala plugin? Are there any workarounds?
My team and I have this same issue, using Intellij 14.0.3, Scala 1.3.3 plugin and Play 2.3.8.
To workaround this I open File --> Project Structure, then click on "Modules" on the left side bar. Adding target/scala-2.11/src_managed/main to the sources eliminates these reverse routing underlines. Make sure that the root target directory is not in the excluded folders.
One thing to note however, is that Intellij seems to remove this from the sources from time to time, causing much annoyance...
The above solution works, but I think it might be useful to document a ripple effect: if you are using the Checkstyle plugin, then after adding those additional source root directories, Checkstyle will process those auto-generated Java files and (in all likelihood) raise a number of (spurious) warnings.
After fiddling around a bit, it appears the easiest way to get Checkstyle to skip those files is to specify the "Inspection Scope" as the "Default" version control scope. Since you will almost certainly exclude the target/ directory from version control, this parameter to Checkstyle keeps it on the straight and narrow. Here's a screen image illustrating the setting:

what are the differences in IntelliJ vs. eclipse regarding groovy development

I am new to IntelliJ coming from Eclipse(mainly Java) and I am trying to find out what Groovy features are included in one IDE that are missing in the other.
Example:
Eclipse shows error in package explorer and in file when package import is incomplete
import Specification --> import spock.lang.Specification
Eclipse shows package mismatch error in package explorer and in file when package name is incorrect to directory structure.
IntelliJ highlights class own methods/properties in code completion in bold eclipse does not.
I would like to gather informations about both IDEs regarding groovy support. This is not about which IDE is better but what are the differences.
I have been using idea for groovy development for very long time and its support is great.
Among the little details I know and like:
Idea spock support permit to:
-- indent the "given:", "when:", and other "then:" labels which is great.
-- you can even have then "colorized as other groovy keywords with the spock plugin"
-- idea also indent recognize the data driven column title as variable for the spec code and indent this tables
-- and idea also support creation of new specification with the "navigate to test" shortcut. "Ctrl+Shift+T"
Idea also support logger generated by ats like "#Log"

How to debug Scala Macros using Eclipse

I am trying to set a breakpoint in a Scala Macro implementation using the Eclipse IDE and failing
Firstly: Scala Macros Rock! Up to now I have preferred Clojure to Scala, but with macros I'm no longer sure
I'm trying to create a macro that will return the toString of a function and the function itself. When that works I'm going to make a new function with a sensible toString. Ah happy days.
But I need to be able to debug the macros. I use Eclipse (20110615-0604), with Scala (2.10.1). I downloaded the scala-compiler-2.10.1.jar and the code from http://www.warski.org/blog/2012/12/starting-with-scala-macros-a-short-tutorial/ now works. I've written a couple of simple macros as well. The macros are in an eclipse project "ScalaMacro" and the code that uses them is in a separate project "HelloScalaMacro"
I'd now like to debug them
Following the instructions at http://docs.scala-lang.org/overviews/macros/overview.html I have created a runtime configuration with scala.tools.nsc.Main as the entry point. I've added -cp HelloScala.scala, and when I run the configuration it actually seems to compile the code (if I put errors in, it reports the errors correctly).
Unfortunately the instructions imply that a breakpoint in the macro implementation should cause Eclipse to pause. It doesn't.
I've done the usual: google search for Eclipse/Scala macro/Debug/Breakpoint, read all the stackoverflow questions in the scala-macro tag, and played around a lot with every eclipse setting I can find.
So if any of you out there know how to set breakpoints, could you let me know how: is it an eclipse version / scala version / ... issue?
I haven't tried this myself, and in principle it is as likely (or more likely) to fail as what you've already tried, but if successful it could be more convenient to you.
To try this you should have Scala-IDE along with the source feature installed. Make sure you are working off of an Eclipse installation that is either "Eclipse Classic", "Eclipse for RCP Developers", or a similar concoction you came up with on your own.
You will also want to install the Equinox Weaving Launcher plugin, that will allow you to create an "Eclipse Application with Equinox Weaving" launchers.
Now:
Create a new workspace
Create a Scala project
Plant your macro code in that project
Add a break point in the macro source
Getting ready to debug:
Create a new "Eclipse Application with Equinox Weaving" debug launch configuration. Give a name more elegant than "New_configuration".
under "location", point it towards a new different workspace directory
under the "configuration" tab, provide something like "-Xmx1536m"
By default, all plugins available to your running Eclipse instance should be available to the instance you are about to launch. Eclipse may need some cajoling in order to include a non-plugin project in the classpath -- if this doesn't work, that's the first thing I'd try to look at.
You will now want to launch the debug configuration.
Depending on your Scala-IDE version, you may encounter a "Multiple launchers available -- Select one..." warning. I'd go for "Equinox Weaving enabled Eclipse Application Launcher".
Once inside the Eclipse instance being debugged:
Create the project you want to use the macro
Make sure to add a dependency on the binary output
Add a small usage example of your macro to the project in the workspace being debugged.
Cross your fingers
Build
In theory, the launching Eclipse instance will now pause the instance being debugged on your break point.
The instructions given by Nadavwr (just below) were helpful, and I recommend them to other people.
The key solution for me was to realise that there are two projects involved, the project that defines the macro, and the project that uses the macro. Rather foolishly I was trying to debug the project that defined the macro
So the instructions as given in the documentation are correct, I just had to make sure I was running them in the correct project: obvious of course.
For the benefit of other people, I found it very helpful to use a command line scalac to get the command line correct: much quicker editing that, and controlling which directory I was in, then in eclipse
The other thing to realise for people thinking of using Scala Macros are that the error messages from running scalac directly are MUCH better than those from eclipse.

Playframework Plugin non-functional in IntelliJ IDEA 12

I have just downloaded and installed IntelliJ IDEA 12 (Ultimate Edition), under Ubuntu, with high hopes that I could cash-in on IJ's tight integration with Scala and the Play Framework.
I have a fully functional install of Play at /home/ryan/play-2.0.4 and from searching around, it seems that all one has to do is perform a play idea on a play project at the command-line and simply open the project in IntelliJ.
However, if I do this: I can't even verify that the Playframework plug-in is even active/functioning. There is no syntax highlighting in Play config files or templates, absolutely no Playframework options in the pull-down menu. If I right-click the project, choose "Add Framework support ..." and "Play" is not even on the list, I can't just create a new "Play" project from scratch in the IDE either (not sure if that is even supported).
If I click File -> Settings -> Play Configuration, I have the Home and Working directory set to: /home/ryan/play-2.0.4. I should note that I am using Play under Eclipse with no issues (except there isn't any Play integration with Eclipse --- hence the reason why I am giving this a try in IJ). If I didn't know any better: I'd declare IJ 12's Play support as a miserable failure, but given all the postings suggesting that play 2.0 integration with IJ 12 is "very easy" - perhaps there is something I am missing?
Most probably you need to download and/or install Play 2.0 Support plugin + dependencies (most probably you will need to find it in Browse repositories section, it is not the same plugin as bundled Playframework support!)
I can ensure you that I'm just sitting and playing with Play 2.0 in Idea 12 with new support, and it works quite nice.
Go to Settings > Plugins section and check if you have newest version of mentioned plugin and if isn't blocked by some error (ie. missing dependency), try to resolve all missing dependencies, restart the IDE, and compile (or run) your applications at least once.
I didn't test it to the end yet, but I can see large progress in the support especially in templates and controllers. routes file allow easily navigate to the target actions, but as I can see there is no syntax highlighting in conf file.
There is even possible now to run and debug Play application from the menu.
In general if you'll enable the Play plugin you will see it for sure :)
You don't have to install additional plugins. You only have to run your application once, and afterwards IntelliJ highlights everything etc.
Look here: http://devnet.jetbrains.net/message/5473435?tstart=0#5473435