Search in sources :

Example 1 with Layout

use of com.github.davityle.ngprocessor.model.Layout in project ngAndroid by davityle.

the class NgProcessor method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    this.roundEnv = roundEnv;
    if (annotations.size() == 0)
        return false;
    try {
        this.dependencyComponent = dependencyComponentBuilder.environmentModule(new EnvironmentModule(envModule.getOrElse(new ResolverImpl()))).build();
        final MessageUtils messageUtils = dependencyComponent.createMessageUtils();
        messageUtils.note(Option.<Element>absent(), ":NgAndroid:processing");
        Option<String> manifestPackageName = getPackageNameFromAndroidManifest();
        if (manifestPackageName.isAbsent()) {
            messageUtils.error(Option.<Element>absent(), ":NgAndroid:Unable to find android manifest.");
            return false;
        }
        Set<Scope> scopes = getScopeSet(annotations);
        Map<Layout, Collection<XmlScope>> xmlScopes = getXmlScopes();
        if (messageUtils.hasErrors())
            return false;
        Map<Layout, Collection<Scope>> layoutsWScopes = mapLayoutsToScopes(scopes, xmlScopes);
        Collection<LayoutSourceLink> layoutSourceLinks = getLayoutSourceLinks(layoutsWScopes, manifestPackageName.get());
        Collection<ScopeSourceLink> scopeSourceLinks = getScopeSourceLinks(scopes, manifestPackageName.get());
        List<NgModelSourceLink> modelSourceLinks = getModelSourceLinks(getModels(annotations));
        createSourceFiles(modelSourceLinks, layoutSourceLinks, scopeSourceLinks);
        messageUtils.note(Option.<Element>absent(), ":NgAndroid:finished");
        return true;
    } catch (Throwable t) {
        StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "There was an error compiling your ngAttributes: " + sw.toString().replace('\n', ' '), null);
        return false;
    }
}
Also used : LayoutSourceLink(com.github.davityle.ngprocessor.source.links.LayoutSourceLink) NgModelSourceLink(com.github.davityle.ngprocessor.source.links.NgModelSourceLink) ScopeSourceLink(com.github.davityle.ngprocessor.source.links.ScopeSourceLink) XmlScope(com.github.davityle.ngprocessor.xml.XmlScope) Scope(com.github.davityle.ngprocessor.model.Scope) StringWriter(java.io.StringWriter) Layout(com.github.davityle.ngprocessor.model.Layout) Collection(java.util.Collection) MessageUtils(com.github.davityle.ngprocessor.util.MessageUtils) PrintWriter(java.io.PrintWriter)

Aggregations

Layout (com.github.davityle.ngprocessor.model.Layout)1 Scope (com.github.davityle.ngprocessor.model.Scope)1 LayoutSourceLink (com.github.davityle.ngprocessor.source.links.LayoutSourceLink)1 NgModelSourceLink (com.github.davityle.ngprocessor.source.links.NgModelSourceLink)1 ScopeSourceLink (com.github.davityle.ngprocessor.source.links.ScopeSourceLink)1 MessageUtils (com.github.davityle.ngprocessor.util.MessageUtils)1 XmlScope (com.github.davityle.ngprocessor.xml.XmlScope)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Collection (java.util.Collection)1