Skip to content

Commit 873019f

Browse files
committed
Use color previews in completion everywhere
1 parent 1c9ad39 commit 873019f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/kotlin/com/gmail/blueboxware/libgdxplugin/filetypes/skin/editor/SkinCompletionContributor.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,13 @@ class SkinCompletionContributor : CompletionContributor() {
160160
(parameters.originalFile as? SkinFile)?.getClassSpecifications(classSpec.getRealClassNamesAsString())?.forEach { cs ->
161161
cs.getResourcesAsList(resource).forEach { res ->
162162
if (res.name != resource.name || cs != originalClassSpec) {
163-
doAdd(LookupElementBuilder.create(res.name.makeSafe()).withPresentableText(res.name.escape()), parameters, result)
163+
val icon = res
164+
.takeIf { cs.getRealClassNamesAsString().contains("com.badlogic.gdx.graphics.Color") }
165+
?.asColor(true)
166+
?.let { createColorIcon(it) }
167+
?: ICON_RESOURCE
168+
169+
doAdd(LookupElementBuilder.create(res.name.makeSafe()).withIcon(icon).withPresentableText(res.name.escape()), parameters, result)
164170
}
165171
}
166172
}
@@ -230,13 +236,11 @@ class SkinCompletionContributor : CompletionContributor() {
230236

231237
skinFile.getResources(elementClass, null, stringLiteral, isParentProperty, isParentProperty).forEach { resource ->
232238

233-
val icon = if (elementClassName == "com.badlogic.gdx.graphics.Color") {
234-
resource.asColor(true)?.let { createColorIcon(it) }
235-
} else {
236-
null
237-
}
239+
val icon =
240+
resource.takeIf { elementClassName == "com.badlogic.gdx.graphics.Color" }?.asColor(true)?.let { createColorIcon(it) }
241+
?: ICON_RESOURCE
238242

239-
doAdd(LookupElementBuilder.create(resource.name).withIcon(icon ?: ICON_RESOURCE), parameters, result)
243+
doAdd(LookupElementBuilder.create(resource.name).withIcon(icon), parameters, result)
240244

241245
}
242246

0 commit comments

Comments
 (0)