mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Andrew Niefer
Further work on C/C++ Search framework.
This commit is contained in:
parent
c4df8f4e6f
commit
6fa5a87930
26 changed files with 1449 additions and 375 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
2003-06-27 Andrew Niefer
|
||||||
|
Modified:
|
||||||
|
search/org.eclipse.cdt.core.search.matching/MatchLocator.java
|
||||||
|
- enter/exitInclusion
|
||||||
|
- enterClassSpecifier
|
||||||
|
search/org.eclipse.cdt.core.search.matching/CSearchPattern.java
|
||||||
|
- createClassPattern
|
||||||
|
- matchesName
|
||||||
|
search/org.eclipse.cdt.core.search.matching/ClassDeclarationPattern.java
|
||||||
|
- matchLevel
|
||||||
|
search/org.eclipse.cdt.core.search/ICSearchPattern.java
|
||||||
|
search/org.eclipse.cdt.core.search/ICSearchResultCollector.java
|
||||||
|
search/org.eclipse.cdt.core.search/SearchEngine.java
|
||||||
|
|
||||||
2003-06-25 Bogdan Gheorghe
|
2003-06-25 Bogdan Gheorghe
|
||||||
|
|
||||||
Modified:
|
Modified:
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search;
|
package org.eclipse.cdt.core.search;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*
|
*
|
||||||
|
@ -21,4 +23,15 @@ package org.eclipse.cdt.core.search;
|
||||||
*/
|
*/
|
||||||
public interface ICSearchPattern {
|
public interface ICSearchPattern {
|
||||||
|
|
||||||
|
public static final int IMPOSSIBLE_MATCH = 0;
|
||||||
|
public static final int POSSIBLE_MATCH = 1;
|
||||||
|
public static final int ACCURATE_MATCH = 2;
|
||||||
|
public static final int INACCURATE_MATCH = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param node
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int matchLevel( IASTOffsetableElement node );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.core.search;
|
package org.eclipse.cdt.core.search;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -59,9 +60,10 @@ public interface ICSearchResultCollector {
|
||||||
IResource resource,
|
IResource resource,
|
||||||
int start,
|
int start,
|
||||||
int end,
|
int end,
|
||||||
/*IJavaElement*/ Object enclosingElement,
|
ICElement enclosingElement,
|
||||||
int accuracy)
|
int accuracy)
|
||||||
throws CoreException;
|
throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the search has ended.
|
* Called when the search has ended.
|
||||||
*/
|
*/
|
||||||
|
@ -72,4 +74,5 @@ public interface ICSearchResultCollector {
|
||||||
* @return a progress monitor or null if no progress monitor is provided
|
* @return a progress monitor or null if no progress monitor is provided
|
||||||
*/
|
*/
|
||||||
public IProgressMonitor getProgressMonitor();
|
public IProgressMonitor getProgressMonitor();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,16 @@
|
||||||
package org.eclipse.cdt.core.search;
|
package org.eclipse.cdt.core.search;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexManager;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
|
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
|
||||||
import org.eclipse.cdt.internal.core.search.Util;
|
import org.eclipse.cdt.internal.core.search.Util;
|
||||||
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
|
||||||
|
import org.eclipse.cdt.internal.core.search.matching.MatchLocator;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -94,9 +98,23 @@ public class SearchEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
CModelManager modelManager = CModelManager.getDefault();
|
CModelManager modelManager = CModelManager.getDefault();
|
||||||
IndexManager indexManager = null; //modelManager.getIndexManager();
|
IndexManager indexManager = modelManager.getIndexManager();
|
||||||
|
|
||||||
|
SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
|
||||||
|
|
||||||
|
indexManager.performConcurrentJob(
|
||||||
|
new PatternSearchJob(),
|
||||||
|
ICSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
|
||||||
|
subMonitor );
|
||||||
|
|
||||||
|
subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 95 );
|
||||||
|
|
||||||
|
MatchLocator matchLocator = new MatchLocator( pattern, collector, scope, subMonitor );
|
||||||
|
|
||||||
|
if( progressMonitor != null && progressMonitor.isCanceled() )
|
||||||
|
throw new OperationCanceledException();
|
||||||
|
|
||||||
|
//matchLocator.locateMatches( pathCollector.getPaths(), workspace, workingCopies );
|
||||||
} finally {
|
} finally {
|
||||||
collector.done();
|
collector.done();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,18 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.search.matching;
|
package org.eclipse.cdt.internal.core.search.matching;
|
||||||
|
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.EndOfFile;
|
||||||
|
import org.eclipse.cdt.core.parser.IScanner;
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
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.internal.core.search.CharOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -22,8 +32,12 @@ import org.eclipse.cdt.core.search.ICSearchPattern;
|
||||||
* To change the template for this generated type comment go to
|
* To change the template for this generated type comment go to
|
||||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
*/
|
*/
|
||||||
public abstract class CSearchPattern
|
public abstract class CSearchPattern implements ICSearchConstants, ICSearchPattern {
|
||||||
implements ICSearchConstants, ICSearchPattern {
|
|
||||||
|
public static final int IMPOSSIBLE_MATCH = 0;
|
||||||
|
public static final int POSSIBLE_MATCH = 1;
|
||||||
|
public static final int ACCURATE_MATCH = 2;
|
||||||
|
public static final int INACCURATE_MATCH = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param matchMode
|
* @param matchMode
|
||||||
|
@ -50,7 +64,7 @@ public abstract class CSearchPattern
|
||||||
CSearchPattern pattern = null;
|
CSearchPattern pattern = null;
|
||||||
switch( searchFor ){
|
switch( searchFor ){
|
||||||
case ICSearchConstants.TYPE:
|
case ICSearchConstants.TYPE:
|
||||||
pattern = createTypePattern( patternString, limitTo, matchMode, caseSensitive );
|
pattern = createClassPattern( patternString, limitTo, matchMode, caseSensitive );
|
||||||
break;
|
break;
|
||||||
//case ICSearchConstants.METHOD:
|
//case ICSearchConstants.METHOD:
|
||||||
// pattern = createMethodPattern( patternString, limitTo, matchMode, caseSensitive );
|
// pattern = createMethodPattern( patternString, limitTo, matchMode, caseSensitive );
|
||||||
|
@ -109,9 +123,33 @@ public abstract class CSearchPattern
|
||||||
* @param caseSensitive
|
* @param caseSensitive
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static CSearchPattern createTypePattern(String patternString, int limitTo, int matchMode, boolean caseSensitive) {
|
private static CSearchPattern createClassPattern(String patternString, int limitTo, int matchMode, boolean caseSensitive) {
|
||||||
// TODO Auto-generated method stub
|
IScanner scanner = ParserFactory.createScanner( new StringReader( patternString ), "TEXT", null, null, ParserMode.QUICK_PARSE );
|
||||||
return null;
|
|
||||||
|
LinkedList list = new LinkedList();
|
||||||
|
IToken token = null;
|
||||||
|
String name = new String("");
|
||||||
|
|
||||||
|
try {
|
||||||
|
while( true ){
|
||||||
|
token = scanner.nextToken();
|
||||||
|
|
||||||
|
switch( token.getType() ){
|
||||||
|
case IToken.tCOLONCOLON :
|
||||||
|
list.addLast( name.toCharArray() );
|
||||||
|
name = new String("");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name += token.getImage();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (EndOfFile e) {
|
||||||
|
} catch (ScannerException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
char [][] qualifications = new char[1][];
|
||||||
|
return new ClassDeclarationPattern( name.toCharArray(), (char[][])list.toArray( qualifications ), null, matchMode, caseSensitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean matchesName( char[] pattern, char[] name ){
|
protected boolean matchesName( char[] pattern, char[] name ){
|
||||||
|
@ -122,14 +160,15 @@ public abstract class CSearchPattern
|
||||||
if( name != null ){
|
if( name != null ){
|
||||||
switch( _matchMode ){
|
switch( _matchMode ){
|
||||||
case EXACT_MATCH:
|
case EXACT_MATCH:
|
||||||
//return CharOperation.equals( pattern, name, _caseSensitive );
|
return CharOperation.equals( pattern, name, _caseSensitive );
|
||||||
case PREFIX_MATCH:
|
case PREFIX_MATCH:
|
||||||
//return CharOperation.prefixEquals( pattern, name, _caseSensitive );
|
return CharOperation.prefixEquals( pattern, name, _caseSensitive );
|
||||||
case PATTERN_MATCH:
|
case PATTERN_MATCH:
|
||||||
if( !_caseSensitive ){
|
if( !_caseSensitive ){
|
||||||
//pattern = CharOperation.toLowerCase( pattern );
|
pattern = CharOperation.toLowerCase( pattern );
|
||||||
}
|
}
|
||||||
//return CharOperation.match( pattern, name, _caseSensitive );
|
|
||||||
|
return CharOperation.match( pattern, name, _caseSensitive );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.search.matching;
|
package org.eclipse.cdt.internal.core.search.matching;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ClassKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTOffsetableElement;
|
||||||
|
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*
|
*
|
||||||
|
@ -25,5 +30,54 @@ public class ClassDeclarationPattern extends CSearchPattern {
|
||||||
super( matchMode, caseSensitive );
|
super( matchMode, caseSensitive );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassDeclarationPattern( char[] name, char[][] containers, ClassKind kind, int mode, boolean caseSensitive ){
|
||||||
|
super( mode, caseSensitive );
|
||||||
|
simpleName = caseSensitive ? name : CharOperation.toLowerCase( name );
|
||||||
|
if( caseSensitive || containers == null ){
|
||||||
|
containingTypes = containers;
|
||||||
|
} else {
|
||||||
|
int len = containers.length;
|
||||||
|
this.containingTypes = new char[ len ][];
|
||||||
|
for( int i = 0; i < len; i++ ){
|
||||||
|
this.containingTypes[i] = CharOperation.toLowerCase( containers[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
classKind = kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int matchLevel( IASTOffsetableElement node ){
|
||||||
|
if( !( node instanceof IASTClassSpecifier ) )
|
||||||
|
return IMPOSSIBLE_MATCH;
|
||||||
|
|
||||||
|
IASTClassSpecifier clsSpec = (IASTClassSpecifier) node;
|
||||||
|
|
||||||
|
//check name, if simpleName == null, its treated the same as "*"
|
||||||
|
if( simpleName != null && !matchesName( simpleName, clsSpec.getName().toCharArray() ) ){
|
||||||
|
return IMPOSSIBLE_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check containing scopes
|
||||||
|
String [] qualifications = clsSpec.getFullyQualifiedName();
|
||||||
|
int size = containingTypes.length;
|
||||||
|
if( qualifications.length < size )
|
||||||
|
return IMPOSSIBLE_MATCH;
|
||||||
|
|
||||||
|
for( int i = 0; i < containingTypes.length; i++ ){
|
||||||
|
if( !matchesName( containingTypes[i], qualifications[i].toCharArray() ) ){
|
||||||
|
return IMPOSSIBLE_MATCH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check type
|
||||||
|
if( classKind != clsSpec.getClassKind() ){
|
||||||
|
return IMPOSSIBLE_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ACCURATE_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
private char[] simpleName;
|
||||||
|
private char[][] containingTypes;
|
||||||
|
private ClassKind classKind;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,23 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.search.matching;
|
package org.eclipse.cdt.internal.core.search.matching;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.*;
|
import org.eclipse.cdt.core.parser.ast.*;
|
||||||
|
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.internal.core.model.IWorkingCopy;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -25,309 +39,97 @@ import org.eclipse.cdt.core.parser.ast.*;
|
||||||
*/
|
*/
|
||||||
public class MatchLocator implements ISourceElementRequestor {
|
public class MatchLocator implements ISourceElementRequestor {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public MatchLocator() {
|
public MatchLocator( ICSearchPattern pattern, ICSearchResultCollector collector, ICSearchScope scope, IProgressMonitor monitor) {
|
||||||
super();
|
super();
|
||||||
// TODO Auto-generated constructor stub
|
searchPattern = pattern;
|
||||||
|
resultCollector = collector;
|
||||||
|
searchScope = scope;
|
||||||
|
progressMonitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void acceptProblem(IProblem problem) { }
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
|
public void acceptMacro(IASTMacro macro) { }
|
||||||
*/
|
public void acceptVariable(IASTVariable variable) { }
|
||||||
public void acceptProblem(IProblem problem) {
|
public void acceptFunctionDeclaration(IASTFunction function) { }
|
||||||
// TODO Auto-generated method stub
|
public void acceptUsingDirective(IASTUsingDirective usageDirective) { }
|
||||||
|
public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) { }
|
||||||
|
public void acceptASMDefinition(IASTASMDefinition asmDefinition) { }
|
||||||
|
public void acceptTypedef(IASTTypedef typedef) { }
|
||||||
|
public void acceptEnumerator(IASTEnumerator enumerator) { }
|
||||||
|
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration){ }
|
||||||
|
public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) { }
|
||||||
|
public void acceptElaboratedTypeSpecifier(IASTElaboratedTypeSpecifier elaboratedTypeSpec){ }
|
||||||
|
public void acceptMethodDeclaration(IASTMethod method) { }
|
||||||
|
public void acceptField(IASTField field) { }
|
||||||
|
public void acceptConstructor(IASTConstructor constructor) { }
|
||||||
|
public void enterFunctionBody(IASTFunction function) { }
|
||||||
|
public void enterCompilationUnit(IASTCompilationUnit compilationUnit) { }
|
||||||
|
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) { }
|
||||||
|
public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) { }
|
||||||
|
public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) { }
|
||||||
|
public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) { }
|
||||||
|
public void enterTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) { }
|
||||||
|
public void enterMethodBody(IASTMethod method) { }
|
||||||
|
public void exitFunctionBody(IASTFunction function) { }
|
||||||
|
public void exitMethodBody(IASTMethod method) { }
|
||||||
|
public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) { }
|
||||||
|
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) { }
|
||||||
|
public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) { }
|
||||||
|
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) { }
|
||||||
|
public void exitClassSpecifier(IASTClassSpecifier classSpecification) { }
|
||||||
|
public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) { }
|
||||||
|
public void exitCompilationUnit(IASTCompilationUnit compilationUnit) { }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
|
|
||||||
*/
|
|
||||||
public void acceptMacro(IASTMacro macro) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
|
|
||||||
*/
|
|
||||||
public void acceptVariable(IASTVariable variable) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
|
||||||
*/
|
|
||||||
public void acceptFunctionDeclaration(IASTFunction function) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDirective(org.eclipse.cdt.core.parser.ast.IASTUsingDirective)
|
|
||||||
*/
|
|
||||||
public void acceptUsingDirective(IASTUsingDirective usageDirective) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration)
|
|
||||||
*/
|
|
||||||
public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
|
|
||||||
*/
|
|
||||||
public void acceptASMDefinition(IASTASMDefinition asmDefinition) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
|
|
||||||
*/
|
|
||||||
public void acceptTypedef(IASTTypedef typedef) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier)
|
|
||||||
*/
|
|
||||||
//public void enterEnumSpecifier(IASTEnumSpecifier enumSpec) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator)
|
|
||||||
*/
|
|
||||||
public void acceptEnumerator(IASTEnumerator enumerator) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier)
|
|
||||||
*/
|
|
||||||
//public void exitEnumSpecifier(IASTEnumSpecifier enumSpec) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
|
||||||
*/
|
|
||||||
public void enterFunctionBody(IASTFunction function) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
|
|
||||||
*/
|
|
||||||
public void exitFunctionBody(IASTFunction function) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
|
|
||||||
*/
|
|
||||||
public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
|
|
||||||
*/
|
|
||||||
public void enterInclusion(IASTInclusion inclusion) {
|
public void enterInclusion(IASTInclusion inclusion) {
|
||||||
// TODO Auto-generated method stub
|
String includePath = inclusion.getFullFileName();
|
||||||
|
|
||||||
|
IPath path = new Path( includePath );
|
||||||
|
IResource resource = workspaceRoot.findMember( path, true );
|
||||||
|
if( resource != null ){
|
||||||
|
resourceStack.addFirst( currentResource );
|
||||||
|
currentResource = resource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
|
|
||||||
*/
|
|
||||||
public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
|
|
||||||
*/
|
|
||||||
public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
|
|
||||||
*/
|
|
||||||
public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
|
||||||
*/
|
|
||||||
public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
|
|
||||||
*/
|
|
||||||
public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
|
|
||||||
*/
|
|
||||||
public void enterTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
|
||||||
*/
|
|
||||||
public void acceptMethodDeclaration(IASTMethod method) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
|
||||||
*/
|
|
||||||
public void enterMethodBody(IASTMethod method) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
|
|
||||||
*/
|
|
||||||
public void exitMethodBody(IASTMethod method) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
|
|
||||||
*/
|
|
||||||
public void acceptField(IASTField field) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptConstructor(org.eclipse.cdt.core.parser.ast.IASTConstructor)
|
|
||||||
*/
|
|
||||||
public void acceptConstructor(IASTConstructor constructor) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
|
|
||||||
*/
|
|
||||||
public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
|
|
||||||
*/
|
|
||||||
public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
|
|
||||||
*/
|
|
||||||
public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
|
|
||||||
*/
|
|
||||||
public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier)
|
|
||||||
*/
|
|
||||||
public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
|
|
||||||
*/
|
|
||||||
public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
|
|
||||||
*/
|
|
||||||
public void exitInclusion(IASTInclusion inclusion) {
|
public void exitInclusion(IASTInclusion inclusion) {
|
||||||
// TODO Auto-generated method stub
|
currentResource = (IResource) resourceStack.removeFirst();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
|
if( searchPattern instanceof ClassDeclarationPattern ){
|
||||||
*/
|
int level = searchPattern.matchLevel( classSpecification );
|
||||||
public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
|
if( level != ICSearchPattern.IMPOSSIBLE_MATCH ){
|
||||||
// TODO Auto-generated method stub
|
report( classSpecification, level );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void locateMatches( String [] paths, IWorkspace workspace, IWorkingCopy[] workingCopies ){
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier)
|
workspaceRoot = workspace.getRoot();
|
||||||
*/
|
|
||||||
public void acceptEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
protected void report( IASTOffsetableElement node, int accuracyLevel ){
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptClassReference(org.eclipse.cdt.core.parser.ast.IASTClassSpecifier, int)
|
try {
|
||||||
*/
|
resultCollector.accept( currentResource,
|
||||||
public void acceptClassReference(IASTClassSpecifier classSpecifier, int referenceOffset) {
|
node.getElementStartingOffset(),
|
||||||
// TODO Auto-generated method stub
|
node.getElementEndingOffset(),
|
||||||
|
null,
|
||||||
|
accuracyLevel );
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
private ICSearchPattern searchPattern;
|
||||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptElaboratedTypeSpecifier(org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier)
|
private ICSearchResultCollector resultCollector;
|
||||||
*/
|
private IProgressMonitor progressMonitor;
|
||||||
public void acceptElaboratedTypeSpecifier(IASTElaboratedTypeSpecifier elaboratedTypeSpec)
|
private IResource currentResource;
|
||||||
{
|
private ICSearchScope searchScope;
|
||||||
// TODO Auto-generated method stub
|
private LinkedList resourceStack;
|
||||||
|
private IWorkspaceRoot workspaceRoot;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,25 @@
|
||||||
|
2003-06-27 Andrew Niefer
|
||||||
|
Changes for C/C++ Search:
|
||||||
|
Added:
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CElementLabels.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CSearchResultLabelProvider.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CSearchViewActionGroup.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/ElementNameSorter.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/GotoMarkerAction.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/GroupByKeyComputer.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/ParentNameSorter.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/PathNameSorter.java
|
||||||
|
* icons/full/clcl16/search_sortmatch.gif
|
||||||
|
* icons/full/obj16/search_decl_obj.gif
|
||||||
|
* icons/full/obj16/search_ref_obj.gif
|
||||||
|
Modified:
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CSearchOperation.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CSearchResultCollector.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties.java
|
||||||
|
* plugin.xml
|
||||||
|
* plugin.properties
|
||||||
|
|
||||||
2003-06-26 Sean Evoy
|
2003-06-26 Sean Evoy
|
||||||
Added a tab to the new standard make project wizard and CNature project
|
Added a tab to the new standard make project wizard and CNature project
|
||||||
property page. User interacts with two list controls to add include paths
|
property page. User interacts with two list controls to add include paths
|
||||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/search_decl_obj.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/search_decl_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 157 B |
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/search_ref_obj.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/search_ref_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 151 B |
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/search_sortmatch.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/search_sortmatch.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 160 B |
|
@ -93,3 +93,13 @@ ToolName.compiler = Compiler
|
||||||
ToolName.archiver = Archiver
|
ToolName.archiver = Archiver
|
||||||
ToolName.linker = Linker
|
ToolName.linker = Linker
|
||||||
ToolName.command = Command Line
|
ToolName.command = Command Line
|
||||||
|
|
||||||
|
#C/C++ Search
|
||||||
|
CSearchPage.label= C/C++ Search
|
||||||
|
ElementNameSorter.label= &Name
|
||||||
|
ElementNameSorter.tooltip= Sort the view by C Element Name
|
||||||
|
ParentNameSorter.label= &Parent Name
|
||||||
|
ParentNameSorter.tooltip= Sort the view by C Element Parent Name
|
||||||
|
PathNameSorter.label= P&ath
|
||||||
|
PathNameSorter.tooltip= Sort the view by Resource Path
|
||||||
|
|
||||||
|
|
|
@ -946,12 +946,39 @@
|
||||||
point="org.eclipse.search.searchPages">
|
point="org.eclipse.search.searchPages">
|
||||||
<page
|
<page
|
||||||
showScopeSection="true"
|
showScopeSection="true"
|
||||||
label="C/CPP Search"
|
label="%CSearchPage.label"
|
||||||
icon="icons/full/obj16/csearch_obj.gif"
|
icon="icons/full/obj16/csearch_obj.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
|
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
|
||||||
sizeHint="460, 160"
|
sizeHint="460, 160"
|
||||||
id="org.eclipse.cdt.ui.CSearchPage">
|
id="org.eclipse.cdt.ui.CSearchPage">
|
||||||
</page>
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.search.searchResultSorters">
|
||||||
|
<sorter
|
||||||
|
pageId="org.eclipse.cdt.ui.CSearchPage"
|
||||||
|
label="%ElementNameSorter.label"
|
||||||
|
class="org.eclipse.cdt.internal.ui.search.ElementNameSorter"
|
||||||
|
tooltip="%ElementNameSorter.tooltip"
|
||||||
|
icon="icons/full/clcl16/search_sortmatch.gif"
|
||||||
|
id="org.eclipse.search.internal.ui.ElementNameSorter" >
|
||||||
|
</sorter>
|
||||||
|
<sorter
|
||||||
|
id="org.eclipse.search.internal.ui.ParentNameSorter"
|
||||||
|
pageId="org.eclipse.cdt.ui.CSearchPage"
|
||||||
|
label="%ParentNameSorter.label"
|
||||||
|
tooltip="%ParentNameSorter.tooltip"
|
||||||
|
icon="icons/full/clcl16/search_sortmatch.gif"
|
||||||
|
class="org.eclipse.cdt.internal.ui.search.ParentNameSorter">
|
||||||
|
</sorter>
|
||||||
|
<sorter
|
||||||
|
id="org.eclipse.search.internal.ui.PathNameSorter"
|
||||||
|
pageId="org.eclipse.cdt.ui.JavaSearchPage"
|
||||||
|
label="%PathNameSorter.label"
|
||||||
|
tooltip="%PathNameSorter.tooltip"
|
||||||
|
icon="icons/full/clcl16/search_sortmatch.gif"
|
||||||
|
class="org.eclipse.cdt.internal.ui.search.PathNameSorter">
|
||||||
|
</sorter>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -164,6 +164,13 @@ public class CPluginImages {
|
||||||
public static final String IMG_BUILD_TOOL = NAME_PREFIX + "config-tool.gif";
|
public static final String IMG_BUILD_TOOL = NAME_PREFIX + "config-tool.gif";
|
||||||
public static final ImageDescriptor DESC_BUILD_TOOL = createManaged(T_BUILD, IMG_BUILD_TOOL);
|
public static final ImageDescriptor DESC_BUILD_TOOL = createManaged(T_BUILD, IMG_BUILD_TOOL);
|
||||||
|
|
||||||
|
//for search
|
||||||
|
public static final String IMG_OBJS_SEARCH_REF = NAME_PREFIX + "search_ref_obj.gif";
|
||||||
|
public static final String IMG_OBJS_SEARCH_DECL = NAME_PREFIX + "search_decl_obj.gif";
|
||||||
|
|
||||||
|
public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
|
||||||
|
public static final ImageDescriptor DESC_OBJS_SEARCH_REF = createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
//createManaged(registry, T_OBJ, IMG_OBJS_TUNIT);
|
//createManaged(registry, T_OBJ, IMG_OBJS_TUNIT);
|
||||||
//createManaged(registry, T_OBJ, IMG_OBJS_FIELD);
|
//createManaged(registry, T_OBJ, IMG_OBJS_FIELD);
|
||||||
|
|
|
@ -0,0 +1,362 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 24, 2003
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IMethod;
|
||||||
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class CElementLabels {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names contain parameter types.
|
||||||
|
* e.g. <code>foo(int)</code>
|
||||||
|
*/
|
||||||
|
public final static int M_PARAMETER_TYPES= 1 << 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names contain parameter names.
|
||||||
|
* e.g. <code>foo(index)</code>
|
||||||
|
*/
|
||||||
|
public final static int M_PARAMETER_NAMES= 1 << 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names contain thrown exceptions.
|
||||||
|
* e.g. <code>foo throw( IOException )</code>
|
||||||
|
*/
|
||||||
|
public final static int M_EXCEPTIONS= 1 << 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names contain return type (appended)
|
||||||
|
* e.g. <code>foo : int</code>
|
||||||
|
*/
|
||||||
|
public final static int M_APP_RETURNTYPE= 1 << 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names contain return type (appended)
|
||||||
|
* e.g. <code>int foo</code>
|
||||||
|
*/
|
||||||
|
public final static int M_PRE_RETURNTYPE= 1 << 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names are fully qualified.
|
||||||
|
* e.g. <code>java.util.Vector.size</code>
|
||||||
|
*/
|
||||||
|
public final static int M_FULLY_QUALIFIED= 1 << 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method names are post qualified.
|
||||||
|
* e.g. <code>size - java.util.Vector</code>
|
||||||
|
*/
|
||||||
|
public final static int M_POST_QUALIFIED= 1 << 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializer names are fully qualified.
|
||||||
|
* e.g. <code>java.util.Vector.{ ... }</code>
|
||||||
|
*/
|
||||||
|
public final static int I_FULLY_QUALIFIED= 1 << 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type names are post qualified.
|
||||||
|
* e.g. <code>{ ... } - java.util.Map</code>
|
||||||
|
*/
|
||||||
|
public final static int I_POST_QUALIFIED= 1 << 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field names contain the declared type (appended)
|
||||||
|
* e.g. <code>int fHello</code>
|
||||||
|
*/
|
||||||
|
public final static int F_APP_TYPE_SIGNATURE= 1 << 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field names contain the declared type (prepended)
|
||||||
|
* e.g. <code>fHello : int</code>
|
||||||
|
*/
|
||||||
|
public final static int F_PRE_TYPE_SIGNATURE= 1 << 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fields names are fully qualified.
|
||||||
|
* e.g. <code>java.lang.System.out</code>
|
||||||
|
*/
|
||||||
|
public final static int F_FULLY_QUALIFIED= 1 << 11;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fields names are post qualified.
|
||||||
|
* e.g. <code>out - java.lang.System</code>
|
||||||
|
*/
|
||||||
|
public final static int F_POST_QUALIFIED= 1 << 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type names are fully qualified.
|
||||||
|
* e.g. <code>java.util.Map.MapEntry</code>
|
||||||
|
*/
|
||||||
|
public final static int T_FULLY_QUALIFIED= 1 << 13;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type names are type container qualified.
|
||||||
|
* e.g. <code>Map.MapEntry</code>
|
||||||
|
*/
|
||||||
|
public final static int T_CONTAINER_QUALIFIED= 1 << 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type names are post qualified.
|
||||||
|
* e.g. <code>MapEntry - java.util.Map</code>
|
||||||
|
*/
|
||||||
|
public final static int T_POST_QUALIFIED= 1 << 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declarations (import container / declarartion, package declarartion) are qualified.
|
||||||
|
* e.g. <code>java.util.Vector.class/import container</code>
|
||||||
|
*/
|
||||||
|
public final static int D_QUALIFIED= 1 << 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declarations (import container / declarartion, package declarartion) are post qualified.
|
||||||
|
* e.g. <code>import container - java.util.Vector.class</code>
|
||||||
|
*/
|
||||||
|
public final static int D_POST_QUALIFIED= 1 << 17;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class file names are fully qualified.
|
||||||
|
* e.g. <code>java.util.Vector.class</code>
|
||||||
|
*/
|
||||||
|
public final static int CF_QUALIFIED= 1 << 18;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class file names are post qualified.
|
||||||
|
* e.g. <code>Vector.class - java.util</code>
|
||||||
|
*/
|
||||||
|
public final static int CF_POST_QUALIFIED= 1 << 19;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compilation unit names are fully qualified.
|
||||||
|
* e.g. <code>java.util.Vector.java</code>
|
||||||
|
*/
|
||||||
|
public final static int CU_QUALIFIED= 1 << 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compilation unit names are post qualified.
|
||||||
|
* e.g. <code>Vector.java - java.util</code>
|
||||||
|
*/
|
||||||
|
public final static int CU_POST_QUALIFIED= 1 << 21;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package names are qualified.
|
||||||
|
* e.g. <code>MyProject/src/java.util</code>
|
||||||
|
*/
|
||||||
|
public final static int P_QUALIFIED= 1 << 22;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package names are post qualified.
|
||||||
|
* e.g. <code>java.util - MyProject/src</code>
|
||||||
|
*/
|
||||||
|
public final static int P_POST_QUALIFIED= 1 << 23;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package Fragment Roots contain variable name if from a variable.
|
||||||
|
* e.g. <code>JRE_LIB - c:\java\lib\rt.jar</code>
|
||||||
|
*/
|
||||||
|
public final static int ROOT_VARIABLE= 1 << 24;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package Fragment Roots contain the project name if not an archive (prepended).
|
||||||
|
* e.g. <code>MyProject/src</code>
|
||||||
|
*/
|
||||||
|
public final static int ROOT_QUALIFIED= 1 << 25;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package Fragment Roots contain the project name if not an archive (appended).
|
||||||
|
* e.g. <code>src - MyProject</code>
|
||||||
|
*/
|
||||||
|
public final static int ROOT_POST_QUALIFIED= 1 << 26;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add root path to all elements except Package Fragment Roots and Java projects.
|
||||||
|
* e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
|
||||||
|
* Option only applies to getElementLabel
|
||||||
|
*/
|
||||||
|
public final static int APPEND_ROOT_PATH= 1 << 27;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add root path to all elements except Package Fragment Roots and Java projects.
|
||||||
|
* e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
|
||||||
|
* Option only applies to getElementLabel
|
||||||
|
*/
|
||||||
|
public final static int PREPEND_ROOT_PATH= 1 << 28;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Package names are compressed.
|
||||||
|
* e.g. <code>o*.e*.search</code>
|
||||||
|
*/
|
||||||
|
public final static int P_COMPRESSED= 1 << 29;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post qualify referenced package fragement roots. For example
|
||||||
|
* <code>jdt.jar - org.eclipse.jdt.ui</code> if the jar is referenced
|
||||||
|
* from another project.
|
||||||
|
*/
|
||||||
|
public final static int REFERENCED_ROOT_POST_QUALIFIED= 1 << 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Qualify all elements
|
||||||
|
*/
|
||||||
|
public final static int ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED | P_QUALIFIED | ROOT_QUALIFIED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post qualify all elements
|
||||||
|
*/
|
||||||
|
public final static int ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED | P_POST_QUALIFIED | ROOT_POST_QUALIFIED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default options (M_PARAMETER_TYPES enabled)
|
||||||
|
*/
|
||||||
|
public final static int ALL_DEFAULT= M_PARAMETER_TYPES;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default qualify options (All except Root and Package)
|
||||||
|
*/
|
||||||
|
public final static int DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default post qualify options (All except Root and Package)
|
||||||
|
*/
|
||||||
|
public final static int DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED;
|
||||||
|
|
||||||
|
|
||||||
|
public final static String CONCAT_STRING= CSearchMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$
|
||||||
|
public final static String COMMA_STRING = CSearchMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$
|
||||||
|
public final static String DECL_STRING = CSearchMessages.getString("CElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static String getTextLabel(Object obj, int flags) {
|
||||||
|
if (obj instanceof ICElement) {
|
||||||
|
return getElementLabel((ICElement) obj, flags);
|
||||||
|
} else if (obj instanceof IAdaptable) {
|
||||||
|
IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
|
||||||
|
if (wbadapter != null) {
|
||||||
|
return wbadapter.getLabel(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getElementLabel(ICElement element, int flags) {
|
||||||
|
StringBuffer buf= new StringBuffer(60);
|
||||||
|
getElementLabel(element, flags, buf);
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getElementLabel(ICElement element, int flags, StringBuffer buf) {
|
||||||
|
int type= element.getElementType();
|
||||||
|
|
||||||
|
switch( type ){
|
||||||
|
case ICElement.C_METHOD :
|
||||||
|
getMethodLabel( (IMethod) element, flags, buf );
|
||||||
|
break;
|
||||||
|
case ICElement.C_CLASS:
|
||||||
|
case ICElement.C_STRUCT:
|
||||||
|
case ICElement.C_UNION:
|
||||||
|
case ICElement.C_ENUMERATION:
|
||||||
|
// getTypeLabel( (IType) element, flags, buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getMethodLabel( IMethod method, int flags, StringBuffer buf ) {
|
||||||
|
//return type
|
||||||
|
if( getFlag( flags, M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) {
|
||||||
|
buf.append( method.getReturnType() );
|
||||||
|
buf.append( ' ' );
|
||||||
|
}
|
||||||
|
|
||||||
|
//qualification
|
||||||
|
if( getFlag( flags, M_FULLY_QUALIFIED ) ){
|
||||||
|
getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
|
||||||
|
buf.append( "::" );
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.append( method.getElementName() );
|
||||||
|
|
||||||
|
//parameters
|
||||||
|
if( getFlag( flags, M_PARAMETER_TYPES | M_PARAMETER_NAMES ) ) {
|
||||||
|
buf.append('(');
|
||||||
|
|
||||||
|
String[] types = getFlag(flags, M_PARAMETER_TYPES) ? method.getParameterTypes() : null;
|
||||||
|
String[] names = null;//(getFlag(flags, M_PARAMETER_NAMES) && method.exists()) ? method.getParameterNames() : null;
|
||||||
|
|
||||||
|
int nParams = ( types != null ) ? types.length : names.length;
|
||||||
|
|
||||||
|
for (int i= 0; i < nParams; i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
buf.append( COMMA_STRING ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types != null) {
|
||||||
|
buf.append( types[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (names != null) {
|
||||||
|
if (types != null) {
|
||||||
|
buf.append(' ');
|
||||||
|
}
|
||||||
|
buf.append( names[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.append(')');
|
||||||
|
}
|
||||||
|
|
||||||
|
//exceptions
|
||||||
|
if( getFlag( flags, M_EXCEPTIONS ) && method.exists() ){
|
||||||
|
String [] types = method.getExceptions();
|
||||||
|
if (types.length > 0) {
|
||||||
|
buf.append(" throw( "); //$NON-NLS-1$
|
||||||
|
for (int i= 0; i < types.length; i++) {
|
||||||
|
if (i > 0) {
|
||||||
|
buf.append(COMMA_STRING);
|
||||||
|
}
|
||||||
|
buf.append( types[i] );
|
||||||
|
}
|
||||||
|
buf.append( " )" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( getFlag( flags, M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor()) {
|
||||||
|
buf.append( DECL_STRING );
|
||||||
|
buf.append( method.getReturnType() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// post qualification
|
||||||
|
if( getFlag(flags, M_POST_QUALIFIED)) {
|
||||||
|
buf.append( CONCAT_STRING );
|
||||||
|
getTypeLabel( method.getParent(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getTypeLabel(ICElement type, int flags, StringBuffer buf) {
|
||||||
|
if( !(type instanceof IStructure) ){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean getFlag(int flags, int flag) {
|
||||||
|
return (flags & flag) != 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,32 +39,32 @@ Search.Error.setDescription.message=Cannot save workspace description
|
||||||
SearchElementSelectionDialog.title=Search
|
SearchElementSelectionDialog.title=Search
|
||||||
SearchElementSelectionDialog.message=Select the element to search for.
|
SearchElementSelectionDialog.message=Select the element to search for.
|
||||||
|
|
||||||
SearchResultCollector.match= 1 match
|
CSearchResultCollector.match= 1 match
|
||||||
SearchResultCollector.matches= {0} matches
|
CSearchResultCollector.matches= {0} matches
|
||||||
SearchResultCollector.done= Search done: {0}.
|
CSearchResultCollector.done= Search done: {0}.
|
||||||
SearchResultCollector.searching= Searching...
|
CSearchResultCollector.searching= Searching...
|
||||||
|
|
||||||
Search.potentialMatchDialog.title.foundPotentialMatch= Search: Found 1 Inexact Match
|
Search.potentialMatchDialog.title.foundPotentialMatch= Search: Found 1 Inexact Match
|
||||||
Search.potentialMatchDialog.title.foundPotentialMatches= Search: Found {0} Inexact Matches
|
Search.potentialMatchDialog.title.foundPotentialMatches= Search: Found {0} Inexact Matches
|
||||||
Search.potentialMatchDialog.message= Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preference page.
|
Search.potentialMatchDialog.message= Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preference page.
|
||||||
|
|
||||||
SearchPage.searchFor.label= Search For
|
CSearchPage.searchFor.label= Search For
|
||||||
SearchPage.searchFor.type= &Type
|
CSearchPage.searchFor.type= &Type
|
||||||
SearchPage.searchFor.method= &Method
|
CSearchPage.searchFor.method= &Method
|
||||||
SearchPage.searchFor.field= &Field
|
CSearchPage.searchFor.field= &Field
|
||||||
SearchPage.searchFor.package= &Package
|
CSearchPage.searchFor.namespace= N&amespace
|
||||||
SearchPage.searchFor.constructor= Co&nstructor
|
CSearchPage.searchFor.constructor= Co&nstructor
|
||||||
|
|
||||||
SearchPage.limitTo.label= Limit To
|
CSearchPage.limitTo.label= Limit To
|
||||||
SearchPage.limitTo.declarations= Dec&larations
|
CSearchPage.limitTo.declarations= Dec&larations
|
||||||
SearchPage.limitTo.implementors= &Implementors
|
CSearchPage.limitTo.implementors= &Implementors
|
||||||
SearchPage.limitTo.references= &References
|
CSearchPage.limitTo.references= &References
|
||||||
SearchPage.limitTo.allOccurrences= All &Occurrences
|
CSearchPage.limitTo.allOccurrences= All &Occurrences
|
||||||
SearchPage.limitTo.readReferences= Read A&ccess
|
CSearchPage.limitTo.readReferences= Read A&ccess
|
||||||
SearchPage.limitTo.writeReferences= Writ&e Access
|
CSearchPage.limitTo.writeReferences= Writ&e Access
|
||||||
|
|
||||||
SearchPage.expression.label= Se&arch string (* = any string, ? = any character):
|
CSearchPage.expression.label= Se&arch string (* = any string, ? = any character):
|
||||||
SearchPage.expression.caseSensitive= Case sens&itive
|
CSearchPage.expression.caseSensitive= Case sens&itive
|
||||||
|
|
||||||
# Concatenate two working set names e.g. "Source, Lib"
|
# Concatenate two working set names e.g. "Source, Lib"
|
||||||
SearchUtil.workingSetConcatenation= {0}, {1}
|
SearchUtil.workingSetConcatenation= {0}, {1}
|
||||||
|
@ -125,20 +125,20 @@ FindOccurrencesEngine.cannotParse.text= Cannot analyze the compilation unit or c
|
||||||
JavaSearchOperation.default_package=(default package)
|
JavaSearchOperation.default_package=(default package)
|
||||||
|
|
||||||
# The first argument will be replaced by the pattern and the second by the scope
|
# The first argument will be replaced by the pattern and the second by the scope
|
||||||
JavaSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
|
CSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
|
||||||
JavaSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
|
CSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
|
||||||
JavaSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
|
CSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
|
||||||
JavaSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
|
CSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
|
||||||
JavaSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
|
CSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
|
||||||
JavaSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
|
CSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
|
||||||
|
|
||||||
# The first argument will be replaced by the pattern, the second by the count and the last by the scope
|
# The first argument will be replaced by the pattern, the second by the count and the last by the scope
|
||||||
JavaSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
|
CSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
|
||||||
JavaSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
|
CSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
|
||||||
JavaSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
|
CSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
|
||||||
JavaSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
|
CSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
|
||||||
JavaSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
|
CSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
|
||||||
JavaSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
|
CSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
|
||||||
|
|
||||||
# The first argument will be replaced by the element name and the second one by the file name
|
# The first argument will be replaced by the element name and the second one by the file name
|
||||||
JavaSearchInFile.singularPostfix={0} - 1 Occurrence in {1}
|
JavaSearchInFile.singularPostfix={0} - 1 Occurrence in {1}
|
||||||
|
@ -154,9 +154,13 @@ JavaElementAction.operationUnavailable.generic= The operation is unavailable on
|
||||||
JavaElementAction.operationUnavailable.field= The operation is unavailable on the current selection. Please select the name of a field.
|
JavaElementAction.operationUnavailable.field= The operation is unavailable on the current selection. Please select the name of a field.
|
||||||
JavaElementAction.operationUnavailable.interface= The operation is unavailable on the current selection. Please select the name of an interface.
|
JavaElementAction.operationUnavailable.interface= The operation is unavailable on the current selection. Please select the name of an interface.
|
||||||
|
|
||||||
JavaSearchResultLabelProvider.potentialMatch= \ (inexact)
|
CSearchResultLabelProvider.potentialMatch= \ (inexact)
|
||||||
|
|
||||||
WorkspaceScope= Workspace
|
WorkspaceScope= Workspace
|
||||||
WorkingSetScope= Working Set - {0}
|
WorkingSetScope= Working Set - {0}
|
||||||
SelectionScope= Selection
|
SelectionScope= Selection
|
||||||
HierarchyScope= Hierarchy - {0}
|
HierarchyScope= Hierarchy - {0}
|
||||||
|
|
||||||
|
CElementLabels.concat_string=\ -\
|
||||||
|
CElementLabels.comma_string=,\
|
||||||
|
CElementLabels.declseparator_string=\ :\
|
|
@ -16,12 +16,15 @@ package org.eclipse.cdt.internal.ui.search;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.ICSearchPattern;
|
||||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||||
import org.eclipse.cdt.core.search.SearchEngine;
|
import org.eclipse.cdt.core.search.SearchEngine;
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +51,7 @@ public class CSearchOperation extends WorkspaceModifyOperation {
|
||||||
_workspace = workspace;
|
_workspace = workspace;
|
||||||
_limitTo = limitTo;
|
_limitTo = limitTo;
|
||||||
_scope = scope;
|
_scope = scope;
|
||||||
_scopeDecsription = scopeDescription;
|
_scopeDescription = scopeDescription;
|
||||||
_collector = collector;
|
_collector = collector;
|
||||||
_collector.setOperation( this );
|
_collector.setOperation( this );
|
||||||
}
|
}
|
||||||
|
@ -71,15 +74,72 @@ public class CSearchOperation extends WorkspaceModifyOperation {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getSingularLabel() {
|
||||||
|
String desc = null;
|
||||||
|
|
||||||
|
if( _elementPattern != null ){
|
||||||
|
desc = _elementPattern.getElementName();
|
||||||
|
} else {
|
||||||
|
desc = _stringPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
String [] args = new String [] { desc, _scopeDescription };
|
||||||
|
switch( _limitTo ){
|
||||||
|
case ICSearchConstants.DECLARATIONS :
|
||||||
|
return CSearchMessages.getFormattedString( "CSearchOperation.singularDeclarationsPostfix", args ); //$NON_NLS-1$
|
||||||
|
case ICSearchConstants.REFERENCES :
|
||||||
|
return CSearchMessages.getFormattedString( "CSearchOperation.singularReferencesPostfix", args ); //$NON_NLS-1$
|
||||||
|
default:
|
||||||
|
return CSearchMessages.getFormattedString( "CSearchOperation.singularOccurencesPostfix", args ); //$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 };
|
||||||
|
switch( _limitTo ){
|
||||||
|
case ICSearchConstants.DECLARATIONS :
|
||||||
|
return CSearchMessages.getFormattedString( "CSearchOperation.pluralDeclarationsPostfix", args ); //$NON_NLS-1$
|
||||||
|
case ICSearchConstants.REFERENCES :
|
||||||
|
return CSearchMessages.getFormattedString( "CSearchOperation.pluralReferencesPostfix", args ); //$NON_NLS-1$
|
||||||
|
default:
|
||||||
|
return CSearchMessages.getFormattedString( "CSearchOperation.pluralOccurencesPostfix", args ); //$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 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 _scopeDecsription;
|
private String _scopeDescription;
|
||||||
private boolean _caseSensitive;
|
private boolean _caseSensitive;
|
||||||
private int _limitTo;
|
private int _limitTo;
|
||||||
private int _searchFor;
|
private int _searchFor;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,11 +160,9 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fSearchFor[ TYPE ].addSelectionListener(cElementInitializer);
|
for( int i = 0; i < fSearchFor.length; i++ ){
|
||||||
fSearchFor[ FUNCTION ].addSelectionListener(cElementInitializer);
|
fSearchFor[ i ].addSelectionListener( cElementInitializer );
|
||||||
fSearchFor[ MEMBER ].addSelectionListener(cElementInitializer);
|
}
|
||||||
fSearchFor[CONSTRUCTOR].addSelectionListener(cElementInitializer);
|
|
||||||
//fSearchFor[ PACKAGE ].addSelectionListener(cElementInitializer);
|
|
||||||
|
|
||||||
setControl( result );
|
setControl( result );
|
||||||
|
|
||||||
|
@ -183,7 +181,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
|
|
||||||
// Pattern text + info
|
// Pattern text + info
|
||||||
Label label = new Label( result, SWT.LEFT );
|
Label label = new Label( result, SWT.LEFT );
|
||||||
label.setText( CSearchMessages.getString( "SearchPage.expression.label" ) ); //$NON-NLS-1$
|
label.setText( CSearchMessages.getString( "CSearchPage.expression.label" ) ); //$NON-NLS-1$
|
||||||
gd = new GridData( GridData.BEGINNING );
|
gd = new GridData( GridData.BEGINNING );
|
||||||
gd.horizontalSpan = 2;
|
gd.horizontalSpan = 2;
|
||||||
label.setLayoutData( gd );
|
label.setLayoutData( gd );
|
||||||
|
@ -210,7 +208,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
|
|
||||||
// Ignore case checkbox
|
// Ignore case checkbox
|
||||||
fCaseSensitive= new Button(result, SWT.CHECK);
|
fCaseSensitive= new Button(result, SWT.CHECK);
|
||||||
fCaseSensitive.setText(CSearchMessages.getString("SearchPage.expression.caseSensitive")); //$NON-NLS-1$
|
fCaseSensitive.setText(CSearchMessages.getString("CSearchPage.expression.caseSensitive")); //$NON-NLS-1$
|
||||||
gd= new GridData();
|
gd= new GridData();
|
||||||
fCaseSensitive.setLayoutData(gd);
|
fCaseSensitive.setLayoutData(gd);
|
||||||
fCaseSensitive.addSelectionListener( new SelectionAdapter() {
|
fCaseSensitive.addSelectionListener( new SelectionAdapter() {
|
||||||
|
@ -259,7 +257,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
|
|
||||||
private Control createLimitTo( Composite parent ) {
|
private Control createLimitTo( Composite parent ) {
|
||||||
Group result = new Group(parent, SWT.NONE);
|
Group result = new Group(parent, SWT.NONE);
|
||||||
result.setText( CSearchMessages.getString("SearchPage.limitTo.label") ); //$NON-NLS-1$
|
result.setText( CSearchMessages.getString("CSearchPage.limitTo.label") ); //$NON-NLS-1$
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
layout.numColumns = 2;
|
layout.numColumns = 2;
|
||||||
result.setLayout( layout );
|
result.setLayout( layout );
|
||||||
|
@ -315,7 +313,7 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
|
|
||||||
private Control createSearchFor(Composite parent) {
|
private Control createSearchFor(Composite parent) {
|
||||||
Group result= new Group(parent, SWT.NONE);
|
Group result= new Group(parent, SWT.NONE);
|
||||||
result.setText(CSearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$
|
result.setText(CSearchMessages.getString("CSearchPage.searchFor.label")); //$NON-NLS-1$
|
||||||
GridLayout layout= new GridLayout();
|
GridLayout layout= new GridLayout();
|
||||||
layout.numColumns= 3;
|
layout.numColumns= 3;
|
||||||
result.setLayout(layout);
|
result.setLayout(layout);
|
||||||
|
@ -566,8 +564,8 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
pattern= p;
|
pattern= p;
|
||||||
isCaseSensitive= i;
|
isCaseSensitive= i;
|
||||||
cElement= element;
|
cElement= element;
|
||||||
this.scope= scope;
|
this.scope = scope;
|
||||||
this.workingSets= workingSets;
|
this.workingSets = workingSets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,20 +577,20 @@ public class CSearchPage extends DialogPage implements ISearchPage, ICSearchCons
|
||||||
|
|
||||||
private Button[] fSearchFor;
|
private Button[] fSearchFor;
|
||||||
private String[] fSearchForText= {
|
private String[] fSearchForText= {
|
||||||
CSearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.searchFor.type"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.searchFor.method"), //$NON-NLS-1$
|
||||||
//CSearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.searchFor.namespace"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.searchFor.constructor"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.searchFor.field")}; //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.searchFor.field")}; //$NON-NLS-1$
|
||||||
|
|
||||||
private Button[] fLimitTo;
|
private Button[] fLimitTo;
|
||||||
private String[] fLimitToText= {
|
private String[] fLimitToText= {
|
||||||
CSearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.limitTo.declarations"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.limitTo.implementors"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.limitTo.references"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.limitTo.allOccurrences"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.limitTo.allOccurrences"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.limitTo.readReferences"), //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.limitTo.readReferences"), //$NON-NLS-1$
|
||||||
CSearchMessages.getString("SearchPage.limitTo.writeReferences")}; //$NON-NLS-1$
|
CSearchMessages.getString("CSearchPage.limitTo.writeReferences")}; //$NON-NLS-1$
|
||||||
|
|
||||||
private SearchPatternData fInitialData;
|
private SearchPatternData fInitialData;
|
||||||
private IStructuredSelection fStructuredSelection;
|
private IStructuredSelection fStructuredSelection;
|
||||||
|
|
|
@ -13,10 +13,19 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
import org.eclipse.cdt.core.search.ICSearchResultCollector;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.search.ui.IActionGroupFactory;
|
||||||
|
import org.eclipse.search.ui.ISearchResultView;
|
||||||
|
import org.eclipse.search.ui.SearchUI;
|
||||||
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -38,8 +47,24 @@ public class CSearchResultCollector implements ICSearchResultCollector {
|
||||||
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#aboutToStart()
|
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#aboutToStart()
|
||||||
*/
|
*/
|
||||||
public void aboutToStart() {
|
public void aboutToStart() {
|
||||||
// TODO Auto-generated method stub
|
_view = SearchUI.getSearchResultView();
|
||||||
|
_matchCount = 0;
|
||||||
|
if( _view != null ){
|
||||||
|
_view.searchStarted(
|
||||||
|
new ActionGroupFactory(),
|
||||||
|
_operation.getSingularLabel(),
|
||||||
|
_operation.getPluralLabelPattern(),
|
||||||
|
_operation.getImageDescriptor(),
|
||||||
|
CSearchPage.EXTENSION_POINT_ID,
|
||||||
|
new CSearchResultLabelProvider(),
|
||||||
|
new GotoMarkerAction(),
|
||||||
|
new GroupByKeyComputer(),
|
||||||
|
_operation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if( !getProgressMonitor().isCanceled() ){
|
||||||
|
getProgressMonitor().subTask( SEARCHING );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -49,19 +74,47 @@ public class CSearchResultCollector implements ICSearchResultCollector {
|
||||||
IResource resource,
|
IResource resource,
|
||||||
int start,
|
int start,
|
||||||
int end,
|
int end,
|
||||||
Object enclosingElement,
|
ICElement enclosingElement,
|
||||||
int accuracy)
|
int accuracy)
|
||||||
throws CoreException {
|
throws CoreException
|
||||||
// TODO Auto-generated method stub
|
{
|
||||||
|
IMarker marker = resource.createMarker( SearchUI.SEARCH_MARKER );
|
||||||
|
|
||||||
|
Object groupKey = enclosingElement;
|
||||||
|
|
||||||
|
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( start, 0 ) ) );
|
||||||
|
markerAttributes.put( IMarker.CHAR_END, new Integer( Math.max( end, 0 ) ) );
|
||||||
|
|
||||||
|
marker.setAttributes( markerAttributes );
|
||||||
|
|
||||||
|
_view.addMatch( enclosingElement.getElementName(), groupKey, resource, marker );
|
||||||
|
_matchCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#done()
|
* @see org.eclipse.cdt.core.search.ICSearchResultCollector#done()
|
||||||
*/
|
*/
|
||||||
public void done() {
|
public void done() {
|
||||||
// TODO Auto-generated method stub
|
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)
|
/* (non-Javadoc)
|
||||||
|
@ -71,22 +124,28 @@ public class CSearchResultCollector implements ICSearchResultCollector {
|
||||||
return _monitor;
|
return _monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param monitor
|
|
||||||
*/
|
|
||||||
public void setProgressMonitor(IProgressMonitor monitor) {
|
public void setProgressMonitor(IProgressMonitor monitor) {
|
||||||
this._monitor = monitor;
|
this._monitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProgressMonitor _monitor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param operation
|
|
||||||
*/
|
|
||||||
public void setOperation( CSearchOperation operation ) {
|
public void setOperation( CSearchOperation operation ) {
|
||||||
_operation = operation;
|
_operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ActionGroupFactory implements IActionGroupFactory {
|
||||||
|
public ActionGroup createActionGroup( ISearchResultView part ){
|
||||||
|
return new CSearchViewActionGroup( part );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CSearchOperation _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 int _matchCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.core.resources.IMarker;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.search.ui.ISearchResultViewEntry;
|
||||||
|
import org.eclipse.search.ui.SearchUI;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aniefer
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||||
|
*/
|
||||||
|
public class CSearchResultLabelProvider extends LabelProvider {
|
||||||
|
|
||||||
|
public static final int SHOW_ELEMENT_CONTAINER = 1; //default
|
||||||
|
public static final int SHOW_CONTAINER_ELEMENT = 2;
|
||||||
|
public static final int SHOW_PATH = 3;
|
||||||
|
|
||||||
|
public final static int DEFAULT_TEXTFLAGS = CElementLabels.ROOT_VARIABLE |
|
||||||
|
CElementLabels.M_PARAMETER_TYPES |
|
||||||
|
CElementLabels.M_APP_RETURNTYPE |
|
||||||
|
CElementLabels.REFERENCED_ROOT_POST_QUALIFIED;
|
||||||
|
|
||||||
|
public static final String POTENTIAL_MATCH = CSearchMessages.getString("CSearchResultLabelProvider.potentialMatch"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
public Image getImage( Object element ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText( Object element ) {
|
||||||
|
_lastMarker = null;
|
||||||
|
|
||||||
|
ICElement cElement = getCElement( element );
|
||||||
|
|
||||||
|
boolean isPotentialMatch = _lastMarker != null && _lastMarker.getAttribute( SearchUI.POTENTIAL_MATCH, false );
|
||||||
|
|
||||||
|
if( cElement == null ){
|
||||||
|
if( _lastMarker != null ){
|
||||||
|
if( isPotentialMatch )
|
||||||
|
return super.getText( _lastMarker.getResource() ) + POTENTIAL_MATCH;
|
||||||
|
else
|
||||||
|
return super.getText( _lastMarker.getResource() );
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = "";
|
||||||
|
if( isPotentialMatch ){
|
||||||
|
text = CElementLabels.getTextLabel( element, _textFlags ) + POTENTIAL_MATCH;
|
||||||
|
} else {
|
||||||
|
text = CElementLabels.getTextLabel( element, _textFlags );
|
||||||
|
}
|
||||||
|
//if( cElement instanceof )
|
||||||
|
|
||||||
|
return element == null ? "" : element.toString();//$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(int orderFlag) {
|
||||||
|
int flags = DEFAULT_TEXTFLAGS | CElementLabels.P_COMPRESSED;
|
||||||
|
|
||||||
|
switch( orderFlag ){
|
||||||
|
case SHOW_ELEMENT_CONTAINER:
|
||||||
|
flags |= CElementLabels.ALL_POST_QUALIFIED | CElementLabels.M_PARAMETER_TYPES;
|
||||||
|
break;
|
||||||
|
case SHOW_PATH:
|
||||||
|
flags |= CElementLabels.PREPEND_ROOT_PATH;
|
||||||
|
/*fall through to SHOW_CONTAINER_ELEMENT*/
|
||||||
|
case SHOW_CONTAINER_ELEMENT:
|
||||||
|
flags |= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_textFlags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IMarker getMarker( Object o ){
|
||||||
|
if( !( o instanceof ISearchResultViewEntry ) ){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( (ISearchResultViewEntry)o ).getSelectedMarker();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement getCElement( Object o ){
|
||||||
|
if( o instanceof ICElement )
|
||||||
|
return (ICElement) o;
|
||||||
|
|
||||||
|
IMarker marker = getMarker( o );
|
||||||
|
if( marker == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return getCElement( marker, (ISearchResultViewEntry) o );
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement getCElement( IMarker marker, ISearchResultViewEntry entry ) {
|
||||||
|
if( _lastMarker != marker ){
|
||||||
|
boolean canUseGroupByKey = false;
|
||||||
|
|
||||||
|
if( canUseGroupByKey && entry.getGroupByKey() instanceof ICElement ){
|
||||||
|
_lastCElement = (ICElement) entry.getGroupByKey();
|
||||||
|
} else {
|
||||||
|
_lastCElement = CSearchUtil.getCElement( marker );
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastMarker = marker;
|
||||||
|
}
|
||||||
|
return _lastCElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IMarker _lastMarker;
|
||||||
|
private ICElement _lastCElement;
|
||||||
|
|
||||||
|
private int _textFlags;
|
||||||
|
private int _imageFlags;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 24, 2003
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
|
import org.eclipse.search.ui.ISearchResultView;
|
||||||
|
import org.eclipse.search.ui.ISearchResultViewEntry;
|
||||||
|
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 ElementNameSorter extends ViewerSorter {
|
||||||
|
|
||||||
|
public int compare( Viewer viewer, Object e1, Object e2 ){
|
||||||
|
String name1 = null, name2 = null;
|
||||||
|
|
||||||
|
if (e1 instanceof ISearchResultViewEntry)
|
||||||
|
name1= _labelProvider.getText( e1 );
|
||||||
|
|
||||||
|
if (e2 instanceof ISearchResultViewEntry)
|
||||||
|
name2= _labelProvider.getText( e2 );
|
||||||
|
|
||||||
|
if (name1 == null)
|
||||||
|
name1= ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (name2 == null)
|
||||||
|
name2= ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
return getCollator().compare(name1, name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSorterProperty( Object element, String property ){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sort( Viewer viewer, Object[] elements ) {
|
||||||
|
// Set label provider to show "element - path"
|
||||||
|
ISearchResultView view = SearchUI.getSearchResultView();
|
||||||
|
if (view == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_labelProvider = view.getLabelProvider();
|
||||||
|
|
||||||
|
if( _labelProvider instanceof CSearchResultLabelProvider ) {
|
||||||
|
((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_ELEMENT_CONTAINER );
|
||||||
|
super.sort( viewer, elements );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILabelProvider _labelProvider;
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 ){
|
||||||
|
editor.gotoMarker( 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 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.core.resources.IMarker;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ICElement element = getCElement( marker );
|
||||||
|
// if( element != null && element.exists() ){
|
||||||
|
// return _lastHandle;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
private String getJavaElementHandleId(IMarker marker) {
|
||||||
|
try {
|
||||||
|
return (String)marker.getAttribute(ICSearchUIConstants.ATT_JE_HANDLE_ID);
|
||||||
|
} catch (CoreException ex) {
|
||||||
|
ExceptionHandler.handle(ex, CSearchMessages.getString("Search.Error.markerAttributeAccess.title"), CSearchMessages.getString("Search.Error.markerAttributeAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement getCElement( IMarker marker ){
|
||||||
|
String handle = getCElementHandleId( marker );
|
||||||
|
if( handle == null ){
|
||||||
|
_lastHandle = null;
|
||||||
|
_lastElement = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if( !handle.equals( _lastHandle ) ){
|
||||||
|
_lastElement = SearchUtil
|
||||||
|
}
|
||||||
|
return _lastElement;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private String _lastHandle = null;
|
||||||
|
private ICElement _lastElement = null;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 24, 2003
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
|
import org.eclipse.search.ui.ISearchResultView;
|
||||||
|
import org.eclipse.search.ui.ISearchResultViewEntry;
|
||||||
|
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 ParentNameSorter extends ViewerSorter {
|
||||||
|
|
||||||
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||||
|
String name1= null;
|
||||||
|
String name2= null;
|
||||||
|
|
||||||
|
if (e1 instanceof ISearchResultViewEntry)
|
||||||
|
name1= _labelProvider.getText(e1);
|
||||||
|
|
||||||
|
if (e2 instanceof ISearchResultViewEntry)
|
||||||
|
name2= _labelProvider.getText(e2);
|
||||||
|
|
||||||
|
if (name1 == null)
|
||||||
|
name1= ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (name2 == null)
|
||||||
|
name2= ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
return getCollator().compare(name1, name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overrides method from ViewerSorter
|
||||||
|
*/
|
||||||
|
public boolean isSorterProperty(Object element, String property) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overrides method from ViewerSorter
|
||||||
|
*/
|
||||||
|
public void sort(Viewer viewer, Object[] elements) {
|
||||||
|
// Set label provider to show "path - resource"
|
||||||
|
ISearchResultView view = SearchUI.getSearchResultView();
|
||||||
|
if (view == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_labelProvider = view.getLabelProvider();
|
||||||
|
|
||||||
|
if( _labelProvider instanceof CSearchResultLabelProvider )
|
||||||
|
((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_CONTAINER_ELEMENT );
|
||||||
|
|
||||||
|
super.sort( viewer, elements );
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILabelProvider _labelProvider;
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 24, 2003
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
|
import org.eclipse.search.ui.ISearchResultView;
|
||||||
|
import org.eclipse.search.ui.ISearchResultViewEntry;
|
||||||
|
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 PathNameSorter extends ViewerSorter {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overrides method from ViewerSorter
|
||||||
|
*/
|
||||||
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||||
|
String name1 = null;
|
||||||
|
String name2 = null;
|
||||||
|
ISearchResultViewEntry entry1 = null;
|
||||||
|
ISearchResultViewEntry entry2 = null;
|
||||||
|
|
||||||
|
if( e1 instanceof ISearchResultViewEntry ) {
|
||||||
|
entry1 = (ISearchResultViewEntry)e1;
|
||||||
|
name1 = _labelProvider.getText( e1 );
|
||||||
|
}
|
||||||
|
if( e2 instanceof ISearchResultViewEntry ) {
|
||||||
|
entry2 = (ISearchResultViewEntry)e2;
|
||||||
|
name2 = _labelProvider.getText( e2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( name1 == null )
|
||||||
|
name1 = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if( name2 == null )
|
||||||
|
name2 = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
IResource resource = null;
|
||||||
|
if( entry1 != null)
|
||||||
|
resource = entry1.getResource();
|
||||||
|
|
||||||
|
if( resource != null && entry2 != null && resource == entry2.getResource() ) {
|
||||||
|
|
||||||
|
if( resource instanceof IProject || resource.getFileExtension().equalsIgnoreCase("jar") || resource.getFileExtension().equalsIgnoreCase("zip") ) //$NON-NLS-2$ //$NON-NLS-1$
|
||||||
|
// binary archives
|
||||||
|
return getCollator().compare(name1, name2);
|
||||||
|
|
||||||
|
// Sort by marker start position if resource is equal.
|
||||||
|
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 );
|
||||||
|
|
||||||
|
return startPos1 - startPos2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getCollator().compare(name1, name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overrides method from ViewerSorter
|
||||||
|
*/
|
||||||
|
public boolean isSorterProperty(Object element, String property) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Overrides method from ViewerSorter
|
||||||
|
*/
|
||||||
|
public void sort( Viewer viewer, Object[] elements ) {
|
||||||
|
// Set label provider to show "path - resource"
|
||||||
|
ISearchResultView view = SearchUI.getSearchResultView();
|
||||||
|
if( view == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
_labelProvider = view.getLabelProvider();
|
||||||
|
if( _labelProvider instanceof CSearchResultLabelProvider )
|
||||||
|
((CSearchResultLabelProvider)_labelProvider).setOrder( CSearchResultLabelProvider.SHOW_PATH );
|
||||||
|
super.sort( viewer, elements );
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILabelProvider _labelProvider;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue