Skip to content

Commit d36d8e8

Browse files
i-garrisonjonahgraham
authored andcommitted
Allow refactoring to find local bindings in headers
1 parent b5eb49f commit d36d8e8

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ public IBinding[] getBindings(ScopeLookupData lookup) {
202202
IBinding[] bindings = lookup.isPrefixLookup()
203203
? index.findBindingsForContentAssist(nchars, true, filter, null)
204204
: index.findBindings(nchars, filter, null);
205-
if (fileSet != null) {
205+
// if using promiscuous binding resolution, allow finding local bindings in index
206+
// to help refactoring with typedefs and using declarations which are now local bindings
207+
if (fileSet != null && !CPPSemantics.isUsingPromiscuousBindingResolution()) {
206208
bindings = fileSet.filterFileLocalBindings(bindings);
207209
}
208210
result = ArrayUtil.addAll(IBinding.class, result, bindings);

core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/includes/IncludeOrganizerTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,37 @@ public void testMethodDefinedInHeader() throws Exception {
612612
assertExpectedResults();
613613
}
614614

615+
//h1.h
616+
//struct A {
617+
// template <typename T>
618+
// void m(const T& p);
619+
//};
620+
621+
//h2.h
622+
//#include "h1.h"
623+
//template<typename T>
624+
//void A::m(const T& p) {
625+
//}
626+
627+
//h3.h
628+
//#include "h1.h"
629+
//using B = A;
630+
631+
//source.cpp
632+
//void test(B& b) {
633+
// b.m(1);
634+
//}
635+
//====================
636+
//#include "h2.h"
637+
//#include "h3.h"
638+
//
639+
//void test(B& b) {
640+
// b.m(1);
641+
//}
642+
public void testMethodDefinedInHeaderWithUsingDeclaration() throws Exception {
643+
assertExpectedResults();
644+
}
645+
615646
//a.h
616647
//struct A {
617648
// void a() const;

0 commit comments

Comments
 (0)