[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [Dltk-dev] Code completion fails to work with no prefix
|
createContext() could be costly operation (if it performs source
parsing), so separate prefix check allows to avoid it.
If you want to check prefix based on the context you can acquire prefix
with the following code:
viewer.getDocument().get(region.getOffset(), region.getLength())
inside your implementation of the createContext() method
Regards,
Alex
Gerald Rosenberg wrote:
Great. Though, if you add the new method, it may more generally useful
if the signature is something like:
isValidPrefixForContext(String prefix, TemplateContext context)
using in ScriptTemplateCompletionProcessor#computeCompletionProposals:
String prefix = extractPrefix(viewer, offset);
Region region = *new* Region(offset - prefix.length(), prefix.length());
TemplateContext context = createContext(viewer, region);
*if* (!isValidPrefixForContext(prefix, context))
*return* *new* ICompletionProposal[0];
with a default implementation of
public boolean isValidPrefixForContext(String prefix, TemplateContext
context) {
if (prefix == *null* || prefix.length() == 0 || context == *null* )
return false;
}
That will allow switching the behavior based on contextType ID.
In any case, very much appreciate the quick response and help.
At 12:50 AM 8/26/2008, Alex Panchenko wrote:
Hi Gerald,
The change was intended to model the JDT behavior - it does not
display all template proposals on the blank line.
I have just introduced the new method
protected boolean isValidPrefix(String prefix) in CVS HEAD (to be
released as 1.0 in September) so you can override it if needed.
Regards,
Alex
Gerald Rosenberg wrote:
Upgrading my plugin to DLTK 0.95 from 0.91 (if memory serves).
In the earlier version, code completion (ctrl-space) on a blank line
used to pull up all templates for the current partition.
With 0.95, code completion on a blank line now produces a message in
the status bar: No completions available.
Looks like
ScriptTemplateCompletionProcessor#computeCompletionProposals (line
83) absolutely requires a prefix.
Was this an intended change? Is there a preferred way to get back
the old behavior?
Thanks.
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev
------------------------------------------------------------------------
_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev