View | Details | Raw Unified | Return to bug 119603
Collapse All | Expand All

(-)ui/org/eclipse/jdt/ui/text/java/AbstractProposalFilter.java (+67 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.ui.text.java;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
15
import org.eclipse.jface.text.contentassist.ICompletionProposal;
16
17
/**
18
 * Abstract base class for filters contributed to the
19
 * <code>org.eclipse.jdt.ui.javaCompletionProposalFilters</code> extension point.
20
 * <p>
21
 * Subclasses need to implement {@link #filter(ICompletionProposal)} and may override
22
 * {@link #beginFiltering(ContentAssistInvocationContext) beginFiltering} and
23
 * {@link #endFiltering() endFiltering}.
24
 * </p>
25
 * 
26
 * @since 3.2
27
 */
28
public abstract class AbstractProposalFilter {
29
	
30
	/**
31
	 * Creates a new filter. Note that subclasses must provide a zero-argument constructor to be
32
	 * instantiatable via {@link IConfigurationElement#createExecutableExtension(String)}.
33
	 */
34
	protected AbstractProposalFilter() {
35
	}
36
37
	/**
38
	 * Called once before the content assist session.
39
	 * <p>
40
	 * Clients may override, the default implementation does nothing.
41
	 * </p>
42
	 * 
43
	 * @param context the context of the content assist invocation
44
	 */
45
	public void beginFiltering(ContentAssistInvocationContext context) {
46
	}
47
	
48
	/**
49
	 * Called once after the content assist session.
50
	 * <p>
51
	 * Clients may override, the default implementation does nothing.
52
	 * </p>
53
	 */
54
	public void endFiltering() {
55
	}
56
	
57
	/**
58
	 * Returns <code>true</code> if a proposal is filtered, i.e. should not be displayed,
59
	 * <code>false</code> if it passes the filter.
60
	 * 
61
	 * @param proposal the proposal to be filtered
62
	 * @return <code>true</code> to filter (remove) <code>proposal</code>, <code>false</code>
63
	 *         to let it pass
64
	 */
65
	public abstract boolean filter(ICompletionProposal proposal);
66
67
}
(-)ui/org/eclipse/jdt/ui/text/java/AbstractProposalSorter.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.ui.text.java;
12
13
import java.util.Comparator;
14
15
import org.eclipse.core.runtime.IConfigurationElement;
16
17
import org.eclipse.jface.text.contentassist.ICompletionProposal;
18
19
/**
20
 * Abstract base class for sorters contributed to the
21
 * <code>org.eclipse.jdt.ui.javaCompletionProposalFilters</code> extension point.
22
 * <p>
23
 * Subclasses need to implement {@link #compare(ICompletionProposal, ICompletionProposal)} and may
24
 * override {@link #beginSorting(ContentAssistInvocationContext) beginSorting} and
25
 * {@link #endSorting() endSorting}.
26
 * </p>
27
 * 
28
 * @since 3.2
29
 */
30
public abstract class AbstractProposalSorter implements Comparator {
31
	
32
	/**
33
	 * Creates a new sorter. Note that subclasses must provide a zero-argument constructor to be
34
	 * instantiatable via {@link IConfigurationElement#createExecutableExtension(String)}.
35
	 */
36
	protected AbstractProposalSorter() {
37
	}
38
39
	/**
40
	 * This method may be removed if the class is ever converted to extend
41
	 * <code>Comparator&lt;ICompletionProposal&gt;</code>.
42
	 * 
43
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
44
	 */
45
	public final int compare(Object o1, Object o2) {
46
		ICompletionProposal p1= (ICompletionProposal) o1;
47
		ICompletionProposal p2= (ICompletionProposal) o2;
48
		
49
		return compare(p1, p2);
50
	}
51
	
52
	/**
53
	 * Called once before the content assist session.
54
	 * <p>
55
	 * Clients may override, the default implementation does nothing.
56
	 * </p>
57
	 * 
58
	 * @param context the context of the content assist invocation
59
	 */
60
	public void beginSorting(ContentAssistInvocationContext context) {
61
	}
62
	
63
	/**
64
	 * Called once after the content assist session.
65
	 * <p>
66
	 * Clients may override, the default implementation does nothing.
67
	 * </p>
68
	 */
69
	public void endSorting() {
70
	}
71
	
72
	/**
73
	 * Implements the same contract as {@link Comparator#compare(Object, Object)} but with
74
	 * completion proposals as parameters.
75
	 * 
76
	 * @param p1 the first proposal to be compared
77
	 * @param p2 the second proposal to be compared
78
	 * @return a negative integer, zero, or a positive integer as the first argument is less than,
79
	 *         equal to, or greater than the second.
80
	 */
81
	public abstract int compare(ICompletionProposal p1, ICompletionProposal p2);
82
}
(-)schema/javaCompletionProposalFilters.exsd (+187 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.jdt.ui">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.jdt.ui" id="javaCompletionProposalFilters" name="Java Completion Proposal Filters and Sorters"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point allows to contribute sorters and filters that may modify the completion proposals displayed in the Java editor.
10
&lt;p&gt;XXX this API is provisional and may change anytime during the course of 3.2&lt;/p&gt;
11
      </documentation>
12
   </annotation>
13
14
   <element name="extension">
15
      <annotation>
16
         <appInfo>
17
            <meta.element labelAttribute="name"/>
18
         </appInfo>
19
      </annotation>
20
      <complexType>
21
         <choice>
22
            <element ref="proposalSorter"/>
23
            <element ref="proposalFilter"/>
24
         </choice>
25
         <attribute name="point" type="string" use="required">
26
            <annotation>
27
               <documentation>
28
                  The fully qualified identifier of the target extension point.
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="id" type="string">
33
            <annotation>
34
               <documentation>
35
                  The identifier of the extension instance, unique within the declaring plug-in (the plug-in&apos;s identifier will be prepended to form a platform-wide unique id).
36
               </documentation>
37
            </annotation>
38
         </attribute>
39
         <attribute name="name" type="string">
40
            <annotation>
41
               <documentation>
42
                  The optional name of the extension instance.
43
               </documentation>
44
               <appInfo>
45
                  <meta.attribute translatable="true"/>
46
               </appInfo>
47
            </annotation>
48
         </attribute>
49
      </complexType>
50
   </element>
51
52
   <element name="proposalSorter">
53
      <annotation>
54
         <appInfo>
55
            <meta.element labelAttribute="name"/>
56
         </appInfo>
57
         <documentation>
58
            A proposal sorter contribution.
59
         </documentation>
60
      </annotation>
61
      <complexType>
62
         <attribute name="id" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  The unique identifier of the sorter.
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
         <attribute name="name" type="string">
70
            <annotation>
71
               <documentation>
72
                  The name of the sorter.
73
               </documentation>
74
               <appInfo>
75
                  <meta.attribute translatable="true"/>
76
               </appInfo>
77
            </annotation>
78
         </attribute>
79
         <attribute name="class" type="string" use="required">
80
            <annotation>
81
               <documentation>
82
                  The name of the class that implements the contributed sorter. The
83
class must be a public implementation of
84
&lt;samp&gt;java.util.Comparator&lt;/samp&gt;
85
and must have a public 0-argument constructor.
86
&lt;p&gt;
87
The sorter&apos;s &lt;tt&gt;compare(Object, Object)&lt;/tt&gt; method will only be called with instances of &lt;code&gt;org.eclipse.jface.text.contentassist.ICompletionProposal&lt;/code&gt;.
88
&lt;/p&gt;
89
               </documentation>
90
               <appInfo>
91
                  <meta.attribute kind="java"/>
92
               </appInfo>
93
            </annotation>
94
         </attribute>
95
      </complexType>
96
   </element>
97
98
   <element name="proposalFilter">
99
      <annotation>
100
         <appInfo>
101
            <meta.element labelAttribute="name"/>
102
         </appInfo>
103
         <documentation>
104
            A proposal filter contribution.
105
         </documentation>
106
      </annotation>
107
      <complexType>
108
         <attribute name="id" type="string" use="required">
109
            <annotation>
110
               <documentation>
111
                  The unique identifier of the filter.
112
               </documentation>
113
            </annotation>
114
         </attribute>
115
         <attribute name="name" type="string">
116
            <annotation>
117
               <documentation>
118
                  The name of the filter.
119
               </documentation>
120
               <appInfo>
121
                  <meta.attribute translatable="true"/>
122
               </appInfo>
123
            </annotation>
124
         </attribute>
125
         <attribute name="class" type="string" use="required">
126
            <annotation>
127
               <documentation>
128
                  The name of the class that implements the contributed sorter. The
129
class must be a public implementation of
130
&lt;samp&gt;java.util.Comparator&lt;/samp&gt;
131
and must have a public 0-argument constructor.
132
               </documentation>
133
               <appInfo>
134
                  <meta.attribute kind="java"/>
135
               </appInfo>
136
            </annotation>
137
         </attribute>
138
      </complexType>
139
   </element>
140
141
   <annotation>
142
      <appInfo>
143
         <meta.section type="since"/>
144
      </appInfo>
145
      <documentation>
146
         3.2
147
      </documentation>
148
   </annotation>
149
150
   <annotation>
151
      <appInfo>
152
         <meta.section type="examples"/>
153
      </appInfo>
154
      <documentation>
155
         
156
      </documentation>
157
   </annotation>
158
159
   <annotation>
160
      <appInfo>
161
         <meta.section type="apiInfo"/>
162
      </appInfo>
163
      <documentation>
164
         [Enter API information here.]
165
      </documentation>
166
   </annotation>
167
168
   <annotation>
169
      <appInfo>
170
         <meta.section type="implementation"/>
171
      </appInfo>
172
      <documentation>
173
         [Enter information about supplied implementation of this extension point.]
174
      </documentation>
175
   </annotation>
176
177
   <annotation>
178
      <appInfo>
179
         <meta.section type="copyright"/>
180
      </appInfo>
181
      <documentation>
182
         Copyright (c) 2006 IBM Corporation and others.&lt;br&gt;
183
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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
184
      </documentation>
185
   </annotation>
186
187
</schema>

Return to bug 119603