CMakeFileCompletionAssist: Limit the size of PerformInputData

The size should drop down to 184 (from 264) bytes.

Amends 07e758147b

Change-Id: Ia07b153f3f75b9e7b6199d857d58bffbb7b3e7d4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-10-09 09:50:43 +02:00
parent a70ead958e
commit 3984108c0c

View File

@@ -254,7 +254,8 @@ class PerformInputData
{ {
public: public:
CMakeKeywords keywords; CMakeKeywords keywords;
CMakeKeywords projectKeywords; QMap<QString, FilePath> projectVariables;
QMap<QString, FilePath> projectFunctions;
QStringList buildTargets; QStringList buildTargets;
QStringList importedTargets; QStringList importedTargets;
QStringList findPackageVariables; QStringList findPackageVariables;
@@ -274,7 +275,9 @@ PerformInputData CMakeFileCompletionAssist::generatePerformInputData() const
for (const auto &target : std::as_const(bs->buildTargets())) for (const auto &target : std::as_const(bs->buildTargets()))
if (target.targetType != TargetType::UtilityType) if (target.targetType != TargetType::UtilityType)
data.buildTargets << target.title; data.buildTargets << target.title;
data.projectKeywords = bs->projectKeywords(); const CMakeKeywords &projectKeywords = bs->projectKeywords();
data.projectVariables = projectKeywords.variables;
data.projectFunctions = projectKeywords.functions;
data.importedTargets = bs->projectImportedTargets(); data.importedTargets = bs->projectImportedTargets();
data.findPackageVariables = bs->projectFindPackageVariables(); data.findPackageVariables = bs->projectFindPackageVariables();
} }
@@ -326,7 +329,7 @@ IAssistProposal *CMakeFileCompletionAssist::doPerform(const PerformInputData &da
if (varGenexToken == "${" || varGenexToken == "$<") { if (varGenexToken == "${" || varGenexToken == "$<") {
if (varGenexToken == "${") { if (varGenexToken == "${") {
items.append(generateList(data.keywords.variables, m_variableIcon)); items.append(generateList(data.keywords.variables, m_variableIcon));
items.append(generateList(data.projectKeywords.variables, m_projectVariableIcon)); items.append(generateList(data.projectVariables, m_projectVariableIcon));
items.append(generateList(data.findPackageVariables, m_projectVariableIcon)); items.append(generateList(data.findPackageVariables, m_projectVariableIcon));
} }
if (varGenexToken == "$<") if (varGenexToken == "$<")
@@ -342,7 +345,7 @@ IAssistProposal *CMakeFileCompletionAssist::doPerform(const PerformInputData &da
|| functionName == "set" || functionName == "list" || functionName == "set" || functionName == "list"
|| functionName == "cmake_print_variables") { || functionName == "cmake_print_variables") {
items.append(generateList(data.keywords.variables, m_variableIcon)); items.append(generateList(data.keywords.variables, m_variableIcon));
items.append(generateList(data.projectKeywords.variables, m_projectVariableIcon)); items.append(generateList(data.projectVariables, m_projectVariableIcon));
items.append(generateList(data.findPackageVariables, m_projectVariableIcon)); items.append(generateList(data.findPackageVariables, m_projectVariableIcon));
items.append(generateList(localVariables, m_variableIcon)); items.append(generateList(localVariables, m_variableIcon));
} }
@@ -390,7 +393,7 @@ IAssistProposal *CMakeFileCompletionAssist::doPerform(const PerformInputData &da
} else if (functionName.isEmpty()) { } else if (functionName.isEmpty()) {
// On a new line we just want functions // On a new line we just want functions
items.append(generateList(data.keywords.functions, m_functionIcon)); items.append(generateList(data.keywords.functions, m_functionIcon));
items.append(generateList(data.projectKeywords.functions, m_projectFunctionIcon)); items.append(generateList(data.projectFunctions, m_projectFunctionIcon));
items.append(generateList(localFunctions, m_functionIcon)); items.append(generateList(localFunctions, m_functionIcon));
// Snippets would make more sense only for the top level suggestions // Snippets would make more sense only for the top level suggestions
@@ -400,7 +403,7 @@ IAssistProposal *CMakeFileCompletionAssist::doPerform(const PerformInputData &da
fileStartPos = addFilePathItems(interface(), items, startPos); fileStartPos = addFilePathItems(interface(), items, startPos);
if (!onlyFileItems()) { if (!onlyFileItems()) {
items.append(generateList(data.keywords.variables, m_variableIcon)); items.append(generateList(data.keywords.variables, m_variableIcon));
items.append(generateList(data.projectKeywords.variables, m_projectVariableIcon)); items.append(generateList(data.projectVariables, m_projectVariableIcon));
items.append(generateList(localVariables, m_variableIcon)); items.append(generateList(localVariables, m_variableIcon));
items.append(generateList(data.findPackageVariables, m_projectVariableIcon)); items.append(generateList(data.findPackageVariables, m_projectVariableIcon));