PT 134914895 - Fix NPE in Yaml Hover if no info is provided
This commit is contained in:
@@ -82,12 +82,14 @@ public class YamlHoverInfoProvider implements HoverInfoProvider {
|
||||
}
|
||||
assistContext = assistPath.traverse(assistContext);
|
||||
if (assistContext != null) {
|
||||
if (path.pointsAtValue()) {
|
||||
Renderable info = assistContext.getValueHoverInfo(ymlDoc, new DocumentRegion(doc, region));
|
||||
Renderable info = path.pointsAtValue()
|
||||
? assistContext.getValueHoverInfo(ymlDoc, new DocumentRegion(doc, region))
|
||||
: assistContext.getHoverInfo();
|
||||
|
||||
// Fix for: PT 134914895. If assist context cannot provide an info, then don't return a Tuple.
|
||||
if (info != null) {
|
||||
return Tuples.of(info, region);
|
||||
}
|
||||
Renderable info = assistContext.getHoverInfo();
|
||||
return Tuples.of(info, region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,7 +408,6 @@ public class ManifestYamlEditorTest {
|
||||
" timeout: 80\n" +
|
||||
" health-check-type: none\n"
|
||||
);
|
||||
editor.assertNoHover("comment");
|
||||
|
||||
editor.assertIsHoverRegion("memory");
|
||||
editor.assertIsHoverRegion("inherit");
|
||||
@@ -454,6 +453,26 @@ public class ManifestYamlEditorTest {
|
||||
editor.assertHoverContains("timeout", "The `timeout` attribute defines the number of seconds Cloud Foundry allocates for starting your application");
|
||||
editor.assertHoverContains("health-check-type", "Use the `health-check-type` attribute to");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noHoverInfos() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"#comment\n" +
|
||||
"applications:\n" +
|
||||
"- buildpack: zbuildpack\n" +
|
||||
" name: foo\n" +
|
||||
" domains:\n" +
|
||||
" - pivotal.io\n" +
|
||||
" - otherdomain.org\n"
|
||||
|
||||
);
|
||||
editor.assertNoHover("comment");
|
||||
|
||||
// May fail in the future if hover support is added, but if hover support is added in the future,
|
||||
// it is expected that these should start to fail, as right now they have no hover
|
||||
editor.assertNoHover("pivotal.io");
|
||||
editor.assertNoHover("otherdomain.org");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Reference in New Issue
Block a user