Streamline arrows in boot hint Hovers and CodeLenses
This commit is contained in:
@@ -56,7 +56,8 @@ import com.google.common.collect.ImmutableList;
|
||||
*/
|
||||
public class AutowiredHoverProvider implements HoverProvider {
|
||||
|
||||
public static final String BEANS_PREFIX = "\u21D0 ";
|
||||
public static final String BEANS_PREFIX_PLAIN_TEXT = "\u2190 ";
|
||||
public static final String BEANS_PREFIX_MARDOWN = "← ";
|
||||
|
||||
private static final String JAVA_COLLECTION = "java.util.Collection";
|
||||
|
||||
@@ -92,7 +93,7 @@ public class AutowiredHoverProvider implements HoverProvider {
|
||||
if (declarationNode != null && definedBean != null) {
|
||||
for (SpringBootApp app : runningApps) {
|
||||
List<LiveBean> relevantBeans = getRelevantAutowiredBeans(project, declarationNode, app, definedBean);
|
||||
return LiveHoverUtils.createCodeLensesForBeans(range, relevantBeans, BEANS_PREFIX, MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR);
|
||||
return LiveHoverUtils.createCodeLensesForBeans(range, relevantBeans, BEANS_PREFIX_PLAIN_TEXT, MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -155,7 +156,7 @@ public class AutowiredHoverProvider implements HoverProvider {
|
||||
List<LiveBean> autowiredBeans) {
|
||||
SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks(server);
|
||||
hover.append("**");
|
||||
hover.append(LiveHoverUtils.createBeansTitleMarkdown(sourceLinks, project, autowiredBeans, "← ", MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR));
|
||||
hover.append(LiveHoverUtils.createBeansTitleMarkdown(sourceLinks, project, autowiredBeans, BEANS_PREFIX_MARDOWN, MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR));
|
||||
hover.append("**\n");
|
||||
hover.append(autowiredBeans.stream()
|
||||
.map(b -> "- " + LiveHoverUtils.showBeanWithResource(server, b, " ", project))
|
||||
|
||||
@@ -43,7 +43,8 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class AbstractInjectedIntoHoverProvider implements HoverProvider {
|
||||
|
||||
private static final String BEANS_PREFIX = "\u21D2 ";
|
||||
public static final String BEANS_PREFIX_PLAIN_TEXT = "\u2192 ";
|
||||
public static final String BEANS_PREFIX_MARKDOWN = "→ ";
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(AbstractInjectedIntoHoverProvider.class);
|
||||
|
||||
@@ -109,14 +110,14 @@ public abstract class AbstractInjectedIntoHoverProvider implements HoverProvider
|
||||
ImmutableList.Builder<CodeLens> builder = ImmutableList.builder();
|
||||
if (!injectedBeans.isEmpty()) {
|
||||
// Break out of the loop. Just look for the first app with injected into beans
|
||||
List<CodeLens> injectedCodeLenses = LiveHoverUtils.createCodeLensesForBeans(range, injectedBeans, BEANS_PREFIX, MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR);
|
||||
List<CodeLens> injectedCodeLenses = LiveHoverUtils.createCodeLensesForBeans(range, injectedBeans, BEANS_PREFIX_PLAIN_TEXT, MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR);
|
||||
builder.addAll(injectedCodeLenses.isEmpty() ? ImmutableList.of(new CodeLens(range)) : injectedCodeLenses);
|
||||
}
|
||||
|
||||
// Wired beans code lenses
|
||||
List<LiveBean> wiredBeans = findWiredBeans(project, app, relevantBeans, astNode);
|
||||
builder.addAll(LiveHoverUtils.createCodeLensesForBeans(range, wiredBeans,
|
||||
AutowiredHoverProvider.BEANS_PREFIX, MAX_INLINE_BEANS_STRING_LENGTH,
|
||||
AutowiredHoverProvider.BEANS_PREFIX_PLAIN_TEXT, MAX_INLINE_BEANS_STRING_LENGTH,
|
||||
INLINE_BEANS_STRING_SEPARATOR));
|
||||
|
||||
return builder.build();
|
||||
@@ -150,7 +151,7 @@ public abstract class AbstractInjectedIntoHoverProvider implements HoverProvider
|
||||
if (!injectedBeans.isEmpty()) {
|
||||
SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks(server);
|
||||
hover.append("**");
|
||||
hover.append(LiveHoverUtils.createBeansTitleMarkdown(sourceLinks, project, injectedBeans, "→ ", MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR));
|
||||
hover.append(LiveHoverUtils.createBeansTitleMarkdown(sourceLinks, project, injectedBeans, BEANS_PREFIX_MARKDOWN, MAX_INLINE_BEANS_STRING_LENGTH, INLINE_BEANS_STRING_SEPARATOR));
|
||||
hover.append("**\n");
|
||||
hover.append(injectedBeans.stream()
|
||||
.map(b -> "- " + LiveHoverUtils.showBeanWithResource(server, b, " ", project))
|
||||
|
||||
@@ -183,7 +183,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Inject");
|
||||
editor.assertTrimmedHover("@Inject",
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA` \n" +
|
||||
" Resource: `" + Paths.get("com/example/DependencyA.class") + "`\n" +
|
||||
@@ -239,7 +239,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA` \n" +
|
||||
" Resource: `" + Paths.get("com/example/DependencyA.class") + "`\n" +
|
||||
@@ -391,11 +391,11 @@ public class AutowiredHoverProviderTest {
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, FOO_IMPL_CONTENTS);
|
||||
editor.assertHighlights("@Component", "@Autowired", "@Autowired");
|
||||
editor.assertHoverContains("@Autowired", 1,
|
||||
"**← `FooImplementation`**\n" +
|
||||
"**← `FooImplementation`**\n" +
|
||||
"- Bean: `superBean` \n" +
|
||||
" Type: `com.example.FooImplementation`");
|
||||
editor.assertHoverContains("@Autowired", 2,
|
||||
"**← `ThreadPoolTaskScheduler`**\n" +
|
||||
"**← `ThreadPoolTaskScheduler`**\n" +
|
||||
"- Bean: `scheduler` \n" +
|
||||
" Type: `org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler`");
|
||||
}
|
||||
@@ -445,12 +445,12 @@ public class AutowiredHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Controller", "@Autowired");
|
||||
editor.assertHoverContains("@Autowired",
|
||||
"**← `RestTemplate`**\n" +
|
||||
"**← `RestTemplate`**\n" +
|
||||
"- Bean: `restTemplate` \n" +
|
||||
" Type: `org.springframework.web.client.RestTemplate`"
|
||||
);
|
||||
editor.assertTrimmedHover("@Controller",
|
||||
"**← `RestTemplate`**\n" +
|
||||
"**← `RestTemplate`**\n" +
|
||||
"- Bean: `restTemplate` \n" +
|
||||
" Type: `org.springframework.web.client.RestTemplate`\n" +
|
||||
" \n" +
|
||||
@@ -507,7 +507,7 @@ public class AutowiredHoverProviderTest {
|
||||
editor.assertHighlights("@Component", "SomeComponent");
|
||||
|
||||
editor.assertTrimmedHover("SomeComponent", 2,
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
"- Bean: `dependencyB` \n" +
|
||||
@@ -668,7 +668,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← UNKNOWN**\n" +
|
||||
"**← UNKNOWN**\n" +
|
||||
"- (Cannot find precise information for the bean)\n" +
|
||||
" \n" +
|
||||
"Bean id: `someComponent` \n" +
|
||||
@@ -725,7 +725,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "SomeComponent");
|
||||
editor.assertTrimmedHover("SomeComponent", 2,
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
"- Bean: `dependencyB` \n" +
|
||||
@@ -780,7 +780,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
@@ -924,7 +924,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
@@ -978,7 +978,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
@@ -1125,7 +1125,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
@@ -1176,7 +1176,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
" \n" +
|
||||
@@ -1232,7 +1232,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
"- Bean: `dependencyB` \n" +
|
||||
@@ -1325,7 +1325,7 @@ public class AutowiredHoverProviderTest {
|
||||
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Autowired", 1,
|
||||
"**← `SomeComponent$1`**\n" +
|
||||
"**← `SomeComponent$1`**\n" +
|
||||
"- Bean: `anonymousBeanFactory` \n" +
|
||||
" Type: `com.example.SomeComponent$1`\n" +
|
||||
" \n" +
|
||||
|
||||
@@ -225,7 +225,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**→ `MyController`**\n" +
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `hello.MyController`\n" +
|
||||
" \n" +
|
||||
@@ -283,7 +283,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**→ `MyController`**\n" +
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `hello.MyController`\n" +
|
||||
" \n" +
|
||||
@@ -335,7 +335,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**→ `MyController`**\n" +
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `hello.MyController` \n" +
|
||||
" Resource: `" + Paths.get("hello/MyController.class") + "`\n" +
|
||||
@@ -387,7 +387,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**→ `MyController`**\n" +
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `hello.MyController` \n" +
|
||||
" Resource: `hello/MyController.class`\n" +
|
||||
@@ -443,7 +443,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `hello.MyController`\n" +
|
||||
"- Bean: `otherBean` \n" +
|
||||
@@ -552,7 +552,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyA`**\n" +
|
||||
"**← `DependencyA`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
" Type: `hello.DependencyA`\n" +
|
||||
" \n" +
|
||||
@@ -606,7 +606,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
" Type: `hello.DependencyA`\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
@@ -662,7 +662,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `depA` \n" +
|
||||
" Type: `hello.DependencyA`\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
@@ -713,7 +713,7 @@ public class BeanInjectedIntoHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Bean");
|
||||
editor.assertTrimmedHover("@Bean",
|
||||
"**← `DependencyB`**\n" +
|
||||
"**← `DependencyB`**\n" +
|
||||
"- Bean: `depB` \n" +
|
||||
" Type: `hello.DependencyB`\n" +
|
||||
" \n" +
|
||||
|
||||
@@ -134,7 +134,7 @@ public class BeansByTypeHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("ScannedRandomClass");
|
||||
editor.assertTrimmedHover("ScannedRandomClass",
|
||||
"**→ `randomOtherBeanType`**\n" +
|
||||
"**→ `randomOtherBeanType`**\n" +
|
||||
"- Bean: `randomOtherBean` \n" +
|
||||
" Type: `randomOtherBeanType`\n" +
|
||||
" \n" +
|
||||
@@ -188,7 +188,7 @@ public class BeansByTypeHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("ScannedFunctionClass");
|
||||
editor.assertTrimmedHover("ScannedFunctionClass",
|
||||
"**→ 1 bean**\n" +
|
||||
"**→ 1 bean**\n" +
|
||||
"- Bean: `org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration` \n" +
|
||||
" Type: `org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration`\n" +
|
||||
" \n" +
|
||||
|
||||
@@ -155,7 +155,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**→ `MyController`**\n" +
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `com.example.MyController`\n" +
|
||||
" \n" +
|
||||
@@ -208,7 +208,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `com.example.MyController`\n" +
|
||||
"- Bean: `otherBean` \n" +
|
||||
@@ -265,7 +265,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `com.example.MyController`\n" +
|
||||
"- Bean: `otherBean` \n" +
|
||||
@@ -274,7 +274,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=1001, name=`app-instance-1`]" +
|
||||
" \n \n" +
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"**→ `MyController` `OtherBean`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `com.example.MyController`\n" +
|
||||
"- Bean: `otherBean` \n" +
|
||||
@@ -334,7 +334,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component");
|
||||
editor.assertHoverExactText("@Component",
|
||||
"**→ `MyController`**\n" +
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `com.example.MyController`\n" +
|
||||
" \n" +
|
||||
@@ -392,7 +392,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**→ `OtherBean`**\n" +
|
||||
"**→ `OtherBean`**\n" +
|
||||
"- Bean: `otherBean` \n" +
|
||||
" Type: `com.example.OtherBean`\n" +
|
||||
" \n" +
|
||||
@@ -504,7 +504,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component", "AutowiredClass");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA` \n" +
|
||||
" Resource: `com/example/DependencyA.class`\n" +
|
||||
@@ -560,7 +560,7 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
);
|
||||
editor.assertHighlights("@Component", "@Autowired");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"**← `DependencyA` `DependencyB`**\n" +
|
||||
"- Bean: `dependencyA` \n" +
|
||||
" Type: `com.example.DependencyA`\n" +
|
||||
"- Bean: `dependencyB` \n" +
|
||||
|
||||
Reference in New Issue
Block a user