forked from qt-creator/qt-creator
LanguageClient: Use double for progress reports
Some servers *cough* clangd *cough* report their progress in double instead of the uint defined by the protocol. Since this does not make a huge difference for the LanguageClient or json switch to double for progress. Change-Id: I76454285e5a3b582d6c6a23a6dfbeb5f1cd7631f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -76,8 +76,12 @@ public:
|
|||||||
* The value should be steadily rising. Clients are free to ignore values
|
* The value should be steadily rising. Clients are free to ignore values
|
||||||
* that are not following this rule.
|
* that are not following this rule.
|
||||||
*/
|
*/
|
||||||
Utils::optional<int> percentage() const { return optionalValue<int>(percentageKey); }
|
|
||||||
void setPercentage(int percentage) { insert(percentageKey, percentage); }
|
// Allthough percentage is defined as an uint by the protocol some server
|
||||||
|
// return a double here. Be less strict and also use a double.
|
||||||
|
// CAUTION: the range is still 0 - 100 and not 0 - 1
|
||||||
|
Utils::optional<double> percentage() const { return optionalValue<double>(percentageKey); }
|
||||||
|
void setPercentage(double percentage) { insert(percentageKey, percentage); }
|
||||||
void clearPercentage() { remove(percentageKey); }
|
void clearPercentage() { remove(percentageKey); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -107,9 +107,8 @@ void ProgressManager::reportProgress(const ProgressToken &token,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (progress.futureInterface) {
|
if (progress.futureInterface) {
|
||||||
const Utils::optional<int> &progressValue = report.percentage();
|
if (const Utils::optional<double> &percentage = report.percentage(); percentage.has_value())
|
||||||
if (progressValue.has_value())
|
progress.futureInterface->setProgressValue(*percentage);
|
||||||
progress.futureInterface->setProgressValue(*progressValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user