forked from qt-creator/qt-creator
CMakePM: Remove comment line lexer addition
This brings the lexer back to vanilla CMake version. The comment arguments were not needed in the implementation of source file addition / rename / removal operations. Change-Id: If28b738b9ce93511b109fe09dcd03f42ee07a431 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -75,8 +75,7 @@ bool cmListFileParser::Parse()
|
|||||||
if (token->type == cmListFileLexer_Token_Space) {
|
if (token->type == cmListFileLexer_Token_Space) {
|
||||||
} else if (token->type == cmListFileLexer_Token_Newline) {
|
} else if (token->type == cmListFileLexer_Token_Newline) {
|
||||||
haveNewline = true;
|
haveNewline = true;
|
||||||
} else if (token->type == cmListFileLexer_Token_CommentBracket
|
} else if (token->type == cmListFileLexer_Token_CommentBracket) {
|
||||||
|| token->type == cmListFileLexer_Token_CommentLine) {
|
|
||||||
haveNewline = false;
|
haveNewline = false;
|
||||||
} else if (token->type == cmListFileLexer_Token_Identifier) {
|
} else if (token->type == cmListFileLexer_Token_Identifier) {
|
||||||
if (haveNewline) {
|
if (haveNewline) {
|
||||||
@@ -187,11 +186,6 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this->Separation = SeparationWarning;
|
this->Separation = SeparationWarning;
|
||||||
} else if (token->type == cmListFileLexer_Token_CommentLine) {
|
|
||||||
if (!this->AddArgument(token, cmListFileArgument::Comment)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this->Separation = SeparationWarning;
|
|
||||||
} else if (token->type == cmListFileLexer_Token_ArgumentBracket) {
|
} else if (token->type == cmListFileLexer_Token_ArgumentBracket) {
|
||||||
if (!this->AddArgument(token, cmListFileArgument::Bracket)) {
|
if (!this->AddArgument(token, cmListFileArgument::Bracket)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ struct cmListFileArgument
|
|||||||
{
|
{
|
||||||
Unquoted,
|
Unquoted,
|
||||||
Quoted,
|
Quoted,
|
||||||
Bracket,
|
Bracket
|
||||||
Comment
|
|
||||||
};
|
};
|
||||||
cmListFileArgument() = default;
|
cmListFileArgument() = default;
|
||||||
cmListFileArgument(std::string v, Delimiter d, long line, long column)
|
cmListFileArgument(std::string v, Delimiter d, long line, long column)
|
||||||
|
|||||||
@@ -755,7 +755,7 @@ This file must be translated to C and modified to build everywhere.
|
|||||||
|
|
||||||
Run flex >= 2.6 like this:
|
Run flex >= 2.6 like this:
|
||||||
|
|
||||||
flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l
|
flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.cxx cmListFileLexer.in.l
|
||||||
|
|
||||||
Modify cmListFileLexer.c:
|
Modify cmListFileLexer.c:
|
||||||
- remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
|
- remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
|
||||||
@@ -1172,10 +1172,7 @@ YY_RULE_SETUP
|
|||||||
case 4:
|
case 4:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
{
|
{
|
||||||
lexer->token.type = cmListFileLexer_Token_CommentLine;
|
|
||||||
cmListFileLexerSetToken(lexer, yytext, yyleng);
|
|
||||||
lexer->column += yyleng;
|
lexer->column += yyleng;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 5:
|
case 5:
|
||||||
@@ -2828,8 +2825,7 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
|
|||||||
return "unterminated bracket";
|
return "unterminated bracket";
|
||||||
case cmListFileLexer_Token_BadString:
|
case cmListFileLexer_Token_BadString:
|
||||||
return "unterminated string";
|
return "unterminated string";
|
||||||
case cmListFileLexer_Token_CommentLine:
|
|
||||||
return "line comment";
|
|
||||||
}
|
}
|
||||||
return "unknown token";
|
return "unknown token";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ typedef enum cmListFileLexer_Type_e
|
|||||||
cmListFileLexer_Token_CommentBracket,
|
cmListFileLexer_Token_CommentBracket,
|
||||||
cmListFileLexer_Token_BadCharacter,
|
cmListFileLexer_Token_BadCharacter,
|
||||||
cmListFileLexer_Token_BadBracket,
|
cmListFileLexer_Token_BadBracket,
|
||||||
cmListFileLexer_Token_BadString,
|
cmListFileLexer_Token_BadString
|
||||||
cmListFileLexer_Token_CommentLine
|
|
||||||
} cmListFileLexer_Type;
|
} cmListFileLexer_Type;
|
||||||
|
|
||||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||||
|
|||||||
@@ -110,10 +110,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
|
|||||||
}
|
}
|
||||||
|
|
||||||
<COMMENT>[^\0\n]* {
|
<COMMENT>[^\0\n]* {
|
||||||
lexer->token.type = cmListFileLexer_Token_CommentLine;
|
|
||||||
cmListFileLexerSetToken(lexer, yytext, yyleng);
|
|
||||||
lexer->column += yyleng;
|
lexer->column += yyleng;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
\( {
|
\( {
|
||||||
@@ -541,8 +538,6 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
|
|||||||
return "unterminated bracket";
|
return "unterminated bracket";
|
||||||
case cmListFileLexer_Token_BadString:
|
case cmListFileLexer_Token_BadString:
|
||||||
return "unterminated string";
|
return "unterminated string";
|
||||||
case cmListFileLexer_Token_CommentLine:
|
|
||||||
return "line comment";
|
|
||||||
}
|
}
|
||||||
return "unknown token";
|
return "unknown token";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,11 +432,10 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
|
|||||||
for (const auto &func : {function, targetSourcesFunc, addQmlModuleFunc}) {
|
for (const auto &func : {function, targetSourcesFunc, addQmlModuleFunc}) {
|
||||||
if (func == cmakeListFile.Functions.end())
|
if (func == cmakeListFile.Functions.end())
|
||||||
continue;
|
continue;
|
||||||
auto filePathArgument
|
auto filePathArgument = Utils::findOrDefault(func->Arguments(),
|
||||||
= Utils::findOrDefault(func->Arguments(),
|
[file_name = fileName.toStdString()](
|
||||||
[file_name = fileName.toStdString()](const auto &arg) {
|
const auto &arg) {
|
||||||
return arg.Delim != cmListFileArgument::Comment
|
return arg.Value == file_name;
|
||||||
&& arg.Value == file_name;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!filePathArgument.Value.empty()) {
|
if (!filePathArgument.Value.empty()) {
|
||||||
@@ -456,9 +455,7 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
|
|||||||
|
|
||||||
const auto haveGlobbing = Utils::anyOf(func->Arguments(),
|
const auto haveGlobbing = Utils::anyOf(func->Arguments(),
|
||||||
[globVariables](const auto &arg) {
|
[globVariables](const auto &arg) {
|
||||||
return globVariables.contains(arg.Value)
|
return globVariables.contains(arg.Value);
|
||||||
&& arg.Delim
|
|
||||||
!= cmListFileArgument::Comment;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (haveGlobbing) {
|
if (haveGlobbing) {
|
||||||
@@ -475,20 +472,15 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
for (const auto &arg : func->Arguments()) {
|
for (const auto &arg : func->Arguments()) {
|
||||||
if (arg.Delim == cmListFileArgument::Comment)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto matchedFunctions = Utils::filtered(setFunctions, [arg](const auto &f) {
|
auto matchedFunctions = Utils::filtered(setFunctions, [arg](const auto &f) {
|
||||||
return arg.Value == std::string("${") + f.Arguments()[0].Value + "}";
|
return arg.Value == std::string("${") + f.Arguments()[0].Value + "}";
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const auto &f : matchedFunctions) {
|
for (const auto &f : matchedFunctions) {
|
||||||
filePathArgument
|
filePathArgument = Utils::findOrDefault(f.Arguments(),
|
||||||
= Utils::findOrDefault(f.Arguments(),
|
|
||||||
[file_name = fileName.toStdString()](
|
[file_name = fileName.toStdString()](
|
||||||
const auto &arg) {
|
const auto &arg) {
|
||||||
return arg.Delim != cmListFileArgument::Comment
|
return arg.Value == file_name;
|
||||||
&& arg.Value == file_name;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!filePathArgument.Value.empty()) {
|
if (!filePathArgument.Value.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user