Skip to content

Commit

Permalink
Removed LambdaOutsideOfParensRule (due to f({ ... }) -/> `f { ... }…
Browse files Browse the repository at this point in the history
…` given f(cb, np = def))
  • Loading branch information
shyiko committed Oct 10, 2017
1 parent b7050fc commit 74114fa
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 241 deletions.
5 changes: 0 additions & 5 deletions ktlint-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
<artifactId>kotlin-compiler-embeddable</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package com.github.shyiko.ktlint.core

import net.sf.cglib.proxy.Enhancer
import net.sf.cglib.proxy.MethodInterceptor
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.mock.MockApplication
import org.jetbrains.kotlin.com.intellij.mock.MockProject
import org.jetbrains.kotlin.com.intellij.openapi.Disposable
import org.jetbrains.kotlin.com.intellij.openapi.application.ApplicationManager
import org.jetbrains.kotlin.com.intellij.openapi.extensions.ExtensionPoint
import org.jetbrains.kotlin.com.intellij.openapi.extensions.Extensions.getArea
import org.jetbrains.kotlin.com.intellij.openapi.fileTypes.FileType
import org.jetbrains.kotlin.com.intellij.openapi.project.Project
import org.jetbrains.kotlin.com.intellij.openapi.util.Key
import org.jetbrains.kotlin.com.intellij.openapi.util.UserDataHolderBase
import org.jetbrains.kotlin.com.intellij.pom.PomModel
Expand All @@ -25,8 +19,6 @@ import org.jetbrains.kotlin.com.intellij.psi.PsiElement
import org.jetbrains.kotlin.com.intellij.psi.PsiErrorElement
import org.jetbrains.kotlin.com.intellij.psi.PsiFileFactory
import org.jetbrains.kotlin.com.intellij.psi.PsiWhiteSpace
import org.jetbrains.kotlin.com.intellij.psi.codeStyle.CodeStyleManager
import org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.IndentHelper
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.TreeCopyHandler
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.idea.KotlinLanguage
Expand Down Expand Up @@ -78,25 +70,6 @@ object KtLint {
}
project as MockProject
project.registerService(PomModel::class.java, pomModel)
// required by KtPsiFactory.createExpressionByPattern used in LambdaOutsideOfParensRule
// cglib is used to guard against com.intellij.psi API (which isn't exactly stable) changes
project.registerService(CodeStyleManager::class.java,
Enhancer.create(CodeStyleManager::class.java, MethodInterceptor { _, method, args, _ ->
if (method.name.startsWith("reformat") &&
method.returnType == PsiElement::class.java &&
!args.isEmpty()) {
val firstArg = args[0]
if (firstArg is PsiElement) {
return@MethodInterceptor firstArg
}
}
null
}) as CodeStyleManager)
(ApplicationManager.getApplication() as MockApplication).registerService(IndentHelper::class.java,
object: IndentHelper() {
override fun getIndent(p0: Project?, p1: FileType?, p2: ASTNode?): Int = 0
override fun getIndent(p0: Project?, p1: FileType?, p2: ASTNode?, p3: Boolean): Int = 0
})
psiFileFactory = PsiFileFactory.getInstance(project)
}

Expand Down Expand Up @@ -402,8 +375,8 @@ object KtLint {
private val segments: List<Segment>

constructor(sortedArray: Array<Int>) {
require(sortedArray.size > 1, { "At least two data points are required" })
sortedArray.reduce({ r, v -> require(r <= v, { "Data points are not sorted (ASC)" }); v })
require(sortedArray.size > 1) { "At least two data points are required" }
sortedArray.reduce { r, v -> require(r <= v) { "Data points are not sorted (ASC)" }; v }
segments = sortedArray.take(sortedArray.size - 1)
.mapIndexed { i: Int, v: Int -> Segment(v, sortedArray[i + 1] - 1) }
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class StandardRuleSetProvider : RuleSetProvider {
FinalNewlineRule(),
ImportOrderingRule(),
IndentationRule(),
LambdaOutsideOfParensRule(),
MaxLineLengthRule(),
ModifierOrderRule(),
NoConsecutiveBlankLinesRule(),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.1.51</kotlin.version>
<cglib.version>3.2.5</cglib.version>
<aether.version>1.1.0</aether.version>
<aether.maven.provider.version>3.2.5</aether.maven.provider.version>
<args4j.version>2.33</args4j.version>
Expand Down

0 comments on commit 74114fa

Please sign in to comment.