Package juzu.impl.common

Examples of juzu.impl.common.Name


    return Collections.<Class<? extends java.lang.annotation.Annotation>>singleton(Less.class);
  }

  @Override
  public void processAnnotationAdded(ModuleMetaModel metaModel, AnnotationKey key, AnnotationState added) {
    Name pkg = key.getElement().getPackageName();
    log.info("Adding less annotation for package " + pkg);
    annotations.put(pkg, added);
  }
View Full Code Here


    annotations.put(pkg, added);
  }

  @Override
  public void processAnnotationRemoved(ModuleMetaModel metaModel, AnnotationKey key, AnnotationState removed) {
    Name pkg = key.getElement().getPackageName();
    log.info("Removing less annotation for package " + pkg);
    annotations.remove(pkg);
  }
View Full Code Here

    annotations = null;

    //
    for (Map.Entry<Name, AnnotationState> entry : clone.entrySet()) {
      AnnotationState annotation = entry.getValue();
      Name pkg = entry.getKey();
      ProcessingContext env = metaModel.processingContext;
      ElementHandle.Package pkgHandle = ElementHandle.Package.create(pkg);
      PackageElement pkgElt = env.get(pkgHandle);
      Boolean minify = (Boolean)annotation.get("minify");
      List<String> resources = (List<String>)annotation.get("value");

      // WARNING THIS IS NOT CORRECT BUT WORK FOR NOW
      AnnotationMirror annotationMirror = Tools.getAnnotation(pkgElt, Less.class.getName());

      //
      log.info("Handling less annotation for package " + pkg + ": minify=" + minify + " resources=" + resources);

      //
      if (resources != null && resources.size() > 0) {

        // For now we use the hardcoded assets package
        Name assetPkg = pkg.append("assets");

        //
        CompilerLessContext clc = new CompilerLessContext(env, pkgHandle, assetPkg);

        //
        for (String resource : resources) {
          log.info("Processing declared resource " + resource);

          //
          Path path;
          try {
            path = Path.parse(resource);
          }
          catch (IllegalArgumentException e) {
            throw MALFORMED_PATH.failure(pkgElt, annotationMirror, resource).initCause(e);
          }

          //
          Path.Absolute to = assetPkg.resolve(path.as("css"));
          log.info("Resource " + resource + " destination resolved to " + to);

          //
          Lesser lesser;
          Result result;
View Full Code Here

    }

    public static Method create(ExecutableElement elt) {
      TypeElement typeElt = (TypeElement)elt.getEnclosingElement();
      String name = elt.getSimpleName().toString();
      Name fqn = Name.parse(typeElt.getQualifiedName().toString());
      ArrayList<String> parameterTypes = new ArrayList<String>();
      for (TypeMirror parameterType : ((ExecutableType)elt.asType()).getParameterTypes()) {
        parameterTypes.add(parameterType.toString());
      }
View Full Code Here

  public static class Field extends ElementHandle<VariableElement> {

    public static Field create(VariableElement elt) {
      TypeElement typeElt = (TypeElement)elt.getEnclosingElement();
      String name = elt.getSimpleName().toString();
      Name fqn = Name.parse(typeElt.getQualifiedName().toString());
      return new Field(fqn, name);
    }
View Full Code Here

      String simpleName = (String)annotation.get("name");
      String resourceBundle = (String)annotation.get("resourceBundle");
      if (simpleName == null) {
        simpleName = metaModel.getBaseName() + "Servlet";
      }
      Name clazz = pkg.getPackageName().append(simpleName);
      Writer writer = null;
      try {
        JavaFileObject file = metaModel.processingContext.createSourceFile(clazz, pkgElt);
        writer = file.openWriter();
        writer.append("package ").append(pkg.getPackageName()).append(";\n");
View Full Code Here

    ArrayList<BeanDescriptor> beans = new ArrayList<BeanDescriptor>();
    List<TemplateDescriptor> templates = new ArrayList<TemplateDescriptor>();

    //
    String packageName = config.getString("package");
    Name pkg = Name.parse(packageName);

    // Load templates
    for (String fqn : config.getList("templates", String.class)) {
      Class<?> clazz = loader.loadClass(fqn);
      Field f = clazz.getField("DESCRIPTOR");
      TemplateDescriptor descriptor = (TemplateDescriptor)f.get(null);
      templates.add(descriptor);
      juzu.impl.common.Path.Absolute path = (juzu.impl.common.Path.Absolute)juzu.impl.common.Path.parse(descriptor.getPath());
      Path qualifier;
      if (pkg.isPrefix(path.getName())) {
        juzu.impl.common.Path.Relative relativePath = juzu.impl.common.Path.relative(path.getName().subName(pkg.size()), path.getExt());
        qualifier = new PathLiteral(relativePath.getCanonical());
      } else {
        qualifier = new PathLiteral(path.getCanonical());
      }
      beans.add(BeanDescriptor.createFromImpl(Template.class, null, Arrays.<Annotation>asList(qualifier), descriptor.getType()));
View Full Code Here

  private void emitPortlet(
    ProcessingContext env,
    PackageElement pkgElt,
    String[] names) throws ProcessingException {
    Writer writer = null;
    Name fqn = Name.parse(pkgElt.getQualifiedName()).append(names[0]);
    try {
      JavaFileObject file = env.createSourceFile(fqn, pkgElt);
      writer = file.openWriter();

      //
View Full Code Here

/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
public abstract class AbstractTemplateTestCase extends AbstractTestCase {

  public GroovyTemplateStub template(final String text) throws IOException, TemplateException {
    Name pkg = Name.parse("foo");
    Name name = Name.parse("index");
    Name fqn = pkg.append(name);
    Path.Absolute absolute = Path.absolute(fqn, ".gtmpl");
    Path.Relative relative = Path.relative(name, ".gtmpl");
    GroovyTemplateEmitter generator = new GroovyTemplateEmitter(fqn);
    try {
      ProcessPhase processPhase = new ProcessPhase(new SimpleProcessContext(Collections.<Path.Absolute, TemplateModel<?>>emptyMap()) {
        @Override
        public Path.Absolute resolveTemplate(Path path) throws TemplateException {
          return null;
        }
        @Override
        public TagHandler resolveTagHandler(String name) {
          if ("title".equals(name)) {
            return new TitleTag();
          } else {
            return null;
          }
        }
        @Override
        public MethodInvocation resolveMethodInvocation(String typeName, String methodName, Map<String, String> parameterMap) throws ProcessingException {
          if (parameterMap.size() > 0) {
            throw failure("Unexpected non empty parameter map");
          }
          Class clazz = AbstractTemplateTestCase.this.getClass();
          try {
            Method m = clazz.getMethod(methodName);
            return new MethodInvocation(clazz.getName(), m.getName(), Collections.<String>emptyList());
          }
          catch (NoSuchMethodException e) {
            // Should we thrown a CompilationException instead ?
            throw failure(e);
          }
        }
      });
      TemplateModel<ASTNode.Template> templateModel = new TemplateModel<ASTNode.Template>(
          ASTNode.Template.parse(text),
          absolute,
          0,
          0);
      processPhase.process(templateModel);

      // Emit
      EmitPhase emitPhase = new EmitPhase(new EmitContext(){
        @Override
        public TagHandler resolveTagHandler(String name) {
          if ("title".equals(name)) {
            return new TitleTag();
          } else {
            return null;
          }
        }

        public void createResource(Path.Absolute path, CharSequence content) throws IOException {
          throw new UnsupportedOperationException();
        }
      });
      emitPhase.emit(generator, templateModel.getModel());
    }
    catch (juzu.impl.template.spi.juzu.ast.ParseException e) {
      throw failure(e);
    }
    GroovyTemplateStub stub = generator.build(fqn.toString());
    stub.init();
    return stub;
  }
View Full Code Here

    FileResource<I> resource = assertSource(name, "java");
    return new JavaFile<I>(resource);
  }

  public JavaFile<I> assertAddJavaSource(String name) {
    Name n = Name.parse(name);
    FileResource<I> source = assertAddSource(name, "java", "package " + n.getParent() + ";\npublic class " + n.getIdentifier() + " {}\n");
    return new JavaFile<I>(source);
  }
View Full Code Here

TOP

Related Classes of juzu.impl.common.Name

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.