mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 415808 - Organize Includes command doesn't add includes for template
arguments
This commit is contained in:
parent
84da897957
commit
7c4c09cb65
3 changed files with 25 additions and 10 deletions
|
@ -347,8 +347,8 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
|
|||
|
||||
// struct D : public C<A> {};
|
||||
public void testTemplate_1() throws Exception {
|
||||
assertDefined("C");
|
||||
assertDeclared("A");
|
||||
assertDefined("A", "C");
|
||||
assertDeclared();
|
||||
}
|
||||
|
||||
// struct A {};
|
||||
|
|
|
@ -167,8 +167,7 @@ public class IncludeOrganizerTest extends IncludesTestBase {
|
|||
//#pragma once
|
||||
//
|
||||
//#include "B.h"
|
||||
//
|
||||
//class C;
|
||||
//#include "C.h"
|
||||
//
|
||||
//namespace ns {
|
||||
//// Comment line 1
|
||||
|
|
|
@ -82,6 +82,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||
|
@ -103,6 +105,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
@ -1114,13 +1117,18 @@ public class BindingClassifier {
|
|||
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding != null) {
|
||||
IBinding owner = binding.getOwner();
|
||||
if (owner instanceof IType) {
|
||||
defineBinding(owner); // Member access requires definition of the containing type.
|
||||
if (binding instanceof IProblemBinding)
|
||||
declareBinding(binding);
|
||||
if (isInTemplateArgument(name)) {
|
||||
// The name is part of a template argument - define the corresponding binding.
|
||||
defineBinding(binding);
|
||||
} else {
|
||||
declareBinding(binding); // Declare the binding of this name.
|
||||
IBinding owner = binding.getOwner();
|
||||
if (owner instanceof IType) {
|
||||
defineBinding(owner); // Member access requires definition of the containing type.
|
||||
if (binding instanceof IProblemBinding)
|
||||
declareBinding(binding);
|
||||
} else {
|
||||
declareBinding(binding); // Declare the binding of this name.
|
||||
}
|
||||
}
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
|
@ -1155,6 +1163,14 @@ public class BindingClassifier {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given name is part of a template argument.
|
||||
*/
|
||||
public boolean isInTemplateArgument(IASTName name) {
|
||||
ICPPASTTypeId typeId = CPPVisitor.findAncestorWithType(name, ICPPASTTypeId.class);
|
||||
return typeId != null && typeId.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT;
|
||||
}
|
||||
|
||||
private static boolean isEnumerationWithoutFixedUnderlyingType(IBinding typeBinding) {
|
||||
return typeBinding instanceof IEnumeration
|
||||
&& (!(typeBinding instanceof ICPPEnumeration) || ((ICPPEnumeration) typeBinding).getFixedType() == null);
|
||||
|
|
Loading…
Add table
Reference in a new issue