1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-12 10:45:37 +02:00

Patch for Andrew Niefer

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
This commit is contained in:
John Camelon 2003-09-05 18:31:52 +00:00
parent 4a6ab5ef38
commit d1d3dec2fe
16 changed files with 170 additions and 100 deletions

View file

@ -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 2003-09-05 John Camelon
Updated CompleteParseASTTest::testSimpleForLoop() Updated CompleteParseASTTest::testSimpleForLoop()

View file

@ -16,7 +16,11 @@ namespace NS {
} }
class B: public A { class B: public A {
struct AA {}; struct AA {};
enum e {}; enum e {
One,
Two,
Three
};
using namespace NS2; using namespace NS2;

View file

@ -176,4 +176,21 @@ public class OtherPatternTests extends BaseSearchTest {
Set matches = resultCollector.getSearchResults(); Set matches = resultCollector.getSearchResults();
assertEquals( matches.size(), 1 ); 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 );
}
} }

View file

@ -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 2003-08-26 Bogdan Gheorghe
- Removed header file extensions from being indexed (they - Removed header file extensions from being indexed (they
will be indexed via inclusion) will be indexed via inclusion)

View file

@ -78,11 +78,14 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
String name = en.getName(); String name = en.getName();
IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier(); IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
String[] parentName = parent.getFullyQualifiedName(); String[] parentName = parent.getFullyQualifiedName();
String[] enumeratorFullName = new String[parentName.length + 1];
int pos; //See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
System.arraycopy(parentName, 0, enumeratorFullName, 0, pos = parentName.length); String[] enumeratorFullName = new String[ parentName.length ];
enumeratorFullName[pos++] = name;
this.output.addRef(encodeEntry(enumeratorFullName,FIELD_DECL,FIELD_DECL_LENGTH)); System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
enumeratorFullName[ parentName.length - 1 ] = name;
this.output.addRef(encodeEntry( enumeratorFullName, FIELD_DECL, FIELD_DECL_LENGTH ));
} }
} }

View file

@ -1,3 +1,6 @@
2003-09-05 Andrew Niefer
- fix searching for enumerators
2003-09-03 Andrew Niefer 2003-09-03 Andrew Niefer
- added CLASS_STRUCT to the SearchFor constants - added CLASS_STRUCT to the SearchFor constants
- Modified CSearchPattern to handle CLASS_STRUCT - Modified CSearchPattern to handle CLASS_STRUCT

View file

@ -163,17 +163,4 @@ public class SearchEngine implements ICSearchConstants{
collector.done(); 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
}
} }

View file

@ -16,6 +16,8 @@ package org.eclipse.cdt.internal.core.search.matching;
import java.io.IOException; import java.io.IOException;
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate; 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.IASTField;
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement; import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement; import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
@ -59,6 +61,9 @@ public class FieldDeclarationPattern extends CSearchPattern {
} else if ( node instanceof IASTVariable ){ } else if ( node instanceof IASTVariable ){
if( searchFor != VAR || !canAccept( limit ) ) if( searchFor != VAR || !canAccept( limit ) )
return IMPOSSIBLE_MATCH; return IMPOSSIBLE_MATCH;
} else if ( node instanceof IASTEnumerator ){
if( searchFor != FIELD || !canAccept( limit ) )
return IMPOSSIBLE_MATCH;
} else return IMPOSSIBLE_MATCH; } else return IMPOSSIBLE_MATCH;
String nodeName = ((IASTOffsetableNamedElement)node).getName(); String nodeName = ((IASTOffsetableNamedElement)node).getName();
@ -70,7 +75,26 @@ public class FieldDeclarationPattern extends CSearchPattern {
//check containing scopes //check containing scopes
//create char[][] out of full name, //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 ][]; char [][] qualName = new char [ fullName.length - 1 ][];
for( int i = 0; i < fullName.length - 1; i++ ){ for( int i = 0; i < fullName.length - 1; i++ ){
qualName[i] = fullName[i].toCharArray(); qualName[i] = fullName[i].toCharArray();

View file

@ -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 2003-09-04 John Camelon
First pass of parsing function bodies with X-Reference information. First pass of parsing function bodies with X-Reference information.
Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope Updated IASTFactory/ISourceElementRequestor to include IASTCodeScope

View file

@ -299,7 +299,7 @@ SearchForReferencesAction.tooltip=Search for References to Name in Workspace
SearchForReferencesAction.description=Searches for references to name in workspace SearchForReferencesAction.description=Searches for references to name in workspace
# ------- SearchDialogAction --------------- # ------- SearchDialogAction ---------------
SearchDialogAction.label=Dialog SearchDialogAction.label=C++ Search Dialog
SearchDialogAction.tooltip=Opens Search Dialog SearchDialogAction.tooltip=Opens Search Dialog
SearchDialogAction.description=Opens Search Dialog SearchDialogAction.description=Opens Search Dialog

View file

@ -43,7 +43,6 @@ public class SearchDialogAction extends Action {
if(provider instanceof CContentOutlinePage) { if(provider instanceof CContentOutlinePage) {
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE); CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
setText("Dialog"); // $NON-NLS
} }
fSelectionProvider= provider; fSelectionProvider= provider;

View file

@ -17,7 +17,6 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchPattern; import org.eclipse.cdt.core.search.ICSearchPattern;
import org.eclipse.cdt.core.search.ICSearchScope; import org.eclipse.cdt.core.search.ICSearchScope;
@ -38,12 +37,6 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
* Window>Preferences>Java>Code Generation>Code and Comments * Window>Preferences>Java>Code Generation>Code and Comments
*/ */
public class CSearchOperation extends WorkspaceModifyOperation implements ICSearchConstants{ 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) { public CSearchOperation(IWorkspace workspace, String pattern, boolean caseSensitive, List searchFor, LimitTo limitTo, ICSearchScope scope, String scopeDescription, CSearchResultCollector collector) {
this( workspace, limitTo, scope, scopeDescription, collector ); this( workspace, limitTo, scope, scopeDescription, collector );
_stringPattern = pattern; _stringPattern = pattern;
@ -69,27 +62,23 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
_collector.setProgressMonitor( monitor ); _collector.setProgressMonitor( monitor );
SearchEngine engine = new SearchEngine( CUIPlugin.getSharedWorkingCopies() ); 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; ICSearchPattern pattern = null;
if( _searchFor.size() > 1 ){
} else { OrPattern orPattern = new OrPattern();
Iterator iter = _searchFor.iterator(); for (Iterator iter = _searchFor.iterator(); iter.hasNext();) {
pattern = SearchEngine.createSearchPattern( _stringPattern, (SearchFor)iter.next(), _limitTo, _caseSensitive ); 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 class CSearchOperation extends WorkspaceModifyOperation implements ICSear
public String getSingularLabel() { public String getSingularLabel() {
String desc = null; String desc = null;
if( _elementPattern != null ){ //if( _elementPattern != null ){
desc = _elementPattern.getElementName(); // desc = _elementPattern.getElementName();
} else { //} else {
desc = _stringPattern; desc = _stringPattern;
} //}
String [] args = new String [] { desc, _scopeDescription }; String [] args = new String [] { desc, _scopeDescription };
@ -111,7 +100,7 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
} else if( _limitTo == REFERENCES ){ } else if( _limitTo == REFERENCES ){
return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$ return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$
} else { } else {
return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurencesPostfix", args ); //$NON_NLS-1$ return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurrencesPostfix", args ); //$NON_NLS-1$
} }
} }
@ -121,11 +110,11 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
public String getPluralLabelPattern() { public String getPluralLabelPattern() {
String desc = null; String desc = null;
if( _elementPattern != null ){ // if( _elementPattern != null ){
desc = _elementPattern.getElementName(); // desc = _elementPattern.getElementName();
} else { // } else {
desc = _stringPattern; desc = _stringPattern;
} // }
String [] args = new String [] { desc, "{0}", _scopeDescription }; String [] args = new String [] { desc, "{0}", _scopeDescription };
if( _limitTo == DECLARATIONS ){ if( _limitTo == DECLARATIONS ){
@ -133,7 +122,7 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
} else if ( _limitTo == REFERENCES ){ } else if ( _limitTo == REFERENCES ){
return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$ return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$
} else { } else {
return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurencesPostfix", args ); //$NON_NLS-1$ return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurrencesPostfix", args ); //$NON_NLS-1$
} }
} }
@ -150,7 +139,7 @@ public class CSearchOperation extends WorkspaceModifyOperation implements ICSear
private CSearchResultCollector _collector; private CSearchResultCollector _collector;
private IWorkspace _workspace; private IWorkspace _workspace;
private ICElement _elementPattern; //private ICElement _elementPattern;
private ICSearchScope _scope; private ICSearchScope _scope;
private String _stringPattern; private String _stringPattern;
private String _scopeDescription; private String _scopeDescription;

View file

@ -35,6 +35,7 @@ import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IDialogSettings;
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.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.search.internal.ui.util.RowLayouter; import org.eclipse.search.internal.ui.util.RowLayouter;
@ -103,14 +104,14 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
CSearchResultCollector collector= new CSearchResultCollector(); CSearchResultCollector collector= new CSearchResultCollector();
CSearchOperation op = null; CSearchOperation op = null;
if (data.cElement != null && getPattern().equals(fInitialData.pattern)) { // if (data.cElement != null && getPattern().equals(fInitialData.pattern)) {
op = new CSearchOperation(workspace, data.cElement, data.limitTo, scope, scopeDescription, collector); // op = new CSearchOperation(workspace, data.cElement, data.limitTo, scope, scopeDescription, collector);
if (data.limitTo == ICSearchConstants.REFERENCES) // if (data.limitTo == ICSearchConstants.REFERENCES)
CSearchUtil.warnIfBinaryConstant(data.cElement, getShell()); // CSearchUtil.warnIfBinaryConstant(data.cElement, getShell());
} else { // } else {
data.cElement= null; data.cElement= null;
op = new CSearchOperation(workspace, data.pattern, data.isCaseSensitive, data.searchFor, data.limitTo, scope, scopeDescription, collector); op = new CSearchOperation(workspace, data.pattern, data.isCaseSensitive, data.searchFor, data.limitTo, scope, scopeDescription, collector);
} //}
try { try {
getContainer().getRunnableContext().run(true, true, op); getContainer().getRunnableContext().run(true, true, op);
@ -484,6 +485,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern; patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;
return patterns; return patterns;
} }
private IStructuredSelection asStructuredSelection() { private IStructuredSelection asStructuredSelection() {
IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (wbWindow != null) { if (wbWindow != null) {
@ -491,10 +493,13 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
if (page != null) { if (page != null) {
IWorkbenchPart part= page.getActivePart(); IWorkbenchPart part= page.getActivePart();
if (part != null){ if (part != null){
//try { ISelectionProvider provider = part.getSite().getSelectionProvider();
// return SelectionConverter.getStructuredSelection(part); if( provider != null ){
//} catch (JavaModelException ex) { ISelection selection = provider.getSelection();
//} if( selection instanceof IStructuredSelection ){
return (IStructuredSelection)selection;
}
}
} }
} }
} }
@ -504,23 +509,31 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
private SearchPatternData determineInitValuesFrom( ICElement element ) { private SearchPatternData determineInitValuesFrom( ICElement element ) {
if( element == null ) if( element == null )
return null; return null;
//TODO search pattern data from element
// SearchFor searchFor = UNKNOWN_SEARCH_FOR; List searchFor = new LinkedList();
// LimitTo limitTo = UNKNOWN_LIMIT_TO;
// //outliune view will confuse methods with functions, so if the
// String pattern = null; //name contains a "::", treat it as a method
// switch( element.getElementType() ) { String pattern = element.getElementName();
// /*case ICElement.PACKAGE_FRAGMENT: boolean forceMethod = ( pattern.indexOf("::") != -1 );
// searchFor= PACKAGE;
// limitTo= REFERENCES; switch ( element.getElementType() ){
// pattern= element.getElementName(); case ICElement.C_FUNCTION: if( forceMethod ) searchFor.add( METHOD );
// break;*/ else searchFor.add( FUNCTION );
// } break;
// case ICElement.C_VARIABLE: searchFor.add( VAR ); break;
// if( searchFor != UNKNOWN_SEARCH_FOR && limitTo != UNKNOWN_LIMIT_TO && pattern != null ) case ICElement.C_STRUCT: /* fall through to CLASS */
// return new SearchPatternData( searchFor, limitTo, true, pattern, element ); case ICElement.C_CLASS: searchFor.add( CLASS_STRUCT ); break;
// case ICElement.C_UNION: searchFor.add( UNION ); break;
return null; 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() { private SearchPatternData getPatternData() {
@ -587,7 +600,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
private static List fgPreviousSearchPatterns = new ArrayList(20); private static List fgPreviousSearchPatterns = new ArrayList(20);
private Button[] fSearchFor; 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= { private String[] fSearchForText= {
CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$ CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$

View file

@ -55,7 +55,7 @@ public class CSearchResultCollector extends BasicSearchResultCollector{
_view = SearchUI.getSearchResultView(); _view = SearchUI.getSearchResultView();
CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider(); CSearchResultLabelProvider labelProvider = new CSearchResultLabelProvider();
labelProvider.setOrder( CSearchResultLabelProvider.SHOW_ELEMENT_CONTAINER ); labelProvider.setOrder( CSearchResultLabelProvider.SHOW_PATH );
if( _view != null ){ if( _view != null ){
_view.searchStarted( _view.searchStarted(

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
@ -105,8 +106,14 @@ public class CSearchScopeFactory {
* @return * @return
*/ */
public ICSearchScope createCSearchScope(IStructuredSelection fStructuredSelection) { public ICSearchScope createCSearchScope(IStructuredSelection fStructuredSelection) {
// TODO Auto-generated method stub Set cElements = new HashSet( fStructuredSelection.size() );
return null;
Iterator iter = fStructuredSelection.iterator();
while( iter.hasNext() ){
addCElements( cElements, (IAdaptable)iter.next() );
}
return createCSearchScope( cElements );
} }
} }

View file

@ -13,8 +13,9 @@
*/ */
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.ui.CSearchResultLabelProvider; 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.ILabelProvider;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.viewers.ViewerSorter;
@ -38,14 +39,25 @@ public class PathNameSorter extends ViewerSorter {
String name2 = null; String name2 = null;
ISearchResultViewEntry entry1 = null; ISearchResultViewEntry entry1 = null;
ISearchResultViewEntry entry2 = null; ISearchResultViewEntry entry2 = null;
IMatch match1 = null;
IMatch match2 = null;
if( e1 instanceof ISearchResultViewEntry ) { if( e1 instanceof ISearchResultViewEntry ) {
entry1 = (ISearchResultViewEntry)e1; 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 ) { if( e2 instanceof ISearchResultViewEntry ) {
entry2 = (ISearchResultViewEntry)e2; 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 ) if( name1 == null )
@ -59,13 +71,11 @@ public class PathNameSorter extends ViewerSorter {
if( compare == 0 ){ if( compare == 0 ){
int startPos1 = -1; int startPos1 = -1;
int startPos2 = -1; int startPos2 = -1;
IMarker marker1 = entry1.getSelectedMarker();
IMarker marker2 = entry2.getSelectedMarker();
if (marker1 != null) if (match1 != null)
startPos1 = marker1.getAttribute( IMarker.CHAR_START, -1 ); startPos1 = match1.getStartOffset();
if (marker2 != null) if (match2 != null)
startPos2 = marker2.getAttribute( IMarker.CHAR_START, -1 ); startPos2 = match2.getStartOffset();
compare = startPos1 - startPos2; compare = startPos1 - startPos2;
} }