Skip to content

Commit

Permalink
修复了像@OverRide等注解对排序的影响
Browse files Browse the repository at this point in the history
  • Loading branch information
dcsmf committed Oct 10, 2023
1 parent 55f56d2 commit f292718
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# intellij-format-methods-plugin Changelog

## [1.0.7] (2023/10/10)
- Fixed the effect of the annotations like `@Override` on sorting
- 修复了像`@Override`等注解对排序的影响

## [1.0.6] (2023/09/28)
- Add plugin settings, now you can customize the sort by
- 新增插件设置,你可以自定义排序依据了
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.6
pluginVersion = 1.0.7

# 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 @@ -2,6 +2,7 @@ package com.github.dcsmf.plugin.formatmethods.utils

import com.github.dcsmf.plugin.formatmethods.settings.AppSettingsState
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiKeyword
import com.intellij.psi.PsiMethod

object MethodUtil {
Expand All @@ -27,7 +28,8 @@ object MethodUtil {

}
val modifier = checkTrueThenConcat(
method.modifierList.text,
method.modifierList.children.filterIsInstance<PsiKeyword>()
.joinToString("") { it.text }/* Remove the impact of the annotation like @Override */,
state.modifier
)
val typeParameter = checkTrueThenConcat(
Expand All @@ -50,6 +52,22 @@ object MethodUtil {
return modifier + typeParameter + returnType + methodName + throws
}

// @JvmStatic
// fun getJvmStyleSignature(method: PsiMethod, project: Project): String {
// val returnTypeElementText = when (method.returnTypeElement) {
// null -> ""
// else -> method.returnTypeElement!!.text
// }
// val typeParameterListText = when (method.typeParameterList) {
// null -> ""
// else -> method.typeParameterList!!.text
//
// }
// val s =
// method.modifierList.text + typeParameterListText + returnTypeElementText + method.name + method.parameterList.text + method.throwsList.text
// return s;
// }

private fun checkTrueThenConcat(str: String, state: Boolean): String {
if (state) {
return str
Expand Down

0 comments on commit f292718

Please sign in to comment.