Skip to content

Commit

Permalink
排序功能修复完成
Browse files Browse the repository at this point in the history
  • Loading branch information
dcsmf committed Jun 15, 2023
1 parent 22f8a5d commit ea01c3d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

## [Unreleased]

## [1.0.3] (2023/06/15)
- 修复函数排序不对的问题(Fix method sorting errors)

## [1.0.2] (2023/06/12)
- 版本号更规范(The version number is more prescriptive)
- 现在编译的语言版本由17改为11(Now change JVM language level from 17 to 11)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.dcsmf.intellijformatmethodsplugin
pluginName = FormatMethodPyramid
pluginRepositoryUrl = https://github.com/dcsmf/intellij-format-methods-plugin
# SemVer format -> https://semver.org
pluginVersion = 1.0.2
pluginVersion = 1.0.3

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 201
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ class FormatMethodWithPyramidAction : AnAction() {
}
val s1 = getJvmStyleSignature(o1)
val s2 = getJvmStyleSignature(o2)

// s1.length.compareTo(s2.length)
1
s1.length.compareTo(s2.length)
}.collect(Collectors.toList())
if (SortUtil.isSameAfterSort(methods, sortedMethods)) {
return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ import com.intellij.psi.PsiMethod
object MethodUtil {
/**
* 构建带权限标识符、返回类型、泛型声明、函数名、参数列表和throws的JVM风格函数定义
* default <T> void buildDefaultField(String userId, @NotNull Group group, T t) throws Exception {System.out.println(t);}
*
* 原始定义:
* default <T> void myMethod(String userId, @NotNull Group group, T t) throws Exception {}
*
* 返回的:
* default<T>voidmyMethod(String userId, @NotNull Group group, T t)throws Exception
*/
@JvmStatic
fun getJvmStyleSignature(method: PsiMethod): String {
if(method.isConstructor){
val returnTypeElement=method.returnTypeElement
val returnTypeElementText = when (method.returnTypeElement) {
null -> ""
else -> method.returnTypeElement!!.text
}
return with(method) {
modifierList.text
val typeParameterListText = when (method.typeParameterList) {
null -> ""
else -> method.typeParameterList!!.text

}
return method.modifierList.text + typeParameterListText + returnTypeElementText + method.name + method.parameterList.text + method.throwsList.text
}
}

0 comments on commit ea01c3d

Please sign in to comment.