List of usage examples for org.eclipse.jdt.internal.codeassist ISearchRequestor acceptType
public void acceptType(char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction);
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.JavaSearchNameEnvironment.java
License:Open Source License
/** * Must be used only by CompletionEngine. * The progress monitor is used to be able to cancel completion operations * * Find the top-level types that are defined * in the current environment and whose name starts with the * given prefix. The prefix is a qualified name separated by periods * or a simple name (ex. java.util.V or V). * * The types found are passed to one of the following methods (if additional * information is known about the types): * ISearchRequestor.acceptType(char[][] packageName, char[] typeName) * ISearchRequestor.acceptClass(char[][] packageName, char[] typeName, int modifiers) * ISearchRequestor.acceptInterface(char[][] packageName, char[] typeName, int modifiers) * * This method can not be used to find member types... member * types are found relative to their enclosing type. */// ww w . jav a 2s . co m public void findTypes(char[] prefix, final boolean findMembers, boolean camelCaseMatch, int searchFor, final ISearchRequestor storage, IProgressMonitor monitor) { try { int lastDotIndex = CharOperation.lastIndexOf('.', prefix); char[] qualification, simpleName; if (lastDotIndex < 0) { qualification = null; if (camelCaseMatch) { simpleName = prefix; } else { simpleName = CharOperation.toLowerCase(prefix); } } else { qualification = CharOperation.subarray(prefix, 0, lastDotIndex); if (camelCaseMatch) { simpleName = CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length); } else { simpleName = CharOperation .toLowerCase(CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length)); } } IProgressMonitor progressMonitor = new IProgressMonitor() { boolean isCanceled = false; public void beginTask(String name, int totalWork) { // implements interface method } public void done() { // implements interface method } public void internalWorked(double work) { // implements interface method } public boolean isCanceled() { return this.isCanceled; } public void setCanceled(boolean value) { this.isCanceled = value; } public void setTaskName(String name) { // implements interface method } public void subTask(String name) { // implements interface method } public void worked(int work) { // implements interface method } }; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor() { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { // if (excludePath != null && excludePath.equals(path)) // return; if (!findMembers && enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types storage.acceptType(packageName, simpleTypeName, enclosingTypeNames, modifiers, access); } }; int matchRule = SearchPattern.R_PREFIX_MATCH; if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH; IndexManager indexManager = javaProject.getIndexManager(); if (monitor != null) { if (indexManager.awaitingJobsCount() == 0) { // indexes were already there, so perform an immediate search to avoid any index rebuilt new BasicSearchEngine(indexManager).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, progressMonitor); } else { // indexes were not ready, give the indexing a chance to finish small jobs by sleeping 100ms... try { Thread.sleep(100); } catch (InterruptedException e) { // Do nothing } if (monitor.isCanceled()) { throw new OperationCanceledException(); } if (indexManager.awaitingJobsCount() == 0) { // indexes are now ready, so perform an immediate search to avoid any index rebuilt new BasicSearchEngine(indexManager).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, progressMonitor); } //else { // Indexes are still not ready, so look for types in the model instead of a search request // findTypes( // new String(prefix), // storage, // convertSearchFilterToModelFilter(searchFor)); // } } } else { try { new BasicSearchEngine(indexManager).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, progressMonitor); } catch (OperationCanceledException e) { // findTypes( // new String(prefix), // storage, // convertSearchFilterToModelFilter(searchFor)); } } } catch (JavaModelException e) { // findTypes( // new String(prefix), // storage, // convertSearchFilterToModelFilter(searchFor)); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.JavaSearchNameEnvironment.java
License:Open Source License
/** * Find the top-level types that are defined * in the current environment and whose simple name matches the given name. * * The types found are passed to one of the following methods (if additional * information is known about the types): * ISearchRequestor.acceptType(char[][] packageName, char[] typeName) * ISearchRequestor.acceptClass(char[][] packageName, char[] typeName, int modifiers) * ISearchRequestor.acceptInterface(char[][] packageName, char[] typeName, int modifiers) * * This method can not be used to find member types... member * types are found relative to their enclosing type. *//* w ww . ja v a2 s.c o m*/ public void findExactTypes(char[] name, final boolean findMembers, int searchFor, final ISearchRequestor storage) { try { IProgressMonitor progressMonitor = new IProgressMonitor() { boolean isCanceled = false; public void beginTask(String n, int totalWork) { // implements interface method } public void done() { // implements interface method } public void internalWorked(double work) { // implements interface method } public boolean isCanceled() { return this.isCanceled; } public void setCanceled(boolean value) { this.isCanceled = value; } public void setTaskName(String n) { // implements interface method } public void subTask(String n) { // implements interface method } public void worked(int work) { // implements interface method } }; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor() { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (!findMembers && enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types storage.acceptType(packageName, simpleTypeName, enclosingTypeNames, modifiers, access); } }; try { new BasicSearchEngine(javaProject.getIndexManager()).searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, name, SearchPattern.R_EXACT_MATCH, searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, progressMonitor); } catch (OperationCanceledException e) { // findExactTypes( // new String(name), // storage, // convertSearchFilterToModelFilter(searchFor)); } } catch (JavaModelException e) { // findExactTypes( // new String(name), // storage, // convertSearchFilterToModelFilter(searchFor)); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.SearchableEnvironment.java
License:Open Source License
/** * Find the top-level types that are defined * in the current environment and whose simple name matches the given name. * * The types found are passed to one of the following methods (if additional * information is known about the types): * ISearchRequestor.acceptType(char[][] packageName, char[] typeName) * ISearchRequestor.acceptClass(char[][] packageName, char[] typeName, int modifiers) * ISearchRequestor.acceptInterface(char[][] packageName, char[] typeName, int modifiers) * * This method can not be used to find member types... member * types are found relative to their enclosing type. *//*from ww w. jav a 2s . c om*/ public void findExactTypes(char[] name, final boolean findMembers, int searchFor, final ISearchRequestor storage) { try { final String excludePath; if (this.unitToSkip != null) { if (!(this.unitToSkip instanceof IJavaElement)) { // revert to model investigation findExactTypes(new String(name), storage, convertSearchFilterToModelFilter(searchFor)); return; } excludePath = ((IJavaElement) this.unitToSkip).getPath().toString(); } else { excludePath = null; } IProgressMonitor progressMonitor = new IProgressMonitor() { boolean isCanceled = false; public void beginTask(String n, int totalWork) { // implements interface method } public void done() { // implements interface method } public void internalWorked(double work) { // implements interface method } public boolean isCanceled() { return this.isCanceled; } public void setCanceled(boolean value) { this.isCanceled = value; } public void setTaskName(String n) { // implements interface method } public void subTask(String n) { // implements interface method } public void worked(int work) { // implements interface method } }; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor() { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (excludePath != null && excludePath.equals(path)) return; if (!findMembers && enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types storage.acceptType(packageName, simpleTypeName, enclosingTypeNames, modifiers, access); } }; try { new BasicSearchEngine(project.getIndexManager(), project).searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, name, SearchPattern.R_EXACT_MATCH, searchFor, getSearchScope(), typeRequestor, CANCEL_IF_NOT_READY_TO_SEARCH, progressMonitor); } catch (OperationCanceledException e) { findExactTypes(new String(name), storage, convertSearchFilterToModelFilter(searchFor)); } } catch (JavaModelException e) { findExactTypes(new String(name), storage, convertSearchFilterToModelFilter(searchFor)); } }
From source file:com.codenvy.ide.ext.java.server.internal.core.SearchableEnvironment.java
License:Open Source License
/** * Must be used only by CompletionEngine. * The progress monitor is used to be able to cancel completion operations * * Find the top-level types that are defined * in the current environment and whose name starts with the * given prefix. The prefix is a qualified name separated by periods * or a simple name (ex. java.util.V or V). * * The types found are passed to one of the following methods (if additional * information is known about the types): * ISearchRequestor.acceptType(char[][] packageName, char[] typeName) * ISearchRequestor.acceptClass(char[][] packageName, char[] typeName, int modifiers) * ISearchRequestor.acceptInterface(char[][] packageName, char[] typeName, int modifiers) * * This method can not be used to find member types... member * types are found relative to their enclosing type. *//*from ww w .j av a 2s . co m*/ public void findTypes(char[] prefix, final boolean findMembers, boolean camelCaseMatch, int searchFor, final ISearchRequestor storage, IProgressMonitor monitor) { /* if (true){ findTypes(new String(prefix), storage, NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES); return; } */ try { final String excludePath; if (this.unitToSkip != null) { if (!(this.unitToSkip instanceof IJavaElement)) { // revert to model investigation findTypes(new String(prefix), storage, convertSearchFilterToModelFilter(searchFor)); return; } excludePath = ((IJavaElement) this.unitToSkip).getPath().toString(); } else { excludePath = null; } int lastDotIndex = CharOperation.lastIndexOf('.', prefix); char[] qualification, simpleName; if (lastDotIndex < 0) { qualification = null; if (camelCaseMatch) { simpleName = prefix; } else { simpleName = CharOperation.toLowerCase(prefix); } } else { qualification = CharOperation.subarray(prefix, 0, lastDotIndex); if (camelCaseMatch) { simpleName = CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length); } else { simpleName = CharOperation .toLowerCase(CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length)); } } IProgressMonitor progressMonitor = new IProgressMonitor() { boolean isCanceled = false; public void beginTask(String name, int totalWork) { // implements interface method } public void done() { // implements interface method } public void internalWorked(double work) { // implements interface method } public boolean isCanceled() { return this.isCanceled; } public void setCanceled(boolean value) { this.isCanceled = value; } public void setTaskName(String name) { // implements interface method } public void subTask(String name) { // implements interface method } public void worked(int work) { // implements interface method } }; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor() { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (excludePath != null && excludePath.equals(path)) return; if (!findMembers && enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types storage.acceptType(packageName, simpleTypeName, enclosingTypeNames, modifiers, access); } }; int matchRule = SearchPattern.R_PREFIX_MATCH; if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH; if (monitor != null) { IndexManager indexManager = project.getIndexManager(); if (indexManager.awaitingJobsCount() == 0) { // indexes were already there, so perform an immediate search to avoid any index rebuilt new BasicSearchEngine(project.getIndexManager(), project).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, FORCE_IMMEDIATE_SEARCH, progressMonitor); } else { // indexes were not ready, give the indexing a chance to finish small jobs by sleeping 100ms... try { Thread.sleep(100); } catch (InterruptedException e) { // Do nothing } if (monitor.isCanceled()) { throw new OperationCanceledException(); } if (indexManager.awaitingJobsCount() == 0) { // indexes are now ready, so perform an immediate search to avoid any index rebuilt new BasicSearchEngine(project.getIndexManager(), project).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, FORCE_IMMEDIATE_SEARCH, progressMonitor); } else { // Indexes are still not ready, so look for types in the model instead of a search request findTypes(new String(prefix), storage, convertSearchFilterToModelFilter(searchFor)); } } } else { try { new BasicSearchEngine(project.getIndexManager(), project).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, CANCEL_IF_NOT_READY_TO_SEARCH, progressMonitor); } catch (OperationCanceledException e) { findTypes(new String(prefix), storage, convertSearchFilterToModelFilter(searchFor)); } } } catch (JavaModelException e) { findTypes(new String(prefix), storage, convertSearchFilterToModelFilter(searchFor)); } }
From source file:org.eclipse.che.jdt.internal.core.search.matching.JavaSearchNameEnvironment.java
License:Open Source License
/** * Must be used only by CompletionEngine. * The progress monitor is used to be able to cancel completion operations * * Find the top-level types that are defined * in the current environment and whose name starts with the * given prefix. The prefix is a qualified name separated by periods * or a simple name (ex. java.util.V or V). * * The types found are passed to one of the following methods (if additional * information is known about the types): * ISearchRequestor.acceptType(char[][] packageName, char[] typeName) * ISearchRequestor.acceptClass(char[][] packageName, char[] typeName, int modifiers) * ISearchRequestor.acceptInterface(char[][] packageName, char[] typeName, int modifiers) * * This method can not be used to find member types... member * types are found relative to their enclosing type. */// w w w . j a va 2s . c o m public void findTypes(char[] prefix, final boolean findMembers, boolean camelCaseMatch, int searchFor, final ISearchRequestor storage, IProgressMonitor monitor) { try { int lastDotIndex = CharOperation.lastIndexOf('.', prefix); char[] qualification, simpleName; if (lastDotIndex < 0) { qualification = null; if (camelCaseMatch) { simpleName = prefix; } else { simpleName = CharOperation.toLowerCase(prefix); } } else { qualification = CharOperation.subarray(prefix, 0, lastDotIndex); if (camelCaseMatch) { simpleName = CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length); } else { simpleName = CharOperation .toLowerCase(CharOperation.subarray(prefix, lastDotIndex + 1, prefix.length)); } } IProgressMonitor progressMonitor = new IProgressMonitor() { boolean isCanceled = false; public void beginTask(String name, int totalWork) { // implements interface method } public void done() { // implements interface method } public void internalWorked(double work) { // implements interface method } public boolean isCanceled() { return this.isCanceled; } public void setCanceled(boolean value) { this.isCanceled = value; } public void setTaskName(String name) { // implements interface method } public void subTask(String name) { // implements interface method } public void worked(int work) { // implements interface method } }; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor() { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { // if (excludePath != null && excludePath.equals(path)) // return; if (!findMembers && enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types storage.acceptType(packageName, simpleTypeName, enclosingTypeNames, modifiers, access); } }; int matchRule = SearchPattern.R_PREFIX_MATCH; if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH; IndexManager indexManager = javaProject.getIndexManager(); if (monitor != null) { if (indexManager.awaitingJobsCount() == 0) { // indexes were already there, so perform an immediate search to avoid any index rebuilt new BasicSearchEngine(indexManager, javaProject).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, progressMonitor); } else { // indexes were not ready, give the indexing a chance to finish small jobs by sleeping 100ms... try { Thread.sleep(100); } catch (InterruptedException e) { // Do nothing } if (monitor.isCanceled()) { throw new OperationCanceledException(); } if (indexManager.awaitingJobsCount() == 0) { // indexes are now ready, so perform an immediate search to avoid any index rebuilt new BasicSearchEngine(indexManager, javaProject).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, progressMonitor); } //else { // Indexes are still not ready, so look for types in the model instead of a search request // findTypes( // new String(prefix), // storage, // convertSearchFilterToModelFilter(searchFor)); // } } } else { try { new BasicSearchEngine(indexManager, javaProject).searchAllTypeNames(qualification, SearchPattern.R_EXACT_MATCH, simpleName, matchRule, // not case sensitive searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, progressMonitor); } catch (OperationCanceledException e) { // findTypes( // new String(prefix), // storage, // convertSearchFilterToModelFilter(searchFor)); } } } catch (JavaModelException e) { // findTypes( // new String(prefix), // storage, // convertSearchFilterToModelFilter(searchFor)); } }
From source file:org.eclipse.che.jdt.internal.core.search.matching.JavaSearchNameEnvironment.java
License:Open Source License
/** * Find the top-level types that are defined * in the current environment and whose simple name matches the given name. * * The types found are passed to one of the following methods (if additional * information is known about the types): * ISearchRequestor.acceptType(char[][] packageName, char[] typeName) * ISearchRequestor.acceptClass(char[][] packageName, char[] typeName, int modifiers) * ISearchRequestor.acceptInterface(char[][] packageName, char[] typeName, int modifiers) * * This method can not be used to find member types... member * types are found relative to their enclosing type. *//*from w w w .jav a2 s .c o m*/ public void findExactTypes(char[] name, final boolean findMembers, int searchFor, final ISearchRequestor storage) { try { IProgressMonitor progressMonitor = new IProgressMonitor() { boolean isCanceled = false; public void beginTask(String n, int totalWork) { // implements interface method } public void done() { // implements interface method } public void internalWorked(double work) { // implements interface method } public boolean isCanceled() { return this.isCanceled; } public void setCanceled(boolean value) { this.isCanceled = value; } public void setTaskName(String n) { // implements interface method } public void subTask(String n) { // implements interface method } public void worked(int work) { // implements interface method } }; IRestrictedAccessTypeRequestor typeRequestor = new IRestrictedAccessTypeRequestor() { public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { if (!findMembers && enclosingTypeNames != null && enclosingTypeNames.length > 0) return; // accept only top level types storage.acceptType(packageName, simpleTypeName, enclosingTypeNames, modifiers, access); } }; try { new BasicSearchEngine(javaProject.getIndexManager(), javaProject).searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, name, SearchPattern.R_EXACT_MATCH, searchFor, getSearchScope(), typeRequestor, IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH, progressMonitor); } catch (OperationCanceledException e) { // findExactTypes( // new String(name), // storage, // convertSearchFilterToModelFilter(searchFor)); } } catch (JavaModelException e) { // findExactTypes( // new String(name), // storage, // convertSearchFilterToModelFilter(searchFor)); } }