mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
JUnit-tests: ported Scanner2Tests to DOMScannerTests.
This commit is contained in:
parent
3dd82904da
commit
f71f0d74ca
5 changed files with 2536 additions and 46 deletions
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -103,17 +104,8 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems , boolean parseComments) throws ParserException {
|
protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems , boolean parseComments) throws ParserException {
|
||||||
CodeReader codeReader = new CodeReader(code
|
IScanner scanner = createScanner(new CodeReader(code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||||
.toCharArray());
|
new ScannerInfo(), parseComments);
|
||||||
ScannerInfo scannerInfo = new ScannerInfo();
|
|
||||||
IScannerExtensionConfiguration configuration = null;
|
|
||||||
if( lang == ParserLanguage.C )
|
|
||||||
configuration = new GCCScannerExtensionConfiguration();
|
|
||||||
else
|
|
||||||
configuration = new GPPScannerExtensionConfiguration();
|
|
||||||
IScanner scanner = new DOMScanner( codeReader, scannerInfo, ParserMode.COMPLETE_PARSE, lang, NULL_LOG, configuration, FileCodeReaderFactory.getInstance() );
|
|
||||||
scanner.setScanComments(parseComments);
|
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser2 = null;
|
||||||
if( lang == ParserLanguage.CPP )
|
if( lang == ParserLanguage.CPP )
|
||||||
{
|
{
|
||||||
|
@ -158,6 +150,18 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IScanner createScanner(CodeReader codeReader, ParserLanguage lang, ParserMode mode,
|
||||||
|
ScannerInfo scannerInfo, boolean parseComments) {
|
||||||
|
IScannerExtensionConfiguration configuration = null;
|
||||||
|
if( lang == ParserLanguage.C )
|
||||||
|
configuration = new GCCScannerExtensionConfiguration();
|
||||||
|
else
|
||||||
|
configuration = new GPPScannerExtensionConfiguration();
|
||||||
|
IScanner scanner = new DOMScanner( codeReader, scannerInfo, mode, lang, NULL_LOG, configuration, FileCodeReaderFactory.getInstance() );
|
||||||
|
scanner.setScanComments(parseComments);
|
||||||
|
return scanner;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Emanuel Graf (IFS)
|
* Emanuel Graf (IFS)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ public class DOMParserTestSuite extends TestCase {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite(ParserTestSuite.class.getName());
|
TestSuite suite= new TestSuite(ParserTestSuite.class.getName());
|
||||||
suite.addTest( AST2Tests.suite() );
|
suite.addTest(DOMScannerTests.suite());
|
||||||
|
suite.addTest(AST2Tests.suite());
|
||||||
suite.addTestSuite( GCCTests.class );
|
suite.addTestSuite( GCCTests.class );
|
||||||
suite.addTestSuite( AST2CPPTests.class );
|
suite.addTestSuite( AST2CPPTests.class );
|
||||||
suite.addTest( AST2TemplateTests.suite() );
|
suite.addTest( AST2TemplateTests.suite() );
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -122,7 +122,10 @@ public class BaseTestCase extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CCorePlugin.getDefault().getLog().addLogListener(logListener);
|
final CCorePlugin corePlugin = CCorePlugin.getDefault();
|
||||||
|
if (corePlugin != null) { // if we don't run a JUnit Plugin Test
|
||||||
|
corePlugin.getLog().addLogListener(logListener);
|
||||||
|
}
|
||||||
|
|
||||||
Throwable testThrowable= null;
|
Throwable testThrowable= null;
|
||||||
try {
|
try {
|
||||||
|
@ -151,7 +154,9 @@ public class BaseTestCase extends TestCase {
|
||||||
throw afe;
|
throw afe;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
CCorePlugin.getDefault().getLog().removeLogListener(logListener);
|
if (corePlugin != null) {
|
||||||
|
corePlugin.getLog().removeLogListener(logListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(testThrowable!=null)
|
if(testThrowable!=null)
|
||||||
|
|
|
@ -1832,21 +1832,20 @@ abstract class BaseScanner implements IScanner {
|
||||||
start = bufferPos[bufferStackPos] + 1;
|
start = bufferPos[bufferStackPos] + 1;
|
||||||
length = 0;
|
length = 0;
|
||||||
boolean escaped = false;
|
boolean escaped = false;
|
||||||
while (++bufferPos[bufferStackPos] < limit) {
|
for (length=0; ++bufferPos[bufferStackPos] < limit; length++) {
|
||||||
++length;
|
|
||||||
c = buffer[bufferPos[bufferStackPos]];
|
c = buffer[bufferPos[bufferStackPos]];
|
||||||
if (c == '"') {
|
if (c == '"') {
|
||||||
if (!escaped)
|
if (!escaped) {
|
||||||
|
filename = new String(buffer, start, length);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else if (c == '\\') {
|
} else if (c == '\\') {
|
||||||
escaped = !escaped;
|
escaped = !escaped;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
escaped = false;
|
escaped = false;
|
||||||
}
|
}
|
||||||
--length;
|
|
||||||
|
|
||||||
filename = new String(buffer, start, length);
|
|
||||||
nameOffset = start;
|
nameOffset = start;
|
||||||
nameEndOffset = start + length;
|
nameEndOffset = start + length;
|
||||||
endOffset = start + length + 1;
|
endOffset = start + length + 1;
|
||||||
|
@ -1855,16 +1854,16 @@ abstract class BaseScanner implements IScanner {
|
||||||
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
||||||
local = false;
|
local = false;
|
||||||
start = bufferPos[bufferStackPos] + 1;
|
start = bufferPos[bufferStackPos] + 1;
|
||||||
length = 0;
|
|
||||||
|
|
||||||
while (++bufferPos[bufferStackPos] < limit
|
for (length=0; ++bufferPos[bufferStackPos] < limit; length++) {
|
||||||
&& buffer[bufferPos[bufferStackPos]] != '>')
|
if (buffer[bufferPos[bufferStackPos]] == '>') {
|
||||||
++length;
|
filename= new String(buffer, start, length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
endOffset = start + length + 1;
|
endOffset = start + length + 1;
|
||||||
nameOffset = start;
|
nameOffset = start;
|
||||||
nameEndOffset = start + length;
|
nameEndOffset = start + length;
|
||||||
|
|
||||||
filename = new String(buffer, start, length);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// handle macro expansions
|
// handle macro expansions
|
||||||
|
@ -2260,8 +2259,13 @@ abstract class BaseScanner implements IScanner {
|
||||||
int currarg = -1;
|
int currarg = -1;
|
||||||
while (bufferPos[bufferStackPos] < limit) {
|
while (bufferPos[bufferStackPos] < limit) {
|
||||||
skipOverWhiteSpace();
|
skipOverWhiteSpace();
|
||||||
if (++bufferPos[bufferStackPos] >= limit)
|
if (++bufferPos[bufferStackPos] >= limit) {
|
||||||
|
if (reportProblems) {
|
||||||
|
handleProblem(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN,
|
||||||
|
idstart, name);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
c = buffer[bufferPos[bufferStackPos]];
|
c = buffer[bufferPos[bufferStackPos]];
|
||||||
int argstart = bufferPos[bufferStackPos];
|
int argstart = bufferPos[bufferStackPos];
|
||||||
if (c == ')') {
|
if (c == ')') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue