Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-ui-dev] Advise on nigration to the new ICompletionProposalExtension7 API?

Hello JDT developers,

we (Code Recommenders) could need some advise on how to best tackle Bug
484049 [1], i.e., migration to the new ICompletionProposalExtension7 API.

A bit of information about the current implementation up-front: Code
Recommenders wraps each AbstractJavaCompletionProposal in a
"processable" proposal. For example, for GetterSetterCompletionProposal
there is ProcessableGetterSetterCompletionProposal, which extends the
former and adds a few methods so we can "process" the proposal, e.g., to
add percentages. This design has worked well for several years now,
despite the internal-ness of AbstractJavaCompletionProposal.

Now, AbstractJavaCompletionProposal.emphasizeMatch's implementation is
something we obviously need to change for subwords completion, as we
need to highlight multiple discontinuous text ranges.

Unfortunately, if we were to simply override emphasizeMatch(IDocument,
int, BoldStylerProvider), our code no longer compile against versions of
JFace older than 3.11, as BoldStylerProvider has only been introduced
with that version.

If the signature were something "old-fashioned" instead (alas, it's a
bit late to change the API by now), say emphasizeMatch(IDocument, int,
Styler), we could simply have a emphasizeMatch method which only on
JFace 3.11 or greater would actually override something; on older
versions of JFace it would not override anything but at least it would
not prevent compilation.

But as emphasizeMatch is defined currently, that's not an option. Hence,
one has to build two versions of
ProcessableGetterSetterCompletionProposal, possibly in fragments, with
all the resulting build ugliness I don't know yet how to deal with in Tycho.

A simpler, but slightly kludgy alternative is to override
getPatternToEmphasizeMatch and let it return null in all
Processable*CompletionProposals (which causes all know implementations
of emphasizeMatch to do nothing) and continue to do the highlighting one
our own. If we can create a BoldStylerProvider using reflection, then we
would use that to provide a Styler for us, otherwise we would use the
same styler that we previously used (StyledString.COUNTER_STYLER).

Admittedly, this is ugly, so maybe I am missing something. Maybe you can
advise us on how you envisioned ICompletionProposalExtension7 to be used
in a way that still works with a pre-JFace 3.11 JDT.

Best wishes,

Andreas

[1] <https://bugs.eclipse.org/bugs/show_bug.cgi?id=484049>

-- 
Codetrails GmbH
The knowledge transfer company

Robert-Bosch-Str. 7, 64293 Darmstadt
Phone: +49-6151-276-7092
Mobile: +49-170-811-3791
http://www.codetrails.com/

Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940


Back to the top