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

Bug 415495 - typedef/type alias change code completion proposals

Change-Id: I963ff5fc2ae073f233b04eb6a5a521d0e6610af7
Signed-off-by: Michi <woskimi@yahoo.de>
Reviewed-on: https://git.eclipse.org/r/38029
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Michi 2014-05-14 12:07:29 +02:00 committed by Sergey Prigogin
parent 07dcb970fa
commit 702f5cb4c8
2 changed files with 28 additions and 6 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2013 IBM Corporation and others. * Copyright (c) 2004, 2014 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
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
@ -325,9 +326,15 @@ public class CPPASTQualifiedName extends CPPASTNameBase
@Override @Override
public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) { public IBinding[] findBindings(IASTName n, boolean isPrefix, String[] namespaces) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces); IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix, namespaces);
if (fQualifierPos >= 0) { if (fQualifierPos >= 0) {
IBinding binding = fQualifier[fQualifierPos].resolveBinding(); IBinding binding = fQualifier[fQualifierPos].resolveBinding();
while (binding instanceof ITypedef) {
ITypedef typedef = (ITypedef) binding;
binding = (IBinding) typedef.getType();
}
if (binding instanceof ICPPClassType) { if (binding instanceof ICPPClassType) {
ICPPClassType classType = (ICPPClassType) binding; ICPPClassType classType = (ICPPClassType) binding;
final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration; final boolean isDeclaration = getParent().getParent() instanceof IASTSimpleDeclaration;

View file

@ -17,6 +17,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist2; package org.eclipse.cdt.ui.tests.text.contentassist2;
import static org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest.CompareType.CONTEXT;
import static org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest.CompareType.DISPLAY;
import static org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest.CompareType.ID;
import static org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest.CompareType.REPLACEMENT;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
@ -36,8 +41,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import static org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest.CompareType.*;
/** /**
* A collection of code completion tests. * A collection of code completion tests.
* *
@ -99,6 +102,7 @@ public class CompletionTests extends AbstractContentAssistTest {
// void m1private(); // void m1private();
// }; // };
// typedef C1 T1; // typedef C1 T1;
// using A1 = C1;
// //
// class C2 : public T1 { // class C2 : public T1 {
// public: // public:
@ -667,8 +671,7 @@ public class CompletionTests extends AbstractContentAssistTest {
//# d/*cursor*/ //# d/*cursor*/
public void testCompletePreprocessorDirective2() throws Exception { public void testCompletePreprocessorDirective2() throws Exception {
final String[] expected= { "define " }; final String[] expected= { "define " };
assertCompletionResults(fCursorOffset, expected, assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
REPLACEMENT);
} }
//# if d/*cursor*/ //# if d/*cursor*/
@ -691,6 +694,18 @@ public class CompletionTests extends AbstractContentAssistTest {
assertCompletionResults(fCursorOffset, expected, ID); assertCompletionResults(fCursorOffset, expected, ID);
} }
//void f(){T1::~/*cursor*/
public void testTypedefSyntheticMembers_415495() throws Exception {
final String[] expected= {};
assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
}
//void f(){A1::~/*cursor*/
public void testAliasSyntheticMembers_415495() throws Exception {
final String[] expected= {};
assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
}
// struct A {}; // struct A {};
// //
// template<typename T> // template<typename T>