1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 102765: [Search] NPE in NewSearchUI

Fix for 102782: BasicSearchMatch doesn't collect parameters
This commit is contained in:
Bogdan Gheorghe 2005-07-06 04:10:11 +00:00
parent 1594e1b8f9
commit 02c0ca6a3c
3 changed files with 25 additions and 7 deletions

View file

@ -49,6 +49,7 @@ public class BasicSearchMatch implements IMatch, Comparable {
public BasicSearchMatch() { public BasicSearchMatch() {
//Create empty BasicSearchMatch
} }
final static private String HASH_SEPERATOR = ":"; //$NON-NLS-1$ final static private String HASH_SEPERATOR = ":"; //$NON-NLS-1$

View file

@ -216,7 +216,7 @@ public class MethodDeclarationPattern extends CSearchPattern {
} }
if (returnTypeExists){ if (returnTypeExists){
this.returnTypes = missmatch[returnStart + 1].toCharArray(); this.decodedReturnTypes = missmatch[returnStart + 1].toCharArray();
} }
} }
@ -249,12 +249,12 @@ public class MethodDeclarationPattern extends CSearchPattern {
* @param decodedReturnTypes * @param decodedReturnTypes
* @return * @return
*/ */
private boolean matchReturnType(char[] returnTypes, char[] decodedReturnTypes) { private boolean matchReturnType(char[] tempReturnTypes, char[] tempDecodedReturnTypes) {
if( returnTypes == null || decodedReturnTypes == null ){ if( tempReturnTypes == null || tempDecodedReturnTypes == null ){
return true; //treat null as "*" return true; //treat null as "*"
} }
return CharOperation.equals( returnTypes, decodedReturnTypes, true); return CharOperation.equals( tempReturnTypes, tempDecodedReturnTypes, true);
} }
private boolean matchParameters(char[][] parameterNames2, char[][] decodedParameters2) { private boolean matchParameters(char[][] parameterNames2, char[][] decodedParameters2) {
@ -291,7 +291,7 @@ public class MethodDeclarationPattern extends CSearchPattern {
for (int j=0; j<offsets[i].length; j++){ for (int j=0; j<offsets[i].length; j++){
BasicSearchMatch match = new BasicSearchMatch(); BasicSearchMatch match = new BasicSearchMatch();
match.setName(new String(this.decodedSimpleName)); match.setName(new String(this.decodedSimpleName));
//Decode the offsetse //Decode the offsets
//Offsets can either be IIndex.LINE or IIndex.OFFSET //Offsets can either be IIndex.LINE or IIndex.OFFSET
match.setLocatable(getMatchLocatable(offsets[i][j],offsetLengths[i][j])); match.setLocatable(getMatchLocatable(offsets[i][j],offsetLengths[i][j]));
match.setParentName(""); //$NON-NLS-1$ match.setParentName(""); //$NON-NLS-1$
@ -301,6 +301,19 @@ public class MethodDeclarationPattern extends CSearchPattern {
match.setType(ICElement.C_FUNCTION); match.setType(ICElement.C_FUNCTION);
} }
if (this.decodedParameters.length > 0){
String[] parms = new String[decodedParameters.length];
for (int k=0; k<this.decodedParameters.length; k++){
parms[k]=new String(decodedParameters[k]);
}
match.setParameters(parms);
}
if (this.decodedReturnTypes != null){
match.setReturnType(new String(this.decodedReturnTypes));
}
IFile tempFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); IFile tempFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
if (tempFile != null && tempFile.exists()) if (tempFile != null && tempFile.exists())
match.setResource(tempFile); match.setResource(tempFile);

View file

@ -120,6 +120,10 @@ public abstract class FindAction extends SelectionParseAction {
ICElement element = (ICElement) obj; ICElement element = (ICElement) obj;
CSearchQuery job = createSearchQuery( getFullyQualifiedName(element), CSearchUtil.getSearchForFromElement(element)); CSearchQuery job = createSearchQuery( getFullyQualifiedName(element), CSearchUtil.getSearchForFromElement(element));
if (job == null)
return;
NewSearchUI.activateSearchResultView(); NewSearchUI.activateSearchResultView();
NewSearchUI.runQueryInBackground(job); NewSearchUI.runQueryInBackground(job);
@ -309,13 +313,13 @@ public abstract class FindAction extends SelectionParseAction {
//or Working Copy (both represented by C_UNIT) or hit a null //or Working Copy (both represented by C_UNIT) or hit a null
if (element.getElementType() == ICElement.C_UNIT || if (element.getElementType() == ICElement.C_UNIT ||
element == null){ element == null){
fullName.insert(0,"::"); fullName.insert(0,"::"); //$NON-NLS-1$
break; break;
} }
else if (element.getElementType() != ICElement.C_ENUMERATION){ else if (element.getElementType() != ICElement.C_ENUMERATION){
//get the parent name as long as it is not an enumeration - enumerators //get the parent name as long as it is not an enumeration - enumerators
//don't use the enumeration name as part of the fully qualified name //don't use the enumeration name as part of the fully qualified name
fullName.insert(0,"::"); fullName.insert(0,"::"); //$NON-NLS-1$
fullName.insert(0,element.getElementName()); fullName.insert(0,element.getElementName());
} }
} }