| /******************************************************************************* |
| * Copyright (c) 2006 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.core.tools.search; |
| |
| import org.eclipse.core.runtime.*; |
| import org.eclipse.jdt.core.ICompilationUnit; |
| import org.eclipse.search.ui.ISearchQuery; |
| import org.eclipse.search.ui.ISearchResult; |
| |
| /** |
| * |
| */ |
| public class FindUnusedSearchQuery implements ISearchQuery { |
| |
| private final ICompilationUnit[] fCus; |
| private FindUnusedSearchResult fSearchResult; |
| |
| public FindUnusedSearchQuery(ICompilationUnit[] cus) { |
| fCus = cus; |
| fSearchResult = new FindUnusedSearchResult(this); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.search.ui.ISearchQuery#canRerun() |
| */ |
| @Override |
| public boolean canRerun() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground() |
| */ |
| @Override |
| public boolean canRunInBackground() { |
| return true; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.search.ui.ISearchQuery#getLabel() |
| */ |
| @Override |
| public String getLabel() { |
| return "Find Unreferenced Members"; //$NON-NLS-1$ |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.search.ui.ISearchQuery#getSearchResult() |
| */ |
| @Override |
| public ISearchResult getSearchResult() { |
| return fSearchResult; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor) |
| */ |
| @Override |
| public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { |
| fSearchResult.removeAll(); |
| |
| FindUnusedMembers search = new FindUnusedMembers(fCus, fSearchResult); |
| try { |
| search.process(monitor); |
| } catch (CoreException e) { |
| return e.getStatus(); |
| } |
| return Status.OK_STATUS; |
| } |
| |
| } |