mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-39447 JSON-schema based completion for js inserts unquoted string as a value
GitOrigin-RevId: 84259752f8a9d4a571cf15efc0eccd63c83958af
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d24fc03c13
commit
19aa77d8c0
@@ -393,7 +393,7 @@ public class JsonSchemaCompletionContributor extends CompletionContributor {
|
||||
@Nullable final String altText,
|
||||
@Nullable InsertHandler<LookupElement> handler) {
|
||||
String unquoted = StringUtil.unquoteString(key);
|
||||
LookupElementBuilder builder = LookupElementBuilder.create(!shouldWrapInQuotes(unquoted) ? unquoted : key);
|
||||
LookupElementBuilder builder = LookupElementBuilder.create(!shouldWrapInQuotes(unquoted, true) ? unquoted : key);
|
||||
if (altText != null) {
|
||||
builder = builder.withPresentableText(altText);
|
||||
}
|
||||
@@ -406,8 +406,11 @@ public class JsonSchemaCompletionContributor extends CompletionContributor {
|
||||
myVariants.add(builder);
|
||||
}
|
||||
|
||||
private boolean shouldWrapInQuotes(String key) {
|
||||
return myWrapInQuotes && myWalker != null && (myWalker.requiresNameQuotes() || !myWalker.isValidIdentifier(key, myProject));
|
||||
private boolean shouldWrapInQuotes(String key, boolean isValue) {
|
||||
return myWrapInQuotes && myWalker != null &&
|
||||
(isValue && myWalker.requiresValueQuotes()
|
||||
|| !isValue && myWalker.requiresNameQuotes()
|
||||
|| !myWalker.isValidIdentifier(key, myProject));
|
||||
}
|
||||
|
||||
private void addPropertyVariant(@NotNull String key,
|
||||
@@ -416,7 +419,7 @@ public class JsonSchemaCompletionContributor extends CompletionContributor {
|
||||
boolean insertComma) {
|
||||
final Collection<JsonSchemaObject> variants = new JsonSchemaResolver(myProject, jsonSchemaObject).resolve();
|
||||
jsonSchemaObject = ObjectUtils.coalesce(ContainerUtil.getFirstItem(variants), jsonSchemaObject);
|
||||
key = !shouldWrapInQuotes(key) ? key : StringUtil.wrapWithDoubleQuote(key);
|
||||
key = !shouldWrapInQuotes(key, false) ? key : StringUtil.wrapWithDoubleQuote(key);
|
||||
LookupElementBuilder builder = LookupElementBuilder.create(key);
|
||||
|
||||
final String typeText = JsonSchemaDocumentationProvider.getBestDocumentation(true, jsonSchemaObject);
|
||||
|
||||
Reference in New Issue
Block a user