From 2f19221ac04b46edbb24346da5bb9045dbf41b0f Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Fri, 7 May 2004 16:37:35 +0000 Subject: [PATCH] Modified indexer friend encoding to encode IASTElaboratedTypeSpecifier --- core/org.eclipse.cdt.core/index/ChangeLog | 3 +++ .../core/search/indexing/AbstractIndexer.java | 27 +++++++++++++++++++ .../core/search/matching/FriendPattern.java | 24 +++++++++++++---- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index e1e2de21a1b..de920e7d1cc 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -1,3 +1,6 @@ +2004-05-07 Bogdan Gheorghe + Modified indexer friend encoding to encode IASTElaboratedTypeSpecifier + 2004-05-06 Bogdan Gheorghe Modified AbstractIndexer to encode friends, add friends constant to IIndexConstants, modified SourceIndexerRequestor to add class specifier on exit instead of enter in order diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java index 12bd935f07d..2f09852f424 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java @@ -88,6 +88,11 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe String[] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedName(); this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS)); } + else if (decl instanceof IASTElaboratedTypeSpecifier){ + IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl; + String[] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedName(); + this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS)); + } else if (decl instanceof IASTFunction){ } @@ -115,6 +120,28 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe } catch (ASTNotImplementedException e) {} } +// Get friends + Iterator friends = classSpecification.getFriends(); + while (friends.hasNext()){ + Object decl = friends.next(); + if (decl instanceof IASTClassSpecifier){ + IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl; + String[] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedName(); + this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS)); + } + else if (decl instanceof IASTElaboratedTypeSpecifier){ + IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl; + String[] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedName(); + this.output.addRef(encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS)); + } + else if (decl instanceof IASTFunction){ + + } + else if (decl instanceof IASTMethod){ + // + } + } + this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),STRUCT, ICSearchConstants.DECLARATIONS)); } else if (classSpecification.getClassKind().equals(ASTClassKind.UNION)) diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java index 3fc6798ddac..de2b2cc0c1b 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FriendPattern.java @@ -12,6 +12,7 @@ import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier; import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier; +import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier; import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer; @@ -67,20 +68,31 @@ public class FriendPattern extends ClassDeclarationPattern { Iterator i = tempNode.getFriends(); boolean matchFlag=false; - + String[] fullName=null; while (i.hasNext()){ Object friend = i.next(); + String[] baseFullyQualifiedName = null; if (friend instanceof IASTClassSpecifier) { IASTClassSpecifier classSpec = (IASTClassSpecifier) friend; - String[] baseFullyQualifiedName = classSpec.getFullyQualifiedName(); - + baseFullyQualifiedName = classSpec.getFullyQualifiedName(); + //check name, if simpleName == null, its treated the same as "*" if( simpleName != null && !matchesName( simpleName, classSpec.getName().toCharArray() ) ){ continue; } - - + } + else if (friend instanceof IASTElaboratedTypeSpecifier ){ + IASTElaboratedTypeSpecifier elabType = (IASTElaboratedTypeSpecifier) friend; + baseFullyQualifiedName = elabType.getFullyQualifiedName(); + + //check name, if simpleName == null, its treated the same as "*" + if( simpleName != null && !matchesName( simpleName, elabType.getName().toCharArray() ) ){ + continue; + } + } + + if (baseFullyQualifiedName != null){ char [][] qualName = new char [ baseFullyQualifiedName.length - 1 ][]; for( int j = 0; j < baseFullyQualifiedName.length - 1; j++ ){ qualName[j] = baseFullyQualifiedName[j].toCharArray(); @@ -102,4 +114,6 @@ public class FriendPattern extends ClassDeclarationPattern { return IMPOSSIBLE_MATCH; } + + }