mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +02:00
Missing type proposals in qualified names, bug 255898
This commit is contained in:
parent
cec0ba6d45
commit
60311183ca
3 changed files with 35 additions and 19 deletions
|
@ -24,9 +24,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
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.IType;
|
||||||
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.ICPPASTOperatorName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
|
@ -314,25 +314,28 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < bindings.length; i++) {
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
if (bindings[i] instanceof IField) {
|
final IBinding binding = bindings[i];
|
||||||
IField field = (IField) bindings[i];
|
if (binding instanceof IField) {
|
||||||
if (!field.isStatic()) continue;
|
IField field = (IField) binding;
|
||||||
} else if (bindings[i] instanceof ICPPMethod) {
|
if (!field.isStatic())
|
||||||
ICPPMethod method = (ICPPMethod) bindings[i];
|
|
||||||
if (method.isImplicit()) continue;
|
|
||||||
if (method.isDestructor() || method instanceof ICPPConstructor) {
|
|
||||||
if (!isDeclaration) continue;
|
|
||||||
} else if (!method.isStatic() && !isDeclaration) {
|
|
||||||
continue;
|
continue;
|
||||||
|
} else if (binding instanceof ICPPMethod) {
|
||||||
|
ICPPMethod method = (ICPPMethod) binding;
|
||||||
|
if (method.isImplicit())
|
||||||
|
continue;
|
||||||
|
if (!isDeclaration) {
|
||||||
|
if (method.isDestructor() || method instanceof ICPPConstructor || !method.isStatic())
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} else if (bindings[i] instanceof ICPPClassType) {
|
} else if (binding instanceof IEnumerator || binding instanceof IEnumerator) {
|
||||||
ICPPClassType type = (ICPPClassType) bindings[i];
|
if (isDeclaration)
|
||||||
if (type.isSameType(classType)) continue;
|
continue;
|
||||||
} else if (!(bindings[i] instanceof IEnumerator || bindings[i] instanceof IEnumeration) || isDeclaration) {
|
} else if (binding instanceof IType) {
|
||||||
continue;
|
IType type = (IType) binding;
|
||||||
}
|
if (type.isSameType(classType))
|
||||||
|
continue;
|
||||||
filtered.add(bindings[i]);
|
}
|
||||||
|
filtered.add(binding);
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,9 +252,10 @@ public class ContentAssistTests extends BaseUITestCase {
|
||||||
cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
|
cu = importFile( "strategy.cpp", c2 ); //$NON-NLS-1$
|
||||||
|
|
||||||
results = getResults( cu, c2.indexOf( "::" ) + 2 ); //$NON-NLS-1$
|
results = getResults( cu, c2.indexOf( "::" ) + 2 ); //$NON-NLS-1$
|
||||||
assertEquals( 2, results.length );
|
assertEquals( 3, results.length );
|
||||||
assertEquals( "getAbility(void) : enum _Ability", results[1].getDisplayString() ); //$NON-NLS-1$
|
assertEquals( "getAbility(void) : enum _Ability", results[1].getDisplayString() ); //$NON-NLS-1$
|
||||||
assertEquals( "Strategy(enum _Ability a)", results[0].getDisplayString() ); //$NON-NLS-1$
|
assertEquals( "Strategy(enum _Ability a)", results[0].getDisplayString() ); //$NON-NLS-1$
|
||||||
|
assertEquals( "_Ability", results[2].getDisplayString() ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug72559() throws Exception {
|
public void testBug72559() throws Exception {
|
||||||
|
|
|
@ -1187,4 +1187,16 @@ public class CompletionTests extends AbstractContentAssistTest {
|
||||||
final String[] expected= {"var : float"};
|
final String[] expected= {"var : float"};
|
||||||
assertCompletionResults(fCursorOffset, expected, COMPARE_DISP_STRINGS);
|
assertCompletionResults(fCursorOffset, expected, COMPARE_DISP_STRINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct X {
|
||||||
|
// typedef int TInt;
|
||||||
|
// };
|
||||||
|
// void main() {
|
||||||
|
// X::T/*cursor*/ // content assist does not propose TInt
|
||||||
|
// }
|
||||||
|
public void testNestedTypesInQualifiedNames_Bug255898() throws Exception {
|
||||||
|
final String[] expected= {"TInt"};
|
||||||
|
assertCompletionResults(fCursorOffset, expected, COMPARE_DISP_STRINGS);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue