mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
CORE
Fixed Bug 43644 : 6 triangle icons appearing in outline viewer when typing an error Fixed Bug 43062 : Outline is confused on operator methods containing spaces Fixed Bug 39531 : Problems with type conversion operators TEST Added QuickParseASTTests::testBug43644() & testBug43062(). Moved ASTFailedTests::testBug39531() to QuickParseASTTests.
This commit is contained in:
parent
3b2b1c6a42
commit
a3a827cf92
9 changed files with 158 additions and 25 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-09-26 John Camelon
|
||||
Added QuickParseASTTests::testBug43644() & testBug43062().
|
||||
Moved ASTFailedTests::testBug39531() to QuickParseASTTests.
|
||||
|
||||
2003-09-25 Andrew Niefer
|
||||
-bug43129 - Cannot search for definitions of global variables
|
||||
-added testbug43129() in OtherPatternTests
|
||||
|
|
|
@ -62,10 +62,6 @@ public class ASTFailedTests extends BaseASTTest
|
|||
}
|
||||
assertCodeFailsParse(code.toString());
|
||||
}
|
||||
public void testBug39531() throws Exception
|
||||
{
|
||||
assertCodeFailsParse("class AString { operator char const *() const; };");
|
||||
}
|
||||
|
||||
public void testBug39536A() throws Exception
|
||||
{
|
||||
|
|
|
@ -421,7 +421,7 @@ public class IndexManagerTests extends TestCase {
|
|||
|
||||
for (int i=0;i<methodresults.length; i++)
|
||||
{
|
||||
assertEquals(methodResultModel[i],methodresults[i].toString());
|
||||
assertEquals("Index is " +i , methodResultModel[i],methodresults[i].toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -811,5 +811,37 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
IASTVariable varX = (IASTVariable)parse( "extern int x;").getDeclarations().next();
|
||||
assertTrue( varX.isExtern() );
|
||||
}
|
||||
|
||||
|
||||
public void testBug43503() throws Exception
|
||||
{
|
||||
StringBuffer buff = new StringBuffer();
|
||||
|
||||
buff.append( "class SD_02 {");
|
||||
buff.append( " public:");
|
||||
buff.append( " void f_SD_02();");
|
||||
buff.append( " };");
|
||||
buff.append( "class SD_01 {\n");
|
||||
buff.append( " public:\n");
|
||||
buff.append( " SD_02 *next;"); // REFERENCE SD_02
|
||||
buff.append( " void f_SD_01();\n");
|
||||
buff.append( "};\n");
|
||||
buff.append( "int main(){\n");
|
||||
buff.append( " SD_01 a = new SD_01();\n"); // REFERENCE SD_01 * 2
|
||||
buff.append( " a->f_SD_01();\n"); // REFERENCE a && REFERENCE f_SD_01
|
||||
buff.append( "}\n");
|
||||
buff.append( "void SD_01::f_SD_01()\n"); // REFERENCE SD_01
|
||||
buff.append( "{\n");
|
||||
buff.append( " next->f_SD_02();\n"); // REFERENCE next && reference f_SD_02
|
||||
buff.append( "}\n");
|
||||
Iterator i = parse( buff.toString() ).getDeclarations();
|
||||
IASTClassSpecifier SD_02 = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
IASTMethod f_SD_02 = (IASTMethod)getDeclarations( SD_02 ).next();
|
||||
IASTClassSpecifier SD_01 = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
IASTField next= (IASTField)getDeclarations( SD_01 ).next();
|
||||
IASTFunction main = (IASTFunction)i.next();
|
||||
IASTVariable a = (IASTVariable)getDeclarations(main).next();
|
||||
IASTMethod f_SD_01 = (IASTMethod)i.next();
|
||||
assertFalse( i.hasNext() );
|
||||
assertAllReferences( 8, createTaskList( new Task( SD_02), new Task( SD_01, 3 ), new Task( a ), new Task( f_SD_01 ), new Task( f_SD_02 ), new Task( next ) ));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
|
@ -687,8 +688,28 @@ public class CompleteParseBaseTest extends TestCase
|
|||
{
|
||||
IASTReference r = (IASTReference)allReferences.next();
|
||||
if( r.getReferencedElement() == element )
|
||||
{
|
||||
if( ! matches.add( r ) && ! allowDuplicates )
|
||||
fail( "Duplicate reference found for ISourceElementCallbackDelegate: " + element + " @ offset " + r.getOffset() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( r.getReferencedElement() instanceof IASTQualifiedNameElement &&
|
||||
element instanceof IASTQualifiedNameElement )
|
||||
{
|
||||
if( qualifiedNamesEquals(
|
||||
((IASTQualifiedNameElement)r.getReferencedElement()).getFullyQualifiedName(),
|
||||
((IASTQualifiedNameElement)element).getFullyQualifiedName()
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
if( ! matches.add( r ) && ! allowDuplicates )
|
||||
fail( "Duplicate reference found for ISourceElementCallbackDelegate: " + element + " @ offset " + r.getOffset() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals( expectedDistinctReferenceCount, matches.size() );
|
||||
|
@ -809,6 +830,22 @@ public class CompleteParseBaseTest extends TestCase
|
|||
result.add( task6 );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public boolean qualifiedNamesEquals( String [] fromAST, String [] theTruth)
|
||||
{
|
||||
if( fromAST == null || theTruth == null ) return false;
|
||||
if( fromAST.length != theTruth.length ) return false;
|
||||
for( int i = 0; i < fromAST.length; ++i )
|
||||
{
|
||||
if( !( fromAST[i].equals( theTruth[i] ) ) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void assertQualifiedName(String [] fromAST, String [] theTruth)
|
||||
{
|
||||
assertTrue( qualifiedNamesEquals( fromAST, theTruth ));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1843,6 +1843,33 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
assertTrue(m1.getVisiblity() == ASTAccessVisibility.PUBLIC);
|
||||
assertTrue(m2.getVisiblity() == ASTAccessVisibility.PUBLIC);
|
||||
assertTrue(m3.getVisiblity() == ASTAccessVisibility.PUBLIC);
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug43644() throws Exception
|
||||
{
|
||||
Iterator i = parse( "void foo();{ int x; }", true, false ).getDeclarations();
|
||||
IASTFunction f = (IASTFunction)i.next();
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testBug43062() throws Exception
|
||||
{
|
||||
Iterator i = parse( "class X { operator short (); operator int unsigned(); operator int signed(); };").getDeclarations();
|
||||
IASTClassSpecifier classX = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
assertFalse( i.hasNext() );
|
||||
Iterator members = classX.getDeclarations();
|
||||
IASTMethod shortMethod = (IASTMethod)members.next();
|
||||
IASTMethod unsignedMethod = (IASTMethod)members.next();
|
||||
IASTMethod signedMethod = (IASTMethod)members.next();
|
||||
assertFalse( members.hasNext() );
|
||||
assertEquals( shortMethod.getName(), "operator short");
|
||||
assertEquals( unsignedMethod.getName(), "operator int unsigned");
|
||||
assertEquals( signedMethod.getName(), "operator int signed");
|
||||
}
|
||||
|
||||
public void testBug39531() throws Exception
|
||||
{
|
||||
parse("class AString { operator char const *() const; };");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
2003-09-26 John Camelon
|
||||
Fixed Bug 43644 : 6 triangle icons appearing in outline viewer when typing an error
|
||||
Fixed Bug 43062 : Outline is confused on operator methods containing spaces
|
||||
Fixed Bug 39531 : Problems with type conversion operators
|
||||
|
||||
2003-09-25 Hoda Amer
|
||||
- Last part of solution to bug#42453: Expression result types not computed
|
||||
Added the handling of POSTFIX_TYPENAME_IDENTIFIER
|
||||
|
|
|
@ -846,8 +846,9 @@ public class Parser implements IParser
|
|||
IASTTemplate ownerTemplate)
|
||||
throws Backtrack
|
||||
{
|
||||
IToken firstToken = LA(1);
|
||||
DeclarationWrapper sdw =
|
||||
new DeclarationWrapper(scope, LA(1).getOffset(), ownerTemplate);
|
||||
new DeclarationWrapper(scope, firstToken.getOffset(), ownerTemplate);
|
||||
|
||||
declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, sdw, forKR );
|
||||
try
|
||||
|
@ -893,6 +894,8 @@ public class Parser implements IParser
|
|||
case IToken.tLBRACE :
|
||||
if (forKR)
|
||||
throw backtrack;
|
||||
if( firstToken == LA(1) )
|
||||
throw backtrack;
|
||||
declarator.setHasFunctionBody(true);
|
||||
hasFunctionBody = true;
|
||||
break;
|
||||
|
@ -2202,7 +2205,7 @@ public class Parser implements IParser
|
|||
else
|
||||
{
|
||||
// must be a conversion function
|
||||
typeId(d.getDeclarationWrapper().getScope(), false );
|
||||
typeId(d.getDeclarationWrapper().getScope(), true );
|
||||
toSend = lastToken;
|
||||
}
|
||||
ITokenDuple duple =
|
||||
|
@ -3553,7 +3556,7 @@ public class Parser implements IParser
|
|||
/**
|
||||
* @throws Backtrack
|
||||
*/
|
||||
protected IASTTypeId typeId(IASTScope scope, boolean forNewExpression ) throws Backtrack
|
||||
protected IASTTypeId typeId(IASTScope scope, boolean skipArrayModifiers ) throws Backtrack
|
||||
{
|
||||
IToken mark = mark();
|
||||
ITokenDuple name = null;
|
||||
|
@ -3576,6 +3579,7 @@ public class Parser implements IParser
|
|||
// do nothing
|
||||
}
|
||||
|
||||
boolean encounteredType = false;
|
||||
simpleMods : for (;;)
|
||||
{
|
||||
switch (LT(1))
|
||||
|
@ -3611,45 +3615,61 @@ public class Parser implements IParser
|
|||
break;
|
||||
|
||||
case IToken.tIDENTIFIER :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
name = name();
|
||||
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
case IToken.t_int :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.INT;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
case IToken.t_char :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.CHAR;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
case IToken.t_bool :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.BOOL;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
case IToken.t_double :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.DOUBLE;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
case IToken.t_float :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.FLOAT;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
case IToken.t_wchar_t :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.WCHAR_T;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
|
||||
case IToken.t_void :
|
||||
if( encounteredType ) break simpleMods;
|
||||
encounteredType = true;
|
||||
kind = IASTSimpleTypeSpecifier.Type.VOID;
|
||||
consume();
|
||||
break simpleMods;
|
||||
break;
|
||||
|
||||
|
||||
default :
|
||||
|
@ -3690,13 +3710,13 @@ public class Parser implements IParser
|
|||
throw backtrack;
|
||||
|
||||
TypeId id = new TypeId();
|
||||
IToken last = mark();
|
||||
IToken last = lastToken;
|
||||
consumePointerOperators( id );
|
||||
if( lastToken == null ) lastToken = last;
|
||||
|
||||
if( ! forNewExpression )
|
||||
if( ! skipArrayModifiers )
|
||||
{
|
||||
last = mark();
|
||||
last = lastToken;
|
||||
consumeArrayModifiers( id, scope );
|
||||
if( lastToken == null ) lastToken = last;
|
||||
}
|
||||
|
|
|
@ -84,16 +84,28 @@ public class TokenDuple implements ITokenDuple {
|
|||
public String toString()
|
||||
{
|
||||
StringBuffer buff = new StringBuffer();
|
||||
IToken prev = null;
|
||||
IToken iter = firstToken;
|
||||
for( ; ; )
|
||||
{
|
||||
buff.append( iter.getImage() );
|
||||
if( iter.getType() == IToken.t_operator )
|
||||
if( prev != null &&
|
||||
prev.getType() != IToken.tCOLONCOLON &&
|
||||
prev.getType() != IToken.tIDENTIFIER &&
|
||||
prev.getType() != IToken.tLT &&
|
||||
prev.getType() != IToken.tCOMPL &&
|
||||
iter.getType() != IToken.tGT &&
|
||||
prev.getType() != IToken.tLBRACKET &&
|
||||
iter.getType() != IToken.tRBRACKET &&
|
||||
iter.getType() != IToken.tCOLONCOLON )
|
||||
buff.append( ' ');
|
||||
|
||||
|
||||
buff.append( iter.getImage() );
|
||||
if( iter == lastToken ) break;
|
||||
prev = iter;
|
||||
iter = iter.getNext();
|
||||
}
|
||||
return buff.toString();
|
||||
return buff.toString().trim();
|
||||
}
|
||||
|
||||
public boolean isIdentifier()
|
||||
|
|
Loading…
Add table
Reference in a new issue