use of org.eclipse.jdt.internal.corext.util.TypeNameMatchCollector in project che by eclipse.
the class AddImportsOperation method findAllTypes.
/*
* Finds a type by the simple name.
*/
private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor) throws JavaModelException {
boolean is50OrHigher = JavaModelUtil.is50OrHigher(fCompilationUnit.getJavaProject());
int typeKinds = SimilarElementsRequestor.ALL_TYPES;
if (nameNode != null) {
typeKinds = ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher);
}
ArrayList<TypeNameMatch> typeInfos = new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor = new TypeNameMatchCollector(typeInfos);
int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
new SearchEngine().searchAllTypeNames(null, matchMode, simpleTypeName.toCharArray(), matchMode, getSearchForConstant(typeKinds), searchScope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
ArrayList<TypeNameMatch> typeRefsFound = new ArrayList<TypeNameMatch>(typeInfos.size());
for (int i = 0, len = typeInfos.size(); i < len; i++) {
TypeNameMatch curr = typeInfos.get(i);
if (curr.getPackageName().length() > 0) {
// do not suggest imports from the default package
if (isOfKind(curr, typeKinds, is50OrHigher) && isVisible(curr)) {
typeRefsFound.add(curr);
}
}
}
return typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]);
}
use of org.eclipse.jdt.internal.corext.util.TypeNameMatchCollector in project che by eclipse.
the class JavaContext method findAllTypes.
/*
* Finds a type by the simple name. From AddImportsOperation
*/
private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor, ICompilationUnit cu) throws JavaModelException {
boolean is50OrHigher = JavaModelUtil.is50OrHigher(cu.getJavaProject());
int typeKinds = SimilarElementsRequestor.ALL_TYPES;
if (nameNode != null) {
typeKinds = ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher);
}
ArrayList<TypeNameMatch> typeInfos = new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor = new TypeNameMatchCollector(typeInfos);
new SearchEngine().searchAllTypeNames(null, 0, simpleTypeName.toCharArray(), SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, getSearchForConstant(typeKinds), searchScope, requestor, IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, monitor);
ArrayList<TypeNameMatch> typeRefsFound = new ArrayList<TypeNameMatch>(typeInfos.size());
for (int i = 0, len = typeInfos.size(); i < len; i++) {
TypeNameMatch curr = typeInfos.get(i);
if (curr.getPackageName().length() > 0) {
// do not suggest imports from the default package
if (isOfKind(curr, typeKinds, is50OrHigher) && isVisible(curr, cu)) {
typeRefsFound.add(curr);
}
}
}
return typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]);
}
Aggregations