mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[json + javascript] WEB-64406 Display number of array items in folded object nodes
GitOrigin-RevId: 336827ac995931adec2b0fdfc5e4eb2b0e36343c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4126bf118a
commit
3f890f8310
@@ -245,4 +245,5 @@ JsonJacksonReformatAction.command.name.json.reformat=JSON Reformat
|
||||
JsonJacksonReformatAction.dialog.title.json.reformatting=JSON Reformatting
|
||||
JsonJacksonReformatAction.dialog.message.this.action.not.undoable.do.you.want.to.reformat.document=This action cannot be reverted. Do you want to reformat the document?
|
||||
|
||||
folding.collapsed.array.text=[ {0} elements\u2026 ]
|
||||
folding.collapsed.array.one.element.text=[ {0} element\u2026 ]
|
||||
folding.collapsed.array.several.elements.text=[ {0} elements\u2026 ]
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.json.editor.folding;
|
||||
|
||||
import com.intellij.json.JsonBundle;
|
||||
import com.intellij.json.JsonElementTypes;
|
||||
import com.intellij.json.psi.*;
|
||||
import com.intellij.json.psi.impl.JsonCollectionPsiPresentationUtils;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.folding.FoldingBuilder;
|
||||
import com.intellij.lang.folding.FoldingDescriptor;
|
||||
@@ -77,11 +77,12 @@ public final class JsonFoldingBuilder implements FoldingBuilder, DumbAware {
|
||||
if (candidate != null) {
|
||||
return "{\"" + candidate.getName() + "\": " + candidate.getValue().getText() + "...}";
|
||||
}
|
||||
return "{...}";
|
||||
else {
|
||||
return JsonCollectionPsiPresentationUtils.getCollectionPsiPresentationText(properties.size());
|
||||
}
|
||||
}
|
||||
else if (type == JsonElementTypes.ARRAY && node.getPsi() instanceof JsonArray arrayNode) {
|
||||
int length = arrayNode.getValueList().size();
|
||||
return JsonBundle.message("folding.collapsed.array.text", length);
|
||||
return JsonCollectionPsiPresentationUtils.getCollectionPsiPresentationText(arrayNode);
|
||||
}
|
||||
else if (type == JsonElementTypes.LINE_COMMENT) {
|
||||
return "//...";
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
@file:JvmName("JsonCollectionPsiPresentationUtils")
|
||||
|
||||
package com.intellij.json.psi.impl
|
||||
|
||||
import com.intellij.json.JsonBundle
|
||||
import com.intellij.json.psi.JsonArray
|
||||
import org.jetbrains.annotations.Nls
|
||||
|
||||
internal fun getCollectionPsiPresentationText(array: JsonArray): @Nls String {
|
||||
val childrenCount = array.valueList.size
|
||||
return getCollectionPsiPresentationText(childrenCount)
|
||||
}
|
||||
|
||||
fun getCollectionPsiPresentationText(childrenCount: Int): @Nls String {
|
||||
return if (childrenCount % 10 == 1) {
|
||||
JsonBundle.message("folding.collapsed.array.one.element.text", childrenCount)
|
||||
}
|
||||
else {
|
||||
JsonBundle.message("folding.collapsed.array.several.elements.text", childrenCount)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
<fold text='{...}'>{
|
||||
<fold text='[ 1 element… ]'>{
|
||||
"value": {"id": 3}
|
||||
}</fold>
|
||||
Reference in New Issue
Block a user