mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 15:56:48 +08:00
Fixed: Values not suggested for attributes with format 'color'
This commit is contained in:
+5
@@ -19,6 +19,7 @@ package com.itsaky.androidide.lsp.xml.providers.completion.layout
|
||||
|
||||
import com.android.aapt.Resources.Attribute.FormatFlags
|
||||
import com.android.aapt.Resources.Attribute.FormatFlags.BOOLEAN
|
||||
import com.android.aapt.Resources.Attribute.FormatFlags.COLOR
|
||||
import com.android.aapt.Resources.Attribute.FormatFlags.DIMENSION
|
||||
import com.android.aapt.Resources.Attribute.FormatFlags.ENUM
|
||||
import com.android.aapt.Resources.Attribute.FormatFlags.FLAGS
|
||||
@@ -107,6 +108,10 @@ class LayoutAttributeValueCompletionProvider : LayoutCompletionProvider() {
|
||||
if (entry.hasType(INTEGER)) {
|
||||
addValues("android", type = AaptResourceType.INTEGER, prefix = prefix, result = list)
|
||||
}
|
||||
|
||||
if (entry.hasType(COLOR)) {
|
||||
addValues("android", type = AaptResourceType.COLOR, prefix = prefix, result = list)
|
||||
}
|
||||
|
||||
if (entry.hasType(BOOLEAN)) {
|
||||
addValues("android", type = AaptResourceType.BOOL, prefix = prefix, result = list)
|
||||
|
||||
+26
-2
@@ -17,6 +17,14 @@
|
||||
|
||||
package com.itsaky.androidide.lsp.xml.providers.completion
|
||||
|
||||
import com.android.aaptcompiler.AaptResourceType
|
||||
import com.android.aaptcompiler.AaptResourceType.ANIM
|
||||
import com.android.aaptcompiler.AaptResourceType.BOOL
|
||||
import com.android.aaptcompiler.AaptResourceType.DIMEN
|
||||
import com.android.aaptcompiler.AaptResourceType.INTEGER
|
||||
import com.android.aaptcompiler.AaptResourceType.LAYOUT
|
||||
import com.android.aaptcompiler.AaptResourceType.MENU
|
||||
import com.android.aaptcompiler.AaptResourceType.STRING
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.itsaky.androidide.lsp.xml.CompletionHelper
|
||||
import com.itsaky.androidide.lsp.xml.CompletionHelperImpl
|
||||
@@ -42,10 +50,26 @@ class AttributeValueCompletionTest : CompletionHelper by CompletionHelperImpl()
|
||||
|
||||
val (isIncomplete, items) = complete()
|
||||
|
||||
assertThat(isIncomplete).isFalse()
|
||||
assertThat(isIncomplete).isTrue()
|
||||
assertThat(items).isNotEmpty()
|
||||
|
||||
// Check if all the expected color values are present
|
||||
assertThat(items)
|
||||
.containsAtLeast(
|
||||
"@android:color/Blue_700",
|
||||
"@android:color/Blue_800",
|
||||
"@android:color/Teal_700",
|
||||
"@android:color/background_dark",
|
||||
"@android:color/background_light",
|
||||
"@android:color/black",
|
||||
"@android:color/Red_700",
|
||||
"@android:color/Purple_700"
|
||||
)
|
||||
|
||||
assertThat(items).containsAtLeast("@android:color/transparent", "@android:attr/transition")
|
||||
// Check that we do not have any other type of values
|
||||
for (type in setOf(STRING, INTEGER, BOOL, DIMEN, INTEGER, MENU)) {
|
||||
assertThat(items.firstOrNull { it.contains(type.tagName) }).isNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -23,7 +23,7 @@
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:textColor="tran@@cursor@@"
|
||||
android:textColor="@@cursor@@"
|
||||
android:padding="4dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
Reference in New Issue
Block a user