An IDE plugin for a custom DSL?

36 views
Skip to first unread message

Clint Gilbert

unread,
Nov 9, 2016, 5:57:37 PM11/9/16
to Scala IDE User
Hi everyone,

First, thanks for the ScalaIDE! It works pretty well these days.

Now, at my workplace, we have a custom 'external' DSL that's pure Scala,
with some methods implicitly imported. Users write files like:

some-file.foo:

"""
foo(42)

val bar = bar()

bar.blarg(foo)
"""

Our app embeds the Scala compiler, and feeds it the above DSL source
transformed by adding a very simple header and footer:

"""
object someFileWithMaybeAMangledName {
import FooPredef._ //foo, bar are defined in FooPredef

foo(42)

val bar = bar()

bar.blarg(foo)
}
"""

Or something like that; the basic idea is to wrap the DSL source in an
object and bring some methods into scope.

Now, my question: how feasible would it be to write a plugin for
ScalaIDE (or whatever other approach) that would let users edit files
like 'some-file.foo' above and get nice IDE features, like highlighting,
completion and red squiggles?

--



signature.asc

Simon Schäfer

unread,
Nov 10, 2016, 12:37:26 PM11/10/16
to scala-ide-user
Generally this is possible but it is not super easy to implement because we don't provide an API that can support this use case as an out of the box experience. A basic editor with syntax and error highlighting shouldn't be very difficult to implement but more powerful features like semantic highlighting are much more of a hassle.

You can have a look at the implementation of our yet unmerged work on a sbt editor: https://github.com/scala-ide/scala-ide/tree/sbt-integration/org.scala-ide.sbt.core/src/org/scalaide/sbt/ui/internal/editor

With a few modifications to this code you should be able to get basic syntax and error highlighting + code completion up and running.


---- On Wed, 09 Nov 2016 23:57:34 +0100Clint Gilbert <cgil...@broadinstitute.org> wrote ----

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clint Gilbert

unread,
Nov 10, 2016, 3:56:24 PM11/10/16
to scala-i...@googlegroups.com
Thanks Simon! I'll look into the SBT editor.

PS: An in-IDE editor for .sbt files would be *really* nice to have!

On 11/10/2016 12:37 PM, Simon Schäfer wrote:
> Generally this is possible but it is not super easy to implement because
> we don't provide an API that can support this use case as an out of the
> box experience. A basic editor with syntax and error highlighting
> shouldn't be very difficult to implement but more powerful features like
> semantic highlighting are much more of a hassle.
>
> You can have a look at the implementation of our yet unmerged work on a
> sbt editor:
> https://github.com/scala-ide/scala-ide/tree/sbt-integration/org.scala-ide.sbt.core/src/org/scalaide/sbt/ui/internal/editor
>
> With a few modifications to this code you should be able to get basic
> syntax and error highlighting + code completion up and running.
>
>
> ---- On Wed, 09 Nov 2016 23:57:34 +0100*Clint Gilbert
> <cgil...@broadinstitute.org>* wrote ----
> <mailto:scala-ide-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scala-ide-user/cc5116a2-bbd9-4ff6-001e-35058771b63b%40broadinstitute.org.
>
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Scala IDE User" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scala-ide-use...@googlegroups.com
> <mailto:scala-ide-use...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scala-ide-user/1584f50c483.f366d089280111.5520717357164439199%40antoras.de
> <https://groups.google.com/d/msgid/scala-ide-user/1584f50c483.f366d089280111.5520717357164439199%40antoras.de?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--



signature.asc

iulian dragos

unread,
Nov 11, 2016, 9:43:43 AM11/11/16
to scala-i...@googlegroups.com
You could have a look at my ScalaDays talk where I describe the Sbt
editor work. It starts around min. 19:

https://www.youtube.com/watch?v=yDOlBaSpXto

iulian
> To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/5131521d-e18b-35af-39b5-37ef667b74c3%40broadinstitute.org.
> For more options, visit https://groups.google.com/d/optout.



--
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais
Reply all
Reply to author
Forward
0 new messages