Merge branch 'master' of github.com:spring-projects/sts4

This commit is contained in:
Kris De Volder
2018-09-07 13:20:52 -07:00
11 changed files with 126 additions and 39 deletions

View File

@@ -319,7 +319,7 @@
<repository>
<id>orbit</id>
<layout>p2</layout>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/S20180710163057/repository</url>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/R20180905201904/repository</url>
</repository>
<repository>
<id>latest-m2e</id>

View File

@@ -86,10 +86,10 @@
<extension
point="org.eclipse.ui.preferencePages">
<page
category="org.springsource.ide.eclipse.commons.preferencePage"
category="org.springframework.tooling.ls.eclipse.commons.console.preferences"
class="org.springframework.tooling.boot.ls.BootLanguageServerPreferencesPage"
id="org.springframework.tooling.boot.java.ls.page1"
name="Boot Language Server Extension">
id="org.springframework.tooling.boot.java.ls.preferences"
name="Spring Boot Language Server">
</page>
</extension>

View File

@@ -12,8 +12,15 @@ package org.springframework.tooling.boot.ls;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.springframework.tooling.ls.eclipse.commons.LanguageServerCommonsActivator;
import org.springframework.tooling.ls.eclipse.commons.preferences.PreferenceConstants;
/**
* Preference page for Boot-Java LS extension
@@ -28,17 +35,43 @@ public class BootLanguageServerPreferencesPage extends FieldEditorPreferencePage
@Override
public void init(IWorkbench workbench) {
setDescription("Settings for Boot-Java language server extension");
setPreferenceStore(BootLanguageServerPlugin.getDefault().getPreferenceStore());
}
@Override
protected void createFieldEditors() {
BooleanFieldEditor liveHintsPrefEditor = new BooleanFieldEditor(Constants.PREF_BOOT_HINTS, "Live Boot Hint Decorators", getFieldEditorParent());
Composite parent = getFieldEditorParent();
Label l = new Label(parent, SWT.NONE);
l.setFont(parent.getFont());
l.setText("Settings for Spring Boot Live Beans data:");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = false;
l.setLayoutData(gd);
BooleanFieldEditor liveHintsPrefEditor = new BooleanFieldEditor(Constants.PREF_BOOT_HINTS, "Live Boot Hint Decorators", parent);
addField(liveHintsPrefEditor);
BooleanFieldEditor liveChangeDetectionPrefEditor = new BooleanFieldEditor(Constants.PREF_CHANGE_DETECTION, "Live Boot Change Detection", getFieldEditorParent());
final IPreferenceStore commonsLsPrefs = LanguageServerCommonsActivator.getInstance().getPreferenceStore();
addField(new BooleanFieldEditor(PreferenceConstants.HIGHLIGHT_CODELENS_PREFS, "Highlights CodeLens (Experimental)", parent) {
@Override
public IPreferenceStore getPreferenceStore() {
return commonsLsPrefs;
}
});
BooleanFieldEditor liveChangeDetectionPrefEditor = new BooleanFieldEditor(Constants.PREF_CHANGE_DETECTION, "Live Boot Change Detection", parent);
addField(liveChangeDetectionPrefEditor);
l = new Label(parent, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
l.setLayoutData(gd);
}
}

View File

@@ -28,10 +28,11 @@
<extension
point="org.eclipse.ui.preferencePages">
<page
class="org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolesPreferencesPage"
id="org.springframework.tooling.ls.eclipse.commons.console.preferences.LanguageServerConsolesPreferencesPage"
name="Language Servers STS">
</page>
category="org.eclipse.lsp4e.preferences"
class="org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerPreferencesPage"
id="org.springframework.tooling.ls.eclipse.commons.console.preferences"
name="Spring Language Servers">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">

View File

@@ -12,7 +12,6 @@ package org.springframework.tooling.ls.eclipse.commons.preferences;
import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.ALL_SERVERS;
import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -22,8 +21,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import org.springframework.tooling.ls.eclipse.commons.LanguageServerCommonsActivator;
import org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.ServerInfo;
@SuppressWarnings("restriction")
public class LanguageServerConsolesPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public class LanguageServerPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
static IPreferenceStore getPrefsStoreFromPlugin() {
return LanguageServerCommonsActivator.getInstance().getPreferenceStore();
@@ -42,12 +40,5 @@ public class LanguageServerConsolesPreferencesPage extends FieldEditorPreference
for (ServerInfo s : ALL_SERVERS) {
addField(new BooleanFieldEditor(s.preferenceKey, s.label, parent));
}
SWTFactory.createHorizontalSpacer(parent, 2);
SWTFactory.createLabel(parent, "Settings for Spring Languare Server extensions:", 2);
addField(new BooleanFieldEditor(PreferenceConstants.HIGHLIGHT_CODELENS_PREFS, "Highlights CodeLens (Experimental)", parent));
}
}

View File

@@ -20,7 +20,7 @@ import org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServer
public class PrefsInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = LanguageServerConsolesPreferencesPage.getPrefsStoreFromPlugin();
IPreferenceStore store = LanguageServerPreferencesPage.getPrefsStoreFromPlugin();
for (ServerInfo s : ALL_SERVERS) {
store.setDefault(s.preferenceKey, ENABLE_BY_DEFAULT);
}

View File

@@ -237,7 +237,7 @@
<repository>
<id>orbit</id>
<layout>p2</layout>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/S20180710163057/repository</url>
<url>http://download.eclipse.org/tools/orbit/downloads/drops/R20180905201904/repository</url>
</repository>
<repository>
<id>e-i-commons</id>

View File

@@ -62,12 +62,19 @@ Example entry:
private JSONObject getHandlerMethod() {
JSONObject details = getDetails();
return details == null ? null : details.getJSONObject("handlerMethod");
if (details != null) {
if (details.has("handlerMethod")) {
return details.getJSONObject("handlerMethod");
} else if (details.has("handlerFunction")) {
//TODO: handler function for the Router bean
}
}
return null;
}
private JSONObject getRequestMappingConditions() {
JSONObject details = getDetails();
return details == null ? null : details.getJSONObject("requestMappingConditions");
return details == null ? null : details.optJSONObject("requestMappingConditions");
}
@Override

View File

@@ -12,7 +12,9 @@ package org.springframework.ide.vscode.commons.boot.app.cli;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
@@ -20,6 +22,8 @@ import org.junit.Test;
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping;
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMappingsParser20;
import com.google.common.collect.ImmutableSet;
public class Boot2xRequestMappingsTest {
@Test
@@ -27,13 +31,62 @@ public class Boot2xRequestMappingsTest {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-web.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(10, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/error",
"/actuator",
"/actuator/health",
"/actuator/info",
"/hello",
"/qq",
"/pp"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxAnnotationRms() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(7, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info",
"/hello",
"/pp",
"/qq"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxAnnotationRmsFunctional() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux-functional.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(6, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
}

View File

@@ -20,6 +20,7 @@ import java.util.stream.Stream;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.IAnnotationBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.springframework.ide.vscode.commons.util.CollectorUtil;
import com.google.common.collect.ImmutableList;
@@ -34,28 +35,31 @@ import com.google.common.collect.ImmutableList;
*/
public abstract class AnnotationHierarchies {
private AnnotationHierarchies() {
}
protected static boolean ignoreAnnotation(String fqname) {
return fqname.startsWith("java."); //mostly intended to capture java.lang.annotation.* types. But really it should be
//safe to ignore any type defined by the JRE since it can't possibly be inheriting from a spring annotation.
};
public static Collection<ITypeBinding> getDirectSuperAnnotations(ITypeBinding typeBinding) {
IAnnotationBinding[] annotations = typeBinding.getAnnotations();
if (annotations!=null && annotations.length!=0) {
ImmutableList.Builder<ITypeBinding> superAnnotations = ImmutableList.builder();
for (IAnnotationBinding ab : annotations) {
ITypeBinding sa = ab.getAnnotationType();
if (sa!=null) {
if (!ignoreAnnotation(sa.getQualifiedName())) {
superAnnotations.add(sa);
try {
IAnnotationBinding[] annotations = typeBinding.getAnnotations();
if (annotations != null && annotations.length != 0) {
ImmutableList.Builder<ITypeBinding> superAnnotations = ImmutableList.builder();
for (IAnnotationBinding ab : annotations) {
ITypeBinding sa = ab.getAnnotationType();
if (sa != null) {
if (!ignoreAnnotation(sa.getQualifiedName())) {
superAnnotations.add(sa);
}
}
}
return superAnnotations.build();
}
return superAnnotations.build();
}
catch (AbortCompilation e) {
// ignore this, it is most likely caused by broken source code, a broken classpath, or some optional dependencies not being on the classpath
}
return ImmutableList.of();
}

View File

@@ -33,8 +33,6 @@ import com.google.common.collect.ImmutableList;
*/
public class AnnotationHierarchyAwareLookup<T> {
private static final boolean DEBUG = false;
private static class Binding<T> {
T value;
boolean isOverriding;