### Eclipse Workspace Patch 1.0 #P org.eclipse.cdt.ui Index: src/org/eclipse/cdt/ui/CElementLabelProvider.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java,v retrieving revision 1.28 diff -u -r1.28 CElementLabelProvider.java --- src/org/eclipse/cdt/ui/CElementLabelProvider.java 7 Dec 2006 12:49:24 -0000 1.28 +++ src/org/eclipse/cdt/ui/CElementLabelProvider.java 2 Mar 2007 20:25:08 -0000 @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; /** @@ -99,7 +99,7 @@ fImageLabelProvider= new CElementImageProvider(); fFlags = flags; - fCElementLabelProvider= new CUILabelProvider(getTextFlags() | CElementLabels.TEMPLATE_PARAMETERS, getImageFlags()); + fCElementLabelProvider= new CUILabelProvider(getTextFlags() | CElementBaseLabels.TEMPLATE_PARAMETERS, getImageFlags()); } public String getText(Object element) { @@ -154,16 +154,16 @@ public int getTextFlags() { fTextFlags = 0; if (getFlag(SHOW_RETURN_TYPE)) { - fTextFlags |= CElementLabels.M_APP_RETURNTYPE; + fTextFlags |= CElementBaseLabels.M_APP_RETURNTYPE; } if (getFlag(SHOW_PARAMETERS)) { - fTextFlags |= CElementLabels.M_PARAMETER_TYPES; + fTextFlags |= CElementBaseLabels.M_PARAMETER_TYPES; } if (getFlag(SHOW_EXCEPTION)) { - fTextFlags |= CElementLabels.M_EXCEPTIONS; + fTextFlags |= CElementBaseLabels.M_EXCEPTIONS; } if (getFlag(SHOW_POST_QUALIFIED)) { - fTextFlags |= CElementLabels.M_POST_QUALIFIED; + fTextFlags |= CElementBaseLabels.M_POST_QUALIFIED; } return fTextFlags; } Index: src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java,v retrieving revision 1.14 diff -u -r1.14 CallHierarchyUI.java --- src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java 30 Jan 2007 15:00:23 -0000 1.14 +++ src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java 2 Mar 2007 20:25:07 -0000 @@ -39,7 +39,7 @@ import org.eclipse.cdt.internal.ui.actions.OpenActionUtil; import org.eclipse.cdt.internal.ui.util.ExceptionHandler; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.IndexUI; public class CallHierarchyUI { @@ -82,7 +82,7 @@ } elem = OpenActionUtil.selectCElement(input, window.getShell(), CHMessages.CallHierarchyUI_label, CHMessages.CallHierarchyUI_selectMessage, - CElementLabels.ALL_DEFAULT | CElementLabels.MF_POST_FILE_QUALIFIED, 0); + CElementBaseLabels.ALL_DEFAULT | CElementBaseLabels.MF_POST_FILE_QUALIFIED, 0); break; } if (elem != null) { Index: src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java,v retrieving revision 1.5 diff -u -r1.5 CHLabelProvider.java --- src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java 11 Sep 2006 13:46:19 -0000 1.5 +++ src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java 2 Mar 2007 20:25:07 -0000 @@ -28,13 +28,13 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor; public class CHLabelProvider extends LabelProvider implements IColorProvider { - private final static int LABEL_OPTIONS_SIMPLE= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES; - private final static int LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED; + private final static int LABEL_OPTIONS_SIMPLE= CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES; + private final static int LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementBaseLabels.MF_POST_FILE_QUALIFIED; private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, 0); private CHContentProvider fContentProvider; Index: src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java,v retrieving revision 1.14 diff -u -r1.14 CHViewPart.java --- src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java 1 Feb 2007 16:50:44 -0000 1.14 +++ src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java 2 Mar 2007 20:25:07 -0000 @@ -73,7 +73,7 @@ import org.eclipse.cdt.internal.ui.util.CoreUtility; import org.eclipse.cdt.internal.ui.util.Messages; import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener; import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator; @@ -624,7 +624,7 @@ String format, scope, label; // label - label= CElementLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS); + label= CElementBaseLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS); // scope IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet(); @@ -687,7 +687,7 @@ final ICElement element= node.getRepresentedDeclaration(); if (element != null) { String label= Messages.format(CHMessages.CHViewPart_FocusOn_label, - CElementLabels.getTextLabel(element, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES)); + CElementBaseLabels.getTextLabel(element, CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES)); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) { public void run() { setInput(element); Index: src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java,v retrieving revision 1.2 diff -u -r1.2 CHHistoryAction.java --- src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java 24 Aug 2006 14:15:36 -0000 1.2 +++ src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java 2 Mar 2007 20:25:07 -0000 @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; /** @@ -25,9 +25,9 @@ */ public class CHHistoryAction extends Action { final static int LABEL_OPTIONS= - CElementLabels.M_PARAMETER_TYPES | - CElementLabels.ALL_FULLY_QUALIFIED | - CElementLabels.MF_POST_FILE_QUALIFIED; + CElementBaseLabels.M_PARAMETER_TYPES | + CElementBaseLabels.ALL_FULLY_QUALIFIED | + CElementBaseLabels.MF_POST_FILE_QUALIFIED; private CHViewPart fViewPart; private ICElement fElement; @@ -37,7 +37,7 @@ fViewPart= viewPart; fElement= element; - String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS); + String elementName= CElementBaseLabels.getElementLabel(element, LABEL_OPTIONS); setText(elementName); setImageDescriptor(getImageDescriptor(element)); } Index: src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java,v retrieving revision 1.2 diff -u -r1.2 IBHistoryListAction.java --- src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java 5 Jul 2006 12:58:04 -0000 1.2 +++ src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java 2 Mar 2007 20:25:07 -0000 @@ -30,7 +30,7 @@ import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter; @@ -66,7 +66,7 @@ } }; - CUILabelProvider labelProvider= new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS); + CUILabelProvider labelProvider= new CUILabelProvider(CElementBaseLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS); fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label); Index: src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java,v retrieving revision 1.1 diff -u -r1.1 IBHistoryAction.java --- src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java 5 Jul 2006 09:55:06 -0000 1.1 +++ src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java 2 Mar 2007 20:25:07 -0000 @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; /** @@ -33,7 +33,7 @@ fViewPart= viewPart; fElement= element; - String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED); + String elementName= CElementBaseLabels.getElementLabel(element, CElementBaseLabels.ALL_POST_QUALIFIED); setText(elementName); setImageDescriptor(getImageDescriptor(element)); } Index: src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java,v retrieving revision 1.5 diff -u -r1.5 THLabelProvider.java --- src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java 30 Jan 2007 15:00:22 -0000 1.5 +++ src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java 2 Mar 2007 20:25:08 -0000 @@ -27,13 +27,13 @@ import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor; public class THLabelProvider extends LabelProvider implements IColorProvider { - private final static int LABEL_OPTIONS_SIMPLE= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES; - private final static int LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED; + private final static int LABEL_OPTIONS_SIMPLE= CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES; + private final static int LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementBaseLabels.MF_POST_FILE_QUALIFIED; private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, 0); private THHierarchyModel fModel; Index: src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java,v retrieving revision 1.10 diff -u -r1.10 THViewPart.java --- src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java 1 Feb 2007 16:50:45 -0000 1.10 +++ src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java 2 Mar 2007 20:25:08 -0000 @@ -88,7 +88,7 @@ import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener; import org.eclipse.cdt.internal.ui.viewsupport.SelectionProviderMediator; @@ -118,8 +118,8 @@ private static final int ORIENTATION_SINGLE = 3; // options for label provider - private static final int MEMBER_LABEL_OPTIONS_SIMPLE = CElementLabels.M_PARAMETER_TYPES; - private static final int MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE | CElementLabels.ALL_POST_QUALIFIED; + private static final int MEMBER_LABEL_OPTIONS_SIMPLE = CElementBaseLabels.M_PARAMETER_TYPES; + private static final int MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE | CElementBaseLabels.ALL_POST_QUALIFIED; private static final int MEMBER_ICON_OPTIONS = CElementImageProvider.OVERLAY_ICONS; // state information @@ -380,7 +380,7 @@ if (hierarchyView && !elem.equals(fModel.getInput())) { String label= MessageFormat.format(Messages.THViewPart_FocusOn, new Object[] { - CElementLabels.getTextLabel(elem, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES) + CElementBaseLabels.getTextLabel(elem, CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES) }); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) { public void run() { @@ -823,7 +823,7 @@ String label; // label - label= CElementLabels.getElementLabel(elem, 0); + label= CElementBaseLabels.getElementLabel(elem, 0); // scope IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet(); @@ -841,7 +841,7 @@ if (node != null) { elem= node.getElement(); if (elem != null) { - label= CElementLabels.getElementLabel(elem, 0); + label= CElementBaseLabels.getElementLabel(elem, 0); image= fHierarchyLabelProvider.getImage(elem); } } Index: src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java,v retrieving revision 1.2 diff -u -r1.2 THHistoryAction.java --- src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java 25 Jan 2007 16:31:03 -0000 1.2 +++ src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java 2 Mar 2007 20:25:08 -0000 @@ -17,7 +17,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; /** @@ -25,9 +25,9 @@ */ public class THHistoryAction extends Action { final static int LABEL_OPTIONS= - CElementLabels.M_PARAMETER_TYPES | - CElementLabels.ALL_FULLY_QUALIFIED | - CElementLabels.MF_POST_FILE_QUALIFIED; + CElementBaseLabels.M_PARAMETER_TYPES | + CElementBaseLabels.ALL_FULLY_QUALIFIED | + CElementBaseLabels.MF_POST_FILE_QUALIFIED; private THViewPart fViewPart; private ICElement fElement; @@ -37,7 +37,7 @@ fViewPart= hierarchyView; fElement= element; - String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS); + String elementName= CElementBaseLabels.getElementLabel(element, LABEL_OPTIONS); setText(elementName); setImageDescriptor(getImageDescriptor(element)); } Index: src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties,v retrieving revision 1.31 diff -u -r1.31 CSearchMessages.properties --- src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties 25 Aug 2006 01:46:32 -0000 1.31 +++ src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties 2 Mar 2007 20:25:08 -0000 @@ -107,9 +107,9 @@ HierarchyScope= Hierarchy - {0} ProjectScope = Project -CElementLabels.concat_string=\ -\ -CElementLabels.comma_string=,\ -CElementLabels.declseparator_string=\ :\ +CElementBaseLabels.concat_string=\ -\ +CElementBaseLabels.comma_string=,\ +CElementBaseLabels.declseparator_string=\ :\ CSearchResultCollector.4=IMatchObject CSearchQuery.searchfor_references=Search for References Index: src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java,v retrieving revision 1.6 diff -u -r1.6 StatusBarUpdater.java --- src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java 7 Dec 2006 12:49:24 -0000 1.6 +++ src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java 2 Mar 2007 20:25:08 -0000 @@ -12,6 +12,8 @@ import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; + import org.eclipse.cdt.internal.ui.CUIMessages; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; @@ -27,9 +29,9 @@ */ public class StatusBarUpdater implements ISelectionChangedListener { - private final int LABEL_FLAGS= CElementLabels.DEFAULT_QUALIFIED | CElementLabels.ROOT_POST_QUALIFIED | CElementLabels.APPEND_ROOT_PATH | - CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.M_EXCEPTIONS | - CElementLabels.F_APP_TYPE_SIGNATURE; + private final int LABEL_FLAGS= CElementBaseLabels.DEFAULT_QUALIFIED | CElementBaseLabels.ROOT_POST_QUALIFIED | CElementBaseLabels.APPEND_ROOT_PATH | + CElementBaseLabels.M_PARAMETER_TYPES | CElementBaseLabels.M_APP_RETURNTYPE | CElementBaseLabels.M_EXCEPTIONS | + CElementBaseLabels.F_APP_TYPE_SIGNATURE; private IStatusLineManager fStatusLineManager; @@ -65,13 +67,13 @@ } private String formatCElementMessage(ICElement element) { - return CElementLabels.getElementLabel(element, LABEL_FLAGS); + return CElementBaseLabels.getElementLabel(element, LABEL_FLAGS); } private String formatResourceMessage(IResource element) { IContainer parent= element.getParent(); if (parent != null && parent.getType() != IResource.ROOT) - return element.getName() + CElementLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString(); + return element.getName() + CElementBaseLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString(); return element.getName(); } Index: src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java,v retrieving revision 1.7 diff -u -r1.7 CUILabelProvider.java --- src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java 21 Feb 2007 12:26:56 -0000 1.7 +++ src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java 2 Mar 2007 20:25:08 -0000 @@ -23,6 +23,7 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.cdt.core.model.IInclude; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.ui.CUIPlugin; public class CUILabelProvider extends LabelProvider implements IColorProvider { @@ -40,11 +41,11 @@ * Creates a new label provider with default flags. */ public CUILabelProvider() { - this(CElementLabels.M_PARAMETER_TYPES, CElementImageProvider.OVERLAY_ICONS); + this(CElementBaseLabels.M_PARAMETER_TYPES, CElementImageProvider.OVERLAY_ICONS); } /** - * @param textFlags Flags defined in CElementLabels. + * @param textFlags Flags defined in CElementBaseLabels. * @param imageFlags Flags defined in CElementImageProvider. */ public CUILabelProvider(int textFlags, int imageFlags) { @@ -154,7 +155,7 @@ * @see ILabelProvider#getText */ public String getText(Object element) { - String result= CElementLabels.getTextLabel(element, evaluateTextFlags(element)); + String result= CElementBaseLabels.getTextLabel(element, evaluateTextFlags(element)); if (result.length() == 0 && (element instanceof IStorage)) { result= fStorageLabelProvider.getText(element); } Index: src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java,v retrieving revision 1.19 diff -u -r1.19 CElementLabels.java --- src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java 9 Feb 2007 14:40:35 -0000 1.19 +++ src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java 2 Mar 2007 20:25:08 -0000 @@ -14,194 +14,18 @@ */ package org.eclipse.cdt.internal.ui.viewsupport; -import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.IBinary; -import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.IField; -import org.eclipse.cdt.core.model.IFunctionDeclaration; -import org.eclipse.cdt.core.model.IInheritance; -import org.eclipse.cdt.core.model.IMethodDeclaration; -import org.eclipse.cdt.core.model.ISourceRoot; -import org.eclipse.cdt.core.model.ITemplate; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.model.ITypeDef; -import org.eclipse.cdt.core.model.IVariableDeclaration; -import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; -import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; -import org.eclipse.cdt.internal.corext.util.CModelUtil; - -import org.eclipse.cdt.internal.ui.CUIMessages; +import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; /** * @author aniefer - * */ -public class CElementLabels { - - /** - * Method names contain parameter types. - * e.g. foo(int) - */ - public final static int M_PARAMETER_TYPES= 1 << 0; - - /** - * Method names contain thrown exceptions. - * e.g. foo throw( IOException ) - */ - public final static int M_EXCEPTIONS= 1 << 2; - - /** - * Method names contain return type (appended) - * e.g. foo : int - */ - public final static int M_APP_RETURNTYPE= 1 << 3; - - /** - * Method names contain return type (appended) - * e.g. int foo - */ - public final static int M_PRE_RETURNTYPE= 1 << 4; - - /** - * Method names are fully qualified. - * e.g. ClassName::size - */ - public final static int M_FULLY_QUALIFIED= 1 << 5; - - /** - * Method names are post qualified. - * e.g. size - ClassName - */ - public final static int M_POST_QUALIFIED= 1 << 6; - - /** - * Templates are qualified with template parameters. - * e.g. ClassName - */ - public final static int TEMPLATE_PARAMETERS= 1 << 7; - - /** - * Field names contain the declared type (appended) - * e.g. fHello: int - */ - public final static int F_APP_TYPE_SIGNATURE= 1 << 9; - - /** - * Field names contain the declared type (prepended) - * e.g. int fHello - */ - public final static int F_PRE_TYPE_SIGNATURE= 1 << 10; - - /** - * Fields names are fully qualified. - * e.g. ClassName::fField - */ - public final static int F_FULLY_QUALIFIED= 1 << 11; - - /** - * Fields names are post qualified. - * e.g. fField - ClassName - */ - public final static int F_POST_QUALIFIED= 1 << 12; - - /** - * Type names are fully qualified. - * e.g. namespace::ClassName - */ - public final static int T_FULLY_QUALIFIED= 1 << 13; - - /** - * Append base class specifications to type names. - * e.g. MyClass : public BaseClass - */ - public final static int T_INHERITANCE= 1 << 16; - - /** - * Translation unit names contain the full path. - * e.g. /MyProject/src/ClassName.cpp - */ - public final static int TU_QUALIFIED= 1 << 20; - - /** - * Translation unit names are post qualified with their path. - * e.g. ClassName.cpp - /MyProject/src - */ - public final static int TU_POST_QUALIFIED= 1 << 21; - - /** - * Source roots contain the project name (prepended). - * e.g. MyProject/src - */ - public final static int ROOT_QUALIFIED= 1 << 25; - - /** - * Source roots contain the project name (appended). - * e.g. src - MyProject - */ - public final static int ROOT_POST_QUALIFIED= 1 << 26; - - /** - * Add source root path. - * e.g. func() - MyProject/src - * Option only applies to getElementLabel - */ - public final static int APPEND_ROOT_PATH= 1 << 27; - - /** - * Prepend source root path. - * e.g. MyProject/src - func() - * Option only applies to getElementLabel - */ - public final static int PREPEND_ROOT_PATH= 1 << 28; - - /** - * Post qualify container project. For example - * folder - MyProject if the folder is in project MyProject. - */ - public final static int PROJECT_POST_QUALIFIED= 1 << 30; - - /** - * Post qualify symbols with file. - * e.g. func() - /proj/folder/file.cpp - */ - public final static int MF_POST_FILE_QUALIFIED= 1 << 31; - - /** - * Qualify all elements - */ - public final static int ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED | ROOT_QUALIFIED; - - /** - * Post qualify all elements - */ - public final static int ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED | ROOT_POST_QUALIFIED; - - /** - * Default options (M_PARAMETER_TYPES enabled) - */ - public final static int ALL_DEFAULT= M_PARAMETER_TYPES; - - /** - * Default qualify options (All except Root) - */ - public final static int DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED; - - /** - * Default post qualify options (All except Root) - */ - public final static int DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED; - - - public final static String CONCAT_STRING= CUIMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$ - public final static String COMMA_STRING = CUIMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$ - public final static String DECL_STRING = CUIMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$ +public class CElementLabels extends CElementBaseLabels { public static String getTextLabel(Object obj, int flags) { if (obj instanceof ICElement) { @@ -214,551 +38,4 @@ } return ""; //$NON-NLS-1$ } - - public static String getElementLabel(ICElement element, int flags) { - StringBuffer buf= new StringBuffer(60); - getElementLabel(element, flags, buf); - return buf.toString(); - } - - public static void getElementLabel(ICElement element, int flags, StringBuffer buf) { - int type= element.getElementType(); - ISourceRoot root= null; - - if (type != ICElement.C_MODEL && type != ICElement.C_PROJECT && !(type == ICElement.C_CCONTAINER && element instanceof ISourceRoot)) - root= CModelUtil.getSourceRoot(element); - if (root != null && getFlag(flags, PREPEND_ROOT_PATH)) { - getSourceRootLabel(root, ROOT_QUALIFIED, buf); - buf.append(CONCAT_STRING); - } - switch (type) { - case ICElement.C_METHOD : - case ICElement.C_METHOD_DECLARATION: - case ICElement.C_TEMPLATE_METHOD: - case ICElement.C_TEMPLATE_METHOD_DECLARATION: - getMethodLabel( (IMethodDeclaration) element, flags, buf ); - break; - case ICElement.C_FUNCTION: - case ICElement.C_FUNCTION_DECLARATION: - case ICElement.C_TEMPLATE_FUNCTION: - case ICElement.C_TEMPLATE_FUNCTION_DECLARATION: - getFunctionLabel( (IFunctionDeclaration) element, flags, buf); - break; - case ICElement.C_FIELD : - getFieldLabel( (IField) element, flags, buf ); - break; - case ICElement.C_VARIABLE: - case ICElement.C_VARIABLE_DECLARATION: - getVariableLabel( (IVariableDeclaration) element, flags, buf); - break; - case ICElement.C_CLASS: - case ICElement.C_STRUCT: - case ICElement.C_UNION: - case ICElement.C_ENUMERATION: - case ICElement.C_TEMPLATE_CLASS: - case ICElement.C_TEMPLATE_STRUCT: - case ICElement.C_TEMPLATE_UNION: - case ICElement.C_TEMPLATE_CLASS_DECLARATION: - case ICElement.C_TEMPLATE_STRUCT_DECLARATION: - case ICElement.C_TEMPLATE_UNION_DECLARATION: - getTypeLabel( element, flags, buf ); - break; - case ICElement.C_TYPEDEF: - getTypeDefLabel((ITypeDef)element, flags, buf); - break; - case ICElement.C_UNIT: - getTranslationUnitLabel((ITranslationUnit) element, flags, buf); - break; - case ICElement.C_CCONTAINER: - ICContainer container = (ICContainer) element; - if (container instanceof ISourceRoot) - getSourceRootLabel((ISourceRoot) container, flags, buf); - else - getContainerLabel(container, flags, buf); - break; - case ICElement.C_PROJECT: - case ICElement.C_MODEL: - buf.append(element.getElementName()); - break; - default: - buf.append(element.getElementName()); - } - - if (root != null && getFlag(flags, APPEND_ROOT_PATH)) { - buf.append(CONCAT_STRING); - getSourceRootLabel(root, ROOT_QUALIFIED, buf); - } - - if (element instanceof IBinary) { - IBinary bin = (IBinary)element; - buf.append(" - [" + bin.getCPU() + "/" + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - } - - } - - public static void getMethodLabel( IMethodDeclaration method, int flags, StringBuffer buf ) { - try { - //return type - if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) { - buf.append( method.getReturnType() ); - buf.append( ' ' ); - } - - //qualification - if( getFlag( flags, M_FULLY_QUALIFIED ) ){ - ICElement parent = method.getParent(); - if (parent != null && parent.exists() && !(parent instanceof ITranslationUnit)) { - getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); - buf.append( "::" ); //$NON-NLS-1$ - } - } - - buf.append( method.getElementName() ); - - //template parameters - if (method instanceof ITemplate) { - getTemplateParameters((ITemplate)method, flags, buf); - } - - //parameters - if( getFlag( flags, M_PARAMETER_TYPES ) ) { - buf.append('('); - - String[] types = method.getParameterTypes(); - - for (int i= 0; i < types.length; i++) { - if (i > 0) { - buf.append( COMMA_STRING ); - } - - if (types != null) { - buf.append( types[i] ); - } - } - buf.append(')'); - } - - //exceptions - if( getFlag( flags, M_EXCEPTIONS ) && method.exists() ){ - String [] types = method.getExceptions(); - if (types.length > 0) { - buf.append(" throw( "); //$NON-NLS-1$ - for (int i= 0; i < types.length; i++) { - if (i > 0) { - buf.append(COMMA_STRING); - } - buf.append( types[i] ); - } - buf.append( " )" ); //$NON-NLS-1$ - } - } - - if( getFlag( flags, M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor() && !method.isDestructor()) { - final String typeName= method.getReturnType(); - if (typeName != null && typeName.length() > 0) { - buf.append( DECL_STRING ); - buf.append(typeName); - } - } - - // post qualification - if( getFlag(flags, M_POST_QUALIFIED)) { - buf.append( CONCAT_STRING ); - getTypeLabel( method.getParent(), T_FULLY_QUALIFIED, buf ); - } - if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { - IPath path= method.getPath(); - if (path != null) { - buf.append( CONCAT_STRING ); - buf.append(path.toString()); - } - } - } catch (CModelException e) { - CUIPlugin.getDefault().log(e); - } - } - - private static void getTemplateParameters(ITemplate template, int flags, StringBuffer buf) { - if (getFlag(flags, TEMPLATE_PARAMETERS)) { - String[] types = template.getTemplateParameterTypes(); - buf.append('<'); - if (types != null) { - for (int i= 0; i < types.length; i++) { - if (i > 0) { - buf.append( ',' ); - } - buf.append( types[i] ); - } - } - buf.append('>'); - } - } - - public static void getFieldLabel(IField field, int flags, StringBuffer buf ) { - try { - //return type - if( getFlag( flags, F_PRE_TYPE_SIGNATURE ) && field.exists()) { - buf.append( field.getTypeName() ); - buf.append( ' ' ); - } - - //qualification - if( getFlag( flags, F_FULLY_QUALIFIED ) ){ - ICElement parent = field.getParent(); - if (parent != null && parent.exists()) { - getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); - buf.append( "::" ); //$NON-NLS-1$ - } - } - - buf.append( field.getElementName() ); - - if( getFlag( flags, F_APP_TYPE_SIGNATURE ) && field.exists()) { - buf.append( DECL_STRING ); - buf.append( field.getTypeName() ); - } - - // post qualification - if( getFlag(flags, F_POST_QUALIFIED)) { - buf.append( CONCAT_STRING ); - getTypeLabel( field.getParent(), T_FULLY_QUALIFIED, buf ); - } - if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { - IPath path= field.getPath(); - if (path != null) { - buf.append( CONCAT_STRING ); - buf.append(path.toString()); - } - } - } catch (CModelException e) { - CUIPlugin.getDefault().log(e); - } - } - - public static void getVariableLabel(IVariableDeclaration var, int flags, StringBuffer buf ) { - try { - //return type - if( getFlag( flags, F_PRE_TYPE_SIGNATURE ) && var.exists()) { - buf.append( var.getTypeName() ); - buf.append( ' ' ); - } - - //qualification - if( getFlag( flags, F_FULLY_QUALIFIED ) ){ - ICElement parent = var.getParent(); - if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { - getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); - buf.append( "::" ); //$NON-NLS-1$ - } - } - - buf.append( var.getElementName() ); - - if( getFlag( flags, F_APP_TYPE_SIGNATURE ) && var.exists()) { - buf.append( DECL_STRING ); - buf.append( var.getTypeName() ); - } - - // post qualification - if( getFlag(flags, F_POST_QUALIFIED)) { - ICElement parent = var.getParent(); - if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { - buf.append( CONCAT_STRING ); - getTypeLabel( var.getParent(), T_FULLY_QUALIFIED, buf ); - } - } - if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { - IPath path= var.getPath(); - if (path != null) { - buf.append( CONCAT_STRING ); - buf.append(path.toString()); - } - } - } catch (CModelException e) { - CUIPlugin.getDefault().log(e); - } - } - - public static void getFunctionLabel(IFunctionDeclaration func, int flags, StringBuffer buf) { - //return type - if( getFlag( flags, M_PRE_RETURNTYPE ) && func.exists()) { - buf.append( func.getReturnType() ); - buf.append( ' ' ); - } - - //qualification - if( getFlag( flags, M_FULLY_QUALIFIED ) ){ - ICElement parent = func.getParent(); - if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { - getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); - buf.append( "::" ); //$NON-NLS-1$ - } - } - - buf.append( func.getElementName() ); - - //template parameters - if (func instanceof ITemplate) { - getTemplateParameters((ITemplate)func, flags, buf); - } - - //parameters - if( getFlag( flags, M_PARAMETER_TYPES ) ) { - buf.append('('); - - String[] types = func.getParameterTypes(); - - for (int i= 0; i < types.length; i++) { - if (i > 0) { - buf.append( COMMA_STRING ); - } - - if (types != null) { - buf.append( types[i] ); - } - } - buf.append(')'); - } - - //exceptions - if( getFlag( flags, M_EXCEPTIONS ) && func.exists() ){ - String [] types = func.getExceptions(); - if (types.length > 0) { - buf.append(" throw( "); //$NON-NLS-1$ - for (int i= 0; i < types.length; i++) { - if (i > 0) { - buf.append(COMMA_STRING); - } - buf.append( types[i] ); - } - buf.append( " )" ); //$NON-NLS-1$ - } - } - - if( getFlag( flags, M_APP_RETURNTYPE ) && func.exists()) { - String typeName= func.getReturnType(); - if (typeName != null && typeName.length() > 0) { - buf.append( DECL_STRING ); - buf.append(typeName); - } - } - - // post qualification - if( getFlag(flags, M_POST_QUALIFIED)) { - ICElement parent = func.getParent(); - if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { - buf.append( CONCAT_STRING ); - getTypeLabel( func.getParent(), T_FULLY_QUALIFIED, buf ); - } - } - if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { - IPath path= func.getPath(); - if (path != null) { - buf.append( CONCAT_STRING ); - buf.append(path.toString()); - } - } - } - - public static void getTypeDefLabel(ITypeDef typedef, int flags, StringBuffer buf ) { - // type - if( getFlag( flags, F_PRE_TYPE_SIGNATURE ) && typedef.exists()) { - buf.append( typedef.getTypeName() ); - buf.append( ' ' ); - } - - //qualification - if( getFlag( flags, F_FULLY_QUALIFIED ) ){ - ICElement parent = typedef.getParent(); - if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { - getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); - buf.append( "::" ); //$NON-NLS-1$ - } - } - - buf.append( typedef.getElementName() ); - - if( getFlag( flags, F_APP_TYPE_SIGNATURE ) && typedef.exists()) { - String typeName= typedef.getTypeName(); - if (typeName != null && typeName.length() > 0) { - buf.append( DECL_STRING ); - buf.append(typeName); - } - } - - // post qualification - if( getFlag(flags, F_POST_QUALIFIED)) { - ICElement parent = typedef.getParent(); - if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { - buf.append( CONCAT_STRING ); - getTypeLabel( typedef.getParent(), T_FULLY_QUALIFIED, buf ); - } - } - if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { - IPath path= typedef.getPath(); - if (path != null) { - buf.append( CONCAT_STRING ); - buf.append(path.toString()); - } - } - } - - /** - * Appends the label for a source root to a StringBuffer. Considers the ROOT_* flags. - */ - public static void getSourceRootLabel(ISourceRoot root, int flags, StringBuffer buf) { - getFolderLabel(root, flags, buf); - } - - /** - * Appends the label for a container to a StringBuffer. Considers the ROOT_* flags. - */ - public static void getContainerLabel(ICContainer container, int flags, StringBuffer buf) { - getFolderLabel(container, flags, buf); - } - - private static void getFolderLabel(ICContainer container, int flags, StringBuffer buf) { - IResource resource= container.getResource(); - boolean rootQualified= getFlag(flags, ROOT_QUALIFIED); - boolean referencedQualified= getFlag(flags, PROJECT_POST_QUALIFIED) - && (container instanceof ISourceRoot && CModelUtil.isReferenced((ISourceRoot)container)) - && resource != null; - if (rootQualified) { - buf.append(container.getPath().makeRelative().toString()); - } else { - buf.append(container.getElementName()); - if (referencedQualified) { - buf.append(CONCAT_STRING); - buf.append(resource.getProject().getName()); - } else if (getFlag(flags, ROOT_POST_QUALIFIED)) { - buf.append(CONCAT_STRING); - buf.append(container.getParent().getElementName()); - } - } - } - - /** - * Appends the label for a translation unit to a StringBuffer. Considers the CU_* flags. - */ - public static void getTranslationUnitLabel(ITranslationUnit tu, int flags, StringBuffer buf) { - IResource r= tu.getResource(); - IPath path; - if (r != null) { - path= r.getFullPath().makeRelative(); - } - else { - path= tu.getPath(); - } - - if (path == null) { - buf.append(tu.getElementName()); - } - else { - if (getFlag(flags, TU_QUALIFIED)) { - buf.append(path.toString()); - } - else if (getFlag(flags, TU_POST_QUALIFIED)) { - buf.append(path.lastSegment()); - buf.append(CONCAT_STRING); - buf.append(path.removeLastSegments(1)); - } - else { - buf.append(path.lastSegment()); - } - } - } - - /** - * Appends the label for a type to a StringBuffer. Considers the T_* flags. - */ - public static void getTypeLabel(ICElement elem, int flags, StringBuffer buf) { - if (getFlag(flags, T_FULLY_QUALIFIED)) { - ICElement parent= elem.getParent(); - boolean isQualifier= true; - if (parent != null && parent.exists()) { - switch (parent.getElementType()) { - case ICElement.C_ARCHIVE: - case ICElement.C_BINARY: - case ICElement.C_CCONTAINER: - case ICElement.C_MODEL: - case ICElement.C_PROJECT: - case ICElement.C_UNIT: - case ICElement.C_VCONTAINER: - isQualifier= false; - break; - } - } - // types cannot be qualified in plain c - if (isQualifier && !isCLanguage(parent)) { - int qflags= flags & ~MF_POST_FILE_QUALIFIED; - getTypeLabel(parent, qflags, buf); - buf.append("::"); //$NON-NLS-1$ - } - } - - String typeName= elem.getElementName(); - if (typeName.length() == 0) { // anonymous - typeName = CUIMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$ - } - buf.append(typeName); - - if (getFlag(flags, T_INHERITANCE) && elem instanceof IInheritance) { - IInheritance inheritance= (IInheritance)elem; - String[] superclassNames= inheritance.getSuperClassesNames(); - if (superclassNames != null && superclassNames.length > 0) { - buf.append(DECL_STRING); - for (int i = 0; i < superclassNames.length; i++) { - if (i> 0) { - buf.append(COMMA_STRING); - } - String superclass = superclassNames[i]; - String visibility = getVisibility(inheritance.getSuperClassAccess(superclass)); - buf.append(visibility).append(' ').append(superclass); - } - } - } - - //template parameters - if (elem instanceof ITemplate) { - getTemplateParameters((ITemplate)elem, flags, buf); - } - - if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { - IPath path= elem.getPath(); - if (path != null) { - buf.append( CONCAT_STRING ); - buf.append(path.toString()); - } - } - } - - private static boolean isCLanguage(ICElement elem) { - while (elem != null) { - elem= elem.getParent(); - if (elem instanceof ITranslationUnit) { - return ((ITranslationUnit) elem).isCLanguage(); - } - } - return false; - } - - /** - * Convert an ASTAccessVisibility into its string representation. - * - * @param access - * @return "public", "protected" or "private" - */ - private static String getVisibility(ASTAccessVisibility access) { - if (access == ASTAccessVisibility.PUBLIC) { - return "public"; //$NON-NLS-1$ - } - if (access == ASTAccessVisibility.PROTECTED) { - return "protected"; //$NON-NLS-1$ - } - return "private"; //$NON-NLS-1$ - } - - private static boolean getFlag(int flags, int flag) { - return (flags & flag) != 0; - } } Index: src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java,v retrieving revision 1.8 diff -u -r1.8 AppearanceAwareLabelProvider.java --- src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java 22 Feb 2007 14:32:53 -0000 1.8 +++ src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java 2 Mar 2007 20:25:08 -0000 @@ -15,13 +15,15 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; + /** * CUILabelProvider that respects settings from the Appearance preference page. * Triggers a viewer update when a preference changes (currently none). */ public class AppearanceAwareLabelProvider extends CUILabelProvider implements IPropertyChangeListener { - public final static int DEFAULT_TEXTFLAGS= CElementLabels.M_PARAMETER_TYPES | CElementLabels.PROJECT_POST_QUALIFIED; + public final static int DEFAULT_TEXTFLAGS= CElementBaseLabels.M_PARAMETER_TYPES | CElementBaseLabels.PROJECT_POST_QUALIFIED; public final static int DEFAULT_IMAGEFLAGS= CElementImageProvider.OVERLAY_ICONS; private int fTextFlagMask; Index: src/org/eclipse/cdt/internal/ui/CUIMessages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties,v retrieving revision 1.25 diff -u -r1.25 CUIMessages.properties --- src/org/eclipse/cdt/internal/ui/CUIMessages.properties 24 Jan 2007 16:11:48 -0000 1.25 +++ src/org/eclipse/cdt/internal/ui/CUIMessages.properties 2 Mar 2007 20:25:07 -0000 @@ -81,10 +81,6 @@ StatusBarUpdater.num_elements_selected={0} items selected -CElementLabels.anonymous=(anon) -CElementLabels.concat_string=\ -\ -CElementLabels.comma_string=,\ -CElementLabels.declseparator_string=\ :\ CHelpConfigurationPropertyPage.buttonLabels.CheckAll=Check All CHelpConfigurationPropertyPage.buttonLabels.UncheckAll=Uncheck All CHelpConfigurationPropertyPage.HelpBooks=Help books Index: src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java,v retrieving revision 1.59 diff -u -r1.59 CContentOutlinePage.java --- src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java 19 Feb 2007 14:43:24 -0000 1.59 +++ src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java 2 Mar 2007 20:25:07 -0000 @@ -75,11 +75,11 @@ import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; public class CContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener { - private static final int TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE; + private static final int TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementBaseLabels.F_APP_TYPE_SIGNATURE | CElementBaseLabels.M_APP_RETURNTYPE; private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS; private CEditor fEditor; Index: src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java,v retrieving revision 1.5 diff -u -r1.5 OpenActionUtil.java --- src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java 1 Sep 2006 12:16:04 -0000 1.5 +++ src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java 2 Mar 2007 20:25:07 -0000 @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.internal.ui.util.EditorUtility; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider; import org.eclipse.cdt.ui.CElementLabelProvider; @@ -76,7 +76,7 @@ /** * Shows a dialog for resolving an ambigous C element. - * @see CElementLabels + * @see CElementBaseLabels * @param elements an array of ambigous elements. * @param shell parent shell for showing the dialog * @param title title of the dialog Index: src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java,v retrieving revision 1.9 diff -u -r1.9 COutlineInformationControl.java --- src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java 22 Feb 2007 14:32:53 -0000 1.9 +++ src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java 2 Mar 2007 20:25:08 -0000 @@ -35,7 +35,7 @@ import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider; import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; -import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels; +import org.eclipse.cdt.core.model.util.CElementBaseLabels; import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider; /** @@ -46,7 +46,7 @@ */ public class COutlineInformationControl extends AbstractInformationControl { - private static final int TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE; + private static final int TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementBaseLabels.F_APP_TYPE_SIGNATURE | CElementBaseLabels.M_APP_RETURNTYPE; private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS; private ICElement fInput = null; #P org.eclipse.cdt.core Index: model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties,v retrieving revision 1.8 diff -u -r1.8 CoreModelMessages.properties --- model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties 23 Feb 2007 20:05:30 -0000 1.8 +++ model/org/eclipse/cdt/internal/core/model/CoreModelMessages.properties 2 Mar 2007 20:25:17 -0000 @@ -79,5 +79,10 @@ PathEntryManager.1=Workspace include path inaccessible ({0}) PathEntryManager.7=Workspace library path inaccessible ({0}) +CElementBaseLabels.anonymous=(anon) +CElementBaseLabels.concat_string=\ -\ +CElementBaseLabels.comma_string=,\ +CElementBaseLabels.declseparator_string=\ :\ + CProjectDescriptionManager.startRcChangeHandling=Initiating resource change handling.. CProjectDescriptionManager.serializing=Serialing CDT Project settings.. Index: model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java =================================================================== RCS file: model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java diff -N model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,791 @@ +/******************************************************************************* + * Copyright (c) 2003, 2007 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corp. - Rational Software - initial implementation + * Markus Schorn (Wind River Systems) + *******************************************************************************/ +/* + * Created on Jun 24, 2003 + */ +package org.eclipse.cdt.core.model.util; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IField; +import org.eclipse.cdt.core.model.IFunctionDeclaration; +import org.eclipse.cdt.core.model.IInheritance; +import org.eclipse.cdt.core.model.IMethodDeclaration; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.ITemplate; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.model.ITypeDef; +import org.eclipse.cdt.core.model.IVariableDeclaration; +import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; +import org.eclipse.cdt.internal.core.model.CoreModelMessages; + +/** + * @author aniefer + * + */ +public class CElementBaseLabels { + + /** + * Method names contain parameter types. + * e.g. foo(int) + */ + public final static int M_PARAMETER_TYPES= 1 << 0; + + /** + * Method names contain thrown exceptions. + * e.g. foo throw( IOException ) + */ + public final static int M_EXCEPTIONS= 1 << 2; + + /** + * Method names contain return type (appended) + * e.g. foo : int + */ + public final static int M_APP_RETURNTYPE= 1 << 3; + + /** + * Method names contain return type (appended) + * e.g. int foo + */ + public final static int M_PRE_RETURNTYPE= 1 << 4; + + /** + * Method names are fully qualified. + * e.g. ClassName::size + */ + public final static int M_FULLY_QUALIFIED= 1 << 5; + + /** + * Method names are post qualified. + * e.g. size - ClassName + */ + public final static int M_POST_QUALIFIED= 1 << 6; + + /** + * Templates are qualified with template parameters. + * e.g. ClassName + */ + public final static int TEMPLATE_PARAMETERS= 1 << 7; + + /** + * Field names contain the declared type (appended) + * e.g. fHello: int + */ + public final static int F_APP_TYPE_SIGNATURE= 1 << 9; + + /** + * Field names contain the declared type (prepended) + * e.g. int fHello + */ + public final static int F_PRE_TYPE_SIGNATURE= 1 << 10; + + /** + * Fields names are fully qualified. + * e.g. ClassName::fField + */ + public final static int F_FULLY_QUALIFIED= 1 << 11; + + /** + * Fields names are post qualified. + * e.g. fField - ClassName + */ + public final static int F_POST_QUALIFIED= 1 << 12; + + /** + * Type names are fully qualified. + * e.g. namespace::ClassName + */ + public final static int T_FULLY_QUALIFIED= 1 << 13; + + /** + * Append base class specifications to type names. + * e.g. MyClass : public BaseClass + */ + public final static int T_INHERITANCE= 1 << 16; + + /** + * Translation unit names contain the full path. + * e.g. /MyProject/src/ClassName.cpp + */ + public final static int TU_QUALIFIED= 1 << 20; + + /** + * Translation unit names are post qualified with their path. + * e.g. ClassName.cpp - /MyProject/src + */ + public final static int TU_POST_QUALIFIED= 1 << 21; + + /** + * Source roots contain the project name (prepended). + * e.g. MyProject/src + */ + public final static int ROOT_QUALIFIED= 1 << 25; + + /** + * Source roots contain the project name (appended). + * e.g. src - MyProject + */ + public final static int ROOT_POST_QUALIFIED= 1 << 26; + + /** + * Add source root path. + * e.g. func() - MyProject/src + * Option only applies to getElementLabel + */ + public final static int APPEND_ROOT_PATH= 1 << 27; + + /** + * Prepend source root path. + * e.g. MyProject/src - func() + * Option only applies to getElementLabel + */ + public final static int PREPEND_ROOT_PATH= 1 << 28; + + /** + * Post qualify container project. For example + * folder - MyProject if the folder is in project MyProject. + */ + public final static int PROJECT_POST_QUALIFIED= 1 << 30; + + /** + * Post qualify symbols with file. + * e.g. func() - /proj/folder/file.cpp + */ + public final static int MF_POST_FILE_QUALIFIED= 1 << 31; + + /** + * Qualify all elements + */ + public final static int ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED | ROOT_QUALIFIED; + + /** + * Post qualify all elements + */ + public final static int ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED | ROOT_POST_QUALIFIED; + + /** + * Default options (M_PARAMETER_TYPES enabled) + */ + public final static int ALL_DEFAULT= M_PARAMETER_TYPES; + + /** + * Default qualify options (All except Root) + */ + public final static int DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED; + + /** + * Default post qualify options (All except Root) + */ + public final static int DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED; + + + public final static String CONCAT_STRING= CoreModelMessages.getString("CElementBaseLabels.concat_string"); // " - "; //$NON-NLS-1$ + public final static String COMMA_STRING = CoreModelMessages.getString("CElementBaseLabels.comma_string"); // ", "; //$NON-NLS-1$ + public final static String DECL_STRING = CoreModelMessages.getString("CElementBaseLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$ + + public static String getTextLabel(Object obj, int flags) { + if (obj instanceof ICElement) { + return getElementLabel((ICElement) obj, flags); + } + return ""; //$NON-NLS-1$ + } + + public static String getElementLabel(ICElement element, int flags) { + StringBuffer buf= new StringBuffer(60); + getElementLabel(element, flags, buf); + return buf.toString(); + } + + public static void getElementLabel(ICElement element, int flags, StringBuffer buf) { + int type= element.getElementType(); + ISourceRoot root= null; + + if (type != ICElement.C_MODEL && type != ICElement.C_PROJECT && !(type == ICElement.C_CCONTAINER && element instanceof ISourceRoot)) + root= getSourceRoot(element); + if (root != null && getFlag(flags, PREPEND_ROOT_PATH)) { + getSourceRootLabel(root, ROOT_QUALIFIED, buf); + buf.append(CONCAT_STRING); + } + switch (type) { + case ICElement.C_METHOD : + case ICElement.C_METHOD_DECLARATION: + case ICElement.C_TEMPLATE_METHOD: + case ICElement.C_TEMPLATE_METHOD_DECLARATION: + getMethodLabel( (IMethodDeclaration) element, flags, buf ); + break; + case ICElement.C_FUNCTION: + case ICElement.C_FUNCTION_DECLARATION: + case ICElement.C_TEMPLATE_FUNCTION: + case ICElement.C_TEMPLATE_FUNCTION_DECLARATION: + getFunctionLabel( (IFunctionDeclaration) element, flags, buf); + break; + case ICElement.C_FIELD : + getFieldLabel( (IField) element, flags, buf ); + break; + case ICElement.C_VARIABLE: + case ICElement.C_VARIABLE_DECLARATION: + getVariableLabel( (IVariableDeclaration) element, flags, buf); + break; + case ICElement.C_CLASS: + case ICElement.C_STRUCT: + case ICElement.C_UNION: + case ICElement.C_ENUMERATION: + case ICElement.C_TEMPLATE_CLASS: + case ICElement.C_TEMPLATE_STRUCT: + case ICElement.C_TEMPLATE_UNION: + case ICElement.C_TEMPLATE_CLASS_DECLARATION: + case ICElement.C_TEMPLATE_STRUCT_DECLARATION: + case ICElement.C_TEMPLATE_UNION_DECLARATION: + getTypeLabel( element, flags, buf ); + break; + case ICElement.C_TYPEDEF: + getTypeDefLabel((ITypeDef)element, flags, buf); + break; + case ICElement.C_UNIT: + getTranslationUnitLabel((ITranslationUnit) element, flags, buf); + break; + case ICElement.C_CCONTAINER: + ICContainer container = (ICContainer) element; + if (container instanceof ISourceRoot) + getSourceRootLabel((ISourceRoot) container, flags, buf); + else + getContainerLabel(container, flags, buf); + break; + case ICElement.C_PROJECT: + case ICElement.C_MODEL: + buf.append(element.getElementName()); + break; + default: + buf.append(element.getElementName()); + } + + if (root != null && getFlag(flags, APPEND_ROOT_PATH)) { + buf.append(CONCAT_STRING); + getSourceRootLabel(root, ROOT_QUALIFIED, buf); + } + + if (element instanceof IBinary) { + IBinary bin = (IBinary)element; + buf.append(" - [" + bin.getCPU() + "/" + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + } + + } + + public static void getMethodLabel( IMethodDeclaration method, int flags, StringBuffer buf ) { + try { + //return type + if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) { + buf.append( method.getReturnType() ); + buf.append( ' ' ); + } + + //qualification + if( getFlag( flags, M_FULLY_QUALIFIED ) ){ + ICElement parent = method.getParent(); + if (parent != null && parent.exists() && !(parent instanceof ITranslationUnit)) { + getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); + buf.append( "::" ); //$NON-NLS-1$ + } + } + + buf.append( method.getElementName() ); + + //template parameters + if (method instanceof ITemplate) { + getTemplateParameters((ITemplate)method, flags, buf); + } + + //parameters + if( getFlag( flags, M_PARAMETER_TYPES ) ) { + buf.append('('); + + String[] types = method.getParameterTypes(); + + for (int i= 0; i < types.length; i++) { + if (i > 0) { + buf.append( COMMA_STRING ); + } + + if (types != null) { + buf.append( types[i] ); + } + } + buf.append(')'); + } + + //exceptions + if( getFlag( flags, M_EXCEPTIONS ) && method.exists() ){ + String [] types = method.getExceptions(); + if (types.length > 0) { + buf.append(" throw( "); //$NON-NLS-1$ + for (int i= 0; i < types.length; i++) { + if (i > 0) { + buf.append(COMMA_STRING); + } + buf.append( types[i] ); + } + buf.append( " )" ); //$NON-NLS-1$ + } + } + + if( getFlag( flags, M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor() && !method.isDestructor()) { + final String typeName= method.getReturnType(); + if (typeName != null && typeName.length() > 0) { + buf.append( DECL_STRING ); + buf.append(typeName); + } + } + + // post qualification + if( getFlag(flags, M_POST_QUALIFIED)) { + buf.append( CONCAT_STRING ); + getTypeLabel( method.getParent(), T_FULLY_QUALIFIED, buf ); + } + if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { + IPath path= method.getPath(); + if (path != null) { + buf.append( CONCAT_STRING ); + buf.append(path.toString()); + } + } + } catch (CModelException e) { + CCorePlugin.log(e); + } + } + + private static void getTemplateParameters(ITemplate template, int flags, StringBuffer buf) { + if (getFlag(flags, TEMPLATE_PARAMETERS)) { + String[] types = template.getTemplateParameterTypes(); + buf.append('<'); + if (types != null) { + for (int i= 0; i < types.length; i++) { + if (i > 0) { + buf.append( ',' ); + } + buf.append( types[i] ); + } + } + buf.append('>'); + } + } + + public static void getFieldLabel(IField field, int flags, StringBuffer buf ) { + try { + //return type + if( getFlag( flags, F_PRE_TYPE_SIGNATURE ) && field.exists()) { + buf.append( field.getTypeName() ); + buf.append( ' ' ); + } + + //qualification + if( getFlag( flags, F_FULLY_QUALIFIED ) ){ + ICElement parent = field.getParent(); + if (parent != null && parent.exists()) { + getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); + buf.append( "::" ); //$NON-NLS-1$ + } + } + + buf.append( field.getElementName() ); + + if( getFlag( flags, F_APP_TYPE_SIGNATURE ) && field.exists()) { + buf.append( DECL_STRING ); + buf.append( field.getTypeName() ); + } + + // post qualification + if( getFlag(flags, F_POST_QUALIFIED)) { + buf.append( CONCAT_STRING ); + getTypeLabel( field.getParent(), T_FULLY_QUALIFIED, buf ); + } + if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { + IPath path= field.getPath(); + if (path != null) { + buf.append( CONCAT_STRING ); + buf.append(path.toString()); + } + } + } catch (CModelException e) { + CCorePlugin.log(e); + } + } + + public static void getVariableLabel(IVariableDeclaration var, int flags, StringBuffer buf ) { + try { + //return type + if( getFlag( flags, F_PRE_TYPE_SIGNATURE ) && var.exists()) { + buf.append( var.getTypeName() ); + buf.append( ' ' ); + } + + //qualification + if( getFlag( flags, F_FULLY_QUALIFIED ) ){ + ICElement parent = var.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); + buf.append( "::" ); //$NON-NLS-1$ + } + } + + buf.append( var.getElementName() ); + + if( getFlag( flags, F_APP_TYPE_SIGNATURE ) && var.exists()) { + buf.append( DECL_STRING ); + buf.append( var.getTypeName() ); + } + + // post qualification + if( getFlag(flags, F_POST_QUALIFIED)) { + ICElement parent = var.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + buf.append( CONCAT_STRING ); + getTypeLabel( var.getParent(), T_FULLY_QUALIFIED, buf ); + } + } + if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { + IPath path= var.getPath(); + if (path != null) { + buf.append( CONCAT_STRING ); + buf.append(path.toString()); + } + } + } catch (CModelException e) { + CCorePlugin.log(e); + } + } + + public static void getFunctionLabel(IFunctionDeclaration func, int flags, StringBuffer buf) { + //return type + if( getFlag( flags, M_PRE_RETURNTYPE ) && func.exists()) { + buf.append( func.getReturnType() ); + buf.append( ' ' ); + } + + //qualification + if( getFlag( flags, M_FULLY_QUALIFIED ) ){ + ICElement parent = func.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); + buf.append( "::" ); //$NON-NLS-1$ + } + } + + buf.append( func.getElementName() ); + + //template parameters + if (func instanceof ITemplate) { + getTemplateParameters((ITemplate)func, flags, buf); + } + + //parameters + if( getFlag( flags, M_PARAMETER_TYPES ) ) { + buf.append('('); + + String[] types = func.getParameterTypes(); + + for (int i= 0; i < types.length; i++) { + if (i > 0) { + buf.append( COMMA_STRING ); + } + + if (types != null) { + buf.append( types[i] ); + } + } + buf.append(')'); + } + + //exceptions + if( getFlag( flags, M_EXCEPTIONS ) && func.exists() ){ + String [] types = func.getExceptions(); + if (types.length > 0) { + buf.append(" throw( "); //$NON-NLS-1$ + for (int i= 0; i < types.length; i++) { + if (i > 0) { + buf.append(COMMA_STRING); + } + buf.append( types[i] ); + } + buf.append( " )" ); //$NON-NLS-1$ + } + } + + if( getFlag( flags, M_APP_RETURNTYPE ) && func.exists()) { + String typeName= func.getReturnType(); + if (typeName != null && typeName.length() > 0) { + buf.append( DECL_STRING ); + buf.append(typeName); + } + } + + // post qualification + if( getFlag(flags, M_POST_QUALIFIED)) { + ICElement parent = func.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + buf.append( CONCAT_STRING ); + getTypeLabel( func.getParent(), T_FULLY_QUALIFIED, buf ); + } + } + if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { + IPath path= func.getPath(); + if (path != null) { + buf.append( CONCAT_STRING ); + buf.append(path.toString()); + } + } + } + + public static void getTypeDefLabel(ITypeDef typedef, int flags, StringBuffer buf ) { + // type + if( getFlag( flags, F_PRE_TYPE_SIGNATURE ) && typedef.exists()) { + buf.append( typedef.getTypeName() ); + buf.append( ' ' ); + } + + //qualification + if( getFlag( flags, F_FULLY_QUALIFIED ) ){ + ICElement parent = typedef.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + getTypeLabel( parent, T_FULLY_QUALIFIED, buf ); + buf.append( "::" ); //$NON-NLS-1$ + } + } + + buf.append( typedef.getElementName() ); + + if( getFlag( flags, F_APP_TYPE_SIGNATURE ) && typedef.exists()) { + String typeName= typedef.getTypeName(); + if (typeName != null && typeName.length() > 0) { + buf.append( DECL_STRING ); + buf.append(typeName); + } + } + + // post qualification + if( getFlag(flags, F_POST_QUALIFIED)) { + ICElement parent = typedef.getParent(); + if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) { + buf.append( CONCAT_STRING ); + getTypeLabel( typedef.getParent(), T_FULLY_QUALIFIED, buf ); + } + } + if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { + IPath path= typedef.getPath(); + if (path != null) { + buf.append( CONCAT_STRING ); + buf.append(path.toString()); + } + } + } + + /** + * Appends the label for a source root to a StringBuffer. Considers the ROOT_* flags. + */ + public static void getSourceRootLabel(ISourceRoot root, int flags, StringBuffer buf) { + getFolderLabel(root, flags, buf); + } + + /** + * Appends the label for a container to a StringBuffer. Considers the ROOT_* flags. + */ + public static void getContainerLabel(ICContainer container, int flags, StringBuffer buf) { + getFolderLabel(container, flags, buf); + } + + private static void getFolderLabel(ICContainer container, int flags, StringBuffer buf) { + IResource resource= container.getResource(); + boolean rootQualified= getFlag(flags, ROOT_QUALIFIED); + boolean referencedQualified= getFlag(flags, PROJECT_POST_QUALIFIED) + && (container instanceof ISourceRoot && isReferenced((ISourceRoot)container)) + && resource != null; + if (rootQualified) { + buf.append(container.getPath().makeRelative().toString()); + } else { + buf.append(container.getElementName()); + if (referencedQualified) { + buf.append(CONCAT_STRING); + buf.append(resource.getProject().getName()); + } else if (getFlag(flags, ROOT_POST_QUALIFIED)) { + buf.append(CONCAT_STRING); + buf.append(container.getParent().getElementName()); + } + } + } + + /** + * Appends the label for a translation unit to a StringBuffer. Considers the CU_* flags. + */ + public static void getTranslationUnitLabel(ITranslationUnit tu, int flags, StringBuffer buf) { + IResource r= tu.getResource(); + IPath path; + if (r != null) { + path= r.getFullPath().makeRelative(); + } + else { + path= tu.getPath(); + } + + if (path == null) { + buf.append(tu.getElementName()); + } + else { + if (getFlag(flags, TU_QUALIFIED)) { + buf.append(path.toString()); + } + else if (getFlag(flags, TU_POST_QUALIFIED)) { + buf.append(path.lastSegment()); + buf.append(CONCAT_STRING); + buf.append(path.removeLastSegments(1)); + } + else { + buf.append(path.lastSegment()); + } + } + } + + /** + * Appends the label for a type to a StringBuffer. Considers the T_* flags. + */ + public static void getTypeLabel(ICElement elem, int flags, StringBuffer buf) { + if (getFlag(flags, T_FULLY_QUALIFIED)) { + ICElement parent= elem.getParent(); + boolean isQualifier= true; + if (parent != null && parent.exists()) { + switch (parent.getElementType()) { + case ICElement.C_ARCHIVE: + case ICElement.C_BINARY: + case ICElement.C_CCONTAINER: + case ICElement.C_MODEL: + case ICElement.C_PROJECT: + case ICElement.C_UNIT: + case ICElement.C_VCONTAINER: + isQualifier= false; + break; + } + } + // types cannot be qualified in plain c + if (isQualifier && !isCLanguage(parent)) { + int qflags= flags & ~MF_POST_FILE_QUALIFIED; + getTypeLabel(parent, qflags, buf); + buf.append("::"); //$NON-NLS-1$ + } + } + + String typeName= elem.getElementName(); + if (typeName.length() == 0) { // anonymous + typeName = CoreModelMessages.getString("CElementBaseLabels.anonymous"); //$NON-NLS-1$ + } + buf.append(typeName); + + if (getFlag(flags, T_INHERITANCE) && elem instanceof IInheritance) { + IInheritance inheritance= (IInheritance)elem; + String[] superclassNames= inheritance.getSuperClassesNames(); + if (superclassNames != null && superclassNames.length > 0) { + buf.append(DECL_STRING); + for (int i = 0; i < superclassNames.length; i++) { + if (i> 0) { + buf.append(COMMA_STRING); + } + String superclass = superclassNames[i]; + String visibility = getVisibility(inheritance.getSuperClassAccess(superclass)); + buf.append(visibility).append(' ').append(superclass); + } + } + } + + //template parameters + if (elem instanceof ITemplate) { + getTemplateParameters((ITemplate)elem, flags, buf); + } + + if( getFlag(flags, MF_POST_FILE_QUALIFIED)) { + IPath path= elem.getPath(); + if (path != null) { + buf.append( CONCAT_STRING ); + buf.append(path.toString()); + } + } + } + + private static boolean isCLanguage(ICElement elem) { + while (elem != null) { + elem= elem.getParent(); + if (elem instanceof ITranslationUnit) { + return ((ITranslationUnit) elem).isCLanguage(); + } + } + return false; + } + + /** + * Convert an ASTAccessVisibility into its string representation. + * + * @param access + * @return "public", "protected" or "private" + */ + private static String getVisibility(ASTAccessVisibility access) { + if (access == ASTAccessVisibility.PUBLIC) { + return "public"; //$NON-NLS-1$ + } + if (access == ASTAccessVisibility.PROTECTED) { + return "protected"; //$NON-NLS-1$ + } + return "private"; //$NON-NLS-1$ + } + + private static boolean getFlag(int flags, int flag) { + return (flags & flag) != 0; + } + + + /** + * Returns the source root of ICElement. If the given + * element is already a source root, the element itself is returned. + * @see org.eclipse.cdt.internal.corext.util.CModelUtil + */ + public static ISourceRoot getSourceRoot(ICElement element) { + ICElement root = element; + while (root != null) { + if (root instanceof ISourceRoot) + return (ISourceRoot)root; + ICElement parent = root.getAncestor(ICElement.C_CCONTAINER); + if (parent == root) + return null; + root = parent; + } + return null; + } + + /** + * Returns true if the given source root is + * referenced. This means it is own by a different project but is referenced + * by the root's parent. Returns false if the given root + * doesn't have an underlying resource. + * @see org.eclipse.cdt.internal.corext.util.CModelUtil + */ + public static boolean isReferenced(ISourceRoot root) { + IResource resource= root.getResource(); + if (resource != null) { + IProject project= resource.getProject(); + IProject container= root.getCProject().getProject(); + return !container.equals(project); + } + return false; + } +}