Skip to content

Commit 95994e3

Browse files
committed
fix bugs
1 parent a2abbd8 commit 95994e3

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
}
1515

1616
group 'com.longforus'
17-
version '1.0'
17+
version '1.1'
1818

1919
apply plugin: 'kotlin'
2020

@@ -38,8 +38,9 @@ intellij {
3838
}
3939
patchPluginXml {
4040
changeNotes """
41-
First version release.<br>
42-
<em>add default order: fields->initializer->constructors->functions</em>"""
41+
Fix bugs that appear in the Code menu at the same time as LifecycleSorter.<br>
42+
Performance optimization.<br>
43+
<em>default order: fields->initializer->constructors->functions</em>"""
4344
}
4445

4546
publishPlugin {

src/main/java/com/longforus/kotlincodesorter/sort/Sorter.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ class Sorter
1919

2020
fun realSort(classOrObject: KtClassOrObject) {
2121
val declarations = classOrObject.declarations
22+
val before = declarations.hashCode()
2223
val sort = CommonSortStrategy(declarations).sort()
24+
val after = sort.hashCode()
2325
sort.forEach {
2426
if (it is KtClassOrObject) {
2527
realSort(it)
2628
}
2729
}
28-
sort.forEach {
29-
classOrObject.addDeclaration(it)
30-
}
31-
declarations.forEach {
32-
it.delete()
30+
if (before != after) {
31+
sort.forEach {
32+
classOrObject.addDeclaration(it)
33+
}
34+
declarations.forEach {
35+
it.delete()
36+
}
3337
}
3438
}
3539

src/main/resources/META-INF/plugin.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<p><b>Features:</b>
2222
<ul>
2323
<li>Sort the kotlin code in the order of fields -> initializer -> constructors -> functions.</li>
24+
<li>default shortcuts is <b>Ctrl+Alt+K</b>,if no effect, check the shortcut key Settings.</li>
2425
</ul>
2526
</p>
2627
<br/>
@@ -42,9 +43,9 @@
4243
</extensions>
4344

4445
<actions>
45-
<group id="sorter" text="Sort kotlin code" popup="true" description="Sort the kotlin code in order">
46+
<group id="com.longforus.kotlincodesorter" text="Sort kotlin code" popup="true" description="Sort the kotlin code in order">
4647

47-
<action class="com.longforus.kotlincodesorter.action.SortAction" id="sortStart" text="fields->initializer->constructors->functions"
48+
<action class="com.longforus.kotlincodesorter.action.SortAction" id="com.longforus.kotlincodesorter.action.SortAction" text="fields->initializer->constructors->functions"
4849
description="Sort the kotlin code in this order">
4950
<keyboard-shortcut first-keystroke="control alt K" keymap="$default"/>
5051
</action>

0 commit comments

Comments
 (0)