Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 205507 - Add a way for CodeCompletionHandler to know if the task has been canceled
Add a way for CodeCompletionHandler to know if the task has been canceled
Product: editor
Classification: Unclassified
Component: CSL (API & infrastructure)
PC All
: P3 (vote)
: 7.4
Assigned To: Svata Dedic
Depends on:
  Show dependency treegraph
Reported: 2011-11-24 08:18 UTC by emi
Modified: 2016-07-07 07:31 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description emi 2011-11-24 08:18:18 UTC
The way I see it, once org.netbeans.modules.csl.api.CodeCompletionHandler.complete() starts running, there is now way for it to stop ahead of time if the task has been canceled.

A common example would be if the user triggers completion then gets bored waiting and presses Escape.

Without knowing when to stop, the handler will just run as long as it takes consuming CPU for nothing. And if another completion is triggered, we'll have multiple threads running the handlers.

It seems AsyncCompletionTask is cancelable and this is also provided in AsyncCompletionQuery but we don't provide this info via GsfCompletionProvider.CodeCompletionContextImpl (which implements CodeCompletionContext).

I can provide my patch for this, it's quite short.

The only thing to debate is if this makes sense and update the CodeCompletionContext API.
Comment 1 emi 2011-11-24 08:20:38 UTC
BTW, the suggested api is:

boolean org.netbeans.modules.csl.api.CodeCompletionContext.isTaskCanceled()
Comment 2 Svata Dedic 2012-12-11 16:05:08 UTC
I'll try it. Strictly speaking (thanks to the original design), adding a method to CCContext is an incompatible API change, so I wonder how the API will look like.
Comment 3 emi 2012-12-11 16:20:56 UTC
My patch is on some older code and basically just a hack, so there isn't much to share.

But overall, I've just added:

public abstract boolean isTaskCanceled();

which defers to AsyncCompletionQuery.isTaskCancelled().

Not knowing if the task has been cancelled is a bug that wastes CPU and should allow client code to bail early if isTaskCanceled() starts returning 'true'.

So I would say this is an API change that should be done in some form.
Comment 4 Martin Balin 2016-07-07 07:31:20 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo