Skip to content

Commit

Permalink
Write errors after generating classes (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
elihart authored Feb 16, 2017
1 parent ae898f3 commit 7d70008
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,12 @@ public int hashCode() {
return result;
}
}

@Override
public String toString() {
return "ClassToGenerateInfo{"
+ "attributeInfo=" + attributeInfo
+ ", originalClassElement=" + originalClassElement
+ '}';
}
}
15 changes: 11 additions & 4 deletions epoxy-processor/src/main/java/com/airbnb/epoxy/ConfigManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.airbnb.epoxy;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand All @@ -10,7 +12,7 @@
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;

import static com.airbnb.epoxy.ProcessorUtils.throwError;
import static com.airbnb.epoxy.ProcessorUtils.buildEpoxyException;

/** Manages configuration settings for different packages. */
class ConfigManager {
Expand All @@ -24,23 +26,28 @@ class ConfigManager {
this.elementUtils = elementUtils;
}

void processConfigurations(RoundEnvironment roundEnv) throws EpoxyProcessorException {
List<Exception> processConfigurations(RoundEnvironment roundEnv) {
configurationMap.clear();

Set<? extends Element> annotatedElements =
roundEnv.getElementsAnnotatedWith(PackageEpoxyConfig.class);

List<Exception> errors = new ArrayList<>();

for (Element element : annotatedElements) {
String packageName = elementUtils.getPackageOf(element).getQualifiedName().toString();

if (configurationMap.containsKey(packageName)) {
throwError("Only one Epoxy configuration annotation is allowed per package (%s)",
packageName);
errors.add(buildEpoxyException(
"Only one Epoxy configuration annotation is allowed per package (%s)",
packageName));
}

PackageEpoxyConfig annotation = element.getAnnotation(PackageEpoxyConfig.class);
configurationMap.put(packageName, PackageConfigSettings.create(annotation));
}

return errors;
}

boolean requiresHashCode(AttributeInfo attributeInfo) {
Expand Down
Loading

0 comments on commit 7d70008

Please sign in to comment.