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:
parent
1594e1b8f9
commit
02c0ca6a3c
3 changed files with 25 additions and 7 deletions
|
@ -49,6 +49,7 @@ public class BasicSearchMatch implements IMatch, Comparable {
|
|||
|
||||
|
||||
public BasicSearchMatch() {
|
||||
//Create empty BasicSearchMatch
|
||||
}
|
||||
|
||||
final static private String HASH_SEPERATOR = ":"; //$NON-NLS-1$
|
||||
|
|
|
@ -216,7 +216,7 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
|||
}
|
||||
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
private boolean matchReturnType(char[] returnTypes, char[] decodedReturnTypes) {
|
||||
if( returnTypes == null || decodedReturnTypes == null ){
|
||||
private boolean matchReturnType(char[] tempReturnTypes, char[] tempDecodedReturnTypes) {
|
||||
if( tempReturnTypes == null || tempDecodedReturnTypes == null ){
|
||||
return true; //treat null as "*"
|
||||
}
|
||||
|
||||
return CharOperation.equals( returnTypes, decodedReturnTypes, true);
|
||||
return CharOperation.equals( tempReturnTypes, tempDecodedReturnTypes, true);
|
||||
}
|
||||
|
||||
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++){
|
||||
BasicSearchMatch match = new BasicSearchMatch();
|
||||
match.setName(new String(this.decodedSimpleName));
|
||||
//Decode the offsetse
|
||||
//Decode the offsets
|
||||
//Offsets can either be IIndex.LINE or IIndex.OFFSET
|
||||
match.setLocatable(getMatchLocatable(offsets[i][j],offsetLengths[i][j]));
|
||||
match.setParentName(""); //$NON-NLS-1$
|
||||
|
@ -301,6 +301,19 @@ public class MethodDeclarationPattern extends CSearchPattern {
|
|||
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));
|
||||
if (tempFile != null && tempFile.exists())
|
||||
match.setResource(tempFile);
|
||||
|
|
|
@ -120,6 +120,10 @@ public abstract class FindAction extends SelectionParseAction {
|
|||
ICElement element = (ICElement) obj;
|
||||
|
||||
CSearchQuery job = createSearchQuery( getFullyQualifiedName(element), CSearchUtil.getSearchForFromElement(element));
|
||||
|
||||
if (job == null)
|
||||
return;
|
||||
|
||||
NewSearchUI.activateSearchResultView();
|
||||
|
||||
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
|
||||
if (element.getElementType() == ICElement.C_UNIT ||
|
||||
element == null){
|
||||
fullName.insert(0,"::");
|
||||
fullName.insert(0,"::"); //$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
else if (element.getElementType() != ICElement.C_ENUMERATION){
|
||||
//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
|
||||
fullName.insert(0,"::");
|
||||
fullName.insert(0,"::"); //$NON-NLS-1$
|
||||
fullName.insert(0,element.getElementName());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue