Tweaks to Live hover spacing

This commit is contained in:
Kris De Volder
2019-05-22 10:17:56 -07:00
parent 5be48c847d
commit 71c1526255
5 changed files with 12 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Pivotal, Inc.
* Copyright (c) 2018, 2019 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
@@ -11,7 +11,6 @@
package org.springframework.tooling.ls.eclipse.commons;
import java.net.URL;
import java.time.Duration;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -59,7 +58,7 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin {
colorRegistry.put(PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS, derivedColor);
// No break - need to update highlights for the new color to take effect
case PreferenceConstants.HIGHLIGHT_CODELENS_PREFS:
new UpdateHighlights(null);
new UpdateHighlights(null, true);
break;
default:
}

View File

@@ -179,10 +179,12 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
static class UpdateHighlights extends UIJob {
private String target;
private boolean updateCodeMinings;
UpdateHighlights(String target) {
UpdateHighlights(String target, boolean updateCodeMinings) {
super("Update highlights");
this.target = target;
this.updateCodeMinings = updateCodeMinings;
setSystem(true);
schedule();
}
@@ -204,12 +206,12 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
if (target != null) {
HighlightParams highlightParams = currentHighlights.get(target);
if (Utils.isProperDocumentIdFor(doc, highlightParams.getDoc())) {
updateHighlightAnnotations(editor, sourceViewer, annotationModel, target);
updateHighlightAnnotations(editor, sourceViewer, annotationModel, target, updateCodeMinings);
}
} else {
URI uri = Utils.findDocUri(doc);
if (uri != null) {
updateHighlightAnnotations(editor, sourceViewer, annotationModel, uri.toString());
updateHighlightAnnotations(editor, sourceViewer, annotationModel, uri.toString(), updateCodeMinings);
}
}
}
@@ -220,14 +222,15 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
};
private static void updateHighlightAnnotations(IEditorPart editor, ISourceViewer sourceViewer,
IAnnotationModel annotationModel, String docUri) {
IAnnotationModel annotationModel, String docUri, boolean updateCodeMinings) {
boolean codeLensHighlightOn = isCodeLensHighlightOn();
if (annotationModel instanceof IAnnotationModelExtension) {
if (isCodeLensHighlightOn()) {
if (codeLensHighlightOn) {
addBootRangeHighlightSupport(editor, sourceViewer);
}
updateAnnotations(docUri, sourceViewer, (IAnnotationModelExtension) annotationModel);
}
if (sourceViewer instanceof ISourceViewerExtension5) {
if (updateCodeMinings && sourceViewer instanceof ISourceViewerExtension5) {
if (sourceViewer instanceof JavaSourceViewer) {
// JavaSourceViewer#updateCodeMinings() is overridden and doesn't do anything
try {
@@ -323,7 +326,7 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
List<CodeLens> oldCodelenses = oldHighligts==null ? ImmutableList.of() : oldHighligts.getCodeLenses();
if (!oldCodelenses.equals(highlights.getCodeLenses())) {
currentHighlights.put(target, highlights);
new UpdateHighlights(target);
new UpdateHighlights(target, isCodeLensHighlightOn());
}
}
}

View File

@@ -278,7 +278,6 @@ public class RequestMappingHoverProvider implements HoverProvider {
Renderable urlRenderables = Renderables.concat(renderableUrls);
Renderable processSection = Renderables.concat(
urlRenderables,
Renderables.lineBreak(),
Renderables.mdBlob(LiveHoverUtils.niceAppName(app))
);

View File

@@ -71,7 +71,6 @@ public class RequestMappingLiveHoverTest {
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/hello-world](https://cfapps.io:1111/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -105,7 +104,6 @@ public class RequestMappingLiveHoverTest {
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/](https://cfapps.io:1111/) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
@@ -160,11 +158,9 @@ public class RequestMappingLiveHoverTest {
editor.assertHighlights("@RequestMapping(\"/hello\")", "@RequestMapping(\"/goodbye\")");
editor.assertHoverContains("@RequestMapping(\"/hello\")", "[https://cfapps.io:999/hello](https://cfapps.io:999/hello) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
editor.assertHoverContains("@RequestMapping(\"/goodbye\")", "[https://cfapps.io:999/goodbye](https://cfapps.io:999/goodbye) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -237,7 +233,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@DeleteMapping(\"/greetings\")", "[https://cfapps.io:999/greetings](https://cfapps.io:999/greetings) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -374,7 +369,6 @@ public class RequestMappingLiveHoverTest {
editor.assertHoverContains("@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)", "[https://cfapps.io:999/greetings](https://cfapps.io:999/greetings) \n" +
"[https://cfapps.io:999/hello](https://cfapps.io:999/hello) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -426,7 +420,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -478,7 +471,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -531,7 +523,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -584,7 +575,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -635,7 +625,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@@ -686,9 +675,7 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@Test
@@ -737,9 +724,7 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "[https://cfapps.io:999/find](https://cfapps.io:999/find) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}
@Test
@@ -793,17 +778,13 @@ public class RequestMappingLiveHoverTest {
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHoverContains("@RequestMapping(\"/hello\")", "[https://cfapps.io:1000/hello](https://cfapps.io:1000/hello) \n" +
"\n" +
"Process [PID=70000, name=`test-request-mapping-live-hover`]\n" +
"\n" +
"[https://cfapps.io:1001/hello](https://cfapps.io:1001/hello) \n" +
"\n" +
"Process [PID=80000, name=`test-request-mapping-live-hover`]\n" +
"\n" +
"[https://cfapps.io:1002/hello](https://cfapps.io:1002/hello) \n" +
"\n" +
"Process [PID=90000, name=`test-request-mapping-live-hover`]");
}
@Test
@@ -869,11 +850,9 @@ public class RequestMappingLiveHoverTest {
editor.assertHighlights("@RequestMapping(\"/inner-class\")", "@RequestMapping(\"/inner-inner-class\")");
editor.assertHoverContains("@RequestMapping(\"/inner-class\")", "[https://cfapps.io:1111/inner-class](https://cfapps.io:1111/inner-class) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
editor.assertHoverContains("@RequestMapping(\"/inner-inner-class\")", "[https://cfapps.io:1111/inner-inner-class](https://cfapps.io:1111/inner-inner-class) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}

View File

@@ -71,7 +71,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromEnv/hello-world](https://cfapps.io:1111/fromEnv/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -108,7 +107,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromlaunchconfig/hello-world](https://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -146,7 +144,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromlaunchconfig/hello-world](https://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -184,7 +181,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/frompropsfile/hello-world](https://cfapps.io:1111/frompropsfile/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -222,7 +218,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/frompropsfile/hello-world](https://cfapps.io:1111/frompropsfile/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -259,7 +254,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromenvironment/hello-world](https://cfapps.io:1111/fromenvironment/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -296,7 +290,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromlaunchconfig/hello-world](https://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -334,7 +327,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromlaunchconfig/hello-world](https://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -372,7 +364,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/frompropsfile/hello-world](https://cfapps.io:1111/frompropsfile/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -410,7 +401,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/frompropsfile/hello-world](https://cfapps.io:1111/frompropsfile/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -450,7 +440,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/fromlaunchconfig/hello-world](https://cfapps.io:1111/fromlaunchconfig/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -485,7 +474,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[https://cfapps.io:1111/mockedpath/hello-world](https://cfapps.io:1111/mockedpath/hello-world) \n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
@@ -535,7 +523,6 @@ public class RequestMappingLiveHoverTestWithContextPath {
editor.assertHoverContains("@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)", "[https://cfapps.io:999/mockedpath/greetings](https://cfapps.io:999/mockedpath/greetings) \n" +
"[https://cfapps.io:999/mockedpath/hello](https://cfapps.io:999/mockedpath/hello) \n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
}