- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Help needed - Code completion
Fri, 2011-10-21, 14:49
Hi
I am working on writing an IDE for Scala and need some help. I would
like to implement coding assistance so that I could present a list of
options when a user presses a period (".") or a space (" "). e.g. if
projects is a List, as soon as user types "projects." or "projects ",
I would like to show all methods of scala.List that he could use
(regular IDE stuff). I know that scala.tools.nsc.interactive package
provides this capability, but I am unable to figure out how to do it.
Besides, it seems that the interactive package would use REPL and
would be slow for this purpose. Is that a fair assumption, and if yes,
are there any alternatives?
Also, is there a way I could get a call reference tree for a literal/
method (where all is the method referred to in a code base) ?
Thanks and Best regards
Aishwarya
Fri, 2011-10-21, 19:27
#2
Re: Help needed - Code completion
Hi Iulian
Thanks for the reply and pointers!
> I'll also ask the obvious question: why don't you contribute to one of
> the existing IDEs for Scala?
Sure, but my intent is to have something that's really light and non-
intrusive. Most of the existing ones I have come across are existing
IDEs for Java that are now offering Scala support. Nothing wrong with
it, but it just means that the IDE does a lot more than you would need
for scala coding. I am just avoiding building on top of something
that's already heavy. I could be totally mistaken and I may realise so
down the line, but I do want to give it a try :-)
It is hosted on github at https://github.com/asinghal/SlateIDE if you
are interested in taking a look!
Best regards
Aishwarya
On Oct 21, 7:53 pm, iulian dragos wrote:
> On Fri, Oct 21, 2011 at 3:49 PM, Aishwarya Singhal wrote:
> > Hi
>
> > I am working on writing an IDE for Scala and need some help. I would
> > like to implement coding assistance so that I could present a list of
> > options when a user presses a period (".") or a space (" "). e.g. if
> > projects is a List, as soon as user types "projects." or "projects ",
> > I would like to show all methods of scala.List that he could use
> > (regular IDE stuff). I know that scala.tools.nsc.interactive package
> > provides this capability, but I am unable to figure out how to do it.
>
> Have a look at CompilerControl, and at the tests in Scala trunk to get
> an idea how to invoke those methods. They are in
> test/files/presentation.
>
> You can also have a look at the Eclipse IDE code, netbeans and ensime.
> They all use the presentation compiler. It should be fairly easy to
> find the source code yourself.
>
> > Besides, it seems that the interactive package would use REPL and
> > would be slow for this purpose. Is that a fair assumption, and if yes,
> > are there any alternatives?
>
> I don't think the REPL uses the presentation compiler.
>
>
>
> > Also, is there a way I could get a call reference tree for a literal/
> > method (where all is the method referred to in a code base) ?
>
> I assume you mean 'find references'. Such functionality needs to be
> coded by you. You can use lower-level services from the presentation
> compiler to implement it (such as retrieving a parsed-and-typed AST
> for a given source file). Given that type checking is time-consuming,
> you should maintain an index per workspace (or project), and use it to
> restrict the amount of type checking you need to do for a given search
> term. For instance, if you look for all method references to 'foo',
> use the index to find the set of files that mention 'foo', and then
> typecheck only those (for locating the exact position of the
> reference).
>
> I'll also ask the obvious question: why don't you contribute to one of
> the existing IDEs for Scala?
>
> cheers,
> iulian
>
>
>
> > Thanks and Best regards
> > Aishwarya
>
> --
> « Je déteste la montagne, ça cache le paysage »
> Alphonse Allais
Sat, 2011-10-22, 05:27
#3
Re: Re: Help needed - Code completion
On Friday 21 October 2011, Aishwarya Singhal wrote:
> Hi Iulian
>
> Thanks for the reply and pointers!
>
> > I'll also ask the obvious question: why don't you contribute to one
> > of the existing IDEs for Scala?
>
> Sure, but my intent is to have something that's really light and non-
> intrusive.
"... light and unintrusive ..."
What does that mean? How can starting from zero make it more likely to
achieve this nebulous goal?
It's fine if you just want to hack away at a pet project, but if your
goal is to create a useful artifact, you are virtually guaranteed never
to catch up to existing IDEs with Scala support.
So, which is it? Something to indulge your desire to code or something
to help the rest of use write Scala more effectively?
> Most of the existing ones I have come across are existing
> IDEs for Java that are now offering Scala support.
Scala is built upon Java. It's eminently sensible that programming tools
for it do the same.
> Nothing wrong with it, but it just means that the IDE does a lot more
> than you would need for scala coding.
Such as?
> I am just avoiding building on top of something that's already heavy.
Software does not have weight or mass. What are you really avoiding?
> I could be totally mistaken and I may realise so down the line, but I
> do want to give it a try :-)
Why? There are good reasons and not-so-good ones. What are yours?
> ...
>
> Best regards
> Aishwarya
>
> ...
Randall Schulz
On Fri, Oct 21, 2011 at 3:49 PM, Aishwarya Singhal wrote:
> Hi
>
> I am working on writing an IDE for Scala and need some help. I would
> like to implement coding assistance so that I could present a list of
> options when a user presses a period (".") or a space (" "). e.g. if
> projects is a List, as soon as user types "projects." or "projects ",
> I would like to show all methods of scala.List that he could use
> (regular IDE stuff). I know that scala.tools.nsc.interactive package
> provides this capability, but I am unable to figure out how to do it.
Have a look at CompilerControl, and at the tests in Scala trunk to get
an idea how to invoke those methods. They are in
test/files/presentation.
You can also have a look at the Eclipse IDE code, netbeans and ensime.
They all use the presentation compiler. It should be fairly easy to
find the source code yourself.
> Besides, it seems that the interactive package would use REPL and
> would be slow for this purpose. Is that a fair assumption, and if yes,
> are there any alternatives?
I don't think the REPL uses the presentation compiler.
>
> Also, is there a way I could get a call reference tree for a literal/
> method (where all is the method referred to in a code base) ?
I assume you mean 'find references'. Such functionality needs to be
coded by you. You can use lower-level services from the presentation
compiler to implement it (such as retrieving a parsed-and-typed AST
for a given source file). Given that type checking is time-consuming,
you should maintain an index per workspace (or project), and use it to
restrict the amount of type checking you need to do for a given search
term. For instance, if you look for all method references to 'foo',
use the index to find the set of files that mention 'foo', and then
typecheck only those (for locating the exact position of the
reference).
I'll also ask the obvious question: why don't you contribute to one of
the existing IDEs for Scala?
cheers,
iulian
>
> Thanks and Best regards
> Aishwarya
>