Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » ICompletionEngine: IAssistParser and ISourceModule
ICompletionEngine: IAssistParser and ISourceModule [message #31659] Fri, 26 September 2008 15:43 Go to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I am trying to write my own implementation of ScriptCompletionEngine.
It has a method getParser which returns an instance of the interface
IAssistParser.
Can you explain the methods of this interface?
There is little or no JavaDoc for it - and the one other reference to this
interface that I see is in:

org.eclipse.dltk.internal.codeassist.impl.Engine:

// TODO: remove this!!!
public abstract IAssistParser getParser();

I believe there is a need to try to parse the code around where you are
requesting completion - either with a normal parser or with some sort of
heuristics or piece-meal token matching.

One thing I needed was the ability to get the existing parse tree for the
module. The only way I could do that was to look at your source code and
determine that SourceModule extends AbstractSourceModule which implements
both ISourceModule interfaces:

public abstract class AbstractSourceModule extends Openable implements
ISourceModule, org.eclipse.dltk.compiler.env.ISourceModule {

Please note that the interface ICompletionEngine has this method:

void complete(ISourceModule module, int position, int i);

where ISourceModule is this:

import org.eclipse.dltk.compiler.env.ISourceModule;

I had to cast the instance of org.eclipse.dltk.compiler.env.ISourceModule to
SourceModule so I could cast it to org.eclipse.dltk.core.ISourceModule and
thus I could obtain the AST tree.

Chuck
Re: ICompletionEngine: IAssistParser and ISourceModule [message #31697 is a reply to message #31659] Sun, 28 September 2008 12:45 Go to previous message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Hi,

The difference between org.eclipse.dltk.core.ISourceModule and
org.eclipse.dltk.compiler.env.ISourceModule is:
- org.eclipse.dltk.core.ISourceModule is something that is a part of the
project
- org.eclipse.dltk.compiler.env.ISourceModule is something that could be
parsed

AbstractSourceModule implements both interfaces, since it is part of the
project and could be parsed too.

Completion code accepts org.eclipse.dltk.compiler.env.ISourceModule
since theoretically you can call code assist not only from the project
files but also from the e.g. breakpoint properties to enter condition
(it does not work in DLTK now, but JDT has this feature).

getParser() method is not used externally it is there to be used
internally by engines and looking at the comments - that code needs some
refactoring. If you don't need the getParser() method - just return null.

Regards,
Alex


Chuck Doucette wrote:
> I am trying to write my own implementation of ScriptCompletionEngine.
> It has a method getParser which returns an instance of the interface
> IAssistParser.
> Can you explain the methods of this interface?
> There is little or no JavaDoc for it - and the one other reference to this
> interface that I see is in:
>
> org.eclipse.dltk.internal.codeassist.impl.Engine:
>
> // TODO: remove this!!!
> public abstract IAssistParser getParser();
>
> I believe there is a need to try to parse the code around where you are
> requesting completion - either with a normal parser or with some sort of
> heuristics or piece-meal token matching.
>
> One thing I needed was the ability to get the existing parse tree for the
> module. The only way I could do that was to look at your source code and
> determine that SourceModule extends AbstractSourceModule which implements
> both ISourceModule interfaces:
>
> public abstract class AbstractSourceModule extends Openable implements
> ISourceModule, org.eclipse.dltk.compiler.env.ISourceModule {
>
> Please note that the interface ICompletionEngine has this method:
>
> void complete(ISourceModule module, int position, int i);
>
> where ISourceModule is this:
>
> import org.eclipse.dltk.compiler.env.ISourceModule;
>
> I had to cast the instance of org.eclipse.dltk.compiler.env.ISourceModule to
> SourceModule so I could cast it to org.eclipse.dltk.core.ISourceModule and
> thus I could obtain the AST tree.
>
> Chuck
>
>
Previous Topic:[BUILD] R1.0-I
Next Topic:Integrating TCL with Eclipse.
Goto Forum:
  


Current Time: Thu Apr 25 08:32:46 GMT 2024

Powered by FUDForum. Page generated in 0.30663 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top