mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=56516 Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=53786 org.eclipse.cdt.core.tests Added CompleteParseASTTest::testBug56516() && CompleteParseASTTests::testBug53786().
This commit is contained in:
parent
45cf3d9fb2
commit
91571bd2e5
4 changed files with 134 additions and 97 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-04-04 John Camelon
|
||||||
|
Added CompleteParseASTTest::testBug56516() && CompleteParseASTTests::testBug53786().
|
||||||
|
|
||||||
2004-04-02 Andrew Niefer
|
2004-04-02 Andrew Niefer
|
||||||
- created CompleteParseASTTemplateTest, added it to the ParserTestSuite and moved all the template tests from
|
- created CompleteParseASTTemplateTest, added it to the ParserTestSuite and moved all the template tests from
|
||||||
CompleteParseASTTest to it.
|
CompleteParseASTTest to it.
|
||||||
|
|
|
@ -37,8 +37,6 @@ import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
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.IASTSimpleTypeSpecifier;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||||
|
@ -1352,4 +1350,28 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
assertEquals( thePointer.getName(), "pA" );
|
assertEquals( thePointer.getName(), "pA" );
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug56516() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "typedef struct blah sb;").getDeclarations();
|
||||||
|
IASTTypedefDeclaration sb = (IASTTypedefDeclaration) i.next();
|
||||||
|
assertEquals( sb.getName(), "sb");
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
IASTElaboratedTypeSpecifier elab = ((IASTElaboratedTypeSpecifier)sb.getAbstractDeclarator().getTypeSpecifier());
|
||||||
|
assertEquals( elab.getName(), "blah");
|
||||||
|
assertEquals( elab.getClassKind(), ASTClassKind.STRUCT );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug53786() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse( "struct Example { struct Data * data; };").getDeclarations();
|
||||||
|
IASTClassSpecifier Example = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
|
assertFalse( i.hasNext() );
|
||||||
|
assertEquals( Example.getName(), "Example");
|
||||||
|
assertEquals( Example.getClassKind(), ASTClassKind.STRUCT );
|
||||||
|
Iterator j = getDeclarations( Example );
|
||||||
|
IASTField data = (IASTField) j.next();
|
||||||
|
assertFalse( j.hasNext() );
|
||||||
|
assertEquals( data.getName(), "data" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-04-04 John Camelon
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=56516
|
||||||
|
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=53786
|
||||||
|
|
||||||
2004-04-02 Andrew Niefer
|
2004-04-02 Andrew Niefer
|
||||||
- partial handling template explicit instantiations
|
- partial handling template explicit instantiations
|
||||||
- bug 56834 - Symbols not available until end of parameter list, fixed for templates using temporary code block
|
- bug 56834 - Symbols not available until end of parameter list, fixed for templates using temporary code block
|
||||||
|
|
|
@ -2783,119 +2783,123 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(IASTScope scope, ASTClassKind kind, ITokenDuple name, int startingOffset, int startingLine, int endOffset, int endingLine, boolean isForewardDecl, boolean isFriend) throws ASTSemanticException
|
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(IASTScope scope, ASTClassKind kind, ITokenDuple name, int startingOffset, int startingLine, int endOffset, int endingLine, boolean isForewardDecl, boolean isFriend) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
IContainerSymbol currentScopeSymbol = scopeToSymbol(scope);
|
IContainerSymbol currentScopeSymbol = scopeToSymbol(scope);
|
||||||
TypeInfo.eType pstType = classKindToTypeInfo(kind);
|
TypeInfo.eType pstType = classKindToTypeInfo(kind);
|
||||||
List references = new ArrayList();
|
List references = new ArrayList();
|
||||||
|
|
||||||
IToken nameToken = name.getFirstToken();
|
IToken nameToken = name.getFirstToken();
|
||||||
|
|
||||||
String newSymbolName = ""; //$NON-NLS-1$
|
String newSymbolName = ""; //$NON-NLS-1$
|
||||||
List templateIdArgList = null;
|
List templateIdArgList = null;
|
||||||
boolean isTemplateId = false;
|
boolean isTemplateId = false;
|
||||||
|
if (name.getSegmentCount() != 1) // qualified name
|
||||||
if( name.getSegmentCount() != 1 ) // qualified name
|
|
||||||
{
|
{
|
||||||
ITokenDuple containerSymbolName = name.getLeadingSegments();
|
ITokenDuple containerSymbolName = name.getLeadingSegments();
|
||||||
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol, containerSymbolName, references, true);
|
currentScopeSymbol = (IContainerSymbol) lookupQualifiedName(
|
||||||
if( currentScopeSymbol == null )
|
currentScopeSymbol, containerSymbolName, references, true);
|
||||||
handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toString(), containerSymbolName.getFirstToken().getOffset(), containerSymbolName.getLastToken().getEndOffset(), containerSymbolName.getLastToken().getLineNumber() );
|
if (currentScopeSymbol == null)
|
||||||
|
handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND,
|
||||||
|
containerSymbolName.toString(), containerSymbolName
|
||||||
|
.getFirstToken().getOffset(),
|
||||||
|
containerSymbolName.getLastToken().getEndOffset(),
|
||||||
|
containerSymbolName.getLastToken().getLineNumber());
|
||||||
nameToken = name.getLastSegment().getFirstToken();
|
nameToken = name.getLastSegment().getFirstToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
//template-id
|
//template-id
|
||||||
List [] array = name.getTemplateIdArgLists();
|
List[] array = name.getTemplateIdArgLists();
|
||||||
if( array != null ){
|
if (array != null) {
|
||||||
isTemplateId = true;
|
isTemplateId = true;
|
||||||
templateIdArgList = array[ array.length - 1 ];
|
templateIdArgList = array[array.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
newSymbolName = nameToken.getImage();
|
newSymbolName = nameToken.getImage();
|
||||||
|
|
||||||
ISymbol checkSymbol = null;
|
ISymbol checkSymbol = null;
|
||||||
if( !isTemplateId ){
|
if (!isTemplateId) {
|
||||||
try
|
try {
|
||||||
{
|
if (isFriend) {
|
||||||
if( isFriend ){
|
checkSymbol = ((IDerivableContainerSymbol) currentScopeSymbol)
|
||||||
checkSymbol = ((IDerivableContainerSymbol)currentScopeSymbol).lookupForFriendship( newSymbolName );
|
.lookupForFriendship(newSymbolName);
|
||||||
} else {
|
} else {
|
||||||
checkSymbol = currentScopeSymbol.elaboratedLookup( pstType, newSymbolName);
|
checkSymbol = currentScopeSymbol.elaboratedLookup(pstType,
|
||||||
|
newSymbolName);
|
||||||
}
|
}
|
||||||
}
|
} catch (ParserSymbolTableException e) {
|
||||||
catch (ParserSymbolTableException e)
|
handleProblem(e.createProblemID(), nameToken.getImage(),
|
||||||
{
|
nameToken.getOffset(), nameToken.getEndOffset(),
|
||||||
handleProblem(e.createProblemID(),nameToken.getImage(), nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
nameToken.getLineNumber());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List args = null;
|
List args = null;
|
||||||
if( isTemplateId ){
|
if (isTemplateId) {
|
||||||
args = getTemplateArgList( templateIdArgList );
|
args = getTemplateArgList(templateIdArgList);
|
||||||
}
|
}
|
||||||
|
if (scope instanceof IASTTemplateInstantiation) {
|
||||||
if( isForewardDecl )
|
if (isTemplateId) {
|
||||||
{
|
checkSymbol = pst.newDerivableContainerSymbol(newSymbolName,
|
||||||
if( scope instanceof IASTTemplateInstantiation )
|
pstType);
|
||||||
{
|
try {
|
||||||
if( isTemplateId ){
|
currentScopeSymbol.addTemplateId(checkSymbol, args);
|
||||||
checkSymbol = pst.newDerivableContainerSymbol( newSymbolName, pstType );
|
} catch (ParserSymbolTableException e) {
|
||||||
try {
|
handleProblem(e.createProblemID(), nameToken.getImage(),
|
||||||
currentScopeSymbol.addTemplateId( checkSymbol, args );
|
nameToken.getOffset(), nameToken.getEndOffset(),
|
||||||
} catch (ParserSymbolTableException e) {
|
nameToken.getLineNumber());
|
||||||
handleProblem(e.createProblemID(),nameToken.getImage(), nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
handleProblem(IProblem.SEMANTIC_INVALID_TEMPLATE, nameToken
|
||||||
handleProblem( IProblem.SEMANTIC_INVALID_TEMPLATE, nameToken.getImage() );
|
.getImage());
|
||||||
}
|
|
||||||
checkSymbol = ((ASTTemplateInstantiation)scope).getInstanceSymbol();
|
|
||||||
}
|
|
||||||
else if( checkSymbol == null )
|
|
||||||
{
|
|
||||||
checkSymbol = pst.newDerivableContainerSymbol( newSymbolName, pstType );
|
|
||||||
checkSymbol.setIsForwardDeclaration( true );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( isFriend ){
|
|
||||||
((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
|
|
||||||
} else {
|
|
||||||
if( !isTemplateId )
|
|
||||||
currentScopeSymbol.addSymbol( checkSymbol );
|
|
||||||
else
|
|
||||||
currentScopeSymbol.addTemplateId( checkSymbol, args );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ParserSymbolTableException e1)
|
|
||||||
{
|
|
||||||
handleProblem(e1.createProblemID(),nameToken.getImage(), nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
|
||||||
}
|
|
||||||
|
|
||||||
ASTElaboratedTypeSpecifier elab =
|
|
||||||
new ASTElaboratedTypeSpecifier( checkSymbol, kind, startingOffset, startingLine, name.getFirstToken().getOffset(), name.getLastToken().getEndOffset(), name.getLastToken().getLineNumber(), endOffset, endingLine, references, isForewardDecl );
|
|
||||||
|
|
||||||
attachSymbolExtension( checkSymbol, elab, isForewardDecl );
|
|
||||||
} else if( isFriend ){
|
|
||||||
((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
|
|
||||||
}
|
}
|
||||||
}
|
checkSymbol = ((ASTTemplateInstantiation) scope)
|
||||||
|
.getInstanceSymbol();
|
||||||
if( checkSymbol != null ){
|
} else if (checkSymbol == null) {
|
||||||
if( scope instanceof IASTTemplateInstantiation ){
|
checkSymbol = pst.newDerivableContainerSymbol(newSymbolName,
|
||||||
addReference( references, createReference( checkSymbol, newSymbolName, nameToken.getOffset() ));
|
pstType);
|
||||||
}
|
checkSymbol.setIsForwardDeclaration(true);
|
||||||
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTClassSpecifier ||
|
try {
|
||||||
checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTEnumerationSpecifier
|
if (isFriend) {
|
||||||
)
|
((IDerivableContainerSymbol) currentScopeSymbol)
|
||||||
{
|
.addFriend(checkSymbol);
|
||||||
ASTElaboratedTypeSpecifier elab = new ASTElaboratedTypeSpecifier( checkSymbol, kind, startingOffset, startingLine, name.getFirstToken().getOffset(), name.getLastToken().getEndOffset(), name.getLastToken().getLineNumber(), endOffset, endingLine, references, isForewardDecl );
|
} else {
|
||||||
attachSymbolExtension( checkSymbol, elab, isForewardDecl );
|
if (!isTemplateId)
|
||||||
|
currentScopeSymbol.addSymbol(checkSymbol);
|
||||||
|
else
|
||||||
|
currentScopeSymbol.addTemplateId(checkSymbol, args);
|
||||||
|
}
|
||||||
|
} catch (ParserSymbolTableException e1) {
|
||||||
|
handleProblem(e1.createProblemID(), nameToken.getImage(),
|
||||||
|
nameToken.getOffset(), nameToken.getEndOffset(),
|
||||||
|
nameToken.getLineNumber());
|
||||||
|
}
|
||||||
|
ASTElaboratedTypeSpecifier elab = new ASTElaboratedTypeSpecifier(
|
||||||
|
checkSymbol, kind, startingOffset, startingLine, name
|
||||||
|
.getFirstToken().getOffset(), name.getLastToken()
|
||||||
|
.getEndOffset(), name.getLastToken()
|
||||||
|
.getLineNumber(), endOffset, endingLine,
|
||||||
|
references, isForewardDecl);
|
||||||
|
attachSymbolExtension(checkSymbol, elab, !isForewardDecl);
|
||||||
|
} else if (isFriend) {
|
||||||
|
((IDerivableContainerSymbol) currentScopeSymbol)
|
||||||
|
.addFriend(checkSymbol);
|
||||||
|
}
|
||||||
|
if (checkSymbol != null) {
|
||||||
|
if (scope instanceof IASTTemplateInstantiation) {
|
||||||
|
addReference(references, createReference(checkSymbol,
|
||||||
|
newSymbolName, nameToken.getOffset()));
|
||||||
|
}
|
||||||
|
if (checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTClassSpecifier
|
||||||
|
|| checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTEnumerationSpecifier) {
|
||||||
|
ASTElaboratedTypeSpecifier elab = new ASTElaboratedTypeSpecifier(
|
||||||
|
checkSymbol, kind, startingOffset, startingLine, name
|
||||||
|
.getFirstToken().getOffset(), name
|
||||||
|
.getLastToken().getEndOffset(), name
|
||||||
|
.getLastToken().getLineNumber(), endOffset,
|
||||||
|
endingLine, references, isForewardDecl);
|
||||||
|
attachSymbolExtension(checkSymbol, elab, !isForewardDecl);
|
||||||
return elab;
|
return elab;
|
||||||
}
|
}
|
||||||
|
if (checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier)
|
||||||
if( checkSymbol.getASTExtension().getPrimaryDeclaration() instanceof IASTElaboratedTypeSpecifier )
|
return (IASTElaboratedTypeSpecifier) checkSymbol
|
||||||
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
|
.getASTExtension().getPrimaryDeclaration();
|
||||||
} else {
|
} else {
|
||||||
handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND, newSymbolName, nameToken.getOffset(), nameToken.getEndOffset(), nameToken.getLineNumber() );
|
handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND, newSymbolName,
|
||||||
}
|
nameToken.getOffset(), nameToken.getEndOffset(), nameToken
|
||||||
|
.getLineNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// assert false : this;
|
// assert false : this;
|
||||||
|
@ -2905,9 +2909,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
protected ParserSymbolTable pst;
|
protected ParserSymbolTable pst;
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNamespaceAlias(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, org.eclipse.cdt.core.parser.ITokenDuple, int, int, int)
|
* (non-Javadoc)
|
||||||
*/
|
*
|
||||||
|
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createNamespaceAlias(org.eclipse.cdt.core.parser.ast.IASTScope,
|
||||||
|
* java.lang.String, org.eclipse.cdt.core.parser.ITokenDuple, int, int,
|
||||||
|
* int)
|
||||||
|
*/
|
||||||
public IASTNamespaceAlias createNamespaceAlias(IASTScope scope, String identifier, ITokenDuple alias, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endingLine) throws ASTSemanticException
|
public IASTNamespaceAlias createNamespaceAlias(IASTScope scope, String identifier, ITokenDuple alias, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endingLine) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
IContainerSymbol startingSymbol = scopeToSymbol(scope);
|
IContainerSymbol startingSymbol = scopeToSymbol(scope);
|
||||||
|
|
Loading…
Add table
Reference in a new issue