Merge branch '1.2.x'
This commit is contained in:
@@ -95,11 +95,13 @@ public class MetadataCollector {
|
||||
|
||||
private boolean shouldBeMerged(ItemMetadata itemMetadata) {
|
||||
String sourceType = itemMetadata.getSourceType();
|
||||
return (sourceType != null && !deletedInCurrentBuild(sourceType) && !processedInCurrentBuild(sourceType));
|
||||
return (sourceType != null && !deletedInCurrentBuild(sourceType)
|
||||
&& !processedInCurrentBuild(sourceType));
|
||||
}
|
||||
|
||||
private boolean deletedInCurrentBuild(String sourceType) {
|
||||
return this.processingEnvironment.getElementUtils().getTypeElement(sourceType) == null;
|
||||
return this.processingEnvironment.getElementUtils()
|
||||
.getTypeElement(sourceType) == null;
|
||||
}
|
||||
|
||||
private boolean processedInCurrentBuild(String sourceType) {
|
||||
|
||||
@@ -97,21 +97,21 @@ public class MetadataStore {
|
||||
}
|
||||
|
||||
private FileObject getMetadataResource() throws IOException {
|
||||
FileObject resource = this.environment.getFiler().getResource(
|
||||
StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
|
||||
FileObject resource = this.environment.getFiler()
|
||||
.getResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
|
||||
return resource;
|
||||
}
|
||||
|
||||
private FileObject createMetadataResource() throws IOException {
|
||||
FileObject resource = this.environment.getFiler().createResource(
|
||||
StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
|
||||
FileObject resource = this.environment.getFiler()
|
||||
.createResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
|
||||
return resource;
|
||||
}
|
||||
|
||||
private InputStream getAdditionalMetadataStream() throws IOException {
|
||||
// Most build systems will have copied the file to the class output location
|
||||
FileObject fileObject = this.environment.getFiler().getResource(
|
||||
StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
|
||||
FileObject fileObject = this.environment.getFiler()
|
||||
.getResource(StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
|
||||
File file = new File(fileObject.toUri());
|
||||
if (!file.exists()) {
|
||||
// Gradle keeps things separate
|
||||
@@ -123,8 +123,8 @@ public class MetadataStore {
|
||||
file = new File(path);
|
||||
}
|
||||
}
|
||||
return (file.exists() ? new FileInputStream(file) : fileObject.toUri().toURL()
|
||||
.openStream());
|
||||
return (file.exists() ? new FileInputStream(file)
|
||||
: fileObject.toUri().toURL().openStream());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ class TypeElementMembers {
|
||||
}
|
||||
|
||||
private void process(TypeElement element) {
|
||||
for (ExecutableElement method : ElementFilter.methodsIn(element
|
||||
.getEnclosedElements())) {
|
||||
for (ExecutableElement method : ElementFilter
|
||||
.methodsIn(element.getEnclosedElements())) {
|
||||
processMethod(method);
|
||||
}
|
||||
for (VariableElement field : ElementFilter
|
||||
@@ -95,14 +95,14 @@ class TypeElementMembers {
|
||||
}
|
||||
|
||||
private boolean isSetterReturnType(ExecutableElement method) {
|
||||
return (TypeKind.VOID == method.getReturnType().getKind() || this.env
|
||||
.getTypeUtils().isSameType(method.getEnclosingElement().asType(),
|
||||
method.getReturnType()));
|
||||
return (TypeKind.VOID == method.getReturnType().getKind()
|
||||
|| this.env.getTypeUtils().isSameType(
|
||||
method.getEnclosingElement().asType(), method.getReturnType()));
|
||||
}
|
||||
|
||||
private String getAccessorName(String methodName) {
|
||||
String name = methodName.startsWith("is") ? methodName.substring(2) : methodName
|
||||
.substring(3);
|
||||
String name = methodName.startsWith("is") ? methodName.substring(2)
|
||||
: methodName.substring(3);
|
||||
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import javax.lang.model.util.Types;
|
||||
class TypeUtils {
|
||||
|
||||
private static final Map<TypeKind, Class<?>> PRIMITIVE_WRAPPERS;
|
||||
|
||||
static {
|
||||
Map<TypeKind, Class<?>> wrappers = new HashMap<TypeKind, Class<?>>();
|
||||
wrappers.put(TypeKind.BOOLEAN, Boolean.class);
|
||||
@@ -63,8 +64,9 @@ class TypeUtils {
|
||||
this.env = env;
|
||||
Types types = env.getTypeUtils();
|
||||
WildcardType wc = types.getWildcardType(null, null);
|
||||
this.collectionType = types.getDeclaredType(this.env.getElementUtils()
|
||||
.getTypeElement(Collection.class.getName()), wc);
|
||||
this.collectionType = types.getDeclaredType(
|
||||
this.env.getElementUtils().getTypeElement(Collection.class.getName()),
|
||||
wc);
|
||||
this.mapType = types.getDeclaredType(
|
||||
this.env.getElementUtils().getTypeElement(Map.class.getName()), wc, wc);
|
||||
}
|
||||
@@ -108,8 +110,8 @@ class TypeUtils {
|
||||
}
|
||||
|
||||
public String getJavaDoc(Element element) {
|
||||
String javadoc = (element == null ? null : this.env.getElementUtils()
|
||||
.getDocComment(element));
|
||||
String javadoc = (element == null ? null
|
||||
: this.env.getElementUtils().getDocComment(element));
|
||||
if (javadoc != null) {
|
||||
javadoc = javadoc.trim();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
|
||||
private static class FieldCollector implements TreeVisitor {
|
||||
|
||||
private static final Map<String, Class<?>> WRAPPER_TYPES;
|
||||
|
||||
static {
|
||||
Map<String, Class<?>> types = new HashMap<String, Class<?>>();
|
||||
types.put("boolean", Boolean.class);
|
||||
@@ -76,6 +77,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
|
||||
}
|
||||
|
||||
private static final Map<Class<?>, Object> DEFAULT_TYPE_VALUES;
|
||||
|
||||
static {
|
||||
Map<Class<?>, Object> values = new HashMap<Class<?>, Object>();
|
||||
values.put(Boolean.class, false);
|
||||
@@ -87,6 +89,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
|
||||
}
|
||||
|
||||
private static final Map<String, Object> WELL_KNOWN_STATIC_FINALS;
|
||||
|
||||
static {
|
||||
Map<String, Object> values = new HashMap<String, Object>();
|
||||
values.put("Boolean.TRUE", true);
|
||||
|
||||
@@ -41,9 +41,11 @@ class Tree extends ReflectionWrapper {
|
||||
}
|
||||
|
||||
public void accept(TreeVisitor visitor) throws Exception {
|
||||
this.acceptMethod.invoke(getInstance(), Proxy.newProxyInstance(getInstance()
|
||||
.getClass().getClassLoader(), new Class<?>[] { this.treeVisitorType },
|
||||
new TreeVisitorInvocationHandler(visitor)), 0);
|
||||
this.acceptMethod.invoke(getInstance(),
|
||||
Proxy.newProxyInstance(getInstance().getClass().getClassLoader(),
|
||||
new Class<?>[] { this.treeVisitorType },
|
||||
new TreeVisitorInvocationHandler(visitor)),
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +61,8 @@ class Tree extends ReflectionWrapper {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
public Object invoke(Object proxy, Method method, Object[] args)
|
||||
throws Throwable {
|
||||
if (method.getName().equals("visitClass")) {
|
||||
if ((Integer) args[1] == 0) {
|
||||
Iterable members = (Iterable) Tree.this.GET_CLASS_TREE_MEMBERS
|
||||
|
||||
Reference in New Issue
Block a user