code cleanup: rest of small modules under 'idea'

This commit is contained in:
Dmitry Jemerov
2015-07-20 19:08:52 +02:00
parent 9142d48e81
commit c718b6f9a3
9 changed files with 25 additions and 37 deletions
@@ -16,49 +16,41 @@
package org.jetbrains.kotlin.idea.completion
import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.completion.CompletionParameters
import com.intellij.codeInsight.completion.CompletionResultSet
import com.intellij.codeInsight.completion.CompletionUtil
import com.intellij.codeInsight.completion.PrefixMatcher
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.patterns.ElementPattern
import com.intellij.patterns.PatternCondition
import com.intellij.patterns.StandardPatterns
import com.intellij.psi.PsiCompiledElement
import com.intellij.psi.PsiElement
import com.intellij.psi.impl.source.tree.LeafPsiElement
import com.intellij.psi.search.DelegatingGlobalSearchScope
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.ProcessingContext
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper
import org.jetbrains.kotlin.idea.completion.smart.LambdaItems
import org.jetbrains.kotlin.idea.completion.smart.SmartCompletion
import org.jetbrains.kotlin.idea.core.*
import org.jetbrains.kotlin.idea.references.JetSimpleNameReference
import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper
import org.jetbrains.kotlin.idea.core.comparePossiblyOverridingDescriptors
import org.jetbrains.kotlin.idea.core.getResolutionScope
import org.jetbrains.kotlin.idea.core.isVisible
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.util.CallType
import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptorKindExclude
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils
import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import kotlin.properties.Delegates
class CompletionSessionConfiguration(
val completeNonImportedDeclarations: Boolean,
@@ -210,7 +202,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
protected abstract val descriptorKindFilter: DescriptorKindFilter?
protected val referenceVariants: Collection<DeclarationDescriptor> by Delegates.lazy {
protected val referenceVariants: Collection<DeclarationDescriptor> by lazy {
if (descriptorKindFilter != null) {
referenceVariantsHelper.getReferenceVariants(
nameExpression!!,
@@ -90,7 +90,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
var parent = tokenAt.getParent()
if (parent is JetExpression && parent !is JetBlockExpression) {
// search expression to be replaced - go up while we are the first child of parent expression
var expression = parent as JetExpression
var expression: JetExpression = parent
parent = expression.getParent()
while (parent is JetExpression && parent.getFirstChild() == expression) {
expression = parent
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.types.JetType
enum class CaretPosition {
IN_BRACKETS
IN_BRACKETS,
AFTER_BRACKETS
}
@@ -49,7 +49,7 @@ import org.jetbrains.kotlin.types.typeUtil.makeNullable
import java.util.ArrayList
import java.util.HashSet
trait InheritanceItemsSearcher {
interface InheritanceItemsSearcher {
fun search(nameFilter: (String) -> Boolean, consumer: (LookupElement) -> Unit)
}
@@ -22,12 +22,10 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.decompiler.navigation.JetSourceNavigationHelper
import org.jetbrains.kotlin.psi.JetExpression
import org.jetbrains.kotlin.psi.JetParameter
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.idea.core.copied
import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getParameterForArgument
@@ -130,7 +128,7 @@ public object OptionalParametersHelper {
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, parameter)?.getNavigationElement() as? JetParameter
val expression = declaration?.getDefaultValue() ?: return null
val allParameters = (parameter.getContainingDeclaration() as CallableDescriptor).getValueParameters().toSet()
val allParameters = parameter.getContainingDeclaration().getValueParameters().toSet()
val parameterUsages = HashMap<ValueParameterDescriptor, MutableCollection<JetExpression>>()
@@ -152,7 +152,7 @@ public abstract class OverrideImplementMethodsHandler : LanguageCodeInsightActio
val elementsToCompact = ArrayList<JetElement>()
for (element in generateOverridingMembers(selectedElements, classOrObject)) {
val added = body!!.addAfter(element, afterAnchor)
val added = body.addAfter(element, afterAnchor)
if (firstGenerated == null) {
firstGenerated = added
@@ -27,10 +27,10 @@ public class FirstChildInParentFilter(val level: Int = 1) : PositionElementFilte
var parent: PsiElement? = element
for (i in 1..level) {
if (parent == null) break
parent = parent?.getContext()
parent = parent.getContext()
}
return (parent != null) && PsiTreeUtil.isAncestor(parent?.getFirstChild(), element, true)
return (parent != null) && PsiTreeUtil.isAncestor(parent.getFirstChild(), element, true)
}
@@ -86,10 +86,9 @@ public fun unInvalidateBuiltins(project: Project, runnable: RunnableWithExceptio
// Base tearDown() invalidates builtins. Restore them with brute force.
for (source in builtInsSources) {
val psiFileImpl = source as PsiFileImpl
val field = javaClass<PsiFileImpl>().getDeclaredField("myInvalidated")!!
field.setAccessible(true)
field.set(psiFileImpl, false)
field.set(source, false)
}
}
@@ -25,7 +25,6 @@ import java.io.File
import java.lang.reflect.Constructor
import java.util.HashMap
import java.util.regex.Pattern
import kotlin.properties.Delegates
import kotlin.reflect.jvm.java
import java.lang.reflect.Array as RArray
@@ -82,14 +81,14 @@ private fun String.amendNextLinesIfNeeded(reader: OutputLineReader): String {
var nextLine = reader.readLine()
val builder = StringBuilder(this)
while (nextLine != null && nextLine!!.isNextMessage().not()) {
while (nextLine != null && nextLine.isNextMessage().not()) {
builder.append("\n").append(nextLine)
if (!reader.hasNextLine()) break
nextLine = reader.readLine()
}
if (nextLine != null) reader.pushBack(nextLine!!)
if (nextLine != null) reader.pushBack(nextLine)
return builder.toString()
}
@@ -148,7 +147,7 @@ object KotlinOutputParserHelper {
loadSeverityEnums()
}
private val simpleMessageConstructor: Constructor<*> by Delegates.lazy {
private val simpleMessageConstructor: Constructor<*> by lazy {
if (!isNewAndroidPlugin) {
val messageClass = Class.forName("$packagePrefix.GradleMessage")
val messageKindClass = Class.forName("$packagePrefix.GradleMessage\$Kind")
@@ -165,7 +164,7 @@ object KotlinOutputParserHelper {
}
}
private val complexMessageConstructor: Constructor<*> by Delegates.lazy {
private val complexMessageConstructor: Constructor<*> by lazy {
if (!isNewAndroidPlugin) {
val messageClass = Class.forName("$packagePrefix.GradleMessage")
val messageKindClass = Class.forName("$packagePrefix.GradleMessage\$Kind")
@@ -187,20 +186,20 @@ object KotlinOutputParserHelper {
}
}
private val sourceFilePositionConstructor: Constructor<*> by Delegates.lazy {
private val sourceFilePositionConstructor: Constructor<*> by lazy {
assert(isNewAndroidPlugin) { "This property should be used only for New Android Plugin" }
val sourcePositionClass = Class.forName("$packagePrefix.SourcePosition")
val sourceFilePositionClass = Class.forName("$packagePrefix.SourceFilePosition")
sourceFilePositionClass.getConstructor(File::class.java, sourcePositionClass)
}
private val sourcePositionConstructor: Constructor<*> by Delegates.lazy {
private val sourcePositionConstructor: Constructor<*> by lazy {
assert(isNewAndroidPlugin) { "This property should be used only for New Android Plugin" }
val sourcePositionClass = Class.forName("$packagePrefix.SourcePosition")
sourcePositionClass.getConstructor(Int::class.java, Int::class.java, Int::class.java)
}
private val sourcePositionVarargArg: Any by Delegates.lazy {
private val sourcePositionVarargArg: Any by lazy {
assert(isNewAndroidPlugin) { "This property should be used only for New Android Plugin" }
val sourceFilePositionClass = Class.forName("$packagePrefix.SourceFilePosition")
RArray.newInstance(sourceFilePositionClass, 0)