From e1ba4ebb495199d1723bd9c4a1f687a02207ee23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= Date: Thu, 2 May 2024 19:06:11 +0200 Subject: [PATCH] Make Compilation mode recognize non-legacy Kotlin/Gradle errors The Compilation mode recognizes Kotlin/Gradle errors but only in the now legacy format. The current format, which has been in wide use for about a year, is not supported. This change adds support for the current format. * etc/compilation.txt: (symbols): Add examples of non-legacy Kotlin/Gradle warnings and errors. * lisp/progmodes/compile.el: (compilation-error-regexp-alist-alist): Rename 'gradle-kotlin' to 'gradle-kotlin-legacy' and add 'grade-kotlin' that matches the errors and warnings outputted by the current (non-legacy) Kotlin/Gradle. (Bug#70797) * test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data): Rename 'gradle-kotlin' to 'gradle-kotlin-legacy' and add two test cases for the newly added, non-legacy Kotlin/Gradle warnings and errors. --- etc/compilation.txt | 13 +++++++++++-- lisp/progmodes/compile.el | 24 +++++++++++++++++++++--- test/lisp/progmodes/compile-tests.el | 20 ++++++++++++-------- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/etc/compilation.txt b/etc/compilation.txt index 05f0829864c..e4e361ecfc7 100644 --- a/etc/compilation.txt +++ b/etc/compilation.txt @@ -186,13 +186,22 @@ Warning near line 10 file arrayclash.f: Module contains no executable Nonportable usage near line 31 col 9 file assign.f: mixed default and explicit -* Gradle with kotlin-gradle-plugin +* Gradle with Kotlin plugin -symbol: gradle-kotlin +symbol: grade-kotlin + +e: file:///src/Test.kt:267:5 foo: bar +w: file:///src/Test.kt:267:5 foo: bar + + +* Gradle with Kotlin plugin (legacy) + +symbol: gradle-kotlin-legacy e: /src/Test.kt: (34, 15): foo: bar w: /src/Test.kt: (34, 15): foo: bar + * Gradle Android resource linking symbol: gradle-android diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index e31af774bd0..4d43a715fef 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -263,10 +263,28 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1)) "\\(^Warning .*\\)? line[ \n]\\([0-9]+\\)[ \n]\\(?:col \\([0-9]+\\)[ \n]\\)?file \\([^ :;\n]+\\)" 4 2 3 (1)) - ;; Gradle with kotlin-gradle-plugin (see - ;; GradleStyleMessagerRenderer.kt in kotlin sources, see - ;; https://youtrack.jetbrains.com/issue/KT-34683). + ;; Introduced in Kotlin 1.8 and current as of Kotlin 2.0. + ;; Emitted by `GradleStyleMessagerRenderer' in Kotlin sources. (gradle-kotlin + ,(rx bol + (| (group "w") ; 1: warning + (group (in "iv")) ; 2: info + "e") ; error + ": " + "file://" + (group ; 3: file + (? (in "A-Za-z") ":") + (+ (not (in "\n:")))) + ":" + (group (+ digit)) ; 4: line + ":" + (group (+ digit)) ; 5: column + " ") + 3 4 5 (1 . 2)) + + ;; Obsoleted in Kotlin 1.8 Beta, released on Nov 15, 2022. + ;; See commit `93a0cdbf973' in Kotlin Git repository. + (gradle-kotlin-legacy ,(rx bol (| (group "w") ; 1: warning (group (in "iv")) ; 2: info diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el index 20beed955d2..b1187426ccf 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el @@ -270,20 +270,24 @@ 1 nil 27041 "{standard input}") (gnu "boost/container/detail/flat_tree.hpp:589:25: [ skipping 5 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]" 1 25 589 "boost/container/detail/flat_tree.hpp" 0) - ;; gradle-kotlin + ;; Gradle/Kotlin (gradle-kotlin + "e: file:///src/Test.kt:267:5 foo: bar" 4 5 267 "/src/Test.kt" 2) + (gradle-kotlin + "w: file:///src/Test.kt:267:5 foo: bar" 4 5 267 "/src/Test.kt" 1) + (gradle-kotlin-legacy "e: /src/Test.kt: (34, 15): foo: bar" 4 15 34 "/src/Test.kt" 2) - (gradle-kotlin + (gradle-kotlin-legacy "w: /src/Test.kt: (11, 98): foo: bar" 4 98 11 "/src/Test.kt" 1) - (gradle-kotlin + (gradle-kotlin-legacy "e: e:/cygwin/src/Test.kt: (34, 15): foo: bar" 4 15 34 "e:/cygwin/src/Test.kt" 2) - (gradle-kotlin + (gradle-kotlin-legacy "w: e:/cygwin/src/Test.kt: (11, 98): foo: bar" 4 98 11 "e:/cygwin/src/Test.kt" 1) - (gradle-kotlin + (gradle-kotlin-legacy "e: e:\\src\\Test.kt: (34, 15): foo: bar" 4 15 34 "e:\\src\\Test.kt" 2) - (gradle-kotlin + (gradle-kotlin-legacy "w: e:\\src\\Test.kt: (11, 98): foo: bar" 4 98 11 "e:\\src\\Test.kt" 1) (gradle-android " ERROR:/Users/salutis/src/AndroidSchemeExperiment/app/build/intermediates/incremental/debug/mergeDebugResources/stripped.dir/layout/item.xml:3: AAPT: error: '16dpw' is incompatible with attribute padding (attr) dimension." @@ -534,8 +538,8 @@ The test data is in `compile-tests--test-regexps-data'." 1 15 5 "alpha.c"))) (compile--test-error-line test)) - (should (eq compilation-num-errors-found 106)) - (should (eq compilation-num-warnings-found 35)) + (should (eq compilation-num-errors-found 107)) + (should (eq compilation-num-warnings-found 36)) (should (eq compilation-num-infos-found 35))))) (ert-deftest compile-test-grep-regexps ()