Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 211966 Details for
Bug 350991
[content assist][api] Allow to re-sort proposals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch for jdt.ui to enable reordering
bug350991_jdt.ui.patch (text/plain), 10.38 KB, created by
Marcel Bruch
on 2012-03-02 09:41:26 EST
(
hide
)
Description:
patch for jdt.ui to enable reordering
Filename:
MIME Type:
Creator:
Marcel Bruch
Created:
2012-03-02 09:41:26 EST
Size:
10.38 KB
patch
obsolete
>From df0b71faca88b4aa7c9814b6d614d30f5da3eb6e Mon Sep 17 00:00:00 2001 >From: Marcel Bruch <marcel.bruch@gmail.com> >Date: Fri, 2 Mar 2012 14:47:43 +0100 >Subject: [PATCH] https://bugs.eclipse.org/bugs/show_bug.cgi?id=350991 > >--- > .../schema/javaCompletionProposalComputer.exsd | 9 ++++++- > .../ui/text/java/CompletionProposalCategory.java | 27 +++++++++++++++++++- > .../java/CompletionProposalComputerDescriptor.java | 20 ++++++++++++++ > .../ui/text/java/ContentAssistProcessor.java | 18 ++++++++++++- > .../ui/text/java/ProposalSorterHandle.java | 2 +- > .../jdt/ui/text/java/AbstractProposalSorter.java | 4 ++- > 6 files changed, 75 insertions(+), 5 deletions(-) > >diff --git a/org.eclipse.jdt.ui/schema/javaCompletionProposalComputer.exsd b/org.eclipse.jdt.ui/schema/javaCompletionProposalComputer.exsd >index c25fcf9..bad37a2 100644 >--- a/org.eclipse.jdt.ui/schema/javaCompletionProposalComputer.exsd >+++ b/org.eclipse.jdt.ui/schema/javaCompletionProposalComputer.exsd >@@ -1,6 +1,6 @@ > <?xml version='1.0' encoding='UTF-8'?> > <!-- Schema file written by PDE --> >-<schema targetNamespace="org.eclipse.jdt.ui"> >+<schema targetNamespace="org.eclipse.jdt.ui" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> > <appInfo> > <meta.schema plugin="org.eclipse.jdt.ui" id="javaCompletionProposalComputer" name="Java Completion Proposal Computer"/> >@@ -95,6 +95,13 @@ and must have a public 0-argument constructor. > </appInfo> > </annotation> > </attribute> >+ <attribute name="requiresReordering" type="boolean" use="default" value="false"> >+ <annotation> >+ <documentation> >+ if the attribute is set to "true" it forces the content assist processessor to resort the list of proposals every time a new token is entered or removed to the completion prefix. >+ </documentation> >+ </annotation> >+ </attribute> > </complexType> > </element> > >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java >index ddccc31..e0b3e84 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java >@@ -76,6 +76,8 @@ public final class CompletionProposalCategory { > private int fSortOrder= 0xffff - 1; > private String fLastError= null; > >+ private boolean fRequiresReordering; >+ > CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException { > fElement= element; > fRegistry= registry; >@@ -108,7 +110,7 @@ public final class CompletionProposalCategory { > } > } > fImage= img; >- >+ initalizeRequiresReordering(); > } > > CompletionProposalCategory(String id, String name, CompletionProposalComputerRegistry registry) { >@@ -118,6 +120,7 @@ public final class CompletionProposalCategory { > fElement= null; > fEnablementExpression = null; > fImage= null; >+ initalizeRequiresReordering(); > } > > private Bundle getBundle() { >@@ -143,6 +146,18 @@ public final class CompletionProposalCategory { > } > > /** >+ * Iterates through all proposal computer descriptors iterated with this category and tests >+ * whether any of them requests proposal reordering. >+ */ >+ private void initalizeRequiresReordering() { >+ for (CompletionProposalComputerDescriptor desc : fRegistry.getProposalComputerDescriptors()) { >+ if (desc.getCategory() == this) { >+ fRequiresReordering|= desc.requiresReordering(); >+ } >+ } >+ } >+ >+ /** > * Returns the identifier of the described extension. > * > * @return Returns the id >@@ -386,4 +401,14 @@ public final class CompletionProposalCategory { > } > } > >+ /** >+ * Returns whether any completion proposal computer associated with this category requires >+ * proposals to be reordered. >+ * >+ * @return <code>true</code> if any completion proposal computer in this category requires >+ * proposals to be reordered. >+ */ >+ public boolean requiresReordering() { >+ return fRequiresReordering; >+ } > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java >index c9dfe2f..1a6dc86 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalComputerDescriptor.java >@@ -61,6 +61,8 @@ final class CompletionProposalComputerDescriptor { > private static final String CLASS= "class"; //$NON-NLS-1$ > /** The extension schema name of the activate attribute. */ > private static final String ACTIVATE= "activate"; //$NON-NLS-1$ >+ /** The extension schema name of the requiresReordering attribute. */ >+ private static final String REQUIRES_REORDERING= "requiresReordering"; //$NON-NLS-1$ > /** The extension schema name of the partition child elements. */ > private static final String PARTITION= "partition"; //$NON-NLS-1$ > /** Set of Java partition types. */ >@@ -131,6 +133,13 @@ final class CompletionProposalComputerDescriptor { > * @since 3.4 > */ > boolean fTriedLoadingComputer= false; >+ /** >+ * Tells whether this proposal engine provides dynamic content that needs reordering of its >+ * proposals. >+ * >+ * @since 3.8 >+ */ >+ private boolean fRequiresReordering; > > > /** >@@ -174,6 +183,9 @@ final class CompletionProposalComputerDescriptor { > String activateAttribute= element.getAttribute(ACTIVATE); > fActivate= Boolean.valueOf(activateAttribute).booleanValue(); > >+ String reorderingAttribute= element.getAttribute(REQUIRES_REORDERING); >+ fRequiresReordering= Boolean.valueOf(reorderingAttribute).booleanValue(); >+ > fClass= element.getAttribute(CLASS); > checkNotNull(fClass, CLASS); > >@@ -564,4 +576,12 @@ final class CompletionProposalComputerDescriptor { > } > } > >+ /** >+ * Returns the requiresReordering flag of the described extension. >+ * >+ * @return the requiresReordering flag of the described extension >+ */ >+ public boolean requiresReordering() { >+ return fRequiresReordering; >+ } > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java >index aba09ea..08a5358 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java >@@ -63,6 +63,7 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; > import org.eclipse.jdt.internal.corext.util.Messages; > > import org.eclipse.jdt.ui.PreferenceConstants; >+import org.eclipse.jdt.ui.text.java.AbstractProposalSorter; > import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; > > import org.eclipse.jdt.internal.ui.JavaPlugin; >@@ -277,16 +278,20 @@ public class ContentAssistProcessor implements IContentAssistProcessor { > * @return the list of proposals > */ > private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) { >+ boolean requiresReordering= false; > List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>(); > List<CompletionProposalCategory> providers= getCategories(); > for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { > CompletionProposalCategory cat= it.next(); > List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1)); > proposals.addAll(computed); >+ requiresReordering|= cat.requiresReordering() && !computed.isEmpty(); > if (fErrorMessage == null) > fErrorMessage= cat.getErrorMessage(); > } >- >+ if (requiresReordering) { >+ installProposalSorter(); >+ } > return proposals; > } > >@@ -630,4 +635,15 @@ public class ContentAssistProcessor implements IContentAssistProcessor { > return (KeySequence) binding; > return null; > } >+ >+ private void installProposalSorter() { >+ AbstractProposalSorter sorter= null; >+ try { >+ sorter= ProposalSorterRegistry.getDefault().getCurrentSorter().getSorter(); >+ } catch (Exception e) { >+ // TODO log? What's the common approach here? >+ } >+ fAssistant.setSorter(sorter); >+ } >+ > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalSorterHandle.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalSorterHandle.java >index fe59e1c..18efab0 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalSorterHandle.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ProposalSorterHandle.java >@@ -133,7 +133,7 @@ public final class ProposalSorterHandle { > * @throws InvalidRegistryObjectException if the extension is not valid any longer (e.g. due to > * plug-in unloading) > */ >- private synchronized AbstractProposalSorter getSorter() throws CoreException, InvalidRegistryObjectException { >+ synchronized AbstractProposalSorter getSorter() throws CoreException, InvalidRegistryObjectException { > if (fSorter == null) > fSorter= createSorter(); > return fSorter; >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/AbstractProposalSorter.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/AbstractProposalSorter.java >index 2fd7d79..ff41ccb 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/AbstractProposalSorter.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/AbstractProposalSorter.java >@@ -15,6 +15,8 @@ import java.util.Comparator; > import org.eclipse.core.runtime.IConfigurationElement; > > import org.eclipse.jface.text.contentassist.ICompletionProposal; >+import org.eclipse.jface.text.contentassist.ICompletionProposalSorter; >+ > > /** > * Abstract base class for sorters contributed to the >@@ -30,7 +32,7 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal; > * > * @since 3.2 > */ >-public abstract class AbstractProposalSorter implements Comparator<ICompletionProposal> { >+public abstract class AbstractProposalSorter implements Comparator<ICompletionProposal>, ICompletionProposalSorter { > > /** > * Creates a new sorter. Note that subclasses must provide a zero-argument constructor to be >-- >1.7.5.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 350991
:
211946
|
211947
|
211966
|
211967
|
211968
|
212115
|
212116
|
212117
|
212506
|
212507
|
212525
|
212588
|
212589