mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 12:34:17 +00:00
Fix empty @ReactModuleList generated code
Reviewed By: AaaChiuuu Differential Revision: D5737684 fbshipit-source-id: dc9312f595da23390cda14d5092c92d1e0319b83
This commit is contained in:
parent
fe0d081229
commit
42713c917e
@ -21,6 +21,7 @@ import javax.lang.model.util.Elements;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -55,6 +56,7 @@ import static javax.tools.Diagnostic.Kind.ERROR;
|
|||||||
@SupportedSourceVersion(SourceVersion.RELEASE_7)
|
@SupportedSourceVersion(SourceVersion.RELEASE_7)
|
||||||
public class ReactModuleSpecProcessor extends AbstractProcessor {
|
public class ReactModuleSpecProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
|
private static final TypeName COLLECTIONS_TYPE = ParameterizedTypeName.get(Collections.class);
|
||||||
private static final TypeName MAP_TYPE = ParameterizedTypeName.get(
|
private static final TypeName MAP_TYPE = ParameterizedTypeName.get(
|
||||||
Map.class,
|
Map.class,
|
||||||
Class.class,
|
Class.class,
|
||||||
@ -145,7 +147,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
|
|||||||
throws ReactModuleSpecException {
|
throws ReactModuleSpecException {
|
||||||
CodeBlock.Builder builder = CodeBlock.builder();
|
CodeBlock.Builder builder = CodeBlock.builder();
|
||||||
if (nativeModules == null || nativeModules.isEmpty()) {
|
if (nativeModules == null || nativeModules.isEmpty()) {
|
||||||
builder.addStatement("return Collections.emptyMap()");
|
builder.addStatement("return $T.emptyMap()", COLLECTIONS_TYPE);
|
||||||
} else {
|
} else {
|
||||||
builder.addStatement("$T map = new $T()", MAP_TYPE, INSTANTIATED_MAP_TYPE);
|
builder.addStatement("$T map = new $T()", MAP_TYPE, INSTANTIATED_MAP_TYPE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user