1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Make template related parameter hint tests succeed (bug 172436)

This commit is contained in:
Anton Leherbauer 2007-05-11 10:10:35 +00:00
parent 6d75f34f60
commit 8fac735b74
3 changed files with 55 additions and 17 deletions

View file

@ -31,6 +31,7 @@ public class CompletionTests extends AbstractContentAssistTest {
private static final String CURSOR_LOCATION_TAG = "/*cursor*/";
protected int fCursorOffset;
private boolean fCheckExtraResults= true;
//{CompletionTest.h}
//class C1;
@ -139,6 +140,26 @@ public class CompletionTests extends AbstractContentAssistTest {
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
}
/*
* @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest#doCheckExtraResults()
*/
protected boolean doCheckExtraResults() {
return fCheckExtraResults;
}
private void setCheckExtraResults(boolean check) {
fCheckExtraResults= check;
}
private void assertMinimumCompletionResults(int offset, String[] expected, int compareType) throws Exception {
setCheckExtraResults(false);
try {
assertCompletionResults(offset, expected, compareType);
} finally {
setCheckExtraResults(true);
}
}
protected void assertCompletionResults(int offset, String[] expected, int compareType) throws Exception {
assertContentAssistResults(offset, expected, true, compareType);
}
@ -672,7 +693,7 @@ public class CompletionTests extends AbstractContentAssistTest {
//using namespace ns;void gfunc(){NSC/*cursor*/
public void testUsingDirective() throws Exception {
final String[] expected= {
"NSCONST"
"NSCONST"
};
assertCompletionResults(fCursorOffset, expected,
AbstractContentAssistTest.COMPARE_ID_STRINGS);
@ -681,7 +702,7 @@ public class CompletionTests extends AbstractContentAssistTest {
//void gfunc(){n/*cursor*/
public void testAutoColons() throws Exception {
final String[] expected= {
"ns::"
"ns::"
};
assertCompletionResults(fCursorOffset, expected,
AbstractContentAssistTest.COMPARE_REP_STRINGS);
@ -690,7 +711,7 @@ public class CompletionTests extends AbstractContentAssistTest {
//using namespace /*cursor*/
public void testAutoColons2() throws Exception {
final String[] expected= {
"ns"
"ns"
};
assertCompletionResults(fCursorOffset, expected,
AbstractContentAssistTest.COMPARE_REP_STRINGS);
@ -710,7 +731,7 @@ public class CompletionTests extends AbstractContentAssistTest {
// EditorTestHelper.joinBackgroundActivities((AbstractTextEditor)fEditor);
final String[] expected= {
"aNewGlobalVar"
"aNewGlobalVar"
};
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_ID_STRINGS);
}
@ -718,9 +739,24 @@ public class CompletionTests extends AbstractContentAssistTest {
//void Printer::InitPrinter(unsigned char port) {
// Printer::/*cursor*/
public void testPrivateStaticMember_Bug109480() throws Exception {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109480
final String[] expected= {
"InitPrinter()", "port"
"InitPrinter()", "port"
};
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
}
// class vector3 {
// public:
// void blah(const vector3& v) { x += v./*cursor*/; }
// float x;
// };
public void _testForwardMembersInInlineMethods_Bug185652() throws Exception {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185652
final String[] expected= {
"x"
};
assertMinimumCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
}
}

View file

@ -39,6 +39,8 @@ public class ParameterHintTests extends AbstractContentAssistTest {
//int pi(aClass a);
//int pie(aClass a);
//int pies(aClass a);
//template<class T>class tClass {public:tClass(T t);};
//template<class T>void tFunc(T x, T y);
public ParameterHintTests(String name) {
super(name);
@ -68,8 +70,6 @@ public class ParameterHintTests extends AbstractContentAssistTest {
});
}
////TODO move function into header once indexer supports templates
//template<class T>void tFunc(T x, T y);
//void foo(){tFunc(
public void testTemplateFunction() throws Exception {
assertParameterHints(new String[] {
@ -77,10 +77,8 @@ public class ParameterHintTests extends AbstractContentAssistTest {
});
}
////TODO move function into header once indexer supports templates
//template<class T>void tFunc(T x, T y);
//void foo(){tFunc<int>(
public void _testTemplateFunction2() throws Exception {
public void testTemplateFunction2() throws Exception {
assertParameterHints(new String[] {
"tFunc(T x,T y) void"
});
@ -138,19 +136,14 @@ public class ParameterHintTests extends AbstractContentAssistTest {
});
}
////TODO move class into header once indexer supports templates
//template<class T>class tClass {public:tClass(T t);};
//void foo(){tClass<int> t=new tClass<int>(
public void _testTemplateConstructor() throws Exception {
public void testTemplateConstructor() throws Exception {
assertParameterHints(new String[] {
"tClass(void)",
"tClass(T t)",
"tClass(const tClass &)"
});
}
////TODO move class into header once indexer supports templates
//template<class T>class tClass {public:tClass(T t);};
//void foo(){tClass<int> t(
public void _testTemplateConstructor2() throws Exception {
assertParameterHints(new String[] {

View file

@ -193,7 +193,16 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
token= scanner.previousToken(pos, bound);
if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) {
if (token == Symbols.TokenGREATERTHAN) {
// skip template arguments
pos= scanner.findOpeningPeer(pos - 1, '<', '>');
if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
pos= scanner.findNonWhitespaceBackward(pos - 1, bound);
if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
token= scanner.previousToken(pos, bound);
}
if (token == Symbols.TokenIDENT) {
return pos + 1;
}
}