From 9cf3510e79292ea7b27f66a227eeb3e246191947 Mon Sep 17 00:00:00 2001 From: "Irina.Chernushina" Date: Thu, 29 Mar 2018 15:55:14 +0200 Subject: [PATCH] fix tests sorry (part of json schema based completion: complete array and object literals - WEB-20119) --- .../jsonSchema/impl/JsonSchemaCompletionContributor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java index 15de49114de5..99eb603c1f01 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaCompletionContributor.java @@ -238,7 +238,7 @@ public class JsonSchemaCompletionContributor extends CompletionContributor { builder = builder.withTypeText(StringUtil.removeHtmlTags(typeText), true); } - if (variants.size() <= 1) { + if (hasSameType(variants)) { final JsonSchemaType type = jsonSchemaObject.getType(); final List values = jsonSchemaObject.getEnum(); if (type != null || !ContainerUtil.isEmpty(values) || jsonSchemaObject.getDefault() != null) { @@ -251,6 +251,10 @@ public class JsonSchemaCompletionContributor extends CompletionContributor { myVariants.add(builder); } + private static boolean hasSameType(@NotNull Collection variants) { + return variants.stream().map(JsonSchemaObject::getType).filter(Objects::nonNull).distinct().count() <= 1; + } + private static InsertHandler createArrayOrObjectLiteralInsertHandler() { return new InsertHandler() { @Override