1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
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:
John Camelon 2003-09-26 19:21:12 +00:00
parent 3b2b1c6a42
commit a3a827cf92
9 changed files with 158 additions and 25 deletions

View file

@ -1,3 +1,7 @@
2003-09-26 John Camelon
Added QuickParseASTTests::testBug43644() & testBug43062().
Moved ASTFailedTests::testBug39531() to QuickParseASTTests.
2003-09-25 Andrew Niefer 2003-09-25 Andrew Niefer
-bug43129 - Cannot search for definitions of global variables -bug43129 - Cannot search for definitions of global variables
-added testbug43129() in OtherPatternTests -added testbug43129() in OtherPatternTests

View file

@ -62,10 +62,6 @@ public class ASTFailedTests extends BaseASTTest
} }
assertCodeFailsParse(code.toString()); assertCodeFailsParse(code.toString());
} }
public void testBug39531() throws Exception
{
assertCodeFailsParse("class AString { operator char const *() const; };");
}
public void testBug39536A() throws Exception public void testBug39536A() throws Exception
{ {

View file

@ -421,7 +421,7 @@ public class IndexManagerTests extends TestCase {
for (int i=0;i<methodresults.length; i++) for (int i=0;i<methodresults.length; i++)
{ {
assertEquals(methodResultModel[i],methodresults[i].toString()); assertEquals("Index is " +i , methodResultModel[i],methodresults[i].toString());
} }
} }

View file

@ -811,5 +811,37 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
IASTVariable varX = (IASTVariable)parse( "extern int x;").getDeclarations().next(); IASTVariable varX = (IASTVariable)parse( "extern int x;").getDeclarations().next();
assertTrue( varX.isExtern() ); 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 ) ));
}
} }

View file

@ -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.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference; import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
import org.eclipse.cdt.core.parser.ast.IASTParameterReference; 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.IASTReference;
import org.eclipse.cdt.core.parser.ast.IASTScope; import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration; import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
@ -687,8 +688,28 @@ public class CompleteParseBaseTest extends TestCase
{ {
IASTReference r = (IASTReference)allReferences.next(); IASTReference r = (IASTReference)allReferences.next();
if( r.getReferencedElement() == element ) if( r.getReferencedElement() == element )
{
if( ! matches.add( r ) && ! allowDuplicates ) if( ! matches.add( r ) && ! allowDuplicates )
fail( "Duplicate reference found for ISourceElementCallbackDelegate: " + element + " @ offset " + r.getOffset() ); 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() ); assertEquals( expectedDistinctReferenceCount, matches.size() );
@ -809,6 +830,22 @@ public class CompleteParseBaseTest extends TestCase
result.add( task6 ); result.add( task6 );
return result; 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 ));
}
} }

View file

@ -1843,6 +1843,33 @@ public class QuickParseASTTests extends BaseASTTest
assertTrue(m1.getVisiblity() == ASTAccessVisibility.PUBLIC); assertTrue(m1.getVisiblity() == ASTAccessVisibility.PUBLIC);
assertTrue(m2.getVisiblity() == ASTAccessVisibility.PUBLIC); assertTrue(m2.getVisiblity() == ASTAccessVisibility.PUBLIC);
assertTrue(m3.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; };");
}
} }

View file

@ -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 2003-09-25 Hoda Amer
- Last part of solution to bug#42453: Expression result types not computed - Last part of solution to bug#42453: Expression result types not computed
Added the handling of POSTFIX_TYPENAME_IDENTIFIER Added the handling of POSTFIX_TYPENAME_IDENTIFIER

View file

@ -846,8 +846,9 @@ public class Parser implements IParser
IASTTemplate ownerTemplate) IASTTemplate ownerTemplate)
throws Backtrack throws Backtrack
{ {
IToken firstToken = LA(1);
DeclarationWrapper sdw = DeclarationWrapper sdw =
new DeclarationWrapper(scope, LA(1).getOffset(), ownerTemplate); new DeclarationWrapper(scope, firstToken.getOffset(), ownerTemplate);
declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, sdw, forKR ); declSpecifierSeq(false, strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, sdw, forKR );
try try
@ -893,6 +894,8 @@ public class Parser implements IParser
case IToken.tLBRACE : case IToken.tLBRACE :
if (forKR) if (forKR)
throw backtrack; throw backtrack;
if( firstToken == LA(1) )
throw backtrack;
declarator.setHasFunctionBody(true); declarator.setHasFunctionBody(true);
hasFunctionBody = true; hasFunctionBody = true;
break; break;
@ -2202,7 +2205,7 @@ public class Parser implements IParser
else else
{ {
// must be a conversion function // must be a conversion function
typeId(d.getDeclarationWrapper().getScope(), false ); typeId(d.getDeclarationWrapper().getScope(), true );
toSend = lastToken; toSend = lastToken;
} }
ITokenDuple duple = ITokenDuple duple =
@ -3553,7 +3556,7 @@ public class Parser implements IParser
/** /**
* @throws Backtrack * @throws Backtrack
*/ */
protected IASTTypeId typeId(IASTScope scope, boolean forNewExpression ) throws Backtrack protected IASTTypeId typeId(IASTScope scope, boolean skipArrayModifiers ) throws Backtrack
{ {
IToken mark = mark(); IToken mark = mark();
ITokenDuple name = null; ITokenDuple name = null;
@ -3576,6 +3579,7 @@ public class Parser implements IParser
// do nothing // do nothing
} }
boolean encounteredType = false;
simpleMods : for (;;) simpleMods : for (;;)
{ {
switch (LT(1)) switch (LT(1))
@ -3611,45 +3615,61 @@ public class Parser implements IParser
break; break;
case IToken.tIDENTIFIER : case IToken.tIDENTIFIER :
if( encounteredType ) break simpleMods;
encounteredType = true;
name = name(); name = name();
kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME; kind = IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME;
break simpleMods; break;
case IToken.t_int : case IToken.t_int :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.INT; kind = IASTSimpleTypeSpecifier.Type.INT;
consume(); consume();
break simpleMods; break;
case IToken.t_char : case IToken.t_char :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.CHAR; kind = IASTSimpleTypeSpecifier.Type.CHAR;
consume(); consume();
break simpleMods; break;
case IToken.t_bool : case IToken.t_bool :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.BOOL; kind = IASTSimpleTypeSpecifier.Type.BOOL;
consume(); consume();
break simpleMods; break;
case IToken.t_double : case IToken.t_double :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.DOUBLE; kind = IASTSimpleTypeSpecifier.Type.DOUBLE;
consume(); consume();
break simpleMods; break;
case IToken.t_float : case IToken.t_float :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.FLOAT; kind = IASTSimpleTypeSpecifier.Type.FLOAT;
consume(); consume();
break simpleMods; break;
case IToken.t_wchar_t : case IToken.t_wchar_t :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.WCHAR_T; kind = IASTSimpleTypeSpecifier.Type.WCHAR_T;
consume(); consume();
break simpleMods; break;
case IToken.t_void : case IToken.t_void :
if( encounteredType ) break simpleMods;
encounteredType = true;
kind = IASTSimpleTypeSpecifier.Type.VOID; kind = IASTSimpleTypeSpecifier.Type.VOID;
consume(); consume();
break simpleMods; break;
default : default :
@ -3690,13 +3710,13 @@ public class Parser implements IParser
throw backtrack; throw backtrack;
TypeId id = new TypeId(); TypeId id = new TypeId();
IToken last = mark(); IToken last = lastToken;
consumePointerOperators( id ); consumePointerOperators( id );
if( lastToken == null ) lastToken = last; if( lastToken == null ) lastToken = last;
if( ! forNewExpression ) if( ! skipArrayModifiers )
{ {
last = mark(); last = lastToken;
consumeArrayModifiers( id, scope ); consumeArrayModifiers( id, scope );
if( lastToken == null ) lastToken = last; if( lastToken == null ) lastToken = last;
} }

View file

@ -84,16 +84,28 @@ public class TokenDuple implements ITokenDuple {
public String toString() public String toString()
{ {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
IToken prev = null;
IToken iter = firstToken; IToken iter = firstToken;
for( ; ; ) for( ; ; )
{ {
buff.append( iter.getImage() ); if( prev != null &&
if( iter.getType() == IToken.t_operator ) 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( ' ');
buff.append( iter.getImage() );
if( iter == lastToken ) break; if( iter == lastToken ) break;
prev = iter;
iter = iter.getNext(); iter = iter.getNext();
} }
return buff.toString(); return buff.toString().trim();
} }
public boolean isIdentifier() public boolean isIdentifier()