mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 20:55:44 +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() {
|
public IIndexFragmentFileSet createFileSet() {
|
||||||
return null;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,7 +9,6 @@
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
|
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.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
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
|
* This is a utility class to help convert AST elements to Strings corresponding
|
||||||
|
@ -1079,4 +1079,10 @@ public class ASTSignatureUtil {
|
||||||
return result;
|
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)
|
* Andrew Ferguson (Symbian)
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.index;
|
package org.eclipse.cdt.core.index;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
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.
|
* Creates a file-set that can be used with this index as long as you hold a read-lock.
|
||||||
*/
|
*/
|
||||||
public IIndexFileSet createFileSet();
|
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,17 +78,21 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
return ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
return ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessageWithoutLocation() {
|
public static String getMessageWithoutLocation(int id, String arg) {
|
||||||
String msg = errorMessages.get(new Integer(id));
|
String msg = errorMessages.get(new Integer(id));
|
||||||
if (msg == null)
|
if (msg == null)
|
||||||
msg = ""; //$NON-NLS-1$
|
msg = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
return MessageFormat.format(msg, new Object[] { new String(arg) });
|
return MessageFormat.format(msg, arg);
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMessageWithoutLocation() {
|
||||||
|
return getMessageWithoutLocation(id, arg == null ? null : new String(arg));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean checkCategory(int bitmask) {
|
public boolean checkCategory(int bitmask) {
|
||||||
return ((id & bitmask) != 0);
|
return ((id & bitmask) != 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,9 +476,11 @@ public class CIndex implements IIndex {
|
||||||
|
|
||||||
private IndexFilter retargetFilter(final ILinkage linkage, final IndexFilter filter) {
|
private IndexFilter retargetFilter(final ILinkage linkage, final IndexFilter filter) {
|
||||||
return new IndexFilter() {
|
return new IndexFilter() {
|
||||||
|
@Override
|
||||||
public boolean acceptBinding(IBinding binding) throws CoreException {
|
public boolean acceptBinding(IBinding binding) throws CoreException {
|
||||||
return filter.acceptBinding(binding);
|
return filter.acceptBinding(binding);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean acceptLinkage(ILinkage other) {
|
public boolean acceptLinkage(ILinkage other) {
|
||||||
return linkage.getLinkageID() == other.getLinkageID();
|
return linkage.getLinkageID() == other.getLinkageID();
|
||||||
}
|
}
|
||||||
|
@ -586,4 +588,14 @@ public class CIndex implements IIndex {
|
||||||
public IIndexFileSet createFileSet() {
|
public IIndexFileSet createFileSet() {
|
||||||
return new IndexFileSet();
|
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() {
|
public IIndexFileSet createFileSet() {
|
||||||
return new IndexFileSet();
|
return new IndexFileSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IIndexFile[] getAllFiles() {
|
||||||
|
return IIndexFile.EMPTY_FILE_ARRAY;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -232,4 +232,9 @@ public interface IIndexFragment {
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
IIndexFragmentFileSet createFileSet();
|
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() {
|
public IIndexFragmentFileSet createFileSet() {
|
||||||
return new PDOMFileSet();
|
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
|
RebuildIndex.name=&Rebuild
|
||||||
SyncIndex.name=&Update with Modified Files
|
SyncIndex.name=&Update with Modified Files
|
||||||
FreshenIndex.name=&Freshen All Files
|
FreshenIndex.name=&Freshen All Files
|
||||||
|
SearchUnresolvedIncludes.name=Search for Unresolved &Includes
|
||||||
|
|
||||||
indexerPage.name = Indexer Page
|
indexerPage.name = Indexer Page
|
||||||
proposalFilter.name = Code Completion Proposal Filter
|
proposalFilter.name = Code Completion Proposal Filter
|
||||||
|
|
|
@ -823,6 +823,7 @@
|
||||||
path="buildGroup">
|
path="buildGroup">
|
||||||
<groupMarker name="rebuild"/>
|
<groupMarker name="rebuild"/>
|
||||||
<separator name="update"/>
|
<separator name="update"/>
|
||||||
|
<separator name="search"/>
|
||||||
</menu>
|
</menu>
|
||||||
</objectContribution>
|
</objectContribution>
|
||||||
<objectContribution
|
<objectContribution
|
||||||
|
@ -833,12 +834,18 @@
|
||||||
id="org.eclipse.cdt.ui.rebuildIndexAction"
|
id="org.eclipse.cdt.ui.rebuildIndexAction"
|
||||||
label="%RebuildIndex.name"
|
label="%RebuildIndex.name"
|
||||||
menubarPath="org.eclipse.cdt.ui.indexmenu/rebuild"/>
|
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
|
<menu
|
||||||
id="org.eclipse.cdt.ui.indexmenu"
|
id="org.eclipse.cdt.ui.indexmenu"
|
||||||
label="%Index.menu"
|
label="%Index.menu"
|
||||||
path="buildGroup">
|
path="buildGroup">
|
||||||
<groupMarker name="rebuild"/>
|
<groupMarker name="rebuild"/>
|
||||||
<separator name="update"/>
|
<separator name="update"/>
|
||||||
|
<separator name="search"/>
|
||||||
</menu>
|
</menu>
|
||||||
</objectContribution>
|
</objectContribution>
|
||||||
<!-- project explorer shows IProjects, we need to handle this -->
|
<!-- project explorer shows IProjects, we need to handle this -->
|
||||||
|
@ -865,12 +872,18 @@
|
||||||
id="org.eclipse.cdt.ui.rebuildIndexAction"
|
id="org.eclipse.cdt.ui.rebuildIndexAction"
|
||||||
label="%RebuildIndex.name"
|
label="%RebuildIndex.name"
|
||||||
menubarPath="org.eclipse.cdt.ui.indexmenu/rebuild"/>
|
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
|
<menu
|
||||||
id="org.eclipse.cdt.ui.indexmenu"
|
id="org.eclipse.cdt.ui.indexmenu"
|
||||||
label="%Index.menu"
|
label="%Index.menu"
|
||||||
path="buildGroup">
|
path="buildGroup">
|
||||||
<groupMarker name="rebuild"/>
|
<groupMarker name="rebuild"/>
|
||||||
<separator name="update"/>
|
<separator name="update"/>
|
||||||
|
<separator name="search"/>
|
||||||
</menu>
|
</menu>
|
||||||
</objectContribution>
|
</objectContribution>
|
||||||
<objectContribution
|
<objectContribution
|
||||||
|
|
|
@ -90,6 +90,7 @@ public final class CSearchMessages extends NLS {
|
||||||
public static String CSearchMessages_IndexRunningIncompleteWarning;
|
public static String CSearchMessages_IndexRunningIncompleteWarning;
|
||||||
public static String PDOMSearchTreeContentProvider_IndexerNotEnabledWarning;
|
public static String PDOMSearchTreeContentProvider_IndexerNotEnabledWarning;
|
||||||
public static String PDOMSearchTreeContentProvider_ProjectClosedWarning;
|
public static String PDOMSearchTreeContentProvider_ProjectClosedWarning;
|
||||||
|
public static String PDOMSearchUnresolvedIncludesQuery_title;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
NLS.initializeMessages(BUNDLE_NAME, CSearchMessages.class);
|
NLS.initializeMessages(BUNDLE_NAME, CSearchMessages.class);
|
||||||
|
|
|
@ -82,6 +82,7 @@ PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat=(project ''{0}'' -
|
||||||
PDOMSearchListContentProvider_ProjectClosedMessageFormat=(project ''{0}'' - unknown results: project is closed)
|
PDOMSearchListContentProvider_ProjectClosedMessageFormat=(project ''{0}'' - unknown results: project is closed)
|
||||||
CSearchMessages_IndexRunningIncompleteWarning=(incomplete or inaccurate results: indexer was busy during search)
|
CSearchMessages_IndexRunningIncompleteWarning=(incomplete or inaccurate results: indexer was busy during search)
|
||||||
PDOMSearch_query_pattern_error = Illegal Search String
|
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_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_SelectedTextNotSymbol_message=Selected text cannot be mapped to a symbol name
|
||||||
SelectionParseAction_SymbolNotFoundInIndex_format=Could not find symbol ''{0}'' in index
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,21 +9,14 @@
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.Path;
|
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.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Element class used to group matches.
|
* Element class used to group matches.
|
||||||
|
@ -32,37 +25,30 @@ import org.eclipse.cdt.core.index.IIndexName;
|
||||||
*/
|
*/
|
||||||
public class PDOMSearchElement implements IAdaptable {
|
public class PDOMSearchElement implements IAdaptable {
|
||||||
|
|
||||||
private final ITypeInfo typeInfo;
|
|
||||||
private final IIndexFileLocation location;
|
private final IIndexFileLocation location;
|
||||||
|
|
||||||
public PDOMSearchElement(IIndex index, IIndexName name, IIndexBinding binding) throws CoreException {
|
public PDOMSearchElement(IIndexFileLocation loc) {
|
||||||
this.typeInfo= IndexTypeInfo.create(index, binding);
|
this.location= loc;
|
||||||
this.location= name.getFile().getLocation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (typeInfo.getCElementType() *31 + typeInfo.getName().hashCode())*31 + location.hashCode();
|
return location.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof PDOMSearchElement))
|
if (!(obj instanceof PDOMSearchElement))
|
||||||
return false;
|
return false;
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
PDOMSearchElement other = (PDOMSearchElement)obj;
|
PDOMSearchElement other = (PDOMSearchElement)obj;
|
||||||
return typeInfo.getCElementType() == other.typeInfo.getCElementType()
|
return location.equals(other.location);
|
||||||
&& typeInfo.getName().equals(other.typeInfo.getName())
|
|
||||||
&& location.equals(other.location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITypeInfo getTypeInfo() {
|
final IIndexFileLocation getLocation() {
|
||||||
return typeInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
IIndexFileLocation getLocation() {
|
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Object getAdapter(Class adapterType) {
|
public Object getAdapter(Class adapterType) {
|
||||||
if (adapterType.isAssignableFrom(IFile.class)) {
|
if (adapterType.isAssignableFrom(IFile.class)) {
|
||||||
String fullPath= location.getFullPath();
|
String fullPath= location.getFullPath();
|
||||||
|
@ -72,5 +58,4 @@ public class PDOMSearchElement implements IAdaptable {
|
||||||
}
|
}
|
||||||
return null;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,7 +9,6 @@
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -22,6 +21,7 @@ import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.ui.ISharedImages;
|
import org.eclipse.ui.ISharedImages;
|
||||||
import org.eclipse.ui.PlatformUI;
|
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.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||||
|
@ -55,9 +55,14 @@ public class PDOMSearchLabelProvider extends LabelProvider {
|
||||||
fPage= page;
|
fPage= page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
if (element instanceof PDOMSearchElement)
|
if (element instanceof TypeInfoSearchElement)
|
||||||
return fTypeInfoLabelProvider.getImage(((PDOMSearchElement)element).getTypeInfo());
|
return fTypeInfoLabelProvider.getImage(((TypeInfoSearchElement)element).getTypeInfo());
|
||||||
|
|
||||||
|
if (element instanceof ProblemSearchElement) {
|
||||||
|
return CPluginImages.get(CPluginImages.IMG_OBJS_REFACTORING_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
if (element instanceof IIndexFileLocation
|
if (element instanceof IIndexFileLocation
|
||||||
|| element instanceof URI) {
|
|| element instanceof URI) {
|
||||||
|
@ -89,9 +94,14 @@ public class PDOMSearchLabelProvider extends LabelProvider {
|
||||||
return fCElementLabelProvider.getImage(element);
|
return fCElementLabelProvider.getImage(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
if (element instanceof PDOMSearchElement) {
|
if (element instanceof TypeInfoSearchElement) {
|
||||||
return fTypeInfoLabelProvider.getText(((PDOMSearchElement)element).getTypeInfo());
|
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) {
|
if (element instanceof IPath) {
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -31,6 +30,7 @@ public class PDOMSearchListLabelProvider extends PDOMSearchLabelProvider {
|
||||||
super(page);
|
super(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
final String text= super.getText(element);
|
final String text= super.getText(element);
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ public class PDOMSearchListLabelProvider extends PDOMSearchLabelProvider {
|
||||||
PDOMSearchElement searchElement = (PDOMSearchElement)element;
|
PDOMSearchElement searchElement = (PDOMSearchElement)element;
|
||||||
final int count= getMatchCount(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$
|
return text + filename + " " //$NON-NLS-1$
|
||||||
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,31 +9,26 @@
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.search.ui.text.Match;
|
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.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 class PDOMSearchMatch extends Match {
|
||||||
|
|
||||||
public PDOMSearchMatch(IIndex index, IIndexBinding binding, IIndexName name, int offset, int length) throws CoreException {
|
public PDOMSearchMatch(PDOMSearchElement elem, int offset, int length) {
|
||||||
super(new PDOMSearchElement(index, name, binding), offset, length);
|
super(elem, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
IIndexFileLocation getLocation() {
|
IIndexFileLocation getLocation() {
|
||||||
return ((PDOMSearchElement)getElement()).getLocation();
|
return ((PDOMSearchElement)getElement()).getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -44,5 +39,4 @@ public class PDOMSearchMatch extends Match {
|
||||||
&& getOffset() == other.getOffset()
|
&& getOffset() == other.getOffset()
|
||||||
&& getLength() == other.getLength();
|
&& getLength() == other.getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -72,7 +71,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
|
|
||||||
projects = (ICProject[]) ArrayUtil.removeNulls(ICProject.class, allProjects);
|
projects = (ICProject[]) ArrayUtil.removeNulls(ICProject.class, allProjects);
|
||||||
} else {
|
} else {
|
||||||
Map projectMap = new HashMap();
|
Map<String, ICProject> projectMap = new HashMap<String, ICProject>();
|
||||||
|
|
||||||
for (int i = 0; i < scope.length; ++i) {
|
for (int i = 0; i < scope.length; ++i) {
|
||||||
ICProject project = scope[i].getCProject();
|
ICProject project = scope[i].getCProject();
|
||||||
|
@ -80,7 +79,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
projectMap.put(project.getElementName(), project);
|
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) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.getDefault().log(e);
|
CUIPlugin.getDefault().log(e);
|
||||||
|
@ -126,7 +125,9 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
if (!filterName(name)) {
|
if (!filterName(name)) {
|
||||||
IASTFileLocation loc = name.getFileLocation();
|
IASTFileLocation loc = name.getFileLocation();
|
||||||
IIndexBinding binding= index.findBinding(name);
|
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() {
|
public ICProject[] getProjects() {
|
||||||
return projects;
|
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,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -57,10 +56,12 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IEditorMatchAdapter getEditorMatchAdapter() {
|
public IEditorMatchAdapter getEditorMatchAdapter() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IFileMatchAdapter getFileMatchAdapter() {
|
public IFileMatchAdapter getFileMatchAdapter() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +106,7 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
||||||
|
|
||||||
private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
|
private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
|
||||||
IPath pfilename= new Path(filename);
|
IPath pfilename= new Path(filename);
|
||||||
List list = new ArrayList();
|
List<Match> list = new ArrayList<Match>();
|
||||||
Object[] elements = result.getElements();
|
Object[] elements = result.getElements();
|
||||||
for (int i = 0; i < elements.length; ++i) {
|
for (int i = 0; i < elements.length; ++i) {
|
||||||
if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((PDOMSearchElement)elements[i]).getLocation()))) {
|
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) {
|
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
|
||||||
|
@ -157,7 +158,7 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
// report pattern and number of matches
|
// report pattern and number of matches
|
||||||
String label = query.getLabel();
|
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$
|
return label + " " + countLabel; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -47,10 +46,10 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
|
|
||||||
private TreeViewer viewer;
|
private TreeViewer viewer;
|
||||||
private PDOMSearchResult result;
|
private PDOMSearchResult result;
|
||||||
private Map tree = new HashMap();
|
private Map<Object, Set<Object>> tree = new HashMap<Object, Set<Object>>();
|
||||||
|
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
Set children = (Set)tree.get(parentElement);
|
Set children = tree.get(parentElement);
|
||||||
if (children == null)
|
if (children == null)
|
||||||
return new Object[0];
|
return new Object[0];
|
||||||
return children.toArray();
|
return children.toArray();
|
||||||
|
@ -60,7 +59,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
Iterator p = tree.keySet().iterator();
|
Iterator p = tree.keySet().iterator();
|
||||||
while (p.hasNext()) {
|
while (p.hasNext()) {
|
||||||
Object parent = p.next();
|
Object parent = p.next();
|
||||||
Set children = (Set)tree.get(parent);
|
Set children = tree.get(parent);
|
||||||
if (children.contains(element))
|
if (children.contains(element))
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
@ -108,9 +107,9 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean insertChild(Object parent, Object child) {
|
private boolean insertChild(Object parent, Object child) {
|
||||||
Set children = (Set)tree.get(parent);
|
Set<Object> children = tree.get(parent);
|
||||||
if (children == null) {
|
if (children == null) {
|
||||||
children = new HashSet();
|
children = new HashSet<Object>();
|
||||||
tree.put(parent, children);
|
tree.put(parent, children);
|
||||||
}
|
}
|
||||||
return children.add(child);
|
return children.add(child);
|
||||||
|
@ -189,7 +188,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addProjectWarningIfApplicable(ICProject cProject) {
|
private boolean addProjectWarningIfApplicable(ICProject cProject) {
|
||||||
if (cProject.isOpen()) {
|
if (cProject.getProject().isOpen()) {
|
||||||
if (!CCorePlugin.getIndexManager().isProjectIndexed(cProject)) {
|
if (!CCorePlugin.getIndexManager().isProjectIndexed(cProject)) {
|
||||||
insertUnindexedProjectWarningElement(cProject);
|
insertUnindexedProjectWarningElement(cProject);
|
||||||
return true;
|
return true;
|
||||||
|
@ -237,7 +236,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
// reached the search result
|
// reached the search result
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Set siblings = (Set)tree.get(parent);
|
Set siblings = tree.get(parent);
|
||||||
siblings.remove(element);
|
siblings.remove(element);
|
||||||
|
|
||||||
if (siblings.isEmpty()) {
|
if (siblings.isEmpty()) {
|
||||||
|
@ -246,5 +245,4 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
||||||
tree.remove(parent);
|
tree.remove(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
||||||
|
@ -27,14 +26,14 @@ public class PDOMSearchTreeLabelProvider extends PDOMSearchLabelProvider {
|
||||||
super(page);
|
super(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
final String text= super.getText(element);
|
final String text= super.getText(element);
|
||||||
final int count= getMatchCount(element);
|
final int count= getMatchCount(element);
|
||||||
if (count == 0) {
|
if (count <= 1) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
return text + " " //$NON-NLS-1$
|
return text + " " //$NON-NLS-1$
|
||||||
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
+ 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,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -9,7 +9,6 @@
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -35,8 +34,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
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 {
|
public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
|
|
||||||
|
@ -50,11 +48,13 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void elementsChanged(Object[] objects) {
|
protected void elementsChanged(Object[] objects) {
|
||||||
if (contentProvider != null)
|
if (contentProvider != null)
|
||||||
contentProvider.elementsChanged(objects);
|
contentProvider.elementsChanged(objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void clear() {
|
protected void clear() {
|
||||||
if (contentProvider != null)
|
if (contentProvider != null)
|
||||||
contentProvider.clear();
|
contentProvider.clear();
|
||||||
|
@ -84,6 +84,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
|
* @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int category(Object element) {
|
public int category(Object element) {
|
||||||
// place status messages first
|
// place status messages first
|
||||||
if (element instanceof IStatus) {
|
if (element instanceof IStatus) {
|
||||||
|
@ -91,8 +92,8 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep elements of the same type together
|
// keep elements of the same type together
|
||||||
if (element instanceof PDOMSearchElement) {
|
if (element instanceof TypeInfoSearchElement) {
|
||||||
PDOMSearchElement searchElement = (PDOMSearchElement)element;
|
TypeInfoSearchElement searchElement = (TypeInfoSearchElement)element;
|
||||||
int type = searchElement.getTypeInfo().getCElementType();
|
int type = searchElement.getTypeInfo().getCElementType();
|
||||||
// handle unknown types
|
// handle unknown types
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
|
@ -122,6 +123,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void configureTreeViewer(TreeViewer viewer) {
|
protected void configureTreeViewer(TreeViewer viewer) {
|
||||||
contentProvider = new PDOMSearchTreeContentProvider();
|
contentProvider = new PDOMSearchTreeContentProvider();
|
||||||
viewer.setComparator(new SearchViewerComparator());
|
viewer.setComparator(new SearchViewerComparator());
|
||||||
|
@ -129,6 +131,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
viewer.setLabelProvider(new PDOMSearchTreeLabelProvider(this));
|
viewer.setLabelProvider(new PDOMSearchTreeLabelProvider(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void configureTableViewer(TableViewer viewer) {
|
protected void configureTableViewer(TableViewer viewer) {
|
||||||
contentProvider = new PDOMSearchListContentProvider();
|
contentProvider = new PDOMSearchListContentProvider();
|
||||||
viewer.setComparator(new SearchViewerComparator());
|
viewer.setComparator(new SearchViewerComparator());
|
||||||
|
@ -136,6 +139,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
viewer.setLabelProvider(new PDOMSearchListLabelProvider(this));
|
viewer.setLabelProvider(new PDOMSearchListLabelProvider(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
|
protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
|
||||||
if (!(match instanceof PDOMSearchMatch))
|
if (!(match instanceof PDOMSearchMatch))
|
||||||
return;
|
return;
|
||||||
|
@ -154,6 +158,7 @@ public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public StructuredViewer getViewer() {
|
public StructuredViewer getViewer() {
|
||||||
return super.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:
|
* Contributors:
|
||||||
* IBM Corp. - Rational Software - initial implementation
|
* IBM Corp. - Rational Software - initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search.actions;
|
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.text.ITextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
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.search.ui.NewSearchUI;
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
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 abstract class FindAction extends SelectionParseAction {
|
||||||
public FindAction(CEditor editor){
|
public FindAction(CEditor editor){
|
||||||
|
@ -35,6 +37,7 @@ public abstract class FindAction extends SelectionParseAction {
|
||||||
super( site );
|
super( site );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ISearchQuery searchJob = null;
|
ISearchQuery searchJob = null;
|
||||||
|
|
||||||
|
@ -42,18 +45,14 @@ public abstract class FindAction extends SelectionParseAction {
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
Object object = ((IStructuredSelection)selection).getFirstElement();
|
Object object = ((IStructuredSelection)selection).getFirstElement();
|
||||||
if (object instanceof ISourceReference)
|
if (object instanceof ISourceReference)
|
||||||
searchJob = new PDOMSearchElementQuery(getScope(), (ISourceReference)object, getLimitTo());
|
searchJob = createQuery((ISourceReference) object);
|
||||||
} else if (selection instanceof ITextSelection) {
|
} else if (selection instanceof ITextSelection) {
|
||||||
ITextSelection selNode = getSelection((ITextSelection)selection);
|
ITextSelection selNode = getSelection((ITextSelection)selection);
|
||||||
ICElement element = fEditor.getInputCElement();
|
ICElement element = fEditor.getInputCElement();
|
||||||
while (element != null && !(element instanceof ITranslationUnit))
|
while (element != null && !(element instanceof ITranslationUnit))
|
||||||
element = element.getParent();
|
element = element.getParent();
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
searchJob = new PDOMSearchTextSelectionQuery(
|
searchJob = createQuery(element, selNode);
|
||||||
getScope(),
|
|
||||||
(ITranslationUnit)element,
|
|
||||||
selNode,
|
|
||||||
getLimitTo());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +68,15 @@ public abstract class FindAction extends SelectionParseAction {
|
||||||
NewSearchUI.runQueryInBackground(searchJob);
|
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();
|
abstract protected String getScopeDescription();
|
||||||
|
|
||||||
abstract protected ICElement[] getScope();
|
abstract protected ICElement[] getScope();
|
||||||
|
|
|
@ -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