Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
e4d4d977
Commit
e4d4d977
authored
Dec 30, 2020
by
Waqar Ahmed
Committed by
Mark Nauwelaerts
Dec 29, 2020
Browse files
LSP: Add support for textDocument/implementation
parent
33545f31
Changes
4
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lspclientpluginview.cpp
View file @
e4d4d977
...
...
@@ -208,6 +208,7 @@ class LSPClientActionView : public QObject
QPointer
<
QAction
>
m_findDef
;
QPointer
<
QAction
>
m_findDecl
;
QPointer
<
QAction
>
m_findRef
;
QPointer
<
QAction
>
m_findImpl
;
QPointer
<
QAction
>
m_triggerHighlight
;
QPointer
<
QAction
>
m_triggerSymbolInfo
;
QPointer
<
QAction
>
m_triggerFormat
;
...
...
@@ -328,6 +329,8 @@ public:
m_findDecl
->
setText
(
i18n
(
"Go to Declaration"
));
m_findRef
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"lspclient_find_references"
),
this
,
&
self_type
::
findReferences
);
m_findRef
->
setText
(
i18n
(
"Find References"
));
m_findImpl
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"lspclient_find_implementations"
),
this
,
&
self_type
::
findImplementation
);
m_findImpl
->
setText
(
i18n
(
"Find Implementations"
));
m_triggerHighlight
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"lspclient_highlight"
),
this
,
&
self_type
::
highlight
);
m_triggerHighlight
->
setText
(
i18n
(
"Highlight"
));
m_triggerSymbolInfo
=
actionCollection
()
->
addAction
(
QStringLiteral
(
"lspclient_symbol_info"
),
this
,
&
self_type
::
symbolInfo
);
...
...
@@ -395,6 +398,7 @@ public:
menu
->
addAction
(
m_findDef
);
menu
->
addAction
(
m_findDecl
);
menu
->
addAction
(
m_findRef
);
menu
->
addAction
(
m_findImpl
);
menu
->
addAction
(
m_triggerHighlight
);
menu
->
addAction
(
m_triggerSymbolInfo
);
menu
->
addAction
(
m_triggerFormat
);
...
...
@@ -1231,6 +1235,17 @@ public:
processLocations
<
LSPLocation
>
(
title
,
req
,
true
,
&
self_type
::
locationToRangeItem
);
}
void
findImplementation
()
{
auto
title
=
i18nc
(
"@title:tab"
,
"Implementation: %1"
,
currentWord
());
// clang-format off
auto
req
=
[](
LSPClientServer
&
server
,
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
)
{
return
server
.
documentImplementation
(
document
,
pos
,
context
,
h
);
};
// clang-format on
processLocations
<
LSPLocation
>
(
title
,
req
,
true
,
&
self_type
::
locationToRangeItem
);
}
void
highlight
()
{
// determine current url to capture and use later on
...
...
@@ -1861,7 +1876,7 @@ public:
KTextEditor
::
View
*
activeView
=
m_mainWindow
->
activeView
();
auto
doc
=
activeView
?
activeView
->
document
()
:
nullptr
;
auto
server
=
m_serverManager
->
findServer
(
activeView
);
bool
defEnabled
=
false
,
declEnabled
=
false
,
refEnabled
=
false
;
bool
defEnabled
=
false
,
declEnabled
=
false
,
refEnabled
=
false
,
implEnabled
=
false
;
bool
hoverEnabled
=
false
,
highlightEnabled
=
false
;
bool
formatEnabled
=
false
;
bool
renameEnabled
=
false
;
...
...
@@ -1872,6 +1887,7 @@ public:
// FIXME no real official protocol way to detect, so enable anyway
declEnabled
=
caps
.
declarationProvider
||
true
;
refEnabled
=
caps
.
referencesProvider
;
implEnabled
=
caps
.
implementationProvider
;
hoverEnabled
=
caps
.
hoverProvider
;
highlightEnabled
=
caps
.
documentHighlightProvider
;
formatEnabled
=
caps
.
documentFormattingProvider
||
caps
.
documentRangeFormattingProvider
;
...
...
@@ -1903,6 +1919,8 @@ public:
m_findDecl
->
setEnabled
(
declEnabled
);
if
(
m_findRef
)
m_findRef
->
setEnabled
(
refEnabled
);
if
(
m_findImpl
)
m_findImpl
->
setEnabled
(
implEnabled
);
if
(
m_triggerHighlight
)
m_triggerHighlight
->
setEnabled
(
highlightEnabled
);
if
(
m_triggerSymbolInfo
)
...
...
addons/lspclient/lspclientprotocol.h
View file @
e4d4d977
...
...
@@ -78,6 +78,7 @@ struct LSPServerCapabilities {
// FIXME ? clangd unofficial extension
bool
declarationProvider
=
false
;
bool
referencesProvider
=
false
;
bool
implementationProvider
=
false
;
bool
documentSymbolProvider
=
false
;
bool
documentHighlightProvider
=
false
;
bool
documentFormattingProvider
=
false
;
...
...
addons/lspclient/lspclientserver.cpp
View file @
e4d4d977
...
...
@@ -290,6 +290,7 @@ static void from_json(LSPServerCapabilities &caps, const QJsonObject &json)
caps
.
definitionProvider
=
json
.
value
(
QStringLiteral
(
"definitionProvider"
)).
toBool
();
caps
.
declarationProvider
=
json
.
value
(
QStringLiteral
(
"declarationProvider"
)).
toBool
();
caps
.
referencesProvider
=
json
.
value
(
QStringLiteral
(
"referencesProvider"
)).
toBool
();
caps
.
implementationProvider
=
json
.
value
(
QStringLiteral
(
"implementationProvider"
)).
toBool
();
caps
.
documentSymbolProvider
=
json
.
value
(
QStringLiteral
(
"documentSymbolProvider"
)).
toBool
();
caps
.
documentHighlightProvider
=
json
.
value
(
QStringLiteral
(
"documentHighlightProvider"
)).
toBool
();
caps
.
documentFormattingProvider
=
json
.
value
(
QStringLiteral
(
"documentFormattingProvider"
)).
toBool
();
...
...
@@ -1119,6 +1120,12 @@ public:
return
send
(
init_request
(
QStringLiteral
(
"textDocument/declaration"
),
params
),
h
);
}
RequestHandle
documentImplementation
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
GenericReplyHandler
&
h
)
{
auto
params
=
textDocumentPositionParams
(
document
,
pos
);
return
send
(
init_request
(
QStringLiteral
(
"textDocument/implementation"
),
params
),
h
);
}
RequestHandle
documentHover
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
GenericReplyHandler
&
h
)
{
auto
params
=
textDocumentPositionParams
(
document
,
pos
);
...
...
@@ -1356,6 +1363,11 @@ LSPClientServer::RequestHandle LSPClientServer::documentDefinition(const QUrl &d
return
d
->
documentDefinition
(
document
,
pos
,
make_handler
(
h
,
context
,
parseDocumentLocation
));
}
LSPClientServer
::
RequestHandle
LSPClientServer
::
documentImplementation
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
)
{
return
d
->
documentImplementation
(
document
,
pos
,
make_handler
(
h
,
context
,
parseDocumentLocation
));
}
LSPClientServer
::
RequestHandle
LSPClientServer
::
documentDeclaration
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
)
{
return
d
->
documentDeclaration
(
document
,
pos
,
make_handler
(
h
,
context
,
parseDocumentLocation
));
...
...
addons/lspclient/lspclientserver.h
View file @
e4d4d977
...
...
@@ -106,6 +106,7 @@ public:
RequestHandle
documentSymbols
(
const
QUrl
&
document
,
const
QObject
*
context
,
const
DocumentSymbolsReplyHandler
&
h
,
const
ErrorReplyHandler
&
eh
=
nullptr
);
RequestHandle
documentDefinition
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
);
RequestHandle
documentDeclaration
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
);
RequestHandle
documentImplementation
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
);
RequestHandle
documentHighlight
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentHighlightReplyHandler
&
h
);
RequestHandle
documentHover
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
const
QObject
*
context
,
const
DocumentHoverReplyHandler
&
h
);
RequestHandle
documentReferences
(
const
QUrl
&
document
,
const
LSPPosition
&
pos
,
bool
decl
,
const
QObject
*
context
,
const
DocumentDefinitionReplyHandler
&
h
);
...
...
Write
Preview
Supports
Markdown
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