summaryrefslogtreecommitdiff
path: root/logcat
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2022-06-28 09:52:23 -0700
committerAlon Albert <aalbert@google.com>2022-07-01 13:46:20 +0000
commit7283aa37272ff3564fdbb4d7deb453ae5d86eb6f (patch)
tree7ea5f1d65731a234e4520b50cf351007fc50d284 /logcat
parentf5444898966e21c7eb8bfcbb7f0ca058367ae071 (diff)
downloadidea-7283aa37272ff3564fdbb4d7deb453ae5d86eb6f.tar.gz
Add a Few Escaped Chars
Single & double quotes, and the backslash itself. Bug: n/a Test: Added Change-Id: I1aa786b438b944bf0b5b5942e2e462eed3a27b87
Diffstat (limited to 'logcat')
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/parser/PsiExtensions.kt2
-rw-r--r--logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterParserTest.kt25
2 files changed, 26 insertions, 1 deletions
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/parser/PsiExtensions.kt b/logcat/src/com/android/tools/idea/logcat/filters/parser/PsiExtensions.kt
index 2c20004c0ee..dd750c819e9 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/parser/PsiExtensions.kt
+++ b/logcat/src/com/android/tools/idea/logcat/filters/parser/PsiExtensions.kt
@@ -22,7 +22,7 @@ import com.android.tools.idea.logcat.filters.parser.LogcatFilterTypes.VALUE
import com.intellij.psi.PsiElement
import com.intellij.psi.util.elementType
-private val ESCAPED_CHAR_REGEX = """\\([ :])""".toRegex()
+private val ESCAPED_CHAR_REGEX = """\\([ :'"\\])""".toRegex()
/**
* Extension functions for [PsiElement] classes.
diff --git a/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterParserTest.kt b/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterParserTest.kt
index b6c2d8ebdb6..c1a64614fe8 100644
--- a/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterParserTest.kt
+++ b/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterParserTest.kt
@@ -103,6 +103,31 @@ class LogcatFilterParserTest {
}
@Test
+ fun parse_stringKey_escapeChars() {
+ for ((key, field) in KEYS) {
+ val filter = logcatFilterParser().parse("""
+ $key:foo\ bar
+ $key:'foobar'
+ $key:\'foobar\'
+ $key:"foobar"
+ $key:\"foobar\"
+ $key:foo\\bar
+ """.trimIndent())
+
+ assertThat(filter).isEqualTo(
+ AndLogcatFilter(
+ StringFilter("foo bar", field),
+ StringFilter("foobar", field),
+ StringFilter("'foobar'", field),
+ StringFilter("foobar", field),
+ StringFilter(""""foobar"""", field),
+ StringFilter("""foo\bar""", field),
+ )
+ )
+ }
+ }
+
+ @Test
fun parse_negatedStringKey() {
for ((key, field) in KEYS) {
assertThat(logcatFilterParser().parse("-$key: Foo")).isEqualTo(NegatedStringFilter("Foo", field))