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

Bug 340664: NPE in content assist.

This commit is contained in:
Markus Schorn 2011-03-28 13:43:52 +00:00
parent 45d8d40d08
commit 33f54a1614
3 changed files with 25 additions and 1 deletions

View file

@ -337,4 +337,25 @@ public class BasicCompletionTest extends CompletionTestBase {
String[] expected= {"fooBar", "foo_bar"};
checkCompletion(code, false, expected);
}
// void someFunction() {
// int abc[5];
// sizeof(ab
public void testCompletionInSizeof340664() throws Exception {
String code = getAboveComment();
String[] expected= {"abc"};
checkCompletion(code, false, expected);
checkCompletion(code, true, expected);
}
// typedef int abc;
// struct X {
// X(ab
public void testCompletionInParamlistOfCtor_338949() throws Exception {
String code = getAboveComment();
String[] expected= {"abc"};
checkCompletion(code, false, expected);
checkCompletion(code, true, expected);
}
}

View file

@ -103,6 +103,9 @@ public class ASTQueries {
* Searches for the innermost declarator that contributes the the type declared.
*/
public static IASTDeclarator findTypeRelevantDeclarator(IASTDeclarator declarator) {
if (declarator == null)
return null;
IASTDeclarator result= findInnermostDeclarator(declarator);
while (result.getPointerOperators().length == 0
&& !(result instanceof IASTFieldDeclarator)

View file

@ -521,7 +521,7 @@ class ImplicitsAnalysis {
private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) {
boolean result= false;
IASTDeclarator pdtor= ASTQueries.findTypeRelevantDeclarator(dec.getDeclarator());
if (pdtor.getPointerOperators().length == 1 &&
if (pdtor != null && pdtor.getPointerOperators().length == 1 &&
pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator &&
pdtor.getParent() == dec &&
dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {