File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
platform/forge/completion Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -104,25 +104,31 @@ object ModsTomlKeyCompletionProvider : CompletionProvider<CompletionParameters>(
104104 val existingKeys = table.entries.mapTo(HashSet ()) { it.key.text }
105105 schema.topLevelEntries(isArray).filter { it.key !in existingKeys }
106106 }
107+
107108 is TomlKeyValue -> when (table) {
108109 null -> {
109110 val existingKeys =
110111 key.containingFile.children.filterIsInstance<TomlKeyValue >().mapTo(HashSet ()) { it.key.text }
111112 schema.topLevelEntries.filter { it.key !in existingKeys }
112113 }
114+
113115 is TomlHeaderOwner -> {
114116 val tableName = table.header.key?.segments?.firstOrNull()?.text ? : return
115117 val existingKeys = table.entries.mapTo(HashSet ()) { it.key.text }
116118 schema.entriesForTable(tableName).filter { it.key !in existingKeys }
117119 }
120+
118121 else -> return
119122 }
123+
120124 else -> return
121125 }
122126
123- result.addAllElements(variants.map { entry ->
124- LookupElementBuilder .create(entry, entry.key).withInsertHandler(TomlKeyInsertionHandler (keyValue))
125- })
127+ result.addAllElements(
128+ variants.map { entry ->
129+ LookupElementBuilder .create(entry, entry.key).withInsertHandler(TomlKeyInsertionHandler (keyValue))
130+ }
131+ )
126132 }
127133}
128134
Original file line number Diff line number Diff line change 1+ /*
2+ * Minecraft Development for IntelliJ
3+ *
4+ * https://mcdev.io/
5+ *
6+ * Copyright (C) 2024 minecraft-dev
7+ *
8+ * This program is free software: you can redistribute it and/or modify
9+ * it under the terms of the GNU Lesser General Public License as published
10+ * by the Free Software Foundation, version 3.0 only.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public License
18+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19+ */
20+
121package com.demonwav.mcdev.toml.toml
222
323import com.intellij.codeInsight.AutoPopupController
@@ -17,7 +37,7 @@ class TomlKeyInsertionHandler(private val keyValue: TomlKeyValue) : InsertHandle
1737 context.document.insertString(context.tailOffset, " = " )
1838 PsiDocumentManager .getInstance(context.project).commitDocument(context.document)
1939 context.editor.caretModel.moveToOffset(context.tailOffset) // The tail offset is tracked automatically
20- AutoPopupController .getInstance(context.project).scheduleAutoPopup(context.editor);
40+ AutoPopupController .getInstance(context.project).scheduleAutoPopup(context.editor)
2141 }
2242 }
2343}
You can’t perform that action at this time.
0 commit comments