mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Added search for unresolved includes, bug 213561.
This commit is contained in:
parent
6c826b3842
commit
b6d7d0cd9c
26 changed files with 448 additions and 105 deletions
|
@ -118,4 +118,7 @@ public class EmptyIndexFragment implements IIndexFragment {
|
|||
public IIndexFragmentFileSet createFileSet() {
|
||||
return null;
|
||||
}
|
||||
public IIndexFragmentFile[] getAllFiles() {
|
||||
return IIndexFragmentFile.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2008 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
|
||||
|
@ -9,7 +9,6 @@
|
|||
* Rational Software - initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
||||
|
@ -44,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
|
||||
|
||||
/**
|
||||
* This is a utility class to help convert AST elements to Strings corresponding
|
||||
|
@ -1079,4 +1079,10 @@ public class ASTSignatureUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the same message as {@link IASTProblem#getMessageWithoutLocation()}.
|
||||
*/
|
||||
public static String getProblemMessage(int problemID, String detail) {
|
||||
return ASTProblem.getMessageWithoutLocation(problemID, detail);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Andrew Ferguson (Symbian)
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.index;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -363,4 +362,10 @@ public interface IIndex {
|
|||
* Creates a file-set that can be used with this index as long as you hold a read-lock.
|
||||
*/
|
||||
public IIndexFileSet createFileSet();
|
||||
|
||||
/**
|
||||
* Returns an array of all files that are part of this index. If a file is parsed in two
|
||||
* linkages, or in multiple fragments only one of the files will be returned.
|
||||
*/
|
||||
public IIndexFile[] getAllFiles() throws CoreException;
|
||||
}
|
||||
|
|
|
@ -78,16 +78,20 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
|||
return ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||
}
|
||||
|
||||
public String getMessageWithoutLocation() {
|
||||
public static String getMessageWithoutLocation(int id, String arg) {
|
||||
String msg = errorMessages.get(new Integer(id));
|
||||
if (msg == null)
|
||||
msg = ""; //$NON-NLS-1$
|
||||
|
||||
if (arg != null) {
|
||||
return MessageFormat.format(msg, new Object[] { new String(arg) });
|
||||
return MessageFormat.format(msg, arg);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
public String getMessageWithoutLocation() {
|
||||
return getMessageWithoutLocation(id, arg == null ? null : new String(arg));
|
||||
}
|
||||
|
||||
public boolean checkCategory(int bitmask) {
|
||||
return ((id & bitmask) != 0);
|
||||
|
|
|
@ -476,9 +476,11 @@ public class CIndex implements IIndex {
|
|||
|
||||
private IndexFilter retargetFilter(final ILinkage linkage, final IndexFilter filter) {
|
||||
return new IndexFilter() {
|
||||
@Override
|
||||
public boolean acceptBinding(IBinding binding) throws CoreException {
|
||||
return filter.acceptBinding(binding);
|
||||
}
|
||||
@Override
|
||||
public boolean acceptLinkage(ILinkage other) {
|
||||
return linkage.getLinkageID() == other.getLinkageID();
|
||||
}
|
||||
|
@ -586,4 +588,14 @@ public class CIndex implements IIndex {
|
|||
public IIndexFileSet createFileSet() {
|
||||
return new IndexFileSet();
|
||||
}
|
||||
|
||||
public IIndexFile[] getAllFiles() throws CoreException {
|
||||
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<IIndexFileLocation, IIndexFile>();
|
||||
for (IIndexFragment ifrag : fFragments) {
|
||||
for (IIndexFragmentFile iff : ifrag.getAllFiles()) {
|
||||
result.put(iff.getLocation(), iff);
|
||||
}
|
||||
}
|
||||
return result.values().toArray(new IIndexFile[result.size()]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,4 +130,8 @@ final public class EmptyCIndex implements IIndex {
|
|||
public IIndexFileSet createFileSet() {
|
||||
return new IndexFileSet();
|
||||
}
|
||||
|
||||
public IIndexFile[] getAllFiles() {
|
||||
return IIndexFile.EMPTY_FILE_ARRAY;
|
||||
}
|
||||
}
|
|
@ -232,4 +232,9 @@ public interface IIndexFragment {
|
|||
* @since 5.0
|
||||
*/
|
||||
IIndexFragmentFileSet createFileSet();
|
||||
|
||||
/**
|
||||
* @return an array of all files contained in this index.
|
||||
*/
|
||||
IIndexFragmentFile[] getAllFiles() throws CoreException;
|
||||
}
|
||||
|
|
|
@ -223,4 +223,10 @@ public class PDOMProxy implements IPDOM {
|
|||
public IIndexFragmentFileSet createFileSet() {
|
||||
return new PDOMFileSet();
|
||||
}
|
||||
|
||||
public synchronized IIndexFragmentFile[] getAllFiles() throws CoreException {
|
||||
if (fDelegate != null)
|
||||
return fDelegate.getAllFiles();
|
||||
return IIndexFragmentFile.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,6 +379,7 @@ IndexView.name=C/C++ Index
|
|||
RebuildIndex.name=&Rebuild
|
||||
SyncIndex.name=&Update with Modified Files
|
||||
FreshenIndex.name=&Freshen All Files
|
||||
SearchUnresolvedIncludes.name=Search for Unresolved &Includes
|
||||
|
||||
indexerPage.name = Indexer Page
|
||||
proposalFilter.name = Code Completion Proposal Filter
|
||||
|
|
|
@ -823,6 +823,7 @@
|
|||
path="buildGroup">
|
||||
<groupMarker name="rebuild"/>
|
||||
<separator name="update"/>
|
||||
<separator name="search"/>
|
||||
</menu>
|
||||
</objectContribution>
|
||||
<objectContribution
|
||||
|
@ -833,12 +834,18 @@
|
|||
id="org.eclipse.cdt.ui.rebuildIndexAction"
|
||||
label="%RebuildIndex.name"
|
||||
menubarPath="org.eclipse.cdt.ui.indexmenu/rebuild"/>
|
||||
<action
|
||||
class="org.eclipse.cdt.internal.ui.search.actions.FindUnresolvedIncludesProjectAction"
|
||||
id="org.eclipse.cdt.ui.searchUnresolvedIncludes"
|
||||
label="%SearchUnresolvedIncludes.name"
|
||||
menubarPath="org.eclipse.cdt.ui.indexmenu/search"/>
|
||||
<menu
|
||||
id="org.eclipse.cdt.ui.indexmenu"
|
||||
label="%Index.menu"
|
||||
path="buildGroup">
|
||||
<groupMarker name="rebuild"/>
|
||||
<separator name="update"/>
|
||||
<separator name="search"/>
|
||||
</menu>
|
||||
</objectContribution>
|
||||
<!-- project explorer shows IProjects, we need to handle this -->
|
||||
|
@ -865,12 +872,18 @@
|
|||
id="org.eclipse.cdt.ui.rebuildIndexAction"
|
||||
label="%RebuildIndex.name"
|
||||
menubarPath="org.eclipse.cdt.ui.indexmenu/rebuild"/>
|
||||
<action
|
||||
class="org.eclipse.cdt.internal.ui.search.actions.FindUnresolvedIncludesProjectAction"
|
||||
id="org.eclipse.cdt.ui.searchUnresolvedIncludes"
|
||||
label="%SearchUnresolvedIncludes.name"
|
||||
menubarPath="org.eclipse.cdt.ui.indexmenu/search"/>
|
||||
<menu
|
||||
id="org.eclipse.cdt.ui.indexmenu"
|
||||
label="%Index.menu"
|
||||
path="buildGroup">
|
||||
<groupMarker name="rebuild"/>
|
||||
<separator name="update"/>
|
||||
<separator name="search"/>
|
||||
</menu>
|
||||
</objectContribution>
|
||||
<objectContribution
|
||||
|
|
|
@ -90,6 +90,7 @@ public final class CSearchMessages extends NLS {
|
|||
public static String CSearchMessages_IndexRunningIncompleteWarning;
|
||||
public static String PDOMSearchTreeContentProvider_IndexerNotEnabledWarning;
|
||||
public static String PDOMSearchTreeContentProvider_ProjectClosedWarning;
|
||||
public static String PDOMSearchUnresolvedIncludesQuery_title;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(BUNDLE_NAME, CSearchMessages.class);
|
||||
|
|
|
@ -82,6 +82,7 @@ PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat=(project ''{0}'' -
|
|||
PDOMSearchListContentProvider_ProjectClosedMessageFormat=(project ''{0}'' - unknown results: project is closed)
|
||||
CSearchMessages_IndexRunningIncompleteWarning=(incomplete or inaccurate results: indexer was busy during search)
|
||||
PDOMSearch_query_pattern_error = Illegal Search String
|
||||
PDOMSearchUnresolvedIncludesQuery_title=Unresolved inclusions in {0}
|
||||
SelectionParseAction_FileOpenFailure_format=Could not open file ''{0}'', verify index is up-to-date
|
||||
SelectionParseAction_SelectedTextNotSymbol_message=Selected text cannot be mapped to a symbol name
|
||||
SelectionParseAction_SymbolNotFoundInIndex_format=Could not find symbol ''{0}'' in index
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 QNX Software Systems 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
|
||||
|
@ -9,21 +9,14 @@
|
|||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.IndexTypeInfo;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
|
||||
/**
|
||||
* Element class used to group matches.
|
||||
|
@ -32,37 +25,30 @@ import org.eclipse.cdt.core.index.IIndexName;
|
|||
*/
|
||||
public class PDOMSearchElement implements IAdaptable {
|
||||
|
||||
private final ITypeInfo typeInfo;
|
||||
private final IIndexFileLocation location;
|
||||
|
||||
public PDOMSearchElement(IIndex index, IIndexName name, IIndexBinding binding) throws CoreException {
|
||||
this.typeInfo= IndexTypeInfo.create(index, binding);
|
||||
this.location= name.getFile().getLocation();
|
||||
public PDOMSearchElement(IIndexFileLocation loc) {
|
||||
this.location= loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (typeInfo.getCElementType() *31 + typeInfo.getName().hashCode())*31 + location.hashCode();
|
||||
return location.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PDOMSearchElement))
|
||||
return false;
|
||||
if (this == obj)
|
||||
return true;
|
||||
PDOMSearchElement other = (PDOMSearchElement)obj;
|
||||
return typeInfo.getCElementType() == other.typeInfo.getCElementType()
|
||||
&& typeInfo.getName().equals(other.typeInfo.getName())
|
||||
&& location.equals(other.location);
|
||||
return location.equals(other.location);
|
||||
}
|
||||
|
||||
public ITypeInfo getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
|
||||
IIndexFileLocation getLocation() {
|
||||
final IIndexFileLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapterType) {
|
||||
if (adapterType.isAssignableFrom(IFile.class)) {
|
||||
String fullPath= location.getFullPath();
|
||||
|
@ -72,5 +58,4 @@ public class PDOMSearchElement implements IAdaptable {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. 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
|
||||
|
@ -9,7 +9,6 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -22,6 +21,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil;
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||
|
@ -55,10 +55,15 @@ public class PDOMSearchLabelProvider extends LabelProvider {
|
|||
fPage= page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof PDOMSearchElement)
|
||||
return fTypeInfoLabelProvider.getImage(((PDOMSearchElement)element).getTypeInfo());
|
||||
if (element instanceof TypeInfoSearchElement)
|
||||
return fTypeInfoLabelProvider.getImage(((TypeInfoSearchElement)element).getTypeInfo());
|
||||
|
||||
if (element instanceof ProblemSearchElement) {
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
|
||||
}
|
||||
|
||||
if (element instanceof IIndexFileLocation
|
||||
|| element instanceof URI) {
|
||||
return CPluginImages.get(CPluginImages.IMG_OBJS_INCLUDE);
|
||||
|
@ -89,9 +94,14 @@ public class PDOMSearchLabelProvider extends LabelProvider {
|
|||
return fCElementLabelProvider.getImage(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof PDOMSearchElement) {
|
||||
return fTypeInfoLabelProvider.getText(((PDOMSearchElement)element).getTypeInfo());
|
||||
if (element instanceof TypeInfoSearchElement) {
|
||||
return fTypeInfoLabelProvider.getText(((TypeInfoSearchElement)element).getTypeInfo());
|
||||
}
|
||||
else if (element instanceof ProblemSearchElement) {
|
||||
ProblemSearchElement pse= (ProblemSearchElement) element;
|
||||
return ASTSignatureUtil.getProblemMessage(pse.getProblemID(), pse.getDetail());
|
||||
}
|
||||
|
||||
if (element instanceof IPath) {
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
@ -31,13 +30,17 @@ public class PDOMSearchListLabelProvider extends PDOMSearchLabelProvider {
|
|||
super(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
final String text= super.getText(element);
|
||||
|
||||
if (element instanceof PDOMSearchElement) {
|
||||
PDOMSearchElement searchElement = (PDOMSearchElement)element;
|
||||
final int count= getMatchCount(element);
|
||||
final String filename = " - " + IndexLocationFactory.getPath(searchElement.getLocation()); //$NON-NLS-1$
|
||||
final String filename = " - " + IndexLocationFactory.getPath(searchElement.getLocation()); //$NON-NLS-1$
|
||||
if (count == 1) {
|
||||
return text+filename;
|
||||
}
|
||||
return text + filename + " " //$NON-NLS-1$
|
||||
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
||||
}
|
||||
|
|
|
@ -1,39 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 QNX Software Systems 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:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.search.ui.text.Match;
|
||||
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* Base class for search matches found by various index searches.
|
||||
*/
|
||||
public class PDOMSearchMatch extends Match {
|
||||
|
||||
public PDOMSearchMatch(IIndex index, IIndexBinding binding, IIndexName name, int offset, int length) throws CoreException {
|
||||
super(new PDOMSearchElement(index, name, binding), offset, length);
|
||||
public PDOMSearchMatch(PDOMSearchElement elem, int offset, int length) {
|
||||
super(elem, offset, length);
|
||||
}
|
||||
|
||||
IIndexFileLocation getLocation() {
|
||||
return ((PDOMSearchElement)getElement()).getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
@ -44,5 +39,4 @@ public class PDOMSearchMatch extends Match {
|
|||
&& getOffset() == other.getOffset()
|
||||
&& getLength() == other.getLength();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -72,7 +71,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
|
||||
projects = (ICProject[]) ArrayUtil.removeNulls(ICProject.class, allProjects);
|
||||
} else {
|
||||
Map projectMap = new HashMap();
|
||||
Map<String, ICProject> projectMap = new HashMap<String, ICProject>();
|
||||
|
||||
for (int i = 0; i < scope.length; ++i) {
|
||||
ICProject project = scope[i].getCProject();
|
||||
|
@ -80,7 +79,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
projectMap.put(project.getElementName(), project);
|
||||
}
|
||||
|
||||
projects = (ICProject[])projectMap.values().toArray(new ICProject[projectMap.size()]);
|
||||
projects = projectMap.values().toArray(new ICProject[projectMap.size()]);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
|
@ -126,7 +125,9 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
if (!filterName(name)) {
|
||||
IASTFileLocation loc = name.getFileLocation();
|
||||
IIndexBinding binding= index.findBinding(name);
|
||||
result.addMatch(new PDOMSearchMatch(index, binding, name, loc.getNodeOffset(), loc.getNodeLength()));
|
||||
result.addMatch(new PDOMSearchMatch(
|
||||
new TypeInfoSearchElement(index, name, binding),
|
||||
loc.getNodeOffset(), loc.getNodeLength()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,4 +172,27 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
public ICProject[] getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public String getScopeDescription() {
|
||||
StringBuilder buf= new StringBuilder();
|
||||
switch (scope.length) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
buf.append(scope[0].getElementName());
|
||||
break;
|
||||
case 2:
|
||||
buf.append(scope[0].getElementName());
|
||||
buf.append(", "); //$NON-NLS-1$
|
||||
buf.append(scope[1].getElementName());
|
||||
break;
|
||||
default:
|
||||
buf.append(scope[0].getElementName());
|
||||
buf.append(", "); //$NON-NLS-1$
|
||||
buf.append(scope[1].getElementName());
|
||||
buf.append(", ..."); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 QNX Software Systems 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:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -57,10 +56,12 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
|||
this.query = query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEditorMatchAdapter getEditorMatchAdapter() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFileMatchAdapter getFileMatchAdapter() {
|
||||
return this;
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
|||
|
||||
private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
|
||||
IPath pfilename= new Path(filename);
|
||||
List list = new ArrayList();
|
||||
List<Match> list = new ArrayList<Match>();
|
||||
Object[] elements = result.getElements();
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((PDOMSearchElement)elements[i]).getLocation()))) {
|
||||
|
@ -117,7 +118,7 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
|||
}
|
||||
}
|
||||
}
|
||||
return (Match[])list.toArray(new Match[list.size()]);
|
||||
return list.toArray(new Match[list.size()]);
|
||||
}
|
||||
|
||||
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
|
||||
|
@ -157,7 +158,7 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
|||
public String getLabel() {
|
||||
// report pattern and number of matches
|
||||
String label = query.getLabel();
|
||||
String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(getElements().length));
|
||||
String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(getMatchCount()));
|
||||
return label + " " + countLabel; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -47,10 +46,10 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
|
||||
private TreeViewer viewer;
|
||||
private PDOMSearchResult result;
|
||||
private Map tree = new HashMap();
|
||||
private Map<Object, Set<Object>> tree = new HashMap<Object, Set<Object>>();
|
||||
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
Set children = (Set)tree.get(parentElement);
|
||||
Set children = tree.get(parentElement);
|
||||
if (children == null)
|
||||
return new Object[0];
|
||||
return children.toArray();
|
||||
|
@ -60,7 +59,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
Iterator p = tree.keySet().iterator();
|
||||
while (p.hasNext()) {
|
||||
Object parent = p.next();
|
||||
Set children = (Set)tree.get(parent);
|
||||
Set children = tree.get(parent);
|
||||
if (children.contains(element))
|
||||
return parent;
|
||||
}
|
||||
|
@ -108,9 +107,9 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
}
|
||||
|
||||
private boolean insertChild(Object parent, Object child) {
|
||||
Set children = (Set)tree.get(parent);
|
||||
Set<Object> children = tree.get(parent);
|
||||
if (children == null) {
|
||||
children = new HashSet();
|
||||
children = new HashSet<Object>();
|
||||
tree.put(parent, children);
|
||||
}
|
||||
return children.add(child);
|
||||
|
@ -189,7 +188,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
}
|
||||
|
||||
private boolean addProjectWarningIfApplicable(ICProject cProject) {
|
||||
if (cProject.isOpen()) {
|
||||
if (cProject.getProject().isOpen()) {
|
||||
if (!CCorePlugin.getIndexManager().isProjectIndexed(cProject)) {
|
||||
insertUnindexedProjectWarningElement(cProject);
|
||||
return true;
|
||||
|
@ -237,7 +236,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
// reached the search result
|
||||
return;
|
||||
|
||||
Set siblings = (Set)tree.get(parent);
|
||||
Set siblings = tree.get(parent);
|
||||
siblings.remove(element);
|
||||
|
||||
if (siblings.isEmpty()) {
|
||||
|
@ -246,5 +245,4 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
tree.remove(parent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
||||
|
@ -27,14 +26,14 @@ public class PDOMSearchTreeLabelProvider extends PDOMSearchLabelProvider {
|
|||
super(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
final String text= super.getText(element);
|
||||
final int count= getMatchCount(element);
|
||||
if (count == 0) {
|
||||
if (count <= 1) {
|
||||
return text;
|
||||
}
|
||||
return text + " " //$NON-NLS-1$
|
||||
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
|
||||
/**
|
||||
* Query for searching unresolved includes in projects.
|
||||
* Could be extended to search resources selections.
|
||||
*/
|
||||
public class PDOMSearchUnresolvedIncludesQuery extends PDOMSearchQuery {
|
||||
|
||||
public PDOMSearchUnresolvedIncludesQuery(ICElement[] scope) {
|
||||
super(scope, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
|
||||
try {
|
||||
for (IIndexFile file : index.getAllFiles()) {
|
||||
for (IIndexInclude include : file.getIncludes()) {
|
||||
if (include.isActive() && !include.isResolved()) {
|
||||
result.addMatch(new PDOMSearchMatch(new ProblemSearchElement(
|
||||
IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, include.getName(),
|
||||
include.getIncludedByLocation()),
|
||||
include.getNameOffset(), include.getNameLength()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return NLS.bind(CSearchMessages.PDOMSearchUnresolvedIncludesQuery_title, getScopeDescription());
|
||||
}
|
||||
}
|
|
@ -1,15 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 QNX Software Systems 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:
|
||||
* QNX - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
* QNX - Initial API and implementation
|
||||
* Ed Swartz (Nokia)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -35,8 +34,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* Implementation of the search view page for index based searches.
|
||||
*/
|
||||
public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||
|
||||
|
@ -50,11 +48,13 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementsChanged(Object[] objects) {
|
||||
if (contentProvider != null)
|
||||
contentProvider.elementsChanged(objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clear() {
|
||||
if (contentProvider != null)
|
||||
contentProvider.clear();
|
||||
|
@ -84,6 +84,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int category(Object element) {
|
||||
// place status messages first
|
||||
if (element instanceof IStatus) {
|
||||
|
@ -91,8 +92,8 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
}
|
||||
|
||||
// keep elements of the same type together
|
||||
if (element instanceof PDOMSearchElement) {
|
||||
PDOMSearchElement searchElement = (PDOMSearchElement)element;
|
||||
if (element instanceof TypeInfoSearchElement) {
|
||||
TypeInfoSearchElement searchElement = (TypeInfoSearchElement)element;
|
||||
int type = searchElement.getTypeInfo().getCElementType();
|
||||
// handle unknown types
|
||||
if (type < 0) {
|
||||
|
@ -122,6 +123,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureTreeViewer(TreeViewer viewer) {
|
||||
contentProvider = new PDOMSearchTreeContentProvider();
|
||||
viewer.setComparator(new SearchViewerComparator());
|
||||
|
@ -129,6 +131,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
viewer.setLabelProvider(new PDOMSearchTreeLabelProvider(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureTableViewer(TableViewer viewer) {
|
||||
contentProvider = new PDOMSearchListContentProvider();
|
||||
viewer.setComparator(new SearchViewerComparator());
|
||||
|
@ -136,6 +139,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
viewer.setLabelProvider(new PDOMSearchListLabelProvider(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
|
||||
if (!(match instanceof PDOMSearchMatch))
|
||||
return;
|
||||
|
@ -154,6 +158,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StructuredViewer getViewer() {
|
||||
return super.getViewer();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
|
||||
/**
|
||||
* Represents a problem in a search.
|
||||
*/
|
||||
public class ProblemSearchElement extends PDOMSearchElement {
|
||||
|
||||
private final int fProblemID;
|
||||
private final String fDetail;
|
||||
|
||||
public ProblemSearchElement(int problemID, String detail, IIndexFileLocation floc) {
|
||||
super(floc);
|
||||
fProblemID= problemID;
|
||||
fDetail= detail;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((fDetail == null) ? 0 : fDetail.hashCode());
|
||||
result = prime * result + fProblemID;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ProblemSearchElement other = (ProblemSearchElement) obj;
|
||||
if (fDetail == null) {
|
||||
if (other.fDetail != null)
|
||||
return false;
|
||||
} else if (!fDetail.equals(other.fDetail))
|
||||
return false;
|
||||
if (fProblemID != other.fProblemID)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public final int getProblemID() {
|
||||
return fProblemID;
|
||||
}
|
||||
|
||||
public final String getDetail() {
|
||||
return fDetail;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.IndexTypeInfo;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexName;
|
||||
|
||||
/**
|
||||
* Represents a a c/c++-entity in a search.
|
||||
*/
|
||||
public class TypeInfoSearchElement extends PDOMSearchElement {
|
||||
private final ITypeInfo typeInfo;
|
||||
|
||||
public TypeInfoSearchElement(IIndex index, IIndexName name, IIndexBinding binding) throws CoreException {
|
||||
super(name.getFile().getLocation());
|
||||
this.typeInfo= IndexTypeInfo.create(index, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + (typeInfo.getCElementType() *31 + typeInfo.getName().hashCode())*31;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof TypeInfoSearchElement))
|
||||
return false;
|
||||
TypeInfoSearchElement other= (TypeInfoSearchElement)obj;
|
||||
return typeInfo.getCElementType() == other.typeInfo.getCElementType() &&
|
||||
typeInfo.getName().equals(other.typeInfo.getName()) &&
|
||||
super.equals(other);
|
||||
}
|
||||
|
||||
public final ITypeInfo getTypeInfo() {
|
||||
return typeInfo;
|
||||
}
|
||||
}
|
|
@ -8,16 +8,8 @@
|
|||
* Contributors:
|
||||
* IBM Corp. - Rational Software - initial implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search.actions;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.PDOMSearchElementQuery;
|
||||
import org.eclipse.cdt.internal.ui.search.PDOMSearchTextSelectionQuery;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
@ -25,6 +17,16 @@ import org.eclipse.search.ui.ISearchQuery;
|
|||
import org.eclipse.search.ui.NewSearchUI;
|
||||
import org.eclipse.ui.IWorkbenchSite;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.PDOMSearchElementQuery;
|
||||
import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
|
||||
import org.eclipse.cdt.internal.ui.search.PDOMSearchTextSelectionQuery;
|
||||
|
||||
|
||||
public abstract class FindAction extends SelectionParseAction {
|
||||
public FindAction(CEditor editor){
|
||||
|
@ -35,6 +37,7 @@ public abstract class FindAction extends SelectionParseAction {
|
|||
super( site );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ISearchQuery searchJob = null;
|
||||
|
||||
|
@ -42,18 +45,14 @@ public abstract class FindAction extends SelectionParseAction {
|
|||
if (selection instanceof IStructuredSelection) {
|
||||
Object object = ((IStructuredSelection)selection).getFirstElement();
|
||||
if (object instanceof ISourceReference)
|
||||
searchJob = new PDOMSearchElementQuery(getScope(), (ISourceReference)object, getLimitTo());
|
||||
searchJob = createQuery((ISourceReference) object);
|
||||
} else if (selection instanceof ITextSelection) {
|
||||
ITextSelection selNode = getSelection((ITextSelection)selection);
|
||||
ICElement element = fEditor.getInputCElement();
|
||||
while (element != null && !(element instanceof ITranslationUnit))
|
||||
element = element.getParent();
|
||||
if (element != null) {
|
||||
searchJob = new PDOMSearchTextSelectionQuery(
|
||||
getScope(),
|
||||
(ITranslationUnit)element,
|
||||
selNode,
|
||||
getLimitTo());
|
||||
searchJob = createQuery(element, selNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,6 +67,15 @@ public abstract class FindAction extends SelectionParseAction {
|
|||
|
||||
NewSearchUI.runQueryInBackground(searchJob);
|
||||
}
|
||||
|
||||
protected PDOMSearchQuery createQuery(ISourceReference object) {
|
||||
return new PDOMSearchElementQuery(getScope(), object, getLimitTo());
|
||||
}
|
||||
|
||||
protected PDOMSearchQuery createQuery(ICElement element, ITextSelection selNode) {
|
||||
return new PDOMSearchTextSelectionQuery(getScope(),
|
||||
(ITranslationUnit)element, selNode, getLimitTo());
|
||||
}
|
||||
|
||||
abstract protected String getScopeDescription();
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.search.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.search.ui.ISearchQuery;
|
||||
import org.eclipse.search.ui.NewSearchUI;
|
||||
import org.eclipse.ui.IObjectActionDelegate;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchSite;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||
import org.eclipse.cdt.internal.ui.search.PDOMSearchUnresolvedIncludesQuery;
|
||||
import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
|
||||
|
||||
/**
|
||||
* Searches projects for unresolved includes.
|
||||
* Could be extended to work on resource selections.
|
||||
*/
|
||||
public class FindUnresolvedIncludesProjectAction implements IObjectActionDelegate {
|
||||
|
||||
private ISelection fSelection;
|
||||
private IWorkbenchSite fSite;
|
||||
|
||||
public FindUnresolvedIncludesProjectAction() {
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
List<ICProject> projects= new ArrayList<ICProject>();
|
||||
IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
|
||||
for (Iterator i = cElements.iterator(); i.hasNext();) {
|
||||
Object elem = i.next();
|
||||
if (elem instanceof ICProject) {
|
||||
projects.add((ICProject) elem);
|
||||
}
|
||||
}
|
||||
|
||||
if (projects.isEmpty()) {
|
||||
StatusLineHandler.showStatusLineMessage(fSite, CSearchMessages.CSearchOperation_operationUnavailable_message);
|
||||
return;
|
||||
}
|
||||
|
||||
ISearchQuery searchJob= new PDOMSearchUnresolvedIncludesQuery(projects.toArray(new ICProject[projects.size()]));
|
||||
|
||||
StatusLineHandler.clearStatusLine(fSite);
|
||||
NewSearchUI.activateSearchResultView();
|
||||
NewSearchUI.runQueryInBackground(searchJob);
|
||||
}
|
||||
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||
fSite= targetPart.getSite();
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
fSelection= selection;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue