From d33ab330f0e1cb90516087df97ce3e81f51e2477 Mon Sep 17 00:00:00 2001 From: Mikhail Pyltsin Date: Tue, 27 Aug 2024 12:02:40 +0200 Subject: [PATCH] IJ-CR-142510 [java-highlighting] IDEA-357310 highlight soft-keywords in compiled files - more tests GitOrigin-RevId: d10c07df9ca188e669972a182f1616e811c6aa9e --- .../java/decompiler/IdeaDecompilerTest.kt | 24 ++++++++++++++++++ .../testData/RecordHighlighting$A.class | Bin 0 -> 307 bytes .../testData/RecordHighlighting$B.class | Bin 0 -> 1256 bytes .../testData/RecordHighlighting$C.class | Bin 0 -> 1256 bytes .../plugin/testData/RecordHighlighting.class | Bin 0 -> 562 bytes .../plugin/testData/RecordHighlighting.java | 16 ++++++++++++ 6 files changed, 40 insertions(+) create mode 100644 plugins/java-decompiler/plugin/testData/RecordHighlighting$A.class create mode 100644 plugins/java-decompiler/plugin/testData/RecordHighlighting$B.class create mode 100644 plugins/java-decompiler/plugin/testData/RecordHighlighting$C.class create mode 100644 plugins/java-decompiler/plugin/testData/RecordHighlighting.class create mode 100644 plugins/java-decompiler/plugin/testData/RecordHighlighting.java diff --git a/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.kt b/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.kt index 66e75b0f2a19..378d90a80cc1 100644 --- a/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.kt +++ b/plugins/java-decompiler/plugin/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.kt @@ -126,7 +126,31 @@ class IdeaDecompilerTest : LightJavaCodeInsightFixtureTestCase() { myFixture.openFileInEditor(getTestFile("module-info.class")) IdentifierHighlighterPassFactory.doWithHighlightingEnabled(project, testRootDisposable, Runnable { val infos = myFixture.doHighlighting() + .filter { it.severity === HighlightInfoType.SYMBOL_TYPE_SEVERITY } assertEquals(5, infos.size) + val texts = infos.map { it.text }.toSet() + assertContainsElements(texts, + "module", + "requires", + "exports", + ) + }) + } + + fun testNameHighlightingInsideCompiledFileWithRecords() { + myFixture.setReadEditorMarkupModel(true) + val testFile = getTestFile("RecordHighlighting.class") + testFile.parent.children ; testFile.parent.refresh(false, true) // inner classes + myFixture.openFileInEditor(testFile) + IdentifierHighlighterPassFactory.doWithHighlightingEnabled(project, testRootDisposable, Runnable { + val infos = myFixture.doHighlighting() + .filter { it.severity === HighlightInfoType.SYMBOL_TYPE_SEVERITY } + val texts = infos.map { it.text }.toSet() + assertContainsElements(texts, + "sealed", + "record", + "permits", + ) }) } diff --git a/plugins/java-decompiler/plugin/testData/RecordHighlighting$A.class b/plugins/java-decompiler/plugin/testData/RecordHighlighting$A.class new file mode 100644 index 0000000000000000000000000000000000000000..ccb9e0bd778b35669494ba4fdff5272ed1ae1f71 GIT binary patch literal 307 zcmZusOA5kJ44nAsdusg)ifh+;hFTEasOSl54Yg8R=zH~WE9fw(dT*lEU5!g75CZ0lt&^ZU!V3q`FG}|1`99lwspA~t?i#TDz@Ygwg zTL^m1#x65s6>5auua3~)a(;=e<>S6Mgh^lw8wL0OJ#&TD|A|jQgo9QXOF$Xre9sShR9FI*t}jql=MDG2N76g`v8Y3hav4UAtkL)B84K+st@qwIHSa^>k0Ox692>l zeL~6uAHYW;u4B^}#i@9hxifdpId_?vU%$sc0W|O?gBaop5-O5NF)W|x=elO;c3=C* z4dL_{QoE*Y%C`*ha^*Nrth9;+WEj#?97@Nu`wZ1`$A`Df{=lLk$z5vJE1jvHkF9$O zs){9CBZYzP4)#QkGZg13v^~PIiX8Hk3;#0GEtjD-2Of&|p?ks&S+9Iju*$F+m7jt_ z^htvu;pdg@m^MEcoprf$q<1aKG~W@1ZXN56>Fon&LJmwys}S7=3Q~?}#iXTehP853 z+6+v1(WV^?Dq_eSijiaRccz!m`fO#}9*5d{z+KrAu2ir^O0zg>sPCkUZwet@>FC4v zTnme6A+KS4*5QJ4aXcx;e;uBmhQS?N1*X}RwNw#p9gx`UbSu8 z+?hynx>VMr(NOS$VQX6Z6}2dM#jtTTlv?i>jvcJfAEZ}6?>s?+{vqwwX{C{+J3zAf z1MGqpFo+>W3x0^k0N zp2J2!-=$zN;-ss!F|zac1s@ZHCp0#3hZK^yJBfD>_b0Z52NMfCB%2{bm6$6iQrSW0roB8IP^Ic}<*YC+s01dp#AcnYxgpMRq49iFSlp7Ye2gXOy zlTM!@wQJg@dd(0oR}S;UO6yoah9RxwzH&@^z)&rBe0a+o3@sXp+@)r{(wXV`*t(~n z>sZ7RDGa$gY|6f1D9%%8dxT{jIpir9@ny^{m!UQX9*Xy&dn9_QUiqY9m0>k1KMjTG zlLkY=&nw$8ZLv2#=?dq7cP+{^-;q6T9dgI?_JK2@h9;#|h;9P~DMz$o+R`?|S~)6h z1}42|vknFoF=Y1T*y)LPrkBt9#mcrl4z+hrxT+;xrD2PdF5;-6zLPHgjg-n&4j;W2 zYAE||8Wjd)Q>bO|01q{6>oBmxusKV}8QaP{5r&^wKxA0x{?%eQ3)g1ar}9`BKCs2@ zz9rmJN6O>zs2-{_cqt)IKs@+55^sgubIg&FPMFfPxa)=;fyU>HBH`%&Jkay@>TTN= z&Qwy+rLrcChK6ShTeI3PsYSyJhKg>|lldAiV;5=Ls704{5hfD}yZE0g}}p zU}v<5;VRAEF|dRp&AJc3HC(4%jy~oM@_6J&WIdc#oj?P=({dhNJEt$=W(55T@a@0o zIcx;PP$r~AUls=@G(JnLSqxRNFj;a(|C7qcWO(xH?_chvKc~DiMfI@RS9Cp VXdqS3C#f`^;yGTT_y_yOA>;r6 literal 0 HcmV?d00001 diff --git a/plugins/java-decompiler/plugin/testData/RecordHighlighting.class b/plugins/java-decompiler/plugin/testData/RecordHighlighting.class new file mode 100644 index 0000000000000000000000000000000000000000..0cfe51abb14d8a67d7be5355d090351ca39e24aa GIT binary patch literal 562 zcmZuu%Sr=55UkE?^3rG$^YVq@AyF_N5D}6EQCK4w$;H!TGi)Yoc42qpe|Zu-_yK;D z*b@cCWT3mKuIip<=Hv729Y7z)c_fe&NEMMrhOjf2&$8=D-|gN{=E{i)nM>{K_==Eh zcg6x)Lis^CK{&n9?#$zeweJ#ARxnkBlC6C;TrMUme3TQ9D`h)yq&JqKHvFfUif1|^ zRPFUqJ)X6Y+9%Z7PxkLVqd4S?dYv)rGIY7SvOy-~N5L|5)U`I3*VpG?n306SP(|^b zGK)q6HQr_2dTI$YHY)>x)@G$oDBk+M3N24Yk>Wkc;uvuBaRR{)ZcYMZo}6=zS(lL* z(`T=smzA97Y-Dg0I2XSSj9bid*hYyfruls3Vc-A8^q)rlTkNtii8AK|DyTAMneU;F WCia=NR!rak4Xz0sGBz2HGTAS8_HsS| literal 0 HcmV?d00001 diff --git a/plugins/java-decompiler/plugin/testData/RecordHighlighting.java b/plugins/java-decompiler/plugin/testData/RecordHighlighting.java new file mode 100644 index 000000000000..21df8f8d4b64 --- /dev/null +++ b/plugins/java-decompiler/plugin/testData/RecordHighlighting.java @@ -0,0 +1,16 @@ +public class RecordHighlighting { + + public static void main(String[] args) { + + } + + sealed interface A { + + } + + record B() implements A { + } + + record C() implements A { + } +} \ No newline at end of file