ICompletionEngine: IAssistParser and ISourceModule [message #31659] |
Fri, 26 September 2008 11:43  |
Eclipse User |
|
|
|
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 08:45  |
Eclipse User |
|
|
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03715 seconds