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.ICPPClassType;
|
||||
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.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||
|
@ -1296,8 +1295,8 @@ public class CPPVisitor {
|
|||
|
||||
|
||||
public CollectReferencesAction( IBinding binding ){
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
binding= ((ICPPDeferredTemplateInstance) binding).getSpecializedBinding();
|
||||
if (binding instanceof ICPPSpecialization) {
|
||||
binding= ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||
}
|
||||
this.binding = binding;
|
||||
this.refs = new IASTName[ DEFAULT_LIST_SIZE ];
|
||||
|
@ -1398,8 +1397,8 @@ public class CPPVisitor {
|
|||
candidate = null;
|
||||
else
|
||||
candidate = bs[ ++n ];
|
||||
} else if (potential instanceof ICPPDeferredTemplateInstance) {
|
||||
candidate= ((ICPPDeferredTemplateInstance) potential).getSpecializedBinding();
|
||||
} else if (potential instanceof ICPPSpecialization) {
|
||||
candidate= ((ICPPSpecialization) potential).getSpecializedBinding();
|
||||
} else {
|
||||
candidate = potential;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ label:
|
|||
template<int X>
|
||||
class ConstantTemplate {
|
||||
public:
|
||||
size_t foo(size_t y) {
|
||||
size_t getNumber(size_t y) {
|
||||
return X;
|
||||
}
|
||||
};
|
||||
|
@ -123,3 +123,5 @@ public:
|
|||
ConstantTemplate<5> c5;
|
||||
ConstantTemplate<5> c52;
|
||||
ConstantTemplate<4> c4;
|
||||
|
||||
const int c= c5.getNumber(0);
|
||||
|
|
|
@ -308,6 +308,19 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
|||
assertOccurrences(2);
|
||||
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() {
|
||||
try {
|
||||
fMatch= fFindReplaceDocumentAdapter.find(0, "pubField", true, true, true, false);
|
||||
|
@ -321,6 +334,19 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
|||
assertOccurrences(2);
|
||||
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() {
|
||||
try {
|
||||
|
@ -436,6 +462,20 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
|||
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() {
|
||||
CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, false);
|
||||
fOccurrences= Integer.MAX_VALUE;
|
||||
|
|
Loading…
Add table
Reference in a new issue