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 208966 Details for
Bug 345213
[content assist][preferences] Add enablement to Java completion proposal category extension point
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
updated patch
345213.txt (text/plain), 15.33 KB, created by
Paul Fullbright
on 2012-01-03 16:24:49 EST
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Paul Fullbright
Created:
2012-01-03 16:24:49 EST
Size:
15.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: schema/javaCompletionProposalComputer.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/schema/javaCompletionProposalComputer.exsd,v >retrieving revision 1.8 >diff -u -r1.8 javaCompletionProposalComputer.exsd >--- schema/javaCompletionProposalComputer.exsd 18 Apr 2008 06:23:21 -0000 1.8 >+++ schema/javaCompletionProposalComputer.exsd 3 Jan 2012 21:23:52 -0000 >@@ -7,13 +7,20 @@ > </appInfo> > <documentation> > This extension point allows to contribute Java completion proposal computers to participate in the content assist process of the Java editor. >+<p> >+This extension point supports the <code>enablement</code> tag. Properties to test on are: >+<dl> >+<li>project: type IJavaProject; the current project</li> >+</dl> > </documentation> > </annotation> > >+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/> >+ > <element name="extension"> > <annotation> > <appInfo> >- <meta.element labelAttribute="name"/> >+ <meta.element labelAttribute="name" /> > </appInfo> > </annotation> > <complexType> >@@ -131,6 +138,9 @@ > </documentation> > </annotation> > <complexType> >+ <sequence> >+ <element ref="enablement" minOccurs="0" maxOccurs="1"/> >+ </sequence> > <attribute name="icon" type="string"> > <annotation> > <documentation> >@@ -204,7 +214,7 @@ > <meta.section type="copyright"/> > </appInfo> > <documentation> >- Copyright (c) 2006, 2008 IBM Corporation and others.<br> >+ Copyright (c) 2006, 2011 IBM Corporation and others.<br> > All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> > </documentation> > </annotation> >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistAction.java,v >retrieving revision 1.13 >diff -u -r1.13 SpecificContentAssistAction.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistAction.java 27 Apr 2011 07:48:35 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistAction.java 3 Jan 2012 21:23:52 -0000 >@@ -7,6 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Paul Fullbright <paul.fullbright@oracle.com> >+ * - content assist category enablement (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345213) > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.javaeditor; > >@@ -29,6 +31,8 @@ > import org.eclipse.ui.texteditor.ITextEditor; > import org.eclipse.ui.texteditor.IUpdate; > >+import org.eclipse.jdt.core.IJavaProject; >+ > import org.eclipse.jdt.ui.text.IJavaPartitions; > > import org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory; >@@ -101,11 +105,15 @@ > private boolean computeEnablement(ITextEditor editor) { > if (editor == null) > return false; >+ > ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class); >- boolean hasContentAssist= target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); >- if (!hasContentAssist) >+ if (target == null || ! target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)) > return false; >- >+ >+ IJavaProject javaProject = EditorUtility.getJavaProject(editor.getEditorInput()); >+ if (! fCategory.matches(javaProject)) >+ return false; >+ > ISelection selection= editor.getSelectionProvider().getSelection(); > return isValidSelection(selection); > } >Index: ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java,v >retrieving revision 1.8 >diff -u -r1.8 SpecificContentAssistExecutor.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java 27 Apr 2011 07:48:36 -0000 1.8 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/SpecificContentAssistExecutor.java 3 Jan 2012 21:23:52 -0000 >@@ -7,6 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Paul Fullbright <paul.fullbright@oracle.com> >+ * - content assist category enablement (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345213) > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.javaeditor; > >@@ -20,6 +22,8 @@ > > import org.eclipse.ui.texteditor.ITextEditor; > >+import org.eclipse.jdt.core.IJavaProject; >+ > import org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory; > import org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerRegistry; > >@@ -53,6 +57,8 @@ > Collection<CompletionProposalCategory> categories= fRegistry.getProposalCategories(); > boolean[] inclusionState= new boolean[categories.size()]; > boolean[] separateState= new boolean[categories.size()]; >+ boolean[] enabledState= new boolean[categories.size()]; >+ IJavaProject javaProject = EditorUtility.getJavaProject(editor.getEditorInput()); > int i= 0; > for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) { > CompletionProposalCategory cat= it.next(); >@@ -60,6 +66,8 @@ > cat.setIncluded(cat.getId().equals(categoryId)); > separateState[i]= cat.isSeparateCommand(); > cat.setSeparateCommand(false); >+ enabledState[i]= cat.isEnabled(); >+ cat.setEnabled(cat.isEnabled() && cat.matches(javaProject)); > } > > try { >@@ -72,6 +80,7 @@ > CompletionProposalCategory cat= it.next(); > cat.setIncluded(inclusionState[i]); > cat.setSeparateCommand(separateState[i]); >+ cat.setEnabled((enabledState[i])); > } > } > } >Index: ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java,v >retrieving revision 1.19 >diff -u -r1.19 CompletionProposalCategory.java >--- ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java 1 Mar 2011 11:50:36 -0000 1.19 >+++ ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java 3 Jan 2012 21:23:52 -0000 >@@ -7,6 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Paul Fullbright <paul.fullbright@oracle.com> >+ * - content assist category enablement (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345213) > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.text.java; > >@@ -17,6 +19,12 @@ > > import org.osgi.framework.Bundle; > >+import org.eclipse.core.expressions.EvaluationContext; >+import org.eclipse.core.expressions.EvaluationResult; >+import org.eclipse.core.expressions.Expression; >+import org.eclipse.core.expressions.ExpressionConverter; >+import org.eclipse.core.expressions.ExpressionTagNames; >+ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.IConfigurationElement; >@@ -33,6 +41,8 @@ > import org.eclipse.jface.text.contentassist.ICompletionProposal; > import org.eclipse.jface.text.contentassist.IContextInformation; > >+import org.eclipse.jdt.core.IJavaProject; >+ > import org.eclipse.jdt.internal.corext.util.Messages; > > import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; >@@ -54,6 +64,9 @@ > private final IConfigurationElement fElement; > /** The image descriptor for this category, or <code>null</code> if none specified. */ > private final ImageDescriptor fImage; >+ >+ /** The enablement expression for this category, or <code>null</code> if none specified. */ >+ private final Expression fEnablementExpression; > > private boolean fIsSeparateCommand= true; > private boolean fIsEnabled= true; >@@ -74,7 +87,16 @@ > fName= fId; > else > fName= name; >- >+ >+ IConfigurationElement[] children= fElement.getChildren(ExpressionTagNames.ENABLEMENT); >+ if (children.length == 1) { >+ ExpressionConverter parser= ExpressionConverter.getDefault(); >+ fEnablementExpression = parser.perform(children[0]); >+ } >+ else { >+ fEnablementExpression = null; >+ } >+ > String icon= element.getAttribute(ICON); > ImageDescriptor img= null; > if (icon != null) { >@@ -94,6 +116,7 @@ > fId= id; > fName= name; > fElement= null; >+ fEnablementExpression = null; > fImage= null; > } > >@@ -245,6 +268,35 @@ > public void setSortOrder(int sortOrder) { > fSortOrder= sortOrder; > } >+ >+ /** >+ * Determines if the project matches any enablement expression defined on the extension. >+ * If there is no enablement expression, return true for any project. >+ * Otherwise, if the project is null, return false. >+ * >+ * @param javaProject - the project against which to test the enablement expression >+ * @return true if this category is to be included in content proposals >+ * @since 3.8 >+ */ >+ public boolean matches(IJavaProject javaProject) { >+ if (fEnablementExpression == null) { >+ return true; >+ } >+ >+ if (javaProject == null) { >+ return false; >+ } >+ >+ try { >+ EvaluationContext evalContext= new EvaluationContext(null, javaProject); >+ evalContext.addVariable("project", javaProject); //$NON-NLS-1$ >+ return fEnablementExpression.evaluate(evalContext) == EvaluationResult.TRUE; >+ } catch (CoreException e) { >+ JavaPlugin.log(e); >+ } >+ >+ return false; >+ } > > /** > * Safely computes completion proposals of all computers of this category through their >Index: ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java,v >retrieving revision 1.26 >diff -u -r1.26 ContentAssistProcessor.java >--- ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java 1 Mar 2011 11:50:36 -0000 1.26 >+++ ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java 3 Jan 2012 21:23:52 -0000 >@@ -7,6 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Paul Fullbright <paul.fullbright@oracle.com> >+ * - content assist category enablement (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345213) > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.text.java; > >@@ -471,13 +473,24 @@ > List<CompletionProposalCategory> included= new ArrayList<CompletionProposalCategory>(); > for (Iterator<CompletionProposalCategory> it= fCategories.iterator(); it.hasNext();) { > CompletionProposalCategory category= it.next(); >- if (category.isIncluded() && category.hasComputers(fPartition)) >+ if (checkDefaultEnablement(category)) > included.add(category); > } > return included; > } > > /** >+ * Determine whether the category is enabled by default >+ * >+ * @param category - the category to check >+ * @return true if this category is enabled by default >+ * @since 3.8 >+ */ >+ protected boolean checkDefaultEnablement(CompletionProposalCategory category) { >+ return category.isIncluded() && category.hasComputers(fPartition); >+ } >+ >+ /** > * Informs the user about the fact that there are no enabled categories in the default content > * assist set and shows a link to the preferences. > * >@@ -565,12 +578,23 @@ > ArrayList<CompletionProposalCategory> sorted= new ArrayList<CompletionProposalCategory>(); > for (Iterator<CompletionProposalCategory> it= fCategories.iterator(); it.hasNext();) { > CompletionProposalCategory category= it.next(); >- if (category.isSeparateCommand() && category.hasComputers(fPartition)) >+ if (checkSeparateEnablement(category)) > sorted.add(category); > } > Collections.sort(sorted, ORDER_COMPARATOR); > return sorted; > } >+ >+ /** >+ * Determine whether the category is enabled for separate use >+ * >+ * @param category - the category to check >+ * @return true if this category is enabled for separate use >+ * @since 3.8 >+ */ >+ protected boolean checkSeparateEnablement(CompletionProposalCategory category) { >+ return category.isSeparateCommand() && category.hasComputers(fPartition); >+ } > > private String createEmptyMessage() { > return Messages.format(JavaTextMessages.ContentAssistProcessor_empty_message, new String[]{getCategoryLabel(fRepetition)}); >Index: ui/org/eclipse/jdt/internal/ui/text/java/JavaCompletionProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaCompletionProcessor.java,v >retrieving revision 1.82 >diff -u -r1.82 JavaCompletionProcessor.java >--- ui/org/eclipse/jdt/internal/ui/text/java/JavaCompletionProcessor.java 1 Mar 2011 11:50:36 -0000 1.82 >+++ ui/org/eclipse/jdt/internal/ui/text/java/JavaCompletionProcessor.java 3 Jan 2012 21:23:52 -0000 >@@ -7,6 +7,8 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Paul Fullbright <paul.fullbright@oracle.com> >+ * - content assist category enablement (https://bugs.eclipse.org/bugs/show_bug.cgi?id=345213) > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.text.java; > >@@ -22,11 +24,14 @@ > > import org.eclipse.ui.IEditorPart; > >+import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.JavaCore; > > import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; > import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; > >+import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; >+ > /** > * Java completion processor. > */ >@@ -83,6 +88,26 @@ > } > > /* >+ * @see ContentAssistProcessor#checkDefaultEnablement(CompletionProposalCategory) >+ */ >+ @Override >+ protected boolean checkDefaultEnablement(CompletionProposalCategory category) { >+ return super.checkDefaultEnablement(category) && category.matches(getJavaProject()); >+ } >+ >+ /* >+ * @see ContentAssistProcessor#checkSeparateEnablement(CompletionProposalCategory) >+ */ >+ @Override >+ protected boolean checkSeparateEnablement(CompletionProposalCategory category) { >+ return super.checkSeparateEnablement(category) && category.matches(getJavaProject()); >+ } >+ >+ private IJavaProject getJavaProject() { >+ return EditorUtility.getJavaProject(fEditor.getEditorInput()); >+ } >+ >+ /* > * @see org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor#filterAndSort(java.util.List, org.eclipse.core.runtime.IProgressMonitor) > */ > @Override
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
Flags:
daniel_megert
:
iplog+
daniel_megert
:
review+
Actions:
View
|
Diff
Attachments on
bug 345213
:
197893
|
208826
|
208827
| 208966