Commit 348b3b3e authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Simplify things and get rid of unnecessary stuff

parent ca62efab
......@@ -27,7 +27,6 @@ class LSPClientHoverImpl : public LSPClientHover
QSharedPointer<LSPClientServerManager> m_manager;
QSharedPointer<LSPClientServer> m_server;
LspTooltip m_tooltip;
LSPClientServer::RequestHandle m_handle;
......@@ -65,7 +64,7 @@ public:
// hack: delayed handling of tooltip on our own, the API is too dumb for a-sync feedback ;=)
if (m_server) {
QPointer<KTextEditor::View> v(view);
auto h = [this, v, position](const LSPHover &info) {
auto h = [v, position](const LSPHover &info) {
if (!v || info.contents.isEmpty()) {
return;
}
......@@ -79,7 +78,7 @@ public:
finalTooltip.append(element.value);
}
m_tooltip.show(finalTooltip, v->mapToGlobal(v->cursorToCoordinate(position)), v);
LspTooltip::show(finalTooltip, v->mapToGlobal(v->cursorToCoordinate(position)), v);
};
if (view && view->document()) {
......
......@@ -4,17 +4,13 @@
#include <QEvent>
#include <QFontMetrics>
#include <QLabel>
#include <QLayout>
#include <QMouseEvent>
#include <QString>
#include <QStyle>
#include <QTextBrowser>
#include <QTimer>
#include <QWidget>
#include <KTextEditor/ConfigInterface>
#include <KTextEditor/Editor>
#include <KTextEditor/MainWindow>
#include <KTextEditor/View>
#include <KSyntaxHighlighting/AbstractHighlighter>
......@@ -48,7 +44,7 @@ class HtmlHl : public AbstractHighlighter
{
public:
HtmlHl()
: out(&strout)
: out(&outputString)
{
}
......@@ -56,9 +52,11 @@ public:
{
text = txt;
QTextStream in(&text);
KSyntaxHighlighting::State state;
out.reset();
strout.clear();
outputString.clear();
KSyntaxHighlighting::State state;
bool li = false;
while (!in.atEnd()) {
currentLine = in.readLine();
......@@ -86,11 +84,11 @@ public:
}
}
QString html()
QString html() const
{
// while (!out.atEnd())
// qWarning() << out.readLine();
return strout;
return outputString;
}
protected:
......@@ -99,18 +97,14 @@ protected:
if (!length)
return;
QVarLengthArray<QString, 1> formatOutput;
QString formatOutput;
if (format.hasTextColor(theme())) {
formatOutput << toHtmlRgbaString(format.textColor(theme())) << QStringLiteral(";");
formatOutput = toHtmlRgbaString(format.textColor(theme()));
}
if (!formatOutput.isEmpty()) {
out << "<span style=\"color:";
for (const auto &o : qAsConst(formatOutput)) {
out << o;
}
out << "\">";
out << "<span style=\"color:" << formatOutput << "\">";
}
out << currentLine.mid(offset, length).toHtmlEscaped();
......@@ -123,7 +117,7 @@ protected:
private:
QString text;
QString currentLine;
QString strout;
QString outputString;
QTextStream out;
};
......@@ -263,10 +257,6 @@ private:
KSyntaxHighlighting::Repository r;
};
LspTooltip::LspTooltip()
{
}
void LspTooltip::show(const QString &text, QPoint pos, KTextEditor::View *v)
{
if (text.isEmpty())
......
......@@ -15,11 +15,7 @@ class View;
class LspTooltip
{
public:
LspTooltip();
void show(const QString &text, QPoint pos, KTextEditor::View *v);
private:
Tooltip *m_tooltip;
static void show(const QString &text, QPoint pos, KTextEditor::View *v);
};
#endif // LSPTOOLTIP_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment