Examples of StringSourceWriter


Examples of com.google.gwt.user.rebind.StringSourceWriter

    String toWrite = Util.readURLAsString(resource);
    if (getValidated(method)) {
      SVGValidator.validate(toWrite, resource.toExternalForm(), logger, null);
    }
   
    SourceWriter sw = new StringSourceWriter();
    sw.println("new " + SVGResource.class.getName() + "() {");
    sw.indent();
    sw.println("private String svg=\"" + Generator.escape(toWrite) + "\";");

    // Convenience when examining the generated code.
    sw.println("// " + resource.toExternalForm());

      sw.println("@Override");
    sw.println("public " + OMSVGSVGElement.class.getName() + " getSvg() {");
    sw.indent();
    sw.println("return " + OMSVGParser.class.getName() + ".parse(svg);");
    sw.outdent();
    sw.println("}");

      sw.println("@Override");
      sw.println("public String getName() {");
      sw.indent();
      sw.println("return \"" + method.getName() + "\";");
      sw.outdent();
      sw.println("}");
     
      sw.println("@Override");
      sw.println("public String getUrl() {");
      sw.indent();
    sw.println("return \"data:image/svg+xml;base64,\" + " + DOMHelper.class.getName() + ".base64encode(svg);");
      sw.outdent();
      sw.println("}");

      sw.println("@Override");
      sw.println("public " + SafeUri.class.getName() + " getSafeUri() {");
      sw.indent();
    sw.println("return " + UriUtils.class.getName() + ".fromSafeConstant(\"data:image/svg+xml;base64,\" + " + DOMHelper.class.getName() + ".base64encode(svg));");
      sw.outdent();
      sw.println("}");

    sw.outdent();
    sw.println("}");

    return sw.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

  @Override
  public String createAssignment(TreeLogger logger, ResourceContext context,
      JMethod method) throws UnableToCompleteException {
    String name = method.getName();

    SourceWriter sw = new StringSourceWriter();
    sw
        .println("new " + ExternalSVGResourcePrototype.class.getName()
            + "(");
    sw.indent();
    sw.println('"' + name + "\",");
    // These are field names
    sw.println(externalSVGUrlIdent + ", " + externalSVGCacheIdent + ", ");
    sw.println(offsets.get(method.getName()).toString());
    sw.outdent();
    sw.print(")");

    return sw.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

    }
    // make sure that the # of ua in VALID_VALUES
    // is the same of predicates. maybe should iterate
    // to make sure each one has a match.
    assert predicates.length == VALID_VALUES.size();
    StringSourceWriter body = new StringSourceWriter();
    body.println("{");
    body.indent();
    writeUserAgentPropertyJavaScript(body, possibleValues);
    body.outdent();
    body.println("}");

    return body.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

  @Override
  public String createAssignment(TreeLogger logger, ResourceContext context,
      JMethod method) throws UnableToCompleteException {
    String name = method.getName();

    SourceWriter sw = new StringSourceWriter();
    sw
        .println("new " + ExternalSVGResourcePrototype.class.getName()
            + "(");
    sw.indent();
    sw.println('"' + name + "\",");
    // These are field names
    sw.println(externalSVGUrlIdent + ", " + externalSVGCacheIdent + ", ");
    sw.println(offsets.get(method.getName()).toString());
    sw.outdent();
    sw.print(")");

    return sw.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

    // xxx = new SVGResource() {
    //   public OMSVGSVGElement getSvg() {
    //     return OMSVGParser.parse("...");
    //   }
    // };
    SourceWriter sw = new StringSourceWriter();
    sw.println("new " + SVGResource.class.getName() + "() {");
    sw.indent();

    // Convenience when examining the generated code.
    sw.println("// " + resource.toExternalForm());

    sw.println("public " + OMSVGSVGElement.class.getName() + " getSvg() {");
    sw.indent();
    String toWrite = Util.readURLAsString(resource);
    if (getValidated(method)) {
      SVGValidator.validate(toWrite, resource.toExternalForm(), logger, null);
    }
    sw.println("return " + OMSVGParser.class.getName() + ".parse(\"" + Generator.escape(toWrite) + "\");");
    sw.outdent();
    sw.println("}");

      sw.println("public String getName() {");
      sw.indent();
      sw.println("return \"" + method.getName() + "\";");
      sw.outdent();
      sw.println("}");

    sw.outdent();
    sw.println("}");

    return sw.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

    Context buildContext = bootStrapClass.getContext();

    BlockBuilder<?> blockBuilder =
            classStructureBuilder.publicMethod(InterfaceInjectionContext.class, "bootstrapContainer");

    SourceWriter sourceWriter = new StringSourceWriter();

    procContext = new IOCProcessingContext(logger, context, sourceWriter, buildContext, bootStrapClass, blockBuilder);
    injectFactory = new InjectorFactory(procContext);
    procFactory = new IOCProcessorFactory(injectFactory);

    MetaDataScanner scanner = ScannerSingleton.getOrCreateInstance();
    Properties props = scanner.getProperties("ErraiApp.properties");
    if (props != null) {
      logger.log(TreeLogger.Type.INFO, "Checking ErraiApp.properties for configured types ...");

      for (Object o : props.keySet()) {
        String key = (String) o;
        if (key.equals(QUALIFYING_METADATA_FACTORY_PROPERTY)) {
          String fqcnQualifyingMetadataFactory = String.valueOf(props.get(key));

          try {
            QualifyingMetadataFactory factory = (QualifyingMetadataFactory)
                    Class.forName
                            (fqcnQualifyingMetadataFactory).newInstance();

            procContext.setQualifyingMetadataFactory(factory);
          }
          catch (ClassNotFoundException e) {
            e.printStackTrace();
          }
          catch (InstantiationException e) {
            e.printStackTrace();
          }
          catch (IllegalAccessException e) {
            e.printStackTrace();
          }
        }
      }
    }

    procContext.setPackages(packages);

    defaultConfigureProcessor();

    // generator constructor source code
    initializeProviders();
    generateExtensions(sourceWriter, classStructureBuilder, blockBuilder);
    // close generated class

    return sourceWriter.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

  protected String getResourceImplAsString(TreeLogger logger, ResourceContext context,
      JMethod method, Map<JMethod, String> actualReplacements,
      JClassType cssResourceSubtype,
      CssStylesheet stylesheet) throws UnableToCompleteException {
    SourceWriter sw = new StringSourceWriter();
    // Write the expression to create the subtype.
    sw.println("new " + method.getReturnType().getQualifiedSourceName()
        + "() {");
    sw.indent();

    // Methods defined by CssResource interface
    writeEnsureInjected(sw);
    writeGetName(method, sw);

    // Create the Java expression that generates the CSS
    writeGetText(logger, context, method, sw);

    // getOverridableMethods is used to handle CssResources extending
    // non-CssResource types. See the discussion in computeReplacementsForType.
    writeUserMethods(logger, sw, stylesheet,
        cssResourceSubtype.getOverridableMethods(), actualReplacements);

    sw.outdent();
    sw.println("}");

    return sw.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

  @Override
  public String generate(TreeLogger logger, SortedSet<String> possibleValues, String fallback,
      SortedSet<ConfigurationProperty> configProperties) {
    assertUserAgents(logger, possibleValues);

    StringSourceWriter body = new StringSourceWriter();
    body.println("{");
    body.indent();
    writeUserAgentPropertyJavaScript(body, possibleValues, fallback);
    body.outdent();
    body.println("}");

    return body.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

    checkErrors();

    // Validate that classes not assigned to one of the interface methods are external
    validateExternalClasses(externalClasses, renamingResult.externalClassCandidate, method, logger);

    SourceWriter sw = new StringSourceWriter();
    sw.println("new " + method.getReturnType().getQualifiedSourceName() + "() {");
    sw.indent();

    writeMethods(logger, context, method, sw, constantDefinitions,
        cssParsingResult.originalConstantNameMapping, renamingResult.mapping);

    sw.outdent();
    sw.println("}");

    return sw.toString();
  }
View Full Code Here

Examples of com.google.gwt.user.rebind.StringSourceWriter

    }

    URL resource = resources[0];
    String outputUrlExpression = context.deploy(resource, null, true);

    SourceWriter sw = new StringSourceWriter();
    // Write the expression to create the subtype.
    sw.println("new " + StaticDataResource.class.getName() + "() {");
    sw.indent();

    // Convenience when examining the generated code.
    sw.println("// " + resource.toExternalForm());

    sw.println("public String getUrl() {");
    sw.indent();
    sw.println("return " + outputUrlExpression + ";");
    sw.outdent();
    sw.println("}");

    sw.println("public com.google.gwt.safehtml.shared.SafeUri getSafeUri() {");
    sw.indent();
    sw.println("return new org.rstudio.core.client.SafeUriStringImpl(" + outputUrlExpression + ");");
    sw.outdent();
    sw.println("}");

    sw.println("public String getName() {");
    sw.indent();
    sw.println("return \"" + method.getName() + "\";");
    sw.outdent();
    sw.println("}");

    sw.outdent();
    sw.println("}");

    return sw.toString();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.