@@ -114,24 +114,24 @@ def ShouldEnableJavaCompleter( user_options ):
114114 LOGGER .warning ( "Not enabling java completion: Couldn't find java 11" )
115115 return False
116116
117- if not os . path . exists ( LANGUAGE_SERVER_HOME ):
117+ if not _PathToLauncherJar ( user_options ):
118118 LOGGER .warning ( 'Not using java completion: jdt.ls is not installed' )
119119 return False
120120
121- if not _PathToLauncherJar ():
122- LOGGER .warning ( 'Not using java completion: jdt.ls is not built' )
123- return False
124-
125121 return True
126122
127123
128- def _PathToLauncherJar ():
124+ def _LanguageServerHome ( user_options ):
125+ return user_options .get ( 'java_jdtls_repository_path' , LANGUAGE_SERVER_HOME )
126+
127+
128+ def _PathToLauncherJar ( user_options ):
129129 # The file name changes between version of eclipse, so we use a glob as
130130 # recommended by the language server developers. There should only be one.
131131 launcher_jars = glob .glob (
132132 os .path .abspath (
133133 os .path .join (
134- LANGUAGE_SERVER_HOME ,
134+ _LanguageServerHome ( user_options ) ,
135135 'plugins' ,
136136 'org.eclipse.equinox.launcher_*.jar' ) ) )
137137
@@ -183,7 +183,7 @@ def _CollectExtensionBundles( extension_path ):
183183 return extension_bundles
184184
185185
186- def _LauncherConfiguration ( workspace_root , wipe_config ):
186+ def _LauncherConfiguration ( user_options , workspace_root , wipe_config ):
187187 if utils .OnMac ():
188188 config = 'config_mac'
189189 elif utils .OnWindows ():
@@ -211,9 +211,10 @@ def _LauncherConfiguration( workspace_root, wipe_config ):
211211 working_config = os .path .abspath ( os .path .join ( workspace_root ,
212212 config ) )
213213 working_config_file = os .path .join ( working_config , CONFIG_FILENAME )
214- base_config_file = os .path .abspath ( os .path .join ( LANGUAGE_SERVER_HOME ,
215- config ,
216- CONFIG_FILENAME ) )
214+ base_config_file = os .path .abspath (
215+ os .path .join ( _LanguageServerHome ( user_options ),
216+ config ,
217+ CONFIG_FILENAME ) )
217218
218219 if os .path .isdir ( working_config ):
219220 if wipe_config :
@@ -285,7 +286,10 @@ def _WorkspaceDirForProject( workspace_root_path,
285286
286287class JavaCompleter ( language_server_completer .LanguageServerCompleter ):
287288 def __init__ ( self , user_options ):
289+ # Stuff used by _Reset have to be set here as super().__init__() calls it.
288290 self ._workspace_path = None
291+ self ._user_options = user_options
292+
289293 super ().__init__ ( user_options )
290294
291295 self ._server_keep_logfiles = user_options [ 'server_keep_logfiles' ]
@@ -316,7 +320,23 @@ def __init__( self, user_options ):
316320
317321 def DefaultSettings ( self , request_data ):
318322 return {
319- 'bundles' : self ._bundles
323+ 'bundles' : self ._bundles ,
324+
325+ # This disables re-checking every open file on every change to every file.
326+ # But can lead to stale diagnostics. Unfortunately, this can be kind of
327+ # annoying, so we don't enable it by default. JDT does re-validate if you
328+ # force load a file, but there isn't a nice way to force it to revalidate
329+ # a specific file e.g. OnFileReadyToParse, so far as i know.
330+ # If users have perf problems, they can set this in the .ycm_extra_conf.py
331+ #
332+ # def Settings( **kwargs ):
333+ # return {
334+ # 'ls': {
335+ # 'java.edit.validateAllOpenBuffersOnChanges': False
336+ # }
337+ # }
338+ #
339+ # 'java.edit.validateAllOpenBuffersOnChanges': False
320340 }
321341
322342
@@ -420,7 +440,7 @@ def _Reset( self ):
420440 LOGGER .exception ( 'Failed to clean up workspace dir %s' ,
421441 self ._workspace_path )
422442
423- self ._launcher_path = _PathToLauncherJar ()
443+ self ._launcher_path = _PathToLauncherJar ( self . _user_options )
424444 self ._launcher_config = None
425445 self ._workspace_path = None
426446 self ._java_project_dir = None
@@ -466,8 +486,9 @@ def StartServer( self,
466486 shutil .rmtree ( self ._workspace_path )
467487
468488 self ._launcher_config = _LauncherConfiguration (
469- self ._workspace_root_path ,
470- wipe_config )
489+ self ._user_options ,
490+ self ._workspace_root_path ,
491+ wipe_config )
471492
472493 self ._command = [ PATH_TO_JAVA ] + self ._GetJvmArgs ( request_data ) + [
473494 '-Dfile.encoding=UTF-8' ,
0 commit comments