use of org.eclipse.jdt.core.search.IJavaSearchScope in project che by eclipse.
the class IndexManager method cleanUpIndexes.
/*
* Removes unused indexes from disk.
*/
public void cleanUpIndexes() {
SimpleSet knownPaths = new SimpleSet();
IJavaSearchScope scope = BasicSearchEngine.createWorkspaceScope();
PatternSearchJob job = new PatternSearchJob(null, SearchEngine.getDefaultSearchParticipant(), scope, null);
Index[] selectedIndexes = job.getIndexes(null);
for (int i = 0, l = selectedIndexes.length; i < l; i++) {
IndexLocation IndexLocation = selectedIndexes[i].getIndexLocation();
knownPaths.add(IndexLocation);
}
if (this.indexStates != null) {
Object[] keys = this.indexStates.keyTable;
IndexLocation[] locations = new IndexLocation[this.indexStates.elementSize];
int count = 0;
for (int i = 0, l = keys.length; i < l; i++) {
IndexLocation key = (IndexLocation) keys[i];
if (key != null && !knownPaths.includes(key))
locations[count++] = key;
}
if (count > 0)
removeIndexesState(locations);
}
deleteIndexFiles(knownPaths);
}
use of org.eclipse.jdt.core.search.IJavaSearchScope in project che by eclipse.
the class IntroduceIndirectionRefactoring method getReferences.
private SearchResultGroup[] getReferences(IMethod[] methods, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
SearchPattern pattern = RefactoringSearchEngine.createOrPattern(methods, IJavaSearchConstants.REFERENCES);
IJavaSearchScope scope = RefactoringScopeFactory.create(fIntermediaryType, false);
return RefactoringSearchEngine.search(pattern, scope, pm, status);
}
use of org.eclipse.jdt.core.search.IJavaSearchScope in project che by eclipse.
the class CreateCopyOfCompilationUnitChange method getReferences.
private static SearchResultGroup getReferences(final ICompilationUnit copy, IProgressMonitor monitor) throws JavaModelException {
final ICompilationUnit[] copies = new ICompilationUnit[] { copy };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(copies);
final IType type = copy.findPrimaryType();
if (type == null)
return null;
SearchPattern pattern = createSearchPattern(type);
final RefactoringSearchEngine2 engine = new RefactoringSearchEngine2(pattern);
engine.setScope(scope);
engine.setWorkingCopies(copies);
engine.setRequestor(new IRefactoringSearchRequestor() {
TypeOccurrenceCollector fTypeOccurrenceCollector = new TypeOccurrenceCollector(type);
public SearchMatch acceptSearchMatch(SearchMatch match) {
try {
return fTypeOccurrenceCollector.acceptSearchMatch2(copy, match);
} catch (CoreException e) {
JavaPlugin.log(e);
return null;
}
}
});
engine.searchPattern(monitor);
final Object[] results = engine.getResults();
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106127)
for (int index = 0; index < results.length; index++) {
SearchResultGroup group = (SearchResultGroup) results[index];
if (group.getCompilationUnit().equals(copy))
return group;
}
return null;
}
use of org.eclipse.jdt.core.search.IJavaSearchScope in project bndtools by bndtools.
the class ExportPatternsListPart method selectPackagesToAdd.
protected List<ExportedPackage> selectPackagesToAdd() {
List<ExportedPackage> added = null;
final IPackageFilter filter = new IPackageFilter() {
@Override
public boolean select(String packageName) {
if (packageName.equals("java") || packageName.startsWith("java."))
return false;
return true;
}
};
IFormPage page = (IFormPage) getManagedForm().getContainer();
IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();
// Prepare the package lister from the Java project
IProject project = ResourceUtil.getResource(page.getEditorInput()).getProject();
IJavaProject javaProject = JavaCore.create(project);
IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
JavaSearchScopePackageLister packageLister = new JavaSearchScopePackageLister(searchScope, window);
// Create and open the dialog
PackageSelectionDialog dialog = new PackageSelectionDialog(window.getShell(), packageLister, filter, "Select new packages to export from the bundle.");
dialog.setSourceOnly(true);
dialog.setMultipleSelection(true);
if (dialog.open() == Window.OK) {
Object[] results = dialog.getResult();
added = new LinkedList<ExportedPackage>();
// Select the results
for (Object result : results) {
String newPackageName = (String) result;
ExportedPackage newPackage = new ExportedPackage(newPackageName, new Attrs());
added.add(newPackage);
}
}
return added;
}
use of org.eclipse.jdt.core.search.IJavaSearchScope in project bndtools by bndtools.
the class NewTypeWizardPage method chooseSuperClass.
/**
* Opens a selection dialog that allows to select a super class.
*
* @return returns the selected type or <code>null</code> if the dialog has been canceled. The caller typically sets
* the result to the super class input field.
* <p>
* Clients can override this method if they want to offer a different dialog.
* </p>
* @since 3.2
*/
protected IType chooseSuperClass() {
IJavaProject project = getJavaProject();
if (project == null) {
return null;
}
IJavaElement[] elements = new IJavaElement[] { project };
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(getShell(), false, getWizard().getContainer(), scope, IJavaSearchConstants.CLASS);
dialog.setTitle(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_title);
dialog.setMessage(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_message);
dialog.setInitialPattern(getSuperClass());
if (dialog.open() == Window.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
Aggregations