1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22: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 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[] expected= {"axx"};
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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,6 +12,7 @@
* Andrew Ferguson (Symbian)
* Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
* Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@ -1531,13 +1532,17 @@ public class CVisitor extends ASTQueries {
private static IBinding[] findBindingForContentAssist(ICASTFieldDesignator fd, boolean isPrefix) {
IASTNode blockItem = getContainingBlockItem(fd);
IASTNode parent= blockItem;
while (parent != null && !(parent instanceof IASTSimpleDeclaration))
parent= parent.getParent();
if (parent instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent;
IASTNode declarationNode = blockItem;
if (blockItem instanceof IASTDeclarationStatement && ((IASTDeclarationStatement) blockItem).getDeclaration() instanceof IASTSimpleDeclaration) {
declarationNode = ((IASTDeclarationStatement) blockItem).getDeclaration();
} else {
while (declarationNode != null && !(declarationNode instanceof IASTSimpleDeclaration))
declarationNode= declarationNode.getParent();
}
if (declarationNode instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declarationNode;
IBinding struct= null;
if (simpleDecl.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) {
struct = ((IASTNamedTypeSpecifier) simpleDecl.getDeclSpecifier()).getName().resolveBinding();
@ -1554,6 +1559,7 @@ public class CVisitor extends ASTQueries {
}
}
}
return null;
}

View file

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