Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-patch] UI patch - some new ... Changes

Actually, I believe that IStructure should extend IVariableDeclaration.
Could you please apply this one? It has some NewModelBuilder enum fixes as
well by John.


-----Original Message-----
From: Alain Magloire [mailto:alain@xxxxxxx] 
Sent: Tuesday, April 01, 2003 2:21 PM
To: cdt-patch@xxxxxxxxxxx
Subject: Re: [cdt-patch] UI patch - some new ... Changes

> 
> New icons for enumerations, enumerators, and typedefs.
> A small fix for CElementLableProvider.getText()
> 

This was applied with a some changes,  IStructure does not
extend IVariableDeclaration, unless it was your intention.  Changed code
below
The else if () case test instanceof IVariableDeclaration.



============================================================================
====
Index: src/org/eclipse/cdt/ui/CElementLabelProvider.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.
java,v
retrieving revision 1.7
diff -u -r1.7 CElementLabelProvider.java
--- src/org/eclipse/cdt/ui/CElementLabelProvider.java	1 Apr 2003 18:41:00
-0000	1.7
+++ src/org/eclipse/cdt/ui/CElementLabelProvider.java	1 Apr 2003 19:11:13
-0000
@@ -58,7 +58,7 @@
 		if (element instanceof ICElement) {
 			ICElement celem= (ICElement)element;
 			
-			String name;
+			String name = "";
 			switch(celem.getElementType()){
 				case ICElement.C_FIELD:
 				case ICElement.C_VARIABLE:
@@ -79,7 +79,7 @@
 				case ICElement.C_ENUMERATION:
 					if((celem.getElementName() != null)
&& (celem.getElementName().length() > 0)){
 						name =
celem.getElementName();
-					} else {
+					} else if (celem instanceof
IVariableDeclaration) {
 						IVariableDeclaration varDecl
= (IVariableDeclaration) celem;
 						name =
varDecl.getTypeName();				
 					}

_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch

Index: model/org/eclipse/cdt/core/model/INamespace.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/INamespace.java,v
retrieving revision 1.1
diff -u -r1.1 INamespace.java
--- model/org/eclipse/cdt/core/model/INamespace.java	26 Jun 2002 20:37:15 -0000	1.1
+++ model/org/eclipse/cdt/core/model/INamespace.java	1 Apr 2003 19:33:56 -0000
@@ -7,7 +7,7 @@
 /**
  * Represents a package declaration in a C translation unit.
  */
-public interface INamespace extends ICElement, ISourceManipulation, ISourceReference {
+public interface INamespace extends ICElement, IParent, ISourceManipulation, ISourceReference {
 	/**
 	 * Returns the name of the package the statement refers to.
 	 * This is a handle-only method.
Index: model/org/eclipse/cdt/core/model/IStructure.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IStructure.java,v
retrieving revision 1.3
diff -u -r1.3 IStructure.java
--- model/org/eclipse/cdt/core/model/IStructure.java	28 Mar 2003 21:05:20 -0000	1.3
+++ model/org/eclipse/cdt/core/model/IStructure.java	1 Apr 2003 19:33:56 -0000
@@ -8,7 +8,7 @@
 /**
  * Represent struct(ure), class or union.
  */
-public interface IStructure extends IInheritance, IParent, IDeclaration {
+public interface IStructure extends IInheritance, IParent, IVariableDeclaration {
 	//public String instantiatesTemplate();
 
 	public IField getField(String name);
Index: parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java,v
retrieving revision 1.15
diff -u -r1.15 NewModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java	1 Apr 2003 18:52:37 -0000	1.15
+++ parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java	1 Apr 2003 19:33:57 -0000
@@ -684,6 +684,7 @@
 		Parent realParent = (Parent)wrapper.getParent();
 		String enumName = ( wrapper.getName() == null ) ? "" : wrapper.getName().toString();
 		Enumeration enumeration = new Enumeration( (ICElement)realParent, enumName );
+		enumeration.setTypeName( "enum" ); 
 		realParent.addChild( enumeration );
 		
 		// create the list 
@@ -691,20 +692,25 @@
 		while( i.hasNext())
 		{
 			EnumeratorWrapper subwrapper = (EnumeratorWrapper)i.next(); 
-			Enumerator enumerator = new Enumerator( enumeration, subwrapper.getName().toString() ); 
+			Enumerator enumerator = new Enumerator( enumeration, subwrapper.getName().toString() );
+			String enumeratorName = subwrapper.getName().toString();
+
+			enumerator.setIdPos(subwrapper.getName().getStartOffset(), enumeratorName.length());
+			enumerator.setPos(subwrapper.getName().getStartOffset(), enumeratorName.length());
+			 
 			enumeration.addChild( enumerator );
 		}
 		
 		// do the offsets
 		if( wrapper.getName() != null )
 		{ 	
-			elem.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
-			elem.setPos(wrapper.getName().getStartOffset(), enumName.length());
+			enumeration.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
+			enumeration.setPos(wrapper.getName().getStartOffset(), enumName.length());
 		}
 		else
 		{
-			elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
-			elem.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());		
+			enumeration.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
+			enumeration.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());		
 		}
 	}
 

Back to the top