1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 353281 - Content assist for designated initializers, additional fix

Change-Id: I534f074f1308f03f341838c87096ef09e3c166a2
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/20094
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Hudson CI
This commit is contained in:
Marc-Andre Laperle 2013-12-19 23:53:10 -05:00
parent b3223dace6
commit 9e3bca14b5
3 changed files with 26 additions and 10 deletions

View file

@ -373,7 +373,17 @@ public class BasicCompletionTest extends CompletionTestBase {
// struct foo { int axx;}; // struct foo { int axx;};
// struct foo bar = {.a // struct foo bar = {.a
public void testCompletionInDesignatedInitializor_353281() throws Exception { public void testCompletionInDesignatedInitializor_353281a() throws Exception {
String code = getAboveComment();
String[] expected= {"axx"};
checkCompletion(code, false, expected);
}
// struct foo { int axx;};
// void func()
// {
// struct foo bar = {.a
public void testCompletionInDesignatedInitializor_353281b() throws Exception {
String code = getAboveComment(); String code = getAboveComment();
String[] expected= {"axx"}; String[] expected= {"axx"};
checkCompletion(code, false, expected); checkCompletion(code, false, expected);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,6 +12,7 @@
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion) * Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
@ -1532,12 +1533,16 @@ public class CVisitor extends ASTQueries {
private static IBinding[] findBindingForContentAssist(ICASTFieldDesignator fd, boolean isPrefix) { private static IBinding[] findBindingForContentAssist(ICASTFieldDesignator fd, boolean isPrefix) {
IASTNode blockItem = getContainingBlockItem(fd); IASTNode blockItem = getContainingBlockItem(fd);
IASTNode parent= blockItem; IASTNode declarationNode = blockItem;
while (parent != null && !(parent instanceof IASTSimpleDeclaration)) if (blockItem instanceof IASTDeclarationStatement && ((IASTDeclarationStatement) blockItem).getDeclaration() instanceof IASTSimpleDeclaration) {
parent= parent.getParent(); declarationNode = ((IASTDeclarationStatement) blockItem).getDeclaration();
} else {
while (declarationNode != null && !(declarationNode instanceof IASTSimpleDeclaration))
declarationNode= declarationNode.getParent();
}
if (parent instanceof IASTSimpleDeclaration) { if (declarationNode instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent; IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declarationNode;
IBinding struct= null; IBinding struct= null;
if (simpleDecl.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) { if (simpleDecl.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) {
struct = ((IASTNamedTypeSpecifier) simpleDecl.getDeclSpecifier()).getName().resolveBinding(); struct = ((IASTNamedTypeSpecifier) simpleDecl.getDeclSpecifier()).getName().resolveBinding();
@ -1554,6 +1559,7 @@ public class CVisitor extends ASTQueries {
} }
} }
} }
return null; return null;
} }

View file

@ -49,7 +49,7 @@ public class LRCompletionBasicTest extends BasicCompletionTest {
@Override @Override
public void testConditionalOperator_Bug308611() throws Exception {} public void testConditionalOperator_Bug308611() throws Exception {}
@Override @Override
public void testCompletionInDesignatedInitializor_353281() throws Exception {} public void testCompletionInDesignatedInitializor_353281a() throws Exception {}
@Override @Override
@SuppressWarnings("unused") @SuppressWarnings("unused")