mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixes type-string computation for model builder, bug 235808.
This commit is contained in:
parent
ddca2b93d1
commit
a8817857ac
11 changed files with 128 additions and 330 deletions
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="misc"/>
|
||||
<classpathentry kind="src" path="failures"/>
|
||||
<classpathentry kind="src" path="model"/>
|
||||
<classpathentry kind="src" path="parser"/>
|
||||
<classpathentry kind="src" path="suite"/>
|
||||
|
|
|
@ -10,7 +10,6 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
|
|||
org.eclipse.cdt.core.internal.index.provider.test;x-internal:=true,
|
||||
org.eclipse.cdt.core.internal.tests;x-internal:=true,
|
||||
org.eclipse.cdt.core.language,
|
||||
org.eclipse.cdt.core.model.failedTests,
|
||||
org.eclipse.cdt.core.model.tests,
|
||||
org.eclipse.cdt.core.parser.tests,
|
||||
org.eclipse.cdt.core.parser.tests.ast2,
|
||||
|
|
|
@ -20,8 +20,7 @@ bin.includes = plugin.xml,\
|
|||
parser/org/eclipse/cdt/core/parser/tests/scanner/
|
||||
|
||||
output.cdtcoretests.jar = bin/
|
||||
source.cdtcoretests.jar = failures/,\
|
||||
model/,\
|
||||
source.cdtcoretests.jar = model/,\
|
||||
parser/,\
|
||||
suite/,\
|
||||
misc/,\
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 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:
|
||||
* Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.failedTests;
|
||||
|
||||
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
|
||||
/**
|
||||
* @author vhirsl
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class CModelElementsFailedTests extends TestCase {
|
||||
|
||||
private ICProject fCProject;
|
||||
private IFile headerFile;
|
||||
private NullProgressMonitor monitor;
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite(CModelElementsFailedTests.class.getName());
|
||||
suite.addTest(new CModelElementsFailedTests("testBug36379"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
public CModelElementsFailedTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
monitor = new NullProgressMonitor();
|
||||
String pluginRoot = CTestPlugin.getDefault().find(new Path("/")).getFile();
|
||||
|
||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
headerFile = fCProject.getProject().getFile("CModelElementsTest.h");
|
||||
if (!headerFile.exists()) {
|
||||
try{
|
||||
FileInputStream fileIn = new FileInputStream(pluginRoot+ "resources/cfiles/CModelElementsTestStart.h");
|
||||
headerFile.create(fileIn,false, monitor);
|
||||
} catch (CoreException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void tearDown() {
|
||||
CProjectHelper.delete(fCProject);
|
||||
}
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 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 Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.failedTests;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IFunction;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
import org.eclipse.cdt.core.model.tests.IntegratedCModelTest;
|
||||
import org.eclipse.cdt.core.tests.FailingTest;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class FailedDeclaratorsTest extends IntegratedCModelTest
|
||||
{
|
||||
// the defect to track these failures is Bug 40768
|
||||
|
||||
private FailedDeclaratorsTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||
*/
|
||||
public String getSourcefileSubdir() {
|
||||
return "resources/cmodel/";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||
*/
|
||||
public String getSourcefileResource() {
|
||||
return "DeclaratorsTests.cpp";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns a test suite named after this class
|
||||
* containing all its public members named "test*"
|
||||
*/
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite("FailedDeclaratorsTest");
|
||||
suite.addTest(new FailingTest(new FailedDeclaratorsTest("testDeclarators_0011"), 40768));
|
||||
suite.addTest(new FailingTest(new FailedDeclaratorsTest("testDeclarators_0013"), 40768));
|
||||
suite.addTest(new FailingTest(new FailedDeclaratorsTest("testDeclarators_0014"), 40768));
|
||||
suite.addTest(new FailingTest(new FailedDeclaratorsTest("testDeclarators_0023"), 40768));
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
||||
public void testDeclarators_0011() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0011");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void()(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0012() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0012");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void()(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0013() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0013");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void()(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0014() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0014");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void*()(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0023() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0023");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_FUNCTION);
|
||||
IFunction decl = (IFunction)element;
|
||||
assertEquals(decl.getSignature(), "decl_0023(int)");
|
||||
assertEquals(decl.getReturnType(), "void(*(*))(char)");
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model.failedTests;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.model.tests.IntegratedCModelTest;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class FailedMacroTests extends IntegratedCModelTest
|
||||
{
|
||||
public static Test suite() {
|
||||
TestSuite suite= new TestSuite("FailedMacroTests");
|
||||
return suite;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FailedMacroTests()
|
||||
{
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public FailedMacroTests(String name)
|
||||
{
|
||||
super(name);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||
*/
|
||||
public String getSourcefileSubdir() {
|
||||
return "resources/cmodel/";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||
*/
|
||||
public String getSourcefileResource() {
|
||||
return "MacroTests.cpp";
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.core.model.tests;
|
|||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.model.failedTests.FailedDeclaratorsTest;
|
||||
import org.eclipse.cdt.core.settings.model.AllCProjectDescriptionTests;
|
||||
import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests;
|
||||
|
||||
|
@ -47,7 +46,6 @@ public class AllCoreTests {
|
|||
suite.addTest(ArchiveTests.suite());
|
||||
suite.addTest(TranslationUnitTests.suite());
|
||||
suite.addTest(DeclaratorsTests.suite());
|
||||
suite.addTest(FailedDeclaratorsTest.suite());
|
||||
suite.addTest(MacroTests.suite());
|
||||
// suite.addTest(FailedMacroTests.suite());
|
||||
suite.addTest(CPathEntryTest.suite());
|
||||
|
|
|
@ -19,6 +19,7 @@ import junit.framework.TestSuite;
|
|||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IFunction;
|
||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
|
@ -40,6 +41,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
|||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||
*/
|
||||
@Override
|
||||
public String getSourcefileSubdir() {
|
||||
return "resources/cmodel/";
|
||||
}
|
||||
|
@ -47,6 +49,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
|||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||
*/
|
||||
@Override
|
||||
public String getSourcefileResource() {
|
||||
return "DeclaratorsTests.cpp";
|
||||
}
|
||||
|
@ -129,6 +132,42 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
|||
}
|
||||
|
||||
|
||||
public void testDeclarators_0011() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0011");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0012() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0012");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0013() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0013");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0014() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0014");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_TYPEDEF);
|
||||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void*(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0015() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0015");
|
||||
|
@ -155,7 +194,17 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
|||
ITypeDef decl = (ITypeDef)element;
|
||||
assertEquals(decl.getTypeName(), "void(*)(char)");
|
||||
}
|
||||
|
||||
|
||||
public void testDeclarators_0023() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0023");
|
||||
assertNotNull(element);
|
||||
assertEquals(element.getElementType(), ICElement.C_FUNCTION);
|
||||
IFunction decl = (IFunction)element;
|
||||
assertEquals(decl.getSignature(), "decl_0023(int)");
|
||||
assertEquals(decl.getReturnType(), "void(**)(char)");
|
||||
}
|
||||
|
||||
public void testDeclarators_0024() throws CModelException {
|
||||
ITranslationUnit tu = getTU();
|
||||
ICElement element = tu.getElement("decl_0024");
|
||||
|
|
|
@ -64,6 +64,7 @@ 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.IGPPASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -119,20 +120,21 @@ public class ASTStringUtil {
|
|||
*/
|
||||
public static String getSignatureString(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||
final StringBuilder buffer= new StringBuilder();
|
||||
appendDeclarationString(buffer, declSpecifier, declarator, true);
|
||||
appendDeclarationString(buffer, declSpecifier, declarator, null);
|
||||
return trimRight(buffer).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute a (return-)type string without parameters and initializers.
|
||||
* Compute the return-type string for a function declarator.
|
||||
*
|
||||
* @param declSpecifier
|
||||
* @param declarator
|
||||
* @return the type string
|
||||
* @param fdecl
|
||||
* @return the return type string
|
||||
*/
|
||||
public static String getTypeString(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||
public static String getReturnTypeString(IASTDeclSpecifier declSpecifier, IASTFunctionDeclarator fdecl) {
|
||||
final StringBuilder buffer= new StringBuilder();
|
||||
appendDeclarationString(buffer, declSpecifier, declarator, false);
|
||||
final IASTDeclarator declarator= CPPVisitor.findOutermostDeclarator(fdecl);
|
||||
appendDeclarationString(buffer, declSpecifier, declarator, fdecl);
|
||||
return trimRight(buffer).toString();
|
||||
}
|
||||
|
||||
|
@ -240,83 +242,87 @@ public class ASTStringUtil {
|
|||
else
|
||||
declSpec= null;
|
||||
|
||||
return appendDeclarationString(buffer, declSpec, declarator, true);
|
||||
return appendDeclarationString(buffer, declSpec, declarator, null);
|
||||
}
|
||||
|
||||
private static StringBuilder appendDeclarationString(StringBuilder buffer, IASTDeclSpecifier declSpecifier, IASTDeclarator declarator, boolean addParams) {
|
||||
private static StringBuilder appendDeclarationString(StringBuilder buffer, IASTDeclSpecifier declSpecifier,
|
||||
IASTDeclarator declarator, IASTFunctionDeclarator returnTypeOf) {
|
||||
if (declSpecifier != null) {
|
||||
appendDeclSpecifierString(buffer, declSpecifier);
|
||||
trimRight(buffer);
|
||||
}
|
||||
appendDeclaratorString(buffer, declarator, addParams);
|
||||
appendDeclaratorString(buffer, declarator, false, returnTypeOf);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private static StringBuilder appendDeclaratorString(StringBuilder buffer, IASTDeclarator declarator,
|
||||
boolean addParams) {
|
||||
boolean protectPointers, IASTFunctionDeclarator returnTypeOf) {
|
||||
if (declarator == null) {
|
||||
return buffer;
|
||||
}
|
||||
appendPointerOperatorsString(buffer, declarator.getPointerOperators());
|
||||
if (declarator instanceof IASTArrayDeclarator) {
|
||||
appendArrayQualifiersString(buffer, (IASTArrayDeclarator)declarator);
|
||||
final IASTPointerOperator[] ptrs = declarator.getPointerOperators();
|
||||
final boolean useParenthesis= protectPointers && ptrs.length > 0;
|
||||
if (useParenthesis) {
|
||||
buffer.append(Keywords.cpLPAREN);
|
||||
protectPointers= false;
|
||||
}
|
||||
final IASTDeclarator nestedDeclarator= declarator.getNestedDeclarator();
|
||||
if (nestedDeclarator != null) {
|
||||
StringBuilder tmp= new StringBuilder();
|
||||
appendDeclaratorString(tmp, nestedDeclarator, addParams);
|
||||
trimRight(tmp);
|
||||
final int tmpLength= tmp.length();
|
||||
if (tmpLength > 0) {
|
||||
if (tmp.charAt(0) != Keywords.cpLPAREN[0] || tmp.charAt(tmpLength-1) != Keywords.cpRPAREN[0]) {
|
||||
buffer.append(Keywords.cpLPAREN);
|
||||
buffer.append(tmp);
|
||||
buffer.append(Keywords.cpRPAREN);
|
||||
} else {
|
||||
buffer.append(tmp);
|
||||
}
|
||||
|
||||
appendPointerOperatorsString(buffer, ptrs);
|
||||
|
||||
if (declarator != returnTypeOf) {
|
||||
final IASTDeclarator nestedDeclarator= declarator.getNestedDeclarator();
|
||||
if (nestedDeclarator != null) {
|
||||
protectPointers=
|
||||
protectPointers || declarator instanceof IASTArrayDeclarator
|
||||
|| declarator instanceof IASTFunctionDeclarator
|
||||
|| declarator instanceof IASTFieldDeclarator;
|
||||
appendDeclaratorString(buffer, nestedDeclarator, protectPointers, returnTypeOf);
|
||||
}
|
||||
}
|
||||
if (!addParams) {
|
||||
return buffer;
|
||||
}
|
||||
if (declarator instanceof IASTFunctionDeclarator) {
|
||||
final IASTFunctionDeclarator functionDecl= (IASTFunctionDeclarator)declarator;
|
||||
appendParameterSignatureString(buffer, functionDecl);
|
||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||
final ICPPASTFunctionDeclarator cppFunctionDecl= (ICPPASTFunctionDeclarator)declarator;
|
||||
if (cppFunctionDecl.isConst()) {
|
||||
buffer.append(Keywords.CONST).append(' ');
|
||||
}
|
||||
if (cppFunctionDecl.isVolatile()) {
|
||||
buffer.append(Keywords.VOLATILE).append(' ');
|
||||
}
|
||||
if (cppFunctionDecl.isPureVirtual()) {
|
||||
buffer.append("=0 "); //$NON-NLS-1$
|
||||
}
|
||||
final IASTTypeId[] exceptionTypeIds= cppFunctionDecl.getExceptionSpecification();
|
||||
if (exceptionTypeIds.length > 0) {
|
||||
buffer.append(Keywords.THROW).append(' ');
|
||||
for (int i= 0; i < exceptionTypeIds.length; i++) {
|
||||
if (i > 0) {
|
||||
buffer.append(COMMA_SPACE);
|
||||
|
||||
if (declarator instanceof IASTArrayDeclarator) {
|
||||
appendArrayQualifiersString(buffer, (IASTArrayDeclarator)declarator);
|
||||
} else if (declarator instanceof IASTFunctionDeclarator) {
|
||||
final IASTFunctionDeclarator functionDecl= (IASTFunctionDeclarator)declarator;
|
||||
appendParameterSignatureString(buffer, functionDecl);
|
||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||
final ICPPASTFunctionDeclarator cppFunctionDecl= (ICPPASTFunctionDeclarator)declarator;
|
||||
if (cppFunctionDecl.isConst()) {
|
||||
buffer.append(Keywords.CONST).append(' ');
|
||||
}
|
||||
if (cppFunctionDecl.isVolatile()) {
|
||||
buffer.append(Keywords.VOLATILE).append(' ');
|
||||
}
|
||||
if (cppFunctionDecl.isPureVirtual()) {
|
||||
buffer.append("=0 "); //$NON-NLS-1$
|
||||
}
|
||||
final IASTTypeId[] exceptionTypeIds= cppFunctionDecl.getExceptionSpecification();
|
||||
if (exceptionTypeIds.length > 0) {
|
||||
buffer.append(Keywords.THROW).append(' ');
|
||||
for (int i= 0; i < exceptionTypeIds.length; i++) {
|
||||
if (i > 0) {
|
||||
buffer.append(COMMA_SPACE);
|
||||
}
|
||||
appendTypeIdString(buffer, exceptionTypeIds[i]);
|
||||
}
|
||||
appendTypeIdString(buffer, exceptionTypeIds[i]);
|
||||
}
|
||||
if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
|
||||
assert false : "TODO: handle "+ declarator.getClass().getName(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
|
||||
assert false : "TODO: handle "+ declarator.getClass().getName(); //$NON-NLS-1$
|
||||
} else if (declarator instanceof IASTFieldDeclarator) {
|
||||
final IASTFieldDeclarator fieldDeclarator= (IASTFieldDeclarator)declarator;
|
||||
final IASTExpression bitFieldSize= fieldDeclarator.getBitFieldSize();
|
||||
if (bitFieldSize != null) {
|
||||
buffer.append(Keywords.cpCOLON);
|
||||
appendExpressionString(buffer, bitFieldSize);
|
||||
}
|
||||
} else {
|
||||
// just a nested name
|
||||
}
|
||||
} else if (declarator instanceof IASTFieldDeclarator) {
|
||||
final IASTFieldDeclarator fieldDeclarator= (IASTFieldDeclarator)declarator;
|
||||
final IASTExpression bitFieldSize= fieldDeclarator.getBitFieldSize();
|
||||
if (bitFieldSize != null) {
|
||||
buffer.append(Keywords.cpCOLON);
|
||||
appendExpressionString(buffer, bitFieldSize);
|
||||
}
|
||||
} else {
|
||||
// assert false : "TODO: handle "+ declarator.getClass().getName(); //$NON-NLS-1$
|
||||
}
|
||||
if (useParenthesis) {
|
||||
trimRight(buffer);
|
||||
buffer.append(Keywords.cpRPAREN);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
@ -358,7 +364,7 @@ public class ASTStringUtil {
|
|||
|
||||
private static StringBuilder appendTypeIdString(StringBuilder buffer, IASTTypeId typeId) {
|
||||
appendDeclSpecifierString(buffer, typeId.getDeclSpecifier());
|
||||
appendDeclaratorString(buffer, typeId.getAbstractDeclarator(), true);
|
||||
appendDeclaratorString(buffer, typeId.getAbstractDeclarator(), false, null);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -459,7 +465,7 @@ public class ASTStringUtil {
|
|||
}
|
||||
final IASTDeclarator declarator= parameter.getDeclarator();
|
||||
if (declarator != null) {
|
||||
appendDeclaratorString(buffer, declarator, true);
|
||||
appendDeclaratorString(buffer, declarator, false, null);
|
||||
appendInitializerString(buffer, declarator.getInitializer());
|
||||
}
|
||||
return buffer;
|
||||
|
|
|
@ -467,23 +467,13 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
if (declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
||||
return createTypeDef(parent, declSpecifier, declarator);
|
||||
}
|
||||
if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
|
||||
return createFunctionDeclaration(parent, declSpecifier, (IASTFunctionDeclarator)declarator, isTemplate);
|
||||
IASTDeclarator typeRelevant= CPPVisitor.findTypeRelevantDeclarator(declarator);
|
||||
if (typeRelevant instanceof IASTFunctionDeclarator) {
|
||||
return createFunctionDeclaration(parent, declSpecifier, (IASTFunctionDeclarator)typeRelevant, isTemplate);
|
||||
}
|
||||
return createVariable(parent, declSpecifier, declarator, isTemplate);
|
||||
}
|
||||
|
||||
private boolean hasNestedPointerOperators(IASTDeclarator declarator) {
|
||||
declarator= declarator.getNestedDeclarator();
|
||||
while (declarator != null) {
|
||||
if (declarator.getPointerOperators().length > 0) {
|
||||
return true;
|
||||
}
|
||||
declarator= declarator.getNestedDeclarator();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void createNamespace(Parent parent, ICPPASTNamespaceDefinition declaration) throws CModelException, DOMException{
|
||||
// create element
|
||||
final String type= Keywords.NAMESPACE;
|
||||
|
@ -826,7 +816,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
|
||||
final String functionName= ASTStringUtil.getSimpleName(name);
|
||||
final String[] parameterTypes= ASTStringUtil.getParameterSignatureArray(declarator);
|
||||
final String returnType= ASTStringUtil.getTypeString(declSpecifier, declarator);
|
||||
final String returnType= ASTStringUtil.getReturnTypeString(declSpecifier, declarator);
|
||||
|
||||
final FunctionDeclaration element;
|
||||
final FunctionInfo info;
|
||||
|
@ -963,7 +953,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
|||
|
||||
final String functionName= ASTStringUtil.getSimpleName(name);
|
||||
final String[] parameterTypes= ASTStringUtil.getParameterSignatureArray(declarator);
|
||||
final String returnType= ASTStringUtil.getTypeString(declSpecifier, declarator);
|
||||
final String returnType= ASTStringUtil.getReturnTypeString(declSpecifier, declarator);
|
||||
|
||||
final FunctionDeclaration element;
|
||||
final FunctionInfo info;
|
||||
|
|
|
@ -102,7 +102,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
|
|||
setPageComplete(true);
|
||||
}
|
||||
else{
|
||||
setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage());
|
||||
setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage()); //$NON-NLS-1$
|
||||
setPageComplete(false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue