This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Hints for a "code fragment" eclipse editor

3 replies
Sciss
Joined: 2008-12-17,
User offline. Last seen 28 weeks 5 days ago.

hi,

this question goes primarily to the eclipse plugin developers, i guess.

i am developing an environment in eclipse that includes a scala
interpreter. i would like to be able to create in my project special
"code fragment" files.

those files should be text documents that go in the normal eclipse
text editor, but they should be exempt from automatic-building etc.,
because they are not supposed to contain a "contiguous" scala code;
instead you use it as a scratch board, to be able to type some (multi-
line) scala code and then execute parts of it, by selecting and
hitting a defined command key.

so i guess, i basically want syntax-highlighting, indentation,
shortcuts like commenting out lines etc., maybe code completion if
possible, maybe an outline as far as possible. the point is that each
of those features needs to fail gracefully if the code currently is
errorneous or incomplete or the different fragments don't go together.

so my question is: i would like to re-use as much as possible from
the code editor of the eclipse scala plug-in (i'm with the SVN
version at the moment). where can i find a documentation or hints as
how to decompose those parts and create a custom more-lightweight
editor that is not directly connected to the scala project build-system.

and maybe you have some hints as how to allow code fragments to
friendly cooexist in that file... i'm think of some kind of hidden
text that could separate "paragraphs". also i would love to include
hidden default text at the beginning of the document, like "import
de.sciss.tint.sc._; import de.sciss.tint.Predef._"; --- so that code
completion could find the standard classes of my project without the
user having to include explicit import statements in each code
fragment file. (besides leaving out the necessity to highlight them
when invoking the interpreter for the first time).

i also find that the Scala -> Create Scala Interpreter of the eclipse
plug-in still doesn't work (Mac OS X 10.4 / Eclipse 3.4) but hangs
(and then throws after a while an OutOfMemoryError) when you try to
execute code.

thanks a lot! cheers, -sciss-

Sciss
Joined: 2008-12-17,
User offline. Last seen 28 weeks 5 days ago.
Re: Hints for a "code fragment" eclipse editor

you could also call this thing "scrapbook" which seems to exist for
the java plug in (File -> New -> Other -> Java -> Java Run/Debug ->
Scrapbook Page). that has a neat execute selection button, some
features (such as auto completion), but lacks others (such as syntax
highlighting)...

so maybe a solution would be to have a ScalaSnippetEditor (that
extends somewhat the JavaSnippetEditor)... there are some problems to
solve, e.g. i would need to run the snippets on the current VM not a
separate one, as i would like to be able to programmatically access
the current eclipse project.

ciao, -sciss-

Am 26.02.2009 um 14:49 schrieb Sciss:

> hi,
>
> this question goes primarily to the eclipse plugin developers, i
> guess.
>
> i am developing an environment in eclipse that includes a scala
> interpreter. i would like to be able to create in my project
> special "code fragment" files.
>
> those files should be text documents that go in the normal eclipse
> text editor, but they should be exempt from automatic-building
> etc., because they are not supposed to contain a "contiguous" scala
> code; instead you use it as a scratch board, to be able to type
> some (multi-line) scala code and then execute parts of it, by
> selecting and hitting a defined command key.
>
> so i guess, i basically want syntax-highlighting, indentation,
> shortcuts like commenting out lines etc., maybe code completion if
> possible, maybe an outline as far as possible. the point is that
> each of those features needs to fail gracefully if the code
> currently is errorneous or incomplete or the different fragments
> don't go together.
>
> so my question is: i would like to re-use as much as possible from
> the code editor of the eclipse scala plug-in (i'm with the SVN
> version at the moment). where can i find a documentation or hints
> as how to decompose those parts and create a custom more-
> lightweight editor that is not directly connected to the scala
> project build-system.
>
> and maybe you have some hints as how to allow code fragments to
> friendly cooexist in that file... i'm think of some kind of hidden
> text that could separate "paragraphs". also i would love to include
> hidden default text at the beginning of the document, like "import
> de.sciss.tint.sc._; import de.sciss.tint.Predef._"; --- so that
> code completion could find the standard classes of my project
> without the user having to include explicit import statements in
> each code fragment file. (besides leaving out the necessity to
> highlight them when invoking the interpreter for the first time).
>
> i also find that the Scala -> Create Scala Interpreter of the
> eclipse plug-in still doesn't work (Mac OS X 10.4 / Eclipse 3.4)
> but hangs (and then throws after a while an OutOfMemoryError) when
> you try to execute code.
>
>
> thanks a lot! cheers, -sciss-
>

milessabin
Joined: 2008-08-11,
User offline. Last seen 33 weeks 3 days ago.
Re: Hints for a "code fragment" eclipse editor

On Thu, Feb 26, 2009 at 2:53 PM, Sciss wrote:
> you could also call this thing "scrapbook" which seems to exist for the java
> plug in (File -> New -> Other -> Java -> Java Run/Debug -> Scrapbook Page).
> that has a neat execute selection button, some features (such as auto
> completion), but lacks others (such as syntax highlighting)...
>
> so maybe a solution would be to have a ScalaSnippetEditor (that extends
> somewhat the JavaSnippetEditor)... there are some problems to solve, e.g. i
> would need to run the snippets on the current VM not a separate one, as i
> would like to be able to programmatically access the current eclipse
> project.

Yes, something along these lines would be wonderful ... it'd be great
if you had the time to work on it.

Cheers,

Miles

Sciss
Joined: 2008-12-17,
User offline. Last seen 28 weeks 5 days ago.
Re: Hints for a "code fragment" eclipse editor

i will do my best... however i will definitely need help from you
guys as this whole eclipse monster is still a little bit too big for
me. i'm very slowly getting through the whole class tree structure
(of eclipse, but then at some point also lampion and scala).

i'll let you know when i have something useful...

ciao, -sciss-

Am 26.02.2009 um 17:18 schrieb Miles Sabin:

> On Thu, Feb 26, 2009 at 2:53 PM, Sciss wrote:
>> you could also call this thing "scrapbook" which seems to exist
>> for the java
>> plug in (File -> New -> Other -> Java -> Java Run/Debug ->
>> Scrapbook Page).
>> that has a neat execute selection button, some features (such as auto
>> completion), but lacks others (such as syntax highlighting)...
>>
>> so maybe a solution would be to have a ScalaSnippetEditor (that
>> extends
>> somewhat the JavaSnippetEditor)... there are some problems to
>> solve, e.g. i
>> would need to run the snippets on the current VM not a separate
>> one, as i
>> would like to be able to programmatically access the current eclipse
>> project.
>
> Yes, something along these lines would be wonderful ... it'd be great
> if you had the time to work on it.
>
> Cheers,
>
>
> Miles
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland