}
public String[] findAllPossibleKindsForProject() {
try {
SearchEngine engine = new SearchEngine();
ArrayList<IJavaElement> elements = new ArrayList<IJavaElement>();
IPackageFragmentRoot[] fragments = project
.getPackageFragmentRoots();
for (IPackageFragmentRoot fragment : fragments) {
int elementType = fragment.getKind();
/*
* if (elementType != IPackageFragmentRoot.K_SOURCE) { continue;
* }
*/
IJavaElement[] children = fragment.getChildren();
for (IJavaElement e : children) {
elements.add(e);
}
}
IJavaSearchScope ijss = SearchEngine.createJavaSearchScope(
elements.toArray(new IJavaElement[elements.size()]),
IJavaSearchScope.SOURCES);
AnnotationSearchRequestor asr = new AnnotationSearchRequestor();
SearchPattern patternFirst = SearchPattern.createPattern(
"PersistenceCapable", IJavaSearchConstants.ANNOTATION_TYPE,
IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH);
SearchPattern patternSecond = SearchPattern.createPattern("Entity",
IJavaSearchConstants.ANNOTATION_TYPE,
IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH);
engine.search(patternFirst, new SearchParticipant[] { SearchEngine
.getDefaultSearchParticipant() }, ijss, asr,
new NullProgressMonitor());
ArrayList<String> full = new ArrayList<String>();
full.addAll(asr.getEntityName());
asr.clear();
engine.search(patternSecond, new SearchParticipant[] { SearchEngine
.getDefaultSearchParticipant() }, ijss, asr,
new NullProgressMonitor());
full.addAll(asr.getEntityName());
return full.toArray(new String[full.size()]);