summaryrefslogtreecommitdiff
path: root/logcat
diff options
context:
space:
mode:
authorAlon Albert <aalbert@google.com>2022-07-13 07:53:42 -0700
committerTreeHugger Robot <treehugger-gerrit@google.com>2022-07-13 18:03:22 +0000
commit53e3f89e94099c0244b77136afc8ae7a37c75a0f (patch)
tree20fab0bf5df59272be6291c508b856791a07b8c0 /logcat
parenteec2ad5b85e2b3d53986fa3fb18dd80fb39dd86c (diff)
downloadidea-53e3f89e94099c0244b77136afc8ae7a37c75a0f.tar.gz
Add a Process Name Filter
As opposed to Package Name. `package:foo` -> Filter by package name (application id) `process:foo` -> Filter by process name (Linux process name) We will consider adding Process Name field to the Formatting options. b/238879077 Bug: 238877175 Bug: 238879077 Fixes: 238522110 Test: Updated Change-Id: I49960b153d3d5e265ad4f655c26b6840233b2a96
Diffstat (limited to 'logcat')
-rw-r--r--logcat/gen/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexer.java142
-rw-r--r--logcat/resources/messages/LogcatBundle.properties1
-rw-r--r--logcat/src/com/android/tools/idea/logcat/Constants.kt2
-rw-r--r--logcat/src/com/android/tools/idea/logcat/LogcatMainPanel.kt12
-rw-r--r--logcat/src/com/android/tools/idea/logcat/LogcatPresenter.kt2
-rw-r--r--logcat/src/com/android/tools/idea/logcat/ProcessNamesProvider.kt23
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/FilterTextField.kt2
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/LogcatFilter.kt10
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributor.kt14
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterParser.kt3
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilter.flex1
-rw-r--r--logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexerWrapper.kt1
-rw-r--r--logcat/testSrc/com/android/tools/idea/logcat/FakeLogcatPresenter.kt4
-rw-r--r--logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributorTest.kt3
-rw-r--r--logcat/testSrc/com/android/tools/idea/logcat/filters/parser/LogcatFilterPsiTest.kt2
15 files changed, 143 insertions, 79 deletions
diff --git a/logcat/gen/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexer.java b/logcat/gen/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexer.java
index ec65e4b4cf8..f98e1a86d12 100644
--- a/logcat/gen/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexer.java
+++ b/logcat/gen/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexer.java
@@ -110,8 +110,8 @@ class LogcatFilterLexer implements FlexLexer {
static final char ZZ_CMAP_A[] = zzUnpackCMap(
"\11\0\5\1\22\0\1\14\1\0\1\12\3\0\1\7\1\15\1\10\1\11\3\0\1\3\14\0\1\2\2\0\1"+
"\5\36\0\1\13\4\0\1\24\1\0\1\27\1\0\1\21\1\0\1\25\1\0\1\17\1\0\1\30\1\16\1"+
- "\22\1\20\1\0\1\26\2\0\1\23\1\31\1\0\1\32\5\0\1\6\1\0\1\4\6\0\1\1\32\0\1\1"+
- "\337\0\1\1\177\0\13\1\35\0\2\1\5\0\1\1\57\0\1\1\40\0");
+ "\22\1\20\1\32\1\26\1\0\1\31\1\23\1\33\1\0\1\34\5\0\1\6\1\0\1\4\6\0\1\1\32"+
+ "\0\1\1\337\0\1\1\177\0\13\1\35\0\2\1\5\0\1\1\57\0\1\1\40\0");
/**
* Translates DFA states to action switch labels.
@@ -121,12 +121,12 @@ class LogcatFilterLexer implements FlexLexer {
private static final String ZZ_ACTION_PACKED_0 =
"\4\0\1\1\1\2\1\1\1\3\1\4\1\5\1\6"+
"\2\7\7\1\1\10\3\7\1\11\2\7\1\12\2\1"+
- "\1\0\1\1\3\0\10\1\1\10\1\0\1\10\3\0"+
- "\1\11\1\0\1\11\3\0\4\1\1\13\3\1\2\10"+
- "\2\11\2\1\1\14\3\1\1\15";
+ "\1\0\1\1\3\0\11\1\1\10\1\0\1\10\3\0"+
+ "\1\11\1\0\1\11\3\0\4\1\1\13\4\1\2\10"+
+ "\2\11\3\1\1\14\4\1\1\15\1\1";
private static int [] zzUnpackAction() {
- int [] result = new int[74];
+ int [] result = new int[79];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -151,19 +151,19 @@ class LogcatFilterLexer implements FlexLexer {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
- "\0\0\0\33\0\66\0\121\0\154\0\207\0\242\0\154"+
- "\0\154\0\275\0\275\0\330\0\363\0\u010e\0\u0129\0\u0144"+
- "\0\u015f\0\u017a\0\u0195\0\u01b0\0\u01cb\0\275\0\u01e6\0\u0201"+
- "\0\u021c\0\u0237\0\u0252\0\u026d\0\u0288\0\u02a3\0\330\0\275"+
- "\0\u02be\0\363\0\u02d9\0\u02f4\0\u030f\0\u032a\0\u0345\0\u0360"+
- "\0\u037b\0\u0396\0\u03b1\0\u03cc\0\u01e6\0\275\0\u03e7\0\u0201"+
- "\0\u0402\0\u041d\0\u0237\0\275\0\u0438\0\u0252\0\u0453\0\330"+
- "\0\363\0\u046e\0\u0489\0\154\0\u04a4\0\u04bf\0\u04da\0\u01e6"+
- "\0\u0201\0\u0237\0\u0252\0\u04f5\0\u0510\0\154\0\u052b\0\u0546"+
- "\0\u0561\0\154";
+ "\0\0\0\35\0\72\0\127\0\164\0\221\0\256\0\164"+
+ "\0\164\0\313\0\313\0\350\0\u0105\0\u0122\0\u013f\0\u015c"+
+ "\0\u0179\0\u0196\0\u01b3\0\u01d0\0\u01ed\0\313\0\u020a\0\u0227"+
+ "\0\u0244\0\u0261\0\u027e\0\u029b\0\u02b8\0\u02d5\0\350\0\313"+
+ "\0\u02f2\0\u0105\0\u030f\0\u032c\0\u0349\0\u0366\0\u0383\0\u03a0"+
+ "\0\u03bd\0\u03da\0\u03f7\0\u0414\0\u0431\0\u020a\0\313\0\u044e"+
+ "\0\u0227\0\u046b\0\u0488\0\u0261\0\313\0\u04a5\0\u027e\0\u04c2"+
+ "\0\350\0\u0105\0\u04df\0\u04fc\0\164\0\u0519\0\u0536\0\u0553"+
+ "\0\u0570\0\u020a\0\u0227\0\u0261\0\u027e\0\u058d\0\u05aa\0\u05c7"+
+ "\0\164\0\u05e4\0\u0601\0\u061e\0\u063b\0\164\0\u0658";
private static int [] zzUnpackRowMap() {
- int [] result = new int[74];
+ int [] result = new int[79];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -188,59 +188,65 @@ class LogcatFilterLexer implements FlexLexer {
private static final String ZZ_TRANS_PACKED_0 =
"\1\5\1\6\1\5\1\7\2\5\1\10\1\11\1\12"+
"\1\13\1\14\1\5\1\6\1\15\1\16\1\17\1\20"+
- "\1\5\1\21\1\5\1\22\1\5\1\23\2\5\1\24"+
+ "\1\5\1\21\1\5\1\22\1\5\1\23\4\5\1\24"+
"\1\5\1\25\1\6\6\25\2\26\1\27\1\25\1\6"+
- "\1\30\15\25\1\31\1\6\6\31\2\26\1\32\1\31"+
- "\1\6\1\33\15\31\1\34\1\6\12\34\1\6\16\34"+
- "\1\5\1\0\6\5\2\0\1\5\1\35\1\0\16\5"+
- "\1\0\1\6\12\0\1\6\16\0\1\5\1\0\6\5"+
+ "\1\30\17\25\1\31\1\6\6\31\2\26\1\32\1\31"+
+ "\1\6\1\33\17\31\1\34\1\6\12\34\1\6\20\34"+
+ "\1\5\1\0\6\5\2\0\1\5\1\35\1\0\20\5"+
+ "\1\0\1\6\12\0\1\6\20\0\1\5\1\0\6\5"+
"\2\0\1\5\1\35\1\0\1\5\1\36\3\5\1\21"+
- "\3\5\1\23\2\5\1\24\1\5\33\0\12\37\1\40"+
- "\1\41\17\37\13\42\1\43\1\42\1\40\15\42\1\5"+
+ "\3\5\1\23\4\5\1\24\1\5\35\0\12\37\1\40"+
+ "\1\41\21\37\13\42\1\43\1\42\1\40\17\42\1\5"+
"\1\0\6\5\2\0\1\5\1\35\1\0\2\5\1\44"+
- "\1\5\1\45\12\5\1\0\6\5\2\0\1\5\1\35"+
- "\1\0\6\5\1\46\10\5\1\0\6\5\2\0\1\5"+
- "\1\35\1\0\7\5\1\47\7\5\1\0\6\5\2\0"+
- "\1\5\1\35\1\0\4\5\1\50\12\5\1\0\6\5"+
- "\2\0\1\5\1\35\1\0\10\5\1\51\6\5\1\0"+
- "\6\5\2\0\1\5\1\35\1\0\7\5\1\52\7\5"+
- "\1\0\6\5\2\0\1\5\1\35\1\0\7\5\1\53"+
- "\6\5\1\25\1\0\6\25\2\0\1\25\1\54\1\0"+
- "\16\25\12\55\1\56\1\57\17\55\13\60\1\61\1\60"+
- "\1\56\15\60\1\31\1\0\6\31\2\0\1\31\1\62"+
- "\1\0\16\31\12\63\1\64\1\65\17\63\13\66\1\67"+
- "\1\66\1\64\15\66\1\34\1\0\12\34\1\0\16\34"+
- "\1\5\1\0\6\5\2\0\1\5\1\35\20\5\1\0"+
- "\6\5\2\0\1\5\1\35\1\0\2\5\1\44\13\5"+
- "\12\37\1\70\1\41\17\37\13\42\1\43\1\42\1\71"+
- "\15\42\1\5\1\0\6\5\2\0\1\5\1\35\1\0"+
- "\3\5\1\72\13\5\1\0\6\5\2\0\1\5\1\35"+
- "\1\0\15\5\1\73\1\5\1\0\1\74\5\5\2\0"+
- "\1\5\1\35\1\0\17\5\1\0\6\5\2\0\1\5"+
- "\1\35\1\0\5\5\1\51\11\5\1\0\6\5\2\0"+
- "\1\5\1\35\1\0\6\5\1\75\10\5\1\0\6\5"+
- "\2\0\1\5\1\35\1\0\4\5\1\46\12\5\1\0"+
- "\6\5\2\0\1\5\1\35\1\0\12\5\1\76\4\5"+
- "\1\0\6\5\2\0\1\5\1\35\1\0\10\5\1\77"+
- "\5\5\1\25\1\0\6\25\2\0\1\25\1\54\17\25"+
- "\12\55\1\100\1\57\17\55\13\60\1\61\1\60\1\101"+
- "\15\60\1\31\1\0\6\31\2\0\1\31\1\62\17\31"+
- "\12\63\1\102\1\65\17\63\13\66\1\67\1\66\1\103"+
- "\15\66\1\5\1\0\6\5\2\0\1\5\1\35\1\0"+
- "\4\5\1\77\12\5\1\0\6\5\2\0\1\5\1\35"+
- "\1\0\4\5\1\104\12\5\1\0\6\5\2\0\1\5"+
- "\1\35\1\0\6\5\1\105\10\5\1\0\6\5\2\0"+
- "\1\5\1\35\1\0\13\5\1\105\3\5\1\0\1\106"+
- "\1\5\1\107\1\110\2\5\2\0\1\5\1\35\1\0"+
- "\17\5\1\0\6\5\2\0\1\5\1\35\1\0\1\5"+
- "\1\46\15\5\1\0\6\5\2\0\1\5\1\35\1\0"+
- "\7\5\1\111\7\5\1\0\1\112\5\5\2\0\1\5"+
- "\1\35\1\0\17\5\1\0\1\106\5\5\2\0\1\5"+
- "\1\35\1\0\17\5\1\0\6\5\2\0\1\5\1\35"+
- "\1\0\10\5\1\72\5\5";
+ "\1\5\1\45\14\5\1\0\6\5\2\0\1\5\1\35"+
+ "\1\0\6\5\1\46\12\5\1\0\6\5\2\0\1\5"+
+ "\1\35\1\0\7\5\1\47\11\5\1\0\6\5\2\0"+
+ "\1\5\1\35\1\0\4\5\1\50\14\5\1\0\6\5"+
+ "\2\0\1\5\1\35\1\0\10\5\1\51\10\5\1\0"+
+ "\6\5\2\0\1\5\1\35\1\0\7\5\1\52\4\5"+
+ "\1\53\4\5\1\0\6\5\2\0\1\5\1\35\1\0"+
+ "\7\5\1\54\10\5\1\25\1\0\6\25\2\0\1\25"+
+ "\1\55\1\0\20\25\12\56\1\57\1\60\21\56\13\61"+
+ "\1\62\1\61\1\57\17\61\1\31\1\0\6\31\2\0"+
+ "\1\31\1\63\1\0\20\31\12\64\1\65\1\66\21\64"+
+ "\13\67\1\70\1\67\1\65\17\67\1\34\1\0\12\34"+
+ "\1\0\20\34\1\5\1\0\6\5\2\0\1\5\1\35"+
+ "\22\5\1\0\6\5\2\0\1\5\1\35\1\0\2\5"+
+ "\1\44\15\5\12\37\1\71\1\41\21\37\13\42\1\43"+
+ "\1\42\1\72\17\42\1\5\1\0\6\5\2\0\1\5"+
+ "\1\35\1\0\3\5\1\73\15\5\1\0\6\5\2\0"+
+ "\1\5\1\35\1\0\17\5\1\74\1\5\1\0\1\75"+
+ "\5\5\2\0\1\5\1\35\1\0\21\5\1\0\6\5"+
+ "\2\0\1\5\1\35\1\0\5\5\1\51\13\5\1\0"+
+ "\6\5\2\0\1\5\1\35\1\0\6\5\1\76\12\5"+
+ "\1\0\6\5\2\0\1\5\1\35\1\0\4\5\1\46"+
+ "\14\5\1\0\6\5\2\0\1\5\1\35\1\0\12\5"+
+ "\1\77\6\5\1\0\6\5\2\0\1\5\1\35\1\0"+
+ "\15\5\1\100\3\5\1\0\6\5\2\0\1\5\1\35"+
+ "\1\0\10\5\1\101\7\5\1\25\1\0\6\25\2\0"+
+ "\1\25\1\55\21\25\12\56\1\102\1\60\21\56\13\61"+
+ "\1\62\1\61\1\103\17\61\1\31\1\0\6\31\2\0"+
+ "\1\31\1\63\21\31\12\64\1\104\1\66\21\64\13\67"+
+ "\1\70\1\67\1\105\17\67\1\5\1\0\6\5\2\0"+
+ "\1\5\1\35\1\0\4\5\1\101\14\5\1\0\6\5"+
+ "\2\0\1\5\1\35\1\0\4\5\1\106\14\5\1\0"+
+ "\6\5\2\0\1\5\1\35\1\0\6\5\1\107\12\5"+
+ "\1\0\6\5\2\0\1\5\1\35\1\0\13\5\1\107"+
+ "\5\5\1\0\6\5\2\0\1\5\1\35\1\0\12\5"+
+ "\1\110\6\5\1\0\1\111\1\5\1\112\1\113\2\5"+
+ "\2\0\1\5\1\35\1\0\21\5\1\0\6\5\2\0"+
+ "\1\5\1\35\1\0\1\5\1\46\17\5\1\0\6\5"+
+ "\2\0\1\5\1\35\1\0\7\5\1\114\11\5\1\0"+
+ "\6\5\2\0\1\5\1\35\1\0\4\5\1\115\14\5"+
+ "\1\0\1\116\5\5\2\0\1\5\1\35\1\0\21\5"+
+ "\1\0\1\111\5\5\2\0\1\5\1\35\1\0\21\5"+
+ "\1\0\6\5\2\0\1\5\1\35\1\0\10\5\1\73"+
+ "\10\5\1\0\6\5\2\0\1\5\1\35\1\0\6\5"+
+ "\1\117\12\5\1\0\6\5\2\0\1\5\1\35\1\0"+
+ "\6\5\1\101\11\5";
private static int [] zzUnpackTrans() {
- int [] result = new int[1404];
+ int [] result = new int[1653];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -279,11 +285,11 @@ class LogcatFilterLexer implements FlexLexer {
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\4\0\5\1\2\11\12\1\1\11\10\1\1\0\1\11"+
- "\3\0\11\1\1\0\1\11\3\0\1\1\1\0\1\11"+
- "\3\0\23\1";
+ "\3\0\12\1\1\0\1\11\3\0\1\1\1\0\1\11"+
+ "\3\0\27\1";
private static int [] zzUnpackAttribute() {
- int [] result = new int[74];
+ int [] result = new int[79];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
diff --git a/logcat/resources/messages/LogcatBundle.properties b/logcat/resources/messages/LogcatBundle.properties
index 62ef5cd58fc..660ec18eca9 100644
--- a/logcat/resources/messages/LogcatBundle.properties
+++ b/logcat/resources/messages/LogcatBundle.properties
@@ -100,6 +100,7 @@ logcat.filter.completion.hint.package.mine=Filter logs from current project pack
logcat.filter.completion.hint.name=Specify a name for this filter
logcat.filter.completion.hint.key.message=Log message
logcat.filter.completion.hint.key.package=Package name
+logcat.filter.completion.hint.key.process=Process name
logcat.filter.completion.hint.key.tag=Log tag
logcat.filter.completion.hint.key={0} contains string
logcat.filter.completion.hint.key.negated={0} does not contain string
diff --git a/logcat/src/com/android/tools/idea/logcat/Constants.kt b/logcat/src/com/android/tools/idea/logcat/Constants.kt
index 3710b8ab7cc..8d2ce8add06 100644
--- a/logcat/src/com/android/tools/idea/logcat/Constants.kt
+++ b/logcat/src/com/android/tools/idea/logcat/Constants.kt
@@ -28,5 +28,7 @@ internal val TAGS_PROVIDER_KEY = Key<TagsProvider>("TagProvider")
internal val PACKAGE_NAMES_PROVIDER_KEY = Key<PackageNamesProvider>("PackageNamesProvider")
+internal val PROCESS_NAMES_PROVIDER_KEY = Key<ProcessNamesProvider>("ProcessNamesProvider")
+
@JvmField
internal val SYSTEM_HEADER = LogcatHeader(LogLevel.INFO, 0, 0, "", "", "", Instant.EPOCH) \ No newline at end of file
diff --git a/logcat/src/com/android/tools/idea/logcat/LogcatMainPanel.kt b/logcat/src/com/android/tools/idea/logcat/LogcatMainPanel.kt
index 66535cbb8c1..58f989327c6 100644
--- a/logcat/src/com/android/tools/idea/logcat/LogcatMainPanel.kt
+++ b/logcat/src/com/android/tools/idea/logcat/LogcatMainPanel.kt
@@ -134,6 +134,7 @@ import kotlin.math.max
// This is probably a massive overkill as we do not expect this many tags/packages in a real Logcat
private const val MAX_TAGS = 1000
private const val MAX_PACKAGE_NAMES = 1000
+private const val MAX_PROCESS_NAMES = 1000
private val HAND_CURSOR = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
private val TEXT_CURSOR = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)
@@ -197,6 +198,7 @@ internal class LogcatMainPanel(
internal val messageBacklog = AtomicReference(MessageBacklog(logcatSettings.bufferSize))
private val tags = MostRecentlyAddedSet<String>(MAX_TAGS)
private val packages = MostRecentlyAddedSet<String>(MAX_PACKAGE_NAMES)
+ private val processNames = MostRecentlyAddedSet<String>(MAX_PROCESS_NAMES)
@VisibleForTesting
val headerPanel = LogcatHeaderPanel(
@@ -344,8 +346,12 @@ internal class LogcatMainPanel(
override suspend fun processMessages(messages: List<LogcatMessage>) {
messageBacklog.get().addAll(messages)
- tags.addAll(messages.map { it.header.tag })
- packages.addAll(messages.map { it.header.getAppName() })
+ messages.forEach {
+ val (_, _, _, applicationId, processName, tag, _) = it.header
+ tags.add(tag)
+ packages.add(applicationId)
+ processNames.add(processName)
+ }
if (!isLogcatPaused) {
// When paused, we don't send message to the document.
messageProcessor.appendMessages(messages)
@@ -424,6 +430,8 @@ internal class LogcatMainPanel(
override fun getPackageNames(): Set<String> = packages
+ override fun getProcessNames(): Set<String> = processNames
+
private fun createToolbarActions(project: Project): ActionGroup {
return SimpleActionGroup().apply {
add(ClearLogcatAction(this@LogcatMainPanel))
diff --git a/logcat/src/com/android/tools/idea/logcat/LogcatPresenter.kt b/logcat/src/com/android/tools/idea/logcat/LogcatPresenter.kt
index ece9706a807..ef3e791c380 100644
--- a/logcat/src/com/android/tools/idea/logcat/LogcatPresenter.kt
+++ b/logcat/src/com/android/tools/idea/logcat/LogcatPresenter.kt
@@ -28,7 +28,7 @@ import com.intellij.openapi.actionSystem.DataKey
/**
* Encapsulates the presentation of Logcat messages.
*/
-internal interface LogcatPresenter : TagsProvider, PackageNamesProvider, Disposable {
+internal interface LogcatPresenter : TagsProvider, PackageNamesProvider, ProcessNamesProvider, Disposable {
var formattingOptions: FormattingOptions
/**
diff --git a/logcat/src/com/android/tools/idea/logcat/ProcessNamesProvider.kt b/logcat/src/com/android/tools/idea/logcat/ProcessNamesProvider.kt
new file mode 100644
index 00000000000..e814a781ebe
--- /dev/null
+++ b/logcat/src/com/android/tools/idea/logcat/ProcessNamesProvider.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tools.idea.logcat
+
+/**
+ * Provides a set of process names.
+ */
+internal interface ProcessNamesProvider {
+ fun getProcessNames(): Set<String>
+}
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/FilterTextField.kt b/logcat/src/com/android/tools/idea/logcat/filters/FilterTextField.kt
index a37d8542162..3432ce18985 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/FilterTextField.kt
+++ b/logcat/src/com/android/tools/idea/logcat/filters/FilterTextField.kt
@@ -21,6 +21,7 @@ import com.android.tools.idea.concurrency.AndroidDispatchers.uiThread
import com.android.tools.idea.logcat.LogcatBundle
import com.android.tools.idea.logcat.LogcatPresenter
import com.android.tools.idea.logcat.PACKAGE_NAMES_PROVIDER_KEY
+import com.android.tools.idea.logcat.PROCESS_NAMES_PROVIDER_KEY
import com.android.tools.idea.logcat.TAGS_PROVIDER_KEY
import com.android.tools.idea.logcat.filters.FilterTextField.FilterHistoryItem.Item
import com.android.tools.idea.logcat.filters.FilterTextField.FilterHistoryItem.Separator
@@ -319,6 +320,7 @@ internal class FilterTextField(
return super.createEditor().apply {
putUserData(TAGS_PROVIDER_KEY, logcatPresenter)
putUserData(PACKAGE_NAMES_PROVIDER_KEY, logcatPresenter)
+ putUserData(PROCESS_NAMES_PROVIDER_KEY, logcatPresenter)
putUserData(AndroidProjectDetector.KEY, androidProjectDetector)
setBorder(EDITOR_BORDER)
}
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilter.kt b/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilter.kt
index 27b7f3d74db..23e5c0d6d47 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilter.kt
+++ b/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilter.kt
@@ -55,7 +55,7 @@ internal interface LogcatFilter {
fun matches(message: LogcatMessageWrapper): Boolean
- open fun getFilterName(): String? = null
+ fun getFilterName(): String? = null
companion object {
const val MY_PACKAGE = "package:mine"
@@ -91,7 +91,7 @@ internal enum class LogcatFilterField {
override fun getValue(message: LogcatMessageWrapper) = message.logcatMessage.header.tag
},
APP {
- override fun getValue(message: LogcatMessageWrapper) = message.logcatMessage.header.getAppName()
+ override fun getValue(message: LogcatMessageWrapper) = message.logcatMessage.header.applicationId
},
MESSAGE {
override fun getValue(message: LogcatMessageWrapper) = message.logcatMessage.message
@@ -101,7 +101,11 @@ internal enum class LogcatFilterField {
},
IMPLICIT_LINE {
override fun getValue(message: LogcatMessageWrapper) = message.logLine
- };
+ },
+ PROCESS {
+ override fun getValue(message: LogcatMessageWrapper) = message.logcatMessage.header.processName
+ },
+ ;
abstract fun getValue(message: LogcatMessageWrapper): String
}
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributor.kt b/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributor.kt
index bb180a8df31..348dce180d1 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributor.kt
+++ b/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributor.kt
@@ -18,6 +18,7 @@ package com.android.tools.idea.logcat.filters
import com.android.tools.idea.flags.StudioFlags
import com.android.tools.idea.logcat.LogcatBundle.message
import com.android.tools.idea.logcat.PACKAGE_NAMES_PROVIDER_KEY
+import com.android.tools.idea.logcat.PROCESS_NAMES_PROVIDER_KEY
import com.android.tools.idea.logcat.TAGS_PROVIDER_KEY
import com.android.tools.idea.logcat.filters.LogcatFilter.Companion.MY_PACKAGE
import com.android.tools.idea.logcat.filters.parser.LogcatFilterTypes
@@ -74,9 +75,10 @@ private class StringKey(name: String, hint: String) {
private val MESSAGE_KEY = StringKey("message", message("logcat.filter.completion.hint.key.message"))
private val PACKAGE_KEY = StringKey("package", message("logcat.filter.completion.hint.key.package"))
+private val PROCESS_KEY = StringKey("process", message("logcat.filter.completion.hint.key.process"))
private val TAG_KEY = StringKey("tag", message("logcat.filter.completion.hint.key.tag"))
-private val STRING_KEYS = listOf(MESSAGE_KEY, PACKAGE_KEY, TAG_KEY)
+private val STRING_KEYS = listOf(MESSAGE_KEY, PACKAGE_KEY, TAG_KEY, PROCESS_KEY)
private val BASE_KEY_LOOKUPS = listOf(
createLookupElement(LEVEL_KEY, message("logcat.filter.completion.hint.level")),
@@ -183,8 +185,8 @@ internal class LogcatFilterCompletionContributor : CompletionContributor() {
}
}
in PACKAGE_KEY.keys -> result.addAllElements((parameters.getPackageNames()).map { createLookupElement("$it ") })
- in TAG_KEY.keys ->
- result.addAllElements(parameters.getTags().filter(String::isNotBlank).map { createLookupElement("$it ") })
+ in PROCESS_KEY.keys -> result.addAllElements((parameters.getProcessNames()).map { createLookupElement("$it ") })
+ in TAG_KEY.keys -> result.addAllElements(parameters.getTags().map { createLookupElement("$it ") })
}
result.addHints()
}
@@ -216,11 +218,15 @@ private fun createLookupElement(text: String, hint: String? = null) = LookupElem
private fun CompletionParameters.findPreviousText() = PsiTreeUtil.skipWhitespacesBackward(position)?.text
private fun CompletionParameters.getTags() =
- editor.getUserData(TAGS_PROVIDER_KEY)?.getTags() ?: throw IllegalStateException("Missing PackageNamesProvider")
+ editor.getUserData(TAGS_PROVIDER_KEY)?.getTags()
+ ?.filter(String::isNotBlank) ?: throw IllegalStateException("Missing PackageNamesProvider")
private fun CompletionParameters.getPackageNames() =
editor.getUserData(PACKAGE_NAMES_PROVIDER_KEY)?.getPackageNames() ?: throw IllegalStateException("Missing PackageNamesProvider")
+private fun CompletionParameters.getProcessNames() =
+ editor.getUserData(PROCESS_NAMES_PROVIDER_KEY)?.getProcessNames() ?: throw IllegalStateException("Missing ProcessNamesProvider")
+
private fun CompletionParameters.getRealTextLength(): Int {
val text = position.text
val len = text.indexOf(DUMMY_IDENTIFIER_TRIMMED)
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterParser.kt b/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterParser.kt
index f0ea3fb802c..acef9d88634 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterParser.kt
+++ b/logcat/src/com/android/tools/idea/logcat/filters/LogcatFilterParser.kt
@@ -21,6 +21,7 @@ import com.android.tools.idea.logcat.filters.LogcatFilterField.APP
import com.android.tools.idea.logcat.filters.LogcatFilterField.IMPLICIT_LINE
import com.android.tools.idea.logcat.filters.LogcatFilterField.LINE
import com.android.tools.idea.logcat.filters.LogcatFilterField.MESSAGE
+import com.android.tools.idea.logcat.filters.LogcatFilterField.PROCESS
import com.android.tools.idea.logcat.filters.LogcatFilterField.TAG
import com.android.tools.idea.logcat.filters.LogcatFilterParser.CombineWith.AND
import com.android.tools.idea.logcat.filters.LogcatFilterParser.CombineWith.OR
@@ -217,6 +218,7 @@ internal class LogcatFilterParser(
MESSAGE -> messageTermsBuilder
LINE -> lineTermsBuilder
IMPLICIT_LINE -> return
+ PROCESS -> return // TODO(238877175): Add processTermsBuilder
}
updater(terms)
}
@@ -309,6 +311,7 @@ private fun LogcatFilterLiteralExpression.toKeyFilter(
when (key) {
"tag" -> TAG
"package" -> APP
+ "process" -> PROCESS
"message" -> MESSAGE
"line" -> LINE
else -> {
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilter.flex b/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilter.flex
index 9680fe25e25..ab9921da151 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilter.flex
+++ b/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilter.flex
@@ -86,6 +86,7 @@ TEXT_KEY
= "line"
| "message"
| "package"
+ | "process"
| "tag"
// Keys that accept unquoted, non-whitespace values
diff --git a/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexerWrapper.kt b/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexerWrapper.kt
index 19feafd97e6..9061d2e6931 100644
--- a/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexerWrapper.kt
+++ b/logcat/src/com/android/tools/idea/logcat/filters/parser/LogcatFilterLexerWrapper.kt
@@ -38,6 +38,7 @@ private val STRING_KEYS_REGEX = listOf(
"msg",
"name",
"package",
+ "process",
"tag",
).joinToString("|")
diff --git a/logcat/testSrc/com/android/tools/idea/logcat/FakeLogcatPresenter.kt b/logcat/testSrc/com/android/tools/idea/logcat/FakeLogcatPresenter.kt
index 8cf22d5d81e..1fb4ec12b77 100644
--- a/logcat/testSrc/com/android/tools/idea/logcat/FakeLogcatPresenter.kt
+++ b/logcat/testSrc/com/android/tools/idea/logcat/FakeLogcatPresenter.kt
@@ -90,6 +90,10 @@ internal class FakeLogcatPresenter : LogcatPresenter {
TODO("Not yet implemented")
}
+ override fun getProcessNames(): Set<String> {
+ TODO("Not yet implemented")
+ }
+
override fun selectDevice(serialNumber: String) {
TODO()
}
diff --git a/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributorTest.kt b/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributorTest.kt
index 1647478c4f5..be9f80048ef 100644
--- a/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributorTest.kt
+++ b/logcat/testSrc/com/android/tools/idea/logcat/filters/LogcatFilterCompletionContributorTest.kt
@@ -89,6 +89,7 @@ class LogcatFilterCompletionContributorTest {
"name:",
"package:",
"package:mine ",
+ "process:",
"tag:")
}
@@ -109,6 +110,7 @@ class LogcatFilterCompletionContributorTest {
"name:",
"package:",
"package:mine ",
+ "process:",
"tag:",
"favorite item",
"history item",
@@ -391,6 +393,7 @@ class LogcatFilterCompletionContributorTest {
"name:",
"package:",
"package:mine ",
+ "process:",
"tag:")
}
}
diff --git a/logcat/testSrc/com/android/tools/idea/logcat/filters/parser/LogcatFilterPsiTest.kt b/logcat/testSrc/com/android/tools/idea/logcat/filters/parser/LogcatFilterPsiTest.kt
index 9887c3e9775..22ed1cf434d 100644
--- a/logcat/testSrc/com/android/tools/idea/logcat/filters/parser/LogcatFilterPsiTest.kt
+++ b/logcat/testSrc/com/android/tools/idea/logcat/filters/parser/LogcatFilterPsiTest.kt
@@ -38,7 +38,7 @@ import org.junit.Rule
import org.junit.Test
import java.text.ParseException
-private val STRING_KEYS = listOf("tag", "package", "message", "line")
+private val STRING_KEYS = listOf("tag", "package", "process", "message", "line")
private val NON_STRING_KEYS = listOf("level", "age", "is", "name")
@RunsInEdt