mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
AST work for friend declarations
for bug 45235 AST does not capture class friend relationships and bug 53759 ISourceElementRequestor missing callbacks for friend declarations
This commit is contained in:
parent
ecdbf0cd6e
commit
b3ac698a40
29 changed files with 221 additions and 28 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-04-14 Andrew Niefer
|
||||
updated FullParseCallback with acceptFriendDeclaration
|
||||
added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testBug45235()
|
||||
added parser/org/eclipse/cdt/core/parser/tests/QuickParseASTTests.testBug45235()
|
||||
|
||||
2004-04-13 Andrew Niefer
|
||||
added parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.testBug46246()
|
||||
|
||||
|
|
|
@ -1472,4 +1472,19 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
|
||||
assertAllReferences( 2, createTaskList( new Task( A ), new Task( B ) ) );
|
||||
}
|
||||
|
||||
public void testBug45235() throws Exception
|
||||
{
|
||||
Iterator i = parse( "class A { friend class B; friend void f(); }; " ).getDeclarations();
|
||||
|
||||
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
|
||||
i = getDeclarations( A );
|
||||
|
||||
IASTAbstractTypeSpecifierDeclaration forewardDecl = (IASTAbstractTypeSpecifierDeclaration)i.next();
|
||||
IASTFunction f = (IASTFunction) i.next();
|
||||
|
||||
assertTrue( forewardDecl.isFriendDeclaration() );
|
||||
assertTrue( f.isFriend() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -696,6 +696,13 @@ public class CompleteParseBaseTest extends TestCase
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void acceptFriendDeclaration(IASTDeclaration declaration) {
|
||||
getCurrentScope().addDeclaration( declaration );
|
||||
}
|
||||
}
|
||||
|
||||
protected Iterator getNestedScopes( IASTCodeScope scope )
|
||||
|
|
|
@ -2161,5 +2161,20 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
IASTFunction func1 = (IASTFunction) assertSoleDeclaration("__declspec(dllexport) int func1 (int a) {}");
|
||||
assertEquals( func1.getName(), "func1");
|
||||
}
|
||||
|
||||
public void testBug45235() throws Exception
|
||||
{
|
||||
Iterator i = parse( "class A { friend class B; friend void f(); }; " ).getDeclarations();
|
||||
|
||||
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
|
||||
i = A.getDeclarations();
|
||||
|
||||
IASTAbstractTypeSpecifierDeclaration forewardDecl = (IASTAbstractTypeSpecifierDeclaration)i.next();
|
||||
IASTFunction f = (IASTFunction) i.next();
|
||||
|
||||
assertTrue( forewardDecl.isFriendDeclaration() );
|
||||
assertTrue( f.isFriend() );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
2004-04-14 Andrew Niefer
|
||||
updated clients of Parse to have a default implementation for ISourceElementRequestor.acceptFriendDeclaration
|
||||
|
||||
2004-04-14 Alain Magloire
|
||||
|
||||
Fix PR 58082, with Patch from Jon Beniston
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -557,5 +558,13 @@ public class TypeMatchLocator implements ISourceElementRequestor, ICSearchConsta
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void acceptFriendDeclaration(IASTDeclaration declaration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -517,6 +518,14 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void acceptFriendDeclaration(IASTDeclaration declaration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void pushInclude( IASTInclusion inclusion ){
|
||||
includeStack.addFirst( currentInclude );
|
||||
currentInclude = inclusion;
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2004-04-14 Andrew Niefer
|
||||
friends in the AST (bugs 45235 & 53759 )
|
||||
- added acceptFriendDeclaration to ISourceElementRequestor
|
||||
- added isFriendDeclaration to IASTAbstractTypeSpecifierDeclaration
|
||||
- modified isFriend on IASTFunction
|
||||
- functions, methods & abstractTypeSpecifierDeclarations callback with acceptFriendDeclaration
|
||||
instead of their normal accept* if isFriend() or isFriendDeclaration() is true.
|
||||
- added getFriends to IASTClassSpecifier
|
||||
|
||||
2004-04-13 Andrew Niefer
|
||||
fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=46246
|
||||
modified symbol table sorting to use a collator instead of String.compare()
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -97,6 +98,7 @@ public interface ISourceElementRequestor {
|
|||
public void acceptEnumeratorReference( IASTEnumeratorReference reference );
|
||||
public void acceptParameterReference(IASTParameterReference reference);
|
||||
public void acceptTemplateParameterReference( IASTTemplateParameterReference reference );
|
||||
public void acceptFriendDeclaration( IASTDeclaration declaration );
|
||||
|
||||
public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
|
||||
public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -478,4 +479,12 @@ public class NullSourceElementRequestor implements ISourceElementRequestor
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void acceptFriendDeclaration(IASTDeclaration declaration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,5 @@ package org.eclipse.cdt.core.parser.ast;
|
|||
public interface IASTAbstractTypeSpecifierDeclaration
|
||||
extends IASTDeclaration, IASTTypeSpecifierOwner, IASTTemplatedDeclaration, IASTOffsetableElement
|
||||
{
|
||||
public boolean isFriendDeclaration();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ public interface IASTClassSpecifier extends IASTScope, IASTOffsetableNamedElemen
|
|||
|
||||
public Iterator getBaseClauses();
|
||||
|
||||
public Iterator getFriends();
|
||||
|
||||
public ASTAccessVisibility getCurrentVisibilityMode();
|
||||
public void setCurrentVisibility( ASTAccessVisibility visibility );
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ public interface IASTFactory
|
|||
|
||||
public IASTTypedefDeclaration createTypedef( IASTScope scope, String name, IASTAbstractDeclaration mapping, int startingOffset, int startingLine, int nameOffset, int nameEndOffset, int nameLine ) throws ASTSemanticException;
|
||||
|
||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int startingLine, int endingOffset, int endingLine);
|
||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration( IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int startingLine, int endingOffset, int endingLine, boolean isFriend );
|
||||
|
||||
public boolean queryIsTypeName( IASTScope scope, ITokenDuple nameInQuestion ) ;
|
||||
|
||||
|
|
|
@ -1095,11 +1095,12 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
try
|
||||
{
|
||||
astFactory.createTypeSpecDeclaration(
|
||||
sdw.getScope(),
|
||||
sdw.getTypeSpecifier(),
|
||||
sdw.getScope(),
|
||||
sdw.getTypeSpecifier(),
|
||||
ownerTemplate,
|
||||
sdw.getStartingOffset(),
|
||||
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber())
|
||||
sdw.getStartingLine(), lastToken.getEndOffset(), lastToken.getLineNumber(),
|
||||
sdw.isFriend())
|
||||
.acceptElement(requestor);
|
||||
}
|
||||
catch (Exception e1)
|
||||
|
|
|
@ -28,15 +28,17 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
{
|
||||
private final IASTTypeSpecifier typeSpec;
|
||||
private final IASTTemplate ownerTemplate;
|
||||
private final boolean isFriendDeclaration;
|
||||
private Offsets offsets = new Offsets();
|
||||
/**
|
||||
* @param ownerScope
|
||||
*/
|
||||
public ASTAbstractTypeSpecifierDeclaration(IContainerSymbol ownerScope, IASTTypeSpecifier typeSpecifier, IASTTemplate ownerTemplate, int startingOffset, int startingLine, int endingOffset, int endingLine )
|
||||
public ASTAbstractTypeSpecifierDeclaration(IContainerSymbol ownerScope, IASTTypeSpecifier typeSpecifier, IASTTemplate ownerTemplate, int startingOffset, int startingLine, int endingOffset, int endingLine, boolean isFriend )
|
||||
{
|
||||
super(ownerScope);
|
||||
this.typeSpec = typeSpecifier;
|
||||
this.ownerTemplate = ownerTemplate;
|
||||
this.isFriendDeclaration = isFriend;
|
||||
setStartingOffsetAndLineNumber(startingOffset, startingLine);
|
||||
setEndingOffsetAndLineNumber(endingOffset, endingLine);
|
||||
}
|
||||
|
@ -48,7 +50,10 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptAbstractTypeSpecDeclaration(this);
|
||||
if( isFriendDeclaration() )
|
||||
requestor.acceptFriendDeclaration( this );
|
||||
else
|
||||
requestor.acceptAbstractTypeSpecDeclaration(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -131,5 +136,12 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
public int getEndingLine() {
|
||||
return offsets.getEndingLine();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration#isFriendDeclaration()
|
||||
*/
|
||||
public boolean isFriendDeclaration() {
|
||||
return isFriendDeclaration;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.ASTQualifiedNamedElement;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.SymbolIterator;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol.IParentSymbol;
|
||||
|
@ -328,4 +329,11 @@ public class ASTClassSpecifier extends ASTScope implements IASTClassSpecifier
|
|||
public void setExtraReferences(List references) {
|
||||
resolvedCrossReferences.addAll( references );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getFriends()
|
||||
*/
|
||||
public Iterator getFriends() {
|
||||
IDerivableContainerSymbol symbol = (IDerivableContainerSymbol) getSymbol();
|
||||
return new SymbolIterator( symbol.getFriends().iterator() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
{
|
||||
private final boolean previouslyDeclared;
|
||||
private boolean hasFunctionBody = false;
|
||||
private final boolean isFriendDeclaration;
|
||||
private final IASTTemplate ownerTemplate;
|
||||
private final IASTAbstractDeclaration returnType;
|
||||
private final IASTExceptionSpecification exception;
|
||||
|
@ -54,7 +55,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
* @param ownerTemplate
|
||||
* @param references
|
||||
*/
|
||||
public ASTFunction(IParameterizedSymbol symbol, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int startingLine, int nameOffset, int nameLine, IASTTemplate ownerTemplate, List references, boolean previouslyDeclared, boolean hasFunctionTryBlock )
|
||||
public ASTFunction(IParameterizedSymbol symbol, int nameEndOffset, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int startingLine, int nameOffset, int nameLine, IASTTemplate ownerTemplate, List references, boolean previouslyDeclared, boolean hasFunctionTryBlock, boolean isFriend )
|
||||
{
|
||||
super( symbol );
|
||||
this.parameters = parameters;
|
||||
|
@ -68,6 +69,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
qualifiedName = new ASTQualifiedNamedElement( getOwnerScope(), symbol.getName() );
|
||||
this.previouslyDeclared =previouslyDeclared;
|
||||
this.hasFunctionTryBlock = hasFunctionTryBlock;
|
||||
this.isFriendDeclaration = isFriend;
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,7 +85,7 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
*/
|
||||
public boolean isFriend()
|
||||
{
|
||||
return symbol.getTypeInfo().checkBit( TypeInfo.isFriend );
|
||||
return isFriendDeclaration;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFunction#isStatic()
|
||||
|
@ -199,7 +201,10 @@ public class ASTFunction extends ASTScope implements IASTFunction
|
|||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptFunctionDeclaration(this);
|
||||
if( isFriend() )
|
||||
requestor.acceptFriendDeclaration(this);
|
||||
else
|
||||
requestor.acceptFunctionDeclaration(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
* @param references
|
||||
*/
|
||||
public ASTMethod(IParameterizedSymbol symbol, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, int startOffset, int startLine, int nameOffset, int nameEndOffset, int nameLine, IASTTemplate ownerTemplate,
|
||||
List references, boolean previouslyDeclared, boolean isConstructor, boolean isDestructor, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean hasFunctionTryBlock )
|
||||
List references, boolean previouslyDeclared, boolean isConstructor, boolean isDestructor, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean hasFunctionTryBlock, boolean isFriend )
|
||||
{
|
||||
super(
|
||||
symbol,
|
||||
|
@ -59,7 +59,7 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
startOffset,
|
||||
startLine,
|
||||
nameOffset,
|
||||
nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock );
|
||||
nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock, isFriend );
|
||||
this.visibility = visibility;
|
||||
this.isConstructor = isConstructor;
|
||||
this.isDestructor = isDestructor;
|
||||
|
@ -130,7 +130,10 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptMethodDeclaration(this);
|
||||
if( isFriend() )
|
||||
requestor.acceptFriendDeclaration( this );
|
||||
else
|
||||
requestor.acceptMethodDeclaration(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -1943,7 +1943,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
symbol = functionDeclaration;
|
||||
}
|
||||
|
||||
ASTFunction function = new ASTFunction( symbol, nameEndOffset, parameters, returnType, exception, startOffset, startLine, nameOffset, nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock );
|
||||
ASTFunction function = new ASTFunction( symbol, nameEndOffset, parameters, returnType, exception, startOffset, startLine, nameOffset, nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock, isFriend );
|
||||
attachSymbolExtension(symbol, function, isFunctionDefinition);
|
||||
return function;
|
||||
}
|
||||
|
@ -2269,8 +2269,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
symbol.setTypeSymbol( functionDeclaration );
|
||||
// friend declaration, has no real visibility, set private
|
||||
visibility = ASTAccessVisibility.PRIVATE;
|
||||
} else
|
||||
} else if( ownerScope.isType( TypeInfo.t_constructor ) ||
|
||||
ownerScope.isType( TypeInfo.t_function ) ||
|
||||
ownerScope.isType( TypeInfo.t_block ) )
|
||||
{
|
||||
//only needs to be previously declared if we are in a local class
|
||||
handleProblem( IProblem.SEMANTIC_ILLFORMED_FRIEND, nameDuple.toString(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber() );
|
||||
}
|
||||
|
||||
|
@ -2287,7 +2290,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
{
|
||||
if( isFriend )
|
||||
{
|
||||
((IDerivableContainerSymbol)ownerScope).addFriend( functionDeclaration );
|
||||
if( functionDeclaration != null )
|
||||
((IDerivableContainerSymbol)ownerScope).addFriend( functionDeclaration );
|
||||
else
|
||||
((IDerivableContainerSymbol)ownerScope).addFriend( symbol );
|
||||
} else if( !isConstructor )
|
||||
ownerScope.addSymbol( symbol );
|
||||
else
|
||||
|
@ -2303,7 +2309,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
|
||||
resolveLeftoverConstructorInitializerMembers( symbol, constructorChain );
|
||||
|
||||
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, startingLine, nameOffset, nameEndOffset, nameLine, ownerTemplate, references, previouslyDeclared, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain, hasFunctionTryBlock );
|
||||
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, startingLine, nameOffset, nameEndOffset, nameLine, ownerTemplate, references, previouslyDeclared, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain, hasFunctionTryBlock, isFriend );
|
||||
attachSymbolExtension( symbol, method, isFunctionDefinition );
|
||||
return method;
|
||||
}
|
||||
|
@ -2815,9 +2821,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
IASTTypeSpecifier typeSpecifier,
|
||||
IASTTemplate template,
|
||||
int startingOffset,
|
||||
int startingLine, int endingOffset, int endingLine)
|
||||
int startingLine, int endingOffset, int endingLine, boolean isFriend)
|
||||
{
|
||||
return new ASTAbstractTypeSpecifierDeclaration( scopeToSymbol(scope), typeSpecifier, template, startingOffset, startingLine, endingOffset, endingLine);
|
||||
return new ASTAbstractTypeSpecifierDeclaration( scopeToSymbol(scope), typeSpecifier, template, startingOffset, startingLine, endingOffset, endingLine, isFriend);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -826,7 +826,8 @@ public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFac
|
|||
int startingOffset,
|
||||
int startingLine,
|
||||
int endingOffset,
|
||||
int endingLine) {
|
||||
int endingLine,
|
||||
boolean isFriend) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -27,15 +27,17 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
{
|
||||
private final IASTTemplate ownerTemplate;
|
||||
private final IASTTypeSpecifier typeSpecifier;
|
||||
private final boolean isFriendDeclaration;
|
||||
/**
|
||||
* @param scope
|
||||
* @param typeSpecifier
|
||||
*/
|
||||
public ASTAbstractTypeSpecifierDeclaration(IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate ownerTemplate, int startingOffset, int endingOffset, int startingLine, int endingLine)
|
||||
public ASTAbstractTypeSpecifierDeclaration(IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate ownerTemplate, int startingOffset, int endingOffset, int startingLine, int endingLine, boolean isFriend)
|
||||
{
|
||||
super( ownerTemplate != null ? null : scope );
|
||||
this.typeSpecifier = typeSpecifier;
|
||||
this.ownerTemplate = ownerTemplate;
|
||||
this.isFriendDeclaration = isFriend;
|
||||
if( ownerTemplate != null )
|
||||
ownerTemplate.setOwnedDeclaration( this );
|
||||
setStartingOffsetAndLineNumber(startingOffset, startingLine);
|
||||
|
@ -93,7 +95,10 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptAbstractTypeSpecDeclaration(this);
|
||||
if( isFriendDeclaration() )
|
||||
requestor.acceptFriendDeclaration( this );
|
||||
else
|
||||
requestor.acceptAbstractTypeSpecDeclaration(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -128,5 +133,12 @@ public class ASTAbstractTypeSpecifierDeclaration
|
|||
public int getEndingLine() {
|
||||
return offsets.getEndingLine();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration#isFriendDeclaration()
|
||||
*/
|
||||
public boolean isFriendDeclaration() {
|
||||
return isFriendDeclaration;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
|||
private final String name;
|
||||
private List declarations = new ArrayList();
|
||||
private List baseClauses = new ArrayList();
|
||||
private List friends = new ArrayList();
|
||||
private ASTAccessVisibility access;
|
||||
private NamedOffsets offsets = new NamedOffsets();
|
||||
private final ClassNameType classNameType;
|
||||
|
@ -230,5 +231,19 @@ public class ASTClassSpecifier extends ASTScopedTypeSpecifier implements IASTQCl
|
|||
public int getNameLineNumber() {
|
||||
return offsets.getNameLineNumber();
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getFriends()
|
||||
*/
|
||||
public Iterator getFriends() {
|
||||
return friends.iterator();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQClassSpecifier#addFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void addFriendDeclaration(IASTDeclaration decl) {
|
||||
friends.add( decl );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -188,7 +188,11 @@ public class ASTFunction extends ASTDeclaration implements IASTFunction
|
|||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptFunctionDeclaration(this);
|
||||
if( isFriend() )
|
||||
requestor.acceptFriendDeclaration(this);
|
||||
else
|
||||
requestor.acceptFunctionDeclaration(this);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -171,7 +171,10 @@ public class ASTMethod extends ASTFunction implements IASTMethod
|
|||
{
|
||||
try
|
||||
{
|
||||
requestor.acceptMethodDeclaration( this );
|
||||
if( isFriend() )
|
||||
requestor.acceptFriendDeclaration(this);
|
||||
else
|
||||
requestor.acceptMethodDeclaration( this );
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser.ast.quick;
|
|||
|
||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -20,4 +21,6 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
|||
public interface IASTQClassSpecifier extends IASTClassSpecifier {
|
||||
|
||||
public void addBaseClass( IASTBaseSpecifier baseSpecifier );
|
||||
|
||||
public void addFriendDeclaration( IASTDeclaration decl );
|
||||
}
|
||||
|
|
|
@ -218,7 +218,11 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
*/
|
||||
public IASTFunction createFunction(IASTScope scope, ITokenDuple name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int startLine, int nameOffset, int nameEndOffset, int nameLine, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, List constructorChain, boolean isFunctionDefinition, boolean hasFunctionTryBlock, boolean hasVariableArguments )
|
||||
{
|
||||
return new ASTFunction(scope, name.toString(), parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, startLine, nameOffset, nameEndOffset, ownerTemplate, hasFunctionTryBlock, hasVariableArguments, nameLine );
|
||||
ASTFunction function = new ASTFunction(scope, name.toString(), parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, startLine, nameOffset, nameEndOffset, ownerTemplate, hasFunctionTryBlock, hasVariableArguments, nameLine );
|
||||
if( isFriend && scope instanceof IASTQClassSpecifier ){
|
||||
((IASTQClassSpecifier)scope).addFriendDeclaration( function );
|
||||
}
|
||||
return function;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -226,7 +230,11 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
*/
|
||||
public IASTMethod createMethod(IASTScope scope, ITokenDuple name, List parameters, IASTAbstractDeclaration returnType, IASTExceptionSpecification exception, boolean isInline, boolean isFriend, boolean isStatic, int startOffset, int startLine, int nameOffset, int nameEndOffset, int nameLine, IASTTemplate ownerTemplate, boolean isConst, boolean isVolatile, boolean isVirtual, boolean isExplicit, boolean isPureVirtual, ASTAccessVisibility visibility, List constructorChain, boolean isFunctionDefinition, boolean hasFunctionTryBlock, boolean hasVariableArguments )
|
||||
{
|
||||
return new ASTMethod(scope, name.toString(), parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, startLine, nameOffset, nameEndOffset, nameLine, ownerTemplate, isConst, isVolatile, false, false, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain, hasFunctionTryBlock, hasVariableArguments);
|
||||
ASTMethod method = new ASTMethod(scope, name.toString(), parameters, returnType, exception, isInline, isFriend, isStatic, startOffset, startLine, nameOffset, nameEndOffset, nameLine, ownerTemplate, isConst, isVolatile, false, false, isVirtual, isExplicit, isPureVirtual, visibility, constructorChain, hasFunctionTryBlock, hasVariableArguments);
|
||||
if( isFriend && scope instanceof IASTQClassSpecifier ){
|
||||
((IASTQClassSpecifier)scope).addFriendDeclaration( method );
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -288,9 +296,13 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createTypeSpecDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier, java.util.List, java.util.List)
|
||||
*/
|
||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration(IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int startingLine, int endingOffset, int endingLine)
|
||||
public IASTAbstractTypeSpecifierDeclaration createTypeSpecDeclaration(IASTScope scope, IASTTypeSpecifier typeSpecifier, IASTTemplate template, int startingOffset, int startingLine, int endingOffset, int endingLine, boolean isFriend)
|
||||
{
|
||||
return new ASTAbstractTypeSpecifierDeclaration( scope, typeSpecifier, template, startingOffset, endingOffset, startingLine, endingLine );
|
||||
ASTAbstractTypeSpecifierDeclaration abs = new ASTAbstractTypeSpecifierDeclaration( scope, typeSpecifier, template, startingOffset, endingOffset, startingLine, endingLine, isFriend );
|
||||
if( isFriend && scope instanceof IASTQClassSpecifier ){
|
||||
((IASTQClassSpecifier)scope).addFriendDeclaration( abs );
|
||||
}
|
||||
return abs;
|
||||
}
|
||||
|
||||
public IASTElaboratedTypeSpecifier createElaboratedTypeSpecifier(IASTScope scope, ASTClassKind elaboratedClassKind, ITokenDuple typeName, int startingOffset, int startingLine, int endOffset, int endingLine, boolean isForewardDecl, boolean isFriend)
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -591,13 +592,22 @@ public class MatchLocator implements ISourceElementRequestor, ICSearchConstants
|
|||
|
||||
private IASTScope currentScope = null;
|
||||
private LinkedList scopeStack = new LinkedList();
|
||||
/* (non-Javadoc)
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedForewardDeclaration(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)
|
||||
*/
|
||||
public void acceptElaboratedForewardDeclaration(IASTElaboratedTypeSpecifier elaboratedType){
|
||||
check( DECLARATIONS, elaboratedType );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void acceptFriendDeclaration(IASTDeclaration declaration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public static void verbose(String log) {
|
||||
System.out.println("(" + Thread.currentThread() + ") " + log); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2004-04-14 Andrew Niefer
|
||||
updated src/org/eclipse/cdt/internal/ui/compare/SourceElementRequestorAdapter with acceptFriendDeclaration
|
||||
|
||||
2004-04-14 Alain Magloire
|
||||
|
||||
Fix PR 58375
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCodeScope;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
|
@ -358,4 +359,12 @@ public class SourceElementRequestorAdapter implements ISourceElementRequestor {
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFriendDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
|
||||
*/
|
||||
public void acceptFriendDeclaration(IASTDeclaration declaration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue