24
24
; ; Java specific adapter for LSP mode
25
25
26
26
; ;; Code:
27
+
27
28
(require 'cc-mode )
28
29
(require 'lsp-mode )
29
30
(require 'markdown-mode )
34
35
(require 'request )
35
36
(require 'cl-lib )
36
37
38
+ ; ; Compiler pacifier
39
+ (defvar java-ts-mode-indent-offset )
40
+
37
41
(defgroup lsp-java nil
38
42
" JDT emacs frontend."
39
43
:prefix " lsp-java-"
@@ -47,7 +51,8 @@ The slash is expected at the end."
47
51
:type 'directory )
48
52
49
53
(defcustom lsp-java-jdt-ls-prefer-native-command nil
50
- " Use native jdtls command provided by jdtls installation instead of lsp's java -jar invocation."
54
+ " Use native jdtls command provided by jdtls installation instead of
55
+ lsp's java -jar invocation."
51
56
:risky t
52
57
:type 'boolean )
53
58
@@ -285,15 +290,15 @@ import is missing."
285
290
:lsp-path " java.completion.favoriteStaticMembers" )
286
291
287
292
(lsp-defcustom lsp-java-completion-import-order [" java" " javax" " com" " org" ]
288
- " Defines the sorting order of import statements. A package or
289
- type name prefix (e.g. ' org.eclipse') is a valid entry. An import
290
- is always added to the most specific group."
293
+ " Defines the sorting order of import statements.
294
+ A package or type name prefix (e.g. ` org.eclipse' ) is a valid entry.
295
+ An import is always added to the most specific group."
291
296
:type '(lsp-repeatable-vector string)
292
297
:lsp-path " java.completion.importOrder" )
293
298
294
299
(lsp-defcustom lsp-java-folding-range-enabled t
295
- " Enable/disable smart folding range support. If disabled, it
296
- will use the default indentation-based folding range provided by
300
+ " Enable/disable smart folding range support.
301
+ If disabled, it will use the default indentation-based folding range provided by
297
302
VS Code."
298
303
:type 'boolean
299
304
:lsp-path " java.foldingRange.enabled" )
@@ -305,8 +310,8 @@ processes on the server."
305
310
:lsp-path " java.progressReports.enabled" )
306
311
307
312
(lsp-defcustom lsp-java-format-settings-url nil
308
- " Specifies the url or file path to the [Eclipse formatter xml
309
- settings] (https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings)."
313
+ " Specifies the url or file path to the [Eclipse formatter XML settings]
314
+ (https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings)."
310
315
:type '(choice (string )
311
316
(const nil ))
312
317
:lsp-path " java.format.settings.url" )
@@ -342,13 +347,13 @@ and higher."
342
347
:lsp-path " java.codeGeneration.hashCodeEquals.useJava7Objects" )
343
348
344
349
(lsp-defcustom lsp-java-code-generation-hash-code-equals-use-instanceof nil
345
- " Use ' instanceof' to compare types when generating the hashCode
350
+ " Use ` instanceof' to compare types when generating the hashCode
346
351
and equals methods."
347
352
:type 'boolean
348
353
:lsp-path " java.codeGeneration.hashCodeEquals.useInstanceof" )
349
354
350
355
(lsp-defcustom lsp-java-code-generation-use-blocks nil
351
- " Use blocks in ' if' statements when generating the methods."
356
+ " Use blocks in ` if' statements when generating the methods."
352
357
:type 'boolean
353
358
:lsp-path " java.codeGeneration.useBlocks" )
354
359
@@ -391,7 +396,7 @@ then list all."
391
396
" Defines the type filters. All types whose fully qualified name
392
397
matches the selected filter strings will be ignored in content
393
398
assist or quick fix proposals and when organizing imports. For
394
- example ' java.awt.*' will hide all types from the awt packages."
399
+ example ` java.awt.*' will hide all types from the awt packages."
395
400
:type '(lsp-repeatable-vector string)
396
401
:lsp-path " java.completion.filteredTypes" )
397
402
@@ -419,7 +424,7 @@ example 'java.awt.*' will hide all types from the awt packages."
419
424
(lsp-defcustom lsp-java-import-gradle-home nil
420
425
" Use Gradle from the specified local installation directory or
421
426
GRADLE_HOME if the Gradle wrapper is missing or disabled and no
422
- ' java.import.gradle.version' is specified."
427
+ ` java.import.gradle.version' is specified."
423
428
:type '(choice (string )
424
429
(const nil ))
425
430
:lsp-path " java.import.gradle.home" )
@@ -554,7 +559,8 @@ projects import is skipped on startup."
554
559
(defun lsp-java--locate-server-jar ()
555
560
" Return the jar file location of the language server.
556
561
557
- The entry point of the language server is in `lsp-java-server-install-dir'/plugins/org.eclipse.equinox.launcher_`version' .jar."
562
+ The entry point of the language server is in the `lsp-java-server-install-dir'
563
+ + /plugins/org.eclipse.equinox.launcher_`version' .jar."
558
564
(pcase (f-glob " org.eclipse.equinox.launcher_*.jar" (expand-file-name " plugins" lsp-java-server-install-dir))
559
565
(`(, single-entry ) single-entry)
560
566
(`nil nil )
@@ -564,7 +570,8 @@ The entry point of the language server is in `lsp-java-server-install-dir'/plugi
564
570
(defun lsp-java--locate-server-command ()
565
571
" Return the jdtls command location of the language server.
566
572
567
- The entry point of the language server is in `lsp-java-server-install-dir' /bin/jdtls[.bat]."
573
+ The entry point of the language server is in the
574
+ `lsp-java-server-install-dir' /bin/jdtls[.bat]."
568
575
(let ((bin-path (expand-file-name " bin" lsp-java-server-install-dir)))
569
576
(locate-file lsp-java-jdt-ls-command `(, bin-path ) exec-suffixes 1 )))
570
577
@@ -1073,9 +1080,9 @@ current symbol."
1073
1080
(progn
1074
1081
(require 'helm-source )
1075
1082
(helm :sources (helm-make-source
1076
- message 'helm-source-sync :candidates items
1077
- :action '((" Identity" lambda (_)
1078
- (setq lsp-java--helm-result (helm-marked-candidates)))))
1083
+ message 'helm-source-sync :candidates items
1084
+ :action '((" Identity" lambda (_)
1085
+ (setq lsp-java--helm-result (helm-marked-candidates)))))
1079
1086
:buffer " *lsp-java select*"
1080
1087
:prompt message)
1081
1088
lsp-java--helm-result)
@@ -1556,14 +1563,16 @@ projects."
1556
1563
:lsp-path " java.configuration.maven.globalSettings" )
1557
1564
1558
1565
(lsp-defcustom lsp-java-configuration-maven-not-covered-plugin-execution-severity " warning"
1559
- " Specifies severity if the plugin execution is not covered by Maven build lifecycle."
1566
+ " Specifies severity if the plugin execution is not covered by Maven
1567
+ build lifecycle."
1560
1568
:type '(choice (const " ignore" )
1561
1569
(const " warning" )
1562
1570
(const " error" ))
1563
1571
:lsp-path " java.configuration.maven.notCoveredPluginExecutionSeverity" )
1564
1572
1565
1573
(lsp-defcustom lsp-java-configuration-maven-default-mojo-execution-action " ignore"
1566
- " Specifies default mojo execution action when no associated metadata can be detected."
1574
+ " Specifies default mojo execution action when no associated metadata can
1575
+ be detected."
1567
1576
:type '(choice (:const " ignore" ) (:const " warn" ) (:const " error" ) (:const " execute" ))
1568
1577
:lsp-path " java.configuration.maven.defaultMojoExecutionAction" )
1569
1578
@@ -1625,24 +1634,23 @@ actions."
1625
1634
:lsp-path " java.codeGeneration.insertionLocation" )
1626
1635
1627
1636
(lsp-defcustom lsp-java-templates-file-header nil
1628
- " Specifies the file header comment for new Java file. Supports
1629
- configuring multi-line comments with an array of strings, and
1630
- using ${variable} to reference the [predefined
1631
- variables](command:_java.templateVariables)."
1637
+ " Specifies the file header comment for new Java file.
1638
+ Supports configuring multi-line comments with an array of strings,
1639
+ and using ${variable} to reference
1640
+ the [predefined variables](command:_java.templateVariables)."
1632
1641
:type 'lsp-string-vector
1633
1642
:lsp-path " java.templates.fileHeader" )
1634
1643
1635
1644
(lsp-defcustom lsp-java-templates-type-comment nil
1636
- " Specifies the type comment for new Java type. Supports
1637
- configuring multi-line comments with an array of strings, and
1638
- using ${variable} to reference the [predefined
1639
- variables](command:_java.templateVariables)."
1645
+ " Specifies the type comment for new Java type.
1646
+ Supports configuring multi-line comments with an array of strings,
1647
+ and using ${variable} to reference
1648
+ the [predefined variables](command:_java.templateVariables)."
1640
1649
:type 'lsp-string-vector
1641
1650
:lsp-path " java.templates.typeComment" )
1642
1651
1643
1652
(lsp-defcustom lsp-java-references-include-accessors t
1644
- " Include getter, setter and builder/constructor when finding
1645
- references."
1653
+ " Include getter, setter and builder/constructor when finding references."
1646
1654
:type 'boolean
1647
1655
:lsp-path " java.references.includeAccessors" )
1648
1656
@@ -1652,16 +1660,15 @@ references."
1652
1660
:lsp-path " java.references.includeDecompiledSources" )
1653
1661
1654
1662
(lsp-defcustom lsp-java-type-hierarchy-lazy-load nil
1655
- " Enable/disable lazy loading the content in type hierarchy. Lazy
1656
- loading could save a lot of loading time but every type should be
1663
+ " Enable/disable lazy loading the content in type hierarchy.
1664
+ Lazy loading could save a lot of loading time but every type should be
1657
1665
expanded manually to load its content."
1658
1666
:type 'boolean
1659
1667
:lsp-path " java.typeHierarchy.lazyLoad" )
1660
1668
1661
1669
(lsp-defcustom lsp-java-settings-url nil
1662
1670
" Specifies the url or file path to the workspace Java settings.
1663
- See [Setting Global
1664
- Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)"
1671
+ See [Setting Global Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)"
1665
1672
:type 'string
1666
1673
:lsp-path " java.settings.url" )
1667
1674
@@ -1682,18 +1689,19 @@ Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Globa
1682
1689
Integer.valueOf(/* s: */ '123', /* radix: */ 10)
1683
1690
1684
1691
```
1685
- `#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay hints for methods."
1692
+ `#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay
1693
+ hints for methods."
1686
1694
:type '(choice (:const " none" ) (:const " literals" ) (:const " all" ))
1687
1695
:lsp-path " java.inlayHints.parameterNames.enabled" )
1688
1696
1689
1697
(lsp-defcustom lsp-java-inlay-hints-parameter-names-exclusions nil
1690
1698
" The patterns for the methods that will be disabled to show the
1691
1699
inlay hints. Supported pattern examples:
1692
1700
- `java.lang.Math.*` - All the methods from java.lang.Math.
1693
- - `*.Arrays.asList` - Methods named as ' asList' in the types named as ' Arrays'.
1694
- - `*.println(*)` - Methods named as ' println'.
1695
- - `(from, to)` - Methods with two parameters named as ' from' and ' to'.
1696
- - `(arg*)` - Methods with one parameter whose name starts with ' arg'."
1701
+ - `*.Arrays.asList` - Methods named as ` asList' in the types named as ` Arrays' .
1702
+ - `*.println(*)` - Methods named as ` println' .
1703
+ - `(from, to)` - Methods with two parameters named as ` from' and ` to' .
1704
+ - `(arg*)` - Methods with one parameter whose name starts with ` arg' ."
1697
1705
:type 'lsp-string-vector
1698
1706
:lsp-path " java.inlayHints.parameterNames.exclusions" )
1699
1707
@@ -1775,7 +1783,8 @@ Visual Studio Code - Insiders."
1775
1783
:lsp-path " java.sharedIndexes.location" )
1776
1784
1777
1785
(lsp-defcustom lsp-java-refactoring-extract-interface-replace t
1778
- " Specify whether to replace all the occurrences of the subtype with the new extracted interface."
1786
+ " Specify whether to replace all the occurrences of the subtype with the new
1787
+ extracted interface."
1779
1788
:type 'boolean
1780
1789
:lsp-path " java.refactoring.extract.interface.replace" )
1781
1790
@@ -1815,40 +1824,42 @@ projects."
1815
1824
:lsp-path " java.configuration.maven.globalSettings" )
1816
1825
1817
1826
(lsp-defcustom lsp-java-configuration-maven-not-covered-plugin-execution-severity " warning"
1818
- " Specifies severity if the plugin execution is not covered by Maven build lifecycle."
1827
+ " Specifies severity if the plugin execution is not covered by Maven
1828
+ build lifecycle."
1819
1829
:type '(choice (:const " ignore" ) (:const " warning" ) (:const " error" ))
1820
1830
:lsp-path " java.configuration.maven.notCoveredPluginExecutionSeverity" )
1821
1831
1822
1832
(lsp-defcustom lsp-java-configuration-maven-default-mojo-execution-action " ignore"
1823
- " Specifies default mojo execution action when no associated metadata can be detected."
1833
+ " Specifies default mojo execution action when no associated metadata
1834
+ can be detected."
1824
1835
:type '(choice (:const " ignore" ) (:const " warn" ) (:const " error" ) (:const " execute" ))
1825
1836
:lsp-path " java.configuration.maven.defaultMojoExecutionAction" )
1826
1837
1827
1838
(lsp-defcustom lsp-java-configuration-workspace-cache-limit 90
1828
- " The number of days (if enabled) to keep unused workspace cache
1829
- data. Beyond this limit, cached workspace data may be removed."
1839
+ " The number of days (if enabled) to keep unused workspace cache data.
1840
+ Beyond this limit, cached workspace data may be removed."
1830
1841
:type '(repeat nil )
1831
1842
:lsp-path " java.configuration.workspaceCacheLimit" )
1832
1843
1833
1844
(lsp-defcustom lsp-java-import-generates-metadata-files-at-project-root nil
1834
1845
" Specify whether the project metadata files(.project, .classpath,
1835
1846
.factorypath, .settings/) will be generated at the project root.
1836
- Click [HERE](command:_java.metadataFilesGeneration) to learn how
1837
- to change the setting to make it take effect."
1847
+ Click [HERE](command:_java.metadataFilesGeneration) to learn how to change the
1848
+ setting to make it take effect."
1838
1849
:type 'boolean
1839
1850
:lsp-path " java.import.generatesMetadataFilesAtProjectRoot" )
1840
1851
1841
1852
(lsp-defcustom lsp-java-project-output-path " "
1842
- " A relative path to the workspace where stores the compiled
1843
- output. `Only` effective in the `WORKSPACE` scope. The setting
1844
- will `NOT` affect Maven or Gradle project."
1853
+ " A relative path to the workspace where stores the compiled output.
1854
+ `Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect
1855
+ Maven or Gradle project."
1845
1856
:type '(repeat string)
1846
1857
:lsp-path " java.project.outputPath" )
1847
1858
1848
1859
(lsp-defcustom lsp-java-project-source-paths nil
1849
1860
" Relative paths to the workspace where stores the source files.
1850
- `Only` effective in the `WORKSPACE` scope. The setting will `NOT`
1851
- affect Maven or Gradle project."
1861
+ `Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect Maven
1862
+ or Gradle project."
1852
1863
:type 'lsp-string-vector
1853
1864
:lsp-path " java.project.sourcePaths" )
1854
1865
@@ -1882,24 +1893,23 @@ actions."
1882
1893
:lsp-path " java.codeGeneration.insertionLocation" )
1883
1894
1884
1895
(lsp-defcustom lsp-java-templates-file-header nil
1885
- " Specifies the file header comment for new Java file. Supports
1886
- configuring multi-line comments with an array of strings, and
1887
- using ${variable} to reference the [predefined
1888
- variables](command:_java.templateVariables)."
1896
+ " Specifies the file header comment for new Java file.
1897
+ Supports configuring multi-line comments with an array of strings, and using
1898
+ ${variable} to reference the
1899
+ [predefined variables](command:_java.templateVariables)."
1889
1900
:type 'lsp-string-vector
1890
1901
:lsp-path " java.templates.fileHeader" )
1891
1902
1892
1903
(lsp-defcustom lsp-java-templates-type-comment nil
1893
- " Specifies the type comment for new Java type. Supports
1894
- configuring multi-line comments with an array of strings, and
1895
- using ${variable} to reference the [predefined
1896
- variables](command:_java.templateVariables)."
1904
+ " Specifies the type comment for new Java type.
1905
+ Supports configuring multi-line comments with an array of strings, and using
1906
+ ${variable} to reference the
1907
+ [predefined variables](command:_java.templateVariables)."
1897
1908
:type 'lsp-string-vector
1898
1909
:lsp-path " java.templates.typeComment" )
1899
1910
1900
1911
(lsp-defcustom lsp-java-references-include-accessors t
1901
- " Include getter, setter and builder/constructor when finding
1902
- references."
1912
+ " Include getter, setter and builder/constructor when finding references."
1903
1913
:type 'boolean
1904
1914
:lsp-path " java.references.includeAccessors" )
1905
1915
@@ -1939,18 +1949,19 @@ Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Globa
1939
1949
Integer.valueOf(/* s: */ '123', /* radix: */ 10)
1940
1950
1941
1951
```
1942
- `#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay hints for methods."
1952
+ `#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay
1953
+ hints for methods."
1943
1954
:type '(choice (:const " none" ) (:const " literals" ) (:const " all" ))
1944
1955
:lsp-path " java.inlayHints.parameterNames.enabled" )
1945
1956
1946
1957
(lsp-defcustom lsp-java-inlay-hints-parameter-names-exclusions nil
1947
1958
" The patterns for the methods that will be disabled to show the
1948
1959
inlay hints. Supported pattern examples:
1949
1960
- `java.lang.Math.*` - All the methods from java.lang.Math.
1950
- - `*.Arrays.asList` - Methods named as ' asList' in the types named as ' Arrays'.
1951
- - `*.println(*)` - Methods named as ' println'.
1952
- - `(from, to)` - Methods with two parameters named as ' from' and ' to'.
1953
- - `(arg*)` - Methods with one parameter whose name starts with ' arg'."
1961
+ - `*.Arrays.asList` - Methods named as ` asList' in the types named as ` Arrays' .
1962
+ - `*.println(*)` - Methods named as ` println' .
1963
+ - `(from, to)` - Methods with two parameters named as ` from' and ` to' .
1964
+ - `(arg*)` - Methods with one parameter whose name starts with ` arg' ."
1954
1965
:type 'lsp-string-vector
1955
1966
:lsp-path " java.inlayHints.parameterNames.exclusions" )
1956
1967
@@ -2012,10 +2023,10 @@ dependencies. This setting will be ignored if
2012
2023
:lsp-path " java.compile.nullAnalysis.mode" )
2013
2024
2014
2025
(lsp-defcustom lsp-java-cleanup-actions-on-save nil
2015
- " The list of clean ups to be run on the current document when it's
2016
- saved. Clean ups can automatically fix code style or programming
2017
- mistakes. Click [HERE](command:_java.learnMoreAboutCleanUps) to
2018
- learn more about what each clean up does."
2026
+ " The list of clean ups to be run on the current document when it's saved.
2027
+ Clean ups can automatically fix code style or programming mistakes.
2028
+ Click [HERE](command:_java.learnMoreAboutCleanUps) to learn more about what each
2029
+ clean up does."
2019
2030
:type 'lsp-string-vector
2020
2031
:lsp-path " java.cleanup.actionsOnSave" )
2021
2032
@@ -2032,7 +2043,8 @@ Visual Studio Code - Insiders."
2032
2043
:lsp-path " java.sharedIndexes.location" )
2033
2044
2034
2045
(lsp-defcustom lsp-java-refactoring-extract-interface-replace t
2035
- " Specify whether to replace all the occurrences of the subtype with the new extracted interface."
2046
+ " Specify whether to replace all the occurrences of the subtype with the new
2047
+ extracted interface."
2036
2048
:type 'boolean
2037
2049
:lsp-path " java.refactoring.extract.interface.replace" )
2038
2050
0 commit comments