Home » General (non-technical) » Test » test 2
test 2 [message #5928] |
Wed, 11 July 2007 14:51 |
Eclipse User |
|
|
|
Originally posted by: dfg.dt.it
I am having a problem with searching for classes that extend another
class. The version of Eclipse that I am using is Version: 3.3.0, Build id:
I20070503-1400.
I have the following code
final Set<SearchMatch> classesThatExtendFoo= new
HashSet<SearchMatch>();
IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
SearchPattern pattern= SearchPattern.createPattern("Foo",
IJavaSearchConstants.TYPE, IJavaSearchConstants.IMPLEMENTORS,
SearchPattern.R_EXACT_MATCH); SearchEngine engine= new
SearchEngine();
engine.search(pattern, new SearchParticipant[] {
SearchEngine.getDefaultSearchParticipant()}, scope, new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws
CoreException {
if (match.getAccuracy() == SearchMatch.A_ACCURATE &&
!match.isInsideDocComment())
System.out.println(match);
classesThatExtendFoo.add(match);
} }, new SubProgressMonitor(monitor, 1,
SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
which I am trying to use in order to find classes that extend a class
named Foo.
This code works when the class Foo exists in my project.
But I would also like it to work when the class Foo does not exist in the
project (i.e. the code will be broken and will not compile).
For example if I have the class
class Bar extends Foo{
}
and the class Foo does not exist in the project is it still possible to
find classes that extend Foo i.e. Bar?
The code above does not find Bar.
The code gets as far as "process(PossibleMatch, boolean) line: 1549"
<unknown receiving type>(MatchLocator).process(PossibleMatch, boolean)
line: 1549
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatch[], int, int) line: 1037
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatchSet, int) line: 1078
<unknown receiving type>(MatchLocator).locateMatches(SearchDocument[])
line: 1199
<unknown receiving
type>(JavaSearchParticipant).locateMatches(SearchDocument[],
SearchPattern, IJavaSearchScope, SearchRequestor, IProgressMonitor) line:
94
<unknown receiving type>(BasicSearchEngine).findMatches(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 217
<unknown receiving type>(BasicSearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 502
<unknown receiving type>(SearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 550
so it does identify Bar as a possible match.
The problem arises when it goes to report the possible match
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
<unknown receiving type>(MatchLocator).process(PossibleMatch, boolean)
line: 1549
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatch[], int, int) line: 1037
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatchSet, int) line: 1078
<unknown receiving type>(MatchLocator).locateMatches(SearchDocument[])
line: 1199
<unknown receiving
type>(JavaSearchParticipant).locateMatches(SearchDocument[],
SearchPattern, IJavaSearchScope, SearchRequestor, IProgressMonitor) line:
94
<unknown receiving type>(BasicSearchEngine).findMatches(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 217
<unknown receiving type>(BasicSearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 502
<unknown receiving type>(SearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 550
it calls the method resolveLevel
/**
* Finds out whether the given ast node matches this search pattern.
* Returns IMPOSSIBLE_MATCH if it doesn't.
* Returns INACCURATE_MATCH if it potentially matches this search
pattern (ie. * it has already been resolved but resolving failed.)
* Returns ACCURATE_MATCH if it matches exactly this search pattern
(ie. * it doesn't need to be resolved or it has already been
resolved.)
*/
public int resolveLevel(ASTNode possibleMatchingNode) {
// only called with nodes which were possible matches to the call
to matchLevel
// need to do instance of checks to find out exact type of ASTNode
return IMPOSSIBLE_MATCH;
}
from the class
org.eclipse.jdt.internal.core.search.matching.SuperTypeRefer enceLocator
in order to see if the class that the class Bar extends is a match for the
class Foo.
But even though the node passed in to the method resolveLevel is for the
class Foo an IMPOSSIBLE_MATCH is returned as no bindings exist (or are
missing) for the class Foo. No bindings exist for the class Foo (I
presume) because the class Foo does not exist.
The problem with the lack of binding information can be seen here
ProblemReferenceBinding(ReferenceBinding).sourceName() line: 1136
ProblemReferenceBinding(ReferenceBinding).qualifiedSourceNam e() line:
1065
PatternLocator.qualifiedSourceName(TypeBinding) line: 113
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
TypeBinding) line: 749
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
char[], TypeBinding) line: 698
SuperTypeReferenceLocator.resolveLevel(ASTNode) line: 82
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
MatchLocator.process(PossibleMatch, boolean) line: 1549
MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int)
line: 1037
MatchLocator.locateMatches(JavaProject, PossibleMatchSet, int) line:
1078
MatchLocator.locateMatches(SearchDocument[]) line: 1199
JavaSearchParticipant.locateMatches(SearchDocument[], SearchPattern,
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 94
BasicSearchEngine.findMatches(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 217
BasicSearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 502
SearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 550
where the sourceName returned is null, and similiary when searching for
the package name. This results in an IMPOSSIBLE_MATCH being returned from
the method
org.eclipse.jdt.internal.core.search.matching.SuperTypeRefer enceLocator::resolveLevelForType.
Is there anyway to get around this and find Bar i.e. find all classes that
extend Foo even when the class Foo does not exist?
Creating the class Foo on the fly solves this problem but I was wondering
if there is a way of doing this without having to create the class Foo?
Any help greatly appreciated,
Máirtín
|
|
|
Re: test 2 [message #5947 is a reply to message #5928] |
Wed, 11 July 2007 14:53 |
Eclipse User |
|
|
|
Originally posted by: dfgdf.ere.et
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
<unknown receiving type>(MatchLocator).process(PossibleMatch, boolean)
line: 1549
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatch[], int, int) line: 1037
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatchSet, int) line: 1078
<unknown receiving type>(MatchLocator).locateMatches(SearchDocument[])
line: 1199
<unknown receiving
type>(JavaSearchParticipant).locateMatches(SearchDocument[],
SearchPattern, IJavaSearchScope, SearchRequestor, IProgressMonitor) line:
94
<unknown receiving type>(BasicSearchEngine).findMatches(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 217
<unknown receiving type>(BasicSearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 502
<unknown receiving type>(SearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 550
|
|
|
Re: test 2 [message #5965 is a reply to message #5947] |
Wed, 11 July 2007 14:56 |
Eclipse User |
|
|
|
Originally posted by: dfg.dg.ie
ProblemReferenceBinding(ReferenceBinding).sourceName() line: 1136
ProblemReferenceBinding(ReferenceBinding).qualifiedSourceNam e() line:
1065
PatternLocator.qualifiedSourceName(TypeBinding) line: 113
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
TypeBinding) line: 749
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
char[], TypeBinding) line: 698
SuperTypeReferenceLocator.resolveLevel(ASTNode) line: 82
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
MatchLocator.process(PossibleMatch, boolean) line: 1549
MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int) line:
1037
MatchLocator.locateMatches(JavaProject, PossibleMatchSet, int) line: 1078
MatchLocator.locateMatches(SearchDocument[]) line: 1199
JavaSearchParticipant.locateMatches(SearchDocument[], SearchPattern,
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 94
BasicSearchEngine.findMatches(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 217
BasicSearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 502
SearchEngine.search(SearchPattern, SearchParticipant[], IJavaSearchScope,
SearchRequestor, IProgressMonitor) line: 550
|
|
|
Re: test 2 [message #5979 is a reply to message #5965] |
Wed, 11 July 2007 14:58 |
Eclipse User |
|
|
|
Originally posted by: dfgdfg.wetwe.oe
ProblemReferenceBinding(ReferenceBinding).sourceName() line: 1136
ProblemReferenceBinding(ReferenceBinding).qualifiedSourceNam e() line:
1065
PatternLocator.qualifiedSourceName(TypeBinding) line: 113
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
TypeBinding) line: 749
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
char[], TypeBinding) line: 698
SuperTypeReferenceLocator.resolveLevel(ASTNode) line: 82
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
MatchLocator.process(PossibleMatch, boolean) line: 1549
MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int)
line: 1037
MatchLocator.locateMatches(JavaProject, PossibleMatchSet, int) line:
1078
MatchLocator.locateMatches(SearchDocument[]) line: 1199
JavaSearchParticipant.locateMatches(SearchDocument[], SearchPattern,
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 94
BasicSearchEngine.findMatches(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 217
BasicSearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 502
SearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 550
|
|
|
Re: test 2 [message #560720 is a reply to message #5928] |
Wed, 11 July 2007 14:53 |
Eclipse User |
|
|
|
Originally posted by: dfgdf.ere.et
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
<unknown receiving type>(MatchLocator).process(PossibleMatch, boolean)
line: 1549
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatch[], int, int) line: 1037
<unknown receiving type>(MatchLocator).locateMatches(JavaProject,
PossibleMatchSet, int) line: 1078
<unknown receiving type>(MatchLocator).locateMatches(SearchDocument[])
line: 1199
<unknown receiving
type>(JavaSearchParticipant).locateMatches(SearchDocument[],
SearchPattern, IJavaSearchScope, SearchRequestor, IProgressMonitor) line:
94
<unknown receiving type>(BasicSearchEngine).findMatches(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 217
<unknown receiving type>(BasicSearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 502
<unknown receiving type>(SearchEngine).search(SearchPattern,
SearchParticipant[], IJavaSearchScope, SearchRequestor, IProgressMonitor)
line: 550
|
|
|
Re: test 2 [message #560731 is a reply to message #5947] |
Wed, 11 July 2007 14:56 |
Eclipse User |
|
|
|
Originally posted by: dfg.dg.ie
ProblemReferenceBinding(ReferenceBinding).sourceName() line: 1136
ProblemReferenceBinding(ReferenceBinding).qualifiedSourceNam e() line:
1065
PatternLocator.qualifiedSourceName(TypeBinding) line: 113
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
TypeBinding) line: 749
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
char[], TypeBinding) line: 698
SuperTypeReferenceLocator.resolveLevel(ASTNode) line: 82
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
MatchLocator.process(PossibleMatch, boolean) line: 1549
MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int) line:
1037
MatchLocator.locateMatches(JavaProject, PossibleMatchSet, int) line: 1078
MatchLocator.locateMatches(SearchDocument[]) line: 1199
JavaSearchParticipant.locateMatches(SearchDocument[], SearchPattern,
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 94
BasicSearchEngine.findMatches(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 217
BasicSearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 502
SearchEngine.search(SearchPattern, SearchParticipant[], IJavaSearchScope,
SearchRequestor, IProgressMonitor) line: 550
|
|
|
Re: test 2 [message #560738 is a reply to message #5965] |
Wed, 11 July 2007 14:58 |
Eclipse User |
|
|
|
Originally posted by: dfgdfg.wetwe.oe
ProblemReferenceBinding(ReferenceBinding).sourceName() line: 1136
ProblemReferenceBinding(ReferenceBinding).qualifiedSourceNam e() line:
1065
PatternLocator.qualifiedSourceName(TypeBinding) line: 113
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
TypeBinding) line: 749
SuperTypeReferenceLocator(PatternLocator).resolveLevelForTyp e(char[],
char[], TypeBinding) line: 698
SuperTypeReferenceLocator.resolveLevel(ASTNode) line: 82
MatchLocator.reportMatching(CompilationUnitDeclaration, boolean) line:
2139
MatchLocator.process(PossibleMatch, boolean) line: 1549
MatchLocator.locateMatches(JavaProject, PossibleMatch[], int, int)
line: 1037
MatchLocator.locateMatches(JavaProject, PossibleMatchSet, int) line:
1078
MatchLocator.locateMatches(SearchDocument[]) line: 1199
JavaSearchParticipant.locateMatches(SearchDocument[], SearchPattern,
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 94
BasicSearchEngine.findMatches(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 217
BasicSearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 502
SearchEngine.search(SearchPattern, SearchParticipant[],
IJavaSearchScope, SearchRequestor, IProgressMonitor) line: 550
|
|
|
Goto Forum:
Current Time: Wed Dec 11 01:06:40 GMT 2024
Powered by FUDForum. Page generated in 0.03903 seconds
|