diff options
author | Markus Schorn | 2008-03-05 13:15:13 +0000 |
---|---|---|
committer | Markus Schorn | 2008-03-05 13:15:13 +0000 |
commit | 4aa0c4245aa611defc1ba9359e398b728a79137a (patch) | |
tree | 3fe54ff8e880f3c88589b81ae119642da79fd26f /core/org.eclipse.cdt.core/model/org | |
parent | b4d5bb7a677e662fd93e410414c42b0e948a8f66 (diff) | |
download | org.eclipse.cdt-4aa0c4245aa611defc1ba9359e398b728a79137a.tar.gz org.eclipse.cdt-4aa0c4245aa611defc1ba9359e398b728a79137a.tar.xz org.eclipse.cdt-4aa0c4245aa611defc1ba9359e398b728a79137a.zip |
Handling ambiguous enumerations in navigation, bug 209550.
Diffstat (limited to 'core/org.eclipse.cdt.core/model/org')
-rw-r--r-- | core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java index 441ca4b37bf..00b581342f6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/util/CElementBaseLabels.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 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 @@ -10,20 +10,14 @@ * Markus Schorn (Wind River Systems) * Gerhard Schaber (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.IEnumerator; import org.eclipse.cdt.core.model.IField; import org.eclipse.cdt.core.model.IFunctionDeclaration; import org.eclipse.cdt.core.model.IInheritance; @@ -35,6 +29,9 @@ 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; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; /** * Creates labels for ICElement objects. @@ -258,6 +255,9 @@ public class CElementBaseLabels { case ICElement.C_VARIABLE_DECLARATION: getVariableLabel( (IVariableDeclaration) element, flags, buf); break; + case ICElement.C_ENUMERATOR: + getEnumeratorLabel((IEnumerator) element, flags, buf); + break; case ICElement.C_CLASS: case ICElement.C_STRUCT: case ICElement.C_UNION: @@ -506,6 +506,41 @@ public class CElementBaseLabels { } /** + * Appends the label for an enumerator to a StringBuffer. + * @param var an enumerator + * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED + * @param buf the buffer to append the label + */ + public static void getEnumeratorLabel(IEnumerator var, int flags, StringBuffer buf ) { + //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() ); + + // 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()); + } + } + } + + /** * Appends the label for a function declaration to a StringBuffer. * @param func a function declaration * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED |