Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-02-20 10:17:23 +0000
committerMarkus Schorn2008-02-20 10:17:23 +0000
commitb6d7d0cd9ce53a5916d7a06eefa0787043065e48 (patch)
treec5c199b0bd5777ee71d90f2e450ba672036f41e3
parent6c826b38420a8b645fa4aabecb80ac56f149c0ca (diff)
downloadorg.eclipse.cdt-b6d7d0cd9ce53a5916d7a06eefa0787043065e48.tar.gz
org.eclipse.cdt-b6d7d0cd9ce53a5916d7a06eefa0787043065e48.tar.xz
org.eclipse.cdt-b6d7d0cd9ce53a5916d7a06eefa0787043065e48.zip
Added search for unresolved includes, bug 213561.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java6
-rw-r--r--core/org.eclipse.cdt.ui/plugin.properties1
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java38
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java17
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java58
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java70
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java34
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java74
26 files changed, 447 insertions, 104 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java
index 6068dacdeb7..d7a9ac2480b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/EmptyIndexFragment.java
@@ -118,4 +118,7 @@ public class EmptyIndexFragment implements IIndexFragment {
public IIndexFragmentFileSet createFileSet() {
return null;
}
+ public IIndexFragmentFile[] getAllFiles() {
+ return IIndexFragmentFile.EMPTY_ARRAY;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
index ce498984c27..9c04705405d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
@@ -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);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java
index 01997cbac61..9ec6ba390c2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java
index aec81fade78..f8a32b57dc0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java
@@ -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);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
index 62d0dc7c4ed..de71ba24962 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
@@ -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()]);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java
index 2122c44a9a5..d42b9b36330 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/EmptyCIndex.java
@@ -130,4 +130,8 @@ final public class EmptyCIndex implements IIndex {
public IIndexFileSet createFileSet() {
return new IndexFileSet();
}
+
+ public IIndexFile[] getAllFiles() {
+ return IIndexFile.EMPTY_FILE_ARRAY;
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
index 1d222a62dde..e09760934ea 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
@@ -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;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
index 9de69867b84..9dd5700c700 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
@@ -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;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index ab036511dfe..e68a00c93d9 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -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
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index aa9fe8dea0b..970095ff92c 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -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
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
index 802826a649f..a9a34f2d11a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
@@ -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);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
index 12331986307..c32b5505d53 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
@@ -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
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java
index df80c97ad76..39a33ec50be 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java
@@ -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;
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java
index 9ab080db056..ceb2c6a15b0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java
@@ -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) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java
index 330916afc63..bf1c599bb27 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java
@@ -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));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java
index 705415888b2..0370fcf15a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java
@@ -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();
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
index 895e5088d15..7e1e6b807fa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
@@ -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();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java
index 0c51c35d96f..b282cbe1570 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java
@@ -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$
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java
index 0f004f57bc2..9b74eaf3393 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java
@@ -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);
}
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java
index 34cebb0c3a8..8fc764bc5c5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java
@@ -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));
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java
new file mode 100644
index 00000000000..abf9268c0b3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java
@@ -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());
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java
index 18805df10e9..ca53753aa83 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java
@@ -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();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java
new file mode 100644
index 00000000000..dcb16808650
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java
@@ -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;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java
new file mode 100644
index 00000000000..05963baab16
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java
@@ -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;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
index 94b5d1aac5e..57183529c59 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
@@ -8,22 +8,24 @@
* Contributors:
* IBM Corp. - Rational Software - initial implementation
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.search.actions;
+import org.eclipse.jface.text.ITextSelection;
+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.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;
-import org.eclipse.jface.text.ITextSelection;
-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.IWorkbenchSite;
public abstract class FindAction extends SelectionParseAction {
@@ -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();
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java
new file mode 100644
index 00000000000..3f6c47637f4
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java
@@ -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;
+ }
+}

Back to the top