mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[yaml] IDEA-210113 key completion insert handler: fix removing lookup if it is the only key value with colon
GitOrigin-RevId: 48c750e214e352a09b52921d2dbdafc695a608a9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f58eada7e2
commit
36a929c19d
+19
-12
@@ -125,19 +125,26 @@ public abstract class YamlKeyCompletionInsertHandler<T extends LookupElement> im
|
||||
}
|
||||
else if (children.length != 0 &&
|
||||
ContainerUtil.find(children, node -> node.getElementType() == YAMLElementTypes.KEY_VALUE_PAIR) == null) {
|
||||
String rootKey = "root";
|
||||
String valueText = parent.getText();
|
||||
YAMLFile file = YAMLElementGenerator.getInstance(parent.getProject())
|
||||
.createDummyYamlWithText(rootKey + ":\n " + valueText);
|
||||
YAMLValue value = file.getDocuments().get(0).getTopLevelValue();
|
||||
if (value instanceof YAMLMapping mapping) {
|
||||
YAMLKeyValue root = mapping.getKeyValueByKey(rootKey);
|
||||
if (root != null) {
|
||||
substitute = root.getValue();
|
||||
}
|
||||
List<ASTNode> notSpaces =
|
||||
ContainerUtil.filter(children, child -> !YAMLElementTypes.SPACE_ELEMENTS.contains(child.getElementType()));
|
||||
if (notSpaces.size() == 1) {
|
||||
substitute = notSpaces.get(0).getPsi();
|
||||
}
|
||||
if (substitute == null) {
|
||||
Logger.getInstance(YamlKeyCompletionInsertHandler.class).error("Could not substitute: " + valueText);
|
||||
else {
|
||||
String rootKey = "root";
|
||||
String valueText = parent.getText();
|
||||
YAMLFile file = YAMLElementGenerator.getInstance(parent.getProject())
|
||||
.createDummyYamlWithText(rootKey + ":\n " + valueText);
|
||||
YAMLValue value = file.getDocuments().get(0).getTopLevelValue();
|
||||
if (value instanceof YAMLMapping mapping) {
|
||||
YAMLKeyValue root = mapping.getKeyValueByKey(rootKey);
|
||||
if (root != null) {
|
||||
substitute = root.getValue();
|
||||
}
|
||||
}
|
||||
if (substitute == null) {
|
||||
Logger.getInstance(YamlKeyCompletionInsertHandler.class).error("Could not substitute: " + valueText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user