Apply Kotlin "Unnecessary type argument" inspection

GitOrigin-RevId: 4b5ab8fc922d7bb060be00fb9c14f96ea9500bfb
This commit is contained in:
Alexey Belkov
2023-05-26 17:19:14 +04:00
committed by intellij-monorepo-bot
parent c89594495a
commit edda51dea1
65 changed files with 86 additions and 81 deletions

View File

@@ -47,7 +47,7 @@ class SingleTestCollector : TestEntryVisitor() {
class ConfigurationsCollector : TestEntryVisitor() {
val entries: MutableList<RecentTestsPopupEntry> = mutableListOf<RecentTestsPopupEntry>()
val entries: MutableList<RecentTestsPopupEntry> = mutableListOf()
override fun visitRunConfiguration(configuration: RunConfigurationEntry) {
entries.add(configuration)

View File

@@ -63,7 +63,7 @@ abstract class ImplicitSubclassProvider {
companion object {
@JvmField
val EP_NAME: ExtensionPointName<ImplicitSubclassProvider> = ExtensionPointName.create<ImplicitSubclassProvider>("com.intellij.codeInsight.implicitSubclassProvider")
val EP_NAME: ExtensionPointName<ImplicitSubclassProvider> = ExtensionPointName.create("com.intellij.codeInsight.implicitSubclassProvider")
}
}

View File

@@ -121,7 +121,7 @@ internal class ChooseComponentsToExportDialog(fileToComponents: Map<FileSpec, Li
for (componentElementProperty in LinkedHashSet(componentToContainingListElement.values)) {
chooser.addElement(componentElementProperty, markedElementNames.isEmpty() || markedElementNames.contains(componentElementProperty.fileName), componentElementProperty)
}
chooser.sort(Comparator.comparing<ComponentElementProperties, String> { it.toString() })
chooser.sort(Comparator.comparing { it.toString() })
val exportPath = PropertiesComponent.getInstance().getValue("export.settings.path", DEFAULT_PATH)
pathPanel.text = exportPath

View File

@@ -15,7 +15,7 @@ class BranchStorage : BaseState() {
fun contains(typeName: String, repository: Repository?, branchName: String): Boolean {
val branches = branches[typeName] ?: return false
return DvcsBranchUtil.find<DvcsBranchInfo>(branches, repository, branchName) != null
return DvcsBranchUtil.find(branches, repository, branchName) != null
}
fun add(typeName: String, repository: Repository?, branchName: String) {
@@ -29,7 +29,7 @@ class BranchStorage : BaseState() {
fun remove(typeName: String, repository: Repository?, branchName: String) {
val branches = branches[typeName] ?: return
val toDelete = DvcsBranchUtil.find<DvcsBranchInfo>(branches, repository, branchName) ?: return
val toDelete = DvcsBranchUtil.find(branches, repository, branchName) ?: return
branches.remove(toDelete)
if (branches.isEmpty()) {
this.branches.remove(typeName)

View File

@@ -38,7 +38,7 @@ internal fun getHardcodedBeforeRunTasks(configuration: RunConfiguration, factory
factory.configureBeforeRunTaskDefaults(provider.id, task)
if (task.isEnabled) {
if (result == null) {
result = SmartList<BeforeRunTask<*>>()
result = SmartList()
}
result.add(task)
}

View File

@@ -123,7 +123,7 @@ open class ContributedConfigurationsList<C, T>(private val extPoint: ExtensionPo
var name by string()
@get:Tag("config")
var innerState: Element? by property<Element?>(null) { it === null }
var innerState: Element? by property(null) { it === null }
open fun loadFromConfiguration(config: ContributedConfigurationBase) {
typeId = config.typeId

View File

@@ -24,7 +24,7 @@ abstract class ExternalSystemReifiedRunConfigurationExtension<C : ExternalSystem
@Suppress("UNCHECKED_CAST")
override fun <P : ExternalSystemRunConfiguration> createFragments(configuration: P): List<SettingsEditor<P>> {
return SettingsFragmentsContainer.fragments<C> {
return SettingsFragmentsContainer.fragments {
configureFragments(configuration as C)
} as List<SettingsEditor<P>>
}

View File

@@ -98,7 +98,7 @@ internal class ConfigurationDataService : AbstractProjectDataService<Configurati
val moduleDataNode = ExternalSystemApiUtil.findParent(node, ProjectKeys.MODULE)
if (moduleDataNode != null) {
var module = moduleDataNode.getUserData<Module>(MODULE_KEY)
var module = moduleDataNode.getUserData(MODULE_KEY)
module = module ?: modelsProvider.findIdeModule(moduleDataNode.data)
if (module == null) {

View File

@@ -79,7 +79,7 @@ class ExternalProjectsDataStorageTest: UsefulTestCase() {
externalName: String,
externalProjectPath: String): InternalExternalProjectInfo {
val projectData = ProjectData(testId, externalName, externalProjectPath, externalProjectPath)
val node = DataNode<ProjectData>(Key(ProjectData::class.jvmName, 0), projectData, null)
val node = DataNode(Key(ProjectData::class.jvmName, 0), projectData, null)
return InternalExternalProjectInfo(testId, externalProjectPath, node)
}
}

View File

@@ -10,7 +10,7 @@ import com.intellij.openapi.project.Project
interface CodeVisionProviderFactory {
companion object {
const val EP_NAME: String = "com.intellij.codeInsight.codeVisionProviderFactory"
val extensionPoint: ExtensionPointName<CodeVisionProviderFactory> = ExtensionPointName<CodeVisionProviderFactory>(EP_NAME)
val extensionPoint: ExtensionPointName<CodeVisionProviderFactory> = ExtensionPointName(EP_NAME)
fun createAllProviders(project: Project): List<CodeVisionProvider<*>> {
return extensionPoint.extensionList.flatMap { it.createProviders(project) }

View File

@@ -21,8 +21,8 @@ import java.awt.event.MouseEvent
// used externally
val editorLensContextKey: Key<EditorCodeVisionContext> = Key<EditorCodeVisionContext>("EditorCodeLensContext")
// used externally
val codeVisionEntryOnHighlighterKey: Key<CodeVisionEntry> = Key.create<CodeVisionEntry>("CodeLensEntryOnHighlighter")
internal val codeVisionEntryMouseEventKey: Key<MouseEvent> = Key.create<MouseEvent>("CodeVisionEntryMouseEventKey")
val codeVisionEntryOnHighlighterKey: Key<CodeVisionEntry> = Key.create("CodeLensEntryOnHighlighter")
internal val codeVisionEntryMouseEventKey: Key<MouseEvent> = Key.create("CodeVisionEntryMouseEventKey")
val Editor.lensContext: EditorCodeVisionContext?
get() = getOrCreateCodeVisionContext(this)

View File

@@ -21,7 +21,7 @@ class CodeVisionListData(
) {
companion object {
@JvmField
val KEY: Key<CodeVisionListData> = Key.create<CodeVisionListData>("CodeVisionListData")
val KEY: Key<CodeVisionListData> = Key.create("CodeVisionListData")
}
@@ -35,7 +35,7 @@ class CodeVisionListData(
}
}
val visibleLens: ArrayList<CodeVisionEntry> = ArrayList<CodeVisionEntry>()
val visibleLens: ArrayList<CodeVisionEntry> = ArrayList()
private var throttle = false
init {

View File

@@ -36,7 +36,7 @@ class CodeVisionSelectionController private constructor(val lifetime: Lifetime,
val projectModel: ProjectCodeVisionModel) {
companion object {
private val map: HashMap<Editor, CodeVisionSelectionController> = HashMap<Editor, CodeVisionSelectionController>()
private val map: HashMap<Editor, CodeVisionSelectionController> = HashMap()
private val logger: Logger = logger<CodeVisionSelectionController>()
fun install(editor: EditorImpl, projectModel: ProjectCodeVisionModel) {

View File

@@ -16,7 +16,7 @@ import com.intellij.util.ui.EmptyIcon
import org.jetbrains.annotations.ApiStatus
import javax.swing.Icon
val EP_NAME: ExtensionPointName<EmptyIntentionProvider> = ExtensionPointName<EmptyIntentionProvider>("com.intellij.emptyIntentionProvider")
val EP_NAME: ExtensionPointName<EmptyIntentionProvider> = ExtensionPointName("com.intellij.emptyIntentionProvider")
@ApiStatus.Internal
interface EmptyIntentionProvider {

View File

@@ -360,7 +360,7 @@ private class FileColorsTableModel(val manager: FileColorManagerImpl) : Abstract
table.tableHeader.defaultRenderer = TableHeaderRenderer()
table.setDefaultRenderer(String::class.java, TableScopeRenderer(manager))
// configure color renderer and its editor
val editor = ComboBox<String>(getColors().toTypedArray())
val editor: ComboBox<String> = ComboBox(getColors().toTypedArray())
editor.renderer = ComboBoxColorRenderer(manager)
table.setDefaultEditor(FileColorConfiguration::class.java, DefaultCellEditor(editor))
table.setDefaultRenderer(FileColorConfiguration::class.java, TableColorRenderer(manager))

View File

@@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicReference
@ApiStatus.NonExtendable
open class AtomicLazyProperty<T>(private val initial: () -> T) : AbstractObservableClearableProperty<T>(), AtomicMutableProperty<T> {
private val value = AtomicReference<Any?>(UNINITIALIZED_VALUE)
private val value = AtomicReference(UNINITIALIZED_VALUE)
override fun get(): T {
return update { it }

View File

@@ -57,7 +57,7 @@ class FeaturesInfo(override val knownFeatures: Set<String>,
private fun <T> String.fromJson(): T {
val typeToken = object : TypeToken<T>() {}
return gson.fromJson<T>(this, typeToken.type)
return gson.fromJson(this, typeToken.type)
}
fun buildFeaturesIndex(vararg featureGroups: List<Feature>): Map<String, Feature> {

View File

@@ -13,7 +13,7 @@ class ChunkMMappedFileIO(
private val fileChannel: FileChannel,
private val mapMode: MapMode
) : StorageIO {
private val chunks = SmallIndexMap<MappedByteBuffer>(::mapChunk)
private val chunks: SmallIndexMap<MappedByteBuffer> = SmallIndexMap(::mapChunk)
private fun mapChunk(chunkId: Int): MappedByteBuffer {
return fileChannel.map(mapMode, CHUNK_SIZE * chunkId, CHUNK_SIZE)

View File

@@ -108,7 +108,7 @@ class ComponentStyle<T : JComponent>private constructor(private val default: Pro
}
fun build(): ComponentStyle<T> {
return ComponentStyle<T>(default.clone(), styleMap.mapValues { it.value.clone()})
return ComponentStyle(default.clone(), styleMap.mapValues { it.value.clone()})
}
}

View File

@@ -90,7 +90,7 @@ internal fun <T> createPropertyBinding(prop: KMutableProperty0<T>, propType: Cla
@ApiStatus.ScheduledForRemoval
@Deprecated("Use MutableProperty and Kotlin UI DSL 2")
fun <T> PropertyBinding<T>.toNullable(): PropertyBinding<T?> {
return PropertyBinding<T?>({ get() }, { set(it!!) })
return PropertyBinding({ get() }, { set(it!!) })
}
@ApiStatus.ScheduledForRemoval

View File

@@ -13,7 +13,7 @@ import javax.swing.border.Border
import kotlin.math.cos
import kotlin.system.exitProcess
fun simple() = barChart<Double> {
fun simple(): HorizontalBarChart<Double> = barChart {
gap = 20
datasets {
dataset {
@@ -49,7 +49,7 @@ fun simple() = barChart<Double> {
}
}
fun performance() = barChart<Double> {
fun performance(): HorizontalBarChart<Double> = barChart {
val format: (Double) -> String = { v -> "%.2f".format(v) }
val labels = listOf("macOS Mojave 10.14.6", "Ubuntu 16.04", "Windows 10")
ranges {

View File

@@ -28,7 +28,7 @@ class EmptyModuleManager(private val project: Project) : ModuleManager() {
override fun moduleDependencyComparator(): Nothing = throw UnsupportedOperationException()
override fun getModuleDependentModules(module: Module): List<Module> = emptyList<Module>()
override fun getModuleDependentModules(module: Module): List<Module> = emptyList()
override fun isModuleDependent(@NotNull module: Module, @NotNull onModule: Module): Boolean = false

View File

@@ -13,7 +13,7 @@ import org.jetbrains.debugger.values.Value
import javax.swing.Icon
open class BasicDebuggerViewSupport : MemberFilter, DebuggerViewSupport {
protected val defaultMemberFilterPromise: Promise<MemberFilter> = resolvedPromise<MemberFilter>(this)
protected val defaultMemberFilterPromise: Promise<MemberFilter> = resolvedPromise(this)
override fun propertyNamesToString(list: List<String>, quotedAware: Boolean): String = ValueModifierUtil.propertyNamesToString(list, quotedAware)

View File

@@ -184,7 +184,8 @@ internal class FieldProcessor(private val reader: InterfaceReader, typeClass: Cl
}
}
internal inline fun <reified T : Annotation> KCallable<*>.annotation(): T? = annotations.firstOrNull() { it is T } as? T ?: (this as? KFunction<*>)?.javaMethod?.getAnnotation<T>(T::class.java)
internal inline fun <reified T : Annotation> KCallable<*>.annotation(): T? =
annotations.firstOrNull { it is T } as? T ?: (this as? KFunction<*>)?.javaMethod?.getAnnotation(T::class.java)
/**
* An internal facility for navigating from object of base type to object of subtype. Used only

View File

@@ -68,7 +68,7 @@ fun assertConcurrentPromises(vararg runnables: () -> Promise<String>, maxTimeout
val allExecutorThreadsReady = CountDownLatch(numThreads)
val afterInitBlocker = CountDownLatch(1)
val allDone = CountDownLatch(numThreads)
val promises: MutableList<Promise<String>> = Collections.synchronizedList(ArrayList<Promise<String>>())
val promises: MutableList<Promise<String>> = Collections.synchronizedList(ArrayList())
for (submittedTestRunnable in runnables) {
threadPool.submit {
allExecutorThreadsReady.countDown()

View File

@@ -39,7 +39,11 @@ class DefaultInclusionModel(
) : BaseInclusionModel() {
private val inclusion: MutableSet<Any> = if (inclusionHashingStrategy == null) HashSet() else CollectionFactory.createCustomHashingStrategySet(inclusionHashingStrategy)
override fun getInclusion(): Set<Any> = Collections.unmodifiableSet<Any>((if (inclusionHashingStrategy == null) HashSet(inclusion) else CollectionFactory.createCustomHashingStrategySet(inclusionHashingStrategy).also { it.addAll(inclusion) }))
override fun getInclusion(): Set<Any> {
val set = if (inclusionHashingStrategy == null) HashSet(inclusion)
else CollectionFactory.createCustomHashingStrategySet(inclusionHashingStrategy).also { it.addAll(inclusion) }
return Collections.unmodifiableSet(set)
}
override fun getInclusionState(item: Any): ThreeStateCheckBox.State =
if (item in inclusion) ThreeStateCheckBox.State.SELECTED else ThreeStateCheckBox.State.NOT_SELECTED

View File

@@ -39,7 +39,7 @@ class EntityStorageSerializationTest {
mutableSetOf("c", "d")
VirtualFileUrlManagerImpl()
builder addEntity SampleEntity(false, stringProperty = "MyEntity",
stringListProperty = mutableListOf<String>("a", "b"),
stringListProperty = mutableListOf("a", "b"),
stringMapProperty = HashMap(), fileProperty = virtualFileManager.fromUrl("file:///tmp"),
entitySource = SampleEntitySource("test"))

View File

@@ -329,7 +329,7 @@ class ExternalEntityMappingTest {
VirtualFileUrlManagerImpl().fromUrl("file:///tmp"), SampleEntitySource("test"))
var externalMapping = replacement.getMutableExternalMapping<Int>(INDEX_ID)
externalMapping.addMapping(fooEntity, 1)
externalMapping = replacement.getMutableExternalMapping<Int>(ANOTHER_INDEX_ID)
externalMapping = replacement.getMutableExternalMapping(ANOTHER_INDEX_ID)
externalMapping.addMapping(barEntity, 2)
initialBuilder.replaceBySource({ it is SampleEntitySource }, replacement)
@@ -421,7 +421,7 @@ class ExternalEntityMappingTest {
val replacement = createEmptyBuilder()
var barEntity = replacement addEntity SampleEntity(false, "bar", ArrayList(), HashMap(),
VirtualFileUrlManagerImpl().fromUrl("file:///tmp"), SampleEntitySource("test"))
externalMapping = replacement.getMutableExternalMapping<Int>(ANOTHER_INDEX_ID)
externalMapping = replacement.getMutableExternalMapping(ANOTHER_INDEX_ID)
externalMapping.addMapping(barEntity, 2)
initialBuilder.replaceBySource({ it is SampleEntitySource }, replacement)
@@ -442,7 +442,7 @@ class ExternalEntityMappingTest {
val replacement = createEmptyBuilder()
var barEntity = replacement addEntity SampleEntity(false, "bar", ArrayList(), HashMap(),
VirtualFileUrlManagerImpl().fromUrl("file:///tmp"), SampleEntitySource("test"))
externalMapping = replacement.getMutableExternalMapping<Int>(INDEX_ID)
externalMapping = replacement.getMutableExternalMapping(INDEX_ID)
externalMapping.addMapping(barEntity, 2)
initialBuilder.replaceBySource({ it is SampleEntitySource }, replacement)

View File

@@ -16,7 +16,7 @@ abstract class EditorConfigJsonFileOptionDescriptorProviderBase : EditorConfigOp
final override fun getOptionDescriptors() = cachedDescriptors
private fun deserialize(text: String) = try {
private fun deserialize(text: String): List<EditorConfigOptionDescriptor> = try {
EditorConfigOptionDescriptorJsonDeserializer
.buildGson()
.fromJson(text, Array<EditorConfigOptionDescriptor?>::class.java)
@@ -25,7 +25,7 @@ abstract class EditorConfigJsonFileOptionDescriptorProviderBase : EditorConfigOp
catch (ex: JsonSyntaxException) {
logger<EditorConfigJsonFileOptionDescriptorProviderBase>()
.warn("Json syntax error in descriptor")
emptyList<EditorConfigOptionDescriptor>()
emptyList()
}
private fun loadFileContent(): String {

View File

@@ -63,7 +63,7 @@ class EditorConfigWrongFileEncodingNotificationProvider : EditorNotificationProv
val hide = EditorConfigBundle["notification.action.hide.once"]
result.createActionLabel(hide) {
editor.putUserData<Boolean>(HIDDEN_KEY, true)
editor.putUserData(HIDDEN_KEY, true)
update(file, project)
}

View File

@@ -76,7 +76,7 @@ class EditorConfigWrongFileNameNotificationProvider : EditorNotificationProvider
val hide = EditorConfigBundle["notification.action.hide.once"]
result.createActionLabel(hide) {
editor.putUserData<Boolean>(HIDDEN_KEY, true)
editor.putUserData(HIDDEN_KEY, true)
update(file, project)
}

View File

@@ -16,7 +16,7 @@ internal class FilePredictionSessionHistory {
private var candidatesPerSession: Int = DEFAULT_CANDIDATES_PER_SESSION
private var previousCandidates: Array<Set<String>> = Array(3) { emptySet<String>() }
private var previousCandidates: Array<Set<String>> = Array(3) { emptySet() }
@TestOnly
fun setCandidatesPerSession(size: Int) {

View File

@@ -197,7 +197,7 @@ class GitHistoryUtilsTest : GitSingleRepoTest() {
repo.checkout(revisions.first().hash)
val hashes = mutableListOf<String>()
GitHistoryUtils.loadTimedCommits(myProject, projectRoot, Consumer<TimedVcsCommit> { hashes.add(it.id.asString()) }, "$branchName..HEAD")
GitHistoryUtils.loadTimedCommits(myProject, projectRoot, Consumer { hashes.add(it.id.asString()) }, "$branchName..HEAD")
TestCase.assertEquals(revisions.subList(0, revisions.size - 1).map { it.hash }, hashes)
}

View File

@@ -101,7 +101,7 @@ class GitPushOperationMultiRepoTest : GitPushOperationBaseTest() {
updateChangeListManager()
val result = GitPushOperation(project, pushSupport,
Collections.singletonMap<GitRepository, PushSpec<GitPushSource, GitPushTarget>>(ultimate, mainSpec), null, false, false).execute()
Collections.singletonMap(ultimate, mainSpec), null, false, false).execute()
val result1 = result.results[ultimate]!!
val result2 = result.results[community]

View File

@@ -44,7 +44,7 @@ class GithubChooseAccountDialog @JvmOverloads constructor(project: Project?, par
margin = JBInsets.emptyInsets()
}
}
private val accountsList: JBList<GithubAccount> = JBList<GithubAccount>(accounts).apply {
private val accountsList: JBList<GithubAccount> = JBList(accounts).apply {
selectionMode = ListSelectionModel.SINGLE_SELECTION
cellRenderer = object : ColoredListCellRenderer<GithubAccount>() {
override fun customizeCellRenderer(list: JList<out GithubAccount>,

View File

@@ -10,7 +10,7 @@ import java.util.function.Supplier
class GHPRReloadCommentsAction
: RefreshAction(GithubBundle.messagePointer("pull.request.refresh.comments.action"),
Supplier<String?> { null },
Supplier { null },
AllIcons.Actions.Refresh) {
override fun update(e: AnActionEvent) {

View File

@@ -11,7 +11,7 @@ import java.util.function.Supplier
class GHPRReloadDetailsAction
: RefreshAction(GithubBundle.messagePointer("pull.request.refresh.details.action"),
Supplier<String?> { null },
Supplier { null },
AllIcons.Actions.Refresh) {
override fun update(e: AnActionEvent) {

View File

@@ -10,7 +10,7 @@ import java.util.function.Supplier
class GHPRReloadListAction
: RefreshAction(GithubBundle.messagePointer("pull.request.refresh.list.action"),
Supplier<String?> { null },
Supplier { null },
AllIcons.Actions.Refresh) {
override fun update(e: AnActionEvent) {

View File

@@ -16,7 +16,7 @@ import org.jetbrains.plugins.github.pullrequest.GHPRVirtualFile
import java.util.function.Supplier
class GHPRSelectPullRequestForFileAction : DumbAwareAction(GithubBundle.messagePointer("pull.request.select.action"),
Supplier<String?> { null },
Supplier { null },
AllIcons.General.Locate) {
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT

View File

@@ -26,7 +26,7 @@ abstract class GHListLoaderBase<T>(protected val progressManager: ProgressManage
}
private val errorChangeEventDispatcher = EventDispatcher.create(SimpleEventListener::class.java)
override var error: Throwable? by Delegates.observable<Throwable?>(null) { _, _, _ ->
override var error: Throwable? by Delegates.observable(null) { _, _, _ ->
errorChangeEventDispatcher.multicaster.eventOccurred()
}
@@ -85,7 +85,7 @@ abstract class GHListLoaderBase<T>(protected val progressManager: ProgressManage
override fun reset() {
lastFuture = lastFuture.handle { _, _ ->
listOf<T>()
listOf()
}
progressIndicator.cancel()
progressIndicator = NonReusableEmptyProgressIndicator()

View File

@@ -30,7 +30,7 @@ class GHPRStatusViewModelImpl(stateModel: GHPRStateModel) : GHPRStatusViewModel
override val hasConflicts: Flow<Boolean> = _mergeabilityState.map { mergeability ->
mergeability?.hasConflicts ?: false
}
override val ciJobs: Flow<List<CodeReviewCIJob>> = _mergeabilityState.map { it?.ciJobs ?: emptyList<CodeReviewCIJob>() }
override val ciJobs: Flow<List<CodeReviewCIJob>> = _mergeabilityState.map { it?.ciJobs ?: emptyList() }
override val isRestricted: Flow<Boolean> = _mergeabilityState.map { mergeability ->
mergeability?.isRestricted ?: false

View File

@@ -8,7 +8,7 @@ import org.jetbrains.plugins.github.pullrequest.comment.ui.GHPRReviewThreadModel
import org.jetbrains.plugins.github.pullrequest.comment.ui.GHPRReviewThreadModelImpl
class GHPRReviewThreadsModel
: CollectionListModel<GHPRReviewThreadModel>(SortedList<GHPRReviewThreadModel>(compareBy { it.createdAt }), true) {
: CollectionListModel<GHPRReviewThreadModel>(SortedList(compareBy { it.createdAt }), true) {
var loaded = false
private set

View File

@@ -28,7 +28,7 @@ class GHPRDiffController(private val diffRequestModel: GHPRDiffRequestModel,
tree?.let { propagateSelection(it) }
}
var filesTree: ChangesTree? by observable<ChangesTree?>(null) { _, oldValue, newValue ->
var filesTree: ChangesTree? by observable(null) { _, oldValue, newValue ->
oldValue?.removeTreeSelectionListener(filesTreeListener)
newValue?.addTreeSelectionListener(filesTreeListener)
filesTreeListener.valueChanged(null)
@@ -39,7 +39,7 @@ class GHPRDiffController(private val diffRequestModel: GHPRDiffRequestModel,
filesTree?.let { propagateSelection(it) }
}
var commitsTree: ChangesTree? by observable<ChangesTree?>(null) { _, oldValue, newValue ->
var commitsTree: ChangesTree? by observable(null) { _, oldValue, newValue ->
oldValue?.removeTreeSelectionListener(commitsTreeListener)
newValue?.addTreeSelectionListener(commitsTreeListener)
commitsTreeListener.valueChanged(null)

View File

@@ -22,7 +22,7 @@ object DialogValidationUtils {
* Stateful validator that checks that contents of [textField] are unique among [records]
*/
class RecordUniqueValidator(private val textField: JTextField, @NlsContexts.DialogMessage private val message: String) : Validator {
var records: Set<String> = setOf<String>()
var records: Set<String> = setOf()
override fun invoke(): ValidationInfo? = if (records.contains(textField.text)) ValidationInfo(message, textField) else null
}

View File

@@ -22,7 +22,7 @@ fun createVariableMap(method: GrMethod): Map<String, SpockVariableDescriptor> {
}
private fun createVariableMap(methodBlock: GrOpenBlock): Map<String, SpockVariableDescriptor> {
val statements = LinkedList<GrStatement>(methodBlock.statements.asList())
val statements: LinkedList<GrStatement> = LinkedList(methodBlock.statements.asList())
val whereBlockStart = findWhereBlockStart(statements) ?: return emptyMap()
val result = HashMap<String, SpockVariableDescriptor>()

View File

@@ -14,7 +14,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder.checkKind
val closureCallKey: Key<GrCall> = Key.create<GrCall>("groovy.pattern.closure.call")
val closureCallKey: Key<GrCall> = Key.create("groovy.pattern.closure.call")
inline fun <reified T : GroovyPsiElement> groovyElement(): GroovyElementPattern.Capture<T> {
return GroovyElementPattern.Capture(T::class.java)

View File

@@ -15,7 +15,7 @@ class GrUFile(override val sourcePsi: GroovyFile, override val languagePlugin: U
override val packageName: String
get() = sourcePsi.packageName
override val imports: List<UImportStatement> = emptyList<UImportStatement>() // not implemented
override val imports: List<UImportStatement> = emptyList() // not implemented
override val uAnnotations: List<UAnnotation>
get() = sourcePsi.packageDefinition?.annotationList?.annotations?.map { GrUAnnotation(it, { this }) } ?: emptyList()

View File

@@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentMap
private fun GroovyFile.getBindings(): ConcurrentMap<String, GrVariable> {
return CachedValuesManager.getCachedValue(this) {
Result.create(ConcurrentHashMap<String, GrVariable>(), PsiModificationTracker.MODIFICATION_COUNT)
Result.create(ConcurrentHashMap(), PsiModificationTracker.MODIFICATION_COUNT)
}
}

View File

@@ -39,7 +39,7 @@ abstract class DeclarationsSearch<T : PsiElement, R : DeclarationSearchRequest<T
protected abstract fun doSearch(request: R, consumer: Processor<in T>)
protected open fun isApplicable(request: R): Boolean = true
fun search(request: R): Query<T> = if (isApplicable(request)) createUniqueResultsQuery(request) else EmptyQuery.getEmptyQuery<T>()
fun search(request: R): Query<T> = if (isApplicable(request)) createUniqueResultsQuery(request) else EmptyQuery.getEmptyQuery()
}
class HierarchySearchRequest<T : PsiElement>(

View File

@@ -251,7 +251,7 @@ class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks:
resultElements.forEach { deleteCommentsInside(it) }
if (commentsToRestore.isNotEmpty() || lineBreaksToRestore.isNotEmpty()) {
toNewPsiElementMap = HashMap<TreeElement, MutableCollection<PsiElement>>()
toNewPsiElementMap = HashMap()
for (element in resultElements) {
element.accept(object : PsiRecursiveElementVisitor() {
override fun visitElement(element: PsiElement) {

View File

@@ -25,7 +25,7 @@ class IdeaModuleStructureOracle : ModuleStructureOracle {
override fun findAllReversedDependsOnPaths(module: ModuleDescriptor): List<ModulePath> {
val currentPath: Stack<ModuleInfo> = Stack()
return sequence<ModuleInfoPath> {
return sequence {
val root = module.moduleInfo
if (root != null) {
yieldPathsFromSubgraph(
@@ -45,7 +45,7 @@ class IdeaModuleStructureOracle : ModuleStructureOracle {
override fun findAllDependsOnPaths(module: ModuleDescriptor): List<ModulePath> {
val currentPath: Stack<ModuleInfo> = Stack()
return sequence<ModuleInfoPath> {
return sequence {
val root = module.moduleInfo
if (root != null) {
yieldPathsFromSubgraph(

View File

@@ -50,7 +50,7 @@ fun Project.executeWriteCommand(@NlsContexts.Command name: String, command: () -
}
fun <T> Project.executeWriteCommand(@NlsContexts.Command name: String, groupId: Any? = null, command: () -> T): T {
return executeCommand<T>(name, groupId) { runWriteAction(command) }
return executeCommand(name, groupId) { runWriteAction(command) }
}
fun <T> Project.executeCommand(@NlsContexts.Command name: String, groupId: Any? = null, command: () -> T): T {

View File

@@ -55,7 +55,7 @@ object ExpectedCompletionUtils {
}
constructor(json: JsonObject) {
map = HashMap<String, String?>()
map = HashMap()
for (entry in json.entrySet()) {
val key = entry.key
if (key !in validKeys) {

View File

@@ -254,7 +254,7 @@ internal fun ElementAndTextList.convertCodeToKotlin(project: Project, targetModu
val inputElements = toList().filterIsInstance<PsiElement>()
val (results, _, converterContext) =
ProgressManager.getInstance().runProcessWithProgressSynchronously(
ThrowableComputable<Result, Exception> {
ThrowableComputable {
runReadAction { converter.elementsToKotlin(inputElements) }
},
JavaToKotlinAction.title,

View File

@@ -137,7 +137,7 @@ class CanBeValInspection : AbstractKotlinInspection() {
private fun canReach(
from: Instruction,
targets: Set<Instruction>,
visited: HashSet<Instruction> = HashSet<Instruction>()
visited: HashSet<Instruction> = HashSet()
): Boolean {
// special algorithm for linear code to avoid too deep recursion
var instruction = from

View File

@@ -60,7 +60,7 @@ object CreateClassFromCallWithConstructorCalleeActionFactory : CreateClassFromUs
}
val typeArgumentInfos = when {
isAnnotation -> Collections.emptyList<TypeInfo>()
isAnnotation -> Collections.emptyList()
else -> element.typeArguments.mapNotNull { it.typeReference?.let { TypeInfo(it, Variance.INVARIANT) } }
}

View File

@@ -405,7 +405,7 @@ private fun KotlinType.collectReferencedTypes(processTypeArguments: Boolean): Li
if (!processTypeArguments) return Collections.singletonList(this)
return dfsFromNode(
this,
Neighbors<KotlinType> { current -> current.arguments.map { it.type } },
Neighbors { current -> current.arguments.map { it.type } },
VisitedWithSet(),
object : CollectingNodeHandler<KotlinType, KotlinType, ArrayList<KotlinType>>(ArrayList()) {
override fun afterChildren(current: KotlinType) {

View File

@@ -193,7 +193,7 @@ private class Fe10BindingLexicalScopeForClassLikeElement(
}
}
private fun collectAllCompanionObjects(skipMine: Boolean) = buildList<KtNamedClassOrObjectSymbol> {
private fun collectAllCompanionObjects(skipMine: Boolean): List<KtNamedClassOrObjectSymbol> = buildList {
var current = ktClassSymbol
mainLoop@ while (true) {
if (current is KtNamedClassOrObjectSymbol && (current !== ktClassSymbol || !skipMine)) {

View File

@@ -307,7 +307,7 @@ abstract class AbstractPerformanceProjectsTest : UsefulTestCase() {
note: String = ""
) {
var fileText: String? = null
perfTypeAndDo<Unit>(
perfTypeAndDo(
project,
fileName,
"typeAndUndo",

View File

@@ -101,7 +101,7 @@ abstract class AbstractPerformanceCompletionIncrementalResolveTest : KotlinLight
private fun innerPerfTest(name: String, setUpBody: (TestData<Unit, Array<LookupElement>>) -> Unit) {
CompletionBindingContextProvider.ENABLED = true
try {
performanceTest<Unit, Array<LookupElement>> {
performanceTest {
name(name)
stats(stats)
setUp(setUpBody)

View File

@@ -88,7 +88,7 @@ abstract class AbstractPerformanceHighlightingTest : KotlinLightCodeInsightFixtu
}
private fun innerPerfTest(name: String, setUpBody: (TestData<Unit, MutableList<HighlightInfo>>) -> Unit) {
performanceTest<Unit, MutableList<HighlightInfo>> {
performanceTest {
name(name)
stats(stats())
setUp {

View File

@@ -29,14 +29,13 @@ object ConsoleJvmApplicationTemplate : Template() {
override fun isApplicableTo(module: Module, projectKind: ProjectKind, reader: Reader): Boolean =
module.configurator.moduleType == ModuleType.jvm
override fun Writer.getIrsToAddToBuildFile(
module: ModuleIR
) = buildList<BuildSystemIR> {
+runTaskIrs("MainKt")
}
override fun Writer.getIrsToAddToBuildFile(module: ModuleIR): List<BuildSystemIR> =
buildList {
+runTaskIrs("MainKt")
}
override fun Reader.getFileTemplates(module: ModuleIR) =
buildList<FileTemplateDescriptorWithPath> {
override fun Reader.getFileTemplates(module: ModuleIR): List<FileTemplateDescriptorWithPath> =
buildList {
+(FileTemplateDescriptor("$id/main.kt.vm", fileToCreate.asPath()) asSrcOf SourcesetType.main)
}
}

View File

@@ -62,7 +62,7 @@ class ConnectorTable : ListTableWithButtons<MavenServerConnector>() {
MavenConfigurableBundle.message("connector.ui.state")) { it.state.toString() }
val type = TableColumn(
MavenConfigurableBundle.message("connector.ui.type")) { it.supportType }
val columnInfos = arrayOf<TableColumn>(project, dir, type, maven, state)
val columnInfos: Array<TableColumn> = arrayOf(project, dir, type, maven, state)
return ListTableModel<MavenServerConnector>(columnInfos, MavenServerManager.getInstance().allConnectors.toList(), 3,
SortOrder.DESCENDING)
}

View File

@@ -8,7 +8,7 @@ import org.jetbrains.uast.psi.UElementWithLocation
@JvmField
@Suppress("DEPRECATION")
val allUElementSubtypes: Set<Class<out UElement>> = setOf<Class<out UElement>>(
val allUElementSubtypes: Set<Class<out UElement>> = setOf(
UAnchorOwner::class.java,
UAnnotated::class.java,
UAnnotation::class.java,

View File

@@ -34,7 +34,8 @@ import kotlin.system.measureTimeMillis
abstract class AbstractLargeProjectTest : UsefulTestCase() {
abstract val testProjectPath: Path
protected open val projectLibraries: List<Pair<String, List<File>>> get() = listOf<Pair<String, List<File>>>()
protected open val projectLibraries: List<Pair<String, List<File>>>
get() = emptyList()
protected lateinit var project: Project