Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2005-06-13 05:21:49 +0000
committerBogdan Gheorghe2005-06-13 05:21:49 +0000
commit37337c303a295749c44f7cab5dc62b48eb54a8a0 (patch)
treeea3ab71de8499565cb4e600869447c8eba66203f
parentbd573a8236c7bc5d64fecfca14c67afd7ee6698e (diff)
downloadorg.eclipse.cdt-37337c303a295749c44f7cab5dc62b48eb54a8a0.tar.gz
org.eclipse.cdt-37337c303a295749c44f7cab5dc62b48eb54a8a0.tar.xz
org.eclipse.cdt-37337c303a295749c44f7cab5dc62b48eb54a8a0.zip
CTag Indexer - patch to index include path
Clean up of deprecated search UI
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java43
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java62
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMDisplaySearchNames.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerQuery.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java153
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java234
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java35
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/DOMQuery.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java94
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java47
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java31
14 files changed, 96 insertions, 646 deletions
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java
index 0ec1ce63f54..e87959c9b42 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java
@@ -24,6 +24,8 @@ import org.eclipse.cdt.internal.core.index.IIndexerOutput;
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -31,9 +33,10 @@ public class CTagsFileReader {
String filename = null;
List list = null;
- IProject project;
- IIndex index;
- CTagsIndexer indexer;
+ IProject project = null;
+ IIndex index = null;
+ CTagsIndexer indexer = null;
+ IPath rootDirectory = null;
public CTagsFileReader(IProject project,String filename, CTagsIndexer indexer) {
this.filename = filename;
@@ -90,9 +93,26 @@ public class CTagsFileReader {
}
+
if (currentFile != null){
- indexer = new MiniIndexer(currentFile);
+ indexer = new MiniIndexer(currentFile.getFullPath());
index.add(currentFile,indexer);
+ } else {
+ indexer = new MiniIndexer(rootDirectory.append(fileName));
+ try {
+ IResource[] resources = project.members();
+ IFile tempFile=null;
+ for (int i=0; i<resources.length; i++){
+ if (resources[i].getType()==IResource.FILE){
+ tempFile = (IFile) resources[i];
+ break;
+ }
+ }
+ if (tempFile != null){
+ index.add(tempFile,indexer);
+ }
+ } catch (CoreException e) { }
+
}
}
@@ -105,16 +125,16 @@ public class CTagsFileReader {
class MiniIndexer implements IIndexer {
IIndexerOutput output;
- IFile currentFile;
+ IPath currentFile; //currentFile.getFullPath()
/**
* @param currentFile
*/
- public MiniIndexer(IFile currentFile) {
+ public MiniIndexer(IPath currentFile) {
this.currentFile = currentFile;
}
public void addToOutput(CTagEntry tagEntry){
- IndexedFileEntry mainIndexFile = this.output.getIndexedFile(currentFile.getFullPath().toString());
+ IndexedFileEntry mainIndexFile = this.output.getIndexedFile(currentFile.toString());
int fileNum = 0;
if (mainIndexFile != null)
fileNum = mainIndexFile.getFileID();
@@ -125,8 +145,8 @@ public class CTagsFileReader {
* @see org.eclipse.cdt.internal.core.index.IIndexer#index(org.eclipse.cdt.internal.core.index.IDocument, org.eclipse.cdt.internal.core.index.IIndexerOutput)
*/
public void index(IFile file, IIndexerOutput output) throws IOException {
- this.output = output;
- IndexedFileEntry indFile =output.addIndexedFile(file.getFullPath().toString());
+ this.output = output;
+ IndexedFileEntry indFile =output.addIndexedFile(currentFile.toString());
}
/* (non-Javadoc)
@@ -144,4 +164,9 @@ public class CTagsFileReader {
this.index = index;
}
+ public void setRootDirectory(IPath path) {
+ this.rootDirectory = path;
+
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java
index 00185561cc8..85383f8fd98 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java
@@ -17,7 +17,11 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtensionReference;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage;
@@ -82,13 +86,14 @@ class CTagsIndexAll extends CTagsIndexRequest {
boolean success=false;
+
if (useInternalCTagsFile()){
if (AbstractIndexer.TIMING)
startTime = System.currentTimeMillis();
//run CTags over project
- success = runCTags();
+ success = runCTags(project.getLocation());
ctagsFileToUse=ctagsFile;
if (AbstractIndexer.TIMING){
@@ -117,6 +122,9 @@ class CTagsIndexAll extends CTagsIndexRequest {
}
}
+ //Try to index includes (if any exist)
+ //cTagsInclude(index);
+
} catch (IOException e) {
if (IndexManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -130,10 +138,32 @@ class CTagsIndexAll extends CTagsIndexRequest {
return true;
}
+ private void cTagsInclude(IIndex index) {
+
+ ICProject cProj = CoreModel.getDefault().create(project);
+ IIncludeReference[] refs = new IIncludeReference[0];
+ try {
+ refs = cProj.getIncludeReferences();
+ } catch (CModelException e) {}
+
+ for (int i=0; i<refs.length; i++){
+ runCTags(refs[i].getPath());
+ ctagsFileToUse=ctagsFile;
+ //Parse the CTag File
+ CTagsFileReader reader = new CTagsFileReader(project,ctagsFileToUse,indexer);
+ reader.setRootDirectory(refs[i].getPath());
+ reader.setIndex(index);
+ reader.parse();
+ }
+
+ // request to save index when all cus have been indexed
+ indexer.request(new CTagsSaveIndex(this.indexPath, indexer));
+ }
+
/**
* @return
*/
- private boolean runCTags() {
+ private boolean runCTags(IPath directoryToRunFrom) {
String[] args = {"--excmd=number", //$NON-NLS-1$
"--format=2", //$NON-NLS-1$
"--sort=no", //$NON-NLS-1$
@@ -144,20 +174,20 @@ class CTagsIndexAll extends CTagsIndexRequest {
"-f",ctagsFile,"-R"}; //$NON-NLS-1$ //$NON-NLS-2$
try{
- //Make sure that there is no ctags file leftover in the metadata
- File tagsFile = new File(ctagsFile);
- if (tagsFile.exists()){
- tagsFile.delete();
- }
-
- CommandLauncher launcher = new CommandLauncher();
- // Print the command for visual interaction.
- launcher.showCommand(true);
-
- IPath fileDirectory = project.getLocation();
- //Process p = launcher.execute(fCompileCommand, args, setEnvironment(launcher), fWorkingDirectory);
- Process p = launcher.execute(new Path("ctags"), args, null, fileDirectory); //$NON-NLS-1$
- p.waitFor();
+ //Make sure that there is no ctags file leftover in the metadata
+ File tagsFile = new File(ctagsFile);
+
+ if (tagsFile.exists()){
+ tagsFile.delete();
+ }
+
+ CommandLauncher launcher = new CommandLauncher();
+ // Print the command for visual interaction.
+ launcher.showCommand(true);
+
+ //Process p = launcher.execute(fCompileCommand, args, setEnvironment(launcher), fWorkingDirectory);
+ Process p = launcher.execute(new Path("ctags"), args, null, directoryToRunFrom); //$NON-NLS-1$
+ p.waitFor();
} catch (InterruptedException e) {
return false;
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMDisplaySearchNames.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMDisplaySearchNames.java
index 2c8f68df6d1..0ea10c043dc 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMDisplaySearchNames.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMDisplaySearchNames.java
@@ -68,7 +68,7 @@ public class DOMDisplaySearchNames extends CSearchQuery implements ISearchQuery
*
*/
public DOMDisplaySearchNames(IASTNode[] nodes, String queryLabel, String pattern) {
- super(CUIPlugin.getWorkspace(), pattern, false, null, null, null, queryLabel, null);
+ super(CUIPlugin.getWorkspace(), pattern, false, null, null, null, queryLabel);
this.nodes = nodes;
this.queryLabel = queryLabel;
}
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerQuery.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerQuery.java
index e3bbd583978..dee85f6bffd 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerQuery.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/IndexerQuery.java
@@ -52,7 +52,7 @@ public class IndexerQuery extends CSearchQuery implements ISearchQuery {
*
*/
public IndexerQuery(IndexerNodeLeaf leaf, String queryLabel, String pattern) {
- super(CTestPlugin.getWorkspace(), pattern, false, null, null, null, queryLabel, null);
+ super(CTestPlugin.getWorkspace(), pattern, false, null, null, null, queryLabel);
this.leaf = leaf;
this.queryLabel = queryLabel;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
deleted file mode 100644
index f56ad3d2f0a..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Jun 11, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.search.ICSearchConstants;
-import org.eclipse.cdt.core.search.ICSearchPattern;
-import org.eclipse.cdt.core.search.ICSearchScope;
-import org.eclipse.cdt.core.search.OrPattern;
-import org.eclipse.cdt.core.search.SearchEngine;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchOperation implements IRunnableWithProgress,ICSearchConstants{
- public CSearchOperation(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector) {
- this( workspace, limitTo, scope, scopeDescription, collector );
- _stringPattern = pattern;
- _caseSensitive = caseSensitive;
- _searchFor = searchFor;
- }
-
- public CSearchOperation(IWorkspace workspace, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector ){
- _workspace = workspace;
- _limitTo = limitTo;
- _scope = scope;
- _scopeDescription = scopeDescription;
- _collector = collector;
- _collector.setOperation( this );
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.WorkspaceModifyOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void run(IProgressMonitor monitor)throws InvocationTargetException
- {
- _collector.setProgressMonitor( monitor );
-
- SearchEngine engine = new SearchEngine( CUIPlugin.getSharedWorkingCopies() );
-
- ICSearchPattern pattern = null;
- if( _searchFor.size() > 1 ){
- OrPattern orPattern = new OrPattern();
- for (Iterator iter = _searchFor.iterator(); iter.hasNext();) {
- SearchFor element = (SearchFor)iter.next();
- orPattern.addPattern( SearchEngine.createSearchPattern( _stringPattern, element, _limitTo, _caseSensitive ) );
- }
-
- pattern = orPattern;
-
- } else {
- Iterator iter = _searchFor.iterator();
- pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
- }
-
- try {
- engine.search( _workspace, pattern, _scope, _collector, false );
- } catch (InterruptedException e) {
- }
- }
-
- /**
- * @return
- */
- public String getSingularLabel() {
- String desc = null;
-
- //if( _elementPattern != null ){
- // desc = _elementPattern.getElementName();
- //} else {
- desc = _stringPattern;
- //}
-
- String [] args = new String [] { desc, _scopeDescription };
-
- if( _limitTo == DECLARATIONS ){
- return CSearchMessages.getFormattedString( "CSearchOperation.singularDeclarationsPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else if( _limitTo == REFERENCES ){
- return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else {
- return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurrencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- }
- }
-
- /**
- * @return
- */
- public String getPluralLabelPattern() {
- String desc = null;
-
- // if( _elementPattern != null ){
- // desc = _elementPattern.getElementName();
- // } else {
- desc = _stringPattern;
- // }
-
- String [] args = new String [] { desc, "{0}", _scopeDescription }; //$NON-NLS-1$
- if( _limitTo == DECLARATIONS ){
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralDeclarationsPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else if ( _limitTo == REFERENCES ){
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- } else {
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurrencesPostfix", args ); //$NON_NLS-1$ //$NON-NLS-1$
- }
- }
-
- /**
- * @return
- */
- public ImageDescriptor getImageDescriptor() {
- if( _limitTo == ICSearchConstants.DECLARATIONS ){
- return CPluginImages.DESC_OBJS_SEARCH_DECL;
- } else {
- return CPluginImages.DESC_OBJS_SEARCH_REF;
- }
- }
-
- private CSearchResultCollector _collector;
- private IWorkspace _workspace;
- //private ICElement _elementPattern;
- private ICSearchScope _scope;
- private String _stringPattern;
- private String _scopeDescription;
- private boolean _caseSensitive;
- private LimitTo _limitTo;
- private List _searchFor;
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
index 95458412f6b..a49e48e6a47 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
@@ -43,7 +43,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.search.ui.ISearchPage;
import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -126,7 +125,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
searching = data.searchFor;
}
- CSearchQuery job = new CSearchQuery(workspace, data.pattern, data.isCaseSensitive, searching, data.limitTo, scope, scopeDescription, null);
+ CSearchQuery job = new CSearchQuery(workspace, data.pattern, data.isCaseSensitive, searching, data.limitTo, scope, scopeDescription);
NewSearchUI.activateSearchResultView();
NewSearchUI.runQueryInBackground(job);
@@ -486,13 +485,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
Object o = selection.getFirstElement();
if( o instanceof ICElement ) {
return determineInitValuesFrom( (ICElement)o );
- } else if( o instanceof ISearchResultViewEntry ) {
- ICElement element = CSearchUtil.getCElement( ((ISearchResultViewEntry)o).getSelectedMarker() );
- return determineInitValuesFrom( element );
- //} else if( o instanceof LogicalPackage ) {
- // LogicalPackage lp = (LogicalPackage)o;
- // return new SearchPatternData( PACKAGE, REFERENCES, fIsCaseSensitive, lp.getElementName(), null );
- } else if( o instanceof IAdaptable ) {
+ } else if( o instanceof IAdaptable ) {
ICElement element = (ICElement)((IAdaptable)o).getAdapter( ICElement.class );
if( element != null ) {
return determineInitValuesFrom( element );
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
index f1ef7f6cb13..01818b13bd0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java
@@ -18,7 +18,6 @@ import java.util.List;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
-import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.OrPattern;
import org.eclipse.cdt.core.search.SearchEngine;
@@ -37,7 +36,6 @@ import org.eclipse.search.ui.ISearchResult;
*/
public class CSearchQuery implements ISearchQuery, ICSearchConstants {
- private ICSearchResultCollector _collector;
private IWorkspace _workspace;
private ICSearchScope _scope;
private String _stringPattern;
@@ -47,21 +45,18 @@ public class CSearchQuery implements ISearchQuery, ICSearchConstants {
private List _searchFor;
private CSearchResult _result;
- public CSearchQuery(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription, ICSearchResultCollector collector) {
- this( workspace, limitTo, scope, scopeDescription, collector );
+ public CSearchQuery(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription) {
+ this( workspace, limitTo, scope, scopeDescription );
_stringPattern = pattern;
_caseSensitive = caseSensitive;
_searchFor = searchFor;
}
- public CSearchQuery(IWorkspace workspace, LimitTo limitTo, ICSearchScope scope, String scopeDescription, ICSearchResultCollector collector ){
+ public CSearchQuery(IWorkspace workspace, LimitTo limitTo, ICSearchScope scope, String scopeDescription){
_workspace = workspace;
_limitTo = limitTo;
_scope = scope;
_scopeDescription = scopeDescription;
- _collector = collector;
- if (_collector instanceof CSearchResultCollector)
- ((CSearchResultCollector)_collector).setOperation( this );
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
deleted file mode 100644
index d884b7fc65b..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Jun 11, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import java.util.HashMap;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.search.BasicSearchMatch;
-import org.eclipse.cdt.core.search.BasicSearchResultCollector;
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.SearchUI;
-
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchResultCollector extends BasicSearchResultCollector{
-
- public static final String IMATCH = CSearchMessages.getString("CSearchResultCollector.4"); //$NON-NLS-1$
-
- /**
- *
- */
- public CSearchResultCollector() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.search.ICSearchResultCollector#aboutToStart()
- */
- public void aboutToStart() {
- super.aboutToStart();
-
- _matchCount = 0;
-
- //_view = NewSearchUI.getSearchResultView();
-
-
- CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider();
- labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH );
-
- _computer = new GroupByKeyComputer();
-
- if( _view != null ){
- if (_operation != null){
- _view.searchStarted(
- null,//new ActionGroupFactory(),
- _operation.getSingularLabel(),
- _operation.getPluralLabelPattern(),
- _operation.getImageDescriptor(),
- CSearchPage.EXTENSION_POINT_ID,
- labelProvider,
- new GotoMarkerAction(),
- _computer,
- _operation
- );
- }
- else if (_query != null){
- _view.searchStarted(
- null,//new ActionGroupFactory(),
- _query.getSingularLabel(),
- _query.getPluralLabelPattern(),
- _query.getImageDescriptor(),
- CSearchPage.EXTENSION_POINT_ID,
- labelProvider,
- new GotoMarkerAction(),
- _computer,
- null
- );
- }
- }
-
- if( getProgressMonitor() != null && !getProgressMonitor().isCanceled() ){
- getProgressMonitor().subTask( SEARCHING );
- }
- }
-
- public boolean acceptMatch( IMatch match ) throws CoreException
- {
- BasicSearchMatch searchMatch = (BasicSearchMatch) match;
-
- if( !super.acceptMatch( match ) )
- return false;
-
- if( searchMatch.resource == null &&
- searchMatch.path == null)
- return false;
-
- if (searchMatch.resource != null){
- IMarker marker = searchMatch.resource.createMarker( SearchUI.SEARCH_MARKER );
-
- HashMap markerAttributes = new HashMap( 2 );
-
- //we can hang any other info we want off the marker
- /*markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) );
- markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) );*/
- markerAttributes.put( IMATCH, searchMatch );
-
- marker.setAttributes( markerAttributes );
-
- if( _view != null ){
- _view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), searchMatch.resource, marker );
- }
- }
- else {
- //Check to see if external markers are enabled
- IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
- if (store.getBoolean(CSearchPage.EXTERNALMATCH_ENABLED)){
- //Create Link in referring file's project
- IPath refLocation = searchMatch.getReferenceLocation();
- IFile refFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(refLocation);
- IProject refProject = refFile.getProject();
- IPath externalMatchLocation = searchMatch.getLocation();
- IFile linksFile = refProject.getFile(externalMatchLocation.lastSegment());
- //Delete links file to keep up to date with latest prefs
- if (linksFile.exists())
- linksFile.delete(true,null);
-
- //Check to see if the file already exists - create if doesn't, mark team private
- if (!linksFile.exists()){
- linksFile.createLink(externalMatchLocation,IResource.NONE,null);
- int number = store.getInt(CSearchPage.EXTERNALMATCH_VISIBLE);
- if (number==0){
- linksFile.setDerived(true);
- }
- else{
- linksFile.setTeamPrivateMember(true);
- }
-
- }
-
- IMarker marker = linksFile.createMarker( SearchUI.SEARCH_MARKER );
-
- HashMap markerAttributes = new HashMap( 2 );
-
- /*markerAttributes.put( IMarker.CHAR_START, new Integer( Math.max( searchMatch.startOffset, 0 ) ) );
- markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( searchMatch.endOffset, 0 ) ) );*/
- markerAttributes.put( IMATCH, searchMatch );
-
- marker.setAttributes( markerAttributes );
-
- if( _view != null ){
- _view.addMatch( searchMatch.name, _computer.computeGroupByKey( marker ), linksFile, marker );
- }
- }
- }
- _matchCount++;
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.search.ICSearchResultCollector#done()
- */
- public void done() {
- /* if( !getProgressMonitor().isCanceled() ){
- String matchesString;
- if( _matchCount == 1 ){
- matchesString = MATCH;
- } else {
- matchesString = MessageFormat.format( MATCHES, new Integer[]{ new Integer(_matchCount) } );
- }
-
- getProgressMonitor().setTaskName( MessageFormat.format( DONE, new String[]{ matchesString } ) );
- }
-
- if( _view != null ){
- _view.searchFinished();
- }
-
- _view = null;
- _monitor = null;*/
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.search.ICSearchResultCollector#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- return _monitor;
- }
-
- public void setProgressMonitor(IProgressMonitor monitor) {
- this._monitor = monitor;
- }
-
- public void setOperation( CSearchOperation operation ) {
- _operation = operation;
- }
-
- private static final String SEARCHING = CSearchMessages.getString("CSearchResultCollector.searching"); //$NON-NLS-1$
- private static final String MATCH = CSearchMessages.getString("CSearchResultCollector.match"); //$NON-NLS-1$
- private static final String MATCHES = CSearchMessages.getString("CSearchResultCollector.matches"); //$NON-NLS-1$
- private static final String DONE = CSearchMessages.getString("CSearchResultCollector.done"); //$NON-NLS-1$
-
- private IProgressMonitor _monitor;
- private CSearchOperation _operation;
- private ISearchResultView _view;
- private IGroupByKeyComputer _computer;
- private int _matchCount;
- private CSearchQuery _query;
-
- /**
- * @param query
- */
- public void setOperation(CSearchQuery query) {
- _query = query;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
deleted file mode 100644
index c6083e4dc49..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.ui.actions.ActionGroup;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CSearchViewActionGroup extends ActionGroup {
-
- /**
- * @param part
- */
- public CSearchViewActionGroup(ISearchResultView part) {
-
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/DOMQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/DOMQuery.java
index 45782cd9dc5..b9a048d7286 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/DOMQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/DOMQuery.java
@@ -41,7 +41,6 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.search.BasicSearchMatch;
import org.eclipse.cdt.core.search.DOMSearchUtil;
-import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.OffsetLocatable;
@@ -73,8 +72,8 @@ public class DOMQuery extends CSearchQuery implements ISearchQuery {
private LimitTo limitTo=null;
private ICSearchScope scope=null;
- public DOMQuery(String displaySearchPattern, IASTName name, LimitTo limitTo, ICSearchScope scope, ICSearchResultCollector collector) {
- super(CUIPlugin.getWorkspace(), displaySearchPattern, false, null, null, null, displaySearchPattern, collector);
+ public DOMQuery(String displaySearchPattern, IASTName name, LimitTo limitTo, ICSearchScope scope) {
+ super(CUIPlugin.getWorkspace(), displaySearchPattern, false, null, null, null, displaySearchPattern);
this.searchName = name;
this.limitTo = limitTo;
this.scope = scope;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
deleted file mode 100644
index c32010233d6..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- ******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.SelectionUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.ide.IDE;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class GotoMarkerAction extends Action {
-
- public GotoMarkerAction(){
-
- }
-
- public void run() {
- ISearchResultView view = SearchUI.getSearchResultView();
- Object element = SelectionUtil.getSingleElement( view.getSelection() );
- if( element instanceof ISearchResultViewEntry ) {
- ISearchResultViewEntry entry = (ISearchResultViewEntry) element;
- show( entry.getSelectedMarker() );
- }
- }
-
- private void show( IMarker marker ){
- IResource resource = marker.getResource();
- if( resource == null || !resource.exists() ){
- return;
- }
-
- IWorkbenchPage page = CUIPlugin.getActivePage();
- ICElement element = CSearchUtil.getCElement( marker );
-
- if( SearchUI.reuseEditor() ){
- showWithReuse( marker, resource, element, page );
- } else {
- showWithoutReuse( marker, element, page );
- }
- }
-
- private void showWithoutReuse( IMarker marker, ICElement element, IWorkbenchPage page ){
- IEditorPart editor = null;
- try{
- Object objectToOpen = ( element != null ) ? (Object) element : (Object) marker.getResource();
- editor = EditorUtility.openInEditor( objectToOpen, false );
- } catch ( CoreException e ) {
- //boo
- }
- if( editor != null ){
- IDE.gotoMarker(editor, marker);
- }
- }
-
- private void showWithReuse( IMarker marker, IResource resource, ICElement element, IWorkbenchPage page ) {
- if( !(resource instanceof IFile) ){
- return;
- }
-
- IEditorPart editor = EditorUtility.isOpenInEditor( element );
- if( editor != null ){
- page.bringToTop( editor );
- } else {
-
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
deleted file mode 100644
index cd314ebf78e..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corp. - Rational Software - initial implementation
- *******************************************************************************/
-/*
- * Created on Jun 18, 2003
- */
-package org.eclipse.cdt.internal.ui.search;
-
-import org.eclipse.cdt.core.search.IMatch;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-
-/**
- * @author aniefer
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class GroupByKeyComputer implements IGroupByKeyComputer {
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.IGroupByKeyComputer#computeGroupByKey(org.eclipse.core.resources.IMarker)
- */
-
- public Object computeGroupByKey(IMarker marker) {
- if( marker == null ){
- return null;
- }
-
- IMatch match = null;
-
- try {
- match = (IMatch) marker.getAttribute(CSearchResultCollector.IMATCH);
- } catch (CoreException e) {
- }
-
- return match.getParentName() + "::" + match.getName() + " - " + match.getLocation(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
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 2085c4159a7..bfa9fbae280 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
@@ -29,13 +29,11 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ParseError;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.search.DOMSearchUtil;
-import org.eclipse.cdt.core.search.ICSearchResultCollector;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
-import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
import org.eclipse.cdt.internal.ui.search.DOMQuery;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
@@ -74,8 +72,8 @@ public abstract class FindAction extends SelectionParseAction {
* @param collector
* @return
*/
- public static CSearchQuery createDOMSearchQueryForName( IASTName name, LimitTo limitTo, ICSearchScope scope, ICSearchResultCollector collector ){
- return new DOMQuery(DOMSearchUtil.getSearchPattern(name), name, limitTo, scope, collector);
+ public static CSearchQuery createDOMSearchQueryForName( IASTName name, LimitTo limitTo, ICSearchScope scope){
+ return new DOMQuery(DOMSearchUtil.getSearchPattern(name), name, limitTo, scope);
}
/**
@@ -88,7 +86,7 @@ public abstract class FindAction extends SelectionParseAction {
* @return
*/
public static CSearchQuery createSearchQueryForName( IASTName name, LimitTo limitTo, ICSearchScope scope ){
- return createDOMSearchQueryForName( name, limitTo, scope, null );
+ return createDOMSearchQueryForName( name, limitTo, scope);
}
public void run() {
@@ -134,11 +132,9 @@ public abstract class FindAction extends SelectionParseAction {
List search = new LinkedList();
search.add(searchFor);
- CSearchResultCollector collector= new CSearchResultCollector();
-
LimitTo limitTo = getLimitTo();
- op = new CSearchQuery(CCorePlugin.getWorkspace(), pattern,true,search,limitTo,scope,scopeDescription,collector);
+ op = new CSearchQuery(CCorePlugin.getWorkspace(), pattern,true,search,limitTo,scope,scopeDescription);
return op;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java
index 6a9be8c5e7a..5523c95060e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CSearchResultLabelProvider.java
@@ -17,16 +17,12 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
-import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
import org.eclipse.cdt.internal.ui.search.CSearchResultPage;
import org.eclipse.cdt.internal.ui.search.NewSearchResultCollector;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.search.ui.ISearchResultViewEntry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
@@ -61,19 +57,8 @@ public class CSearchResultLabelProvider extends LabelProvider {
IMatch match = null;
int elementType = -1;
int visibility = -1;
- if( element instanceof ISearchResultViewEntry ){
- ISearchResultViewEntry viewEntry = (ISearchResultViewEntry)element;
- IMarker marker = viewEntry.getSelectedMarker();
- try {
- match = (IMatch) marker.getAttribute( CSearchResultCollector.IMATCH );
- if( match == null )
- return null;
- elementType = match.getElementType();
- visibility = match.getVisibility();
- } catch (CoreException e) {
- return null;
- }
- } else if ( element instanceof IMatch ){
+
+ if ( element instanceof IMatch ){
match = (IMatch) element;
if( match == null )
return null;
@@ -162,17 +147,7 @@ public class CSearchResultLabelProvider extends LabelProvider {
public String getText( Object element ) {
IMatch match = null;
- if( element instanceof ISearchResultViewEntry ){
- ISearchResultViewEntry viewEntry = (ISearchResultViewEntry) element;
-
- IMarker marker = viewEntry.getSelectedMarker();
-
- try {
- match = (IMatch) marker.getAttribute(CSearchResultCollector.IMATCH);
- } catch (CoreException e) {
- return ""; //$NON-NLS-1$
- }
- } else if( element instanceof IMatch ){
+ if( element instanceof IMatch ){
match = (IMatch) element;
} else if ( element instanceof ICElement){
return getElementText((ICElement) element);

Back to the top