/** * @see {@link org.eclipse.jdt.internal.junit.ui.OpenTestAction} */ static IType findType(String className, IProgressMonitor monitor) throws CoreException { 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(); engine.searchAllTypeNames(packageName, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, typeName, SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, IJavaSearchConstants.TYPE, SearchEngine.createWorkspaceScope(), nameMatchRequestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); return result[0]; }
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException { try { new SearchEngine().searchAllTypeNames( null, 0, // make sure we search a concrete name. This is faster according to Kent "_______________".toCharArray(), //$NON-NLS-1$ SearchPattern.RULE_EXACT_MATCH | SearchPattern.RULE_CASE_SENSITIVE, IJavaSearchConstants.ENUM, SearchEngine.createWorkspaceScope(), new TypeNameRequestor() {}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException { try { new SearchEngine().searchAllTypeNames( null, 0, // make sure we search a concrete name. This is faster according to Kent "_______________".toCharArray(), //$NON-NLS-1$ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, IJavaSearchConstants.ENUM, SearchEngine.createWorkspaceScope(), new TypeNameRequestor() { /* dummy */}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }
private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException { try { new SearchEngine().searchAllTypeNames( null, 0, // make sure we search a concrete name. This is faster according to Kent "_______________".toCharArray(), //$NON-NLS-1$ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, IJavaSearchConstants.ENUM, SearchEngine.createWorkspaceScope(), new TypeNameRequestor() { /* dummy */}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); } catch (JavaModelException e) { throw new InvocationTargetException(e); } } }
/** * Internal adapter class. * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor */ static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor { ITypeNameRequestor nameRequestor; TypeNameRequestorAdapter(ITypeNameRequestor requestor) { this.nameRequestor = requestor; } public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (Flags.isInterface(modifiers)) { this.nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path); } else { this.nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path); } } }
/** * Internal adapter class. * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor */ static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor { ITypeNameRequestor nameRequestor; TypeNameRequestorAdapter(ITypeNameRequestor requestor) { this.nameRequestor = requestor; } public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (Flags.isInterface(modifiers)) { this.nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path); } else { this.nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path); } } }
/** * Internal adapter class. * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor */ static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor { ITypeNameRequestor nameRequestor; TypeNameRequestorAdapter(ITypeNameRequestor requestor) { this.nameRequestor = requestor; } public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (Flags.isInterface(modifiers)) { this.nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path); } else { this.nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path); } } }
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException { if(progressMonitor == null) { progressMonitor = new NullProgressMonitor(); } progressMonitor.setTaskName(BreakpointMessages.AddExceptionDialog_10); SearchEngine engine = new SearchEngine((WorkingCopyOwner) null); engine.searchAllTypeNames((char[])null, SearchPattern.R_EXACT_MATCH, (char[])null, SearchPattern.R_EXACT_MATCH, IJavaSearchConstants.CLASS, SearchEngine.createWorkspaceScope(), new ExceptionTypeNameRequestor(contentProvider, itemsFilter), IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, progressMonitor); }
private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor, ICompilationUnit cu) throws JavaModelException { boolean is50OrHigher= JavaModelUtil.is50OrHigher(cu.getJavaProject()); int typeKinds= TypeKinds.ALL_TYPES; if (nameNode != null) { typeKinds= ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher); } ArrayList<TypeNameMatch> typeInfos= new ArrayList<>(); 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<>(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()]); }
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<>(); 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<>(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()]); }
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 typeInfos= new ArrayList(); 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 typeRefsFound= new ArrayList(typeInfos.size()); for (int i= 0, len= typeInfos.size(); i < len; i++) { TypeNameMatch curr= (TypeNameMatch) 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 (TypeNameMatch[]) typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]); }
private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor) throws JavaModelException { boolean is50OrHigher= JavaModelUtil.is50OrHigher(fCompilationUnit.getJavaProject()); int typeKinds= TypeKinds.ALL_TYPES; if (nameNode != null) { typeKinds= ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher); } ArrayList<TypeNameMatch> typeInfos= new ArrayList<>(); 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<>(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()]); }
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 typeInfos= new ArrayList(); 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 typeRefsFound= new ArrayList(typeInfos.size()); for (int i= 0, len= typeInfos.size(); i < len; i++) { TypeNameMatch curr= (TypeNameMatch) 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 (TypeNameMatch[]) typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]); }
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<>(); 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<>(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()]); }
@Override public Set<String> findConflictingSimpleNames( Set<String> simpleNames, Set<String> onDemandAndImplicitContainerNames, IProgressMonitor monitor) throws JavaModelException { IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { this.javaProject }); ConflictAccumulatingTypeRequestor requestor = new ConflictAccumulatingTypeRequestor(); this.searchEngine.searchAllTypeNames( stringsToCharArrays(onDemandAndImplicitContainerNames), stringsToCharArrays(simpleNames), scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); return requestor.getNamesFoundInMultipleContainers(); } }
@Override public Set<String> findConflictingSimpleNames( Set<String> simpleNames, Set<String> onDemandAndImplicitContainerNames, IProgressMonitor monitor) throws JavaModelException { IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { this.javaProject }); ConflictAccumulatingTypeRequestor requestor = new ConflictAccumulatingTypeRequestor(); this.searchEngine.searchAllTypeNames( stringsToCharArrays(onDemandAndImplicitContainerNames), stringsToCharArrays(simpleNames), scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); return requestor.getNamesFoundInMultipleContainers(); } }
@Override public Set<String> findConflictingSimpleNames( Set<String> simpleNames, Set<String> onDemandAndImplicitContainerNames, IProgressMonitor monitor) throws JavaModelException { IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { this.javaProject }); ConflictAccumulatingTypeRequestor requestor = new ConflictAccumulatingTypeRequestor(); this.searchEngine.searchAllTypeNames( stringsToCharArrays(onDemandAndImplicitContainerNames), stringsToCharArrays(simpleNames), scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor); return requestor.getNamesFoundInMultipleContainers(); } }
/** * Internal adapter class. * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor */ static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor { ITypeNameRequestor nameRequestor; TypeNameRequestorAdapter(ITypeNameRequestor requestor) { this.nameRequestor = requestor; } public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (Flags.isInterface(modifiers)) { this.nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path); } else { this.nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path); } } }
/** * Internal adapter class. * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor */ static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor { ITypeNameRequestor nameRequestor; TypeNameRequestorAdapter(ITypeNameRequestor requestor) { this.nameRequestor = requestor; } public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (Flags.isInterface(modifiers)) { this.nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path); } else { this.nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path); } } }
/** * Internal adapter class. * @deprecated marking deprecated as it uses deprecated ITypeNameRequestor */ static class TypeNameRequestorAdapter implements IRestrictedAccessTypeRequestor { ITypeNameRequestor nameRequestor; TypeNameRequestorAdapter(ITypeNameRequestor requestor) { this.nameRequestor = requestor; } @Override public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (Flags.isInterface(modifiers)) { this.nameRequestor.acceptInterface(packageName, simpleTypeName, enclosingTypeNames, path); } else { this.nameRequestor.acceptClass(packageName, simpleTypeName, enclosingTypeNames, path); } } }