mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fixing last problems for bugs 52695 & 45372
This commit is contained in:
parent
727994dc39
commit
688e94b21b
12 changed files with 167 additions and 25 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-04-21 Andrew Niefer
|
||||
fox bugs 52695 & 45372
|
||||
added parser/CompleteParseASTSymbolIteratorTest.testUsingDirectives()
|
||||
added parser/CompleteParseASTSymbolIteratorTest.testUsingDeclaration()
|
||||
|
||||
2004-04-21 John Camelon
|
||||
Removed unused testInclusions() test from ScannerTestCase.
|
||||
|
||||
|
|
|
@ -30,8 +30,9 @@ import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
|
@ -334,4 +335,21 @@ public class CompleteParseASTSymbolIteratorTest extends CompleteParseBaseTest {
|
|||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testUsingDirectives() throws Exception
|
||||
{
|
||||
Iterator i = parse( "namespace NS { int i; } using namespace NS;" ).getDeclarations();
|
||||
|
||||
IASTNamespaceDefinition ns = (IASTNamespaceDefinition) i.next();
|
||||
IASTUsingDirective using = (IASTUsingDirective) i.next();
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testUsingDeclaration() throws Exception
|
||||
{
|
||||
Iterator i = parse( "namespace NS{ void f(); void f( int ); }; using NS::f;" ).getDeclarations();
|
||||
|
||||
IASTNamespaceDefinition ns = (IASTNamespaceDefinition) i.next();
|
||||
IASTUsingDeclaration using = (IASTUsingDeclaration) i.next();
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2004-04-21 Andrew Niefer
|
||||
fixing 52695 & 45372
|
||||
- updated CompleteParseASTFactory.createUsingDirective & createUsingDeclaration
|
||||
- added CompleteParseASTFactory.attachSymbolExtension( IExtensibleSymbol symbol, ASTNode astNode )
|
||||
- updated ContainerSymbol.addUsingDeclaration
|
||||
- modified ISymbolASTExtension and added ExtensibleSymbolExtension.java
|
||||
|
||||
2004-04-21 John Camelon
|
||||
Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=59468
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM 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 Corp. - Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Created on Feb 25, 2004
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.ast;
|
||||
|
||||
|
@ -13,9 +20,6 @@ import org.eclipse.cdt.internal.core.parser.pst.IExtensibleSymbol;
|
|||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class SymbolIterator implements Iterator {
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ public class ASTTemplateDeclaration extends ASTSymbol implements IASTTemplateDec
|
|||
{
|
||||
IContainerSymbol owned = getTemplateSymbol().getTemplatedSymbol();
|
||||
if( owned != null && owned.getASTExtension() != null ){
|
||||
return owned.getASTExtension().getPrimaryDeclaration();
|
||||
ASTNode node = owned.getASTExtension().getPrimaryDeclaration();
|
||||
return ( node instanceof IASTDeclaration ) ? (IASTDeclaration)node : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -33,8 +33,10 @@ public class ASTTemplateSpecialization extends ASTTemplateDeclaration implements
|
|||
|
||||
public IASTDeclaration getOwnedDeclaration()
|
||||
{
|
||||
if( owned != null && owned.getASTExtension() != null )
|
||||
return owned.getASTExtension().getPrimaryDeclaration();
|
||||
if( owned != null && owned.getASTExtension() != null ){
|
||||
ASTNode node = owned.getASTExtension().getPrimaryDeclaration();
|
||||
return ( node instanceof IASTDeclaration ) ? (IASTDeclaration)node : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -75,10 +75,12 @@ import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
|||
import org.eclipse.cdt.core.parser.extension.IASTFactoryExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ExtensibleSymbolExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IExtensibleSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
|
||||
|
@ -469,7 +471,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
handleProblem( pste.createProblemID(), duple.toString(), startingOffset, endingOffset, startingLine );
|
||||
}
|
||||
|
||||
return new ASTUsingDirective( scopeToSymbol(scope), usingDirective, startingOffset, startingLine, endingOffset, endingLine, references );
|
||||
ASTUsingDirective using = new ASTUsingDirective( scopeToSymbol(scope), usingDirective, startingOffset, startingLine, endingOffset, endingLine, references );
|
||||
attachSymbolExtension( usingDirective, using );
|
||||
|
||||
return using;
|
||||
}
|
||||
|
||||
|
||||
|
@ -547,9 +552,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
addReference( references, reference );
|
||||
}
|
||||
}
|
||||
|
||||
return new ASTUsingDeclaration( scope, name.getLastToken().getImage(),
|
||||
endResult.getReferencedSymbols(), isTypeName, startingOffset, startingLine, endingOffset, endingLine, references );
|
||||
ASTUsingDeclaration using = new ASTUsingDeclaration( scope, name.getLastToken().getImage(),
|
||||
endResult.getReferencedSymbols(), isTypeName, startingOffset, startingLine, endingOffset, endingLine, references );
|
||||
attachSymbolExtension( endResult, using );
|
||||
|
||||
return using;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createASMDefinition(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, int, int)
|
||||
|
@ -626,6 +633,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return compilationUnit;
|
||||
}
|
||||
|
||||
protected void attachSymbolExtension( IExtensibleSymbol symbol, ASTNode astNode )
|
||||
{
|
||||
ISymbolASTExtension extension = new ExtensibleSymbolExtension( symbol, astNode );
|
||||
symbol.setASTExtension( extension );
|
||||
}
|
||||
|
||||
protected void attachSymbolExtension(
|
||||
ISymbol symbol,
|
||||
|
@ -902,7 +914,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
return new ASTEnumeratorReference( offset, referenceElementName, (IASTEnumerator)symbol.getASTExtension().getPrimaryDeclaration() );
|
||||
else if(( symbol.getType() == TypeInfo.t_function ) || (symbol.getType() == TypeInfo.t_constructor))
|
||||
{
|
||||
ASTSymbol referenced = symbol.getASTExtension().getPrimaryDeclaration();
|
||||
ASTNode referenced = symbol.getASTExtension().getPrimaryDeclaration();
|
||||
if( referenced instanceof IASTMethod )
|
||||
return new ASTMethodReference( offset, referenceElementName, (IASTMethod)referenced );
|
||||
else
|
||||
|
@ -936,7 +948,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
else
|
||||
{
|
||||
ASTSymbol s = symbol.getASTExtension().getPrimaryDeclaration();
|
||||
ASTNode s = symbol.getASTExtension().getPrimaryDeclaration();
|
||||
if(s instanceof IASTVariable)
|
||||
return new ASTVariableReference( offset, referenceElementName, (IASTVariable)s);
|
||||
else if (s instanceof IASTParameterDeclaration)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +39,11 @@ public abstract class AbstractSymbolExtension implements ISymbolASTExtension
|
|||
return symbol;
|
||||
}
|
||||
|
||||
public ASTSymbol getPrimaryDeclaration()
|
||||
public IExtensibleSymbol getExtensibleSymbol(){
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public ASTNode getPrimaryDeclaration()
|
||||
{
|
||||
return primaryDeclaration;
|
||||
}
|
||||
|
|
|
@ -394,8 +394,15 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
List usingDecs = new LinkedList();
|
||||
List usingRefs = new LinkedList();
|
||||
|
||||
UsingDeclarationSymbol usingDeclaration = new UsingDeclarationSymbol( getSymbolTable(), usingRefs, usingDecs );
|
||||
boolean addedUsingToContained = false;
|
||||
|
||||
while( symbol != null ){
|
||||
if( ParserSymbolTable.okToAddUsingDeclaration( symbol, this ) ){
|
||||
if( ! addedUsingToContained ){
|
||||
getContents().add( usingDeclaration );
|
||||
addedUsingToContained = true;
|
||||
}
|
||||
clone = (ISymbol) symbol.clone(); //7.3.3-9
|
||||
addSymbol( clone );
|
||||
} else {
|
||||
|
@ -412,7 +419,7 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
}
|
||||
}
|
||||
|
||||
return new UsingDeclarationSymbol( getSymbolTable(), usingRefs, usingDecs );
|
||||
return usingDeclaration;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -992,6 +999,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
next = symbol.getTypeSymbol();
|
||||
return true;
|
||||
}
|
||||
} else if( extensible instanceof IUsingDeclarationSymbol ){
|
||||
IUsingDeclarationSymbol using = (IUsingDeclarationSymbol) extensible;
|
||||
alreadyReturned.addAll( using.getDeclaredSymbols() );
|
||||
}
|
||||
next = extensible;
|
||||
return true;
|
||||
|
@ -1018,6 +1028,9 @@ public class ContainerSymbol extends BasicSymbol implements IContainerSymbol {
|
|||
alreadyReturned.add( symbol.getTypeSymbol() );
|
||||
return symbol.getTypeSymbol();
|
||||
}
|
||||
} else if( extensible instanceof IUsingDeclarationSymbol ){
|
||||
IUsingDeclarationSymbol using = (IUsingDeclarationSymbol) extensible;
|
||||
alreadyReturned.addAll( using.getDeclaredSymbols() );
|
||||
}
|
||||
return extensible;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM 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 Corp. - Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Created on Apr 21, 2004
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class ExtensibleSymbolExtension implements ISymbolASTExtension {
|
||||
protected final IExtensibleSymbol extensibleSymbol;
|
||||
protected final ASTNode primaryDeclaration;
|
||||
|
||||
public ExtensibleSymbolExtension( IExtensibleSymbol symbol, IASTNode node ){
|
||||
primaryDeclaration = (ASTNode) node;
|
||||
extensibleSymbol = symbol;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getPrimaryDeclaration()
|
||||
*/
|
||||
public ASTNode getPrimaryDeclaration() {
|
||||
return primaryDeclaration;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#getAllDefinitions()
|
||||
*/
|
||||
public Iterator getAllDefinitions() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension#addDefinition(org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol)
|
||||
*/
|
||||
public void addDefinition(ASTSymbol definition) throws ExtensionException {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner#getSymbol()
|
||||
*/
|
||||
public ISymbol getSymbol() {
|
||||
if( extensibleSymbol instanceof ISymbol )
|
||||
return (ISymbol) extensibleSymbol;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public IExtensibleSymbol getExtensibleSymbol(){
|
||||
return extensibleSymbol;
|
||||
}
|
||||
}
|
|
@ -10,8 +10,10 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTSymbol;
|
||||
|
||||
/**
|
||||
|
@ -25,7 +27,8 @@ public interface ISymbolASTExtension extends ISymbolOwner
|
|||
}
|
||||
|
||||
|
||||
public ASTSymbol getPrimaryDeclaration();
|
||||
public ASTNode getPrimaryDeclaration();
|
||||
public IExtensibleSymbol getExtensibleSymbol();
|
||||
public Iterator getAllDefinitions();
|
||||
public void addDefinition( ASTSymbol definition ) throws ExtensionException;
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM 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 Corp. - Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Created on Feb 18, 2004
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.parser.pst;
|
||||
|
||||
|
@ -11,9 +18,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class UsingDeclarationSymbol extends ExtensibleSymbol implements IUsingDeclarationSymbol {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue