This is an automated email from the ASF dual-hosted git repository.
jlahoda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 8d22152 Find Usages for LSP languages - both client and (Java) server.
8d22152 is described below
commit 8d221521d7ea8346a0508248844d892d61689aff
Author: Jan Lahoda <[email protected]>
AuthorDate: Thu Oct 15 06:34:17 2020 +0200
Find Usages for LSP languages - both client and (Java) server.
---
.../modules/cpplite/editor/file/CDataObject.java | 6 +
.../modules/cpplite/editor/file/CPPDataObject.java | 6 +
.../modules/cpplite/editor/file/HDataObject.java | 6 +
.../modules/cpplite/editor/file/HPPDataObject.java | 6 +
ide/lsp.client/external/binaries-list | 12 +-
ide/lsp.client/external/lsp4j-0.8.1-p1-license.txt | 94 -----------
...j-0.8.1-license.txt => lsp4j-0.9.0-license.txt} | 4 +-
...2.18.0-license.txt => xtend-2.19.0-license.txt} | 4 +-
ide/lsp.client/nbproject/project.properties | 12 +-
ide/lsp.client/nbproject/project.xml | 40 +++--
.../src/org/netbeans/modules/lsp/client/Utils.java | 33 ++--
.../client/bindings/CompletionProviderImpl.java | 11 +-
.../lsp/client/bindings/HyperlinkProviderImpl.java | 18 +-
.../lsp/client/bindings/MarkOccurrences.java | 4 +-
.../client/bindings/refactoring/Refactoring.java | 183 +++++++++++++++++++++
.../refactoring/RefactoringActionsProvider.java | 132 +++++++++++++++
.../bindings/refactoring/RefactoringUIImpl.java | 109 ++++++++++++
.../bindings/refactoring/tree/FileTreeElement.java | 96 +++++++++++
.../refactoring/tree/ProjectTreeElement.java | 74 +++++++++
.../refactoring/tree/TreeElementFactoryImpl.java | 65 ++++++++
java/java.lsp.server/external/binaries-list | 6 +-
...2.14.0-license.txt => xtend-2.19.0-license.txt} | 4 +-
java/java.lsp.server/nbproject/project.properties | 6 +-
java/java.lsp.server/nbproject/project.xml | 16 +-
.../modules/java/lsp/server/protocol/Server.java | 1 +
.../server/protocol/TextDocumentServiceImpl.java | 136 ++++++++++++++-
.../java/lsp/server/protocol/ServerTest.java | 126 ++++++++++++++
.../org/netbeans/nbbuild/extlibs/ignored-overlaps | 9 +-
.../editor/TypeScriptDataObjectDataObject.java | 6 +
29 files changed, 1043 insertions(+), 182 deletions(-)
diff --git
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CDataObject.java
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CDataObject.java
index 6faf771..bbaa61d 100644
---
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CDataObject.java
+++
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CDataObject.java
@@ -96,6 +96,12 @@ import org.openide.util.NbBundle.Messages;
path = "Loaders/" + MIMETypes.C + "/Actions",
id = @ActionID(category = "System", id =
"org.openide.actions.PropertiesAction"),
position = 1400
+ ),
+ @ActionReference(
+ path = "Editors/" + MIMETypes.CPP + "/Popup",
+ id = @ActionID(category = "Refactoring", id =
"org.netbeans.modules.refactoring.api.ui.WhereUsedAction"),
+ position = 1400,
+ separatorAfter = 1450
)
})
@GrammarRegistration(grammar="resources/c.tmLanguage.json",
mimeType=MIMETypes.C)
diff --git
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CPPDataObject.java
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CPPDataObject.java
index d6fbbe8..b9fada4 100644
---
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CPPDataObject.java
+++
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/CPPDataObject.java
@@ -96,6 +96,12 @@ import org.openide.util.NbBundle.Messages;
path = "Loaders/" + MIMETypes.CPP + "/Actions",
id = @ActionID(category = "System", id =
"org.openide.actions.PropertiesAction"),
position = 1400
+ ),
+ @ActionReference(
+ path = "Editors/" + MIMETypes.CPP + "/Popup",
+ id = @ActionID(category = "Refactoring", id =
"org.netbeans.modules.refactoring.api.ui.WhereUsedAction"),
+ position = 1400,
+ separatorAfter = 1450
)
})
@GrammarRegistration(grammar="resources/cpp.tmLanguage.json",
mimeType=MIMETypes.CPP)
diff --git
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HDataObject.java
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HDataObject.java
index 64075bb..df473e3 100644
---
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HDataObject.java
+++
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HDataObject.java
@@ -96,6 +96,12 @@ import org.openide.util.NbBundle.Messages;
path = "Loaders/" + MIMETypes.H + "/Actions",
id = @ActionID(category = "System", id =
"org.openide.actions.PropertiesAction"),
position = 1400
+ ),
+ @ActionReference(
+ path = "Editors/" + MIMETypes.CPP + "/Popup",
+ id = @ActionID(category = "Refactoring", id =
"org.netbeans.modules.refactoring.api.ui.WhereUsedAction"),
+ position = 1400,
+ separatorAfter = 1450
)
})
@GrammarRegistration(grammar="resources/c.tmLanguage.json",
mimeType=MIMETypes.H)
diff --git
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HPPDataObject.java
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HPPDataObject.java
index e23f801..ea6349d 100644
---
a/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HPPDataObject.java
+++
b/cpplite/cpplite.editor/src/org/netbeans/modules/cpplite/editor/file/HPPDataObject.java
@@ -96,6 +96,12 @@ import org.openide.util.NbBundle.Messages;
path = "Loaders/" + MIMETypes.HPP + "/Actions",
id = @ActionID(category = "System", id =
"org.openide.actions.PropertiesAction"),
position = 1400
+ ),
+ @ActionReference(
+ path = "Editors/" + MIMETypes.CPP + "/Popup",
+ id = @ActionID(category = "Refactoring", id =
"org.netbeans.modules.refactoring.api.ui.WhereUsedAction"),
+ position = 1400,
+ separatorAfter = 1450
)
})
@GrammarRegistration(grammar="resources/cpp.tmLanguage.json",
mimeType=MIMETypes.HPP)
diff --git a/ide/lsp.client/external/binaries-list
b/ide/lsp.client/external/binaries-list
index dae32bf..a8dc71e 100644
--- a/ide/lsp.client/external/binaries-list
+++ b/ide/lsp.client/external/binaries-list
@@ -15,9 +15,9 @@
# specific language governing permissions and limitations
# under the License.
-7C6F663CCE381A3498D676F080B79E33F4D4761C org.eclipse.lsp4j-0.8.1-p1.jar
-A9BC24A06267C6495439A4D998FCD49899399384
org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.8.1
-4535BD0485FC3E6867B7D5CE0C74E7E7274A3CA4
org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.8.1
-C33EA2BD646E28DE06DF4695142A237C1237CCBC
org.eclipse.xtend:org.eclipse.xtend.lib:2.18.0
-AD3EC3339240D8CC24A4B8F3549B559AC3BC7CDD
org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.18.0
-BA7AFE66B8FC19CCE0C2DA203C56291DA74D410E
org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.18.0
+4FF29B93C50F6768C9A73040AE818E96EB2E68DB
org.eclipse.lsp4j:org.eclipse.lsp4j:0.9.0
+DA453B2A6C9BBD9369DE41365C59E88574EC1F0B
org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.9.0
+1CF7FCE1E2F4DFA76C3B91E4C2D72EA0C6899945
org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.9.0
+751B324BED8C077BF6B7B8C2055595EB8C28509D
org.eclipse.xtend:org.eclipse.xtend.lib:2.19.0
+F3626A047A3ABFA47CF62D76BDEF1D246F7985F6
org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.19.0
+997BA9935D0069B3F1CD2F93B56B91D24E9C60A0
org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.19.0
diff --git a/ide/lsp.client/external/lsp4j-0.8.1-p1-license.txt
b/ide/lsp.client/external/lsp4j-0.8.1-p1-license.txt
deleted file mode 100644
index f7c6a02..0000000
--- a/ide/lsp.client/external/lsp4j-0.8.1-p1-license.txt
+++ /dev/null
@@ -1,94 +0,0 @@
-Name: Eclipse Language Server Protocol Library
-Origin: Eclipse
-Version: 0.8.1-p1
-License: EPL-v20
-URL: http://www.eclipse.org/
-Description: Eclipse Language Server Protocol Library
-Files: org.eclipse.lsp4j-0.8.1-p1.jar
-
-Eclipse Public License - v 2.0
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-1. Definitions
-“Contribution” means:
-
-a) in the case of the initial Contributor, the initial content Distributed
under this Agreement, and
-b) in the case of each subsequent Contributor:
-i) changes to the Program, and
-ii) additions to the Program; where such changes and/or additions to the
Program originate from and are Distributed by that particular Contributor. A
Contribution “originates” from a Contributor if it was added to the Program by
such Contributor itself or anyone acting on such Contributor's behalf.
Contributions do not include changes or additions to the Program that are not
Modified Works.
-“Contributor” means any person or entity that Distributes the Program.
-
-“Licensed Patents” mean patent claims licensable by a Contributor which are
necessarily infringed by the use or sale of its Contribution alone or when
combined with the Program.
-
-“Program” means the Contributions Distributed in accordance with this
Agreement.
-
-“Recipient” means anyone who receives the Program under this Agreement or any
Secondary License (as applicable), including Contributors.
-
-“Derivative Works” shall mean any work, whether in Source Code or other form,
that is based on (or derived from) the Program and for which the editorial
revisions, annotations, elaborations, or other modifications represent, as a
whole, an original work of authorship.
-
-“Modified Works” shall mean any work in Source Code or other form that results
from an addition to, deletion from, or modification of the contents of the
Program, including, for purposes of clarity any new file in Source Code form
that contains any contents of the Program. Modified Works shall not include
works that contain only declarations, interfaces, types, classes, structures,
or files of the Program solely in each case in order to link to, bind by name,
or subclass the Program or M [...]
-
-“Distribute” means the acts of a) distributing or b) making available in any
manner that enables the transfer of a copy.
-
-“Source Code” means the form of a Program preferred for making modifications,
including but not limited to software source code, documentation source, and
configuration files.
-
-“Secondary License” means either the GNU General Public License, Version 2.0,
or any later versions of that license, including any exceptions or additional
permissions as identified by the initial Contributor.
-
-2. Grant of Rights
-a) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free copyright license to
reproduce, prepare Derivative Works of, publicly display, publicly perform,
Distribute and sublicense the Contribution of such Contributor, if any, and
such Derivative Works.
-
-b) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free patent license under
Licensed Patents to make, use, sell, offer to sell, import and otherwise
transfer the Contribution of such Contributor, if any, in Source Code or other
form. This patent license shall apply to the combination of the Contribution
and the Program if, at the time the Contribution is added by the Contributor,
such addition of the Contribution cause [...]
-
-c) Recipient understands that although each Contributor grants the licenses to
its Contributions set forth herein, no assurances are provided by any
Contributor that the Program does not infringe the patent or other intellectual
property rights of any other entity. Each Contributor disclaims any liability
to Recipient for claims brought by any other entity based on infringement of
intellectual property rights or otherwise. As a condition to exercising the
rights and licenses granted here [...]
-
-d) Each Contributor represents that to its knowledge it has sufficient
copyright rights in its Contribution, if any, to grant the copyright license
set forth in this Agreement.
-
-e) Notwithstanding the terms of any Secondary License, no Contributor makes
additional grants to any Recipient (other than those set forth in this
Agreement) as a result of such Recipient's receipt of the Program under the
terms of a Secondary License (if permitted under the terms of Section 3).
-
-3. Requirements
-3.1 If a Contributor Distributes the Program in any form, then:
-
-a) the Program must also be made available as Source Code, in accordance with
section 3.2, and the Contributor must accompany the Program with a statement
that the Source Code for the Program is available under this Agreement, and
informs Recipients how to obtain it in a reasonable manner on or through a
medium customarily used for software exchange; and
-
-b) the Contributor may Distribute the Program under a license different than
this Agreement, provided that such license:
-
-i) effectively disclaims on behalf of all other Contributors all warranties
and conditions, express and implied, including warranties or conditions of
title and non-infringement, and implied warranties or conditions of
merchantability and fitness for a particular purpose;
-ii) effectively excludes on behalf of all other Contributors all liability for
damages, including direct, indirect, special, incidental and consequential
damages, such as lost profits;
-iii) does not attempt to limit or alter the recipients' rights in the Source
Code under section 3.2; and
-iv) requires any subsequent distribution of the Program by any party to be
under a license that satisfies the requirements of this section 3.
-3.2 When the Program is Distributed as Source Code:
-
-a) it must be made available under this Agreement, or if the Program (i) is
combined with other material in a separate file or files made available under a
Secondary License, and (ii) the initial Contributor attached to the Source Code
the notice described in Exhibit A of this Agreement, then the Program may be
made available under the terms of such Secondary Licenses, and
-b) a copy of this Agreement must be included with each copy of the Program.
-3.3 Contributors may not remove or alter any copyright, patent, trademark,
attribution notices, disclaimers of warranty, or limitations of liability
(“notices”) contained within the Program from any copy of the Program which
they Distribute, provided that Contributors may add their own appropriate
notices.
-
-4. Commercial Distribution
-Commercial distributors of software may accept certain responsibilities with
respect to end users, business partners and the like. While this license is
intended to facilitate the commercial use of the Program, the Contributor who
includes the Program in a commercial product offering should do so in a manner
which does not create potential liability for other Contributors. Therefore, if
a Contributor includes the Program in a commercial product offering, such
Contributor (“Commercial Con [...]
-
-For example, a Contributor might include the Program in a commercial product
offering, Product X. That Contributor is then a Commercial Contributor. If that
Commercial Contributor then makes performance claims, or offers warranties
related to Product X, those performance claims and warranties are such
Commercial Contributor's responsibility alone. Under this section, the
Commercial Contributor would have to defend claims against the other
Contributors related to those performance claims [...]
-
-5. No Warranty
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
responsible for determining the appropriateness of using and distributing the
Program and assumes all risks assoc [...]
-
-6. Disclaimer of Liability
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY
LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OR DISTRIBUTION OF THE PROGRAM OR THE EX [...]
-
-7. General
-If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of the
remainder of the terms of this Agreement, and without further action by the
parties hereto, such provision shall be reformed to the minimum extent
necessary to make such provision valid and enforceable.
-
-If Recipient institutes patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Program itself
(excluding combinations of the Program with other software or hardware)
infringes such Recipient's patent(s), then such Recipient's rights granted
under Section 2(b) shall terminate as of the date such litigation is filed.
-
-All Recipient's rights under this Agreement shall terminate if it fails to
comply with any of the material terms or conditions of this Agreement and does
not cure such failure in a reasonable period of time after becoming aware of
such noncompliance. If all Recipient's rights under this Agreement terminate,
Recipient agrees to cease use and distribution of the Program as soon as
reasonably practicable. However, Recipient's obligations under this Agreement
and any licenses granted by Reci [...]
-
-Everyone is permitted to copy and distribute copies of this Agreement, but in
order to avoid inconsistency the Agreement is copyrighted and may only be
modified in the following manner. The Agreement Steward reserves the right to
publish new versions (including revisions) of this Agreement from time to time.
No one other than the Agreement Steward has the right to modify this Agreement.
The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
may assign the respons [...]
-
-Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives
no rights or licenses to the intellectual property of any Contributor under
this Agreement, whether expressly, by implication, estoppel or otherwise. All
rights in the Program not expressly granted under this Agreement are reserved.
Nothing in this Agreement is intended to be enforceable by any entity that is
not a Contributor or Recipient. No third-party beneficiary rights are created
under this Agreement.
-
-Exhibit A - Form of Secondary Licenses Notice
-“This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: {name license(s), version(s), and
exceptions or additional permissions here}.”
-
-Simply including a copy of this Agreement, including this Exhibit A is not
sufficient to license the Source Code under Secondary Licenses.
-
-If it is not possible or desirable to put the notice in a particular file,
then You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a notice.
-
-You may add additional accurate notices of copyright ownership.
diff --git a/ide/lsp.client/external/lsp4j-0.8.1-license.txt
b/ide/lsp.client/external/lsp4j-0.9.0-license.txt
similarity index 99%
rename from ide/lsp.client/external/lsp4j-0.8.1-license.txt
rename to ide/lsp.client/external/lsp4j-0.9.0-license.txt
index 1193c3b..208dfb7 100644
--- a/ide/lsp.client/external/lsp4j-0.8.1-license.txt
+++ b/ide/lsp.client/external/lsp4j-0.9.0-license.txt
@@ -1,10 +1,10 @@
Name: Eclipse Language Server Protocol Library
Origin: Eclipse
-Version: 0.8.1
+Version: 0.9.0
License: EPL-v20
URL: http://www.eclipse.org/
Description: Eclipse Language Server Protocol Library
-Files: org.eclipse.lsp4j.generator-0.8.1.jar
org.eclipse.lsp4j.jsonrpc-0.8.1.jar
+Files: org.eclipse.lsp4j-0.9.0.jar org.eclipse.lsp4j.generator-0.9.0.jar
org.eclipse.lsp4j.jsonrpc-0.9.0.jar
Eclipse Public License - v 2.0
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
diff --git a/ide/lsp.client/external/xtend-2.18.0-license.txt
b/ide/lsp.client/external/xtend-2.19.0-license.txt
similarity index 98%
rename from ide/lsp.client/external/xtend-2.18.0-license.txt
rename to ide/lsp.client/external/xtend-2.19.0-license.txt
index 19b947d..e679f21 100644
--- a/ide/lsp.client/external/xtend-2.18.0-license.txt
+++ b/ide/lsp.client/external/xtend-2.19.0-license.txt
@@ -1,10 +1,10 @@
Name: Eclipse Xtend library
Origin: Eclipse
-Version: 2.18.0
+Version: 2.19.0
License: EPL-v10
URL: http://www.eclipse.org/
Description: Eclipse Xtend library
-Files: org.eclipse.xtend.lib-2.18.0.jar org.eclipse.xtend.lib.macro-2.18.0.jar
org.eclipse.xtext.xbase.lib-2.18.0.jar
+Files: org.eclipse.xtend.lib-2.19.0.jar org.eclipse.xtend.lib.macro-2.19.0.jar
org.eclipse.xtext.xbase.lib-2.19.0.jar
Eclipse Public License - v 1.0
diff --git a/ide/lsp.client/nbproject/project.properties
b/ide/lsp.client/nbproject/project.properties
index ed9efa5..b26ef68 100644
--- a/ide/lsp.client/nbproject/project.properties
+++ b/ide/lsp.client/nbproject/project.properties
@@ -18,10 +18,10 @@
javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
javadoc.arch=${basedir}/arch.xml
-release.external/org.eclipse.lsp4j-0.8.1-p1.jar=modules/ext/org.eclipse.lsp4j-0.8.1-p1.jar
-release.external/org.eclipse.lsp4j.generator-0.8.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.8.1.jar
-release.external/org.eclipse.lsp4j.jsonrpc-0.8.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.8.1.jar
-release.external/org.eclipse.xtend.lib-2.18.0.jar=modules/ext/org.eclipse.xtend.lib-2.18.0.jar
-release.external/org.eclipse.xtend.lib.macro-2.18.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.18.0.jar
-release.external/org.eclipse.xtext.xbase.lib-2.18.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.18.0.jar
+release.external/org.eclipse.lsp4j-0.9.0.jar=modules/ext/org.eclipse.lsp4j-0.9.0.jar
+release.external/org.eclipse.lsp4j.generator-0.9.0.jar=modules/ext/org.eclipse.lsp4j.generator-0.9.0.jar
+release.external/org.eclipse.lsp4j.jsonrpc-0.9.0.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.9.0.jar
+release.external/org.eclipse.xtend.lib-2.19.0.jar=modules/ext/org.eclipse.xtend.lib-2.19.0.jar
+release.external/org.eclipse.xtend.lib.macro-2.19.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.19.0.jar
+release.external/org.eclipse.xtext.xbase.lib-2.19.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.19.0.jar
spec.version.base=1.9.0
diff --git a/ide/lsp.client/nbproject/project.xml
b/ide/lsp.client/nbproject/project.xml
index 4baad62..6fb2dc6 100644
--- a/ide/lsp.client/nbproject/project.xml
+++ b/ide/lsp.client/nbproject/project.xml
@@ -183,6 +183,14 @@
</run-dependency>
</dependency>
<dependency>
+
<code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>1.57</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
<code-name-base>org.netbeans.modules.textmate.lexer</code-name-base>
<build-prerequisite/>
<compile-dependency/>
@@ -297,6 +305,14 @@
<specification-version>9.10</specification-version>
</run-dependency>
</dependency>
+ <dependency>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.87</specification-version>
+ </run-dependency>
+ </dependency>
</module-dependencies>
<test-dependencies>
<test-type>
@@ -354,28 +370,28 @@
<package>org.netbeans.modules.lsp.client.spi</package>
</public-packages>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.lsp4j-0.8.1-p1.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.lsp4j-0.8.1-p1.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.lsp4j-0.9.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.lsp4j-0.9.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.xtend.lib.macro-2.18.0.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.xtend.lib.macro-2.18.0.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.xtend.lib.macro-2.19.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.xtend.lib.macro-2.19.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.lsp4j.generator-0.8.1.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.lsp4j.generator-0.8.1.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.lsp4j.generator-0.9.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.lsp4j.generator-0.9.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.xtend.lib-2.18.0.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.xtend.lib-2.18.0.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.xtend.lib-2.19.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.xtend.lib-2.19.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.xtext.xbase.lib-2.18.0.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.xtext.xbase.lib-2.18.0.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.xtext.xbase.lib-2.19.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.xtext.xbase.lib-2.19.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.lsp4j.jsonrpc-0.8.1.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.lsp4j.jsonrpc-0.8.1.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.lsp4j.jsonrpc-0.9.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.lsp4j.jsonrpc-0.9.0.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/Utils.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/Utils.java
index 278cfbc..ab1c088 100644
--- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/Utils.java
+++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/Utils.java
@@ -248,26 +248,31 @@ public class Utils {
return edits;
}
- public static void open(String targetUri, Range targetRange) {
+ public static FileObject fromURI(String targetUri) {
try {
URI target = URI.create(targetUri);
- FileObject targetFile = URLMapper.findFileObject(target.toURL());
+ return URLMapper.findFileObject(target.toURL());
+ } catch (MalformedURLException ex) {
+ Exceptions.printStackTrace(ex);
+ return null;
+ }
+ }
+
+ public static void open(String targetUri, Range targetRange) {
+ FileObject targetFile = fromURI(targetUri);
- if (targetFile != null) {
- LineCookie lc =
targetFile.getLookup().lookup(LineCookie.class);
+ if (targetFile != null) {
+ LineCookie lc = targetFile.getLookup().lookup(LineCookie.class);
- //TODO: expecting lc != null!
+ //TODO: expecting lc != null!
- Line line =
lc.getLineSet().getCurrent(targetRange.getStart().getLine());
+ Line line =
lc.getLineSet().getCurrent(targetRange.getStart().getLine());
- SwingUtilities.invokeLater(() ->
- line.show(Line.ShowOpenType.OPEN,
Line.ShowVisibilityType.FOCUS, targetRange.getStart().getCharacter())
- );
- } else {
- //TODO: beep
- }
- } catch (MalformedURLException ex) {
- Exceptions.printStackTrace(ex);
+ SwingUtilities.invokeLater(() ->
+ line.show(Line.ShowOpenType.OPEN,
Line.ShowVisibilityType.FOCUS, targetRange.getStart().getCharacter())
+ );
+ } else {
+ //TODO: beep
}
}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
index f3c0fb6..92fcd22 100644
---
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
@@ -25,7 +25,6 @@ import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.net.URL;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
@@ -47,22 +46,18 @@ import org.eclipse.lsp4j.MarkupContent;
import org.eclipse.lsp4j.ParameterInformation;
import org.eclipse.lsp4j.ServerCapabilities;
import org.eclipse.lsp4j.SignatureHelp;
+import org.eclipse.lsp4j.SignatureHelpParams;
import org.eclipse.lsp4j.SignatureInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
-import org.eclipse.lsp4j.TextDocumentPositionParams;
import org.eclipse.lsp4j.TextEdit;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.netbeans.api.editor.completion.Completion;
import org.netbeans.api.editor.mimelookup.MimeRegistration;
-import org.netbeans.api.lexer.Token;
-import org.netbeans.api.lexer.TokenHierarchy;
-import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.Utilities;
import org.netbeans.modules.editor.NbEditorUtilities;
import org.netbeans.modules.lsp.client.LSPBindings;
import org.netbeans.modules.lsp.client.Utils;
-import org.netbeans.modules.textmate.lexer.TextmateTokenId;
import org.netbeans.spi.editor.completion.CompletionDocumentation;
import org.netbeans.spi.editor.completion.CompletionProvider;
import org.netbeans.spi.editor.completion.CompletionResultSet;
@@ -100,8 +95,8 @@ public class CompletionProviderImpl implements
CompletionProvider {
return ;
}
String uri = Utils.toURI(file);
- TextDocumentPositionParams params;
- params = new TextDocumentPositionParams(new
TextDocumentIdentifier(uri),
+ SignatureHelpParams params;
+ params = new SignatureHelpParams(new
TextDocumentIdentifier(uri),
Utils.createPosition(doc, caretOffset));
SignatureHelp help =
server.getTextDocumentService().signatureHelp(params).get();
if (help == null || help.getSignatures().isEmpty()) {
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java
index a460a31..c087b67 100644
---
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java
@@ -18,24 +18,20 @@
*/
package org.netbeans.modules.lsp.client.bindings;
-import java.net.MalformedURLException;
-import java.net.URI;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
+import org.eclipse.lsp4j.DefinitionParams;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.LocationLink;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextDocumentIdentifier;
-import org.eclipse.lsp4j.TextDocumentPositionParams;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.netbeans.api.editor.mimelookup.MimeRegistration;
-import org.netbeans.api.lexer.Language;
import org.netbeans.api.lexer.TokenHierarchy;
import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.editor.BaseDocument;
@@ -46,13 +42,7 @@ import org.netbeans.modules.editor.NbEditorUtilities;
import org.netbeans.modules.lsp.client.LSPBindings;
import org.netbeans.modules.lsp.client.Utils;
import org.netbeans.modules.textmate.lexer.TextmateTokenId;
-import org.netbeans.spi.lexer.LanguageHierarchy;
-import org.openide.cookies.LineCookie;
import org.openide.filesystems.FileObject;
-import org.openide.filesystems.URLMapper;
-import org.openide.text.Line;
-import org.openide.text.Line.ShowOpenType;
-import org.openide.text.Line.ShowVisibilityType;
import org.openide.util.Exceptions;
/**
@@ -110,9 +100,9 @@ public class HyperlinkProviderImpl implements
HyperlinkProviderExt {
}
String uri = Utils.toURI(file);
try {
- TextDocumentPositionParams params;
- params = new TextDocumentPositionParams(new
TextDocumentIdentifier(uri),
- Utils.createPosition(doc,
offset));
+ DefinitionParams params;
+ params = new DefinitionParams(new TextDocumentIdentifier(uri),
+ Utils.createPosition(doc, offset));
//TODO: Location or Location[]
CompletableFuture<Either<List<? extends Location>, List<? extends
LocationLink>>> def = server.getTextDocumentService().definition(params);
def.handleAsync((locations, exception) -> {
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/MarkOccurrences.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/MarkOccurrences.java
index 5ba0ea6..06f0704 100644
---
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/MarkOccurrences.java
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/MarkOccurrences.java
@@ -33,8 +33,8 @@ import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import org.eclipse.lsp4j.DocumentHighlight;
+import org.eclipse.lsp4j.DocumentHighlightParams;
import org.eclipse.lsp4j.TextDocumentIdentifier;
-import org.eclipse.lsp4j.TextDocumentPositionParams;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimeRegistration;
import org.netbeans.api.editor.settings.AttributesUtilities;
@@ -100,7 +100,7 @@ public class MarkOccurrences implements BackgroundTask,
CaretListener, PropertyC
String uri = Utils.toURI(file);
try {
List<? extends DocumentHighlight> highlights =
- server.getTextDocumentService().documentHighlight(new
TextDocumentPositionParams(new TextDocumentIdentifier(uri),
Utils.createPosition(doc, caretPos))).get();
+ server.getTextDocumentService().documentHighlight(new
DocumentHighlightParams(new TextDocumentIdentifier(uri),
Utils.createPosition(doc, caretPos))).get();
for (DocumentHighlight h : highlights) {
result.addHighlight(Utils.getOffset(doc,
h.getRange().getStart()), Utils.getOffset(doc, h.getRange().getEnd()), attr);
}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/Refactoring.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/Refactoring.java
new file mode 100644
index 0000000..c267eb8
--- /dev/null
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/Refactoring.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.lsp.client.bindings.refactoring;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import javax.swing.text.Position;
+import javax.swing.text.StyledDocument;
+import org.eclipse.lsp4j.Location;
+import org.eclipse.lsp4j.ReferenceParams;
+import org.netbeans.modules.lsp.client.LSPBindings;
+import org.netbeans.modules.lsp.client.Utils;
+import org.netbeans.modules.refactoring.api.AbstractRefactoring;
+import org.netbeans.modules.refactoring.api.Problem;
+import org.netbeans.modules.refactoring.api.WhereUsedQuery;
+import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
+import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
+import org.netbeans.modules.refactoring.spi.RefactoringPluginFactory;
+import
org.netbeans.modules.refactoring.spi.SimpleRefactoringElementImplementation;
+import org.openide.cookies.EditorCookie;
+import org.openide.cookies.LineCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.text.CloneableEditorSupport;
+import org.openide.text.Line;
+import org.openide.text.PositionBounds;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+public class Refactoring {
+
+ private static final class WhereUsedRefactoringPlugin implements
RefactoringPlugin {
+
+ private final WhereUsedQuery query;
+ private final LSPBindings bindings;
+ private final ReferenceParams params;
+
+ public WhereUsedRefactoringPlugin(WhereUsedQuery query, LSPBindings
bindings, ReferenceParams params) {
+ this.query = query;
+ this.bindings = bindings;
+ this.params = params;
+ }
+
+ @Override
+ public Problem preCheck() {
+ return null;
+ }
+
+ @Override
+ public Problem checkParameters() {
+ return null;
+ }
+
+ @Override
+ public Problem fastCheckParameters() {
+ return null;
+ }
+
+ @Override
+ public void cancelRequest() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Problem prepare(RefactoringElementsBag refactoringElements) {
+ try {
+ for (Location l :
bindings.getTextDocumentService().references(params).get()) {
+ FileObject file = Utils.fromURI(l.getUri());
+ PositionBounds boundsTemp = null;
+ if (file != null) {
+ try {
+ CloneableEditorSupport es =
file.getLookup().lookup(CloneableEditorSupport.class);
+ EditorCookie ec =
file.getLookup().lookup(EditorCookie.class);
+ StyledDocument doc = ec.openDocument();
+
+ boundsTemp = new
PositionBounds(es.createPositionRef(Utils.getOffset(doc,
l.getRange().getStart()), Position.Bias.Forward),
+
es.createPositionRef(Utils.getOffset(doc, l.getRange().getEnd()),
Position.Bias.Forward));
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
+ boundsTemp = null;
+ }
+ PositionBounds bounds = boundsTemp;
+ LineCookie lc =
file.getLookup().lookup(LineCookie.class);
+ Line startLine =
lc.getLineSet().getCurrent(l.getRange().getStart().getLine());
+ String lineText = startLine.getText();
+ int highlightEnd = Math.min(lineText.length(),
l.getRange().getEnd().getCharacter());
+ String annotatedLine = lineText.substring(0,
l.getRange().getStart().getCharacter()) +
+ "<strong>" +
lineText.substring(l.getRange().getStart().getCharacter(), highlightEnd) +
"</strong>" +
+
lineText.substring(highlightEnd);
+ refactoringElements.add(query, new
LSPRefactoringElementImpl(annotatedLine, file, bounds));
+ }
+ }
+ return null;
+ } catch (InterruptedException | ExecutionException ex) {
+ return new Problem(true, ex.getLocalizedMessage());
+ }
+ }
+
+ }
+
+ public static class LSPRefactoringElementImpl extends
SimpleRefactoringElementImplementation {
+
+ private final String annotatedLine;
+ private final FileObject file;
+ private final PositionBounds bounds;
+
+ public LSPRefactoringElementImpl(String annotatedLine, FileObject
file, PositionBounds bounds) {
+ this.annotatedLine = annotatedLine;
+ this.file = file;
+ this.bounds = bounds;
+ }
+
+ @Override
+ public String getText() {
+ return "TODO: getText";
+ }
+
+ @Override
+ public String getDisplayText() {
+ return annotatedLine;
+ }
+
+ @Override
+ public void performChange() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Lookup getLookup() {
+ return Lookup.EMPTY;
+ }
+
+ @Override
+ public FileObject getParentFile() {
+ return file;
+ }
+
+ @Override
+ public PositionBounds getPosition() {
+ return bounds;
+ }
+ }
+
+
+ @ServiceProvider(service=RefactoringPluginFactory.class)
+ public static class FactoryImpl implements RefactoringPluginFactory {
+
+ @Override
+ public RefactoringPlugin createInstance(AbstractRefactoring
refactoring) {
+ if (refactoring instanceof WhereUsedQuery) {
+ WhereUsedQuery q = (WhereUsedQuery) refactoring;
+ LSPBindings bindings =
q.getRefactoringSource().lookup(LSPBindings.class);
+ ReferenceParams params =
q.getRefactoringSource().lookup(ReferenceParams.class);
+ if (bindings != null && params != null) {
+ return new WhereUsedRefactoringPlugin(q, bindings, params);
+ }
+ }
+ return null;
+ }
+
+ }
+
+}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/RefactoringActionsProvider.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/RefactoringActionsProvider.java
new file mode 100644
index 0000000..c1d72ed
--- /dev/null
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/RefactoringActionsProvider.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.lsp.client.bindings.refactoring;
+
+import javax.swing.Action;
+import javax.swing.JEditorPane;
+import javax.swing.SwingUtilities;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import org.eclipse.lsp4j.Position;
+import org.eclipse.lsp4j.ReferenceContext;
+import org.eclipse.lsp4j.ReferenceParams;
+import org.eclipse.lsp4j.TextDocumentIdentifier;
+import org.netbeans.api.lexer.TokenHierarchy;
+import org.netbeans.api.lexer.TokenSequence;
+import org.netbeans.modules.editor.NbEditorUtilities;
+import org.netbeans.modules.lsp.client.LSPBindings;
+import org.netbeans.modules.lsp.client.Utils;
+import org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider;
+import org.netbeans.modules.refactoring.spi.ui.UI;
+import org.openide.cookies.EditorCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.text.CloneableEditorSupport;
+import org.openide.text.NbDocument;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import org.openide.util.NbBundle.Messages;
+import org.openide.windows.TopComponent;
+
+
+/** Based on RefactoringActionsProvider, ContextAnalyzer, RefactoringUtils,
UIUtilities from refactoring.java.
+ *
+ * @author Jan Becicka
+ */
[email protected]({"WARN_CannotPerformHere=Cannot perform rename here."})
[email protected](service=org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider.class,
position=100)
+public class RefactoringActionsProvider extends ActionsImplementationProvider{
+
+ @Override
+ @Messages("NM_Unknown=Unknown")
+ public void doFindUsages(Lookup lookup) {
+ Runnable start = () -> {
+ EditorCookie ec = lookup.lookup(EditorCookie.class);
+
+ if (isFromEditor(ec)) {
+ try {
+ JEditorPane c = ec.getOpenedPanes()[0];
+ Document doc = c.getDocument();
+ FileObject file = NbEditorUtilities.getFileObject(doc);
+ LSPBindings bindings = LSPBindings.getBindings(file);
+ int caretPos = c.getCaretPosition();
+ Position pos = Utils.createPosition(doc, caretPos);
+ ReferenceParams params = new ReferenceParams();
+ params.setTextDocument(new
TextDocumentIdentifier(Utils.toURI(file)));
+ params.setPosition(pos);
+ params.setContext(new ReferenceContext(false)); //(could
be an option?)
+ TokenSequence<?> ts =
TokenHierarchy.get(doc).tokenSequence();
+ String name = Bundle.NM_Unknown();
+ if (ts != null) {
+ ts.move(caretPos);
+ if (ts.moveNext()) {
+ name = ts.token().text().toString();
+ }
+ }
+
+ UI.openRefactoringUI(new RefactoringUIImpl(bindings,
params, name),
+
TopComponent.getRegistry().getActivated());
+ } catch (BadLocationException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+ };
+ SwingUtilities.invokeLater(start);
+ }
+
+ static String getActionName(Action action) {
+ String arg = (String) action.getValue(Action.NAME);
+ arg = arg.replace("&", ""); // NOI18N
+ return arg.replace("...", ""); // NOI18N
+ }
+
+ @Override
+ public boolean canFindUsages(Lookup lookup) {
+ LSPBindings bindings = getBindings(lookup);
+ if (bindings == null) {
+ return false;
+ }
+ Boolean hasReferences =
bindings.getInitResult().getCapabilities().getReferencesProvider();
+ return hasReferences != null && hasReferences;
+ }
+
+ private LSPBindings getBindings(Lookup lookup) {
+ EditorCookie ec = lookup.lookup(EditorCookie.class);
+ if (isFromEditor(ec)) {
+ JEditorPane c = ec.getOpenedPanes()[0];
+ Document doc = c.getDocument();
+ FileObject file = NbEditorUtilities.getFileObject(doc);
+ LSPBindings bindings = file != null ?
LSPBindings.getBindings(file) : null;
+ return bindings;
+ }
+ return null;
+ }
+
+ public static boolean isFromEditor(EditorCookie ec) {
+ if (ec != null && NbDocument.findRecentEditorPane(ec) != null) {
+ TopComponent activetc = TopComponent.getRegistry().getActivated();
+ if (activetc instanceof CloneableEditorSupport.Pane) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/RefactoringUIImpl.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/RefactoringUIImpl.java
new file mode 100644
index 0000000..665e5cd
--- /dev/null
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/RefactoringUIImpl.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.lsp.client.bindings.refactoring;
+
+import java.awt.Component;
+import javax.swing.JPanel;
+import javax.swing.event.ChangeListener;
+import org.eclipse.lsp4j.ReferenceParams;
+import org.netbeans.modules.lsp.client.LSPBindings;
+import org.netbeans.modules.refactoring.api.AbstractRefactoring;
+import org.netbeans.modules.refactoring.api.Problem;
+import org.netbeans.modules.refactoring.api.WhereUsedQuery;
+import org.netbeans.modules.refactoring.spi.ui.CustomRefactoringPanel;
+import org.netbeans.modules.refactoring.spi.ui.RefactoringUI;
+import org.openide.util.HelpCtx;
+import org.openide.util.NbBundle.Messages;
+import org.openide.util.lookup.Lookups;
+
+/**
+ *
+ * @author lahvac
+ */
+public class RefactoringUIImpl implements RefactoringUI {
+
+ private final LSPBindings bindings;
+ private final ReferenceParams params;
+ private final String name;
+
+ public RefactoringUIImpl(LSPBindings binding, ReferenceParams params,
String name) {
+ this.bindings = binding;
+ this.params = params;
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ @Messages({
+ "# {0} - identifier",
+ "DESC_Usages=Usages of {0}"
+ })
+ public String getDescription() {
+ return Bundle.DESC_Usages(name);
+ }
+
+ @Override
+ public boolean isQuery() {
+ return true;
+ }
+
+ @Override
+ public CustomRefactoringPanel getPanel(ChangeListener parent) {
+ return new CustomRefactoringPanel() {
+ @Override
+ public void initialize() {
+ }
+
+ @Override
+ public Component getComponent() {
+ return new JPanel();
+ }
+ };
+ }
+
+ @Override
+ public Problem setParameters() {
+ return null;
+ }
+
+ @Override
+ public Problem checkParameters() {
+ return null;
+ }
+
+ @Override
+ public boolean hasParameters() {
+ return false;
+ }
+
+ @Override
+ public AbstractRefactoring getRefactoring() {
+ return new WhereUsedQuery(Lookups.fixed(bindings, params));
+ }
+
+ @Override
+ public HelpCtx getHelpCtx() {
+ return HelpCtx.DEFAULT_HELP;
+ }
+
+}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/FileTreeElement.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/FileTreeElement.java
new file mode 100644
index 0000000..872b87f
--- /dev/null
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/FileTreeElement.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.lsp.client.bindings.refactoring.tree;
+
+import java.beans.BeanInfo;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import org.netbeans.api.actions.Openable;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.refactoring.spi.ui.TreeElement;
+import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataObjectNotFoundException;
+import org.openide.text.Line;
+import org.openide.text.NbDocument;
+import org.openide.util.Exceptions;
+
+/**Copied from refactoring.java, and simplified.
+ *
+ * @author Jan Becicka
+ */
+public class FileTreeElement implements TreeElement, Openable {
+
+ private FileObject fo;
+ FileTreeElement(FileObject fo) {
+ this.fo = fo;
+ }
+
+ @Override
+ public TreeElement getParent(boolean isLogical) {
+ if (isLogical) {
+ Project p = FileOwnerQuery.getOwner(fo);
+ if (p != null && p.getProjectDirectory() == fo.getParent()) {
+ return TreeElementFactory.getTreeElement(p);
+ }
+ return TreeElementFactory.getTreeElement(fo.getParent());
+ } else {
+ Project p = FileOwnerQuery.getOwner(fo);
+ if(p != null) {
+ return TreeElementFactory.getTreeElement(p);
+ }
+ return TreeElementFactory.getTreeElement(fo.getParent());
+ }
+ }
+
+ @Override
+ public Icon getIcon() {
+ try {
+ ImageIcon imageIcon = new
ImageIcon(DataObject.find(fo).getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16));
+ return imageIcon;
+ } catch (DataObjectNotFoundException ex) {
+ return null;
+ }
+ }
+
+ @Override
+ public String getText(boolean isLogical) {
+ return fo.getNameExt();
+ }
+
+ @Override
+ public Object getUserObject() {
+ return fo;
+ }
+
+ @Override
+ public void open() {
+ try {
+ if(fo.isValid() && fo.isData()) {
+ DataObject od = DataObject.find(fo);
+ NbDocument.openDocument(od, 0, Line.ShowOpenType.OPEN,
Line.ShowVisibilityType.FOCUS);
+ }
+ } catch (DataObjectNotFoundException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/ProjectTreeElement.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/ProjectTreeElement.java
new file mode 100644
index 0000000..fe14d88
--- /dev/null
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/ProjectTreeElement.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.lsp.client.bindings.refactoring.tree;
+
+import java.lang.ref.WeakReference;
+import javax.swing.Icon;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectInformation;
+import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.modules.refactoring.spi.ui.TreeElement;
+import org.openide.filesystems.FileObject;
+
+/**Copied from refactoring.java, and simplified.
+ *
+ * @author Jan Becicka
+ */
+public class ProjectTreeElement implements TreeElement {
+
+ private String name;
+ private Icon icon;
+ private WeakReference<Project> prj;
+ private FileObject prjDir;
+ /** Creates a new instance of ProjectTreeElement */
+ public ProjectTreeElement(Project prj) {
+ ProjectInformation pi = ProjectUtils.getInformation(prj);
+ name = pi.getDisplayName();
+ icon = pi.getIcon();
+ this.prj = new WeakReference<Project>(prj);
+ prjDir = prj.getProjectDirectory();
+ }
+
+ @Override
+ public TreeElement getParent(boolean isLogical) {
+ return null;
+ }
+
+ @Override
+ public Icon getIcon() {
+ return icon;
+ }
+
+ @Override
+ public String getText(boolean isLogical) {
+ return name;
+ }
+
+ @Override
+ public Object getUserObject() {
+ Project p = prj.get();
+ if (p==null) {
+ p = FileOwnerQuery.getOwner(prjDir);
+ }
+ return p;
+ }
+
+}
diff --git
a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/TreeElementFactoryImpl.java
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/TreeElementFactoryImpl.java
new file mode 100644
index 0000000..a75dc8d
--- /dev/null
+++
b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/refactoring/tree/TreeElementFactoryImpl.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.lsp.client.bindings.refactoring.tree;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.SourceGroup;
+import org.netbeans.modules.refactoring.spi.ui.TreeElement;
+import
org.netbeans.modules.refactoring.spi.ui.TreeElementFactoryImplementation;
+import org.openide.filesystems.FileObject;
+
+/**Copied from refactoring.java, and simplified.
+ *
+ * @author Jan Becicka
+ */
[email protected](service=org.netbeans.modules.refactoring.spi.ui.TreeElementFactoryImplementation.class)
+public class TreeElementFactoryImpl implements
TreeElementFactoryImplementation {
+
+ private final Map<Object, TreeElement> map = new WeakHashMap<>();
+
+ @Override
+ public TreeElement getTreeElement(Object o) {
+ TreeElement result;
+ result = map.get(o);
+ if (result != null) {
+ return result;
+ }
+ if (o instanceof FileObject) {
+ result = new FileTreeElement((FileObject) o);
+ } else if (o instanceof Project) {
+ result = new ProjectTreeElement((Project) o);
+ }
+ if (result != null) {
+ if (o instanceof SourceGroup) {
+ map.put(((SourceGroup) o).getRootFolder(), result);
+ } else {
+ map.put(o, result);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void cleanUp() {
+ map.clear();
+ }
+}
diff --git a/java/java.lsp.server/external/binaries-list
b/java/java.lsp.server/external/binaries-list
index 3aa7942..05e0a74 100644
--- a/java/java.lsp.server/external/binaries-list
+++ b/java/java.lsp.server/external/binaries-list
@@ -20,9 +20,9 @@ E5F9B4D2A6DDE53FA2CEAD6F0D51CABC73E3C850
org.eclipse.lsp4j:org.eclipse.lsp4j.deb
DA453B2A6C9BBD9369DE41365C59E88574EC1F0B
org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.9.0
1CF7FCE1E2F4DFA76C3B91E4C2D72EA0C6899945
org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.9.0
DAF59D5711756C35B6BF9537EB1A6EDDF52EF452
org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc.debug:0.9.0
-56459301B64C92BBBB6E13988B91CDBE1FC6264E
org.eclipse.xtend:org.eclipse.xtend.lib:2.14.0
-F2FCA7A70C8A29374E79487417CEFB5F51A84867
org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.14.0
-C40FFE7E5E6244DD094AE95009AA45072C629254
org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.14.0
+751B324BED8C077BF6B7B8C2055595EB8C28509D
org.eclipse.xtend:org.eclipse.xtend.lib:2.19.0
+F3626A047A3ABFA47CF62D76BDEF1D246F7985F6
org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.19.0
+997BA9935D0069B3F1CD2F93B56B91D24E9C60A0
org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.19.0
2852E6E05FBB95076FC091F6D1780F1F8FE35E0F commons-io:commons-io:2.5
9D28A6B23650E8A7E9063C04588ACE6CF7012C17 org.apache.commons:commons-lang3:3.6
diff --git a/java/java.lsp.server/external/xtend-2.14.0-license.txt
b/java/java.lsp.server/external/xtend-2.19.0-license.txt
similarity index 98%
rename from java/java.lsp.server/external/xtend-2.14.0-license.txt
rename to java/java.lsp.server/external/xtend-2.19.0-license.txt
index 2158078..e679f21 100644
--- a/java/java.lsp.server/external/xtend-2.14.0-license.txt
+++ b/java/java.lsp.server/external/xtend-2.19.0-license.txt
@@ -1,10 +1,10 @@
Name: Eclipse Xtend library
Origin: Eclipse
-Version: 2.14.0
+Version: 2.19.0
License: EPL-v10
URL: http://www.eclipse.org/
Description: Eclipse Xtend library
-Files: org.eclipse.xtend.lib-2.14.0.jar org.eclipse.xtend.lib.macro-2.14.0.jar
org.eclipse.xtext.xbase.lib-2.14.0.jar
+Files: org.eclipse.xtend.lib-2.19.0.jar org.eclipse.xtend.lib.macro-2.19.0.jar
org.eclipse.xtext.xbase.lib-2.19.0.jar
Eclipse Public License - v 1.0
diff --git a/java/java.lsp.server/nbproject/project.properties
b/java/java.lsp.server/nbproject/project.properties
index 5f0bbc6..a4153f3 100644
--- a/java/java.lsp.server/nbproject/project.properties
+++ b/java/java.lsp.server/nbproject/project.properties
@@ -28,8 +28,8 @@
release.external/org.eclipse.lsp4j.debug-0.9.0.jar=modules/ext/org.eclipse.lsp4j
release.external/org.eclipse.lsp4j.generator-0.9.0.jar=modules/ext/org.eclipse.lsp4j.generator-0.9.0.jar
release.external/org.eclipse.lsp4j.jsonrpc-0.9.0.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.9.0.jar
release.external/org.eclipse.lsp4j.jsonrpc.debug-0.9.0.jar=modules/ext/org.eclipse.lsp4j.jsonrpc.debug-0.9.0.jar
-release.external/org.eclipse.xtend.lib-2.14.0.jar=modules/ext/org.eclipse.xtend.lib-2.14.0.jar
-release.external/org.eclipse.xtend.lib.macro-2.14.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.14.0.jar
-release.external/org.eclipse.xtext.xbase.lib-2.14.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.14.0.jar
+release.external/org.eclipse.xtend.lib-2.19.0.jar=modules/ext/org.eclipse.xtend.lib-2.19.0.jar
+release.external/org.eclipse.xtend.lib.macro-2.19.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.19.0.jar
+release.external/org.eclipse.xtext.xbase.lib-2.19.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.19.0.jar
release.external/commons-io-2.5.jar=modules/ext/commons-io-2.5.jar
release.external/commons-lang3-3.6.jar=modules/ext/commons-lang3-3.6.jar
diff --git a/java/java.lsp.server/nbproject/project.xml
b/java/java.lsp.server/nbproject/project.xml
index 46c2273..89d6327 100644
--- a/java/java.lsp.server/nbproject/project.xml
+++ b/java/java.lsp.server/nbproject/project.xml
@@ -479,6 +479,10 @@
<binary-origin>external/org.eclipse.lsp4j.debug-0.9.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
+
<runtime-relative-path>ext/org.eclipse.xtend.lib.macro-2.19.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.xtend.lib.macro-2.19.0.jar</binary-origin>
+ </class-path-extension>
+ <class-path-extension>
<runtime-relative-path>ext/org.eclipse.lsp4j.generator-0.9.0.jar</runtime-relative-path>
<binary-origin>external/org.eclipse.lsp4j.generator-0.9.0.jar</binary-origin>
</class-path-extension>
@@ -491,16 +495,12 @@
<binary-origin>external/org.eclipse.lsp4j.jsonrpc.debug-0.9.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.xtend.lib.macro-2.14.0.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.xtend.lib.macro-2.14.0.jar</binary-origin>
- </class-path-extension>
- <class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.xtend.lib-2.14.0.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.xtend.lib-2.14.0.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.xtend.lib-2.19.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.xtend.lib-2.19.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
-
<runtime-relative-path>ext/org.eclipse.xtext.xbase.lib-2.14.0.jar</runtime-relative-path>
-
<binary-origin>external/org.eclipse.xtext.xbase.lib-2.14.0.jar</binary-origin>
+
<runtime-relative-path>ext/org.eclipse.xtext.xbase.lib-2.19.0.jar</runtime-relative-path>
+
<binary-origin>external/org.eclipse.xtext.xbase.lib-2.19.0.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/org.eclipse.lsp4j-0.9.0.jar</runtime-relative-path>
diff --git
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java
index 6f3e151..2a10c70 100644
---
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java
+++
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java
@@ -158,6 +158,7 @@ public final class Server {
capabilities.setDocumentSymbolProvider(true);
capabilities.setDefinitionProvider(true);
capabilities.setDocumentHighlightProvider(true);
+ capabilities.setReferencesProvider(true);
capabilities.setExecuteCommandProvider(new
ExecuteCommandOptions(Arrays.asList(JAVA_BUILD_WORKSPACE,
GRAALVM_PAUSE_SCRIPT)));
return CompletableFuture.completedFuture(new
InitializeResult(capabilities));
}
diff --git
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
index ccefb64..7d33acf 100644
---
a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
+++
b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
@@ -20,8 +20,13 @@ package org.netbeans.modules.java.lsp.server.protocol;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
+import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.LineMap;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.Tree.Kind;
+import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter;
import java.io.File;
@@ -129,6 +134,7 @@ import org.netbeans.api.java.source.ModificationResult;
import org.netbeans.api.java.source.SourceUtils;
import org.netbeans.api.java.source.Task;
import org.netbeans.api.java.source.TreePathHandle;
+import org.netbeans.api.java.source.TreeUtilities;
import org.netbeans.api.java.source.WorkingCopy;
import org.netbeans.api.java.source.support.ReferencesCount;
import org.netbeans.api.java.source.ui.ElementJavadoc;
@@ -155,6 +161,10 @@ import org.netbeans.modules.parsing.api.Source;
import org.netbeans.modules.parsing.api.UserTask;
import org.netbeans.modules.parsing.spi.ParseException;
import org.netbeans.modules.parsing.spi.SchedulerEvent;
+import org.netbeans.modules.refactoring.api.Problem;
+import org.netbeans.modules.refactoring.api.RefactoringElement;
+import org.netbeans.modules.refactoring.api.RefactoringSession;
+import org.netbeans.modules.refactoring.api.WhereUsedQuery;
import org.netbeans.spi.editor.hints.EnhancedFix;
import org.netbeans.spi.editor.hints.ErrorDescription;
import org.netbeans.spi.editor.hints.Fix;
@@ -166,8 +176,10 @@ import org.openide.filesystems.FileUtil;
import org.openide.filesystems.URLMapper;
import org.openide.modules.Places;
import org.openide.text.NbDocument;
+import org.openide.text.PositionBounds;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
+import org.openide.util.lookup.Lookups;
/**
*
@@ -176,6 +188,7 @@ import org.openide.util.RequestProcessor;
public class TextDocumentServiceImpl implements TextDocumentService,
LanguageClientAware {
private static final RequestProcessor BACKGROUND_TASKS = new
RequestProcessor(TextDocumentServiceImpl.class.getName(), 1, false, false);
+ private static final RequestProcessor WORKER = new
RequestProcessor(TextDocumentServiceImpl.class.getName(), 1, false, false);
private final Map<String, Document> openedDocuments = new HashMap<>();
private final Map<String, RequestProcessor.Task> diagnosticTasks = new
HashMap<>();
@@ -539,7 +552,7 @@ public class TextDocumentServiceImpl implements
TextDocumentService, LanguageCli
@Override
public CompletableFuture<Either<List<? extends Location>, List<? extends
LocationLink>>> definition(DefinitionParams params) {
- JavaSource js = getSource(params.getTextDocument().getUri());
+ JavaSource js = getSource(params.getTextDocument().getUri());
GoToTarget[] target = new GoToTarget[1];
LineMap[] thisFileLineMap = new LineMap[1];
try {
@@ -585,8 +598,125 @@ public class TextDocumentServiceImpl implements
TextDocumentService, LanguageCli
}
@Override
- public CompletableFuture<List<? extends Location>>
references(ReferenceParams arg0) {
- throw new UnsupportedOperationException("Not supported yet.");
+ public CompletableFuture<List<? extends Location>>
references(ReferenceParams params) {
+ AtomicBoolean cancel = new AtomicBoolean();
+ Runnable[] cancelCallback = new Runnable[1];
+ CompletableFuture<List<? extends Location>> result = new
CompletableFuture<List<? extends Location>>() {
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ cancel.set(mayInterruptIfRunning);
+ if (cancelCallback[0] != null) {
+ cancelCallback[0].run();
+ }
+ return super.cancel(mayInterruptIfRunning);
+ }
+ };
+ WORKER.post(() -> {
+ JavaSource js = getSource(params.getTextDocument().getUri());
+ try {
+ WhereUsedQuery[] query = new WhereUsedQuery[1];
+ List<Location> locations = new ArrayList<>();
+ js.runUserActionTask(cc -> {
+ cc.toPhase(JavaSource.Phase.RESOLVED);
+ if (cancel.get()) return ;
+ Document doc =
cc.getSnapshot().getSource().getDocument(true);
+ TreePath path =
cc.getTreeUtilities().pathFor(getOffset(doc, params.getPosition()));
+ if (params.getContext().isIncludeDeclaration()) {
+ Element decl = cc.getTrees().getElement(path);
+ if (decl != null) {
+ TreePath declPath = cc.getTrees().getPath(decl);
+ if (declPath != null && cc.getCompilationUnit() ==
declPath.getCompilationUnit()) {
+ Range range = declarationRange(cc, declPath);
+ if (range != null) {
+ locations.add(new
Location(toUri(cc.getFileObject()),
+ range));
+ }
+ } else {
+ ElementHandle<Element> declHandle =
ElementHandle.create(decl);
+ FileObject sourceFile =
SourceUtils.getFile(declHandle, cc.getClasspathInfo());
+ JavaSource source = sourceFile != null ?
JavaSource.forFileObject(sourceFile) : null;
+ if (source != null) {
+ source.runUserActionTask(nestedCC -> {
+
nestedCC.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+ Element declHandle2 =
declHandle.resolve(nestedCC);
+ TreePath declPath2 = declHandle2 !=
null ? nestedCC.getTrees().getPath(declHandle2) : null;
+ if (declPath2 != null) {
+ Range range =
declarationRange(nestedCC, declPath2);
+ if (range != null) {
+ locations.add(new
Location(toUri(nestedCC.getFileObject()),
+
range));
+ }
+ }
+ }, true);
+ }
+ }
+ }
+ }
+ query[0] = new
WhereUsedQuery(Lookups.singleton(TreePathHandle.create(path, cc)));
+ }, true);
+ if (cancel.get()) return ;
+ cancelCallback[0] = () -> query[0].cancelRequest();
+ RefactoringSession refactoring =
RefactoringSession.create("FindUsages");
+ Problem p;
+ p = query[0].checkParameters();
+ if (cancel.get()) return ;
+ if (p != null && p.isFatal()) {
+ result.completeExceptionally(new
IllegalStateException(p.getMessage()));
+ return ;
+ }
+ p = query[0].preCheck();
+ if (p != null && p.isFatal()) {
+ result.completeExceptionally(new
IllegalStateException(p.getMessage()));
+ return ;
+ }
+ if (cancel.get()) return ;
+ p = query[0].prepare(refactoring);
+ if (p != null && p.isFatal()) {
+ result.completeExceptionally(new
IllegalStateException(p.getMessage()));
+ return ;
+ }
+ for (RefactoringElement re :
refactoring.getRefactoringElements()) {
+ if (cancel.get()) return ;
+ locations.add(new Location(toUri(re.getParentFile()),
toRange(re.getPosition())));
+ }
+
+ refactoring.finished();
+
+ result.complete(locations);
+ } catch (Throwable ex) {
+ result.completeExceptionally(ex);
+ }
+ });
+ return result;
+ }
+
+ private static Range declarationRange(CompilationInfo info, TreePath tp) {
+ Tree t = tp.getLeaf();
+ int[] span;
+ if (TreeUtilities.CLASS_TREE_KINDS.contains(t.getKind())) {
+ span = info.getTreeUtilities().findNameSpan((ClassTree) t);
+ } else if (t.getKind() == Kind.VARIABLE) {
+ span = info.getTreeUtilities().findNameSpan((VariableTree) t);
+ } else if (t.getKind() == Kind.METHOD) {
+ span = info.getTreeUtilities().findNameSpan((MethodTree) t);
+ if (span == null) {
+ span = info.getTreeUtilities().findNameSpan((ClassTree)
tp.getParentPath().getLeaf());
+ }
+ } else {
+ return null;
+ }
+ if (span == null) {
+ return null;
+ }
+ return new
Range(createPosition(info.getCompilationUnit().getLineMap(), span[0]),
+
createPosition(info.getCompilationUnit().getLineMap(), span[1]));
+ }
+
+ private static Range toRange(PositionBounds bounds) throws IOException {
+ return new Range(new Position(bounds.getBegin().getLine(),
+ bounds.getBegin().getColumn()),
+ new Position(bounds.getEnd().getLine(),
+ bounds.getEnd().getColumn()));
}
@Override
diff --git
a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
index 14862e8..67d9409 100644
---
a/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
+++
b/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
@@ -64,6 +64,8 @@ import org.eclipse.lsp4j.MessageParams;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.PublishDiagnosticsParams;
import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.ReferenceContext;
+import org.eclipse.lsp4j.ReferenceParams;
import org.eclipse.lsp4j.ShowMessageRequestParams;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentContentChangeEvent;
@@ -851,6 +853,130 @@ public class ServerTest extends NbTestCase {
}
}
+ public void testFindUsages() throws Exception {
+ File src = new File(getWorkDir(), "Test.java");
+ src.getParentFile().mkdirs();
+ try (Writer w = new FileWriter(new File(src.getParentFile(),
".test-project"))) {}
+ String code = "public class Test {\n" +
+ " int val = new Test2().get();\n" +
+ "}\n";
+ try (Writer w = new FileWriter(src)) {
+ w.write(code);
+ }
+ File src2 = new File(getWorkDir(), "Test2.java");
+ try (Writer w = new FileWriter(src2)) {
+ w.write("public class Test2 extends Test {\n" +
+ " Test t;\n" +
+ " void m(Test p) {};\n" +
+ " int get() { return t.val; };\n" +
+ "}\n");
+ }
+ List<Diagnostic>[] diags = new List[1];
+ CountDownLatch indexingComplete = new CountDownLatch(1);
+ Launcher<LanguageServer> serverLauncher =
LSPLauncher.createClientLauncher(new LanguageClient() {
+ @Override
+ public void telemetryEvent(Object arg0) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void publishDiagnostics(PublishDiagnosticsParams params) {
+ synchronized (diags) {
+ diags[0] = params.getDiagnostics();
+ diags.notifyAll();
+ }
+ }
+
+ @Override
+ public void showMessage(MessageParams params) {
+ if (Server.INDEXING_COMPLETED.equals(params.getMessage())) {
+ indexingComplete.countDown();
+ } else {
+ throw new UnsupportedOperationException("Unexpected
message.");
+ }
+ }
+
+ @Override
+ public CompletableFuture<MessageActionItem>
showMessageRequest(ShowMessageRequestParams arg0) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void logMessage(MessageParams arg0) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }, client.getInputStream(), client.getOutputStream());
+ serverLauncher.startListening();
+ LanguageServer server = serverLauncher.getRemoteProxy();
+ InitializeParams initParams = new InitializeParams();
+ initParams.setRootUri(getWorkDir().toURI().toString());
+ InitializeResult result = server.initialize(initParams).get();
+ indexingComplete.await();
+ server.getTextDocumentService().didOpen(new
DidOpenTextDocumentParams(new TextDocumentItem(src.toURI().toString(), "java",
0, code)));
+
+ {
+ ReferenceParams params = new ReferenceParams(new
TextDocumentIdentifier(src.toURI().toString()),
+ new Position(0, 15),
+ new
ReferenceContext(false));
+
+ Set<? extends String> locations =
server.getTextDocumentService().references(params).get().stream().map(this::toString).collect(Collectors.toSet());
+ Set<? extends String> expected = new
HashSet<>(Arrays.asList("Test2.java:1:4-1:8", "Test2.java:0:27-0:31",
"Test2.java:2:11-2:15"));
+
+ assertEquals(expected, locations);
+ }
+
+ {
+ ReferenceParams params = new ReferenceParams(new
TextDocumentIdentifier(src.toURI().toString()),
+ new Position(0, 15),
+ new
ReferenceContext(true));
+
+ Set<? extends String> locations =
server.getTextDocumentService().references(params).get().stream().map(this::toString).collect(Collectors.toSet());
+ Set<? extends String> expected = new
HashSet<>(Arrays.asList("Test2.java:1:4-1:8", "Test2.java:0:27-0:31",
"Test2.java:2:11-2:15", "Test.java:0:13-0:17"));
+
+ assertEquals(expected, locations);
+ }
+
+ {
+ ReferenceParams params = new ReferenceParams(new
TextDocumentIdentifier(src2.toURI().toString()),
+ new Position(0, 29),
+ new
ReferenceContext(true));
+
+ Set<? extends String> locations =
server.getTextDocumentService().references(params).get().stream().map(this::toString).collect(Collectors.toSet());
+ Set<? extends String> expected = new
HashSet<>(Arrays.asList("Test2.java:1:4-1:8", "Test2.java:0:27-0:31",
"Test2.java:2:11-2:15", "Test.java:0:13-0:17"));
+
+ assertEquals(expected, locations);
+ }
+
+ {
+ ReferenceParams params = new ReferenceParams(new
TextDocumentIdentifier(src2.toURI().toString()),
+ new Position(3, 10),
+ new
ReferenceContext(true));
+
+ Set<? extends String> locations =
server.getTextDocumentService().references(params).get().stream().map(this::toString).collect(Collectors.toSet());
+ Set<? extends String> expected = new
HashSet<>(Arrays.asList("Test.java:1:26-1:29", "Test2.java:3:8-3:11"));
+
+ assertEquals(expected, locations);
+ }
+
+ {
+ ReferenceParams params = new ReferenceParams(new
TextDocumentIdentifier(src2.toURI().toString()),
+ new Position(3, 27),
+ new
ReferenceContext(true));
+
+ Set<? extends String> locations =
server.getTextDocumentService().references(params).get().stream().map(this::toString).collect(Collectors.toSet());
+ Set<? extends String> expected = new
HashSet<>(Arrays.asList("Test.java:1:8-1:11", "Test2.java:3:25-3:28"));
+
+ assertEquals(expected, locations);
+ }
+ }
+
+ private String toString(Location location) {
+ String path = location.getUri();
+ String simpleName = path.substring(path.lastIndexOf('/') + 1);
+ return simpleName + ":" + location.getRange().getStart().getLine() +
":" + location.getRange().getStart().getCharacter() +
+ "-" + location.getRange().getEnd().getLine() + ":"
+ location.getRange().getEnd().getCharacter();
+ }
+
private void assertHighlights(List<? extends DocumentHighlight>
highlights, String... expected) {
Set<String> stringHighlights = new HashSet<>();
for (DocumentHighlight h : highlights) {
diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
index fd321ee..924751e 100644
--- a/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/extlibs/ignored-overlaps
@@ -76,9 +76,12 @@ enterprise/javaee7.api/external/jsr181-api-1.0-MR1.jar
java/websvc.jaxws21api/ex
ide/libs.bytelist/external/jcodings-1.0.18.jar
ide/textmate.lexer/external/jcodings-1.0.18.jar
# ide/lsp.client and java/java.lsp.server both use LSP libraries, but are
independent:
-ide/lsp.client/external/org.eclipse.xtend.lib-2.14.0.jar
java/java.lsp.server/external/org.eclipse.xtend.lib-2.14.0.jar
-ide/lsp.client/external/org.eclipse.xtend.lib.macro-2.14.0.jar
java/java.lsp.server/external/org.eclipse.xtend.lib.macro-2.14.0.jar
-ide/lsp.client/external/org.eclipse.xtext.xbase.lib-2.14.0.jar
java/java.lsp.server/external/org.eclipse.xtext.xbase.lib-2.14.0.jar
+ide/lsp.client/external/org.eclipse.lsp4j-0.9.0.jar
java/java.lsp.server/external/org.eclipse.lsp4j-0.9.0.jar
+ide/lsp.client/external/org.eclipse.lsp4j.generator-0.9.0.jar
java/java.lsp.server/external/org.eclipse.lsp4j.generator-0.9.0.jar
+ide/lsp.client/external/org.eclipse.lsp4j.jsonrpc-0.9.0.jar
java/java.lsp.server/external/org.eclipse.lsp4j.jsonrpc-0.9.0.jar
+ide/lsp.client/external/org.eclipse.xtend.lib-2.19.0.jar
java/java.lsp.server/external/org.eclipse.xtend.lib-2.19.0.jar
+ide/lsp.client/external/org.eclipse.xtend.lib.macro-2.19.0.jar
java/java.lsp.server/external/org.eclipse.xtend.lib.macro-2.19.0.jar
+ide/lsp.client/external/org.eclipse.xtext.xbase.lib-2.19.0.jar
java/java.lsp.server/external/org.eclipse.xtext.xbase.lib-2.19.0.jar
# Derby jar is used when run tests, so we can ignore the duplicates
ide/db/external/derby-10.14.2.0.jar
ide/db.metadata.model/external/derby-10.14.2.0.jar
diff --git
a/webcommon/typescript.editor/src/org/netbeans/modules/typescript/editor/TypeScriptDataObjectDataObject.java
b/webcommon/typescript.editor/src/org/netbeans/modules/typescript/editor/TypeScriptDataObjectDataObject.java
index 1962169..1c2de60 100644
---
a/webcommon/typescript.editor/src/org/netbeans/modules/typescript/editor/TypeScriptDataObjectDataObject.java
+++
b/webcommon/typescript.editor/src/org/netbeans/modules/typescript/editor/TypeScriptDataObjectDataObject.java
@@ -96,6 +96,12 @@ import org.openide.util.NbBundle.Messages;
path = "Loaders/application/x-typescript/Actions",
id = @ActionID(category = "System", id =
"org.openide.actions.PropertiesAction"),
position = 1400
+ ),
+ @ActionReference(
+ path = "Editors/application/x-typescript/Popup",
+ id = @ActionID(category = "Refactoring", id =
"org.netbeans.modules.refactoring.api.ui.WhereUsedAction"),
+ position = 1400,
+ separatorAfter = 1450
)
})
@GrammarRegistration(mimeType="application/x-typescript",
grammar="TypeScript.tmLanguage.json")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists