1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

2005-01-20

PR 82964
	* icons/full/cview16/view_menu.gif
	* src/org/eclipse/cdt/internal.ui/CPluginImages.java
	* src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
	* src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
	* src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
	* src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
	* src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
	* src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
	* src/org/eclipse/cdt/internal/ui/text/contenassist/CCompletionProcessor.java
This commit is contained in:
Alain Magloire 2005-01-20 22:10:45 +00:00
parent d36d5364f7
commit 5cf93d3112
10 changed files with 265 additions and 57 deletions

View file

@ -1,3 +1,15 @@
2005-01-20
PR 82964
* icons/full/cview16/view_menu.gif
* src/org/eclipse/cdt/internal.ui/CPluginImages.java
* src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
* src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
* src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
* src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
* src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
* src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
* src/org/eclipse/cdt/internal/ui/text/contenassist/CCompletionProcessor.java
2005-01-19 Alain Magloire
PR 83151
* src/org/eclipse/cdt/ui/CElementContentProvider.java

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

View file

@ -105,11 +105,13 @@ public class CPluginImages {
// build console
public static final String IMG_VIEW_BUILD = NAME_PREFIX + "buildconsole.gif"; //$NON-NLS-1$
public static final String IMG_VIEW_MENU = NAME_PREFIX + "view_menu.gif"; //$NON-NLS-1$
// unknow type
public static final String IMG_OBJS_UNKNOWN = NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_BUILD_CONSOLE = createManaged(T_VIEW, IMG_VIEW_BUILD);
public static final ImageDescriptor IMG_VIEW_MENU_DESC = createManaged(T_VIEW, IMG_VIEW_MENU);
public static final ImageDescriptor DESC_OBJS_VARIABLE= createManaged(T_OBJ, IMG_OBJS_VARIABLE);
public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
@ -182,7 +184,7 @@ public class CPluginImages {
public static final String IMG_TOOL_GOTO_PREV_ERROR= NAME_PREFIX + "prev_error_nav.gif"; //$NON-NLS-1$
public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif"; //$NON-NLS-1$
public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_SHOW_FIELDS= NAME_PREFIX + "fields_co.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
public static final String IMG_ACTION_SHOW_STATIC= NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$

View file

@ -280,3 +280,6 @@ ToggleLinkingAction.description=Link with active editor
IncludesGroupingAction.label=Group includes
IncludesGroupingAction.tooltip=Group includes statements
IncludesGroupingAction.description=Group includes statements
COutlineInformationControl.viewMenu.remember.label=Remember size and position
COutlineInformationControl.viewMenu.move.label=Move outline

View file

@ -65,10 +65,8 @@ public class CSourceViewer extends ProjectionViewer implements ITextViewerExtens
public void configure(SourceViewerConfiguration configuration)
{
super.configure(configuration);
System.out.println("Configuration...");
if (configuration instanceof CSourceViewerConfiguration)
{
System.out.println("configured");
fOutlinePresenter = ((CSourceViewerConfiguration) configuration).getOutlinePresenter(editor);
fOutlinePresenter.install(this);
}

View file

@ -30,8 +30,8 @@ public final class CCodeScanner extends AbstractCScanner {
/** Constants which are additionally colored. */
private static String[] fgConstants= { "NULL", "__DATE__", "__LINE__", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"__TIME__", "__FILE__", "__STDC__", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"bool", "TRUE", "FALSE"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"bool", "TRUE", "FALSE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"EXT_TEXT"}; //$NON-NLS-1$
/** Properties for tokens. */
private static String[] fgTokenProperties= {
ICColorConstants.C_KEYWORD,

View file

@ -25,6 +25,7 @@ public class COperatorRule extends SingleCharRule
{
return (ch == ';' || ch == '.' || ch == ':' || ch == '=' || ch == '-'
|| ch == '+' || ch == '\\' || ch == '*' || ch == '!' || ch == '%'
|| ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<');
|| ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<')
|| ch == '|';
}
}

View file

@ -1,13 +1,15 @@
/*
* COutlineInformationControl.java 2004-12-14 / 08:17:41
* $Revision: 1.1 $ $Date: 2004/12/14 18:46:19 $
* $Revision: 1.2 $ $Date: 2004/12/23 19:38:20 $
*
* @author P.Tomaszewski
*/
package org.eclipse.cdt.internal.ui.text;
import org.eclipse.cdt.internal.core.model.CElement;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
@ -16,7 +18,11 @@ import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
import org.eclipse.cdt.ui.CElementGrouping;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlExtension;
import org.eclipse.jface.text.IInformationControlExtension3;
@ -39,6 +45,8 @@ import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
@ -58,8 +66,12 @@ import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tracker;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@ -67,36 +79,35 @@ import org.eclipse.swt.widgets.TreeItem;
* Control which shows outline information in C/C++ editor. Based on
* AbstracInformationContol/JavaOutlineInformationControl from JDT.
*
* TODO: Bounds restoring, sorting.
* TODO: Sorting.
*
* @author P.Tomaszewski
*/
public class COutlineInformationControl implements IInformationControl,
IInformationControlExtension, IInformationControlExtension3 {
/** If this option is set, location is not restored. */
private static final String STORE_RESTORE_SIZE= "ENABLE_RESTORE_SIZE"; //$NON-NLS-1$
/** If this option is set, size is not restore. */
private static final String STORE_RESTORE_LOCATION= "ENABLE_RESTORE_LOCATION"; //$NON-NLS-1$
/** Border thickness in pixels. */
private static final int BORDER = 1;
/** Right margin in pixels. */
private static final int RIGHT_MARGIN = 3;
/** Minimum width set by setSizeConstrains to tree viewer. */
private static final int MIN_WIDTH = 300;
/** Source viewer which shows this control. */
CEditor fEditor;
/** Shell for this control. */
Shell fShell;
/** Control's composite. */
Composite fComposite;
/** Tree viewer used to display outline. */
TreeViewer fTreeViewer;
/** Text control for filter. */
private Text fFilterText;
Text fFilterText;
/** Content provider for tree control. */
IContentProvider fTreeContentProvider;
@ -105,25 +116,29 @@ public class COutlineInformationControl implements IInformationControl,
/** Control bounds. */
Rectangle fBounds;
/** Control trim. */
Rectangle fTrim;
/** Deactivation adapter. */
private Listener fDeactivateListener;
/** This prevents to notify listener when it is adding. */
boolean fIsDeactivationActive;
/** Deactivation adapter. */
private Listener fDeactivateListener;
/** Shell adapter, used for control deactivation. */
private ShellListener fShellListener;
/** Control adapter for shell, used in resize action. */
private ControlListener fControlListener;
/** Should outline be sorted. */
boolean fSort = true;
/** Tool bar displayed on the top of the outline. */
ToolBar fToolBar;
/** Composite for tool bar. */
private Composite fToolbarComposite;
/** Menu manager for options menu. */
private MenuManager fViewMenuManager;
/**
* Creates new outline control.
*
@ -142,7 +157,7 @@ public class COutlineInformationControl implements IInformationControl,
this.fEditor = editor;
createShell(parent, shellStyle);
createComposite();
createFilterText();
createToolbar();
createHorizontalSeparator();
createTreeeViewer(treeStyle);
}
@ -323,16 +338,27 @@ public class COutlineInformationControl implements IInformationControl,
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
*/
public boolean restoresLocation() {
// TODO: To implement.
return false;
return getSettings().getBoolean(STORE_RESTORE_LOCATION);
}
/**
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
*/
public boolean restoresSize() {
// TODO: To implement.
return false;
return getSettings().getBoolean(STORE_RESTORE_SIZE);
}
/**
* Returns view manager instance. If instance does not exit it is created.
* @return View manager.
*/
MenuManager getViewMenuManager() {
if (fViewMenuManager == null) {
fViewMenuManager= new MenuManager();
fViewMenuManager.add(new RememberBoundsAction());
fViewMenuManager.add(new MoveAction());
}
return fViewMenuManager;
}
/**
@ -363,7 +389,7 @@ public class COutlineInformationControl implements IInformationControl,
*
*/
private void createComposite() {
fComposite = new org.eclipse.swt.widgets.Composite(fShell, SWT.RESIZE);
fComposite = new Composite(fShell, SWT.RESIZE);
GridLayout layout = new GridLayout(1, false);
fComposite.setLayout(layout);
fComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -371,6 +397,7 @@ public class COutlineInformationControl implements IInformationControl,
/**
* Creates tree viewer control.
* @param treeStyle Tree style.
*/
private void createTreeeViewer(int treeStyle) {
final IWorkingCopyManager manager = CUIPlugin.getDefault()
@ -392,15 +419,38 @@ public class COutlineInformationControl implements IInformationControl,
tree.addMouseListener(createMouseListenerForTreeViewer());
}
/**
* Creates horizontal separator between filter text and outline.
*/
private void createHorizontalSeparator() {
Label separator = new Label(fComposite, SWT.SEPARATOR | SWT.HORIZONTAL
| SWT.LINE_DOT);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
/**
* Creates toolbar.
*/
private void createToolbar() {
fToolbarComposite = new Composite(fComposite, SWT.NONE);
final GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
fToolbarComposite.setLayout(layout);
fToolbarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
createFilterText();
createViewMenu();
}
/**
* Creates control for filter text.
*/
private void createFilterText() {
fFilterText = new Text(fComposite, SWT.NONE);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
GC gc = new GC(fComposite);
fFilterText = new Text(fToolbarComposite, SWT.NONE);
final GridData data = new GridData(GridData.FILL_HORIZONTAL);
final GC gc = new GC(fComposite);
gc.setFont(fComposite.getFont());
FontMetrics fontMetrics = gc.getFontMetrics();
final FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
@ -413,14 +463,43 @@ public class COutlineInformationControl implements IInformationControl,
}
/**
* Creates horizontal separator between filter text and outline.
* Creates view menu for toolbar. In this menu options will be displayed.
*/
private void createHorizontalSeparator() {
Label separator = new Label(fComposite, SWT.SEPARATOR | SWT.HORIZONTAL
| SWT.LINE_DOT);
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
private void createViewMenu() {
fToolBar= new ToolBar(fToolbarComposite, SWT.FLAT);
final ToolItem viewMenuButton= new ToolItem(fToolBar, SWT.PUSH, 0);
final GridData data= new GridData();
data.horizontalAlignment= GridData.END;
data.verticalAlignment= GridData.BEGINNING;
fToolBar.setLayoutData(data);
viewMenuButton.setImage(CPluginImages.get(CPluginImages.IMG_VIEW_MENU));
createSelectionListenerForOptions(viewMenuButton);
}
/**
* Creates selection listener for options.
* @param viewMenuButton Button to create selection adapter.
*/
private void createSelectionListenerForOptions(ToolItem viewMenuButton) {
viewMenuButton.addSelectionListener(new SelectionAdapter() {
/**
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
fIsDeactivationActive = false;
final Menu menu = getViewMenuManager().createContextMenu(fShell);
final Rectangle bounds = fToolBar.getBounds();
final Point topLeft = fShell.toDisplay(new Point(bounds.x, bounds.y + bounds.height));
menu.setLocation(topLeft.x, topLeft.y);
menu.setVisible(true);
}
});
}
/**
* Creates mouse listener for tree viewer.
*
@ -446,7 +525,10 @@ public class COutlineInformationControl implements IInformationControl,
fEditor.setSelection(selectedElement);
dispose();
}
fBounds = fComposite.getBounds();
if (fComposite != null && !fComposite.isDisposed())
{
fBounds = fComposite.getBounds();
}
}
}
};
@ -506,15 +588,14 @@ public class COutlineInformationControl implements IInformationControl,
/**
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
public void widgetSelected(SelectionEvent e) {
// Does not need implementation.
}
/**
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetDefaultSelected(
org.eclipse.swt.events.SelectionEvent e) {
public void widgetDefaultSelected(SelectionEvent e) {
final TreeItem[] selection = ((Tree) fTreeViewer.getControl())
.getSelection();
if (selection.length > 0) {
@ -535,6 +616,9 @@ public class COutlineInformationControl implements IInformationControl,
*/
private KeyListener createKeyListenerForTreeViewer() {
final KeyListener listener = new KeyListener() {
/**
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
*/
public void keyPressed(KeyEvent e) {
if (e.keyCode == 0x1B) // ESC
{
@ -542,6 +626,9 @@ public class COutlineInformationControl implements IInformationControl,
}
}
/**
* @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
*/
public void keyReleased(KeyEvent e) {
// Does not need implementation.
}
@ -562,8 +649,7 @@ public class COutlineInformationControl implements IInformationControl,
if (length > 0 && text.charAt(length - 1) != '*') {
text = text + '*';
}
((CContentOutlinerProvider) fTreeContentProvider)
.updateFilter(text);
((CContentOutlinerProvider) fTreeContentProvider).updateFilter(text);
}
};
return modifyListener;
@ -671,6 +757,21 @@ public class COutlineInformationControl implements IInformationControl,
};
}
/**
* Returns setting for this control.
* @return Settings.
*/
IDialogSettings getSettings() {
final String sectionName = "org.eclipse.jdt.internal.ui.text.QuickOutline"; //$NON-NLS-1$
IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null)
{
settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
}
return settings;
}
/**
*
* Border fill layout. Copied from AbstractInformationControl.
@ -729,18 +830,17 @@ public class COutlineInformationControl implements IInformationControl,
}
/**
* @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
* boolean)
* @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean)
*/
protected void layout(Composite composite, boolean flushCache) {
Control[] children = composite.getChildren();
Point minSize = new Point(composite.getClientArea().width,
final Control[] children = composite.getChildren();
final Point minSize = new Point(composite.getClientArea().width,
composite.getClientArea().height);
if (children != null) {
for (int i = 0; i < children.length; i++) {
Control child = children[i];
final Control child = children[i];
child.setSize(minSize.x - fBorderSize * 2, minSize.y
- fBorderSize * 2);
child.setLocation(fBorderSize, fBorderSize);
@ -812,4 +912,62 @@ public class COutlineInformationControl implements IInformationControl,
}
}
/**
* The view menu's Remember Size and Location action.
*/
private class RememberBoundsAction extends Action {
/**
* Creates new action.
*/
RememberBoundsAction() {
super(ActionMessages.getString("COutlineInformationControl.viewMenu.remember.label"), IAction.AS_CHECK_BOX); //$NON-NLS-1$
setChecked(getSettings().getBoolean(STORE_RESTORE_LOCATION));
}
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
final IDialogSettings settings = getSettings();
final boolean newValue = isChecked();
// store new value
settings.put(STORE_RESTORE_LOCATION, newValue);
settings.put(STORE_RESTORE_SIZE, newValue);
fIsDeactivationActive = true;
}
}
/**
*
* The view menu's Move action.
*
* @author P.Tomaszewski
*/
private class MoveAction extends Action {
/**
* Creates new action.
*/
MoveAction() {
super(ActionMessages.getString("COutlineInformationControl.viewMenu.move.label"), IAction.AS_PUSH_BUTTON); //$NON-NLS-1$
}
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
final Tracker tracker= new Tracker(fShell.getDisplay(), SWT.NONE);
tracker.setStippled(true);
final Rectangle[] r= new Rectangle[] { fFilterText.getShell().getBounds() };
tracker.setRectangles(r);
if (tracker.open()) {
fShell.setBounds(tracker.getRectangles()[0]);
}
}
}
}

View file

@ -14,6 +14,7 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IAutoIndentStrategy;
@ -54,7 +55,7 @@ public class CSourceViewerConfiguration extends SourceViewerConfiguration {
/** Key used to look up display tab width */
public final static String PREFERENCE_TAB_WIDTH= "org.eclipse.cdt.editor.tab.width"; //$NON-NLS-1$
private CTextTools fTextTools;
private CTextTools fTextTools;
private CEditor fEditor;
/**
@ -121,14 +122,15 @@ public class CSourceViewerConfiguration extends SourceViewerConfiguration {
*/
public IInformationPresenter getOutlinePresenter(CEditor editor)
{
final InformationPresenter presenter = new InformationPresenter(getOutlineContolCreator(editor));
presenter.setSizeConstraints(20, 20, true, false);
final IInformationControlCreator outlineControlCreator = getOutlineContolCreator(editor);
final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
final IInformationProvider provider = new CElementContentProvider(getEditor());
presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
presenter.setInformationProvider(provider, ICPartitions.C_MULTILINE_COMMENT);
presenter.setInformationProvider(provider, ICPartitions.C_SINGLE_LINE_COMMENT);
presenter.setInformationProvider(provider, ICPartitions.C_STRING);
presenter.setSizeConstraints(20, 20, true, false);
presenter.setRestoreInformationControlBounds(getSettings("outline_presenter_bounds"), true, true); //$NON-NLS-1$
return presenter;
}
@ -438,12 +440,25 @@ public class CSourceViewerConfiguration extends SourceViewerConfiguration {
{
int shellStyle= SWT.RESIZE;
int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
return new COutlineInformationControl(editor, parent, shellStyle, treeStyle);
return new COutlineInformationControl(editor, parent, shellStyle, treeStyle);
}
};
return conrolCreator;
}
/**
* Returns the settings for the given section.
*
* @param sectionName the section name
* @return the settings
*/
private IDialogSettings getSettings(String sectionName) {
IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null) {
settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
}
return settings;
}
}

View file

@ -10,6 +10,7 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
@ -32,8 +33,8 @@ import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IFunctionSummary;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
@ -315,7 +316,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
fCurrentSourceUnit = unit;
fTextViewer = viewer;
ArrayList completions = new ArrayList();
final List completions = new Vector();
if (fCurrentSourceUnit == null)
return null;
@ -327,12 +328,30 @@ public class CCompletionProcessor implements IContentAssistProcessor {
if (fCurrentCompletionNode != null) {
addProposalsFromSearch(fCurrentCompletionNode, completions);
addProposalsFromCompletionContributors(fCurrentCompletionNode, completions);
addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions);
addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions);
removeRepeatedProposals(completions);
return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]));
}
return null;
}
/**
* Removes duplicated proposals.
* @param completions Completions to check.
*/
private void removeRepeatedProposals(List completions) {
final int size = completions.size();
final ICompletionProposal[] proposalsToCheck = (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[size]);
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
if (proposalsToCheck[i].equals(proposalsToCheck[j])) {
completions.remove(proposalsToCheck[j]);
break;
}
}
}
}
private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){
if (completionNode == null)
return;