mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Code style fixes
This commit is contained in:
parent
5ecfb3620c
commit
933a5c3efc
|
@ -991,9 +991,12 @@ class JSClassProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isProperFunctor(ClassReader type) {
|
private boolean isProperFunctor(ClassReader type) {
|
||||||
return type.hasModifier(ElementModifier.INTERFACE)
|
if (!type.hasModifier(ElementModifier.INTERFACE)) {
|
||||||
&& type.getMethods().stream().filter(it->it.hasModifier(ElementModifier.ABSTRACT))
|
return false;
|
||||||
.toArray().length == 1;
|
}
|
||||||
|
return type.getMethods().stream()
|
||||||
|
.filter(method -> method.hasModifier(ElementModifier.ABSTRACT))
|
||||||
|
.count() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Variable wrapFunctor(CallLocation location, Variable var, ClassReader type) {
|
private Variable wrapFunctor(CallLocation location, Variable var, ClassReader type) {
|
||||||
|
@ -1002,7 +1005,8 @@ class JSClassProcessor {
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
String name = type.getMethods().stream()
|
String name = type.getMethods().stream()
|
||||||
.filter(it->it.hasModifier(ElementModifier.ABSTRACT)).findFirst().get().getName();
|
.filter(method -> method.hasModifier(ElementModifier.ABSTRACT))
|
||||||
|
.findFirst().get().getName();
|
||||||
Variable functor = program.createVariable();
|
Variable functor = program.createVariable();
|
||||||
Variable nameVar = addStringWrap(addString(name, location.getSourceLocation()), location.getSourceLocation());
|
Variable nameVar = addStringWrap(addString(name, location.getSourceLocation()), location.getSourceLocation());
|
||||||
InvokeInstruction insn = new InvokeInstruction();
|
InvokeInstruction insn = new InvokeInstruction();
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class FunctorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void functorWithDefaultMethodPassed(){
|
public void functorWithDefaultMethodPassed() {
|
||||||
JSFunctionWithDefaultMethod javaFunction = (s) -> s+" returned";
|
JSFunctionWithDefaultMethod javaFunction = (s) -> s + " returned";
|
||||||
|
|
||||||
String returned = javaFunction.defaultMethod();
|
String returned = javaFunction.defaultMethod();
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ public class FunctorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void functorWithStaticMethodPassed(){
|
public void functorWithStaticMethodPassed() {
|
||||||
JSFunctionWithStaticMethod javaFunction = (s) -> s+" returned";
|
JSFunctionWithStaticMethod javaFunction = (s) -> s + " returned";
|
||||||
|
|
||||||
String returned = javaFunction.apply(JSFunctionWithStaticMethod.staticMethod());
|
String returned = javaFunction.apply(JSFunctionWithStaticMethod.staticMethod());
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class FunctorTest {
|
||||||
interface JSFunctionWithDefaultMethod extends JSObject {
|
interface JSFunctionWithDefaultMethod extends JSObject {
|
||||||
String apply(String a);
|
String apply(String a);
|
||||||
|
|
||||||
default String defaultMethod(){
|
default String defaultMethod() {
|
||||||
return apply("Content");
|
return apply("Content");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class FunctorTest {
|
||||||
interface JSFunctionWithStaticMethod extends JSObject {
|
interface JSFunctionWithStaticMethod extends JSObject {
|
||||||
String apply(String a);
|
String apply(String a);
|
||||||
|
|
||||||
public static String staticMethod(){
|
static String staticMethod() {
|
||||||
return "Content";
|
return "Content";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user