mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
kotlin speedup: specify return type for public/protected APIs
This commit is contained in:
@@ -68,7 +68,7 @@ abstract class DefaultJreSelector {
|
||||
|
||||
|
||||
class ProjectSdkSelector(val project: Project): DefaultJreSelector() {
|
||||
override fun getNameAndDescription() = Pair.create(ProjectRootManager.getInstance(project).projectSdkName, "project SDK")
|
||||
override fun getNameAndDescription(): Pair<String?, String> = Pair.create(ProjectRootManager.getInstance(project).projectSdkName, "project SDK")
|
||||
}
|
||||
|
||||
open class SdkFromModuleDependencies<T: ComboBox<*>>(val moduleComboBox: T, val getSelectedModule: (T) -> Module?, val productionOnly: () -> Boolean): DefaultJreSelector() {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class ConvertProjectLibraryToRepositoryLibraryAction(private val librariesConfig
|
||||
context: StructureConfigurableContext)
|
||||
: ConvertToRepositoryLibraryActionBase(context) {
|
||||
|
||||
override fun getSelectedLibrary() = (librariesConfigurable.selectedElement as? LibraryProjectStructureElement)?.library as? LibraryEx
|
||||
override fun getSelectedLibrary(): LibraryEx? = (librariesConfigurable.selectedElement as? LibraryProjectStructureElement)?.library as? LibraryEx
|
||||
|
||||
override fun replaceLibrary(library: Library, configureNewLibrary: (LibraryEditorBase) -> Unit) {
|
||||
val name = library.name
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ abstract class ConvertToRepositoryLibraryActionBase(protected val context: Struc
|
||||
"Convert to Repository Library...",
|
||||
"Convert a regular library to a repository library which additionally stores its Maven coordinates, so the IDE can automatically download the library JARs if they are missing",
|
||||
null) {
|
||||
protected val project = context.project
|
||||
protected val project: Project = context.project
|
||||
|
||||
protected abstract fun getSelectedLibrary(): LibraryEx?
|
||||
|
||||
@@ -298,7 +298,7 @@ private class ComparingJarFilesTask(project: Project, private val downloadedFile
|
||||
val len2 = input2.read(buffer2)
|
||||
if (len1 != len2) return false
|
||||
if (len1 <= 0) break
|
||||
for (i in 0..len1 - 1) {
|
||||
for (i in 0 until len1) {
|
||||
if (buffer1[i] != buffer2[i]) return false
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class LibraryJarsDiffDialog(libraryFile: VirtualFile,
|
||||
private val libraryName: String,
|
||||
project: Project) : DialogWrapper(project) {
|
||||
companion object {
|
||||
val CHANGE_COORDINATES_CODE = 2;
|
||||
val CHANGE_COORDINATES_CODE: Int = 2
|
||||
}
|
||||
|
||||
private val panel: DiffRequestPanel
|
||||
|
||||
+2
-2
@@ -20,5 +20,5 @@ sealed class AnnotationAttributeValueRequest {
|
||||
|
||||
data class AnnotationAttributeRequest(val name: String, val value: AnnotationAttributeValueRequest)
|
||||
|
||||
fun stringAttribute(name: String, value: String) = AnnotationAttributeRequest(name, AnnotationAttributeValueRequest.StringValue(value))
|
||||
fun intAttribute(name: String, value: Int) = AnnotationAttributeRequest(name, AnnotationAttributeValueRequest.PrimitiveValue(value))
|
||||
fun stringAttribute(name: String, value: String): AnnotationAttributeRequest = AnnotationAttributeRequest(name, AnnotationAttributeValueRequest.StringValue(value))
|
||||
fun intAttribute(name: String, value: Int): AnnotationAttributeRequest = AnnotationAttributeRequest(name, AnnotationAttributeValueRequest.PrimitiveValue(value))
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.intellij.openapi.util.registry.Registry
|
||||
|
||||
fun useInterlaguageActions(): Boolean = ApplicationManager.getApplication().isUnitTestMode || Registry.`is`("ide.interlanguage.fixes")
|
||||
|
||||
val EP_NAME = ExtensionPointName.create<JvmElementActionsFactory>("com.intellij.lang.jvm.actions.jvmElementActionsFactory")
|
||||
val EP_NAME: ExtensionPointName<JvmElementActionsFactory> = ExtensionPointName.create<JvmElementActionsFactory>("com.intellij.lang.jvm.actions.jvmElementActionsFactory")
|
||||
|
||||
private inline fun createActions(crossinline actions: (JvmElementActionsFactory) -> List<IntentionAction>): List<IntentionAction> {
|
||||
return EP_NAME.extensions.flatMap {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.lang.jvm.actions
|
||||
|
||||
fun annotationRequest(fqn: String, vararg parameters: AnnotationAttributeRequest) = object : AnnotationRequest {
|
||||
fun annotationRequest(fqn: String, vararg parameters: AnnotationAttributeRequest): AnnotationRequest = object : AnnotationRequest {
|
||||
override fun getQualifiedName(): String = fqn
|
||||
|
||||
override fun getAttributes(): List<AnnotationAttributeRequest> = parameters.asList()
|
||||
|
||||
@@ -9,5 +9,5 @@ import com.intellij.util.xmlb.annotations.Attribute
|
||||
|
||||
class LanguageLevelState : BaseState() {
|
||||
@get:Attribute("LANGUAGE_LEVEL")
|
||||
var languageLevel by property<LanguageLevel?>()
|
||||
var languageLevel: LanguageLevel? by property<LanguageLevel?>()
|
||||
}
|
||||
+6
-6
@@ -9,19 +9,19 @@ import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PsiUtil
|
||||
|
||||
abstract class AddModuleDirectiveFix(module: PsiJavaModule) : LocalQuickFixAndIntentionActionOnPsiElement(module) {
|
||||
override fun getFamilyName() = QuickFixBundle.message("module.info.add.directive.family.name")
|
||||
override fun getFamilyName(): String = QuickFixBundle.message("module.info.add.directive.family.name")
|
||||
|
||||
override fun isAvailable(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement) =
|
||||
override fun isAvailable(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement): Boolean =
|
||||
startElement is PsiJavaModule && PsiUtil.isLanguageLevel9OrHigher(file) && startElement.getManager().isInProject(startElement)
|
||||
|
||||
override fun invoke(project: Project, file: PsiFile, editor: Editor?, startElement: PsiElement, endElement: PsiElement) =
|
||||
override fun invoke(project: Project, file: PsiFile, editor: Editor?, startElement: PsiElement, endElement: PsiElement): Unit =
|
||||
invoke(project, file, editor, startElement as PsiJavaModule)
|
||||
|
||||
protected abstract fun invoke(project: Project, file: PsiFile, editor: Editor?, module: PsiJavaModule)
|
||||
}
|
||||
|
||||
class AddRequiresDirectiveFix(module: PsiJavaModule, private val requiredName: String) : AddModuleDirectiveFix(module) {
|
||||
override fun getText() = QuickFixBundle.message("module.info.add.requires.name", requiredName)
|
||||
override fun getText(): String = QuickFixBundle.message("module.info.add.requires.name", requiredName)
|
||||
|
||||
override fun invoke(project: Project, file: PsiFile, editor: Editor?, module: PsiJavaModule) {
|
||||
if (module.requires.find { requiredName == it.moduleName } == null) {
|
||||
@@ -33,7 +33,7 @@ class AddRequiresDirectiveFix(module: PsiJavaModule, private val requiredName: S
|
||||
class AddExportsDirectiveFix(module: PsiJavaModule,
|
||||
private val packageName: String,
|
||||
private val targetName: String) : AddModuleDirectiveFix(module) {
|
||||
override fun getText() = QuickFixBundle.message("module.info.add.exports.name", packageName)
|
||||
override fun getText(): String = QuickFixBundle.message("module.info.add.exports.name", packageName)
|
||||
|
||||
override fun invoke(project: Project, file: PsiFile, editor: Editor?, module: PsiJavaModule) {
|
||||
val existing = module.exports.find { packageName == it.packageName }
|
||||
@@ -50,7 +50,7 @@ class AddExportsDirectiveFix(module: PsiJavaModule,
|
||||
}
|
||||
|
||||
class AddUsesDirectiveFix(module: PsiJavaModule, private val svcName: String) : AddModuleDirectiveFix(module) {
|
||||
override fun getText() = QuickFixBundle.message("module.info.add.uses.name", svcName)
|
||||
override fun getText(): String = QuickFixBundle.message("module.info.add.uses.name", svcName)
|
||||
|
||||
override fun invoke(project: Project, file: PsiFile, editor: Editor?, module: PsiJavaModule) {
|
||||
if (module.uses.find { svcName == it.classReference?.qualifiedName } == null) {
|
||||
|
||||
+10
-10
@@ -33,8 +33,8 @@ import kotlin.collections.ArrayList
|
||||
class DfaControlTransferValue(factory: DfaValueFactory,
|
||||
val target: TransferTarget,
|
||||
val traps: FList<Trap>) : DfaValue(factory) {
|
||||
fun dispatch(state: DfaMemoryState, runner: DataFlowRunner) = ControlTransferHandler(state, runner, this).dispatch()
|
||||
override fun toString() = target.toString() + (if (traps.isEmpty()) "" else " $traps")
|
||||
fun dispatch(state: DfaMemoryState, runner: DataFlowRunner): List<DfaInstructionState> = ControlTransferHandler(state, runner, this).dispatch()
|
||||
override fun toString(): String = target.toString() + (if (traps.isEmpty()) "" else " $traps")
|
||||
}
|
||||
|
||||
interface TransferTarget {
|
||||
@@ -44,7 +44,7 @@ interface TransferTarget {
|
||||
fun dispatch(state: DfaMemoryState, runner: DataFlowRunner) : List<DfaInstructionState> = emptyList()
|
||||
}
|
||||
data class ExceptionTransfer(val throwable: DfaPsiType?) : TransferTarget {
|
||||
override fun toString() = "Exception($throwable)"
|
||||
override fun toString(): String = "Exception($throwable)"
|
||||
}
|
||||
data class InstructionTransfer(val offset: ControlFlow.ControlFlowOffset, private val toFlush: List<DfaVariableValue>) : TransferTarget {
|
||||
override fun dispatch(state: DfaMemoryState, runner: DataFlowRunner): List<DfaInstructionState> {
|
||||
@@ -52,18 +52,18 @@ data class InstructionTransfer(val offset: ControlFlow.ControlFlowOffset, privat
|
||||
return listOf(DfaInstructionState(runner.getInstruction(offset.instructionOffset), state))
|
||||
}
|
||||
|
||||
override fun getPossibleTargets() = listOf(offset.instructionOffset)
|
||||
override fun toString() = "-> $offset" + (if (toFlush.isEmpty()) "" else "; flushing $toFlush")
|
||||
override fun getPossibleTargets(): List<Int> = listOf(offset.instructionOffset)
|
||||
override fun toString(): String = "-> $offset" + (if (toFlush.isEmpty()) "" else "; flushing $toFlush")
|
||||
}
|
||||
data class ExitFinallyTransfer(private val enterFinally: Trap.EnterFinally) : TransferTarget {
|
||||
override fun getPossibleTargets() = enterFinally.backLinks.asIterable().flatMap { it.getPossibleTargetIndices() }
|
||||
override fun getPossibleTargets(): Set<Int> = enterFinally.backLinks.asIterable().flatMap { it.getPossibleTargetIndices() }
|
||||
.filter { index -> index != enterFinally.jumpOffset.instructionOffset }.toSet()
|
||||
|
||||
override fun dispatch(state: DfaMemoryState, runner: DataFlowRunner): List<DfaInstructionState> {
|
||||
return (state.pop() as DfaControlTransferValue).dispatch(state, runner)
|
||||
}
|
||||
|
||||
override fun toString() = "ExitFinally"
|
||||
override fun toString(): String = "ExitFinally"
|
||||
}
|
||||
object ReturnTransfer : TransferTarget {
|
||||
override fun toString(): String = "Return"
|
||||
@@ -74,7 +74,7 @@ sealed class Trap(val anchor: PsiElement) {
|
||||
|
||||
internal abstract fun dispatch(handler: ControlTransferHandler): List<DfaInstructionState>
|
||||
internal open fun getPossibleTargets(): Collection<Int> = emptyList()
|
||||
override fun toString() = javaClass.simpleName!!
|
||||
override fun toString(): String = javaClass.simpleName!!
|
||||
|
||||
class TryCatch(tryStatement: PsiTryStatement, val clauses: LinkedHashMap<PsiCatchSection, ControlFlow.ControlFlowOffset>)
|
||||
: Trap(tryStatement) {
|
||||
@@ -84,7 +84,7 @@ sealed class Trap(val anchor: PsiElement) {
|
||||
}
|
||||
|
||||
override fun getPossibleTargets() = clauses.values.map { it.instructionOffset }
|
||||
override fun toString() = "${super.toString()} -> ${clauses.values}"
|
||||
override fun toString(): String = "${super.toString()} -> ${clauses.values}"
|
||||
}
|
||||
abstract class EnterFinally(anchor: PsiElement, val jumpOffset: ControlFlow.ControlFlowOffset): Trap(anchor) {
|
||||
internal val backLinks = ArrayList<ControlTransferInstruction>()
|
||||
@@ -99,7 +99,7 @@ sealed class Trap(val anchor: PsiElement) {
|
||||
}
|
||||
|
||||
override fun getPossibleTargets() = listOf(jumpOffset.instructionOffset)
|
||||
override fun toString() = "${super.toString()} -> $jumpOffset"
|
||||
override fun toString(): String = "${super.toString()} -> $jumpOffset"
|
||||
}
|
||||
class TryFinally(finallyBlock: PsiCodeBlock, jumpOffset: ControlFlow.ControlFlowOffset): EnterFinally(finallyBlock, jumpOffset)
|
||||
class TwrFinally(resourceList: PsiResourceList, jumpOffset: ControlFlow.ControlFlowOffset) : EnterFinally(resourceList, jumpOffset) {
|
||||
|
||||
+3
-3
@@ -24,7 +24,7 @@ data class ExpressionRange internal constructor (internal val startOffset: Int,
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun create(expr: LighterASTNode, scopeStart: Int) = ExpressionRange(
|
||||
fun create(expr: LighterASTNode, scopeStart: Int): ExpressionRange = ExpressionRange(
|
||||
expr.startOffset - scopeStart, expr.endOffset - scopeStart)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ data class ExpressionRange internal constructor (internal val startOffset: Int,
|
||||
|
||||
data class PurityInferenceResult(internal val mutatedRefs: List<ExpressionRange>, internal val singleCall: ExpressionRange?) {
|
||||
|
||||
fun isPure(method: PsiMethod, body: () -> PsiCodeBlock) = !mutatesNonLocals(method, body) && callsOnlyPureMethods(body)
|
||||
fun isPure(method: PsiMethod, body: () -> PsiCodeBlock): Boolean = !mutatesNonLocals(method, body) && callsOnlyPureMethods(body)
|
||||
|
||||
private fun mutatesNonLocals(method: PsiMethod, body: () -> PsiCodeBlock): Boolean {
|
||||
return mutatedRefs.any { range -> !isLocalVarReference(range.restoreExpression(body()), method) }
|
||||
@@ -87,7 +87,7 @@ interface MethodReturnInferenceResult {
|
||||
@Suppress("EqualsOrHashCode")
|
||||
data class Predefined(internal val value: Nullness) : MethodReturnInferenceResult {
|
||||
override fun hashCode() = value.ordinal
|
||||
override fun getNullness(method: PsiMethod, body: () -> PsiCodeBlock) = when {
|
||||
override fun getNullness(method: PsiMethod, body: () -> PsiCodeBlock): Nullness = when {
|
||||
value == Nullness.NULLABLE && InferenceFromSourceUtil.suppressNullable(
|
||||
method) -> Nullness.UNKNOWN
|
||||
else -> value
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ open class ControlTransferInstruction(val transfer: DfaControlTransferValue) : I
|
||||
/**
|
||||
* Returns list of possible target instruction indices
|
||||
*/
|
||||
fun getPossibleTargetIndices() = transfer.traps.flatMap(Trap::getPossibleTargets) + transfer.target.getPossibleTargets()
|
||||
fun getPossibleTargetIndices(): List<Int> = transfer.traps.flatMap(Trap::getPossibleTargets) + transfer.target.getPossibleTargets()
|
||||
|
||||
override fun toString() = "TRANSFER $transfer [targets: ${getPossibleTargetIndices()}]"
|
||||
override fun toString(): String = "TRANSFER $transfer [targets: ${getPossibleTargetIndices()}]"
|
||||
}
|
||||
+2
-2
@@ -79,10 +79,10 @@ abstract class ImplicitSubclassProvider {
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val EP_NAME = ExtensionPointName.create<ImplicitSubclassProvider>("com.intellij.codeInsight.implicitSubclassProvider")
|
||||
val EP_NAME: ExtensionPointName<ImplicitSubclassProvider> = ExtensionPointName.create<ImplicitSubclassProvider>("com.intellij.codeInsight.implicitSubclassProvider")
|
||||
|
||||
@Deprecated("To be removed in 2018.2", ReplaceWith("ImplicitSubclassProvider.EP_NAME"))
|
||||
fun getEP_NAME() = EP_NAME
|
||||
fun getEP_NAME(): ExtensionPointName<ImplicitSubclassProvider> = EP_NAME
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ class UastSmartPointer<T : UElement>(uElement: T, val targetClass: Class<T>) {
|
||||
|
||||
}
|
||||
|
||||
inline fun <reified T : UElement> T.createUastSmartPointer() = UastSmartPointer(this, T::class.java)
|
||||
inline fun <reified T : UElement> T.createUastSmartPointer(): UastSmartPointer<T> = UastSmartPointer(this, T::class.java)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user