forked from qt-creator/qt-creator
clangbackend: Fix crash
We cannot assume that a Q_PROPERTY name is on the same line as the keyword. Fixes: QTCREATORBUG-24746 Change-Id: Ic2e02291e24c1abbaf72881b540a26c82899cb2c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -146,6 +146,7 @@ public:
|
||||
static void TearDownTestCase();
|
||||
|
||||
SourceRange sourceRange(uint line, uint columnEnd) const;
|
||||
SourceRange sourceRangeMultiLine(uint firstLine, uint lastLine, uint columnEnd) const;
|
||||
|
||||
protected:
|
||||
static Data *d;
|
||||
@@ -1574,6 +1575,14 @@ TEST_F(TokenProcessor, QtPropertyName)
|
||||
ASSERT_THAT(infos[8], HasOnlyType(HighlightingType::QtProperty));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyNameMultiLine)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14));
|
||||
|
||||
ASSERT_THAT(infos[0], HasOnlyType(HighlightingType::PreprocessorExpansion));
|
||||
ASSERT_THAT(infos[8], HasOnlyType(HighlightingType::QtProperty));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyFunction)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(599, 103));
|
||||
@@ -1581,6 +1590,13 @@ TEST_F(TokenProcessor, QtPropertyFunction)
|
||||
ASSERT_THAT(infos[10], HasOnlyType(HighlightingType::Function));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyFunctionMultiLine)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14));
|
||||
|
||||
ASSERT_THAT(infos[10], HasOnlyType(HighlightingType::Function));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyInternalKeyword)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(599, 103));
|
||||
@@ -1588,6 +1604,13 @@ TEST_F(TokenProcessor, QtPropertyInternalKeyword)
|
||||
ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Invalid));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyInternalKeywordMultiLine)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14));
|
||||
|
||||
ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Invalid));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyLastToken)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(599, 103));
|
||||
@@ -1595,6 +1618,13 @@ TEST_F(TokenProcessor, QtPropertyLastToken)
|
||||
ASSERT_THAT(infos[14], HasOnlyType(HighlightingType::Function));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyLastTokenMultiLine)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRangeMultiLine(704, 732, 14));
|
||||
|
||||
ASSERT_THAT(infos[14], HasOnlyType(HighlightingType::Function));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, QtPropertyType)
|
||||
{
|
||||
const auto infos = translationUnit.fullTokenInfosInRange(sourceRange(600, 46));
|
||||
@@ -1747,4 +1777,10 @@ ClangBackEnd::SourceRange TokenProcessor::sourceRange(uint line, uint columnEnd)
|
||||
return translationUnit.sourceRange(line, 1, line, columnEnd);
|
||||
}
|
||||
|
||||
ClangBackEnd::SourceRange TokenProcessor::sourceRangeMultiLine(uint firstLine, uint lastLine,
|
||||
uint columnEnd) const
|
||||
{
|
||||
return translationUnit.sourceRange(firstLine, 1, lastLine, columnEnd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user