Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Utilities
Kate
Commits
98876895
Commit
98876895
authored
Oct 06, 2020
by
Mark Nauwelaerts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lspclient: also secretly accept LocationLink in some replies
BUG: 427270
parent
ea4fe985
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
addons/lspclient/lspclientserver.cpp
addons/lspclient/lspclientserver.cpp
+22
-1
No files found.
addons/lspclient/lspclientserver.cpp
View file @
98876895
...
...
@@ -53,6 +53,9 @@ static const QString MEMBER_EDIT = QStringLiteral("edit");
static
const
QString
MEMBER_TITLE
=
QStringLiteral
(
"title"
);
static
const
QString
MEMBER_ARGUMENTS
=
QStringLiteral
(
"arguments"
);
static
const
QString
MEMBER_DIAGNOSTICS
=
QStringLiteral
(
"diagnostics"
);
static
const
QString
MEMBER_TARGET_URI
=
QStringLiteral
(
"targetUri"
);
static
const
QString
MEMBER_TARGET_RANGE
=
QStringLiteral
(
"targetRange"
);
static
const
QString
MEMBER_TARGET_SELECTION_RANGE
=
QStringLiteral
(
"targetSelectionRange"
);
// message construction helpers
static
QJsonObject
to_json
(
const
LSPPosition
&
pos
)
...
...
@@ -372,6 +375,18 @@ static LSPLocation parseLocation(const QJsonObject &loc)
return
{
QUrl
(
uri
),
range
};
}
static
LSPLocation
parseLocationLink
(
const
QJsonObject
&
loc
)
{
auto
uri
=
normalizeUrl
(
QUrl
(
loc
.
value
(
MEMBER_TARGET_URI
).
toString
()));
// both should be present, selection contained by the other
// so let's preferentially pick the smallest one
auto
vrange
=
loc
.
value
(
MEMBER_TARGET_SELECTION_RANGE
);
if
(
vrange
.
isUndefined
())
vrange
=
loc
.
value
(
MEMBER_TARGET_RANGE
);
auto
range
=
parseRange
(
vrange
.
toObject
());
return
{
QUrl
(
uri
),
range
};
}
static
LSPDocumentHighlight
parseDocumentHighlight
(
const
QJsonValue
&
result
)
{
auto
hover
=
result
.
toObject
();
...
...
@@ -497,7 +512,13 @@ static QList<LSPLocation> parseDocumentLocation(const QJsonValue &result)
// could be array
if
(
result
.
isArray
())
{
for
(
const
auto
&
def
:
result
.
toArray
())
{
ret
.
push_back
(
parseLocation
(
def
.
toObject
()));
const
auto
&
ob
=
def
.
toObject
();
ret
.
push_back
(
parseLocation
(
ob
));
// bogus server might have sent LocationLink[] instead
// let's try to handle it, but not announce in capabilities
if
(
ret
.
back
().
uri
.
isEmpty
())
{
ret
.
back
()
=
parseLocationLink
(
ob
);
}
}
}
else
if
(
result
.
isObject
())
{
// or a single value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment