From 71c15262558ba8e0bc6ebdcc2dd0884bb53fa37d Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Wed, 22 May 2019 10:17:56 -0700 Subject: [PATCH] Tweaks to Live hover spacing --- .../LanguageServerCommonsActivator.java | 5 ++--- .../commons/STS4LanguageClientImpl.java | 17 ++++++++------- .../RequestMappingHoverProvider.java | 1 - .../test/RequestMappingLiveHoverTest.java | 21 ------------------- ...stMappingLiveHoverTestWithContextPath.java | 13 ------------ 5 files changed, 12 insertions(+), 45 deletions(-) diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java index b50720ef3..1dacf6aec 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java @@ -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: } diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java index e84034eb4..309700c86 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java @@ -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 oldCodelenses = oldHighligts==null ? ImmutableList.of() : oldHighligts.getCodeLenses(); if (!oldCodelenses.equals(highlights.getCodeLenses())) { currentHighlights.put(target, highlights); - new UpdateHighlights(target); + new UpdateHighlights(target, isCodeLensHighlightOn()); } } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java index 0cdd0f740..cc8524e0b 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java @@ -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)) ); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java index 71d68fbb9..938609cb5 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTest.java @@ -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`]"); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTestWithContextPath.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTestWithContextPath.java index f3f97ed06..9217b1a67 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTestWithContextPath.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingLiveHoverTestWithContextPath.java @@ -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`]"); }