Skip to content

Commit

Permalink
Merge pull request #477 from emacs-lsp/fix/compile
Browse files Browse the repository at this point in the history
fix: Compile warnings
  • Loading branch information
jcs090218 authored May 24, 2024
2 parents 968ddc1 + af84c6d commit 4909c14
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 73 deletions.
6 changes: 3 additions & 3 deletions dap-java.el
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ If the port is taken, DAP will try the next port."
(defcustom dap-java-terminal 'internalConsole
"Default java terminal."
:group 'dap-java
:type '(choice (const 'integratedTerminal)
(const 'externalTerminal)
(const 'internalConsole)))
:type '(choice (const integratedTerminal)
(const externalTerminal)
(const internalConsole)))

(defcustom dap-java-args ""
"Default java args."
Expand Down
152 changes: 82 additions & 70 deletions lsp-java.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
;; Java specific adapter for LSP mode

;;; Code:

(require 'cc-mode)
(require 'lsp-mode)
(require 'markdown-mode)
Expand All @@ -34,6 +35,9 @@
(require 'request)
(require 'cl-lib)

;; Compiler pacifier
(defvar java-ts-mode-indent-offset)

(defgroup lsp-java nil
"JDT emacs frontend."
:prefix "lsp-java-"
Expand All @@ -47,7 +51,8 @@ The slash is expected at the end."
:type 'directory)

(defcustom lsp-java-jdt-ls-prefer-native-command nil
"Use native jdtls command provided by jdtls installation instead of lsp's java -jar invocation."
"Use native jdtls command provided by jdtls installation instead of
lsp's java -jar invocation."
:risky t
:type 'boolean)

Expand Down Expand Up @@ -285,15 +290,15 @@ import is missing."
:lsp-path "java.completion.favoriteStaticMembers")

(lsp-defcustom lsp-java-completion-import-order ["java" "javax" "com" "org"]
"Defines the sorting order of import statements. A package or
type name prefix (e.g. 'org.eclipse') is a valid entry. An import
is always added to the most specific group."
"Defines the sorting order of import statements.
A package or type name prefix (e.g. `org.eclipse') is a valid entry.
An import is always added to the most specific group."
:type '(lsp-repeatable-vector string)
:lsp-path "java.completion.importOrder")

(lsp-defcustom lsp-java-folding-range-enabled t
"Enable/disable smart folding range support. If disabled, it
will use the default indentation-based folding range provided by
"Enable/disable smart folding range support.
If disabled, it will use the default indentation-based folding range provided by
VS Code."
:type 'boolean
:lsp-path "java.foldingRange.enabled")
Expand All @@ -305,8 +310,8 @@ processes on the server."
:lsp-path "java.progressReports.enabled")

(lsp-defcustom lsp-java-format-settings-url nil
"Specifies the url or file path to the [Eclipse formatter xml
settings](https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings)."
"Specifies the url or file path to the [Eclipse formatter XML settings]
(https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings)."
:type '(choice (string)
(const nil))
:lsp-path "java.format.settings.url")
Expand Down Expand Up @@ -342,13 +347,13 @@ and higher."
:lsp-path "java.codeGeneration.hashCodeEquals.useJava7Objects")

(lsp-defcustom lsp-java-code-generation-hash-code-equals-use-instanceof nil
"Use 'instanceof' to compare types when generating the hashCode
"Use `instanceof' to compare types when generating the hashCode
and equals methods."
:type 'boolean
:lsp-path "java.codeGeneration.hashCodeEquals.useInstanceof")

(lsp-defcustom lsp-java-code-generation-use-blocks nil
"Use blocks in 'if' statements when generating the methods."
"Use blocks in `if' statements when generating the methods."
:type 'boolean
:lsp-path "java.codeGeneration.useBlocks")

Expand Down Expand Up @@ -391,7 +396,7 @@ then list all."
"Defines the type filters. All types whose fully qualified name
matches the selected filter strings will be ignored in content
assist or quick fix proposals and when organizing imports. For
example 'java.awt.*' will hide all types from the awt packages."
example `java.awt.*' will hide all types from the awt packages."
:type '(lsp-repeatable-vector string)
:lsp-path "java.completion.filteredTypes")

Expand Down Expand Up @@ -419,7 +424,7 @@ example 'java.awt.*' will hide all types from the awt packages."
(lsp-defcustom lsp-java-import-gradle-home nil
"Use Gradle from the specified local installation directory or
GRADLE_HOME if the Gradle wrapper is missing or disabled and no
'java.import.gradle.version' is specified."
`java.import.gradle.version' is specified."
:type '(choice (string)
(const nil))
:lsp-path "java.import.gradle.home")
Expand Down Expand Up @@ -554,7 +559,8 @@ projects import is skipped on startup."
(defun lsp-java--locate-server-jar ()
"Return the jar file location of the language server.
The entry point of the language server is in `lsp-java-server-install-dir'/plugins/org.eclipse.equinox.launcher_`version'.jar."
The entry point of the language server is in the `lsp-java-server-install-dir'
+ /plugins/org.eclipse.equinox.launcher_`version'.jar."
(pcase (f-glob "org.eclipse.equinox.launcher_*.jar" (expand-file-name "plugins" lsp-java-server-install-dir))
(`(,single-entry) single-entry)
(`nil nil)
Expand All @@ -564,7 +570,8 @@ The entry point of the language server is in `lsp-java-server-install-dir'/plugi
(defun lsp-java--locate-server-command ()
"Return the jdtls command location of the language server.
The entry point of the language server is in `lsp-java-server-install-dir'/bin/jdtls[.bat]."
The entry point of the language server is in the
`lsp-java-server-install-dir'/bin/jdtls[.bat]."
(let ((bin-path (expand-file-name "bin" lsp-java-server-install-dir)))
(locate-file lsp-java-jdt-ls-command `(,bin-path) exec-suffixes 1)))

Expand Down Expand Up @@ -1073,9 +1080,9 @@ current symbol."
(progn
(require 'helm-source)
(helm :sources (helm-make-source
message 'helm-source-sync :candidates items
:action '(("Identity" lambda (_)
(setq lsp-java--helm-result (helm-marked-candidates)))))
message 'helm-source-sync :candidates items
:action '(("Identity" lambda (_)
(setq lsp-java--helm-result (helm-marked-candidates)))))
:buffer "*lsp-java select*"
:prompt message)
lsp-java--helm-result)
Expand Down Expand Up @@ -1556,14 +1563,16 @@ projects."
:lsp-path "java.configuration.maven.globalSettings")

(lsp-defcustom lsp-java-configuration-maven-not-covered-plugin-execution-severity "warning"
"Specifies severity if the plugin execution is not covered by Maven build lifecycle."
"Specifies severity if the plugin execution is not covered by Maven
build lifecycle."
:type '(choice (const "ignore")
(const "warning")
(const "error"))
:lsp-path "java.configuration.maven.notCoveredPluginExecutionSeverity")

(lsp-defcustom lsp-java-configuration-maven-default-mojo-execution-action "ignore"
"Specifies default mojo execution action when no associated metadata can be detected."
"Specifies default mojo execution action when no associated metadata can
be detected."
:type '(choice (:const "ignore") (:const "warn") (:const "error") (:const "execute"))
:lsp-path "java.configuration.maven.defaultMojoExecutionAction")

Expand Down Expand Up @@ -1625,24 +1634,23 @@ actions."
:lsp-path "java.codeGeneration.insertionLocation")

(lsp-defcustom lsp-java-templates-file-header nil
"Specifies the file header comment for new Java file. Supports
configuring multi-line comments with an array of strings, and
using ${variable} to reference the [predefined
variables](command:_java.templateVariables)."
"Specifies the file header comment for new Java file.
Supports configuring multi-line comments with an array of strings,
and using ${variable} to reference
the [predefined variables](command:_java.templateVariables)."
:type 'lsp-string-vector
:lsp-path "java.templates.fileHeader")

(lsp-defcustom lsp-java-templates-type-comment nil
"Specifies the type comment for new Java type. Supports
configuring multi-line comments with an array of strings, and
using ${variable} to reference the [predefined
variables](command:_java.templateVariables)."
"Specifies the type comment for new Java type.
Supports configuring multi-line comments with an array of strings,
and using ${variable} to reference
the [predefined variables](command:_java.templateVariables)."
:type 'lsp-string-vector
:lsp-path "java.templates.typeComment")

(lsp-defcustom lsp-java-references-include-accessors t
"Include getter, setter and builder/constructor when finding
references."
"Include getter, setter and builder/constructor when finding references."
:type 'boolean
:lsp-path "java.references.includeAccessors")

Expand All @@ -1652,16 +1660,15 @@ references."
:lsp-path "java.references.includeDecompiledSources")

(lsp-defcustom lsp-java-type-hierarchy-lazy-load nil
"Enable/disable lazy loading the content in type hierarchy. Lazy
loading could save a lot of loading time but every type should be
"Enable/disable lazy loading the content in type hierarchy.
Lazy loading could save a lot of loading time but every type should be
expanded manually to load its content."
:type 'boolean
:lsp-path "java.typeHierarchy.lazyLoad")

(lsp-defcustom lsp-java-settings-url nil
"Specifies the url or file path to the workspace Java settings.
See [Setting Global
Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)"
See [Setting Global Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)"
:type 'string
:lsp-path "java.settings.url")

Expand All @@ -1682,18 +1689,19 @@ Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Globa
Integer.valueOf(/* s: */ '123', /* radix: */ 10)
```
`#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay hints for methods."
`#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay
hints for methods."
:type '(choice (:const "none") (:const "literals") (:const "all"))
:lsp-path "java.inlayHints.parameterNames.enabled")

(lsp-defcustom lsp-java-inlay-hints-parameter-names-exclusions nil
"The patterns for the methods that will be disabled to show the
inlay hints. Supported pattern examples:
- `java.lang.Math.*` - All the methods from java.lang.Math.
- `*.Arrays.asList` - Methods named as 'asList' in the types named as 'Arrays'.
- `*.println(*)` - Methods named as 'println'.
- `(from, to)` - Methods with two parameters named as 'from' and 'to'.
- `(arg*)` - Methods with one parameter whose name starts with 'arg'."
- `*.Arrays.asList` - Methods named as `asList' in the types named as `Arrays'.
- `*.println(*)` - Methods named as `println'.
- `(from, to)` - Methods with two parameters named as `from' and `to'.
- `(arg*)` - Methods with one parameter whose name starts with `arg'."
:type 'lsp-string-vector
:lsp-path "java.inlayHints.parameterNames.exclusions")

Expand Down Expand Up @@ -1775,7 +1783,8 @@ Visual Studio Code - Insiders."
:lsp-path "java.sharedIndexes.location")

(lsp-defcustom lsp-java-refactoring-extract-interface-replace t
"Specify whether to replace all the occurrences of the subtype with the new extracted interface."
"Specify whether to replace all the occurrences of the subtype with the new
extracted interface."
:type 'boolean
:lsp-path "java.refactoring.extract.interface.replace")

Expand Down Expand Up @@ -1815,40 +1824,42 @@ projects."
:lsp-path "java.configuration.maven.globalSettings")

(lsp-defcustom lsp-java-configuration-maven-not-covered-plugin-execution-severity "warning"
"Specifies severity if the plugin execution is not covered by Maven build lifecycle."
"Specifies severity if the plugin execution is not covered by Maven
build lifecycle."
:type '(choice (:const "ignore") (:const "warning") (:const "error"))
:lsp-path "java.configuration.maven.notCoveredPluginExecutionSeverity")

(lsp-defcustom lsp-java-configuration-maven-default-mojo-execution-action "ignore"
"Specifies default mojo execution action when no associated metadata can be detected."
"Specifies default mojo execution action when no associated metadata
can be detected."
:type '(choice (:const "ignore") (:const "warn") (:const "error") (:const "execute"))
:lsp-path "java.configuration.maven.defaultMojoExecutionAction")

(lsp-defcustom lsp-java-configuration-workspace-cache-limit 90
"The number of days (if enabled) to keep unused workspace cache
data. Beyond this limit, cached workspace data may be removed."
"The number of days (if enabled) to keep unused workspace cache data.
Beyond this limit, cached workspace data may be removed."
:type '(repeat nil)
:lsp-path "java.configuration.workspaceCacheLimit")

(lsp-defcustom lsp-java-import-generates-metadata-files-at-project-root nil
"Specify whether the project metadata files(.project, .classpath,
.factorypath, .settings/) will be generated at the project root.
Click [HERE](command:_java.metadataFilesGeneration) to learn how
to change the setting to make it take effect."
Click [HERE](command:_java.metadataFilesGeneration) to learn how to change the
setting to make it take effect."
:type 'boolean
:lsp-path "java.import.generatesMetadataFilesAtProjectRoot")

(lsp-defcustom lsp-java-project-output-path ""
"A relative path to the workspace where stores the compiled
output. `Only` effective in the `WORKSPACE` scope. The setting
will `NOT` affect Maven or Gradle project."
"A relative path to the workspace where stores the compiled output.
`Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect
Maven or Gradle project."
:type '(repeat string)
:lsp-path "java.project.outputPath")

(lsp-defcustom lsp-java-project-source-paths nil
"Relative paths to the workspace where stores the source files.
`Only` effective in the `WORKSPACE` scope. The setting will `NOT`
affect Maven or Gradle project."
`Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect Maven
or Gradle project."
:type 'lsp-string-vector
:lsp-path "java.project.sourcePaths")

Expand Down Expand Up @@ -1882,24 +1893,23 @@ actions."
:lsp-path "java.codeGeneration.insertionLocation")

(lsp-defcustom lsp-java-templates-file-header nil
"Specifies the file header comment for new Java file. Supports
configuring multi-line comments with an array of strings, and
using ${variable} to reference the [predefined
variables](command:_java.templateVariables)."
"Specifies the file header comment for new Java file.
Supports configuring multi-line comments with an array of strings, and using
${variable} to reference the
[predefined variables](command:_java.templateVariables)."
:type 'lsp-string-vector
:lsp-path "java.templates.fileHeader")

(lsp-defcustom lsp-java-templates-type-comment nil
"Specifies the type comment for new Java type. Supports
configuring multi-line comments with an array of strings, and
using ${variable} to reference the [predefined
variables](command:_java.templateVariables)."
"Specifies the type comment for new Java type.
Supports configuring multi-line comments with an array of strings, and using
${variable} to reference the
[predefined variables](command:_java.templateVariables)."
:type 'lsp-string-vector
:lsp-path "java.templates.typeComment")

(lsp-defcustom lsp-java-references-include-accessors t
"Include getter, setter and builder/constructor when finding
references."
"Include getter, setter and builder/constructor when finding references."
:type 'boolean
:lsp-path "java.references.includeAccessors")

Expand Down Expand Up @@ -1939,18 +1949,19 @@ Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Globa
Integer.valueOf(/* s: */ '123', /* radix: */ 10)
```
`#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay hints for methods."
`#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay
hints for methods."
:type '(choice (:const "none") (:const "literals") (:const "all"))
:lsp-path "java.inlayHints.parameterNames.enabled")

(lsp-defcustom lsp-java-inlay-hints-parameter-names-exclusions nil
"The patterns for the methods that will be disabled to show the
inlay hints. Supported pattern examples:
- `java.lang.Math.*` - All the methods from java.lang.Math.
- `*.Arrays.asList` - Methods named as 'asList' in the types named as 'Arrays'.
- `*.println(*)` - Methods named as 'println'.
- `(from, to)` - Methods with two parameters named as 'from' and 'to'.
- `(arg*)` - Methods with one parameter whose name starts with 'arg'."
- `*.Arrays.asList` - Methods named as `asList' in the types named as `Arrays'.
- `*.println(*)` - Methods named as `println'.
- `(from, to)` - Methods with two parameters named as `from' and `to'.
- `(arg*)` - Methods with one parameter whose name starts with `arg'."
:type 'lsp-string-vector
:lsp-path "java.inlayHints.parameterNames.exclusions")

Expand Down Expand Up @@ -2012,10 +2023,10 @@ dependencies. This setting will be ignored if
:lsp-path "java.compile.nullAnalysis.mode")

(lsp-defcustom lsp-java-cleanup-actions-on-save nil
"The list of clean ups to be run on the current document when it's
saved. Clean ups can automatically fix code style or programming
mistakes. Click [HERE](command:_java.learnMoreAboutCleanUps) to
learn more about what each clean up does."
"The list of clean ups to be run on the current document when it's saved.
Clean ups can automatically fix code style or programming mistakes.
Click [HERE](command:_java.learnMoreAboutCleanUps) to learn more about what each
clean up does."
:type 'lsp-string-vector
:lsp-path "java.cleanup.actionsOnSave")

Expand All @@ -2032,7 +2043,8 @@ Visual Studio Code - Insiders."
:lsp-path "java.sharedIndexes.location")

(lsp-defcustom lsp-java-refactoring-extract-interface-replace t
"Specify whether to replace all the occurrences of the subtype with the new extracted interface."
"Specify whether to replace all the occurrences of the subtype with the new
extracted interface."
:type 'boolean
:lsp-path "java.refactoring.extract.interface.replace")

Expand Down

0 comments on commit 4909c14

Please sign in to comment.