Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » completion proposals - not matched to prefix?
completion proposals - not matched to prefix? [message #22530] Wed, 30 April 2008 23:41 Go to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I have developed a prototype editor for our scripting language based on your
tutorial:

http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE

We now would like to figure out how to turn the prototype into a real
editor.

The first thing that was obvious was that it was proposing every keyword in
the language as a possible completion without regard for:
a) whether or not it starts with the same prefix
b) whether it fits into the syntax at that point

Doing b may be difficult - but a should be quite easy.
I did run my prototype editor in the debugger and found that it accepted or
rejected possible templates based on whether the name of the template
started with the same prefix as what the user had typed. This did not seem
to be the case for adding keywords.

How can I get at least the prefix to constrain possible completions?

Also, is there any documentation or even Java doc for DLTK?

Thanks,
Chuck
Re: completion proposals - not matched to prefix? [message #22708 is a reply to message #22530] Fri, 02 May 2008 21:07 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I'm still stuck on this problem, and I would appreciate some input.

The issue is specifically with ICompletionEngine, and the method:
void complete(ISourceModule module, int position, int pos)

I found where it is called from Openable.codeComplete:

engine.complete(cu, position, 0);

I can use ISourceModule, and call this method:
String getSourceContents();

From, that, I assume I can use position to determine where someone is trying
to perform completion.

What I don't know is how to determine what if anything they have typed
before attempting to do completion (which I assume they haven't saved yet).

I know this is prefix is available for evaluating matching template names.

I don't remember where that source is.

Thanks,

Chuck

"Chuck Doucette" <cdoucette@vaultus.com> wrote in message
news:fvb05h$jgb$1@build.eclipse.org...
>I have developed a prototype editor for our scripting language based on
>your tutorial:
>
> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>
> We now would like to figure out how to turn the prototype into a real
> editor.
>
> The first thing that was obvious was that it was proposing every keyword
> in the language as a possible completion without regard for:
> a) whether or not it starts with the same prefix
> b) whether it fits into the syntax at that point
>
> Doing b may be difficult - but a should be quite easy.
> I did run my prototype editor in the debugger and found that it accepted
> or rejected possible templates based on whether the name of the template
> started with the same prefix as what the user had typed. This did not seem
> to be the case for adding keywords.
>
> How can I get at least the prefix to constrain possible completions?
>
> Also, is there any documentation or even Java doc for DLTK?
>
> Thanks,
> Chuck
>
>
Re: completion proposals - not matched to prefix? [message #22752 is a reply to message #22708] Sun, 04 May 2008 12:23 Go to previous messageGo to next message
Andrei Sobolev is currently offline Andrei SobolevFriend
Messages: 72
Registered: July 2009
Member
Hi Chuck,

Tutorial we provided contain only basic information about some DLTK parts.

For more complex implementation please refer to our language implementations( Tcl, Ruby ).
> I'm still stuck on this problem, and I would appreciate some input.
>
> The issue is specifically with ICompletionEngine, and the method:
> void complete(ISourceModule module, int position, int pos)
>
> I found where it is called from Openable.codeComplete:
>
> engine.complete(cu, position, 0);
>
> I can use ISourceModule, and call this method:
> String getSourceContents();
>
> From, that, I assume I can use position to determine where someone is trying
> to perform completion.
>
> What I don't know is how to determine what if anything they have typed
> before attempting to do completion (which I assume they haven't saved yet).

SourceModules use special structure named Buffer.
All changes from user are be in this buffer.
So then you call getSourceContents() and if buffer exists content from buffer will be returned.

Best regards,
Andrei Sobolev.

>
> I know this is prefix is available for evaluating matching template names.
>
> I don't remember where that source is.
>
> Thanks,
>
> Chuck
>
> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
> news:fvb05h$jgb$1@build.eclipse.org...
>> I have developed a prototype editor for our scripting language based on
>> your tutorial:
>>
>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>
>> We now would like to figure out how to turn the prototype into a real
>> editor.
>>
>> The first thing that was obvious was that it was proposing every keyword
>> in the language as a possible completion without regard for:
>> a) whether or not it starts with the same prefix
>> b) whether it fits into the syntax at that point
>>
>> Doing b may be difficult - but a should be quite easy.
>> I did run my prototype editor in the debugger and found that it accepted
>> or rejected possible templates based on whether the name of the template
>> started with the same prefix as what the user had typed. This did not seem
>> to be the case for adding keywords.
>>
>> How can I get at least the prefix to constrain possible completions?
>>
>> Also, is there any documentation or even Java doc for DLTK?
>>
>> Thanks,
>> Chuck
>>
>>
>
>
Re: completion proposals - not matched to prefix? [message #22880 is a reply to message #22752] Sun, 04 May 2008 15:51 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I already said that apparently I could call ISourceModule.getSourceContents.

I assume that method will return the original contents of the buffer.
I want to get the current contents, and specifically what was just typed
before invoking completion.
Is that possible to obtain? If so, how?

I found the template code that I was referring to in the class
ScriptTemplateCompletionProcessor:
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
int offset) {

It calls this:

String prefix = extractPrefix(viewer, offset);

That method is defined here:
package org.eclipse.jface.text.templates;

class TemplateCompletionProcessor

as follows:

/**

* Heuristically extracts the prefix used for determining template relevance

* from the viewer's document. The default implementation returns the String
from

* offset backwards that forms a java identifier.

*

* @param viewer the viewer

* @param offset offset into document

* @return the prefix to consider

* @see #getRelevance(Template, String)

*/

protected String extractPrefix(ITextViewer viewer, int offset) {

This would give me exactly what I (and probably many others) are looking
for.

It makes no sense to return possible completions (template or otherwise)
that don't match the prefix.

For now, I guess I will attempt to emulate this code in my classes - but
ideally it would be functionality offerred by DLTK.

I will look at some of your complete implementations, like JavaScript,
rather than the tutorial example for Python.

Thanks,

Chuck

"Andrei Sobolev" <haiodo@xored.com> wrote in message
news:fvk9sd$8td$1@build.eclipse.org...
> Hi Chuck,
>
> Tutorial we provided contain only basic information about some DLTK parts.
>
> For more complex implementation please refer to our language
> implementations( Tcl, Ruby ).
>> I'm still stuck on this problem, and I would appreciate some input.
>>
>> The issue is specifically with ICompletionEngine, and the method:
>> void complete(ISourceModule module, int position, int pos)
>>
>> I found where it is called from Openable.codeComplete:
>>
>> engine.complete(cu, position, 0);
>>
>> I can use ISourceModule, and call this method:
>> String getSourceContents();
>>
>> From, that, I assume I can use position to determine where someone is
>> trying
>> to perform completion.
>>
>> What I don't know is how to determine what if anything they have typed
>> before attempting to do completion (which I assume they haven't saved
>> yet).
>
> SourceModules use special structure named Buffer.
> All changes from user are be in this buffer.
> So then you call getSourceContents() and if buffer exists content from
> buffer will be returned.
>
> Best regards,
> Andrei Sobolev.
>
>>
>> I know this is prefix is available for evaluating matching template
>> names.
>>
>> I don't remember where that source is.
>>
>> Thanks,
>>
>> Chuck
>>
>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>> news:fvb05h$jgb$1@build.eclipse.org...
>>> I have developed a prototype editor for our scripting language based on
>>> your tutorial:
>>>
>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>
>>> We now would like to figure out how to turn the prototype into a real
>>> editor.
>>>
>>> The first thing that was obvious was that it was proposing every keyword
>>> in the language as a possible completion without regard for:
>>> a) whether or not it starts with the same prefix
>>> b) whether it fits into the syntax at that point
>>>
>>> Doing b may be difficult - but a should be quite easy.
>>> I did run my prototype editor in the debugger and found that it accepted
>>> or rejected possible templates based on whether the name of the template
>>> started with the same prefix as what the user had typed. This did not
>>> seem
>>> to be the case for adding keywords.
>>>
>>> How can I get at least the prefix to constrain possible completions?
>>>
>>> Also, is there any documentation or even Java doc for DLTK?
>>>
>>> Thanks,
>>> Chuck
>>>
>>>
>>
>>
Re: completion proposals - not matched to prefix? [message #22968 is a reply to message #22880] Mon, 05 May 2008 19:07 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
It appears that perhaps my class should extend the class
ScriptCompletionEngine
rather than implement the interface ICompletionEngine (as was done in the
tutorial).

The problem is that there are 4 methods that need to be defined, and there
is no documentation that I can find on how to define them:
@Override

protected String processFieldName(IField field, String token) {

// TODO Auto-generated method stub

return null;

}


@Override

protected String processMethodName(IMethod method, String token) {

// TODO Auto-generated method stub

return null;

}


@Override

protected String processTypeName(IType method, String token) {

// TODO Auto-generated method stub

return null;

}


@Override

public IAssistParser getParser() {

// TODO Auto-generated method stub

return null;

}

Also, IAssistParser is not documented either.

Thanks,
Chuck

"Chuck Doucette" <cdoucette@vaultus.com> wrote in message
news:fvkm4a$ia3$1@build.eclipse.org...
>I already said that apparently I could call
>ISourceModule.getSourceContents.
>
> I assume that method will return the original contents of the buffer.
> I want to get the current contents, and specifically what was just typed
> before invoking completion.
> Is that possible to obtain? If so, how?
>
> I found the template code that I was referring to in the class
> ScriptTemplateCompletionProcessor:
> public ICompletionProposal[] computeCompletionProposals(ITextViewer
> viewer, int offset) {
>
> It calls this:
>
> String prefix = extractPrefix(viewer, offset);
>
> That method is defined here:
> package org.eclipse.jface.text.templates;
>
> class TemplateCompletionProcessor
>
> as follows:
>
> /**
>
> * Heuristically extracts the prefix used for determining template
> relevance
>
> * from the viewer's document. The default implementation returns the
> String from
>
> * offset backwards that forms a java identifier.
>
> *
>
> * @param viewer the viewer
>
> * @param offset offset into document
>
> * @return the prefix to consider
>
> * @see #getRelevance(Template, String)
>
> */
>
> protected String extractPrefix(ITextViewer viewer, int offset) {
>
> This would give me exactly what I (and probably many others) are looking
> for.
>
> It makes no sense to return possible completions (template or otherwise)
> that don't match the prefix.
>
> For now, I guess I will attempt to emulate this code in my classes - but
> ideally it would be functionality offerred by DLTK.
>
> I will look at some of your complete implementations, like JavaScript,
> rather than the tutorial example for Python.
>
> Thanks,
>
> Chuck
>
> "Andrei Sobolev" <haiodo@xored.com> wrote in message
> news:fvk9sd$8td$1@build.eclipse.org...
>> Hi Chuck,
>>
>> Tutorial we provided contain only basic information about some DLTK
>> parts.
>>
>> For more complex implementation please refer to our language
>> implementations( Tcl, Ruby ).
>>> I'm still stuck on this problem, and I would appreciate some input.
>>>
>>> The issue is specifically with ICompletionEngine, and the method:
>>> void complete(ISourceModule module, int position, int pos)
>>>
>>> I found where it is called from Openable.codeComplete:
>>>
>>> engine.complete(cu, position, 0);
>>>
>>> I can use ISourceModule, and call this method:
>>> String getSourceContents();
>>>
>>> From, that, I assume I can use position to determine where someone is
>>> trying
>>> to perform completion.
>>>
>>> What I don't know is how to determine what if anything they have typed
>>> before attempting to do completion (which I assume they haven't saved
>>> yet).
>>
>> SourceModules use special structure named Buffer.
>> All changes from user are be in this buffer.
>> So then you call getSourceContents() and if buffer exists content from
>> buffer will be returned.
>>
>> Best regards,
>> Andrei Sobolev.
>>
>>>
>>> I know this is prefix is available for evaluating matching template
>>> names.
>>>
>>> I don't remember where that source is.
>>>
>>> Thanks,
>>>
>>> Chuck
>>>
>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>> news:fvb05h$jgb$1@build.eclipse.org...
>>>> I have developed a prototype editor for our scripting language based on
>>>> your tutorial:
>>>>
>>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>>
>>>> We now would like to figure out how to turn the prototype into a real
>>>> editor.
>>>>
>>>> The first thing that was obvious was that it was proposing every
>>>> keyword
>>>> in the language as a possible completion without regard for:
>>>> a) whether or not it starts with the same prefix
>>>> b) whether it fits into the syntax at that point
>>>>
>>>> Doing b may be difficult - but a should be quite easy.
>>>> I did run my prototype editor in the debugger and found that it
>>>> accepted
>>>> or rejected possible templates based on whether the name of the
>>>> template
>>>> started with the same prefix as what the user had typed. This did not
>>>> seem
>>>> to be the case for adding keywords.
>>>>
>>>> How can I get at least the prefix to constrain possible completions?
>>>>
>>>> Also, is there any documentation or even Java doc for DLTK?
>>>>
>>>> Thanks,
>>>> Chuck
>>>>
>>>>
>>>
>>>
>
>
Re: completion proposals - not matched to prefix? [message #23055 is a reply to message #22968] Mon, 05 May 2008 22:07 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I downloaded the latest Integration/Incubation build, with all of the
language toolkit bundles.

As far as I could tell, only JavaScript defines a completion engine, and
they do extend ScriptCompletionEngine rather than simply implement
ICompletionEngine.

I didn't see a completion engine defined in Ruby, Tcl, or Python.

Chuck

"Chuck Doucette" <cdoucette@vaultus.com> wrote in message
news:fvnlvq$qjb$1@build.eclipse.org...
> It appears that perhaps my class should extend the class
> ScriptCompletionEngine
> rather than implement the interface ICompletionEngine (as was done in the
> tutorial).
>
> The problem is that there are 4 methods that need to be defined, and there
> is no documentation that I can find on how to define them:
> @Override
>
> protected String processFieldName(IField field, String token) {
>
> // TODO Auto-generated method stub
>
> return null;
>
> }
>
>
> @Override
>
> protected String processMethodName(IMethod method, String token) {
>
> // TODO Auto-generated method stub
>
> return null;
>
> }
>
>
> @Override
>
> protected String processTypeName(IType method, String token) {
>
> // TODO Auto-generated method stub
>
> return null;
>
> }
>
>
> @Override
>
> public IAssistParser getParser() {
>
> // TODO Auto-generated method stub
>
> return null;
>
> }
>
> Also, IAssistParser is not documented either.
>
> Thanks,
> Chuck
>
> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
> news:fvkm4a$ia3$1@build.eclipse.org...
>>I already said that apparently I could call
>>ISourceModule.getSourceContents.
>>
>> I assume that method will return the original contents of the buffer.
>> I want to get the current contents, and specifically what was just typed
>> before invoking completion.
>> Is that possible to obtain? If so, how?
>>
>> I found the template code that I was referring to in the class
>> ScriptTemplateCompletionProcessor:
>> public ICompletionProposal[] computeCompletionProposals(ITextViewer
>> viewer, int offset) {
>>
>> It calls this:
>>
>> String prefix = extractPrefix(viewer, offset);
>>
>> That method is defined here:
>> package org.eclipse.jface.text.templates;
>>
>> class TemplateCompletionProcessor
>>
>> as follows:
>>
>> /**
>>
>> * Heuristically extracts the prefix used for determining template
>> relevance
>>
>> * from the viewer's document. The default implementation returns the
>> String from
>>
>> * offset backwards that forms a java identifier.
>>
>> *
>>
>> * @param viewer the viewer
>>
>> * @param offset offset into document
>>
>> * @return the prefix to consider
>>
>> * @see #getRelevance(Template, String)
>>
>> */
>>
>> protected String extractPrefix(ITextViewer viewer, int offset) {
>>
>> This would give me exactly what I (and probably many others) are looking
>> for.
>>
>> It makes no sense to return possible completions (template or otherwise)
>> that don't match the prefix.
>>
>> For now, I guess I will attempt to emulate this code in my classes - but
>> ideally it would be functionality offerred by DLTK.
>>
>> I will look at some of your complete implementations, like JavaScript,
>> rather than the tutorial example for Python.
>>
>> Thanks,
>>
>> Chuck
>>
>> "Andrei Sobolev" <haiodo@xored.com> wrote in message
>> news:fvk9sd$8td$1@build.eclipse.org...
>>> Hi Chuck,
>>>
>>> Tutorial we provided contain only basic information about some DLTK
>>> parts.
>>>
>>> For more complex implementation please refer to our language
>>> implementations( Tcl, Ruby ).
>>>> I'm still stuck on this problem, and I would appreciate some input.
>>>>
>>>> The issue is specifically with ICompletionEngine, and the method:
>>>> void complete(ISourceModule module, int position, int pos)
>>>>
>>>> I found where it is called from Openable.codeComplete:
>>>>
>>>> engine.complete(cu, position, 0);
>>>>
>>>> I can use ISourceModule, and call this method:
>>>> String getSourceContents();
>>>>
>>>> From, that, I assume I can use position to determine where someone is
>>>> trying
>>>> to perform completion.
>>>>
>>>> What I don't know is how to determine what if anything they have typed
>>>> before attempting to do completion (which I assume they haven't saved
>>>> yet).
>>>
>>> SourceModules use special structure named Buffer.
>>> All changes from user are be in this buffer.
>>> So then you call getSourceContents() and if buffer exists content from
>>> buffer will be returned.
>>>
>>> Best regards,
>>> Andrei Sobolev.
>>>
>>>>
>>>> I know this is prefix is available for evaluating matching template
>>>> names.
>>>>
>>>> I don't remember where that source is.
>>>>
>>>> Thanks,
>>>>
>>>> Chuck
>>>>
>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>> news:fvb05h$jgb$1@build.eclipse.org...
>>>>> I have developed a prototype editor for our scripting language based
>>>>> on
>>>>> your tutorial:
>>>>>
>>>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>>>
>>>>> We now would like to figure out how to turn the prototype into a real
>>>>> editor.
>>>>>
>>>>> The first thing that was obvious was that it was proposing every
>>>>> keyword
>>>>> in the language as a possible completion without regard for:
>>>>> a) whether or not it starts with the same prefix
>>>>> b) whether it fits into the syntax at that point
>>>>>
>>>>> Doing b may be difficult - but a should be quite easy.
>>>>> I did run my prototype editor in the debugger and found that it
>>>>> accepted
>>>>> or rejected possible templates based on whether the name of the
>>>>> template
>>>>> started with the same prefix as what the user had typed. This did not
>>>>> seem
>>>>> to be the case for adding keywords.
>>>>>
>>>>> How can I get at least the prefix to constrain possible completions?
>>>>>
>>>>> Also, is there any documentation or even Java doc for DLTK?
>>>>>
>>>>> Thanks,
>>>>> Chuck
>>>>>
>>>>>
>>>>
>>>>
>>
>>
>
>
Re: completion proposals - not matched to prefix? [message #23098 is a reply to message #23055] Mon, 05 May 2008 22:24 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I looked again and did find a completion engined defined for both Ruby and
Tcl.

Again they both extended ScriptCompletionEngine rather than implement
ICompletionEngine.

Chuck

"Chuck Doucette" <cdoucette@vaultus.com> wrote in message
news:fvo0ib$f50$1@build.eclipse.org...
>I downloaded the latest Integration/Incubation build, with all of the
>language toolkit bundles.
>
> As far as I could tell, only JavaScript defines a completion engine, and
> they do extend ScriptCompletionEngine rather than simply implement
> ICompletionEngine.
>
> I didn't see a completion engine defined in Ruby, Tcl, or Python.
>
> Chuck
>
> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
> news:fvnlvq$qjb$1@build.eclipse.org...
>> It appears that perhaps my class should extend the class
>> ScriptCompletionEngine
>> rather than implement the interface ICompletionEngine (as was done in the
>> tutorial).
>>
>> The problem is that there are 4 methods that need to be defined, and
>> there is no documentation that I can find on how to define them:
>> @Override
>>
>> protected String processFieldName(IField field, String token) {
>>
>> // TODO Auto-generated method stub
>>
>> return null;
>>
>> }
>>
>>
>> @Override
>>
>> protected String processMethodName(IMethod method, String token) {
>>
>> // TODO Auto-generated method stub
>>
>> return null;
>>
>> }
>>
>>
>> @Override
>>
>> protected String processTypeName(IType method, String token) {
>>
>> // TODO Auto-generated method stub
>>
>> return null;
>>
>> }
>>
>>
>> @Override
>>
>> public IAssistParser getParser() {
>>
>> // TODO Auto-generated method stub
>>
>> return null;
>>
>> }
>>
>> Also, IAssistParser is not documented either.
>>
>> Thanks,
>> Chuck
>>
>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>> news:fvkm4a$ia3$1@build.eclipse.org...
>>>I already said that apparently I could call
>>>ISourceModule.getSourceContents.
>>>
>>> I assume that method will return the original contents of the buffer.
>>> I want to get the current contents, and specifically what was just typed
>>> before invoking completion.
>>> Is that possible to obtain? If so, how?
>>>
>>> I found the template code that I was referring to in the class
>>> ScriptTemplateCompletionProcessor:
>>> public ICompletionProposal[] computeCompletionProposals(ITextViewer
>>> viewer, int offset) {
>>>
>>> It calls this:
>>>
>>> String prefix = extractPrefix(viewer, offset);
>>>
>>> That method is defined here:
>>> package org.eclipse.jface.text.templates;
>>>
>>> class TemplateCompletionProcessor
>>>
>>> as follows:
>>>
>>> /**
>>>
>>> * Heuristically extracts the prefix used for determining template
>>> relevance
>>>
>>> * from the viewer's document. The default implementation returns the
>>> String from
>>>
>>> * offset backwards that forms a java identifier.
>>>
>>> *
>>>
>>> * @param viewer the viewer
>>>
>>> * @param offset offset into document
>>>
>>> * @return the prefix to consider
>>>
>>> * @see #getRelevance(Template, String)
>>>
>>> */
>>>
>>> protected String extractPrefix(ITextViewer viewer, int offset) {
>>>
>>> This would give me exactly what I (and probably many others) are looking
>>> for.
>>>
>>> It makes no sense to return possible completions (template or otherwise)
>>> that don't match the prefix.
>>>
>>> For now, I guess I will attempt to emulate this code in my classes - but
>>> ideally it would be functionality offerred by DLTK.
>>>
>>> I will look at some of your complete implementations, like JavaScript,
>>> rather than the tutorial example for Python.
>>>
>>> Thanks,
>>>
>>> Chuck
>>>
>>> "Andrei Sobolev" <haiodo@xored.com> wrote in message
>>> news:fvk9sd$8td$1@build.eclipse.org...
>>>> Hi Chuck,
>>>>
>>>> Tutorial we provided contain only basic information about some DLTK
>>>> parts.
>>>>
>>>> For more complex implementation please refer to our language
>>>> implementations( Tcl, Ruby ).
>>>>> I'm still stuck on this problem, and I would appreciate some input.
>>>>>
>>>>> The issue is specifically with ICompletionEngine, and the method:
>>>>> void complete(ISourceModule module, int position, int pos)
>>>>>
>>>>> I found where it is called from Openable.codeComplete:
>>>>>
>>>>> engine.complete(cu, position, 0);
>>>>>
>>>>> I can use ISourceModule, and call this method:
>>>>> String getSourceContents();
>>>>>
>>>>> From, that, I assume I can use position to determine where someone is
>>>>> trying
>>>>> to perform completion.
>>>>>
>>>>> What I don't know is how to determine what if anything they have typed
>>>>> before attempting to do completion (which I assume they haven't saved
>>>>> yet).
>>>>
>>>> SourceModules use special structure named Buffer.
>>>> All changes from user are be in this buffer.
>>>> So then you call getSourceContents() and if buffer exists content from
>>>> buffer will be returned.
>>>>
>>>> Best regards,
>>>> Andrei Sobolev.
>>>>
>>>>>
>>>>> I know this is prefix is available for evaluating matching template
>>>>> names.
>>>>>
>>>>> I don't remember where that source is.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Chuck
>>>>>
>>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>>> news:fvb05h$jgb$1@build.eclipse.org...
>>>>>> I have developed a prototype editor for our scripting language based
>>>>>> on
>>>>>> your tutorial:
>>>>>>
>>>>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>>>>
>>>>>> We now would like to figure out how to turn the prototype into a real
>>>>>> editor.
>>>>>>
>>>>>> The first thing that was obvious was that it was proposing every
>>>>>> keyword
>>>>>> in the language as a possible completion without regard for:
>>>>>> a) whether or not it starts with the same prefix
>>>>>> b) whether it fits into the syntax at that point
>>>>>>
>>>>>> Doing b may be difficult - but a should be quite easy.
>>>>>> I did run my prototype editor in the debugger and found that it
>>>>>> accepted
>>>>>> or rejected possible templates based on whether the name of the
>>>>>> template
>>>>>> started with the same prefix as what the user had typed. This did not
>>>>>> seem
>>>>>> to be the case for adding keywords.
>>>>>>
>>>>>> How can I get at least the prefix to constrain possible completions?
>>>>>>
>>>>>> Also, is there any documentation or even Java doc for DLTK?
>>>>>>
>>>>>> Thanks,
>>>>>> Chuck
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>>>
>>
>>
>
>
Re: completion proposals - not matched to prefix? [message #23141 is a reply to message #23098] Mon, 05 May 2008 23:48 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
I found
org.eclipse.dltk.ruby.internal.core.codeassist.RubyCompletio nEngine.getWordStarting
and copied it to my class. Ideally, this functionality should be moved to a
base class.

I gather the source module contents are the current contents, and the offset
is where the cursor is
when you request completion. So, if you ask what did someone just type, you
can assume it was the previous word/identifier.
1) getWordStarting takes a maxLength. Pratically - the previous token
wouldn't be very long - but why must there be a limit?
I may rewrite this method.
2) I now properly filter my keyword proposals to only return those
starting with the previous token.
3) Unfortunately, the full keyword proposals are always added to the
existing token prefix, i.e.:

fo

becomes

fofor

Chuck

"Chuck Doucette" <cdoucette@vaultus.com> wrote in message
news:fvo1ib$19c$1@build.eclipse.org...
>I looked again and did find a completion engined defined for both Ruby and
>Tcl.
>
> Again they both extended ScriptCompletionEngine rather than implement
> ICompletionEngine.
>
> Chuck
>
> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
> news:fvo0ib$f50$1@build.eclipse.org...
>>I downloaded the latest Integration/Incubation build, with all of the
>>language toolkit bundles.
>>
>> As far as I could tell, only JavaScript defines a completion engine, and
>> they do extend ScriptCompletionEngine rather than simply implement
>> ICompletionEngine.
>>
>> I didn't see a completion engine defined in Ruby, Tcl, or Python.
>>
>> Chuck
>>
>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>> news:fvnlvq$qjb$1@build.eclipse.org...
>>> It appears that perhaps my class should extend the class
>>> ScriptCompletionEngine
>>> rather than implement the interface ICompletionEngine (as was done in
>>> the tutorial).
>>>
>>> The problem is that there are 4 methods that need to be defined, and
>>> there is no documentation that I can find on how to define them:
>>> @Override
>>>
>>> protected String processFieldName(IField field, String token) {
>>>
>>> // TODO Auto-generated method stub
>>>
>>> return null;
>>>
>>> }
>>>
>>>
>>> @Override
>>>
>>> protected String processMethodName(IMethod method, String token) {
>>>
>>> // TODO Auto-generated method stub
>>>
>>> return null;
>>>
>>> }
>>>
>>>
>>> @Override
>>>
>>> protected String processTypeName(IType method, String token) {
>>>
>>> // TODO Auto-generated method stub
>>>
>>> return null;
>>>
>>> }
>>>
>>>
>>> @Override
>>>
>>> public IAssistParser getParser() {
>>>
>>> // TODO Auto-generated method stub
>>>
>>> return null;
>>>
>>> }
>>>
>>> Also, IAssistParser is not documented either.
>>>
>>> Thanks,
>>> Chuck
>>>
>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>> news:fvkm4a$ia3$1@build.eclipse.org...
>>>>I already said that apparently I could call
>>>>ISourceModule.getSourceContents.
>>>>
>>>> I assume that method will return the original contents of the buffer.
>>>> I want to get the current contents, and specifically what was just
>>>> typed before invoking completion.
>>>> Is that possible to obtain? If so, how?
>>>>
>>>> I found the template code that I was referring to in the class
>>>> ScriptTemplateCompletionProcessor:
>>>> public ICompletionProposal[] computeCompletionProposals(ITextViewer
>>>> viewer, int offset) {
>>>>
>>>> It calls this:
>>>>
>>>> String prefix = extractPrefix(viewer, offset);
>>>>
>>>> That method is defined here:
>>>> package org.eclipse.jface.text.templates;
>>>>
>>>> class TemplateCompletionProcessor
>>>>
>>>> as follows:
>>>>
>>>> /**
>>>>
>>>> * Heuristically extracts the prefix used for determining template
>>>> relevance
>>>>
>>>> * from the viewer's document. The default implementation returns the
>>>> String from
>>>>
>>>> * offset backwards that forms a java identifier.
>>>>
>>>> *
>>>>
>>>> * @param viewer the viewer
>>>>
>>>> * @param offset offset into document
>>>>
>>>> * @return the prefix to consider
>>>>
>>>> * @see #getRelevance(Template, String)
>>>>
>>>> */
>>>>
>>>> protected String extractPrefix(ITextViewer viewer, int offset) {
>>>>
>>>> This would give me exactly what I (and probably many others) are
>>>> looking for.
>>>>
>>>> It makes no sense to return possible completions (template or
>>>> otherwise) that don't match the prefix.
>>>>
>>>> For now, I guess I will attempt to emulate this code in my classes -
>>>> but ideally it would be functionality offerred by DLTK.
>>>>
>>>> I will look at some of your complete implementations, like JavaScript,
>>>> rather than the tutorial example for Python.
>>>>
>>>> Thanks,
>>>>
>>>> Chuck
>>>>
>>>> "Andrei Sobolev" <haiodo@xored.com> wrote in message
>>>> news:fvk9sd$8td$1@build.eclipse.org...
>>>>> Hi Chuck,
>>>>>
>>>>> Tutorial we provided contain only basic information about some DLTK
>>>>> parts.
>>>>>
>>>>> For more complex implementation please refer to our language
>>>>> implementations( Tcl, Ruby ).
>>>>>> I'm still stuck on this problem, and I would appreciate some input.
>>>>>>
>>>>>> The issue is specifically with ICompletionEngine, and the method:
>>>>>> void complete(ISourceModule module, int position, int pos)
>>>>>>
>>>>>> I found where it is called from Openable.codeComplete:
>>>>>>
>>>>>> engine.complete(cu, position, 0);
>>>>>>
>>>>>> I can use ISourceModule, and call this method:
>>>>>> String getSourceContents();
>>>>>>
>>>>>> From, that, I assume I can use position to determine where someone is
>>>>>> trying
>>>>>> to perform completion.
>>>>>>
>>>>>> What I don't know is how to determine what if anything they have
>>>>>> typed
>>>>>> before attempting to do completion (which I assume they haven't saved
>>>>>> yet).
>>>>>
>>>>> SourceModules use special structure named Buffer.
>>>>> All changes from user are be in this buffer.
>>>>> So then you call getSourceContents() and if buffer exists content from
>>>>> buffer will be returned.
>>>>>
>>>>> Best regards,
>>>>> Andrei Sobolev.
>>>>>
>>>>>>
>>>>>> I know this is prefix is available for evaluating matching template
>>>>>> names.
>>>>>>
>>>>>> I don't remember where that source is.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Chuck
>>>>>>
>>>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>>>> news:fvb05h$jgb$1@build.eclipse.org...
>>>>>>> I have developed a prototype editor for our scripting language based
>>>>>>> on
>>>>>>> your tutorial:
>>>>>>>
>>>>>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>>>>>
>>>>>>> We now would like to figure out how to turn the prototype into a
>>>>>>> real
>>>>>>> editor.
>>>>>>>
>>>>>>> The first thing that was obvious was that it was proposing every
>>>>>>> keyword
>>>>>>> in the language as a possible completion without regard for:
>>>>>>> a) whether or not it starts with the same prefix
>>>>>>> b) whether it fits into the syntax at that point
>>>>>>>
>>>>>>> Doing b may be difficult - but a should be quite easy.
>>>>>>> I did run my prototype editor in the debugger and found that it
>>>>>>> accepted
>>>>>>> or rejected possible templates based on whether the name of the
>>>>>>> template
>>>>>>> started with the same prefix as what the user had typed. This did
>>>>>>> not seem
>>>>>>> to be the case for adding keywords.
>>>>>>>
>>>>>>> How can I get at least the prefix to constrain possible completions?
>>>>>>>
>>>>>>> Also, is there any documentation or even Java doc for DLTK?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Chuck
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Re: completion proposals - not matched to prefix? [message #23179 is a reply to message #23141] Tue, 06 May 2008 00:14 Go to previous messageGo to next message
Charles Doucette is currently offline Charles DoucetteFriend
Messages: 125
Registered: July 2009
Senior Member
Once I set the offset to the length of the preceeding token,
everything seems to work fine as I expected.

Chuck

"Chuck Doucette" <cdoucette@vaultus.com> wrote in message
news:fvo6er$655$1@build.eclipse.org...
>I found
> org.eclipse.dltk.ruby.internal.core.codeassist.RubyCompletio nEngine.getWordStarting
> and copied it to my class. Ideally, this functionality should be moved to
> a base class.
>
> I gather the source module contents are the current contents, and the
> offset is where the cursor is
> when you request completion. So, if you ask what did someone just type,
> you can assume it was the previous word/identifier.
> 1) getWordStarting takes a maxLength. Pratically - the previous token
> wouldn't be very long - but why must there be a limit?
> I may rewrite this method.
> 2) I now properly filter my keyword proposals to only return those
> starting with the previous token.
> 3) Unfortunately, the full keyword proposals are always added to the
> existing token prefix, i.e.:
>
> fo
>
> becomes
>
> fofor
>
> Chuck
>
> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
> news:fvo1ib$19c$1@build.eclipse.org...
>>I looked again and did find a completion engined defined for both Ruby and
>>Tcl.
>>
>> Again they both extended ScriptCompletionEngine rather than implement
>> ICompletionEngine.
>>
>> Chuck
>>
>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>> news:fvo0ib$f50$1@build.eclipse.org...
>>>I downloaded the latest Integration/Incubation build, with all of the
>>>language toolkit bundles.
>>>
>>> As far as I could tell, only JavaScript defines a completion engine, and
>>> they do extend ScriptCompletionEngine rather than simply implement
>>> ICompletionEngine.
>>>
>>> I didn't see a completion engine defined in Ruby, Tcl, or Python.
>>>
>>> Chuck
>>>
>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>> news:fvnlvq$qjb$1@build.eclipse.org...
>>>> It appears that perhaps my class should extend the class
>>>> ScriptCompletionEngine
>>>> rather than implement the interface ICompletionEngine (as was done in
>>>> the tutorial).
>>>>
>>>> The problem is that there are 4 methods that need to be defined, and
>>>> there is no documentation that I can find on how to define them:
>>>> @Override
>>>>
>>>> protected String processFieldName(IField field, String token) {
>>>>
>>>> // TODO Auto-generated method stub
>>>>
>>>> return null;
>>>>
>>>> }
>>>>
>>>>
>>>> @Override
>>>>
>>>> protected String processMethodName(IMethod method, String token) {
>>>>
>>>> // TODO Auto-generated method stub
>>>>
>>>> return null;
>>>>
>>>> }
>>>>
>>>>
>>>> @Override
>>>>
>>>> protected String processTypeName(IType method, String token) {
>>>>
>>>> // TODO Auto-generated method stub
>>>>
>>>> return null;
>>>>
>>>> }
>>>>
>>>>
>>>> @Override
>>>>
>>>> public IAssistParser getParser() {
>>>>
>>>> // TODO Auto-generated method stub
>>>>
>>>> return null;
>>>>
>>>> }
>>>>
>>>> Also, IAssistParser is not documented either.
>>>>
>>>> Thanks,
>>>> Chuck
>>>>
>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>> news:fvkm4a$ia3$1@build.eclipse.org...
>>>>>I already said that apparently I could call
>>>>>ISourceModule.getSourceContents.
>>>>>
>>>>> I assume that method will return the original contents of the buffer.
>>>>> I want to get the current contents, and specifically what was just
>>>>> typed before invoking completion.
>>>>> Is that possible to obtain? If so, how?
>>>>>
>>>>> I found the template code that I was referring to in the class
>>>>> ScriptTemplateCompletionProcessor:
>>>>> public ICompletionProposal[] computeCompletionProposals(ITextViewer
>>>>> viewer, int offset) {
>>>>>
>>>>> It calls this:
>>>>>
>>>>> String prefix = extractPrefix(viewer, offset);
>>>>>
>>>>> That method is defined here:
>>>>> package org.eclipse.jface.text.templates;
>>>>>
>>>>> class TemplateCompletionProcessor
>>>>>
>>>>> as follows:
>>>>>
>>>>> /**
>>>>>
>>>>> * Heuristically extracts the prefix used for determining template
>>>>> relevance
>>>>>
>>>>> * from the viewer's document. The default implementation returns the
>>>>> String from
>>>>>
>>>>> * offset backwards that forms a java identifier.
>>>>>
>>>>> *
>>>>>
>>>>> * @param viewer the viewer
>>>>>
>>>>> * @param offset offset into document
>>>>>
>>>>> * @return the prefix to consider
>>>>>
>>>>> * @see #getRelevance(Template, String)
>>>>>
>>>>> */
>>>>>
>>>>> protected String extractPrefix(ITextViewer viewer, int offset) {
>>>>>
>>>>> This would give me exactly what I (and probably many others) are
>>>>> looking for.
>>>>>
>>>>> It makes no sense to return possible completions (template or
>>>>> otherwise) that don't match the prefix.
>>>>>
>>>>> For now, I guess I will attempt to emulate this code in my classes -
>>>>> but ideally it would be functionality offerred by DLTK.
>>>>>
>>>>> I will look at some of your complete implementations, like JavaScript,
>>>>> rather than the tutorial example for Python.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Chuck
>>>>>
>>>>> "Andrei Sobolev" <haiodo@xored.com> wrote in message
>>>>> news:fvk9sd$8td$1@build.eclipse.org...
>>>>>> Hi Chuck,
>>>>>>
>>>>>> Tutorial we provided contain only basic information about some DLTK
>>>>>> parts.
>>>>>>
>>>>>> For more complex implementation please refer to our language
>>>>>> implementations( Tcl, Ruby ).
>>>>>>> I'm still stuck on this problem, and I would appreciate some input.
>>>>>>>
>>>>>>> The issue is specifically with ICompletionEngine, and the method:
>>>>>>> void complete(ISourceModule module, int position, int pos)
>>>>>>>
>>>>>>> I found where it is called from Openable.codeComplete:
>>>>>>>
>>>>>>> engine.complete(cu, position, 0);
>>>>>>>
>>>>>>> I can use ISourceModule, and call this method:
>>>>>>> String getSourceContents();
>>>>>>>
>>>>>>> From, that, I assume I can use position to determine where someone
>>>>>>> is trying
>>>>>>> to perform completion.
>>>>>>>
>>>>>>> What I don't know is how to determine what if anything they have
>>>>>>> typed
>>>>>>> before attempting to do completion (which I assume they haven't
>>>>>>> saved yet).
>>>>>>
>>>>>> SourceModules use special structure named Buffer.
>>>>>> All changes from user are be in this buffer.
>>>>>> So then you call getSourceContents() and if buffer exists content
>>>>>> from buffer will be returned.
>>>>>>
>>>>>> Best regards,
>>>>>> Andrei Sobolev.
>>>>>>
>>>>>>>
>>>>>>> I know this is prefix is available for evaluating matching template
>>>>>>> names.
>>>>>>>
>>>>>>> I don't remember where that source is.
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Chuck
>>>>>>>
>>>>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>>>>> news:fvb05h$jgb$1@build.eclipse.org...
>>>>>>>> I have developed a prototype editor for our scripting language
>>>>>>>> based on
>>>>>>>> your tutorial:
>>>>>>>>
>>>>>>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>>>>>>
>>>>>>>> We now would like to figure out how to turn the prototype into a
>>>>>>>> real
>>>>>>>> editor.
>>>>>>>>
>>>>>>>> The first thing that was obvious was that it was proposing every
>>>>>>>> keyword
>>>>>>>> in the language as a possible completion without regard for:
>>>>>>>> a) whether or not it starts with the same prefix
>>>>>>>> b) whether it fits into the syntax at that point
>>>>>>>>
>>>>>>>> Doing b may be difficult - but a should be quite easy.
>>>>>>>> I did run my prototype editor in the debugger and found that it
>>>>>>>> accepted
>>>>>>>> or rejected possible templates based on whether the name of the
>>>>>>>> template
>>>>>>>> started with the same prefix as what the user had typed. This did
>>>>>>>> not seem
>>>>>>>> to be the case for adding keywords.
>>>>>>>>
>>>>>>>> How can I get at least the prefix to constrain possible
>>>>>>>> completions?
>>>>>>>>
>>>>>>>> Also, is there any documentation or even Java doc for DLTK?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Chuck
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Re: completion proposals - not matched to prefix? [message #23214 is a reply to message #23179] Tue, 06 May 2008 05:36 Go to previous message
Andrei Sobolev is currently offline Andrei SobolevFriend
Messages: 72
Registered: July 2009
Member
Hi Chuck,

Nice to see it.

Best regards,
Andrei Sobolev.
> Once I set the offset to the length of the preceeding token,
> everything seems to work fine as I expected.
>
> Chuck
>
> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
> news:fvo6er$655$1@build.eclipse.org...
>> I found
>> org.eclipse.dltk.ruby.internal.core.codeassist.RubyCompletio nEngine.getWordStarting
>> and copied it to my class. Ideally, this functionality should be moved to
>> a base class.
>>
>> I gather the source module contents are the current contents, and the
>> offset is where the cursor is
>> when you request completion. So, if you ask what did someone just type,
>> you can assume it was the previous word/identifier.
>> 1) getWordStarting takes a maxLength. Pratically - the previous token
>> wouldn't be very long - but why must there be a limit?
>> I may rewrite this method.
>> 2) I now properly filter my keyword proposals to only return those
>> starting with the previous token.
>> 3) Unfortunately, the full keyword proposals are always added to the
>> existing token prefix, i.e.:
>>
>> fo
>>
>> becomes
>>
>> fofor
>>
>> Chuck
>>
>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>> news:fvo1ib$19c$1@build.eclipse.org...
>>> I looked again and did find a completion engined defined for both Ruby and
>>> Tcl.
>>>
>>> Again they both extended ScriptCompletionEngine rather than implement
>>> ICompletionEngine.
>>>
>>> Chuck
>>>
>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>> news:fvo0ib$f50$1@build.eclipse.org...
>>>> I downloaded the latest Integration/Incubation build, with all of the
>>>> language toolkit bundles.
>>>>
>>>> As far as I could tell, only JavaScript defines a completion engine, and
>>>> they do extend ScriptCompletionEngine rather than simply implement
>>>> ICompletionEngine.
>>>>
>>>> I didn't see a completion engine defined in Ruby, Tcl, or Python.
>>>>
>>>> Chuck
>>>>
>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>> news:fvnlvq$qjb$1@build.eclipse.org...
>>>>> It appears that perhaps my class should extend the class
>>>>> ScriptCompletionEngine
>>>>> rather than implement the interface ICompletionEngine (as was done in
>>>>> the tutorial).
>>>>>
>>>>> The problem is that there are 4 methods that need to be defined, and
>>>>> there is no documentation that I can find on how to define them:
>>>>> @Override
>>>>>
>>>>> protected String processFieldName(IField field, String token) {
>>>>>
>>>>> // TODO Auto-generated method stub
>>>>>
>>>>> return null;
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> @Override
>>>>>
>>>>> protected String processMethodName(IMethod method, String token) {
>>>>>
>>>>> // TODO Auto-generated method stub
>>>>>
>>>>> return null;
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> @Override
>>>>>
>>>>> protected String processTypeName(IType method, String token) {
>>>>>
>>>>> // TODO Auto-generated method stub
>>>>>
>>>>> return null;
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> @Override
>>>>>
>>>>> public IAssistParser getParser() {
>>>>>
>>>>> // TODO Auto-generated method stub
>>>>>
>>>>> return null;
>>>>>
>>>>> }
>>>>>
>>>>> Also, IAssistParser is not documented either.
>>>>>
>>>>> Thanks,
>>>>> Chuck
>>>>>
>>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>>> news:fvkm4a$ia3$1@build.eclipse.org...
>>>>>> I already said that apparently I could call
>>>>>> ISourceModule.getSourceContents.
>>>>>>
>>>>>> I assume that method will return the original contents of the buffer.
>>>>>> I want to get the current contents, and specifically what was just
>>>>>> typed before invoking completion.
>>>>>> Is that possible to obtain? If so, how?
>>>>>>
>>>>>> I found the template code that I was referring to in the class
>>>>>> ScriptTemplateCompletionProcessor:
>>>>>> public ICompletionProposal[] computeCompletionProposals(ITextViewer
>>>>>> viewer, int offset) {
>>>>>>
>>>>>> It calls this:
>>>>>>
>>>>>> String prefix = extractPrefix(viewer, offset);
>>>>>>
>>>>>> That method is defined here:
>>>>>> package org.eclipse.jface.text.templates;
>>>>>>
>>>>>> class TemplateCompletionProcessor
>>>>>>
>>>>>> as follows:
>>>>>>
>>>>>> /**
>>>>>>
>>>>>> * Heuristically extracts the prefix used for determining template
>>>>>> relevance
>>>>>>
>>>>>> * from the viewer's document. The default implementation returns the
>>>>>> String from
>>>>>>
>>>>>> * offset backwards that forms a java identifier.
>>>>>>
>>>>>> *
>>>>>>
>>>>>> * @param viewer the viewer
>>>>>>
>>>>>> * @param offset offset into document
>>>>>>
>>>>>> * @return the prefix to consider
>>>>>>
>>>>>> * @see #getRelevance(Template, String)
>>>>>>
>>>>>> */
>>>>>>
>>>>>> protected String extractPrefix(ITextViewer viewer, int offset) {
>>>>>>
>>>>>> This would give me exactly what I (and probably many others) are
>>>>>> looking for.
>>>>>>
>>>>>> It makes no sense to return possible completions (template or
>>>>>> otherwise) that don't match the prefix.
>>>>>>
>>>>>> For now, I guess I will attempt to emulate this code in my classes -
>>>>>> but ideally it would be functionality offerred by DLTK.
>>>>>>
>>>>>> I will look at some of your complete implementations, like JavaScript,
>>>>>> rather than the tutorial example for Python.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Chuck
>>>>>>
>>>>>> "Andrei Sobolev" <haiodo@xored.com> wrote in message
>>>>>> news:fvk9sd$8td$1@build.eclipse.org...
>>>>>>> Hi Chuck,
>>>>>>>
>>>>>>> Tutorial we provided contain only basic information about some DLTK
>>>>>>> parts.
>>>>>>>
>>>>>>> For more complex implementation please refer to our language
>>>>>>> implementations( Tcl, Ruby ).
>>>>>>>> I'm still stuck on this problem, and I would appreciate some input.
>>>>>>>>
>>>>>>>> The issue is specifically with ICompletionEngine, and the method:
>>>>>>>> void complete(ISourceModule module, int position, int pos)
>>>>>>>>
>>>>>>>> I found where it is called from Openable.codeComplete:
>>>>>>>>
>>>>>>>> engine.complete(cu, position, 0);
>>>>>>>>
>>>>>>>> I can use ISourceModule, and call this method:
>>>>>>>> String getSourceContents();
>>>>>>>>
>>>>>>>> From, that, I assume I can use position to determine where someone
>>>>>>>> is trying
>>>>>>>> to perform completion.
>>>>>>>>
>>>>>>>> What I don't know is how to determine what if anything they have
>>>>>>>> typed
>>>>>>>> before attempting to do completion (which I assume they haven't
>>>>>>>> saved yet).
>>>>>>> SourceModules use special structure named Buffer.
>>>>>>> All changes from user are be in this buffer.
>>>>>>> So then you call getSourceContents() and if buffer exists content
>>>>>>> from buffer will be returned.
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Andrei Sobolev.
>>>>>>>
>>>>>>>> I know this is prefix is available for evaluating matching template
>>>>>>>> names.
>>>>>>>>
>>>>>>>> I don't remember where that source is.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> Chuck
>>>>>>>>
>>>>>>>> "Chuck Doucette" <cdoucette@vaultus.com> wrote in message
>>>>>>>> news:fvb05h$jgb$1@build.eclipse.org...
>>>>>>>>> I have developed a prototype editor for our scripting language
>>>>>>>>> based on
>>>>>>>>> your tutorial:
>>>>>>>>>
>>>>>>>>> http://wiki.eclipse.org/A_guide_to_building_a_DLTK-based_lan guage_IDE
>>>>>>>>>
>>>>>>>>> We now would like to figure out how to turn the prototype into a
>>>>>>>>> real
>>>>>>>>> editor.
>>>>>>>>>
>>>>>>>>> The first thing that was obvious was that it was proposing every
>>>>>>>>> keyword
>>>>>>>>> in the language as a possible completion without regard for:
>>>>>>>>> a) whether or not it starts with the same prefix
>>>>>>>>> b) whether it fits into the syntax at that point
>>>>>>>>>
>>>>>>>>> Doing b may be difficult - but a should be quite easy.
>>>>>>>>> I did run my prototype editor in the debugger and found that it
>>>>>>>>> accepted
>>>>>>>>> or rejected possible templates based on whether the name of the
>>>>>>>>> template
>>>>>>>>> started with the same prefix as what the user had typed. This did
>>>>>>>>> not seem
>>>>>>>>> to be the case for adding keywords.
>>>>>>>>>
>>>>>>>>> How can I get at least the prefix to constrain possible
>>>>>>>>> completions?
>>>>>>>>>
>>>>>>>>> Also, is there any documentation or even Java doc for DLTK?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Chuck
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
>
Previous Topic:DLTK javadoc - do it yourself
Next Topic:unable to find method declarations
Goto Forum:
  


Current Time: Thu Dec 26 10:16:33 GMT 2024

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

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

Back to the top