Skip to content

Commit

Permalink
specific detail
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhao2007 committed Sep 30, 2017
1 parent 1f621f3 commit c0889c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Binary file modified annotation/build/libs/annotation.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.android.easyrouter.annotation.DisPatcher;
import com.android.easyrouter.annotation.DispatcherModules;
import com.android.easyrouter.annotation.ModuleService;
import com.android.easyrouter.compiler.exception.InvalidTargetException;
import com.google.auto.service.AutoService;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
Expand Down Expand Up @@ -67,6 +68,7 @@ public Set<String> getSupportedAnnotationTypes() {
Set<String> ret = new HashSet<>();
ret.add(DisPatcher.class.getCanonicalName());
ret.add(DispatcherModules.class.getCanonicalName());
ret.add(ModuleService.class.getCanonicalName());
return ret;
}

Expand Down Expand Up @@ -134,23 +136,21 @@ private TypeSpec generateModulesRouterInit(String[] moduleNames) {


private TypeSpec getRouterTableInitializer(Set<? extends Element> elements, Set<? extends Element> moduleServiceElements) throws ClassNotFoundException {

// error("执行!"+moduleName);
if (elements == null || elements.size() == 0) {
return null;
}
ParameterizedTypeName mapTypeName = ParameterizedTypeName
.get(ClassName.get(HashMap.class), ClassName.get(String.class),
ClassName.get(Class.class)) ;
ClassName.get(Class.class));
ParameterSpec mapParameterSpec = ParameterSpec.builder(mapTypeName, "activityMap")
.build();
MethodSpec.Builder routerInitBuilder = MethodSpec.methodBuilder("initActivityMap")
// .addAnnotation(Override.class)
.addAnnotation(Override.class)
.addModifiers(Modifier.PUBLIC)
.addParameter(mapParameterSpec);
for (Element element : elements) {
if (element.getKind() != ElementKind.CLASS) {
// throw new TargetErrorException();
throw new InvalidTargetException("DisPatcher must be used on class");
}
DisPatcher router = element.getAnnotation(DisPatcher.class);
String[] routerUrls = router.value();
Expand All @@ -168,7 +168,6 @@ private TypeSpec getRouterTableInitializer(Set<? extends Element> elements, Set<
ClassName.get((TypeElement) element), ClassName.get((TypeElement) element));
}


TypeElement routerInitializerType = elementUtils.getTypeElement("com.android.easyrouter.dispatcher.idispatcher.IActivityInitMap");
return TypeSpec.classBuilder(com.android.easyrouter.compiler.CompilerConstant.AutoCreateActivityMapPrefix + moduleName)
.addSuperinterface(ClassName.get(routerInitializerType))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.android.easyrouter.compiler.exception;

/**
* Created by liuzhao on 2017/9/30.
*/

public class InvalidTargetException extends RuntimeException {

public InvalidTargetException(String message) {
super(message);
}

}

0 comments on commit c0889c6

Please sign in to comment.