1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

Bug Fixing

This commit is contained in:
Hoda Amer 2004-06-15 18:17:20 +00:00
parent e2ea942fe5
commit f50273233f
3 changed files with 26 additions and 33 deletions

View file

@ -1,3 +1,6 @@
2004-06-15 Hoda Amer
Fix for PR 63207: ITranslationUnit.getElementAtOffset(i) does not factor in multiple namespace decl
2004-06-14 Hoda Amer 2004-06-14 Hoda Amer
Fix for PR 63243: [Outline View] Missing user defined type if declare variable along with the C++ elem (struct, enum, union) Fix for PR 63243: [Outline View] Missing user defined type if declare variable along with the C++ elem (struct, enum, union)

View file

@ -436,37 +436,16 @@ public class CModelBuilder {
String nsName = (nsDef.getName() == null ) String nsName = (nsDef.getName() == null )
? "" //$NON-NLS-1$ ? "" //$NON-NLS-1$
: nsDef.getName().toString(); : nsDef.getName().toString();
Namespace element = new Namespace (parent, nsName );
// check if there is another namespace with the same name for the same parent // add to parent
boolean alreadyThere = false; parent.addChild(element);
Namespace oldElement = null; element.setIdPos(nsDef.getNameOffset(),
(nsName.length() == 0) ? type.length() : (nsDef.getNameEndOffset() - nsDef.getNameOffset()));
List siblings = parent.getChildrenOfType(ICElement.C_NAMESPACE); element.setPos(nsDef.getStartingOffset(), nsDef.getEndingOffset() - nsDef.getStartingOffset());
if(siblings.size() > 0){ element.setLines( nsDef.getStartingLine(), nsDef.getEndingLine() );
Iterator i = siblings.iterator(); element.setTypeName(type);
while (i.hasNext()){ this.newElements.put(element, element.getElementInfo());
Namespace n = (Namespace)i.next(); return element;
if(n.getElementName().equals(nsName)){
alreadyThere = true;
oldElement = n;
}
}
}
if( (alreadyThere) && (oldElement != null)) {
return oldElement;
} else {
// this is the first namespace
Namespace element = new Namespace (parent, nsName );
// add to parent
parent.addChild(element);
element.setIdPos(nsDef.getNameOffset(),
(nsName.length() == 0) ? type.length() : (nsDef.getNameEndOffset() - nsDef.getNameOffset()));
element.setPos(nsDef.getStartingOffset(), nsDef.getEndingOffset() - nsDef.getStartingOffset());
element.setLines( nsDef.getStartingLine(), nsDef.getEndingLine() );
element.setTypeName(type);
this.newElements.put(element, element.getElementInfo());
return element;
}
} }
private Enumeration createEnumeration(Parent parent, IASTEnumerationSpecifier enumSpecifier) throws CModelException{ private Enumeration createEnumeration(Parent parent, IASTEnumerationSpecifier enumSpecifier) throws CModelException{

View file

@ -11,6 +11,7 @@ package org.eclipse.cdt.internal.core.model;
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
***********************************************************************/ ***********************************************************************/
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.INamespace; import org.eclipse.cdt.core.model.INamespace;
@ -21,7 +22,7 @@ public class Namespace extends SourceManipulation implements INamespace{
super(parent, name, CElement.C_NAMESPACE); super(parent, name, CElement.C_NAMESPACE);
} }
/** /*
* Returns the typeName. * Returns the typeName.
* @return String * @return String
*/ */
@ -29,12 +30,22 @@ public class Namespace extends SourceManipulation implements INamespace{
return typeName; return typeName;
} }
/** /*
* Sets the typeName. * Sets the typeName.
* @param typeName The typeName to set * @param typeName The typeName to set
*/ */
public void setTypeName(String typeName) { public void setTypeName(String typeName) {
this.typeName = typeName; this.typeName = typeName;
} }
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object other) {
// TODO Auto-generated method stub
return (super.equals(other)
&& (this.getStartPos() == ((Namespace)other).getStartPos())
&& (this.getLength() == ((Namespace)other).getLength())
);
}
} }