Skip to content

Commit 959ca63

Browse files
committed
refactor: reformat all code
1 parent 25b6113 commit 959ca63

94 files changed

Lines changed: 598 additions & 589 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/kotlin/com/github/lppedd/cc/CCExtensions.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ internal fun Presentation.updateIcons(withIcon: Icon) {
7575
@Suppress("unused", "UseJBColor")
7676
internal fun Color.darker(factor: Double): Color =
7777
Color(
78-
max((red * factor).toInt(), 0),
79-
max((green * factor).toInt(), 0),
80-
max((blue * factor).toInt(), 0),
81-
alpha,
78+
max((red * factor).toInt(), 0),
79+
max((green * factor).toInt(), 0),
80+
max((blue * factor).toInt(), 0),
81+
alpha,
8282
)
8383

8484
@Suppress("ConvertTwoComparisonsToRangeCheck", "UseJBColor")
@@ -98,10 +98,10 @@ internal fun Color.brighter(factor: Double): Color {
9898
if (b > 0 && b < i) b = i
9999

100100
return Color(
101-
min((r / factor).toInt(), 255),
102-
min((g / factor).toInt(), 255),
103-
min((b / factor).toInt(), 255),
104-
alpha,
101+
min((r / factor).toInt(), 255),
102+
min((g / factor).toInt(), 255),
103+
min((b / factor).toInt(), 255),
104+
alpha,
105105
)
106106
}
107107

@@ -205,10 +205,10 @@ internal inline fun Editor.insertStringAtCaret(string: String, moveCaret: Boolea
205205
}
206206

207207
internal fun Editor.replaceString(
208-
startOffset: Int,
209-
endOffset: Int,
210-
newString: CharSequence,
211-
moveCaret: Boolean = true,
208+
startOffset: Int,
209+
endOffset: Int,
210+
newString: CharSequence,
211+
moveCaret: Boolean = true,
212212
) {
213213
document.replaceString(startOffset, endOffset, newString)
214214

@@ -306,9 +306,9 @@ internal fun String.abbreviate(max: Int, suffix: CharSequence = "..."): String {
306306
}
307307

308308
var end = minOf(
309-
lastIndexOf(' ', max - 3),
310-
lastIndexOf('\n', max - 3),
311-
lastIndexOf('\r', max - 3),
309+
lastIndexOf(' ', max - 3),
310+
lastIndexOf('\n', max - 3),
311+
lastIndexOf('\r', max - 3),
312312
)
313313

314314
if (end == -1) {
@@ -320,9 +320,9 @@ internal fun String.abbreviate(max: Int, suffix: CharSequence = "..."): String {
320320
do {
321321
end = newEnd
322322
newEnd = minOf(
323-
indexOf(' ', end + 1),
324-
indexOf('\n', end + 1),
325-
indexOf('\r', end + 1),
323+
indexOf(' ', end + 1),
324+
indexOf('\n', end + 1),
325+
indexOf('\r', end + 1),
326326
)
327327

328328
if (newEnd == -1) {

src/main/kotlin/com/github/lppedd/cc/annotation/Compatibility.kt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ package com.github.lppedd.cc.annotation
44
* @author Edoardo Luppi
55
*/
66
@Target(
7-
AnnotationTarget.CLASS,
8-
AnnotationTarget.FIELD,
9-
AnnotationTarget.FUNCTION,
10-
AnnotationTarget.EXPRESSION,
11-
AnnotationTarget.LOCAL_VARIABLE,
7+
AnnotationTarget.CLASS,
8+
AnnotationTarget.FIELD,
9+
AnnotationTarget.FUNCTION,
10+
AnnotationTarget.EXPRESSION,
11+
AnnotationTarget.LOCAL_VARIABLE,
1212
)
1313
@Retention(AnnotationRetention.SOURCE)
1414
internal annotation class Compatibility(
15-
/**
16-
* Whether the annotated element should be kept regardless of [minVersion].
17-
*/
18-
val keepForHistoricReasons: Boolean = false,
15+
/**
16+
* Whether the annotated element should be kept regardless of [minVersion].
17+
*/
18+
val keepForHistoricReasons: Boolean = false,
1919

20-
/**
21-
* The minimum supported IDE version that is required
22-
* for removing the annotated element.
23-
*/
24-
val minVersion: String = "?",
20+
/**
21+
* The minimum supported IDE version that is required
22+
* for removing the annotated element.
23+
*/
24+
val minVersion: String = "?",
2525

26-
/**
27-
* A brief explanation of why this behavior is needed
28-
* to maintain compatibility.
29-
*/
30-
val description: String = "",
26+
/**
27+
* A brief explanation of why this behavior is needed
28+
* to maintain compatibility.
29+
*/
30+
val description: String = "",
3131

32-
/**
33-
* A suggestion for replacing the annotated element
34-
* when it's time to remove it.
35-
*/
36-
val replaceWith: String = "",
32+
/**
33+
* A suggestion for replacing the annotated element
34+
* when it's time to remove it.
35+
*/
36+
val replaceWith: String = "",
3737
)

src/main/kotlin/com/github/lppedd/cc/api/CommitFooterValueProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public interface CommitFooterValueProvider : CommitTokenProvider {
1616
* @param subject A subject to optionally filter down footer values, or an empty string
1717
*/
1818
public fun getCommitFooterValues(
19-
footerType: String,
20-
type: String?,
21-
scope: String?,
22-
subject: String?,
19+
footerType: String,
20+
type: String?,
21+
scope: String?,
22+
subject: String?,
2323
): Collection<CommitFooterValue>
2424
}

src/main/kotlin/com/github/lppedd/cc/api/impl/InternalCommitTokenProvider.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ internal class InternalCommitTokenProvider(private val project: Project) :
5555
defaults.footerTypes.map { (key, value) -> DefaultCommitToken(key, value.description) }
5656

5757
override fun getCommitFooterValues(
58-
footerType: String,
59-
type: String?,
60-
scope: String?,
61-
subject: String?,
58+
footerType: String,
59+
type: String?,
60+
scope: String?,
61+
subject: String?,
6262
): Collection<CommitFooterValue> {
6363
if ("co-authored-by".equals(footerType, true)) {
6464
return tokensService.getCoAuthors()
@@ -98,9 +98,9 @@ internal class InternalCommitTokenProvider(private val project: Project) :
9898
}
9999

100100
private class DefaultCommitToken(
101-
private val text: String,
102-
private val description: String,
103-
private val isCoAuthor: Boolean = false,
101+
private val text: String,
102+
private val description: String,
103+
private val isCoAuthor: Boolean = false,
104104
) : CommitType,
105105
CommitScope,
106106
CommitFooterType,

src/main/kotlin/com/github/lppedd/cc/completion/ConventionalCommitLookupElementWeigher.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.intellij.codeInsight.lookup.LookupElementWeigher
1010
* @author Edoardo Luppi
1111
*/
1212
internal class ConventionalCommitLookupElementWeigher(
13-
private val configService: CCConfigService,
13+
private val configService: CCConfigService,
1414
) : LookupElementWeigher("commitLookupElementWeigher") {
1515
private companion object {
1616
private const val PRIORITY_SCOPE = 1
@@ -83,10 +83,10 @@ internal class ConventionalCommitLookupElementWeigher(
8383
}
8484

8585
private class CommitTokenWeight(
86-
private val tokenPriority: Int,
87-
private val isRecentlyUsed: Boolean,
88-
private val providerPriority: Int,
89-
private val index: Int,
86+
private val tokenPriority: Int,
87+
private val isRecentlyUsed: Boolean,
88+
private val providerPriority: Int,
89+
private val index: Int,
9090
) : Comparable<CommitTokenWeight> {
9191
companion object {
9292
private val comparator =

src/main/kotlin/com/github/lppedd/cc/completion/ConventionalCommitTextCompletionContributor.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ internal class ConventionalCommitTextCompletionContributor : CompletionContribut
112112
.caseInsensitive()
113113
.withPrefixMatcher(FlatPrefixMatcher(parameters.getCompletionPrefix()))
114114
.withRelevanceSorter(
115-
CompletionSorter.emptySorter()
116-
.weigh(PreferStartMatching())
117-
.weigh(ConventionalCommitLookupElementWeigher(project.service()))
115+
CompletionSorter.emptySorter()
116+
.weigh(PreferStartMatching())
117+
.weigh(ConventionalCommitLookupElementWeigher(project.service()))
118118
)
119119

120120
val editor = parameters.editor
@@ -225,8 +225,8 @@ internal class ConventionalCommitTextCompletionContributor : CompletionContribut
225225
}
226226

227227
private fun enhanceCompletionProcessIndicator(
228-
process: CompletionProcess,
229-
completionProviders: Collection<CompletionProvider<*>>,
228+
process: CompletionProcess,
229+
completionProviders: Collection<CompletionProvider<*>>,
230230
) {
231231
if (process !is CompletionProgressIndicator) {
232232
return

src/main/kotlin/com/github/lppedd/cc/completion/FilterPrefixMatcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import com.intellij.codeInsight.lookup.LookupElement
99
* @author Edoardo Luppi
1010
*/
1111
internal class FilterPrefixMatcher(
12-
private val delegate: PrefixMatcher,
13-
prefix: String? = null,
12+
private val delegate: PrefixMatcher,
13+
prefix: String? = null,
1414
) : PrefixMatcher(prefix ?: delegate.prefix) {
1515
override fun prefixMatches(element: LookupElement): Boolean =
1616
false

src/main/kotlin/com/github/lppedd/cc/completion/LookupEnhancer.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ import java.awt.event.KeyEvent
3636

3737
/**
3838
* Known issues:
39-
* - the menu retains focus after opening, see [IDEA-254427](https://youtrack.jetbrains.com/issue/IDEA-254427)
39+
* - The menu retains focus after opening, see [IDEA-254427](https://youtrack.jetbrains.com/issue/IDEA-254427)
4040
*
4141
* @author Edoardo Luppi
4242
*/
43-
internal class LookupEnhancer(
44-
private val lookup: LookupImpl,
45-
) : LookupListener, PrefixChangeListener, AnActionListener {
43+
internal class LookupEnhancer(private val lookup: LookupImpl) : LookupListener, PrefixChangeListener, AnActionListener {
4644
private companion object {
4745
private const val SHOW_GROUP_IN_POPUP = "actionSystem.toolbar.show.group.in.popup"
4846

49-
private val menuActionClass = Class.forName("com.intellij.codeInsight.lookup.impl.LookupUi\$MenuAction")
47+
private val menuActionClass = Class.forName($$"com.intellij.codeInsight.lookup.impl.LookupUi$MenuAction")
5048
private val logger = logger<LookupEnhancer>()
5149
private val robot = Robot()
5250
}
@@ -110,7 +108,7 @@ internal class LookupEnhancer(
110108
try {
111109
// After many thoughts and trial-and-errors, keeping the Action list
112110
// in memory and replacing each Action in the ActionGroup (the popup's menu)
113-
// each time the UI is refreshed, is the only way to have a decent and consistent behavior.
111+
// each time the UI is refreshed is the only way to have a decent and consistent behavior.
114112
// A positive side of this logic is that code is much simpler, and filters' state
115113
// (filtered or not filtered) is maintained for all the Lookup lifecycle without any effort
116114
val ui = getField<Any>(lookup.javaClass, lookup, null, "myUi") ?: return

src/main/kotlin/com/github/lppedd/cc/completion/menu/FilterAction.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import java.util.*
1717
* @author Edoardo Luppi
1818
*/
1919
internal class FilterAction(
20-
private val enhancer: LookupEnhancer,
21-
private val lookup: LookupImpl,
22-
private val provider: CommitTokenProvider,
20+
private val enhancer: LookupEnhancer,
21+
private val lookup: LookupImpl,
22+
private val provider: CommitTokenProvider,
2323
) : AnAction(provider.getPresentation().getName()) {
2424
private var isFiltered = false
2525
private var backupItems = emptyList<CommitTokenLookupElement>()

src/main/kotlin/com/github/lppedd/cc/completion/menu/SettingsActions.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import java.util.*
2323
* @author Edoardo Luppi
2424
*/
2525
internal class SettingsActions(
26-
private val enhancer: LookupEnhancer,
27-
private val lookup: LookupImpl,
26+
private val enhancer: LookupEnhancer,
27+
private val lookup: LookupImpl,
2828
) : ActionGroup("", false), DumbAware {
2929
private val config = lookup.project.service<CCConfigService>()
3030
private val actions = arrayOf(
31-
Separator.create(),
32-
CompletionModeChangeAction(),
33-
FilterModeChangeAction(),
34-
Separator.create(),
31+
Separator.create(),
32+
CompletionModeChangeAction(),
33+
FilterModeChangeAction(),
34+
Separator.create(),
3535
)
3636

3737
override fun getChildren(e: AnActionEvent?): Array<AnAction> =

0 commit comments

Comments
 (0)