mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix mark occurrences for template specializations
This commit is contained in:
parent
645d096b60
commit
952046381e
3 changed files with 47 additions and 6 deletions
|
@ -119,7 +119,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
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.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||||
|
@ -1296,8 +1295,8 @@ public class CPPVisitor {
|
||||||
|
|
||||||
|
|
||||||
public CollectReferencesAction( IBinding binding ){
|
public CollectReferencesAction( IBinding binding ){
|
||||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
if (binding instanceof ICPPSpecialization) {
|
||||||
binding= ((ICPPDeferredTemplateInstance) binding).getSpecializedBinding();
|
binding= ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||||
}
|
}
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.refs = new IASTName[ DEFAULT_LIST_SIZE ];
|
this.refs = new IASTName[ DEFAULT_LIST_SIZE ];
|
||||||
|
@ -1398,8 +1397,8 @@ public class CPPVisitor {
|
||||||
candidate = null;
|
candidate = null;
|
||||||
else
|
else
|
||||||
candidate = bs[ ++n ];
|
candidate = bs[ ++n ];
|
||||||
} else if (potential instanceof ICPPDeferredTemplateInstance) {
|
} else if (potential instanceof ICPPSpecialization) {
|
||||||
candidate= ((ICPPDeferredTemplateInstance) potential).getSpecializedBinding();
|
candidate= ((ICPPSpecialization) potential).getSpecializedBinding();
|
||||||
} else {
|
} else {
|
||||||
candidate = potential;
|
candidate = potential;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ label:
|
||||||
template<int X>
|
template<int X>
|
||||||
class ConstantTemplate {
|
class ConstantTemplate {
|
||||||
public:
|
public:
|
||||||
size_t foo(size_t y) {
|
size_t getNumber(size_t y) {
|
||||||
return X;
|
return X;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -123,3 +123,5 @@ public:
|
||||||
ConstantTemplate<5> c5;
|
ConstantTemplate<5> c5;
|
||||||
ConstantTemplate<5> c52;
|
ConstantTemplate<5> c52;
|
||||||
ConstantTemplate<4> c4;
|
ConstantTemplate<4> c4;
|
||||||
|
|
||||||
|
const int c= c5.getNumber(0);
|
||||||
|
|
|
@ -308,6 +308,19 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
||||||
assertOccurrences(2);
|
assertOccurrences(2);
|
||||||
assertOccurrencesInWidget();
|
assertOccurrencesInWidget();
|
||||||
}
|
}
|
||||||
|
public void testMarkMethodOccurrences2() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "getNumber", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
public void testMarkFieldOccurrences() {
|
public void testMarkFieldOccurrences() {
|
||||||
try {
|
try {
|
||||||
fMatch= fFindReplaceDocumentAdapter.find(0, "pubField", true, true, true, false);
|
fMatch= fFindReplaceDocumentAdapter.find(0, "pubField", true, true, true, false);
|
||||||
|
@ -321,6 +334,19 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
||||||
assertOccurrences(2);
|
assertOccurrences(2);
|
||||||
assertOccurrencesInWidget();
|
assertOccurrencesInWidget();
|
||||||
}
|
}
|
||||||
|
public void testMarkFieldOccurrences2() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "tArg1", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
public void testMarkConstructorOccurrences() {
|
public void testMarkConstructorOccurrences() {
|
||||||
try {
|
try {
|
||||||
|
@ -436,6 +462,20 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
||||||
assertOccurrencesInWidget();
|
assertOccurrencesInWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMarkLabelOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "label", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
public void testNoOccurrencesIfDisabled() {
|
public void testNoOccurrencesIfDisabled() {
|
||||||
CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, false);
|
CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, false);
|
||||||
fOccurrences= Integer.MAX_VALUE;
|
fOccurrences= Integer.MAX_VALUE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue