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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="misc"/>
|
<classpathentry kind="src" path="misc"/>
|
||||||
<classpathentry kind="src" path="failures"/>
|
|
||||||
<classpathentry kind="src" path="model"/>
|
<classpathentry kind="src" path="model"/>
|
||||||
<classpathentry kind="src" path="parser"/>
|
<classpathentry kind="src" path="parser"/>
|
||||||
<classpathentry kind="src" path="suite"/>
|
<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.index.provider.test;x-internal:=true,
|
||||||
org.eclipse.cdt.core.internal.tests;x-internal:=true,
|
org.eclipse.cdt.core.internal.tests;x-internal:=true,
|
||||||
org.eclipse.cdt.core.language,
|
org.eclipse.cdt.core.language,
|
||||||
org.eclipse.cdt.core.model.failedTests,
|
|
||||||
org.eclipse.cdt.core.model.tests,
|
org.eclipse.cdt.core.model.tests,
|
||||||
org.eclipse.cdt.core.parser.tests,
|
org.eclipse.cdt.core.parser.tests,
|
||||||
org.eclipse.cdt.core.parser.tests.ast2,
|
org.eclipse.cdt.core.parser.tests.ast2,
|
||||||
|
|
|
@ -20,8 +20,7 @@ bin.includes = plugin.xml,\
|
||||||
parser/org/eclipse/cdt/core/parser/tests/scanner/
|
parser/org/eclipse/cdt/core/parser/tests/scanner/
|
||||||
|
|
||||||
output.cdtcoretests.jar = bin/
|
output.cdtcoretests.jar = bin/
|
||||||
source.cdtcoretests.jar = failures/,\
|
source.cdtcoretests.jar = model/,\
|
||||||
model/,\
|
|
||||||
parser/,\
|
parser/,\
|
||||||
suite/,\
|
suite/,\
|
||||||
misc/,\
|
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.Test;
|
||||||
import junit.framework.TestSuite;
|
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.AllCProjectDescriptionTests;
|
||||||
import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests;
|
import org.eclipse.cdt.core.settings.model.PathSettingsContainerTests;
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ public class AllCoreTests {
|
||||||
suite.addTest(ArchiveTests.suite());
|
suite.addTest(ArchiveTests.suite());
|
||||||
suite.addTest(TranslationUnitTests.suite());
|
suite.addTest(TranslationUnitTests.suite());
|
||||||
suite.addTest(DeclaratorsTests.suite());
|
suite.addTest(DeclaratorsTests.suite());
|
||||||
suite.addTest(FailedDeclaratorsTest.suite());
|
|
||||||
suite.addTest(MacroTests.suite());
|
suite.addTest(MacroTests.suite());
|
||||||
// suite.addTest(FailedMacroTests.suite());
|
// suite.addTest(FailedMacroTests.suite());
|
||||||
suite.addTest(CPathEntryTest.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.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.IFunctionDeclaration;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.ITypeDef;
|
import org.eclipse.cdt.core.model.ITypeDef;
|
||||||
|
@ -40,6 +41,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getSourcefileSubdir() {
|
public String getSourcefileSubdir() {
|
||||||
return "resources/cmodel/";
|
return "resources/cmodel/";
|
||||||
}
|
}
|
||||||
|
@ -47,6 +49,7 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
* @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getSourcefileResource() {
|
public String getSourcefileResource() {
|
||||||
return "DeclaratorsTests.cpp";
|
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 {
|
public void testDeclarators_0015() throws CModelException {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ICElement element = tu.getElement("decl_0015");
|
ICElement element = tu.getElement("decl_0015");
|
||||||
|
@ -156,6 +195,16 @@ public class DeclaratorsTests extends IntegratedCModelTest {
|
||||||
assertEquals(decl.getTypeName(), "void(*)(char)");
|
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 {
|
public void testDeclarators_0024() throws CModelException {
|
||||||
ITranslationUnit tu = getTU();
|
ITranslationUnit tu = getTU();
|
||||||
ICElement element = tu.getElement("decl_0024");
|
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.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;
|
||||||
|
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) {
|
public static String getSignatureString(IASTDeclSpecifier declSpecifier, IASTDeclarator declarator) {
|
||||||
final StringBuilder buffer= new StringBuilder();
|
final StringBuilder buffer= new StringBuilder();
|
||||||
appendDeclarationString(buffer, declSpecifier, declarator, true);
|
appendDeclarationString(buffer, declSpecifier, declarator, null);
|
||||||
return trimRight(buffer).toString();
|
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 declSpecifier
|
||||||
* @param declarator
|
* @param fdecl
|
||||||
* @return the type string
|
* @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();
|
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();
|
return trimRight(buffer).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,47 +242,46 @@ public class ASTStringUtil {
|
||||||
else
|
else
|
||||||
declSpec= null;
|
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) {
|
if (declSpecifier != null) {
|
||||||
appendDeclSpecifierString(buffer, declSpecifier);
|
appendDeclSpecifierString(buffer, declSpecifier);
|
||||||
trimRight(buffer);
|
trimRight(buffer);
|
||||||
}
|
}
|
||||||
appendDeclaratorString(buffer, declarator, addParams);
|
appendDeclaratorString(buffer, declarator, false, returnTypeOf);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StringBuilder appendDeclaratorString(StringBuilder buffer, IASTDeclarator declarator,
|
private static StringBuilder appendDeclaratorString(StringBuilder buffer, IASTDeclarator declarator,
|
||||||
boolean addParams) {
|
boolean protectPointers, IASTFunctionDeclarator returnTypeOf) {
|
||||||
if (declarator == null) {
|
if (declarator == null) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
appendPointerOperatorsString(buffer, declarator.getPointerOperators());
|
final IASTPointerOperator[] ptrs = declarator.getPointerOperators();
|
||||||
if (declarator instanceof IASTArrayDeclarator) {
|
final boolean useParenthesis= protectPointers && ptrs.length > 0;
|
||||||
appendArrayQualifiersString(buffer, (IASTArrayDeclarator)declarator);
|
if (useParenthesis) {
|
||||||
|
buffer.append(Keywords.cpLPAREN);
|
||||||
|
protectPointers= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appendPointerOperatorsString(buffer, ptrs);
|
||||||
|
|
||||||
|
if (declarator != returnTypeOf) {
|
||||||
final IASTDeclarator nestedDeclarator= declarator.getNestedDeclarator();
|
final IASTDeclarator nestedDeclarator= declarator.getNestedDeclarator();
|
||||||
if (nestedDeclarator != null) {
|
if (nestedDeclarator != null) {
|
||||||
StringBuilder tmp= new StringBuilder();
|
protectPointers=
|
||||||
appendDeclaratorString(tmp, nestedDeclarator, addParams);
|
protectPointers || declarator instanceof IASTArrayDeclarator
|
||||||
trimRight(tmp);
|
|| declarator instanceof IASTFunctionDeclarator
|
||||||
final int tmpLength= tmp.length();
|
|| declarator instanceof IASTFieldDeclarator;
|
||||||
if (tmpLength > 0) {
|
appendDeclaratorString(buffer, nestedDeclarator, protectPointers, returnTypeOf);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (declarator instanceof IASTArrayDeclarator) {
|
||||||
if (!addParams) {
|
appendArrayQualifiersString(buffer, (IASTArrayDeclarator)declarator);
|
||||||
return buffer;
|
} else if (declarator instanceof IASTFunctionDeclarator) {
|
||||||
}
|
|
||||||
if (declarator instanceof IASTFunctionDeclarator) {
|
|
||||||
final IASTFunctionDeclarator functionDecl= (IASTFunctionDeclarator)declarator;
|
final IASTFunctionDeclarator functionDecl= (IASTFunctionDeclarator)declarator;
|
||||||
appendParameterSignatureString(buffer, functionDecl);
|
appendParameterSignatureString(buffer, functionDecl);
|
||||||
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
if (declarator instanceof ICPPASTFunctionDeclarator) {
|
||||||
|
@ -316,7 +317,12 @@ public class ASTStringUtil {
|
||||||
appendExpressionString(buffer, bitFieldSize);
|
appendExpressionString(buffer, bitFieldSize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// assert false : "TODO: handle "+ declarator.getClass().getName(); //$NON-NLS-1$
|
// just a nested name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (useParenthesis) {
|
||||||
|
trimRight(buffer);
|
||||||
|
buffer.append(Keywords.cpRPAREN);
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -358,7 +364,7 @@ public class ASTStringUtil {
|
||||||
|
|
||||||
private static StringBuilder appendTypeIdString(StringBuilder buffer, IASTTypeId typeId) {
|
private static StringBuilder appendTypeIdString(StringBuilder buffer, IASTTypeId typeId) {
|
||||||
appendDeclSpecifierString(buffer, typeId.getDeclSpecifier());
|
appendDeclSpecifierString(buffer, typeId.getDeclSpecifier());
|
||||||
appendDeclaratorString(buffer, typeId.getAbstractDeclarator(), true);
|
appendDeclaratorString(buffer, typeId.getAbstractDeclarator(), false, null);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +465,7 @@ public class ASTStringUtil {
|
||||||
}
|
}
|
||||||
final IASTDeclarator declarator= parameter.getDeclarator();
|
final IASTDeclarator declarator= parameter.getDeclarator();
|
||||||
if (declarator != null) {
|
if (declarator != null) {
|
||||||
appendDeclaratorString(buffer, declarator, true);
|
appendDeclaratorString(buffer, declarator, false, null);
|
||||||
appendInitializerString(buffer, declarator.getInitializer());
|
appendInitializerString(buffer, declarator.getInitializer());
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -467,23 +467,13 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
if (declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
if (declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
|
||||||
return createTypeDef(parent, declSpecifier, declarator);
|
return createTypeDef(parent, declSpecifier, declarator);
|
||||||
}
|
}
|
||||||
if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
|
IASTDeclarator typeRelevant= CPPVisitor.findTypeRelevantDeclarator(declarator);
|
||||||
return createFunctionDeclaration(parent, declSpecifier, (IASTFunctionDeclarator)declarator, isTemplate);
|
if (typeRelevant instanceof IASTFunctionDeclarator) {
|
||||||
|
return createFunctionDeclaration(parent, declSpecifier, (IASTFunctionDeclarator)typeRelevant, isTemplate);
|
||||||
}
|
}
|
||||||
return createVariable(parent, declSpecifier, declarator, 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{
|
private void createNamespace(Parent parent, ICPPASTNamespaceDefinition declaration) throws CModelException, DOMException{
|
||||||
// create element
|
// create element
|
||||||
final String type= Keywords.NAMESPACE;
|
final String type= Keywords.NAMESPACE;
|
||||||
|
@ -826,7 +816,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
|
|
||||||
final String functionName= ASTStringUtil.getSimpleName(name);
|
final String functionName= ASTStringUtil.getSimpleName(name);
|
||||||
final String[] parameterTypes= ASTStringUtil.getParameterSignatureArray(declarator);
|
final String[] parameterTypes= ASTStringUtil.getParameterSignatureArray(declarator);
|
||||||
final String returnType= ASTStringUtil.getTypeString(declSpecifier, declarator);
|
final String returnType= ASTStringUtil.getReturnTypeString(declSpecifier, declarator);
|
||||||
|
|
||||||
final FunctionDeclaration element;
|
final FunctionDeclaration element;
|
||||||
final FunctionInfo info;
|
final FunctionInfo info;
|
||||||
|
@ -963,7 +953,7 @@ public class CModelBuilder2 implements IContributedModelBuilder {
|
||||||
|
|
||||||
final String functionName= ASTStringUtil.getSimpleName(name);
|
final String functionName= ASTStringUtil.getSimpleName(name);
|
||||||
final String[] parameterTypes= ASTStringUtil.getParameterSignatureArray(declarator);
|
final String[] parameterTypes= ASTStringUtil.getParameterSignatureArray(declarator);
|
||||||
final String returnType= ASTStringUtil.getTypeString(declSpecifier, declarator);
|
final String returnType= ASTStringUtil.getReturnTypeString(declSpecifier, declarator);
|
||||||
|
|
||||||
final FunctionDeclaration element;
|
final FunctionDeclaration element;
|
||||||
final FunctionInfo info;
|
final FunctionInfo info;
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class ExtractFunctionInputPage extends UserInputWizardPage {
|
||||||
setPageComplete(true);
|
setPageComplete(true);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage());
|
setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage()); //$NON-NLS-1$
|
||||||
setPageComplete(false);
|
setPageComplete(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue