Add ability to specify version of jdt.ls to use.
This commit is contained in:
parent
905e034137
commit
198f28d994
@ -28,7 +28,7 @@ def locate_launcher_configuration (jdt_ls_path):
|
||||
def log (message, *args, **kwargs):
|
||||
print(message.format(*args, **kwargs), file=sys.stderr)
|
||||
|
||||
def download_jdt_ls (destination):
|
||||
def download_jdt_ls (version, destination):
|
||||
if not os.path.isdir(destination):
|
||||
os.makedirs(destination)
|
||||
|
||||
@ -40,12 +40,12 @@ def download_jdt_ls (destination):
|
||||
log("Currently downloaded version is {version}:", version=current_version)
|
||||
|
||||
latest_version = None
|
||||
with request.urlopen(DOWNLOADS_URI.format(version=VERSION, file=LATEST)) as f:
|
||||
with request.urlopen(DOWNLOADS_URI.format(version=version, file=LATEST)) as f:
|
||||
latest_version = f.read().decode().strip()
|
||||
log("Latest available version is {version}:", version=latest_version)
|
||||
|
||||
if not latest_version == current_version:
|
||||
latest_uri = DOWNLOADS_URI.format(version=VERSION, file=latest_version)
|
||||
latest_uri = DOWNLOADS_URI.format(version=version, file=latest_version)
|
||||
log("Downloading latest version from: {uri}:", uri=latest_uri)
|
||||
with request.urlopen(latest_uri) as f:
|
||||
with tarfile.open(fileobj=f, mode="r|gz") as tar:
|
||||
@ -61,12 +61,25 @@ def download_jdt_ls (destination):
|
||||
def locate_lombok ():
|
||||
return os.path.join(os.environ['HOME'], ".m2/repository/org/projectlombok/lombok/1.18.16/lombok-1.18.16.jar")
|
||||
|
||||
def get_argument (arguments, arg_name):
|
||||
if not arg_name in args:
|
||||
return
|
||||
|
||||
value = arguments.pop(arguments.index(arg_name) + 1)
|
||||
arguments.remove(arg_name)
|
||||
return value
|
||||
|
||||
class Java(LspServer):
|
||||
def __init__ (self, arguments):
|
||||
self.path = arguments[0] if arguments else None
|
||||
|
||||
if self.path is None or not os.path.exists(self.path):
|
||||
self.path = download_jdt_ls(os.path.join(get_data_home(), "java", "jdt.ls"))
|
||||
version = VERSION
|
||||
|
||||
if "--version" in arguments:
|
||||
version = get_argument(arguments, "--version")
|
||||
|
||||
self.path = download_jdt_ls(version, os.path.join(get_data_home(), "java", "jdt.ls", version))
|
||||
else:
|
||||
self.path = locate_product_directory(self.path)
|
||||
|
||||
@ -77,8 +90,7 @@ class Java(LspServer):
|
||||
|
||||
data_directory = None
|
||||
if "--data" in arguments:
|
||||
data_directory = arguments.pop(arguments.index("--data") + 1)
|
||||
arguments.remove("--data")
|
||||
data_directory = get_argument(arguments, "--data")
|
||||
else:
|
||||
data_directory = os.path.join(get_data_home(), "java", "data")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user