[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Core:
- fix patterns & indexing for Enumerators
Core.Tests:
- Added testEnumerators to OtherPatternTests.java
- Modified resources/search/classDecl.cpp to include some enumerators
UI:
- enable Selected Resources scope
- populate dialog base on selection when opened from outline view
- fix small bug that found namespaces when searching for enumerations
- tweak sorting by path to consider line number second
-Andrew
Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.14
diff -u -r1.14 ChangeLog
--- index/ChangeLog 26 Aug 2003 19:15:58 -0000 1.14
+++ index/ChangeLog 5 Sep 2003 17:27:29 -0000
@@ -1,3 +1,6 @@
+2003-09-05 Andrew Niefer
+ - Modified how AbstractIndexer creates the fully qualified name for an enumerator (spec 7.2-10)
+
2003-08-26 Bogdan Gheorghe
- Removed header file extensions from being indexed (they
will be indexed via inclusion)
Index: index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java,v
retrieving revision 1.14
diff -u -r1.14 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java 20 Aug 2003 20:53:50 -0000 1.14
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java 5 Sep 2003 17:27:29 -0000
@@ -78,11 +78,14 @@
String name = en.getName();
IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
String[] parentName = parent.getFullyQualifiedName();
- String[] enumeratorFullName = new String[parentName.length + 1];
- int pos;
- System.arraycopy(parentName, 0, enumeratorFullName, 0, pos = parentName.length);
- enumeratorFullName[pos++] = name;
- this.output.addRef(encodeEntry(enumeratorFullName,FIELD_DECL,FIELD_DECL_LENGTH));
+
+ //See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
+ String[] enumeratorFullName = new String[ parentName.length ];
+
+ System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
+ enumeratorFullName[ parentName.length - 1 ] = name;
+
+ this.output.addRef(encodeEntry( enumeratorFullName, FIELD_DECL, FIELD_DECL_LENGTH ));
}
}
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.20
diff -u -r1.20 ChangeLog
--- search/ChangeLog 4 Sep 2003 13:50:42 -0000 1.20
+++ search/ChangeLog 5 Sep 2003 17:27:30 -0000
@@ -1,3 +1,6 @@
+2003-09-05 Andrew Niefer
+ - fix searching for enumerators
+
2003-09-03 Andrew Niefer
- added CLASS_STRUCT to the SearchFor constants
- Modified CSearchPattern to handle CLASS_STRUCT
Index: search/org/eclipse/cdt/core/search/SearchEngine.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/SearchEngine.java,v
retrieving revision 1.7
diff -u -r1.7 SearchEngine.java
--- search/org/eclipse/cdt/core/search/SearchEngine.java 26 Aug 2003 19:15:58 -0000 1.7
+++ search/org/eclipse/cdt/core/search/SearchEngine.java 5 Sep 2003 17:27:30 -0000
@@ -163,17 +163,4 @@
collector.done();
}
}
-
- /**
- * @param _workspace
- * @param _elementPattern
- * @param _limitTo
- * @param _scope
- * @param _collector
- */
- public void search(IWorkspace workspace, ICElement elementPattern, LimitTo limitTo, ICSearchScope scope, ICSearchResultCollector collector) {
- // TODO Auto-generated method stub
-
- }
-
}
Index: search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java,v
retrieving revision 1.8
diff -u -r1.8 FieldDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java 12 Aug 2003 20:20:04 -0000 1.8
+++ search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java 5 Sep 2003 17:27:30 -0000
@@ -16,6 +16,8 @@
import java.io.IOException;
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTField;
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
@@ -59,7 +61,10 @@
} else if ( node instanceof IASTVariable ){
if( searchFor != VAR || !canAccept( limit ) )
return IMPOSSIBLE_MATCH;
- } else return IMPOSSIBLE_MATCH;
+ } else if ( node instanceof IASTEnumerator ){
+ if( searchFor != FIELD || !canAccept( limit ) )
+ return IMPOSSIBLE_MATCH;
+ } else return IMPOSSIBLE_MATCH;
String nodeName = ((IASTOffsetableNamedElement)node).getName();
@@ -70,7 +75,26 @@
//check containing scopes
//create char[][] out of full name,
- String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+ String [] fullName = null;
+
+ if( node instanceof IASTEnumerator ){
+ //Enumerators don't derive from IASTQualifiedElement, so make the fullName
+ //from the enumerations name.
+ // 7.2 - 10 : each enumerator declared by an enum-specifier is declared in the
+ //scope that immediately contains the enum-specifier.
+ IASTEnumerationSpecifier enumeration = ((IASTEnumerator)node).getOwnerEnumerationSpecifier();
+ fullName = enumeration.getFullyQualifiedName();
+
+ String[] enumeratorFullName = new String[ fullName.length ];
+
+ System.arraycopy( fullName, 0, enumeratorFullName, 0, fullName.length);
+ enumeratorFullName[ fullName.length - 1 ] = nodeName;
+
+ fullName = enumeratorFullName;
+ } else {
+ fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+ }
+
char [][] qualName = new char [ fullName.length - 1 ][];
for( int i = 0; i < fullName.length - 1; i++ ){
qualName[i] = fullName[i].toCharArray();
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.79
diff -u -r1.79 ChangeLog
--- ChangeLog 5 Sep 2003 14:19:58 -0000 1.79
+++ ChangeLog 5 Sep 2003 17:04:05 -0000
@@ -1,3 +1,7 @@
+2003-09-05 Andrew Niefer
+ Added testEnumerators to OtherPatternTests.java
+ Modified resources/search/classDecl.cpp to include some enumerators
+
2003-09-05 John Camelon
Updated CompleteParseASTTest::testSimpleForLoop()
Index: resources/search/classDecl.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp,v
retrieving revision 1.6
diff -u -r1.6 classDecl.cpp
--- resources/search/classDecl.cpp 12 Aug 2003 18:19:54 -0000 1.6
+++ resources/search/classDecl.cpp 5 Sep 2003 17:04:05 -0000
@@ -16,7 +16,11 @@
}
class B: public A {
struct AA {};
- enum e {};
+ enum e {
+ One,
+ Two,
+ Three
+ };
using namespace NS2;
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java,v
retrieving revision 1.8
diff -u -r1.8 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 12 Aug 2003 20:19:47 -0000 1.8
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 5 Sep 2003 17:04:05 -0000
@@ -176,4 +176,21 @@
Set matches = resultCollector.getSearchResults();
assertEquals( matches.size(), 1 );
}
+
+ public void testEnumerators(){
+ ICSearchPattern pattern = SearchEngine.createSearchPattern( "One", FIELD, DECLARATIONS, true );
+
+ search( workspace, pattern, scope, resultCollector );
+
+ Set matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 1 );
+
+ pattern = SearchEngine.createSearchPattern( "NS::B::Two", FIELD, DECLARATIONS, true );
+
+ search( workspace, pattern, scope, resultCollector );
+
+ matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 1 );
+ }
+
}
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.161
diff -u -r1.161 ChangeLog
--- ChangeLog 4 Sep 2003 20:47:01 -0000 1.161
+++ ChangeLog 5 Sep 2003 17:46:27 -0000
@@ -1,3 +1,10 @@
+2003-09-05 Andrew Niefer
+ C++ Search:
+ - enable Selected Resource Scope
+ - populate dialog base on selection when opened from outline view
+ - fix small bug that found namespaces when searching for enumerations
+ - tweak sorting by path to consider line number second
+
2003-09-04 John Camelon
First pass of parsing function bodies with X-Reference information.
Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope
Index: src/org/eclipse/cdt/internal/ui/CPluginResources.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties,v
retrieving revision 1.18
diff -u -r1.18 CPluginResources.properties
--- src/org/eclipse/cdt/internal/ui/CPluginResources.properties 4 Sep 2003 17:38:57 -0000 1.18
+++ src/org/eclipse/cdt/internal/ui/CPluginResources.properties 5 Sep 2003 17:46:27 -0000
@@ -299,7 +299,7 @@
SearchForReferencesAction.description=Searches for references to name in workspace
# ------- SearchDialogAction ---------------
-SearchDialogAction.label=Dialog
+SearchDialogAction.label=C++ Search Dialog
SearchDialogAction.tooltip=Opens Search Dialog
SearchDialogAction.description=Opens Search Dialog
Index: src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java,v
retrieving revision 1.1
diff -u -r1.1 SearchDialogAction.java
--- src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java 20 Aug 2003 20:53:42 -0000 1.1
+++ src/org/eclipse/cdt/internal/ui/editor/SearchDialogAction.java 5 Sep 2003 17:46:27 -0000
@@ -43,7 +43,6 @@
if(provider instanceof CContentOutlinePage) {
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
- setText("Dialog"); // $NON-NLS
}
fSelectionProvider= provider;
Index: src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java,v
retrieving revision 1.6
diff -u -r1.6 CSearchOperation.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java 4 Sep 2003 14:13:02 -0000 1.6
+++ src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java 5 Sep 2003 17:46:27 -0000
@@ -17,7 +17,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchScope;
@@ -38,12 +37,6 @@
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class CSearchOperation extends WorkspaceModifyOperation implements ICSearchConstants{
-
- public CSearchOperation(IWorkspace workspace, ICElement element, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector) {
- this( workspace, limitTo, scope, scopeDescription, collector );
- _elementPattern = element;
- }
-
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;
@@ -69,27 +62,23 @@
_collector.setProgressMonitor( monitor );
SearchEngine engine = new SearchEngine( CUIPlugin.getSharedWorkingCopies() );
- if( _elementPattern != null ){
- engine.search( _workspace, _elementPattern, _limitTo, _scope, _collector );
- } else {
- 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 );
+
+ 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 ) );
}
- engine.search( _workspace, pattern, _scope, _collector );
+ pattern = orPattern;
+
+ } else {
+ Iterator iter = _searchFor.iterator();
+ pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive );
}
-
+
+ engine.search( _workspace, pattern, _scope, _collector );
}
/**
@@ -98,11 +87,11 @@
public String getSingularLabel() {
String desc = null;
- if( _elementPattern != null ){
- desc = _elementPattern.getElementName();
- } else {
+ //if( _elementPattern != null ){
+ // desc = _elementPattern.getElementName();
+ //} else {
desc = _stringPattern;
- }
+ //}
String [] args = new String [] { desc, _scopeDescription };
@@ -111,7 +100,7 @@
} else if( _limitTo == REFERENCES ){
return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$
} else {
- return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurencesPostfix", args ); //$NON_NLS-1$
+ return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurrencesPostfix", args ); //$NON_NLS-1$
}
}
@@ -121,11 +110,11 @@
public String getPluralLabelPattern() {
String desc = null;
- if( _elementPattern != null ){
- desc = _elementPattern.getElementName();
- } else {
+ // if( _elementPattern != null ){
+ // desc = _elementPattern.getElementName();
+ // } else {
desc = _stringPattern;
- }
+ // }
String [] args = new String [] { desc, "{0}", _scopeDescription };
if( _limitTo == DECLARATIONS ){
@@ -133,7 +122,7 @@
} else if ( _limitTo == REFERENCES ){
return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$
} else {
- return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurencesPostfix", args ); //$NON_NLS-1$
+ return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurrencesPostfix", args ); //$NON_NLS-1$
}
}
@@ -150,7 +139,7 @@
private CSearchResultCollector _collector;
private IWorkspace _workspace;
- private ICElement _elementPattern;
+ //private ICElement _elementPattern;
private ICSearchScope _scope;
private String _stringPattern;
private String _scopeDescription;
Index: src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java,v
retrieving revision 1.6
diff -u -r1.6 CSearchPage.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchPage.java 4 Sep 2003 14:13:02 -0000 1.6
+++ src/org/eclipse/cdt/internal/ui/search/CSearchPage.java 5 Sep 2003 17:46:27 -0000
@@ -35,6 +35,7 @@
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.search.internal.ui.util.RowLayouter;
@@ -103,14 +104,14 @@
CSearchResultCollector collector= new CSearchResultCollector();
CSearchOperation op = null;
- if (data.cElement != null && getPattern().equals(fInitialData.pattern)) {
- op = new CSearchOperation(workspace, data.cElement, data.limitTo, scope, scopeDescription, collector);
- if (data.limitTo == ICSearchConstants.REFERENCES)
- CSearchUtil.warnIfBinaryConstant(data.cElement, getShell());
- } else {
+// if (data.cElement != null && getPattern().equals(fInitialData.pattern)) {
+// op = new CSearchOperation(workspace, data.cElement, data.limitTo, scope, scopeDescription, collector);
+// if (data.limitTo == ICSearchConstants.REFERENCES)
+// CSearchUtil.warnIfBinaryConstant(data.cElement, getShell());
+// } else {
data.cElement= null;
op = new CSearchOperation(workspace, data.pattern, data.isCaseSensitive, data.searchFor, data.limitTo, scope, scopeDescription, collector);
- }
+ //}
try {
getContainer().getRunnableContext().run(true, true, op);
@@ -484,6 +485,7 @@
patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;
return patterns;
}
+
private IStructuredSelection asStructuredSelection() {
IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (wbWindow != null) {
@@ -491,10 +493,13 @@
if (page != null) {
IWorkbenchPart part= page.getActivePart();
if (part != null){
- //try {
- // return SelectionConverter.getStructuredSelection(part);
- //} catch (JavaModelException ex) {
- //}
+ ISelectionProvider provider = part.getSite().getSelectionProvider();
+ if( provider != null ){
+ ISelection selection = provider.getSelection();
+ if( selection instanceof IStructuredSelection ){
+ return (IStructuredSelection)selection;
+ }
+ }
}
}
}
@@ -504,23 +509,31 @@
private SearchPatternData determineInitValuesFrom( ICElement element ) {
if( element == null )
return null;
- //TODO search pattern data from element
-// SearchFor searchFor = UNKNOWN_SEARCH_FOR;
-// LimitTo limitTo = UNKNOWN_LIMIT_TO;
-//
-// String pattern = null;
-// switch( element.getElementType() ) {
-// /*case ICElement.PACKAGE_FRAGMENT:
-// searchFor= PACKAGE;
-// limitTo= REFERENCES;
-// pattern= element.getElementName();
-// break;*/
-// }
-//
-// if( searchFor != UNKNOWN_SEARCH_FOR && limitTo != UNKNOWN_LIMIT_TO && pattern != null )
-// return new SearchPatternData( searchFor, limitTo, true, pattern, element );
-//
- return null;
+
+ List searchFor = new LinkedList();
+
+ //outliune view will confuse methods with functions, so if the
+ //name contains a "::", treat it as a method
+ String pattern = element.getElementName();
+ boolean forceMethod = ( pattern.indexOf("::") != -1 );
+
+ switch ( element.getElementType() ){
+ case ICElement.C_FUNCTION: if( forceMethod ) searchFor.add( METHOD );
+ else searchFor.add( FUNCTION );
+ break;
+ case ICElement.C_VARIABLE: searchFor.add( VAR ); break;
+ case ICElement.C_STRUCT: /* fall through to CLASS */
+ case ICElement.C_CLASS: searchFor.add( CLASS_STRUCT ); break;
+ case ICElement.C_UNION: searchFor.add( UNION ); break;
+ case ICElement.C_ENUMERATOR: /* fall through to FIELD */
+ case ICElement.C_FIELD: searchFor.add( FIELD ); break;
+ case ICElement.C_METHOD: searchFor.add( METHOD ); break;
+ case ICElement.C_NAMESPACE: searchFor.add( NAMESPACE ); break;
+ }
+
+ LimitTo limitTo = ALL_OCCURRENCES;
+
+ return new SearchPatternData( searchFor, limitTo, true, pattern, element );
}
private SearchPatternData getPatternData() {
@@ -587,7 +600,7 @@
private static List fgPreviousSearchPatterns = new ArrayList(20);
private Button[] fSearchFor;
- private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, NAMESPACE, ENUM, null };
+ private SearchFor[] fSearchForValues = { CLASS_STRUCT, FUNCTION, VAR, UNION, METHOD, FIELD, ENUM, NAMESPACE, null };
private String[] fSearchForText= {
CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$
Index: src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java,v
retrieving revision 1.8
diff -u -r1.8 CSearchResultCollector.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java 1 Aug 2003 19:26:58 -0000 1.8
+++ src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java 5 Sep 2003 17:46:28 -0000
@@ -55,7 +55,7 @@
_view = SearchUI.getSearchResultView();
CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider();
- labelProvider.setOrder( CSearchResultLabelProvider.SHOW_ELEMENT_CONTAINER );
+ labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH );
if( _view != null ){
_view.searchStarted(
Index: src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java,v
retrieving revision 1.2
diff -u -r1.2 CSearchScopeFactory.java
--- src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java 11 Aug 2003 13:42:55 -0000 1.2
+++ src/org/eclipse/cdt/internal/ui/search/CSearchScopeFactory.java 5 Sep 2003 17:46:28 -0000
@@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.ui.search;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import org.eclipse.cdt.core.model.ICElement;
@@ -105,8 +106,14 @@
* @return
*/
public ICSearchScope createCSearchScope(IStructuredSelection fStructuredSelection) {
- // TODO Auto-generated method stub
- return null;
+ Set cElements = new HashSet( fStructuredSelection.size() );
+
+ Iterator iter = fStructuredSelection.iterator();
+ while( iter.hasNext() ){
+ addCElements( cElements, (IAdaptable)iter.next() );
+ }
+
+ return createCSearchScope( cElements );
}
}
Index: src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java,v
retrieving revision 1.3
diff -u -r1.3 PathNameSorter.java
--- src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java 11 Aug 2003 13:48:39 -0000 1.3
+++ src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java 5 Sep 2003 17:46:28 -0000
@@ -13,8 +13,9 @@
*/
package org.eclipse.cdt.internal.ui.search;
+import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.ui.CSearchResultLabelProvider;
-import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
@@ -38,14 +39,25 @@
String name2 = null;
ISearchResultViewEntry entry1 = null;
ISearchResultViewEntry entry2 = null;
+ IMatch match1 = null;
+ IMatch match2 = null;
if( e1 instanceof ISearchResultViewEntry ) {
entry1 = (ISearchResultViewEntry)e1;
- name1 = _labelProvider.getText( e1 );
+ try {
+ match1 = (IMatch)entry1.getSelectedMarker().getAttribute( CSearchResultCollector.IMATCH );
+ } catch (CoreException e) {
+ }
+ name1 = match1.getLocation().toString();
}
if( e2 instanceof ISearchResultViewEntry ) {
entry2 = (ISearchResultViewEntry)e2;
- name2 = _labelProvider.getText( e2 );
+ try {
+ match2 = (IMatch)entry2.getSelectedMarker().getAttribute( CSearchResultCollector.IMATCH );
+ } catch (CoreException e) {
+ }
+ //name2 = _labelProvider.getText( e2 );
+ name2 = match2.getLocation().toString();
}
if( name1 == null )
@@ -59,13 +71,11 @@
if( compare == 0 ){
int startPos1 = -1;
int startPos2 = -1;
- IMarker marker1 = entry1.getSelectedMarker();
- IMarker marker2 = entry2.getSelectedMarker();
-
- if (marker1 != null)
- startPos1 = marker1.getAttribute( IMarker.CHAR_START, -1 );
- if (marker2 != null)
- startPos2 = marker2.getAttribute( IMarker.CHAR_START, -1 );
+
+ if (match1 != null)
+ startPos1 = match1.getStartOffset();
+ if (match2 != null)
+ startPos2 = match2.getStartOffset();
compare = startPos1 - startPos2;
}