本文整理汇总了Java中org.eclipse.jdt.core.search.SearchEngine.searchAllTypeNames方法的典型用法代码示例。如果您正苦于以下问题:Java SearchEngine.searchAllTypeNames方法的具体用法?Java SearchEngine.searchAllTypeNames怎么用?Java SearchEngine.searchAllTypeNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.search.SearchEngine
的用法示例。
在下文中一共展示了SearchEngine.searchAllTypeNames方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findType
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
/**
* Find type
*
* @param className
* @param monitor
* @return type or <code>null</code>
*/
public IType findType(String className, IProgressMonitor monitor) {
final IType[] result = { null };
TypeNameMatchRequestor nameMatchRequestor = new TypeNameMatchRequestor() {
@Override
public void acceptTypeNameMatch(TypeNameMatch match) {
result[0] = match.getType();
}
};
int lastDot = className.lastIndexOf('.');
char[] packageName = lastDot >= 0 ? className.substring(0, lastDot).toCharArray() : null;
char[] typeName = (lastDot >= 0 ? className.substring(lastDot + 1) : className).toCharArray();
SearchEngine engine = new SearchEngine();
int packageMatchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
try {
engine.searchAllTypeNames(packageName, packageMatchRule, typeName, packageMatchRule, IJavaSearchConstants.TYPE,
SearchEngine.createWorkspaceScope(), nameMatchRequestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
} catch (JavaModelException e) {
EditorUtil.INSTANCE.logError("Was not able to search all type names",e);
}
return result[0];
}
示例2: findTypeByFqn
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
private List<IType> findTypeByFqn(char[][] packages, char[][] names, IJavaSearchScope scope)
throws JavaModelException {
List<IType> result = new ArrayList<>();
SearchEngine searchEngine = new SearchEngine();
searchEngine.searchAllTypeNames(
packages,
names,
scope,
new TypeNameMatchRequestor() {
@Override
public void acceptTypeNameMatch(TypeNameMatch typeNameMatch) {
result.add(typeNameMatch.getType());
}
},
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
new NullProgressMonitor());
return result;
}
示例3: waitUntilIndexesReady
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
public static void waitUntilIndexesReady() {
// dummy query for waiting until the indexes are ready
SearchEngine engine = new SearchEngine();
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
try {
engine.searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, "[email protected]$#[email protected]".toCharArray(), SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
IJavaSearchConstants.CLASS, scope, new TypeNameRequestor() {
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
}
}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
} catch (CoreException e) {
}
}
示例4: getSearchResult
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
@Override
protected TypeNameMatch[] getSearchResult(Set matchIdsInHistory, ProgressMonitor monitor) throws CoreException {
long start= System.currentTimeMillis();
fReqestor.setHistory(matchIdsInHistory);
// consider primary working copies during searching
SearchEngine engine= new SearchEngine((WorkingCopyOwner)null);
String packPattern= fFilter.getPackagePattern();
monitor.setTaskName(JavaUIMessages.TypeInfoViewer_searchJob_taskName);
engine.searchAllTypeNames(
packPattern == null ? null : packPattern.toCharArray(),
fFilter.getPackageFlags(),
fFilter.getNamePattern().toCharArray(),
fFilter.getSearchFlags(),
fElementKind,
fScope,
fReqestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
monitor);
if (DEBUG)
System.out.println("Time needed until search has finished: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
TypeNameMatch[] result= fReqestor.getResult();
Arrays.sort(result, new TypeInfoComparator(fLabelProvider, fFilter));
if (DEBUG)
System.out.println("Time needed until sort has finished: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
fViewer.rememberResult(fTicket, result);
return result;
}
示例5: fillContentProvider
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
@Override
protected void fillContentProvider(AbstractContentProvider provider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
TypeItemsFilter typeSearchFilter= (TypeItemsFilter) itemsFilter;
TypeSearchRequestor requestor= new TypeSearchRequestor(provider, typeSearchFilter);
SearchEngine engine= new SearchEngine((WorkingCopyOwner) null);
String packPattern= typeSearchFilter.getPackagePattern();
progressMonitor.setTaskName(JavaUIMessages.FilteredTypesSelectionDialog_searchJob_taskName);
/*
* Setting the filter into match everything mode avoids filtering twice
* by the same pattern (the search engine only provides filtered
* matches). For the case when the pattern is a camel case pattern with
* a terminator, the filter is not set to match everything mode because
* jdt.core's SearchPattern does not support that case.
*/
String typePattern= typeSearchFilter.getNamePattern();
int matchRule= typeSearchFilter.getMatchRule();
typeSearchFilter.setMatchEverythingMode(true);
try {
engine.searchAllTypeNames(packPattern == null ? null : packPattern.toCharArray(),
typeSearchFilter.getPackageFlags(),
typePattern.toCharArray(),
matchRule,
typeSearchFilter.getElementKind(),
typeSearchFilter.getSearchScope(),
requestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
progressMonitor);
} finally {
typeSearchFilter.setMatchEverythingMode(false);
}
}
示例6: searchJavaType
import org.eclipse.jdt.core.search.SearchEngine; //导入方法依赖的package包/类
public static void searchJavaType(String matchString, IJavaSearchScope scope,
TypeNameRequestor requestor) throws JavaModelException
{
char[] searchPkg = null;
char[] searchType = null;
if (matchString != null && matchString.length() > 0)
{
char[] match = matchString.toCharArray();
int lastDotPos = matchString.lastIndexOf('.');
if (lastDotPos == -1)
{
searchType = match;
}
else
{
if (lastDotPos + 1 < match.length)
{
searchType = CharOperation.lastSegment(match, '.');
}
searchPkg = Arrays.copyOfRange(match, 0, lastDotPos);
}
}
SearchEngine searchEngine = new SearchEngine();
searchEngine.searchAllTypeNames(searchPkg, SearchPattern.R_PREFIX_MATCH, searchType,
SearchPattern.R_CAMELCASE_MATCH, IJavaSearchConstants.CLASS, scope, requestor,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
}