Fix "Placing function type parameters after the function name" errors in project

This commit is contained in:
Yan Zhulanow
2015-11-24 18:21:13 +03:00
parent 87799e9b6b
commit 278f1cd6ef
21 changed files with 46 additions and 46 deletions
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.container
import java.util.ArrayList
import java.util.HashSet
public fun topologicalSort<T>(items: Iterable<T>, dependencies: (T) -> Iterable<T>): List<T> {
public fun <T> topologicalSort(items: Iterable<T>, dependencies: (T) -> Iterable<T>): List<T> {
val itemsInProgress = HashSet<T>()
val completedItems = HashSet<T>()
val result = ArrayList<T>()
@@ -91,7 +91,7 @@ public fun PsiElement.nextLeaf(filter: (PsiElement) -> Boolean): PsiElement? {
return leaf
}
public fun PsiElement.getParentOfTypesAndPredicate<T : PsiElement>(
public fun <T : PsiElement> PsiElement.getParentOfTypesAndPredicate(
strict: Boolean = false, vararg parentClasses: Class<T>, predicate: (T) -> Boolean
): T? {
var element = if (strict) getParent() else this
@@ -110,27 +110,27 @@ public fun PsiElement.getParentOfTypesAndPredicate<T : PsiElement>(
return null
}
public fun PsiElement.getNonStrictParentOfType<T : PsiElement>(parentClass: Class<T>): T? {
public fun <T : PsiElement> PsiElement.getNonStrictParentOfType(parentClass: Class<T>): T? {
return PsiTreeUtil.getParentOfType(this, parentClass, false)
}
inline public fun PsiElement.getParentOfType<reified T : PsiElement>(strict: Boolean): T? {
inline public fun <reified T : PsiElement> PsiElement.getParentOfType(strict: Boolean): T? {
return PsiTreeUtil.getParentOfType(this, javaClass<T>(), strict)
}
inline public fun PsiElement.getStrictParentOfType<reified T : PsiElement>(): T? {
inline public fun <reified T : PsiElement> PsiElement.getStrictParentOfType(): T? {
return PsiTreeUtil.getParentOfType(this, javaClass<T>(), true)
}
inline public fun PsiElement.getNonStrictParentOfType<reified T : PsiElement>(): T? {
inline public fun <reified T : PsiElement> PsiElement.getNonStrictParentOfType(): T? {
return PsiTreeUtil.getParentOfType(this, javaClass<T>(), false)
}
inline public fun PsiElement.getChildOfType<reified T : PsiElement>(): T? {
inline public fun <reified T : PsiElement> PsiElement.getChildOfType(): T? {
return PsiTreeUtil.getChildOfType(this, javaClass<T>())
}
inline public fun PsiElement.getChildrenOfType<reified T : PsiElement>(): Array<T> {
inline public fun <reified T : PsiElement> PsiElement.getChildrenOfType(): Array<T> {
return PsiTreeUtil.getChildrenOfType(this, javaClass<T>()) ?: arrayOf()
}
@@ -148,7 +148,7 @@ public fun <T : PsiElement> T.getIfChildIsInBranch(element: PsiElement, branch:
return if (branch().isAncestor(element)) this else null
}
public inline fun PsiElement.getParentOfTypeAndBranch<reified T : PsiElement>(strict: Boolean = false, noinline branch: T.() -> PsiElement?): T? {
public inline fun <reified T : PsiElement> PsiElement.getParentOfTypeAndBranch(strict: Boolean = false, noinline branch: T.() -> PsiElement?): T? {
return getParentOfType<T>(strict)?.getIfChildIsInBranch(this, branch)
}
@@ -88,7 +88,7 @@ public abstract class PerformanceCounter protected constructor(val name: String)
count++
}
public final fun time<T>(block: () -> T): T {
public final fun <T> time(block: () -> T): T {
count++
if (!enabled) return block()
@@ -110,7 +110,7 @@ public abstract class PerformanceCounter protected constructor(val name: String)
totalTimeNanos += delta
}
protected abstract fun countTime<T>(block: () -> T): T
protected abstract fun <T> countTime(block: () -> T): T
public fun report(consumer: (String) -> Unit) {
if (totalTimeNanos == 0L) {
@@ -39,7 +39,7 @@ public fun <T> Collection<T>?.concat(collection: Collection<T>): Collection<T>?
return result
}
public fun concatInOrder<T>(c1: Collection<T>?, c2: Collection<T>?): Collection<T> {
public fun <T> concatInOrder(c1: Collection<T>?, c2: Collection<T>?): Collection<T> {
val result = if (c1 == null || c1.isEmpty())
c2
else if (c2 == null || c2.isEmpty())
@@ -53,7 +53,7 @@ public fun concatInOrder<T>(c1: Collection<T>?, c2: Collection<T>?): Collection<
return result ?: emptySet()
}
public inline fun getFromAllScopes<Scope, T>(scopes: Array<out Scope>, callback: (Scope) -> Collection<T>): Collection<T> {
public inline fun <Scope, T> getFromAllScopes(scopes: Array<out Scope>, callback: (Scope) -> Collection<T>): Collection<T> {
if (scopes.isEmpty()) return emptySet()
var result: Collection<T>? = null
for (scope in scopes) {
@@ -62,7 +62,7 @@ public inline fun getFromAllScopes<Scope, T>(scopes: Array<out Scope>, callback:
return result ?: emptySet()
}
public inline fun getFirstMatch<Scope, T : Any>(scopes: Array<out Scope>, callback: (Scope) -> T?): T? {
public inline fun <Scope, T : Any> getFirstMatch(scopes: Array<out Scope>, callback: (Scope) -> T?): T? {
// NOTE: This is performance-sensitive; please don't replace with map().firstOrNull()
for (scope in scopes) {
val result = callback(scope)
@@ -61,7 +61,7 @@ public class HierarchySearchRequest<T: PsiElement> (
override val searchScope: SearchScope,
val searchDeeply: Boolean = true
) : SearchRequestWithElement<T> {
fun copy<U: PsiElement>(newOriginalElement: U): HierarchySearchRequest<U> =
fun <U: PsiElement> copy(newOriginalElement: U): HierarchySearchRequest<U> =
HierarchySearchRequest(newOriginalElement, searchScope, searchDeeply)
}
@@ -21,14 +21,14 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.stubs.KotlinCallableStubBase
import org.jetbrains.kotlin.util.aliasImportMap
fun indexTopLevelExtension<TDeclaration : KtCallableDeclaration>(stub: KotlinCallableStubBase<TDeclaration>, sink: IndexSink) {
fun <TDeclaration : KtCallableDeclaration> indexTopLevelExtension(stub: KotlinCallableStubBase<TDeclaration>, sink: IndexSink) {
if (stub.isExtension()) {
val declaration = stub.getPsi()
declaration.getReceiverTypeReference()!!.typeElement?.index(declaration, sink)
}
}
private fun KtTypeElement.index<TDeclaration : KtCallableDeclaration>(declaration: TDeclaration, sink: IndexSink) {
private fun <TDeclaration : KtCallableDeclaration> KtTypeElement.index(declaration: TDeclaration, sink: IndexSink) {
fun occurrence(typeName: String) {
val name = declaration.getName() ?: return
sink.occurrence(KotlinTopLevelExtensionsByReceiverTypeIndex.INSTANCE.getKey(),
@@ -21,11 +21,11 @@ import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
public fun runReadAction<T>(action: () -> T): T {
public fun <T> runReadAction(action: () -> T): T {
return ApplicationManager.getApplication().runReadAction<T>(action)
}
public fun runWriteAction<T>(action: () -> T): T {
public fun <T> runWriteAction(action: () -> T): T {
return ApplicationManager.getApplication().runWriteAction<T>(action)
}
@@ -342,7 +342,7 @@ public fun KtElement.getContextForContainingDeclarationBody(): BindingContext? {
return bodyElement?.let { it.analyze() }
}
public fun chooseContainerElement<T>(
public fun <T> chooseContainerElement(
containers: List<T>,
editor: Editor,
title: String,
@@ -415,7 +415,7 @@ public fun chooseContainerElement<T>(
).showInBestPositionFor(editor)
}
public fun chooseContainerElementIfNecessary<T>(
public fun <T> chooseContainerElementIfNecessary(
containers: List<T>,
editor: Editor,
title: String,
@@ -462,7 +462,7 @@ private fun copyModifierListItems(from: PsiModifierList, to: PsiModifierList, wi
}
}
private fun copyTypeParameters<T>(
private fun <T> copyTypeParameters(
from: T,
to: T,
inserter: (T, PsiTypeParameterList) -> Unit
@@ -522,7 +522,7 @@ public class KotlinPsiUnifier(
return (!decl1.isNameRelevant() && !decl2.isNameRelevant()) || desc1.getName() == desc2.getName()
}
private fun matchContainedDescriptors<T: DeclarationDescriptor>(
private fun <T: DeclarationDescriptor> matchContainedDescriptors(
declarations1: List<T>,
declarations2: List<T>,
matchPair: (Pair<T, T>) -> Boolean
@@ -99,7 +99,7 @@ public abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixture
}
}
protected fun chooseMembers<T : MemberInfoBase<*>>(members: List<T>): List<T> {
protected fun <T : MemberInfoBase<*>> chooseMembers(members: List<T>): List<T> {
members.forEach {
val info = it.member.elementInfo
it.isChecked = info.checked
@@ -52,7 +52,7 @@ public class KotlinReferencesSearchTest(): AbstractSearcherTest() {
// workaround for KT-9788 AssertionError from backand when we read field from inline function
private val myFixtureProxy: JavaCodeInsightTestFixture get() = myFixture
private inline fun doTest<reified T: PsiElement>(): List<PsiReference> {
private inline fun <reified T: PsiElement> doTest(): List<PsiReference> {
myFixtureProxy.configureByFile(getFileName())
val func = myFixtureProxy.getElementAtCaret().getParentOfType<T>(false)!!
return ReferencesSearch.search(func).findAll().sortedBy { it.getElement().getTextRange().getStartOffset() }
@@ -238,7 +238,7 @@ public class JavaToKotlinConverter(
private var fraction = 0.0
private var pass = 1
fun processItems<TInputItem, TOutputItem>(
fun <TInputItem, TOutputItem> processItems(
fractionPortion: Double,
inputItems: Iterable<TInputItem>,
processItem: (TInputItem) -> TOutputItem
@@ -292,7 +292,7 @@ internal class ExpressionDecomposer private constructor(
}
inline
private fun withNewAdditionalStatements<T>(fn: ()->T): T {
private fun <T> withNewAdditionalStatements(fn: ()->T): T {
val backup = additionalStatements
additionalStatements = SmartList<JsStatement>()
val result = fn()
@@ -68,7 +68,7 @@ public fun collectNamedFunctions(scope: JsNode): IdentityHashMap<JsName, JsFunct
return namedFunctions
}
public fun collectInstances<T : JsNode>(klass: Class<T>, scope: JsNode): List<T> {
public fun <T : JsNode> collectInstances(klass: Class<T>, scope: JsNode): List<T> {
return with(InstanceCollector(klass, visitNestedDeclarations = false)) {
accept(scope)
collected
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.js.inline.util
import java.util.Collections
import java.util.IdentityHashMap
public fun IdentitySet<T>(): MutableSet<T> {
public fun <T> IdentitySet(): MutableSet<T> {
return Collections.newSetFromMap(IdentityHashMap<T, Boolean>())
}
@@ -30,6 +30,6 @@ public fun <T : JsNode> replaceNames(node: T, replaceMap: IdentityHashMap<JsName
return NameReplacingVisitor(replaceMap).accept(node)!!
}
public fun replaceThisReference<T : JsNode>(node: T, replacement: JsExpression) {
public fun <T : JsNode> replaceThisReference(node: T, replacement: JsExpression) {
ThisReplacingVisitor(replacement).accept(node)
}
+5 -5
View File
@@ -16,18 +16,18 @@
package java.util
public fun HashSet<E>(c: Collection<E>): HashSet<E>
public fun <E> HashSet(c: Collection<E>): HashSet<E>
= HashSet<E>(c.size()).apply { addAll(c) }
public fun LinkedHashSet<E>(c: Collection<E>): HashSet<E>
public fun <E> LinkedHashSet(c: Collection<E>): HashSet<E>
= LinkedHashSet<E>(c.size()).apply { addAll(c) }
public fun HashMap<K, V>(m: Map<K, V>): HashMap<K, V>
public fun <K, V> HashMap(m: Map<K, V>): HashMap<K, V>
= HashMap<K, V>(m.size()).apply { putAll(m) }
public fun LinkedHashMap<K, V>(m: Map<K, V>): LinkedHashMap<K, V>
public fun <K, V> LinkedHashMap(m: Map<K, V>): LinkedHashMap<K, V>
= LinkedHashMap<K, V>(m.size()).apply { putAll(m) }
public fun ArrayList<E>(c: Collection<E>): ArrayList<E>
public fun <E> ArrayList(c: Collection<E>): ArrayList<E>
= ArrayList<E>().apply { asDynamic().array = c.toTypedArray<Any?>() } // black dynamic magic
@@ -4,7 +4,7 @@ import java.lang.*
import java.util.*
public object Collections {
public fun max<T>(col: Collection<T>, comp: Comparator<in T>): T = java.util.max(col, comp)
public fun <T> max(col: Collection<T>, comp: Comparator<in T>): T = java.util.max(col, comp)
@Deprecated("Use list.sort() instead.", ReplaceWith("list.sort()"))
public fun <T: Comparable<T>> sort(list: MutableList<T>): Unit = java.util.sort(list, naturalOrder())
@@ -25,7 +25,7 @@ public object Collections {
}
@library("collectionsMax")
private fun max<T>(col: Collection<T>, comp: Comparator<in T>): T = noImpl
private fun <T> max(col: Collection<T>, comp: Comparator<in T>): T = noImpl
@library("collectionsSort")
private fun <T> sort(list: MutableList<T>, comparator: Comparator<in T>): Unit = noImpl
+2 -2
View File
@@ -26,8 +26,8 @@ public interface JsonClass {
public fun stringify(o: Any, replacer: Array<String>, space: Int): String
public fun stringify(o: Any, replacer: Array<String>, space: String): String
public fun parse<T>(text: String): T
public fun parse<T>(text: String, reviver: ((key: String, value: Any?)->Any?)): T
public fun <T> parse(text: String): T
public fun <T> parse(text: String, reviver: ((key: String, value: Any?)->Any?)): T
}
@native
+6 -6
View File
@@ -38,36 +38,36 @@ public fun <reified T> Collection<T>.toTypedArray(): Array<T> = noImpl
/**
* Returns an immutable list containing only the specified object [element].
*/
public fun listOf<T>(element: T): List<T> = arrayListOf(element)
public fun <T> listOf(element: T): List<T> = arrayListOf(element)
/**
* Returns an immutable set containing only the specified object [element].
*/
public fun setOf<T>(element: T): Set<T> = hashSetOf(element)
public fun <T> setOf(element: T): Set<T> = hashSetOf(element)
/**
* Returns an immutable map, mapping only the specified key to the
* specified value.
*/
public fun mapOf<K, V>(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*/
public fun lazy<T>(initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
public fun <T> lazy(initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [mode] parameter is ignored. */
public fun lazy<T>(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
public fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [lock] parameter is ignored.
*/
public fun lazy<T>(lock: Any?, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
public fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = UnsafeLazyImpl(initializer)
internal fun <T> arrayOfNulls(reference: Array<out T>, size: Int): Array<T> {
@@ -78,7 +78,7 @@ private fun parse(
}
inline
private fun Node.toJsAst<T>(scope: JsScope, mapAction: JsAstMapper.(Node)->T): T =
private fun <T> Node.toJsAst(scope: JsScope, mapAction: JsAstMapper.(Node)->T): T =
JsAstMapper(scope).mapAction(this)
private fun StringReader(string: String, offset: Int): Reader {