Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 20238 Details for
Bug 83230
[1.5][search][annot] search for annotation elements does not seem to be implemented yet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to implement this functionality
v00.txt (text/plain), 12.61 KB, created by
Frederic Fusier
on 2005-04-22 10:43:46 EDT
(
hide
)
Description:
Patch to implement this functionality
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2005-04-22 10:43:46 EDT
Size:
12.61 KB
patch
obsolete
>Index: model/org/eclipse/jdt/internal/compiler/SourceElementParser.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java,v >retrieving revision 1.45 >diff -u -r1.45 SourceElementParser.java >--- model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 20 Apr 2005 21:43:51 -0000 1.45 >+++ model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 22 Apr 2005 14:40:57 -0000 >@@ -329,6 +329,13 @@ > requestor.acceptFieldReference(fr.token, fr.sourceStart); > } > } >+protected void consumeMemberValuePair() { >+ super.consumeMemberValuePair(); >+ MemberValuePair memberValuepair = (MemberValuePair) this.astStack[this.astPtr]; >+ if (reportReferenceInfo) { >+ requestor.acceptMethodReference(memberValuepair.name, 0, memberValuepair.sourceStart); >+ } >+} > protected void consumeMethodHeaderName(boolean isAnnotationMethod) { > long selectorSourcePositions = this.identifierPositionStack[this.identifierPtr]; > int selectorSourceEnd = (int) selectorSourcePositions; >@@ -435,6 +442,13 @@ > (int)(messageSend.nameSourcePosition >>> 32)); > } > } >+protected void consumeSingleMemberAnnotation() { >+ super.consumeSingleMemberAnnotation(); >+ SingleMemberAnnotation member = (SingleMemberAnnotation) expressionStack[expressionPtr]; >+ if (reportReferenceInfo) { >+ requestor.acceptMethodReference(TypeConstants.VALUE, 0, member.sourceStart); >+ } >+} > protected void consumeSingleStaticImportDeclarationName() { > // SingleTypeImportDeclarationName ::= 'import' 'static' Name > super.consumeSingleStaticImportDeclarationName(); >Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v >retrieving revision 1.236 >diff -u -r1.236 MatchLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 11 Apr 2005 15:37:37 -0000 1.236 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 22 Apr 2005 14:41:00 -0000 >@@ -1767,15 +1767,10 @@ > > // report annotations > if (method.annotations != null) { >- for (int i=0, al=method.annotations.length; i<al; i++) { >- TypeReference typeRef = method.annotations[i].type; >- Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef); >- if (level != null) { >- if (enclosingElement == null) >- enclosingElement = createHandle(method, parent); >- this.patternLocator.matchReportReference(typeRef, enclosingElement, method.binding, level.intValue(), this); >- } >+ if (enclosingElement == null) { >+ enclosingElement = createHandle(method, parent); > } >+ reportMatching(method.annotations, enclosingElement, method.binding, nodeSet, true, true); > } > > // references in this method >@@ -1800,6 +1795,32 @@ > } > } > /** >+ * Report matching in annotations. >+ */ >+protected void reportMatching(Annotation[] annotations, IJavaElement enclosingElement, Binding elementBinding, MatchingNodeSet nodeSet, boolean matchedContainer, boolean enclosesElement) throws CoreException { >+ for (int i=0, al=annotations.length; i<al; i++) { >+ Annotation annotationType = annotations[i]; >+ >+ // Look for annotation type ref >+ TypeReference typeRef = annotationType.type; >+ Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef); >+ if (level != null && matchedContainer) { >+ this.patternLocator.matchReportReference(typeRef, enclosingElement, elementBinding, level.intValue(), this); >+ } >+ >+ // Look for attribute ref >+ MemberValuePair[] pairs = annotationType.memberValuePairs(); >+ for (int j = 0, pl = pairs.length; j < pl; j++) { >+ MemberValuePair pair = pairs[j]; >+ level = (Integer) nodeSet.matchingNodes.removeKey(pair); >+ if (level != null && enclosesElement) { >+ ASTNode reference = (annotationType instanceof SingleMemberAnnotation) ? (ASTNode) annotationType: pair; >+ this.patternLocator.matchReportReference(reference, enclosingElement, pair.binding, level.intValue(), this); >+ } >+ } >+ } >+} >+/** > * Visit the given resolved parse tree and report the nodes that match the search pattern. > */ > protected void reportMatching(CompilationUnitDeclaration unit, boolean mustResolve) throws CoreException { >@@ -1889,15 +1910,10 @@ > > // report annotations > if (field.annotations != null) { >- for (int i=0, al=field.annotations.length; i<al; i++) { >- TypeReference typeRef = field.annotations[i].type; >- Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef); >- if (level != null) { >- if (enclosingElement == null) >- enclosingElement = createHandle(field, type, parent); >- this.patternLocator.matchReportReference(typeRef, enclosingElement, field.binding, level.intValue(), this); >- } >+ if (enclosingElement == null) { >+ enclosingElement = createHandle(field, type, parent); > } >+ reportMatching(field.annotations, enclosingElement, field.binding, nodeSet, true, true); > } > > if (typeInHierarchy) { >@@ -1940,9 +1956,10 @@ > enclosingElement = member.getType(new String(type.name), occurrenceCount); > } > if (enclosingElement == null) return; >+ boolean enclosesElement = encloses(enclosingElement); > > // report the type declaration >- if (accuracy > -1 && encloses(enclosingElement)) { >+ if (accuracy > -1 && enclosesElement) { > int offset = type.sourceStart; > SearchMatch match = this.patternLocator.newDeclarationMatch(type, enclosingElement, type.binding, accuracy, type.sourceEnd-offset+1, this); > report(match); >@@ -1957,7 +1974,7 @@ > if (typeParameter != null) { > Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeParameter); > if (level != null && matchedClassContainer) { >- if (level.intValue() > -1 && encloses(enclosingElement)) { >+ if (level.intValue() > -1 && enclosesElement) { > int offset = typeParameter.sourceStart; > SearchMatch match = this.patternLocator.newDeclarationMatch(typeParameter, enclosingElement, type.binding, level.intValue(), typeParameter.sourceEnd-offset+1, this); > report(match); >@@ -1983,13 +2000,7 @@ > > // report annotations > if (type.annotations != null) { >- for (int i=0, al=type.annotations.length; i<al; i++) { >- TypeReference typeRef = type.annotations[i].type; >- Integer level = (Integer) nodeSet.matchingNodes.removeKey(typeRef); >- if (level != null && matchedClassContainer) { >- this.patternLocator.matchReportReference(typeRef, enclosingElement, type.binding, level.intValue(), this); >- } >- } >+ reportMatching(type.annotations, enclosingElement, type.binding, nodeSet, matchedClassContainer, enclosesElement); > } > > // report references in javadoc >@@ -2003,8 +2014,9 @@ > for (int i = 0, l = nodes.length; i < l; i++) { > ASTNode node = nodes[i]; > Integer level = (Integer) nodeSet.matchingNodes.removeKey(node); >- if (encloses(enclosingElement)) >+ if (enclosesElement) { > this.patternLocator.matchReportReference(node, enclosingElement, type.binding, level.intValue(), this); >+ } > } > } > } >Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java,v >retrieving revision 1.68 >diff -u -r1.68 MatchLocatorParser.java >--- search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java 10 Mar 2005 16:28:15 -0000 1.68 >+++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java 22 Apr 2005 14:41:01 -0000 >@@ -75,6 +75,10 @@ > patternLocator.match(methodDeclaration, nodeSet); > return (methodDeclaration.bits & ASTNode.HasLocalTypeMASK) != 0; // continue only if it has local type > } >+ public boolean visit(AnnotationMethodDeclaration methodDeclaration, ClassScope scope) { >+ patternLocator.match(methodDeclaration, nodeSet); >+ return false; // no local type for annotation type members >+ } > } > public class ClassAndMethodDeclarationVisitor extends ClassButNoMethodDeclarationVisitor { > public boolean visit(TypeDeclaration localTypeDeclaration, BlockScope scope) { >@@ -232,6 +236,12 @@ > // this is always a LocalDeclaration > this.patternLocator.match((LocalDeclaration) this.astStack[this.astPtr], this.nodeSet); > } >+protected void consumeMemberValuePair() { >+ super.consumeMemberValuePair(); >+ >+ // this is always a MemberValuePair >+ this.patternLocator.match((MemberValuePair) this.astStack[this.astPtr], this.nodeSet); >+} > protected void consumeMethodInvocationName() { > super.consumeMethodInvocationName(); > >@@ -283,6 +293,13 @@ > intPtr--; > intPtr--; > } >+protected void consumeSingleMemberAnnotation() { >+ super.consumeSingleMemberAnnotation(); >+ MemberValuePair[] pairs = ((SingleMemberAnnotation) expressionStack[expressionPtr]).memberValuePairs(); >+ if (pairs != null && pairs.length==1) { >+ this.patternLocator.match(pairs[0], nodeSet); >+ } >+} > protected void consumeTypeArgument() { > super.consumeTypeArgument(); > patternLocator.match((TypeReference)genericsStack[genericsPtr], nodeSet); >Index: search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java,v >retrieving revision 1.45 >diff -u -r1.45 MethodLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 21 Apr 2005 13:06:49 -0000 1.45 >+++ search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java 22 Apr 2005 14:41:01 -0000 >@@ -104,6 +104,13 @@ > // Method declaration may match pattern > return nodeSet.addMatch(node, ((InternalSearchPattern)this.pattern).mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); > } >+public int match(MemberValuePair node, MatchingNodeSet nodeSet) { >+ if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; >+ >+ if (!matchesName(this.pattern.selector, node.name)) return IMPOSSIBLE_MATCH; >+ >+ return nodeSet.addMatch(node, ((InternalSearchPattern)this.pattern).mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); >+} > public int match(MessageSend node, MatchingNodeSet nodeSet) { > if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; > >@@ -223,7 +230,8 @@ > } else { > int offset = reference.sourceStart; > match.setOffset(offset); >- match.setLength(reference.sourceEnd-offset+1); >+ int length = (reference instanceof SingleMemberAnnotation) ? 0 : reference.sourceEnd - offset + 1; >+ match.setLength(length); > locator.report(match); > } > } >@@ -354,10 +362,20 @@ > } > } > public int resolveLevel(ASTNode possibleMatchingNode) { >- if (this.pattern.findReferences && possibleMatchingNode instanceof MessageSend) >- return resolveLevel((MessageSend) possibleMatchingNode); >- if (this.pattern.findDeclarations && possibleMatchingNode instanceof MethodDeclaration) >- return resolveLevel(((MethodDeclaration) possibleMatchingNode).binding); >+ if (this.pattern.findReferences) { >+ if (possibleMatchingNode instanceof MessageSend) { >+ return resolveLevel((MessageSend) possibleMatchingNode); >+ } >+ if (possibleMatchingNode instanceof MemberValuePair) { >+ MemberValuePair memberValuePair = (MemberValuePair) possibleMatchingNode; >+ return resolveLevel(memberValuePair.binding); >+ } >+ } >+ if (this.pattern.findDeclarations) { >+ if (possibleMatchingNode instanceof MethodDeclaration) { >+ return resolveLevel(((MethodDeclaration) possibleMatchingNode).binding); >+ } >+ } > return IMPOSSIBLE_MATCH; > } > public int resolveLevel(Binding binding) { >Index: search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java,v >retrieving revision 1.44 >diff -u -r1.44 PatternLocator.java >--- search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 21 Apr 2005 13:06:49 -0000 1.44 >+++ search/org/eclipse/jdt/internal/core/search/matching/PatternLocator.java 22 Apr 2005 14:41:02 -0000 >@@ -180,6 +180,10 @@ > // each subtype should override if needed > return IMPOSSIBLE_MATCH; > } >+public int match(MemberValuePair node, MatchingNodeSet nodeSet) { >+ // each subtype should override if needed >+ return IMPOSSIBLE_MATCH; >+} > public int match(MessageSend node, MatchingNodeSet nodeSet) { > // each subtype should override if needed > return IMPOSSIBLE_MATCH;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 83230
: 20238