mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
org.eclipse.cdt.core
Added preliminary (crude) SelectionParser IParser implementation for SELECTION_PARSE clients. org.eclipse.cdt.core.tests Added preliminary SelectionParseTests to test SELECTION_PARSE clients. Added SelectionParseTests to ParserTestSuite.
This commit is contained in:
parent
8512e1b76f
commit
395c81dceb
4 changed files with 93 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
2004-02-04 John Camelon
|
||||
Added preliminary SelectionParseTests to test SELECTION_PARSE clients.
|
||||
Added SelectionParseTests to ParserTestSuite.
|
||||
|
||||
2004-01-30 John Camelon
|
||||
Added QuickParseASTTest::testBug47752.
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ public class ParserTestSuite extends TestCase {
|
|||
suite.addTestSuite( PreprocessorConditionalTest.class );
|
||||
suite.addTestSuite( QuickParseASTQualifiedNameTest.class);
|
||||
suite.addTestSuite( CompleteParseASTTest.class );
|
||||
suite.addTestSuite( SelectionParseTest.class );
|
||||
suite.addTestSuite( CompleteParseASTExpressionTest.class );
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.NullLogService;
|
||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class SelectionParseTest extends CompleteParseBaseTest {
|
||||
|
||||
protected IASTNode parse(String code, int offset1, int offset2 )
|
||||
throws Exception {
|
||||
callback = new FullParseCallback();
|
||||
IParser parser = null;
|
||||
|
||||
parser =
|
||||
ParserFactory.createParser(
|
||||
ParserFactory.createScanner(
|
||||
new StringReader(code),
|
||||
"completion-test",
|
||||
new ScannerInfo(),
|
||||
ParserMode.SELECTION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
callback,
|
||||
new NullLogService()),
|
||||
callback,
|
||||
ParserMode.SELECTION_PARSE,
|
||||
ParserLanguage.CPP,
|
||||
ParserUtil.getParserLogService());
|
||||
|
||||
return parser.parse( offset1, offset2 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testBaseCase_Variable() throws Exception
|
||||
{
|
||||
String code = "int x; x=3;";
|
||||
int offset1 = code.indexOf( "x=" );
|
||||
int offset2 = code.indexOf( '=');
|
||||
IASTNode node = parse( code, offset1, offset2 );
|
||||
assertTrue( node instanceof IASTVariable );
|
||||
assertEquals( ((IASTVariable)node).getName(), "x" );
|
||||
}
|
||||
|
||||
public void testBaseCase_Function() throws Exception
|
||||
{
|
||||
String code = "int x(); x( );";
|
||||
int offset1 = code.indexOf( "x( " );
|
||||
int offset2 = code.indexOf( "( )");
|
||||
IASTNode node = parse( code, offset1, offset2 );
|
||||
assertTrue( node instanceof IASTFunction );
|
||||
assertEquals( ((IASTFunction)node).getName(), "x" );
|
||||
}
|
||||
|
||||
public void testBaseCase_Error() throws Exception
|
||||
{
|
||||
String code = "int x(); y( );";
|
||||
int offset1 = code.indexOf( "y( " );
|
||||
int offset2 = code.indexOf( "( )");
|
||||
assertNull( parse( code, offset1, offset2 ));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
2004-02-04 John Camelon
|
||||
Added preliminary (crude) SelectionParser IParser implementation for SELECTION_PARSE clients.
|
||||
|
||||
2004-02-01 John Camelon
|
||||
Added CompletionKind.UNREACHABLE_CODE to IASTCompletionNode.
|
||||
Updated Scanner to handle unreachable code scenarios in content assist.
|
||||
|
|
Loading…
Add table
Reference in a new issue