mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-25 09:55:29 +02:00
Cosmetics.
This commit is contained in:
parent
815d32990c
commit
6878112781
9 changed files with 443 additions and 495 deletions
|
@ -8,10 +8,6 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Sept 28, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -41,7 +37,7 @@ public class FileBasePluginTest extends TestCase {
|
|||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
static int numProjects = 0;
|
||||
static int numProjects;
|
||||
static Class className;
|
||||
static ICProject cPrj;
|
||||
|
||||
|
@ -52,111 +48,94 @@ public class FileBasePluginTest extends TestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
private void initialize(Class aClassName){
|
||||
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
|
||||
private void initialize(Class aClassName) {
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
|
||||
|
||||
// ugly
|
||||
if (className == null || !className.equals(aClassName)) {
|
||||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
} catch (CoreException e) {
|
||||
// Ignore
|
||||
}
|
||||
if (project == null)
|
||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
|
||||
public FileBasePluginTest(String name, Class className)
|
||||
{
|
||||
public FileBasePluginTest(String name, Class className) {
|
||||
super(name);
|
||||
initialize(className);
|
||||
}
|
||||
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
numProjects--;
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
if (numProjects == 0) {
|
||||
project.delete( true, false, monitor );
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
}
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if( project == null || !project.exists() )
|
||||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
|
||||
IResource [] members = project.members();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
try {
|
||||
members[i].delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// below can be used to work with large files (too large for memory)
|
||||
// protected IFile importFile(String fileName) throws Exception {
|
||||
// IFile file = cPrj.getProject().getFile(fileName);
|
||||
// if (!file.exists()) {
|
||||
// try{
|
||||
// FileInputStream fileIn = new FileInputStream(
|
||||
// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
|
||||
// file.create(fileIn,false, monitor);
|
||||
// } catch (CoreException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return file;
|
||||
// }
|
||||
|
||||
protected IFolder importFolder(String folderName) throws Exception {
|
||||
IFolder folder = project.getProject().getFolder(folderName);
|
||||
|
||||
//Create file input stream
|
||||
if( !folder.exists() )
|
||||
folder.create( false, false, monitor );
|
||||
|
||||
|
||||
// Create file input stream
|
||||
if (!folder.exists())
|
||||
folder.create(false, false, monitor);
|
||||
|
||||
return folder;
|
||||
}
|
||||
public IFile importFile(String fileName, String contents ) throws Exception{
|
||||
//Obtain file handle
|
||||
|
||||
public IFile importFile(String fileName, String contents) throws Exception {
|
||||
// Obtain file handle
|
||||
IFile file = project.getProject().getFile(fileName);
|
||||
|
||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
||||
//Create file input stream
|
||||
if( file.exists() )
|
||||
file.setContents( stream, false, false, monitor );
|
||||
else
|
||||
file.create( stream, false, monitor );
|
||||
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
// Create file input stream
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, false, false, monitor);
|
||||
} else {
|
||||
file.create(stream, false, monitor);
|
||||
}
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,11 +124,11 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
public AST2BaseTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public AST2BaseTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
sValidateCopy= true;
|
||||
|
@ -138,7 +138,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException {
|
||||
return parse(code, lang, false, true);
|
||||
}
|
||||
|
||||
|
||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
||||
return parse(code, lang, useGNUExtensions, true);
|
||||
}
|
||||
|
@ -147,10 +147,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
boolean expectNoProblems) throws ParserException {
|
||||
return parse(code, lang, useGNUExtensions, expectNoProblems, false);
|
||||
}
|
||||
|
||||
|
||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
|
||||
boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
|
||||
IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||
IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||
createScannerInfo(useGNUExtensions));
|
||||
configureScanner(scanner);
|
||||
AbstractGNUSourceCodeParser parser = null;
|
||||
|
@ -170,12 +170,12 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
} else {
|
||||
config = new ANSICParserExtensionConfiguration();
|
||||
}
|
||||
|
||||
|
||||
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
||||
}
|
||||
if (skipTrivialInitializers)
|
||||
parser.setSkipTrivialExpressionsInAggregateInitializers(true);
|
||||
|
||||
|
||||
IASTTranslationUnit tu = parser.parse();
|
||||
assertTrue(tu.isFrozen());
|
||||
if (sValidateCopy)
|
||||
|
@ -183,7 +183,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
if (parser.encounteredError() && expectNoProblems)
|
||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||
|
||||
|
||||
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||
assertEquals(CVisitor.getProblems(tu).length, 0);
|
||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||
|
@ -193,7 +193,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
if (expectNoProblems)
|
||||
assertEquals(0, tu.getPreprocessorProblems().length);
|
||||
|
||||
|
||||
return tu;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
|
||||
}
|
||||
IScanner scanner;
|
||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||
IncludeFileContentProvider.getSavedFilesProvider());
|
||||
return scanner;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
|
||||
protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
|
||||
IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
|
||||
IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
|
||||
assertNotNull(e);
|
||||
assertEquals(e.getOperator(), operand);
|
||||
IASTIdExpression x = (IASTIdExpression) e.getOperand1();
|
||||
|
@ -290,8 +290,8 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
ASTComparer.assertCopy(tu, copy);
|
||||
return (T) copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -309,22 +309,22 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
return null;
|
||||
return nameList.get(idx);
|
||||
}
|
||||
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertInstances(CNameCollector collector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
|
||||
|
||||
assertNotNull(binding);
|
||||
|
||||
|
||||
for (int i = 0; i < collector.size(); i++) {
|
||||
if (collector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
assertEquals(count, num);
|
||||
}
|
||||
|
||||
|
@ -332,12 +332,12 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
public CPPNameCollector() {
|
||||
this(false); // don't visit implicit names by default
|
||||
}
|
||||
|
||||
|
||||
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||
this.shouldVisitNames = true;
|
||||
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||
}
|
||||
|
||||
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
@Override
|
||||
|
@ -355,7 +355,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
|
||||
|
||||
public void dump() {
|
||||
for (int i= 0; i < size(); i++) {
|
||||
IASTName name= getName(i);
|
||||
|
@ -371,7 +371,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
if (collector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
assertEquals(num, count);
|
||||
}
|
||||
|
||||
|
@ -392,42 +392,42 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
String expressionString = ASTStringUtil.getExpressionString(exp);
|
||||
assertEquals(str, expressionString);
|
||||
}
|
||||
|
||||
|
||||
protected void isParameterSignatureEqual(IASTDeclarator decltor, String str) {
|
||||
assertTrue(decltor instanceof IASTFunctionDeclarator);
|
||||
final String[] sigArray = ASTStringUtil.getParameterSignatureArray((IASTFunctionDeclarator) decltor);
|
||||
assertEquals(str, "(" + ASTStringUtil.join(sigArray, ", ") + ")");
|
||||
}
|
||||
|
||||
|
||||
protected void isSignatureEqual(IASTDeclarator declarator, String expected) {
|
||||
String signature= ASTStringUtil.getSignatureString(declarator);
|
||||
assertEquals(expected, signature);
|
||||
}
|
||||
|
||||
|
||||
protected void isSignatureEqual(IASTDeclSpecifier declSpec, String str) {
|
||||
assertEquals(str, ASTStringUtil.getSignatureString(declSpec, null));
|
||||
}
|
||||
|
||||
|
||||
protected void isSignatureEqual(IASTTypeId typeId, String str) {
|
||||
assertEquals(str, ASTStringUtil.getSignatureString(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator()));
|
||||
}
|
||||
|
||||
|
||||
protected void isTypeEqual(IASTDeclarator decltor, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getType(decltor));
|
||||
}
|
||||
|
||||
|
||||
protected void isTypeEqual(IASTTypeId typeId, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getType(typeId));
|
||||
}
|
||||
|
||||
|
||||
protected void isTypeEqual(IType type, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getType(type));
|
||||
}
|
||||
|
||||
|
||||
protected void isParameterTypeEqual(IFunctionType fType, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getParameterTypeString(fType));
|
||||
}
|
||||
|
||||
|
||||
static protected class CNameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -455,9 +455,9 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static protected class CPPNameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -485,13 +485,13 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String getAboveComment() throws IOException {
|
||||
return getContents(1)[0].toString();
|
||||
}
|
||||
|
||||
|
||||
protected CharSequence[] getContents(int sections) throws IOException {
|
||||
CTestPlugin plugin = CTestPlugin.getDefault();
|
||||
if (plugin == null)
|
||||
|
@ -508,14 +508,14 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
return clazz.cast(o);
|
||||
}
|
||||
|
||||
|
||||
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
|
||||
assertInstance(binding, IField.class);
|
||||
assertEquals(fieldName, binding.getName());
|
||||
ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
|
||||
assertEquals(ownerName, struct.getName());
|
||||
}
|
||||
|
||||
|
||||
protected class BindingAssertionHelper {
|
||||
protected IASTTranslationUnit tu;
|
||||
protected String contents;
|
||||
|
@ -568,7 +568,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
IBinding binding= binding(section, len);
|
||||
if (binding instanceof IProblemBinding) {
|
||||
IProblemBinding problem= (IProblemBinding) binding;
|
||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
||||
}
|
||||
if (binding == null) {
|
||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||
|
@ -617,12 +617,12 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
IASTName name = findImplicitName(section, len);
|
||||
final String selection = section.substring(0, len);
|
||||
assertNotNull("did not find \"" + selection + "\"", name);
|
||||
|
||||
|
||||
assertInstance(name, IASTImplicitName.class);
|
||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||
assertNotNull(implicits);
|
||||
|
||||
|
||||
if (implicits.length > 1) {
|
||||
boolean found = false;
|
||||
for (IASTImplicitName n : implicits) {
|
||||
|
@ -633,34 +633,34 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
assertTrue(found);
|
||||
}
|
||||
|
||||
|
||||
assertEquals(selection, name.getRawSignature());
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull(binding);
|
||||
assertInstance(binding, bindingClass);
|
||||
return (IASTImplicitName) name;
|
||||
}
|
||||
|
||||
|
||||
public void assertNoImplicitName(String section, int len) {
|
||||
IASTName name = findImplicitName(section, len);
|
||||
final String selection = section.substring(0, len);
|
||||
assertNull("found name \"" + selection + "\"", name);
|
||||
}
|
||||
|
||||
|
||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||
IASTName name = findImplicitName(section, len);
|
||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||
return implicits;
|
||||
}
|
||||
|
||||
|
||||
public IASTName findName(String section, int len) {
|
||||
final int offset = contents.indexOf(section);
|
||||
assertTrue("Section \"" + section + "\" not found", offset >= 0);
|
||||
IASTNodeSelector selector = tu.getNodeSelector(null);
|
||||
return selector.findName(offset, len);
|
||||
}
|
||||
|
||||
|
||||
public IASTName findName(String context, String name) {
|
||||
if (context == null) {
|
||||
context = contents;
|
||||
|
@ -718,7 +718,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
return "Unknown problem ID";
|
||||
}
|
||||
|
||||
|
||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
|
||||
if (len <= 0)
|
||||
len += section.length();
|
||||
|
@ -750,10 +750,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
final String selection = section.substring(0, len);
|
||||
assertNotNull("No AST name for \"" + selection + "\"", astName);
|
||||
assertEquals(selection, astName.getRawSignature());
|
||||
|
||||
|
||||
IBinding binding = astName.resolveBinding();
|
||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||
|
||||
|
||||
return astName.resolveBinding();
|
||||
}
|
||||
|
||||
|
@ -761,10 +761,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
IASTName astName = findName(context, name);
|
||||
assertNotNull("No AST name for \"" + name + "\"", astName);
|
||||
assertEquals(name, astName.getRawSignature());
|
||||
|
||||
|
||||
IBinding binding = astName.resolveBinding();
|
||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||
|
||||
|
||||
return astName.resolveBinding();
|
||||
}
|
||||
}
|
||||
|
@ -776,10 +776,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
|
||||
return parseAndCheckBindings(code, lang, useGnuExtensions, false);
|
||||
}
|
||||
|
||||
|
||||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions,
|
||||
boolean skipTrivialInitializers) throws Exception {
|
||||
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
||||
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
||||
CNameCollector col = new CNameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
||||
|
|
|
@ -33,15 +33,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
|
||||
public AST2CPPImplicitNameTests() {
|
||||
}
|
||||
|
||||
|
||||
public AST2CPPImplicitNameTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(AST2CPPImplicitNameTests.class);
|
||||
}
|
||||
|
||||
|
||||
public IASTImplicitName[] getImplicitNames(IASTTranslationUnit tu, String contents, String section, int len) {
|
||||
final int offset = contents.indexOf(section);
|
||||
assertTrue(offset >= 0);
|
||||
|
@ -76,25 +76,25 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
IASTImplicitName n;
|
||||
|
||||
|
||||
n = ba.assertImplicitName("+= 5", 2, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(14).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("+ p", 1, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(4).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("- p", 1, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(8).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("* p", 1, ICPPFunction.class);
|
||||
assertSame(n.resolveBinding(), col.getName(17).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("/ p", 1, ICPPFunction.class);
|
||||
assertSame(n.resolveBinding(), col.getName(23).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("-p;", 1, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(12).resolveBinding());
|
||||
|
||||
|
||||
ba.assertNoImplicitName("<< 6", 2);
|
||||
ba.assertNoImplicitName("+p;", 1);
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
ba.assertNoImplicitName("&Y::x;", 1);
|
||||
|
||||
|
||||
IASTImplicitName n = ba.assertImplicitName("&y;", 1, ICPPFunction.class);
|
||||
assertSame(n.resolveBinding(), col.getName(9).resolveBinding());
|
||||
}
|
||||
|
@ -166,20 +166,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
// p2->doA();
|
||||
// }
|
||||
public void testArrowOperator() throws Exception {
|
||||
String contents = getAboveComment();
|
||||
String contents = getAboveComment();
|
||||
IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
IASTImplicitName[] implicits = getImplicitNames(tu, contents, "->doA();", 2);
|
||||
|
||||
|
||||
assertNotNull(implicits);
|
||||
assertEquals(2, implicits.length);
|
||||
|
||||
|
||||
assertSame(implicits[1].getBinding(), col.getName(4).resolveBinding());
|
||||
assertSame(implicits[0].getBinding(), col.getName(12).resolveBinding());
|
||||
}
|
||||
|
||||
|
||||
// struct A {
|
||||
// int x;
|
||||
// };
|
||||
|
@ -225,15 +225,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
ba.assertNoImplicitName(", b, c, d); // func", 1);
|
||||
ba.assertNoImplicitName(", c, d); // func", 1);
|
||||
ba.assertNoImplicitName(", d); // func", 1);
|
||||
|
||||
|
||||
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d; // expr", 1, ICPPFunction.class);
|
||||
IASTImplicitName opCC = ba.assertImplicitName(", c, d; // expr", 1, ICPPFunction.class);
|
||||
ba.assertNoImplicitName(", d; // expr", 1);
|
||||
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
assertSame(opAB.resolveBinding(), col.getName(5).resolveBinding());
|
||||
assertSame(opCC.resolveBinding(), col.getName(11).resolveBinding());
|
||||
}
|
||||
|
@ -256,20 +256,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testCommaOperator2() throws Exception {
|
||||
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
||||
|
||||
|
||||
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d", 1, ICPPMethod.class);
|
||||
IASTImplicitName opCC = ba.assertImplicitName(", c, d", 1, ICPPFunction.class);
|
||||
IASTImplicitName opDD = ba.assertImplicitName(", d", 1, ICPPMethod.class);
|
||||
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
// 6, 11, 15
|
||||
assertSame(opAB.resolveBinding(), col.getName(6).resolveBinding());
|
||||
assertSame(opCC.resolveBinding(), col.getName(15).resolveBinding());
|
||||
assertSame(opDD.resolveBinding(), col.getName(11).resolveBinding());
|
||||
|
||||
|
||||
ba.assertNonProblem("ee;", 2);
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
IASTImplicitName n1 = ba.assertImplicitName("(b); // 1", 1, ICPPMethod.class);
|
||||
IASTImplicitName n2 = ba.assertImplicitName("); // 1", 1, ICPPMethod.class);
|
||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||
|
@ -299,14 +299,14 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
// there should be no overlap
|
||||
ba.assertNoImplicitName("b); // 1", 1);
|
||||
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
||||
|
||||
|
||||
n1 = ba.assertImplicitName("(); // 2", 1, ICPPMethod.class);
|
||||
n2 = ba.assertImplicitName("); // 2", 1, ICPPMethod.class);
|
||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||
assertFalse(n1.isAlternate());
|
||||
assertTrue(n2.isAlternate());
|
||||
assertSame(col.getName(3).resolveBinding(), n1.resolveBinding());
|
||||
|
||||
|
||||
n1 = ba.assertImplicitName("(1, 2); // 3", 1, ICPPMethod.class);
|
||||
n2 = ba.assertImplicitName("); // 3", 1, ICPPMethod.class);
|
||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||
|
@ -349,7 +349,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
IASTImplicitName n1 = ba.assertImplicitName("[0]); //1", 1, ICPPMethod.class);
|
||||
ba.assertNoImplicitName("0]); //1", 1);
|
||||
IASTImplicitName n2 = ba.assertImplicitName("]); //1", 1, ICPPMethod.class);
|
||||
|
@ -357,7 +357,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
assertFalse(n1.isAlternate());
|
||||
assertTrue(n2.isAlternate());
|
||||
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
||||
|
||||
|
||||
n1 = ba.assertImplicitName("[q]); //2", 1, ICPPMethod.class);
|
||||
ba.assertNoImplicitName("q]); //2", 1);
|
||||
n2 = ba.assertImplicitName("]); //2", 1, ICPPMethod.class);
|
||||
|
@ -385,21 +385,21 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
assertEquals(2, names.length);
|
||||
IASTImplicitName destructor = names[0];
|
||||
IASTImplicitName delete = names[1];
|
||||
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
assertSame(col.getName(1).resolveBinding(), destructor.resolveBinding());
|
||||
assertSame(col.getName(2).resolveBinding(), delete.resolveBinding());
|
||||
|
||||
|
||||
names = ba.getImplicitNames("delete[] x;", 6);
|
||||
assertEquals(1, names.length);
|
||||
assertSame(col.getName(4).resolveBinding(), names[0].resolveBinding());
|
||||
|
||||
|
||||
ba.assertNoImplicitName("delete 1;", 6);
|
||||
}
|
||||
|
||||
|
||||
// struct A {
|
||||
// void operator delete(void * a);
|
||||
// };
|
||||
|
@ -417,15 +417,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IBinding m= bh.assertNonProblem("operator delete(void * a)", 15);
|
||||
IBinding f= bh.assertNonProblem("operator delete(void * b)", 15);
|
||||
|
||||
|
||||
IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6);
|
||||
assertEquals(2, names.length);
|
||||
assertEquals(2, names.length);
|
||||
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
||||
assertSame(m, names[1].resolveBinding());
|
||||
|
||||
names = bh.getImplicitNames("delete b;", 6);
|
||||
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
||||
assertEquals(2, names.length);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(f, names[1].resolveBinding());
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IBinding m= bh.assertNonProblem("operator new(size_t a)", 12);
|
||||
IBinding f= bh.assertNonProblem("operator new(size_t b)", 12);
|
||||
|
||||
|
||||
IASTImplicitName[] names = bh.getImplicitNames("new A;", 3);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(m, names[0].resolveBinding());
|
||||
|
@ -462,9 +462,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
public void testImplicitNewAndDelete() throws Exception {
|
||||
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
||||
ba.assertNoImplicitName("new X", 3);
|
||||
ba.assertNoImplicitName("delete[]", 6);
|
||||
ba.assertNoImplicitName("delete[]", 6);
|
||||
}
|
||||
|
||||
|
||||
// typedef long unsigned int size_t
|
||||
// struct nothrow_t {};
|
||||
// extern const nothrow_t nothrow;
|
||||
|
@ -492,7 +492,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
assertSame(col.getName(9).resolveBinding(), n2.resolveBinding());
|
||||
assertSame(col.getName(14).resolveBinding(), n3.resolveBinding());
|
||||
}
|
||||
|
||||
|
||||
// int test() {
|
||||
// throw;
|
||||
// }
|
||||
|
@ -552,7 +552,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTImplicitName v = ba.assertImplicitName("v(p)", 1, ICPPConstructor.class);
|
||||
assertSame(ctor1, v.resolveBinding());
|
||||
}
|
||||
|
||||
|
||||
// enum A {aa};
|
||||
// struct B{ operator A();};
|
||||
// bool operator==(A, A); // overrides the built-in operator.
|
||||
|
@ -568,5 +568,5 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
ICPPFunction op = ba.assertNonProblem("operator==", 0);
|
||||
IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class);
|
||||
assertSame(op, a.resolveBinding());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals(declNames.length, i);
|
||||
assertEquals(defNames.length, j);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void assertSameType(IType first, IType second){
|
||||
assertNotNull(first);
|
||||
|
@ -8397,7 +8397,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// TODO(nathanridge): Perhaps we should store implicit names even if they
|
||||
// resolve to ProblemBindings. Then we can do the stronger check in the
|
||||
// 3 commented lines below.
|
||||
//IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
|
||||
//IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
|
||||
//problem= (IProblemBinding) n.resolveBinding();
|
||||
//assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
|
||||
bh.assertProblem("fH(1)", 2);
|
||||
|
@ -9827,7 +9827,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
// struct Base {
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDef(){}
|
||||
// };
|
||||
// struct S : public Base {
|
||||
|
@ -9855,9 +9855,9 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
|
||||
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
|
||||
}
|
||||
|
||||
|
||||
// struct Base {
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDef(){}
|
||||
// };
|
||||
// struct S : public Base {
|
||||
|
@ -10029,7 +10029,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// double vdouble;
|
||||
// long double vlongdouble;
|
||||
// UnscopedEnum vue;
|
||||
//
|
||||
//
|
||||
// // Narrowing conversions
|
||||
// fint({vdouble});
|
||||
// ffloat({vlongdouble});
|
||||
|
@ -10087,7 +10087,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
helper.assertNonProblemOnFirstIdentifier("fint({vbool");
|
||||
helper.assertNonProblemOnFirstIdentifier("fint({vchar");
|
||||
}
|
||||
|
||||
|
||||
// namespace std {
|
||||
// struct string {};
|
||||
// struct exception {};
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Sept 28, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -44,7 +40,7 @@ public class AST2FileBasePluginTest extends TestCase {
|
|||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
static int numProjects = 0;
|
||||
static int numProjects;
|
||||
static Class className;
|
||||
static ICProject cPrj;
|
||||
|
||||
|
@ -55,100 +51,100 @@ public class AST2FileBasePluginTest extends TestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
private void initialize(Class aClassName){
|
||||
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
|
||||
private void initialize(Class aClassName) {
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
||||
project = cPrj.getProject();
|
||||
|
||||
|
||||
// ugly
|
||||
if (className == null || !className.equals(aClassName)) {
|
||||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
} catch (CoreException e) {
|
||||
// Ignore
|
||||
}
|
||||
if (project == null)
|
||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
|
||||
// Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
|
||||
public AST2FileBasePluginTest(String name, Class className)
|
||||
{
|
||||
public AST2FileBasePluginTest(String name, Class className) {
|
||||
super(name);
|
||||
initialize(className);
|
||||
}
|
||||
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
numProjects--;
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
if (numProjects == 0) {
|
||||
project.delete( true, false, monitor );
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
}
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if( project == null || !project.exists() )
|
||||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
IResource [] members = project.members();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
try {
|
||||
members[i].delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IFolder importFolder(String folderName) throws Exception {
|
||||
IFolder folder = project.getProject().getFolder(folderName);
|
||||
|
||||
//Create file input stream
|
||||
if( !folder.exists() )
|
||||
folder.create( false, false, monitor );
|
||||
|
||||
|
||||
// Create file input stream
|
||||
if (!folder.exists())
|
||||
folder.create(false, false, monitor);
|
||||
|
||||
return folder;
|
||||
}
|
||||
public IFile importFile(String fileName, String contents ) throws Exception{
|
||||
//Obtain file handle
|
||||
|
||||
public IFile importFile(String fileName, String contents) throws Exception {
|
||||
// Obtain file handle
|
||||
IFile file = project.getProject().getFile(fileName);
|
||||
|
||||
InputStream stream = new ByteArrayInputStream( contents.getBytes() );
|
||||
//Create file input stream
|
||||
if( file.exists() )
|
||||
file.setContents( stream, false, false, monitor );
|
||||
else
|
||||
file.create( stream, false, monitor );
|
||||
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
// Create file input stream
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, false, false, monitor);
|
||||
} else {
|
||||
file.create(stream, false, monitor);
|
||||
}
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
protected StringBuilder[] getContents(int sections) throws IOException {
|
||||
return TestSourceReader.getContentsForTest(
|
||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6221,24 +6221,24 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||
ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class);
|
||||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S", "Alias", ITypedef.class);
|
||||
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
|
||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
|
||||
|
||||
|
||||
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, x, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertInstances(collector, foo, 1);
|
||||
assertInstances(collector, myA, 2);
|
||||
}
|
||||
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T x;
|
||||
|
@ -6250,7 +6250,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSpecifiedTemplateAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6259,7 +6259,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S<int>;", "Alias", ITypedef.class);
|
||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
|
||||
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
|
||||
|
||||
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
|
@ -6275,13 +6275,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasBasicType() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
||||
ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
|
||||
ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
|
||||
|
||||
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
}
|
||||
|
@ -6298,7 +6298,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6336,9 +6336,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclarationMultipleParameters() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t1 = assertionHelper.assertNonProblem("T1 t1;", "t1", ICPPField.class);
|
||||
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
|
||||
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
|
||||
|
@ -6379,9 +6379,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclarationTemplateArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
|
||||
|
@ -6402,9 +6402,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasAsTemplateArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
|
@ -6425,9 +6425,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclarationValueArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
|
||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||
|
||||
|
@ -6448,9 +6448,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDefaultArguments() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
|
||||
ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
|
||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||
|
@ -6472,9 +6472,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasTemplateArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
|
||||
|
@ -6499,9 +6499,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasAsFunctionParameter() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
|
||||
|
@ -6524,7 +6524,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasAsFunctionArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(S<int> arg){", "bar", ICPPFunction.class);
|
||||
|
@ -6573,7 +6573,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleFunctionAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6598,7 +6598,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasForTemplateReference() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
|
||||
|
@ -6614,7 +6614,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleFunctionTemplateAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6634,7 +6634,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6659,7 +6659,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasTemplateParameter() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
|
@ -6682,10 +6682,11 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// Alias<int> intAlias;
|
||||
public void testAliasDeclarationContext() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
|
||||
ICPPAliasTemplateInstance AliasInt =
|
||||
assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
|
||||
assertEquals("Alias<int>", AliasInt.getName());
|
||||
assertEquals("NS", AliasInt.getQualifiedName()[0]);
|
||||
assertEquals("Alias<int>", AliasInt.getQualifiedName()[1]);
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -755,7 +755,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
public void testConstructorChain() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
||||
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
public void testScoping() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
||||
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
public void testBug42872() throws Exception {
|
||||
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
||||
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
@ -1293,7 +1293,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testCDesignatedInitializers() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("struct Inner { int a,b,c; };");
|
||||
buffer.append("struct Inner { int a,b,c; };");
|
||||
buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };");
|
||||
buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
|
||||
parse(buffer.toString(), true, ParserLanguage.C);
|
||||
|
@ -1319,7 +1319,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
" _Bool b; " +
|
||||
" f(b);" +
|
||||
" f(g((_Bool) 1) );" +
|
||||
"}",
|
||||
"}",
|
||||
true, ParserLanguage.C);
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1342,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug44925() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("class MyClass { };");
|
||||
buffer.append("class MyClass { };");
|
||||
buffer.append("class MyClass myObj1;");
|
||||
buffer.append("enum MyEnum { Item1 };");
|
||||
buffer.append("enum MyEnum myObj2;");
|
||||
|
@ -1999,7 +1999,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("int main(int argc, char **argv) {\n");
|
||||
writer.write("FILE * file = 0;\n");
|
||||
writer.write("static_function(file);\n");
|
||||
writer.write("return 0;\n");
|
||||
writer.write("return 0;\n");
|
||||
writer.write("}\n");
|
||||
parse(writer.toString());
|
||||
}
|
||||
|
@ -2051,8 +2051,8 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("};\n");
|
||||
writer.write("\n");
|
||||
writer.write("template<typename T>\n");
|
||||
writer.write("inline T526026< T >\n");
|
||||
writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
|
||||
writer.write("inline T526026< T >\n");
|
||||
writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
|
||||
writer.write("{ return T526026< T >(); }\n");
|
||||
writer.write("}\n");
|
||||
parse(writer.toString(), false);
|
||||
|
@ -2060,7 +2060,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug71094() throws Exception {
|
||||
Writer writer = new StringWriter();
|
||||
writer.write("using namespace DOESNOTEXIST;\n");
|
||||
writer.write("using namespace DOESNOTEXIST;\n");
|
||||
writer.write("class A { int x; };\n");
|
||||
parse(writer.toString(), false);
|
||||
}
|
||||
|
@ -2228,7 +2228,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug74328() throws Exception {
|
||||
Writer writer = new StringWriter();
|
||||
writer.write("int\n");
|
||||
writer.write("int\n");
|
||||
writer.write("main(int argc, char **argv) {\n");
|
||||
writer.write(" char *sign;\n");
|
||||
writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
public class TestUtil {
|
||||
/**
|
||||
* Searches the AST upward from the given starting node to find the
|
||||
* nearest IASTImplicitNameOwner and returns its first implicit name,
|
||||
* nearest IASTImplicitNameOwner and returns its first implicit name,
|
||||
* or null if it has no implicit names.
|
||||
*/
|
||||
public static IASTName findImplicitName(IASTNode node) {
|
||||
|
|
Loading…
Add table
Reference in a new issue