Simple demo of registering a jdt command

This commit is contained in:
Kris De Volder
2018-03-06 16:02:35 -08:00
parent bdebabf696
commit 319bc0124b
12 changed files with 203 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.springframework.tooling.jdt.ls.extension</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.jdt.ls.core.delegateCommandHandler">
<delegateCommandHandler class="org.springframework.tooling.jdt.ls.extension.ResolveClasspathHandler">
<command id="sts.java.resolveClasspath"/>
</delegateCommandHandler>
</extension>
</plugin>

View File

@@ -0,0 +1,35 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>eclipse-plugin</packaging>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>org.springframework.tooling.jdt.ls.extension</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>org.springframework.tooling.jdt.ls.extension</name>
<properties>
<tycho-version>1.1.0</tycho-version>
</properties>
<repositories>
<repository>
<id>eclipse-oxygen</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/oxygen</url>
</repository>
<repository>
<id>JDT.LS</id>
<layout>p2</layout>
<url>http://download.eclipse.org/jdtls/snapshots/repository/latest/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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<Object> arguments, IProgressMonitor monitor) throws Exception {
return "Tasty "+arguments.get(0)+"!";
}
}

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?><target name="Java Language Server Target Definition" sequenceNumber="109">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.mockito.mockito-all" version="1.9.5"/>
<repository location="http://download.eclipse.org/scout/releases/4.0/testing"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.xtend.sdk.feature.group" version="2.12.0.v20170519-1412"/>
<unit id="org.eclipse.xtext.sdk.feature.group" version="2.12.0.v20170519-1412"/>
<repository location="http://download.eclipse.org/releases/oxygen"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="com.google.gson" version="2.7.0.v20170129-0911"/>
<unit id="com.google.gson.source" version="2.7.0.v20170129-0911"/>
<unit id="com.ibm.icu.base" version="58.2.0.v20170418-1837"/>
<unit id="org.apache.commons.io" version="2.2.0.v201405211200"/>
<unit id="org.apache.commons.lang3" version="3.1.0.v201403281430"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<repository location="http://download.eclipse.org/tools/orbit/R-builds/R20170516192513/repository"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.lsp4j.sdk.feature.group" version="0.3.0.v20170913-0640"/>
<repository location="http://download.eclipse.org/lsp4j/updates/releases/0.3.0/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.buildship.feature.group" version="2.2.0.v20171211-1404"/>
<repository location="http://download.eclipse.org/buildship/updates/e47/releases/2.x/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.m2e.feature.feature.group" version="1.9.0.20180214-1942"/>
<repository location="http://download.eclipse.org/technology/m2e/milestones/1.9/1.9.0.20180214-1942/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.equinox.core.feature.feature.group" version="1.5.0.v20180123-1456"/>
<unit id="org.eclipse.equinox.core.sdk.feature.group" version="3.14.0.v20180119-2027"/>
<unit id="org.eclipse.equinox.executable.feature.group" version="3.8.0.v20180124-1426"/>
<unit id="org.eclipse.equinox.p2.core.feature.source.feature.group" version="1.5.0.v20180122-2220"/>
<unit id="org.eclipse.equinox.p2.discovery.feature.feature.group" version="1.2.0.v20180103-0918"/>
<unit id="org.eclipse.equinox.p2.rcp.feature.feature.group" version="1.4.0.v20180122-2220"/>
<unit id="org.eclipse.equinox.sdk.feature.group" version="3.14.0.v20180124-1426"/>
<unit id="org.eclipse.jdt.source.feature.group" version="3.14.0.v20180124-2000"/>
<unit id="org.eclipse.sdk.feature.group" version="4.8.0.v20180124-2000"/>
<repository location="http://download.eclipse.org/eclipse/updates/4.8milestones/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.jdt.ls.core" version="0.15.0.201803012111"/>
<repository location="http://download.eclipse.org/jdtls/snapshots/repository/latest/"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
</target>

View File

@@ -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);
}

View File

@@ -31,6 +31,9 @@
"onLanguage:java"
],
"contributes": {
"javaExtensions": [
"./jars/jdt-ls-extension.jar"
],
"languages": [
{
"id": "spring-boot-properties-yaml",

View File

@@ -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