forked from qt-creator/qt-creator
Clang: Fix adding snippets after opening brace
The regression was introduced by
commit 82d6d20acb
Clang: Do not show completions after comma in initializer list
This fixes ClangCodeCompletionTest::testCompleteGlobals().
Change-Id: Ic126f1e3eaed158196268e3682ff32bc02deb7b9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -168,6 +168,7 @@ void ClangCompletionContextAnalyzer::handleFunctionCall(int afterOperatorPositio
|
||||
} else {
|
||||
const int functionNameStart = startOfFunctionCall(afterOperatorPosition);
|
||||
if (functionNameStart >= 0) {
|
||||
m_addSnippets = functionNameStart == afterOperatorPosition;
|
||||
// Always pass the position right after '(' to libclang because
|
||||
// positions after the comma might be problematic if a preceding
|
||||
// argument is invalid code.
|
||||
|
||||
@@ -564,4 +564,25 @@ TEST_F(ClangCompletionContextAnalyzer, QualifiedFunctionNameStartPosition)
|
||||
ASSERT_THAT(functionNameStartPosition, 1);
|
||||
}
|
||||
|
||||
TEST_F(ClangCompletionContextAnalyzer, SnippetsAfterOpeningBrace)
|
||||
{
|
||||
auto analyzer = runAnalyzer("{@");
|
||||
|
||||
ASSERT_TRUE(analyzer.addSnippets());
|
||||
}
|
||||
|
||||
TEST_F(ClangCompletionContextAnalyzer, NoSnippetsAfterFunctionCallLike_OpeningBrace)
|
||||
{
|
||||
auto analyzer = runAnalyzer("foo{@");
|
||||
|
||||
ASSERT_FALSE(analyzer.addSnippets());
|
||||
}
|
||||
|
||||
TEST_F(ClangCompletionContextAnalyzer, NoSnippetsAfterFunctionCallLike_OpeningParen)
|
||||
{
|
||||
auto analyzer = runAnalyzer("foo(@");
|
||||
|
||||
ASSERT_FALSE(analyzer.addSnippets());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user