Eclipse plug-in

756 views
Skip to first unread message

Stefan De Boey

unread,
Sep 12, 2011, 1:15:19 PM9/12/11
to sca...@googlegroups.com
hi,

i was wondering if there's already someone working on an Eclipse plugin for Scalate?
i'm interested in creating a plug-in with editor support (fancy colors, snippets, ...) for editing Scalate templates in Eclipse (and maybe also integration with the Scala IDE, JDT, ...)
in case somebody is already working on this, maybe i can contribute? otherwise i can start a new project for this.

would you guys be interested in such a plugin ?

thanks,
stefan

James Strachan

unread,
Sep 13, 2011, 4:24:14 AM9/13/11
to sca...@googlegroups.com
On 12 September 2011 18:15, Stefan De Boey <ste...@ellefant.be> wrote:
> hi,
> i was wondering if there's already someone working on an Eclipse plugin for
> Scalate?

Not that I know of.


> i'm interested in creating a plug-in with editor support (fancy colors,
> snippets, ...) for editing Scalate templates in Eclipse (and maybe also
> integration with the Scala IDE, JDT, ...)

Awesome! We created Scalate so it'd be fairly easy to make IDE
friendly; particularly to be able to do smart completion on the Scala
code & expressions (so an IDE would know at edit time the static
context, imports & types of everything to get awesome smart
completion); so I've been desperate for such a thing for a while :)
http://scalate.fusesource.org/documentation/user-guide.html#If_you_are_an_IDE_hacker
http://scalate.fusesource.org/creating-ide.html

but so far all we've got are TextMate bundles for syntax highlighting
(which are not perfect but OK - unfortunately no code folding in
jade/scaml).
http://scalate.fusesource.org/documentation/user-guide.html#TextMate_plugin


> in case somebody is already working on this, maybe i can contribute?

Please do!


> otherwise i can start a new project for this.
> would you guys be interested in such a plugin ?

Definitely!

For Jade/Scaml I was wondering if it'd make sense to take an already
available HAML plugin and refactor it; as mostly (at least to get 90%
of the way there) Scaml is HAML but using Scala rather than Ruby for
the code & expressions. Then Jade is pretty close to Scaml but omits
the % on element names and uses | as the first character on newlines
for text; so its hopefully a minor tweak to the grammar/lexer.

It looks like there's the Aptana Eclipse plugin for HAML/SASS
http://stackoverflow.com/questions/1474096/using-haml-sass-with-eclipse

plus there's lexers for HAML/SASS
http://www.mail-archive.com/ha...@googlegroups.com/msg01886.html

It seems the Aptana HAML support is here...
https://github.com/aptana/studio3-ruby/tree/development/plugins/com.aptana.editor.haml

not sure how easy it is to hack; but hopefully we could wire in the
Scala Eclipse Plugin to handle the Scala expressions inside
Jade/Scaml. For SSP I guess a JSP / Velocity plugin for Eclipse could
maybe be reused as a base?

We could of course use the Scalate parser to parse the templates; the
main issue though is for great IDE integration you often have to parse
bad documents and try make sense of them; so IDE's tend to use
incremental parsers using different parser technology to the actual
underlying language. e.g. In IDEA folks tend to use JFlex to parse the
text in the editor to better handle not-yet-complete files.


Another thing worth mentioning is XText for Eclipse...
http://www.eclipse.org/Xtext/

which from a parser generates a nice syntax highlighter with smart
completion with outline UI etc.

The grammars for jade/scaml/ssp are all pretty simple; so it wouldn't
be that big a deal to reimplement them on top of the underlying Antlr
mechanism in XText. All our parsers in Scalate use the Scala parser
combinators stuff (which rock!) - I did wonder if we could reuse the
existing parser combinator model and kinda introspect them to be able
to create different kinds of parsers for IDE integration; so I wonder
if we could figure out how to transform the parser combinators into
Antlr grammars that XText could use? Might be a step so far though :).
It does seem like you get so much bang for the buck with XText; that
maybe we should try create XText grammars for Scaml/Jade and SSP and
we've get a pretty decent IDE (with code folding, syntax highlighting,
outline view, warning red squiggles, completion etc) with very little
work.

If its helpful we could maybe use the underlying AST models that the
Scalate parsers use. e.g. for Scaml/Jade its the derivations of the
Statement class (expand the "Known subclasses" field on this page...)
http://scalate.fusesource.org/maven/1.5.2/scalate-core/scaladocs/index.html#org.fusesource.scalate.scaml.Statement

Or see the classes here
https://github.com/scalate/scalate/blob/master/scalate-core/src/main/scala/org/fusesource/scalate/scaml/ScamlParser.scala#L138

Here's the full scaml parser btw
https://github.com/scalate/scalate/blob/master/scalate-core/src/main/scala/org/fusesource/scalate/scaml/ScamlParser.scala#L162

Have never tried introspecting Scala Parser Combinators; so reusing
them to generate the Antlr grammar might be a little bit too hard
maybe?

What do you think? Maybe starting with XText might be easier & cleaner
and let us plugin various languages from Scalate more easily?

--
James
-------
FuseSource
Email: ja...@fusesource.com
Web: http://fusesource.com
Twitter: jstrachan, fusenews
Blog: http://macstrac.blogspot.com/

Open Source Integration and Messaging

James Strachan

unread,
Sep 13, 2011, 5:10:41 AM9/13/11
to sca...@googlegroups.com

I did wonder how easy it'd be to support whitespace sensitive
languages in Xtext (Jade/Scaml) - turns out there's a sample one
available...
http://code.google.com/a/eclipselabs.org/p/todotext/

The source is here...
https://github.com/ralfebert/org.eclipselabs.todotext/tree/master/plugins/org.eclipselabs.todotext/src/org/eclipselabs/todotext

Here's how it deals with indent/dedent tokens...
https://github.com/ralfebert/org.eclipselabs.todotext/blob/master/plugins/org.eclipselabs.todotext/src/org/eclipselabs/todotext/parser/IndentTokenSource.java

So it might not be that hard to do. The parser for SSP should be much
more trivial though.

Though not sure how easy it is going to be to get full Scala
expression support; though the use of Xbase suggests it might be
possible to at least get Java-ish expressions out of the box maybe.
http://www.eclipse.org/Xtext/#xbase

Stefan De Boey

unread,
Sep 14, 2011, 7:44:36 AM9/14/11
to sca...@googlegroups.com
hi,

Thanks for the response. at first glance XText looks like a good option. i'm going to try it out soon.

i'll also have to experiment a bit and try the different approaches you proposed. we have a lot of options and i'm not quite sure which route to take yet :)

if we don't use XText, then luckily we have a lot of examples, as you said there are editors for Velocity, JSP, HAML, CoffeeScript, ...

initially my main focus will be on Ssp and Jade with CoffeeScript, because that's what we're using at the moment.
the editors should support: 
    - syntax coloring for templates and (hopefully) scala code
    - integration with the ouline view
    - error/problem markers
    - content assist
the build can be maven-based (with tycho) and the plug-ins can be written in Scala. like the Scala IDE project.
i'll give you an update soon.

Dwayne Ghant

unread,
Sep 9, 2012, 8:58:19 PM9/9/12
to sca...@googlegroups.com
Hi Stefan,

I was wondering how far did you get with this.  I many not be as experienced with you in authoring eclipse plugins, but I'm willing to help.  Would you like me to jump in?

Stefan De Boey

unread,
Sep 10, 2012, 6:53:34 PM9/10/12
to sca...@googlegroups.com
hi Dwayne,

it's been a while so i can't remember completely how far i got on this. I've had a look at my commits and i think i have implemented syntax coloring for SSP and some basic preferences.

if you want we can have a look and see if we can take this further. it would we great if you can help out.

i'll try it out in the coming week and write a page on the wiki to get started with development.

FYI, the build is Maven-based and the code is mostly Scala. you can find the source code here: https://github.com/sdb/escalate

hope to hear from you soon.

greets,
stefan

Rafał Krzewski

unread,
Sep 11, 2012, 4:55:00 AM9/11/12
to sca...@googlegroups.com
Escalate! That's a nice name :) What route did you take with parsing? 

Cheers,
Rafał

Dwayne Ghant

unread,
Sep 11, 2012, 11:52:18 PM9/11/12
to sca...@googlegroups.com
Hey Sefan,

Great,  Not sure exactly how you would like to proceed. I got a clone of the repo (git). I'm taking look at you code now and trying to grasp the architecture you had in mind.  I don't want to implement something ahead of you!  I will need a little more guidance here.  I see that you coded this in Scala.  It will take some adjustment for me to program in a syntax that I'm used to reading so much about.  But I'm confident that I will make it through as I do with every other language I use (lol). 

Thanks

Stefan De Boey

unread,
Sep 12, 2012, 8:27:24 AM9/12/12
to sca...@googlegroups.com
i'm trying to setup the project again on my machine, but i need to make some changes because some of the update sites required for the project don't exist anymore. as soon as i got this working again, i will add the information to the project's wiki. normally it should be very easy to setup the project in eclipse. i will give you an update this evening.

for communication we can use the #scalate room, or u can add me to gmail chat.

Dwayne Ghant

unread,
Sep 12, 2012, 8:48:26 AM9/12/12
to sca...@googlegroups.com
Agreed,

This link should help with sites that change url's:


OR


Maybe the code below should be considered for ALL builds:

------------------------------------------------ 
<!-- mirror all repositories to central except for EclipseLink repository -->
<mirror>
<id>maven-central</id>
<mirrorOf>*,!eclipselink.repository</mirrorOf>
</mirror>
------------------------------------------------

Sure we can chat... which is more convenient for you?

Stefan De Boey

unread,
Sep 23, 2012, 8:54:44 AM9/23/12
to sca...@googlegroups.com
Hi Rafał,

i wrote my own using the basic support in Eclipse. I didn't go the XText way.

Greets,
Stefan

Rafał Krzewski

unread,
Sep 23, 2012, 12:38:27 PM9/23/12
to sca...@googlegroups.com
Interesting, I thought XText provided a ton of nifty features out of the box. 
I would like to help with Eclipse tooling for Scalate eventually, but I don't know when I'll be able to do that.
Right now, I'm trying to get Scala 2.10 support working, and my next objective will be improving OSGi support - I find it very interesting and I have some experience here, much more that in Eclipse plugin programming anyway :)

Cheers,
Rafał
Reply all
Reply to author
Forward
0 new messages