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:
parent
45d8d40d08
commit
33f54a1614
3 changed files with 25 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue