Lines 10-15
Link Here
|
10 |
import java.util.Iterator; |
10 |
import java.util.Iterator; |
11 |
import java.util.LinkedList; |
11 |
import java.util.LinkedList; |
12 |
import java.util.List; |
12 |
import java.util.List; |
|
|
13 |
import java.util.Vector; |
13 |
|
14 |
|
14 |
import org.eclipse.cdt.core.model.ICElement; |
15 |
import org.eclipse.cdt.core.model.ICElement; |
15 |
import org.eclipse.cdt.core.model.ITranslationUnit; |
16 |
import org.eclipse.cdt.core.model.ITranslationUnit; |
Lines 32-39
Link Here
|
32 |
import org.eclipse.cdt.ui.CUIPlugin; |
33 |
import org.eclipse.cdt.ui.CUIPlugin; |
33 |
import org.eclipse.cdt.ui.IFunctionSummary; |
34 |
import org.eclipse.cdt.ui.IFunctionSummary; |
34 |
import org.eclipse.cdt.ui.IWorkingCopyManager; |
35 |
import org.eclipse.cdt.ui.IWorkingCopyManager; |
35 |
import org.eclipse.cdt.ui.text.ICHelpInvocationContext; |
|
|
36 |
import org.eclipse.cdt.ui.text.ICCompletionProposal; |
36 |
import org.eclipse.cdt.ui.text.ICCompletionProposal; |
|
|
37 |
import org.eclipse.cdt.ui.text.ICHelpInvocationContext; |
37 |
import org.eclipse.core.resources.IProject; |
38 |
import org.eclipse.core.resources.IProject; |
38 |
import org.eclipse.jface.preference.IPreferenceStore; |
39 |
import org.eclipse.jface.preference.IPreferenceStore; |
39 |
import org.eclipse.jface.text.BadLocationException; |
40 |
import org.eclipse.jface.text.BadLocationException; |
Lines 315-321
Link Here
|
315 |
fCurrentSourceUnit = unit; |
316 |
fCurrentSourceUnit = unit; |
316 |
fTextViewer = viewer; |
317 |
fTextViewer = viewer; |
317 |
|
318 |
|
318 |
ArrayList completions = new ArrayList(); |
319 |
final List completions = new Vector(); |
319 |
|
320 |
|
320 |
if (fCurrentSourceUnit == null) |
321 |
if (fCurrentSourceUnit == null) |
321 |
return null; |
322 |
return null; |
Lines 327-338
Link Here
|
327 |
if (fCurrentCompletionNode != null) { |
328 |
if (fCurrentCompletionNode != null) { |
328 |
addProposalsFromSearch(fCurrentCompletionNode, completions); |
329 |
addProposalsFromSearch(fCurrentCompletionNode, completions); |
329 |
addProposalsFromCompletionContributors(fCurrentCompletionNode, completions); |
330 |
addProposalsFromCompletionContributors(fCurrentCompletionNode, completions); |
330 |
addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions); |
331 |
addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions); |
|
|
332 |
removeRepeatedProposals(completions); |
331 |
return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0])); |
333 |
return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0])); |
332 |
} |
334 |
} |
333 |
return null; |
335 |
return null; |
334 |
} |
336 |
} |
335 |
|
337 |
|
|
|
338 |
/** |
339 |
* Removes duplicated proposals. |
340 |
* @param completions Completions to check. |
341 |
*/ |
342 |
private void removeRepeatedProposals(List completions) { |
343 |
final int size = completions.size(); |
344 |
final ICompletionProposal[] proposalsToCheck = (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]); |
345 |
for (int i = 0; i < size; i++) { |
346 |
for (int j = i + 1; j < size; j++) { |
347 |
if (proposalsToCheck[i].equals(proposalsToCheck[j])) { |
348 |
completions.remove(proposalsToCheck[j]); |
349 |
} |
350 |
} |
351 |
} |
352 |
} |
353 |
|
336 |
private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){ |
354 |
private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){ |
337 |
if (completionNode == null) |
355 |
if (completionNode == null) |
338 |
return; |
356 |
return; |