From 319bc0124bbbd91abe3379ae44b2c91d1a6e0765 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Tue, 6 Mar 2018 16:02:35 -0800 Subject: [PATCH] Simple demo of registering a jdt command --- .../.classpath | 7 +++ .../.project | 28 ++++++++++ .../.settings/org.eclipse.jdt.core.prefs | 7 +++ .../META-INF/MANIFEST.MF | 9 ++++ .../build.properties | 5 ++ .../plugin.xml | 10 ++++ .../pom.xml | 35 +++++++++++++ .../ls/extension/ResolveClasspathHandler.java | 26 ++++++++++ .../target-platform.target | 52 +++++++++++++++++++ .../vscode-spring-boot/lib/Main.ts | 15 ++++-- .../vscode-spring-boot/package.json | 3 ++ .../vscode-spring-boot/scripts/preinstall.sh | 12 +++-- 12 files changed, 203 insertions(+), 6 deletions(-) create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/.classpath create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/.project create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/.settings/org.eclipse.jdt.core.prefs create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/META-INF/MANIFEST.MF create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/build.properties create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/plugin.xml create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/pom.xml create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/src/org/springframework/tooling/jdt/ls/extension/ResolveClasspathHandler.java create mode 100644 headless-services/org.springframework.tooling.jdt.ls.extension/target-platform.target diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/.classpath b/headless-services/org.springframework.tooling.jdt.ls.extension/.classpath new file mode 100644 index 000000000..eca7bdba8 --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/.project b/headless-services/org.springframework.tooling.jdt.ls.extension/.project new file mode 100644 index 000000000..1b18edcd2 --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/.project @@ -0,0 +1,28 @@ + + + org.springframework.tooling.jdt.ls.extension + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/.settings/org.eclipse.jdt.core.prefs b/headless-services/org.springframework.tooling.jdt.ls.extension/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0c68a61dc --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/META-INF/MANIFEST.MF b/headless-services/org.springframework.tooling.jdt.ls.extension/META-INF/MANIFEST.MF new file mode 100644 index 000000000..99188644a --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.springframework.tooling.jdt.ls.extension +Bundle-SymbolicName: org.springframework.tooling.jdt.ls.extension;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Pivotal Inc. +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.jdt.ls.core, + org.eclipse.core.runtime diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/build.properties b/headless-services/org.springframework.tooling.jdt.ls.extension/build.properties new file mode 100644 index 000000000..e9863e281 --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/plugin.xml b/headless-services/org.springframework.tooling.jdt.ls.extension/plugin.xml new file mode 100644 index 000000000..4e2611527 --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/pom.xml b/headless-services/org.springframework.tooling.jdt.ls.extension/pom.xml new file mode 100644 index 000000000..72e9694ce --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/pom.xml @@ -0,0 +1,35 @@ + + 4.0.0 + eclipse-plugin + org.springframework.ide.vscode + org.springframework.tooling.jdt.ls.extension + 1.0.0-SNAPSHOT + org.springframework.tooling.jdt.ls.extension + + 1.1.0 + + + + eclipse-oxygen + p2 + http://download.eclipse.org/releases/oxygen + + + JDT.LS + p2 + http://download.eclipse.org/jdtls/snapshots/repository/latest/ + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + + \ No newline at end of file diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/src/org/springframework/tooling/jdt/ls/extension/ResolveClasspathHandler.java b/headless-services/org.springframework.tooling.jdt.ls.extension/src/org/springframework/tooling/jdt/ls/extension/ResolveClasspathHandler.java new file mode 100644 index 000000000..e3fdb68ab --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/src/org/springframework/tooling/jdt/ls/extension/ResolveClasspathHandler.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2018 Pivotal, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.tooling.jdt.ls.extension; + +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.ls.core.internal.IDelegateCommandHandler; + +@SuppressWarnings("restriction") +public class ResolveClasspathHandler implements IDelegateCommandHandler { + + @Override + public Object executeCommand(String commandId, List arguments, IProgressMonitor monitor) throws Exception { + return "Tasty "+arguments.get(0)+"!"; + } + +} diff --git a/headless-services/org.springframework.tooling.jdt.ls.extension/target-platform.target b/headless-services/org.springframework.tooling.jdt.ls.extension/target-platform.target new file mode 100644 index 000000000..c77a11c53 --- /dev/null +++ b/headless-services/org.springframework.tooling.jdt.ls.extension/target-platform.target @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vscode-extensions/vscode-spring-boot/lib/Main.ts b/vscode-extensions/vscode-spring-boot/lib/Main.ts index 6b5ae76d8..bcf374cd4 100644 --- a/vscode-extensions/vscode-spring-boot/lib/Main.ts +++ b/vscode-extensions/vscode-spring-boot/lib/Main.ts @@ -35,9 +35,18 @@ export function activate(context: VSCode.ExtensionContext) { }, initializationOptions: { workspaceFolders: workspace.workspaceFolders ? workspace.workspaceFolders.map(f => f.uri.toString()) : null - }, - + } } }; - let clientPromise = commons.activate(options, context); + setTimeout(() => { + VSCode.commands.executeCommand("java.execute.workspaceCommand", "sts.java.resolveClasspath", "Brocoli", "Cabbage") + .then( + (commandResult) => VSCode.window.showInformationMessage(""+commandResult), + (e) => { + VSCode.window.showErrorMessage("Error" + e); + } + ); + }, 10000); + + return commons.activate(options, context); } diff --git a/vscode-extensions/vscode-spring-boot/package.json b/vscode-extensions/vscode-spring-boot/package.json index 85df507ea..681781d17 100644 --- a/vscode-extensions/vscode-spring-boot/package.json +++ b/vscode-extensions/vscode-spring-boot/package.json @@ -31,6 +31,9 @@ "onLanguage:java" ], "contributes": { + "javaExtensions": [ + "./jars/jdt-ls-extension.jar" + ], "languages": [ { "id": "spring-boot-properties-yaml", diff --git a/vscode-extensions/vscode-spring-boot/scripts/preinstall.sh b/vscode-extensions/vscode-spring-boot/scripts/preinstall.sh index 61c80406a..5667fb908 100755 --- a/vscode-extensions/vscode-spring-boot/scripts/preinstall.sh +++ b/vscode-extensions/vscode-spring-boot/scripts/preinstall.sh @@ -11,11 +11,17 @@ npm install ../commons-vscode/commons-vscode-*.tgz curl https://raw.githubusercontent.com/textmate/yaml.tmbundle/master/Syntaxes/YAML.tmLanguage > yaml-support/yaml.tmLanguage curl https://raw.githubusercontent.com/textmate/java.tmbundle/master/Syntaxes/JavaProperties.plist > properties-support/java-properties.tmLanguage +# Clean old jars +rm -fr ${workdir}/jars +mkdir -p ${workdir}/jars + +# Use maven to build jdt ls extension +cd ../../headless-services/org.springframework.tooling.jdt.ls.extension +../mvnw clean package +cp target/*.jar ${workdir}/jars/jdt-ls-extension.jar + # Use maven to build fat jar of the language server cd ../../headless-services/spring-boot-language-server ./build.sh - -rm -fr ${workdir}/jars -mkdir -p ${workdir}/jars cp target/*.jar ${workdir}/jars