Implement CharSequence.isEmpty method in stdlib.js. Remove corresponding intrinsic.
This commit is contained in:
@@ -48,8 +48,6 @@ native public fun String.match(regex : String) : Array<String> = noImpl
|
||||
native("length")
|
||||
public val CharSequence.size: Int get() = noImpl
|
||||
|
||||
library
|
||||
public fun CharSequence.isEmpty(): Boolean = noImpl
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public inline fun String.matches(regex : String) : Boolean {
|
||||
return result != null && result.size() > 0
|
||||
}
|
||||
|
||||
public inline fun CharSequence.isEmpty(): Boolean = this.length() == 0
|
||||
|
||||
public fun String.isBlank(): Boolean = length() == 0 || matches("^[\\s\\xA0]+$")
|
||||
|
||||
|
||||
-10
@@ -35,16 +35,6 @@ public abstract class CompositeFIF implements FunctionIntrinsicFactory {
|
||||
@NotNull
|
||||
public static final FunctionIntrinsic LENGTH_PROPERTY_INTRINSIC = new BuiltInPropertyIntrinsic("length");
|
||||
public static final FunctionIntrinsic MESSAGE_PROPERTY_INTRINSIC = new BuiltInPropertyIntrinsic("message");
|
||||
public static final FunctionIntrinsic IS_EMPTY_INTRINSIC = new FunctionIntrinsic() {
|
||||
@NotNull
|
||||
@Override
|
||||
public JsExpression apply(
|
||||
@Nullable JsExpression receiver, @NotNull List<JsExpression> arguments, @NotNull TranslationContext context
|
||||
) {
|
||||
assert receiver != null;
|
||||
return JsAstUtils.equality(new JsNameRef("length", receiver), context.program().getNumberLiteral(0));
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
private final List<Pair<Predicate<FunctionDescriptor>, FunctionIntrinsic>> patternsAndIntrinsics = Lists.newArrayList();
|
||||
|
||||
-1
@@ -31,6 +31,5 @@ public final class StringOperationFIF extends CompositeFIF {
|
||||
add(pattern("kotlin", "CharSequence", "charAt").checkOverridden(), new BuiltInFunctionIntrinsic("charAt"));
|
||||
add(pattern("kotlin", "CharSequence", "length").checkOverridden(), LENGTH_PROPERTY_INTRINSIC);
|
||||
add(pattern("kotlin", "CharSequence", "subSequence").checkOverridden(), new BuiltInFunctionIntrinsic("substring"));
|
||||
add(pattern("kotlin.js", "isEmpty").isExtensionOf("kotlin.CharSequence"), IS_EMPTY_INTRINSIC);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user