Skip to content

Commit 40d6b84

Browse files
committed
Add missing license and fix style
1 parent f3d3406 commit 40d6b84

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/main/kotlin/toml/platform/forge/completion/ModsTomlCompletionContributor.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff 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

src/main/kotlin/toml/toml/TomlKeyInsertionHandler.kt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
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+
121
package com.demonwav.mcdev.toml.toml
222

323
import 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
}

0 commit comments

Comments
 (0)