mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 10:15:39 +02:00
Bug 274490 - Return type stored in the ICElement- IFunctionDeclaration contains method qualifiers as well
This commit is contained in:
parent
3cec77c9d5
commit
4ca3c8a905
3 changed files with 40 additions and 30 deletions
|
@ -15,6 +15,7 @@ import junit.framework.Test;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||||
import org.eclipse.cdt.core.model.INamespace;
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -74,4 +75,12 @@ public class CModelBuilderBugsTest extends BaseTestCase {
|
||||||
assertNotNull(fTU.getElement("Unknown2::method"));
|
assertNotNull(fTU.getElement("Unknown2::method"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testModelBuilderBug274490() throws Exception {
|
||||||
|
IStructure clazz= (IStructure) fTU.getElement("Bug274490");
|
||||||
|
assertNotNull(clazz);
|
||||||
|
ICElement[] methods= clazz.getChildren();
|
||||||
|
assertEquals(2, methods.length);
|
||||||
|
assertEquals("int", ((IFunctionDeclaration) methods[0]).getReturnType());
|
||||||
|
assertEquals("const char*", ((IFunctionDeclaration) methods[1]).getReturnType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,3 +13,7 @@ namespace nsTest {
|
||||||
//http://bugs.eclipse.org/262785
|
//http://bugs.eclipse.org/262785
|
||||||
void Unknown1::method() {} // no qualifier in outline
|
void Unknown1::method() {} // no qualifier in outline
|
||||||
void Unknown2::method() {} // no qualifier in outline
|
void Unknown2::method() {} // no qualifier in outline
|
||||||
|
class Bug274490 {
|
||||||
|
virtual int m();
|
||||||
|
inline const char* m2() const;
|
||||||
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -39,13 +39,11 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||||
|
@ -59,7 +57,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
|
@ -472,35 +469,35 @@ public class ASTStringUtil {
|
||||||
if (declSpecifier.isConst()) {
|
if (declSpecifier.isConst()) {
|
||||||
buffer.append(Keywords.CONST).append(' ');
|
buffer.append(Keywords.CONST).append(' ');
|
||||||
}
|
}
|
||||||
if (declSpecifier.isVolatile()) {
|
// if (declSpecifier.isVolatile()) {
|
||||||
buffer.append(Keywords.VOLATILE).append(' ');
|
// buffer.append(Keywords.VOLATILE).append(' ');
|
||||||
}
|
// }
|
||||||
// if (declSpecifier.isInline()) {
|
// if (declSpecifier.isInline()) {
|
||||||
// buffer.append(Keywords.INLINE).append(' ');
|
// buffer.append(Keywords.INLINE).append(' ');
|
||||||
// }
|
// }
|
||||||
if (declSpecifier instanceof ICASTDeclSpecifier) {
|
// if (declSpecifier instanceof ICASTDeclSpecifier) {
|
||||||
final ICASTDeclSpecifier cDeclSpec= (ICASTDeclSpecifier)declSpecifier;
|
// final ICASTDeclSpecifier cDeclSpec= (ICASTDeclSpecifier)declSpecifier;
|
||||||
if (cDeclSpec.isRestrict()) {
|
// if (cDeclSpec.isRestrict()) {
|
||||||
buffer.append(Keywords.RESTRICT).append(' ');
|
// buffer.append(Keywords.RESTRICT).append(' ');
|
||||||
}
|
// }
|
||||||
} else if (declSpecifier instanceof ICPPASTDeclSpecifier) {
|
// } else if (declSpecifier instanceof ICPPASTDeclSpecifier) {
|
||||||
final ICPPASTDeclSpecifier cppDeclSpec= (ICPPASTDeclSpecifier)declSpecifier;
|
// final ICPPASTDeclSpecifier cppDeclSpec= (ICPPASTDeclSpecifier)declSpecifier;
|
||||||
if (cppDeclSpec.isFriend()) {
|
// if (cppDeclSpec.isFriend()) {
|
||||||
buffer.append(Keywords.FRIEND).append(' ');
|
// buffer.append(Keywords.FRIEND).append(' ');
|
||||||
}
|
// }
|
||||||
if (cppDeclSpec.isVirtual()) {
|
// if (cppDeclSpec.isVirtual()) {
|
||||||
buffer.append(Keywords.VIRTUAL).append(' ');
|
// buffer.append(Keywords.VIRTUAL).append(' ');
|
||||||
}
|
// }
|
||||||
if (cppDeclSpec.isExplicit()) {
|
// if (cppDeclSpec.isExplicit()) {
|
||||||
buffer.append(Keywords.EXPLICIT).append(' ');
|
// buffer.append(Keywords.EXPLICIT).append(' ');
|
||||||
}
|
// }
|
||||||
if (declSpecifier instanceof IGPPASTDeclSpecifier) {
|
// if (declSpecifier instanceof IGPPASTDeclSpecifier) {
|
||||||
final IGPPASTDeclSpecifier gppDeclSpec= (IGPPASTDeclSpecifier)declSpecifier;
|
// final IGPPASTDeclSpecifier gppDeclSpec= (IGPPASTDeclSpecifier)declSpecifier;
|
||||||
if (gppDeclSpec.isRestrict()) {
|
// if (gppDeclSpec.isRestrict()) {
|
||||||
buffer.append(Keywords.RESTRICT).append(' ');
|
// buffer.append(Keywords.RESTRICT).append(' ');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// storage class
|
// storage class
|
||||||
// final int storageClass= declSpecifier.getStorageClass();
|
// final int storageClass= declSpecifier.getStorageClass();
|
||||||
// switch (storageClass) {
|
// switch (storageClass) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue