Merge pull request #296 from mhshams/master
KT-3715 make Collection.notEmpty a property
This commit is contained in:
@@ -17,7 +17,7 @@ public inline fun String.matches(regex : String) : Boolean {
|
|||||||
* @includeFunctionBody ../../test/StringTest.kt capitalize
|
* @includeFunctionBody ../../test/StringTest.kt capitalize
|
||||||
*/
|
*/
|
||||||
public inline fun String.capitalize(): String {
|
public inline fun String.capitalize(): String {
|
||||||
return if (notEmpty()) substring(0, 1).toUpperCase() + substring(1) else this
|
return if (isNotEmpty()) substring(0, 1).toUpperCase() + substring(1) else this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,5 +26,5 @@ public inline fun String.capitalize(): String {
|
|||||||
* @includeFunctionBody ../../test/StringTest.kt decapitalize
|
* @includeFunctionBody ../../test/StringTest.kt decapitalize
|
||||||
*/
|
*/
|
||||||
public inline fun String.decapitalize(): String {
|
public inline fun String.decapitalize(): String {
|
||||||
return if (notEmpty()) substring(0, 1).toLowerCase() + substring(1) else this
|
return if (isNotEmpty()) substring(0, 1).toLowerCase() + substring(1) else this
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package kotlin
|
package kotlin
|
||||||
|
|
||||||
/** Returns true if the array is not empty */
|
/** Returns true if the array is not empty */
|
||||||
public inline fun <T> Array<T>.notEmpty() : Boolean = !this.isEmpty()
|
public inline fun <T> Array<T>.isNotEmpty() : Boolean = !this.isEmpty()
|
||||||
|
|
||||||
/** Returns true if the array is empty */
|
/** Returns true if the array is empty */
|
||||||
public inline fun <T> Array<T>.isEmpty() : Boolean = this.size == 0
|
public inline fun <T> Array<T>.isEmpty() : Boolean = this.size == 0
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ val Int.indices: IntRange
|
|||||||
get() = 0..this-1
|
get() = 0..this-1
|
||||||
|
|
||||||
/** Returns true if the collection is not empty */
|
/** Returns true if the collection is not empty */
|
||||||
public inline fun <T> Collection<T>.notEmpty() : Boolean = !this.isEmpty()
|
public inline fun <T> Collection<T>.isNotEmpty() : Boolean = !this.isEmpty()
|
||||||
|
|
||||||
|
/** Returns true if this collection is not empty */
|
||||||
|
val Collection<*>.notEmpty : Boolean
|
||||||
|
get() = isNotEmpty()
|
||||||
|
|
||||||
/** Returns the Collection if its not null otherwise it returns the empty list */
|
/** Returns the Collection if its not null otherwise it returns the empty list */
|
||||||
public inline fun <T> Collection<T>?.orEmpty() : Collection<T>
|
public inline fun <T> Collection<T>?.orEmpty() : Collection<T>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public inline fun String.trimTrailing(postfix: String): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if the string is not null and not empty */
|
/** Returns true if the string is not null and not empty */
|
||||||
public inline fun String?.notEmpty() : Boolean = this != null && this.length() > 0
|
public inline fun String?.isNotEmpty() : Boolean = this != null && this.length() > 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Iterator for characters of given CharSequence
|
Iterator for characters of given CharSequence
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ get() = length()
|
|||||||
* @includeFunctionBody ../../test/StringTest.kt capitalize
|
* @includeFunctionBody ../../test/StringTest.kt capitalize
|
||||||
*/
|
*/
|
||||||
public inline fun String.capitalize(): String {
|
public inline fun String.capitalize(): String {
|
||||||
return if (notEmpty() && charAt(0).isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this
|
return if (isNotEmpty() && charAt(0).isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,7 +188,7 @@ public inline fun String.capitalize(): String {
|
|||||||
* @includeFunctionBody ../../test/StringTest.kt decapitalize
|
* @includeFunctionBody ../../test/StringTest.kt decapitalize
|
||||||
*/
|
*/
|
||||||
public inline fun String.decapitalize(): String {
|
public inline fun String.decapitalize(): String {
|
||||||
return if (notEmpty() && charAt(0).isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this
|
return if (isNotEmpty() && charAt(0).isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
|||||||
val scope = descriptor.getMemberScope()
|
val scope = descriptor.getMemberScope()
|
||||||
addFunctions(pkg, scope)
|
addFunctions(pkg, scope)
|
||||||
pkg.local = isLocal(descriptor)
|
pkg.local = isLocal(descriptor)
|
||||||
pkg.useExternalLink = pkg.model.config.resolveLink(pkg.name, false).notEmpty()
|
pkg.useExternalLink = pkg.model.config.resolveLink(pkg.name, false).isNotEmpty()
|
||||||
|
|
||||||
if (pkg.wikiDescription.isEmpty()) {
|
if (pkg.wikiDescription.isEmpty()) {
|
||||||
// lets try find a custom doc
|
// lets try find a custom doc
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
return if (c != null) {
|
return if (c != null) {
|
||||||
val prefix = if (c.isAnnotation()) "@" else ""
|
val prefix = if (c.isAnnotation()) "@" else ""
|
||||||
val cname = c.name
|
val cname = c.name
|
||||||
if ((cname.startsWith("jet.Function") || cname.startsWith("jet.ExtensionFunction")) && arguments.notEmpty()) {
|
if ((cname.startsWith("jet.Function") || cname.startsWith("jet.ExtensionFunction")) && arguments.isNotEmpty()) {
|
||||||
val rt = arguments.last()
|
val rt = arguments.last()
|
||||||
// TODO use drop()
|
// TODO use drop()
|
||||||
val rest = arguments.subList(0, arguments.size - 1).orEmpty()
|
val rest = arguments.subList(0, arguments.size - 1).orEmpty()
|
||||||
|
|||||||
Vendored
+1
-1
@@ -103,7 +103,7 @@ ${stylesheets()}
|
|||||||
}
|
}
|
||||||
protected fun printPackageProperties(): Unit {
|
protected fun printPackageProperties(): Unit {
|
||||||
val list = pkg.packageProperties()
|
val list = pkg.packageProperties()
|
||||||
if (list.notEmpty()) {
|
if (list.isNotEmpty()) {
|
||||||
println("""<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
println("""<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||||
<TR>
|
<TR>
|
||||||
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">Properties</FONT>
|
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">Properties</FONT>
|
||||||
|
|||||||
Vendored
+3
-3
@@ -17,7 +17,7 @@ abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
|||||||
protected fun keyword(name: String): String = "<B>$name</B>"
|
protected fun keyword(name: String): String = "<B>$name</B>"
|
||||||
|
|
||||||
fun printFunctionSummary(functions: Collection<KFunction>): Unit {
|
fun printFunctionSummary(functions: Collection<KFunction>): Unit {
|
||||||
if (functions.notEmpty()) {
|
if (functions.isNotEmpty()) {
|
||||||
println("""<!-- ========== FUNCTION SUMMARY =========== -->
|
println("""<!-- ========== FUNCTION SUMMARY =========== -->
|
||||||
|
|
||||||
<A NAME="method_summary"><!-- --></A>
|
<A NAME="method_summary"><!-- --></A>
|
||||||
@@ -90,7 +90,7 @@ abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun printFunctionDetail(functions: Collection<KFunction>): Unit {
|
fun printFunctionDetail(functions: Collection<KFunction>): Unit {
|
||||||
if (functions.notEmpty()) {
|
if (functions.isNotEmpty()) {
|
||||||
println("""
|
println("""
|
||||||
|
|
||||||
<!-- ============ FUNCTION DETAIL ========== -->
|
<!-- ============ FUNCTION DETAIL ========== -->
|
||||||
@@ -159,7 +159,7 @@ abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun printPropertySummary(properties: Collection<KProperty>): Unit {
|
fun printPropertySummary(properties: Collection<KProperty>): Unit {
|
||||||
if (properties.notEmpty()) {
|
if (properties.isNotEmpty()) {
|
||||||
println("""<!-- ========== PROPERTY SUMMARY =========== -->
|
println("""<!-- ========== PROPERTY SUMMARY =========== -->
|
||||||
|
|
||||||
<A NAME="method_summary"><!-- --></A>
|
<A NAME="method_summary"><!-- --></A>
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ import js.noImpl
|
|||||||
}
|
}
|
||||||
val fields = klass.getDeclaredFields()
|
val fields = klass.getDeclaredFields()
|
||||||
if (fields != null) {
|
if (fields != null) {
|
||||||
if (fields.notEmpty()) {
|
if (fields.isNotEmpty()) {
|
||||||
println("")
|
println("")
|
||||||
println(" public class object {")
|
println(" public class object {")
|
||||||
for (field in fields) {
|
for (field in fields) {
|
||||||
|
|||||||
Reference in New Issue
Block a user