Effective comment annotation in Scala Eclipse Plugin? - scala

I was wondering if anyone can explain where and how comment documentation in Scala is applicable - in particular, the Eclipse plugin. For example, is there a way to comment a procedure, that might later show as a help-hint while using Eclipse? I'm not entirely sure how to get these Javadoc like effects when using Scala Eclipse. I've checked the various FAQs for the plugin, it's possibly not supported but I can't find an explanation either way.

You need to use Scaladoc, but it isn't supported completely yet.

ScalaDoc on hover/completion is not yet integrated in the Scala IDE.
The good news is that this feature is currently under development and we plan to have intial support for it in the coming months. A Pull Request for adding ScalaDoc in support in the Scala Presentation Compiler has been recently merged.
A Pull Request on the Scala IDE project will follow. You can track progress on this feature here

Related

Scala # IntelliJ 12 - Can't fetch docs / some functions are not shown in dropdown. [BUGS]

I've been searching for a long time now to find a decent IDE for Scala.
Eclipse is not satisfying at all, as auto completion doesn't work, somehow. Also, I can't modify the libraries at all in the build path e.g. set the docs/source.
IntelliJ seems better, however, there are some major bugs:
When the drop down menu appears that lists all the function, some of them are sometimes just not shown! I think it's because of scala-library / scala-compiler, it mixes them up or something...
The docs cannot be fetched, I get this message over and over again (here the functions are listed, strange enough...):
This is the library window:
The dependencies and the compiler are set right, I strongly suppose.
Does anyone know what the problem is? And how to fix it? Or is it a known bug?
Is there an IDE that can handle Scala?
Regards!
Typically, searching for names (values/classes/functions/etc.) for auto-complete can be quite slow compared to Java in IntelliJ simply because the automatically imported namespace can be quite large, and it also searches through all implicit conversions. However, I've never seen it refuse to show functions like your screenshot, what version of IntelliJ and Scala plugin are you using?
I've never gotten the pop-up docs to work via attaching JavaDocs (I haven't tried remote fetching), so I'd recommend just ctrl+click to go through to the source to read the documentation there. (However, the function/type definition does popup correctly when sources are attached). I'd suggest posting an issue at http://youtrack.jetbrains.com/issues/SCL if you have the opportunity.
To your final question, the answer is unfortunately no. The tooling for Scala is nowhere near that of Java, but both Scala IDE for Eclipse and IntelliJ are making great progress in changing that, and both are strong in some areas while weak in others. In the end, you'll get limited support either way, so choose whichever fits you best.
I have found the solution to the problem:
The bug was caused by Java Decompiler Plugin. It tried to decompile the binaries of Scala's class-files, which obviously failed. This led to that error message and further led to the Scala plugin not working as it should, thus not displaying some of the functions.
This took me a long time to figure out, I installed 2 other versions of IntelliJ (which apparently imported the JD plugin), NetBeans and downloaded several builds of the Scala Plugin, only to discover this cause. Deactivating Java Decompiler solved it.
Regards.

Is there a coding standards enforcement tool for Scala?

Where I work, we use mostly Java. We've always made extensive use of CheckStyle to enforce our coding standards for Java.
We're now branching out into Scala. Many of the same considerations as in Java apply (indentation/whitespace, naming conventions, ...) - and arguably having a consistent coding style is even more important given the power of the language.
However, there does not seem to be a Checkstyle equivalent for Scala.
Does anyone know of one?
Yes. It is called Scalastyle. (Same sort of focus as Checkstyle and findbugs). It's currently in version 0.2.0, we're adding rules all of the time
EDIT (Dec 2012):
Scalastyle 0.2.0 was released last month, with a total of 46 rules. There is, in no particular order:
A maven plugin
An eclipse plugin
An SBT plugin
Under development are:
An Intellij plugin
A sonar plugin
Contributions/bug fixes are always welcome: github.
For code formatting, you can use Scalariform.
It can be used standalone, integrated into an editor, or as an SBT plugin that runs it automatically before every compilation.
Codacy integrates Scalastyle (amazing work from Matthew) along with custom rules (like checking for Option.get() and warning you when you do them) and works as an improved Sonar for Scala.
Free for open source.
You also have abide from the Typesafe team and scapegoat from the makers of SCoverage.
There's sniff, which detect "code smells" based on regular expressions. It can be used as a Specs2 test, which is nice.

Can I write Eclipse plugins using Groovy?

Groovy seems to fix a lot of the things I dislike about Java, and I was wondering if it would be possible to actually write an Eclipse plugin in Groovy instead of Java.
Does anyone know if this is possible, and if so how to go about it?
I've just found a blog entry which says it's not officially supported but is actually possible.
Not yet tested to see if it works, but it seems promising:
Writing Eclipse plugins with Groovy, by Jörn Dinkla
#Peter, I do not think that the blog post you linked to is complete or if it will really work. It is pointing to the old version of Groovy-Eclipse, which is no longer supported and is out of date.
Yes. It is possible to create your own plugins in Groovy.
First, install the Groovy-Eclipse plugin from here:
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.7/
Then you can create a new plugin project and add the Groovy Nature.
Remove the Groovy Libraries classpath container
Instead, add the org.codehause.groovy as a required bundle
Create your Groovy code as normal
Now, the tricky part is exporting the plugin using PDE. See this blog post for how to do that: http://contraptionsforprogramming.blogspot.com/2010/08/groovy-pde-redux.html
One important thing to note is that you will need at least one Java file in your project for PDE to compile anything, It can be a dummy, empty file (this is a bug that has not yet been fixed).
Rejoice!
As an example, here is the codenarc Eclipse plugin that was written completely in Groovy:
http://sourceforge.net/projects/codenarceclipse/
You can also use JRuby, or Javascript ...
JAM Circle is a great example showing how to make great use of a scripting language in an Eclipse plugin, by allowing the end user to write his own actions and load them at runtime.
There's a proxy-like plugin that allows you to implement the plugin virtually in any language that supports JSR223 (javax.scripting)

Which scala compiler plugins are available?

I stumbled across the ScalaCL project and its compiler plugin that has an awesome loop optimizer.
This made me wonder:
Which compiler plugins are available for scala?
Plugins need not be performance improving plugins; any type of plugin is eligible for this list.
(I have done Google searches but the SNR is low for this query.)
A few plugins are linked from this thread on the mailing list (autoproxy, browse, enhanced strings, avro).
From the Scala team, there is the existing delimited continuations plugin, and a current effort toward an effect system plugin.
Documentation on writing a plugin is here.
There also exists a compiler plugin for generation functional lenses in scalaz: https://github.com/gseitz/Lensed for more details see here: http://groups.google.com/group/scalaz/browse_thread/thread/a9334c5741b67d55
There's also the miniboxing plugin, for optimizing generics: scala-miniboxing.org.
Here's a plugin written by Eiríkr Åsheim that optimizes generic numeric code (runtime + compiler plugin) :
https://github.com/azavea/numeric

Is there an easy way to integrate scaladoc into IntelliJ Idea?

How do I use/generate scaladoc from within IntelliJ Idea (running on ubuntu)? Most preferably I would like to configure Tools/generate javadoc to also generate scaladoc, though that might be hard as of the differences between both according to this thread.
The scaladoc support in IntelliJ is pretty basic for now: some keywords are highlighted in comments, but there is no "generate scaladoc" option in tools. We'll create an issue in the tracker to keep it in mind.
Thanks.
Cheers!
Ilya