diff options
author | Markus Schorn | 2008-03-05 13:44:35 +0000 |
---|---|---|
committer | Markus Schorn | 2008-03-05 13:44:35 +0000 |
commit | a5f83b394c1705d04c5e2b640a5c9580c4fdfe46 (patch) | |
tree | 815263da61af19bc77e896169f30334fc75e3fbe | |
parent | bb5cead81a481be877fb0e9ea0711b36b82effe0 (diff) | |
download | org.eclipse.cdt-a5f83b394c1705d04c5e2b640a5c9580c4fdfe46.tar.gz org.eclipse.cdt-a5f83b394c1705d04c5e2b640a5c9580c4fdfe46.tar.xz org.eclipse.cdt-a5f83b394c1705d04c5e2b640a5c9580c4fdfe46.zip |
Open Element to show macro parameters, bug 209762.
4 files changed, 77 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java index 3e332433ccd..641b5ec24d8 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/IndexTypeInfo.java @@ -125,7 +125,16 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { */ public static IndexTypeInfo create(IIndex index, IIndexMacro macro) { final char[] name= macro.getNameCharArray(); - return new IndexTypeInfo(new String[] {new String(name)}, ICElement.C_MACRO, index); + final char[][] ps= macro.getParameterList(); + String[] params= null; + if (ps != null) { + params= new String[ps.length]; + int i=-1; + for (char[] p : ps) { + params[++i]= new String(p); + } + } + return new IndexTypeInfo(new String[] {new String(name)}, ICElement.C_MACRO, params, null, index); } private IndexTypeInfo(String[] fqn, IIndexFileLocation fileLocal, int elementType, IIndex index, String[] params, String returnType, ITypeReference reference) { @@ -412,10 +421,12 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { HashMap<IIndexFileLocation, IIndexFile> iflMap= new HashMap<IIndexFileLocation, IIndexFile>(); for (int i = 0; i < ibs.length; i++) { IIndexMacro macro= ibs[i]; - if (checkFile(iflMap, macro.getFile())) { - IndexTypeReference ref= createReference(macro); - if (ref != null) { - references.add(ref); + if (checkParameters(macro.getParameterList())) { + if (checkFile(iflMap, macro.getFile())) { + IndexTypeReference ref= createReference(macro); + if (ref != null) { + references.add(ref); + } } } } @@ -429,6 +440,21 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { return references.toArray(new IndexTypeReference[references.size()]); } + private boolean checkParameters(char[][] parameterList) { + if (parameterList == null) { + return params == null; + } + if (params == null || parameterList.length != params.length) { + return false; + } + for (int i = 0; i < parameterList.length; i++) { + if (!params[i].equals(new String(parameterList[i]))) { + return false; + } + } + return true; + } + /** * Makes sure that per file only refs from one IIndexFile object are taken. */ @@ -520,6 +546,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { return returnType; } + @Override public int hashCode() { final int prime = 31; int result = 1; @@ -532,6 +559,7 @@ public class IndexTypeInfo implements ITypeInfo, IFunctionInfo { /** * Type info objects are equal if they compute the same references. */ + @Override public boolean equals(Object obj) { if (this == obj) return true; diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java index 2cfed737828..4facfaefd31 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java @@ -73,6 +73,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { setPriority(Job.LONG); } + @Override public IStatus run(final IProgressMonitor monitor) { monitor.beginTask(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_inProgress, IProgressMonitor.UNKNOWN); final ITypeInfo[] elements= getElementsByPrefix(fCurrentPrefix, monitor); @@ -108,6 +109,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { fMonitor= monitor; } + @Override public void done(IJobChangeEvent event) { fDone= true; final Shell shell= getShell(); @@ -122,6 +124,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { } } + @Override public void running(final IJobChangeEvent event) { fDone= false; final Shell shell= getShell(); @@ -172,6 +175,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /* * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create() */ + @Override public void create() { super.create(); // trigger initial query @@ -181,6 +185,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /* * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#close() */ + @Override public boolean close() { fUpdateJob.cancel(); return super.close(); @@ -199,6 +204,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /* * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#setMatchEmptyString(boolean) */ + @Override public void setMatchEmptyString(boolean matchEmptyString) { super.setMatchEmptyString(matchEmptyString); fAllowEmptyString= matchEmptyString; @@ -219,6 +225,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /* * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#showLowLevelFilter() */ + @Override protected boolean showLowLevelFilter() { // the low-level filter is useless for us return false; @@ -227,6 +234,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /* * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite) */ + @Override public Control createDialogArea(Composite parent) { PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, fHelpContextId); return super.createDialogArea(parent); @@ -235,6 +243,7 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /* * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createLowerList(org.eclipse.swt.widgets.Composite) */ + @Override protected Table createLowerList(Composite parent) { Table table= super.createLowerList(parent); createProgressMonitorPart(parent); @@ -268,9 +277,10 @@ public class ElementSelectionDialog extends TypeSelectionDialog { if (monitor.isCanceled()) { return null; } - HashSet types = new HashSet(); + HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>(); if(prefix != null) { final IndexFilter filter= new IndexFilter() { + @Override public boolean acceptBinding(IBinding binding) throws CoreException { if (isVisibleType(IndexModelUtil.getElementType(binding))) { return IndexFilter.ALL_DECLARED.acceptBinding(binding); @@ -310,9 +320,10 @@ public class ElementSelectionDialog extends TypeSelectionDialog { CCorePlugin.log(ie); } } - return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]); + return types.toArray(new ITypeInfo[types.size()]); } + @Override protected final void setListElements(Object[] elements) { super.setListElements(elements); } @@ -320,14 +331,18 @@ public class ElementSelectionDialog extends TypeSelectionDialog { /** * @deprecated Unsupported */ + @Deprecated + @Override public void setElements(Object[] elements) { throw new UnsupportedOperationException(); } + @Override protected void handleEmptyList() { updateOkState(); } + @Override protected Text createFilterText(Composite parent) { final Text result = super.createFilterText(parent); Listener listener = new Listener() { diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java index 585649ca966..ad630f30084 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java @@ -69,6 +69,7 @@ public class TypeInfoLabelProvider extends LabelProvider { /* non java-doc * @see ILabelProvider#getText */ + @Override public String getText(Object element) { if (! (element instanceof ITypeInfo)) return super.getText(element); @@ -95,7 +96,7 @@ public class TypeInfoLabelProvider extends LabelProvider { } buf.append(qualifiedName.getFullyQualifiedName()); } - if (isSet(SHOW_PARAMETERS) && typeInfo.getCElementType() == ICElement.C_FUNCTION) { + if (isSet(SHOW_PARAMETERS) && typeInfo.getCElementType() == ICElement.C_FUNCTION || typeInfo.getCElementType() == ICElement.C_MACRO) { if (typeInfo instanceof IFunctionInfo) { IFunctionInfo functionInfo= (IFunctionInfo)typeInfo; String[] params= functionInfo.getParameters(); @@ -157,6 +158,7 @@ public class TypeInfoLabelProvider extends LabelProvider { /* non java-doc * @see ILabelProvider#getImage */ + @Override public Image getImage(Object element) { if (!(element instanceof ITypeInfo)) return super.getImage(element); diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java index 2e27320dcde..05075eb9fa4 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * 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 @@ -62,7 +62,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { private StringMatcher fNameMatcher = null; private StringMatcher[] fSegmentMatchers = null; private boolean fMatchGlobalNamespace = false; - private Collection fVisibleTypes = new HashSet(); + private Collection<Integer> fVisibleTypes = new HashSet<Integer>(); private boolean fShowLowLevelTypes = false; /* @@ -107,12 +107,12 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { fNameMatcher = fSegmentMatchers[fSegmentMatchers.length-1]; } - public void setVisibleTypes(Collection visibleTypes) { + public void setVisibleTypes(Collection<Integer> visibleTypes) { fVisibleTypes.clear(); fVisibleTypes.addAll(visibleTypes); } - public Collection getVisibleTypes() { + public Collection<Integer> getVisibleTypes() { return fVisibleTypes; } @@ -228,7 +228,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { // the filter matcher contains state information, must not be static private final TypeFilterMatcher fFilterMatcher = new TypeFilterMatcher(); - private Set fKnownTypes = new HashSet(ALL_TYPES.length); + private Set<Integer> fKnownTypes = new HashSet<Integer>(ALL_TYPES.length); private Text fTextWidget; private boolean fSelectFilterText = false; private FilteredList fNewFilteredList; @@ -296,7 +296,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* (non-Javadoc) * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#createFilterText(org.eclipse.swt.widgets.Composite) */ - protected Text createFilterText(Composite parent) { + @Override + protected Text createFilterText(Composite parent) { fTextWidget = super.createFilterText(parent); // create type checkboxes below filter text @@ -308,7 +309,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* (non-Javadoc) * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#createFilteredList(org.eclipse.swt.widgets.Composite) */ - protected FilteredList createFilteredList(Composite parent) { + @Override + protected FilteredList createFilteredList(Composite parent) { fNewFilteredList = super.createFilteredList(parent); fNewFilteredList.setFilterMatcher(fFilterMatcher); fNewFilteredList.setComparator(fStringComparator); @@ -316,7 +318,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { if (fNewFilteredList != null) { fNewFilteredList.getAccessible().addAccessibleListener( new AccessibleAdapter() { - public void getName(AccessibleEvent e) { + @Override + public void getName(AccessibleEvent e) { e.result = TypeInfoMessages.TypeSelectionDialog_upperLabel; } } @@ -328,6 +331,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* (non-Javadoc) * @see org.eclipse.jface.window.Window#create() */ + @Override public void create() { super.create(); if (fSelectFilterText) @@ -337,6 +341,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* * @see Window#close() */ + @Override public boolean close() { writeSettings(getDialogSettings()); return super.close(); @@ -345,6 +350,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) */ + @Override protected Control createContents(Composite parent) { readSettings(getDialogSettings()); return super.createContents(parent); @@ -400,6 +406,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { checkbox.setImage(icon); checkbox.setSelection(fFilterMatcher.getVisibleTypes().contains(fTypeObject)); checkbox.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (e.widget instanceof Button) { Button checkbox = (Button) e.widget; @@ -458,6 +465,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { checkbox.setText(name); checkbox.setSelection(fFilterMatcher.getShowLowLevelTypes()); checkbox.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { if (e.widget instanceof Button) { Button button = (Button) e.widget; @@ -614,6 +622,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* (non-Cdoc) * @see org.eclipse.jface.window.Window#getInitialSize() */ + @Override protected Point getInitialSize() { Point result = super.getInitialSize(); if (fSize != null) { @@ -629,6 +638,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* (non-Cdoc) * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point) */ + @Override protected Point getInitialLocation(Point initialSize) { Point result = super.getInitialLocation(initialSize); if (fLocation != null) { @@ -650,18 +660,20 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { /* * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult() */ + @Override protected void computeResult() { ITypeInfo selection = (ITypeInfo) getLowerSelectedElement(); if (selection == null) return; - List result = new ArrayList(1); + List<ITypeInfo> result = new ArrayList<ITypeInfo>(1); result.add(selection); setResult(result); } - public Object[] getFoldedElements(int index) { - ArrayList result= new ArrayList(); + @Override + public Object[] getFoldedElements(int index) { + ArrayList<IndexTypeInfo> result= new ArrayList<IndexTypeInfo>(); Object[] typeInfos= super.getFoldedElements(index); if (typeInfos != null) { for (int i = 0; i < typeInfos.length; i++) { @@ -674,7 +686,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector { return result.toArray(); } - private void addFoldedElements(IndexTypeInfo typeInfo, ArrayList result) { + private void addFoldedElements(IndexTypeInfo typeInfo, ArrayList<IndexTypeInfo> result) { ITypeReference[] refs= typeInfo.getReferences(); for (int i = 0; i < refs.length; i++) { result.add(new IndexTypeInfo(typeInfo, refs[i])); |