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

This commit is contained in:
Kris De Volder
2017-01-20 15:42:23 -08:00
4 changed files with 28 additions and 9 deletions

View File

@@ -65,6 +65,19 @@ public class ExceptionUtil {
return msg; return msg;
} }
/**
*
* @param e
* @return a nicer message suitable for display to the user
*/
public static String getMessageForUserDisplay(Throwable e) {
// The message of nested exception is usually more interesting than the
// one on top.
Throwable cause = getDeepestCause(e);
String msg = cause.getMessage();
return msg;
}
public static IllegalStateException notImplemented(String string) { public static IllegalStateException notImplemented(String string) {
return new IllegalStateException("Not implemented: " + string); return new IllegalStateException("Not implemented: " + string);
} }

View File

@@ -155,7 +155,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
values = typeUtil.getHintValues(type, getSchemaContext()); values = typeUtil.getHintValues(type, getSchemaContext());
} catch (Exception e) { } catch (Exception e) {
DocumentEdits edits = new DocumentEdits(doc.getDocument()); DocumentEdits edits = new DocumentEdits(doc.getDocument());
return ImmutableList.of(completionFactory().errorMessage(ExceptionUtil.getMessage(e), query, type, edits, typeUtil)); return ImmutableList.of(completionFactory().errorMessage(ExceptionUtil.getMessageForUserDisplay(e), query, type, edits, typeUtil));
} }
if (values!=null) { if (values!=null) {
ArrayList<ICompletionProposal> completions = new ArrayList<>(); ArrayList<ICompletionProposal> completions = new ArrayList<>();

View File

@@ -28,11 +28,12 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider {
@Override @Override
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception { public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
List<YValueHint> hints = new ArrayList<>();
for (CFTarget cfTarget : targets) { for (CFTarget cfTarget : targets) {
List<CFBuildpack> buildpacks = cfTarget.getBuildpacks(); List<CFBuildpack> buildpacks = cfTarget.getBuildpacks();
if (buildpacks != null) { if (buildpacks != null && !buildpacks.isEmpty()) {
List<YValueHint> hints = new ArrayList<>();
for (CFBuildpack buildpack : buildpacks) { for (CFBuildpack buildpack : buildpacks) {
String name = buildpack.getName(); String name = buildpack.getName();
String label = getBuildpackLabel(cfTarget, buildpack); String label = getBuildpackLabel(cfTarget, buildpack);
@@ -41,10 +42,12 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider {
hints.add(hint); hints.add(hint);
} }
} }
return hints;
} }
} }
// Return null if no hints an be resolved rather than empty list (seems to be
return hints; // what is expected for parsing for reconciler)
return null;
} }
protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) { protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) {

View File

@@ -28,11 +28,12 @@ public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider {
@Override @Override
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception { public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
List<YValueHint> hints = new ArrayList<>();
for (CFTarget cfTarget : targets) { for (CFTarget cfTarget : targets) {
List<CFServiceInstance> services = cfTarget.getServices(); List<CFServiceInstance> services = cfTarget.getServices();
if (services != null) { if (services != null && !services.isEmpty()) {
List<YValueHint> hints = new ArrayList<>();
for (CFServiceInstance service : services) { for (CFServiceInstance service : services) {
String name = service.getName(); String name = service.getName();
String label = getServiceLabel(cfTarget, service); String label = getServiceLabel(cfTarget, service);
@@ -41,10 +42,12 @@ public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider {
hints.add(hint); hints.add(hint);
} }
} }
return hints;
} }
} }
// Return null if no hints an be resolved rather than empty list (seems to be
return hints; // what is expected for parsing for reconciler)
return null;
} }
private String getServiceLabel(CFTarget cfClientTarget, CFServiceInstance service) { private String getServiceLabel(CFTarget cfClientTarget, CFServiceInstance service) {