Package com.google.gxp.compiler.fs

Examples of com.google.gxp.compiler.fs.FileRef


    assertAlert(new ParamTypeMismatchError(pos(2,1), "foo", "text/html", "text/plain"));
    assertNoUnexpectedAlerts();
  }

  public void testParamMissingDefault() throws Exception {
    FileRef iface = createInterfaceFile("testInterface",
                                        "<gxp:param name='x' type='String' has-default='true' />");

    FileRef implementation = createFile("testImplementation",
                                        "<gxp:implements interface='testInterface' />",
                                        "<gxp:param name='x' type='String' />");

    compileFiles(iface, implementation);
    assertAlert(new ParamDefaultMismatchError(pos(3,1), "<gxp:param>", "x"));
View Full Code Here


    assertAlert(new ParamDefaultMismatchError(pos(3,1), "<gxp:param>", "x"));
    assertNoUnexpectedAlerts();
  }

  public void testParamMissingConstructor() throws Exception {
    FileRef iface = createInterfaceFile(
        "testInterface",
        "<gxp:param name='x' type='String' has-constructor='true' />");

    FileRef implementation = createFile("testImplementation",
                                        "<gxp:implements interface='testInterface' />",
                                        "<gxp:param name='x' type='String' />");

    compileFiles(iface, implementation);
    assertAlert(new ParamConstructorMismatchError(pos(3,1), "<gxp:param>", "x"));
View Full Code Here

    assertAlert(new ParamConstructorMismatchError(pos(3,1), "<gxp:param>", "x"));
    assertNoUnexpectedAlerts();
  }

  public void testNoThisParamSupplied() throws Exception {
    FileRef iface = createInterfaceFile("testInterface");
    FileRef implementation = createFile("testImplementation",
                                        "<call:testInterface />");

    compileFiles(iface, implementation);
    assertAlert(new MissingAttributeError(pos(2,1), "<call:testInterface>", "this"));
    assertNoUnexpectedAlerts();
View Full Code Here

      throws CmdLineException, IOException {

    // If there is only one argument, and it starts with an '@', then treat it
    // as an options file, relative to the current working directory.
    if ((args.length == 1) && (args[0].startsWith("@"))) {
      FileRef optionsFile = defaultDir.join(args[0].substring(1));
      Reader in = optionsFile.openReader(Charsets.UTF_8);
      List<String> lines = CharStreams.readLines(in);
      in.close();
      List<String> parsedTokens = Lists.newArrayList();
      for (String line : lines) {
        for (String token : line.trim().split("\\s+")) {
          if (token.length() > 0) {
            parsedTokens.add(token);
          }
        }
      }
      args = parsedTokens.toArray(new String[parsedTokens.size()]);
    }

    commandLine = new CommandLine(args);

    Set<FileRef> underlyingInputFiles = getFileRefs(fs, commandLine.trailingArgs);

    FileRef outputDir = (commandLine.FLAG_dir == null)
        ? defaultDir : fs.parseFilename(commandLine.FLAG_dir);

    List<FileRef> sourcePaths = (commandLine.FLAG_source == null)
        ? Collections.singletonList(defaultDir)
        : fs.parseFilenameList(commandLine.FLAG_source);

    SourcePathFileSystem sourcePathFs = new SourcePathFileSystem(fs,
                                                                 sourcePaths,
                                                                 underlyingInputFiles,
                                                                 outputDir);

    sourceFiles = ImmutableSet.copyOf(sourcePathFs.getSourceFileRefs());
    schemaFiles = getFileRefs(fs, commandLine.FLAG_schema);

    // Compute Output Languages
    Set<OutputLanguage> tmpOutputLanguages = EnumSet.noneOf(OutputLanguage.class);
    for (String outputLanguage : commandLine.FLAG_output_language) {
      tmpOutputLanguages.add(OutputLanguage.valueOf(outputLanguage.toUpperCase()));
    }
    outputLanguages = ImmutableSet.copyOf(tmpOutputLanguages);

    allowedOutputFiles = getFileRefs(sourcePathFs, commandLine.FLAG_output);

    alertPolicy = computeAlertPolicy(commandLine.FLAG_warn, commandLine.FLAG_error);

    // Compute Dependency File
    dependencyFile = (commandLine.FLAG_depend == null)
        ? null : fs.parseFilename(commandLine.FLAG_depend);

    // Compute Properties File
    propertiesFile = (commandLine.FLAG_output_properties
                      && commandLine.FLAG_message_source != null)
        ? outputDir.join(
            "/" + commandLine.FLAG_message_source.replace(".", "/") + "_en.properties")
        : null;

    isVerboseEnabled = commandLine.FLAG_verbose;
    isDebugEnabled = commandLine.FLAG_g;
View Full Code Here

    if (destdir == null) {
      log("Attribute 'destdir' was not set, the current working directory will be used.",
          Project.MSG_WARN);
    }
    FileRef outputDir = (destdir == null)
        ? cwd
        : fs.parseFilename(destdir);

    Set<FileRef> sourcePaths = (srcpaths == null)
        ? ImmutableSet.<FileRef>of()
        : ImmutableSet.copyOf(fs.parseFilenameList(srcpaths));

    SourcePathFileSystem sourcePathFs = new SourcePathFileSystem(fs,
                                                                 sourcePaths,
                                                                 underlyingInputFiles,
                                                                 outputDir);

    sourceFiles = ImmutableSet.copyOf(sourcePathFs.getSourceFileRefs());

    // Compute Schema Files
    schemaFiles = (schemas == null)
        ? ImmutableSet.<FileRef>of()
        : ImmutableSet.copyOf(fs.parseFilenameList(schemas));

    // Compute Output Languages
    outputLanguages = ImmutableSet.of(OutputLanguage.JAVA);

    // Compute Properties File
    propertiesFile = (target != null)
        ? outputDir.join("/" + target.replace(".", "/") + "_en.properties")
        : null;

    // Compute Alert Policy
    alertPolicy = computeAlertPolicy();
View Full Code Here

        "<gxp:param type='String' name='x'/><my:" + getTemplateBaseName()
        + " expr:x='", "'/>", 2, 36);
  }

  public void testCall_invalidRegex() throws Exception {
    FileRef callee = createFile(
        "callee", "<gxp:param name='s' type='String' regex='foo' />");
    FileRef caller = createFile("caller", "<my:callee s='bar' />");
    compileFiles(caller, callee);

    assertAlert(new InvalidParameterFailedRegexError(
                    pos(2, 1), "callee", "s", "foo", "bar"));
    assertNoUnexpectedAlerts();
View Full Code Here

                                          "inside " + startCall));
    assertNoUnexpectedAlerts();
  }

  public void testCall_paramHasMultipleValues() throws Exception {
    FileRef callee = createFile("callee", "<gxp:param type='int' name='y'/>");
    FileRef caller = createFile("caller",
                                "<gxp:param type='int' name='x'/>",
                                "<call:callee y='1'>",
                                "  <gxp:attr name='y'>",
                                "    5",
                                "  </gxp:attr>",
View Full Code Here

    assertAlert(new MultiValueAttributeError(pos(10, 3), "<call:callee>", "'y' attribute"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_paramIsContentButNotContainer() throws Exception {
    FileRef callee = createFile(
        "callee", "<gxp:param content-type='text/html' name='x'/>");
    FileRef caller = createFile("caller",
                                "<call:callee>foo</call:callee>",
                                "<my:callee>foo</my:callee>");
    compileFiles(callee, caller);
    assertAlert(new BadNodePlacementError(pos(2, 14), "text",
                                          "inside <call:callee>"));
View Full Code Here

    assertAlert(new IllegalJavaPrimitiveError(pos(5, 1), "bad", "boolean"));
    assertNoUnexpectedAlerts();
  }

  public void testCall_badContentType() throws Exception {
    FileRef callee = createFileNoHeader(
        "callee",
        "<!DOCTYPE gxp:template SYSTEM \"http://gxp.googlecode.com/svn/trunk/resources/xhtml.ent\">",
        "<gxp:template name='com.google.gxp.compiler.errortests.callee'",
        "              xmlns:gxp='http://google.com/2001/gxp'",
        "              content-type='text/javascript'>",
        "</gxp:template>");

    // bad call (not on javascript context)
    FileRef caller = createFile("caller", "<call:callee />");
    compileFiles(callee, caller);
    assertAlert(new TypeError(pos(2,1), "<call:callee>", "text/javascript", "text/html"));
    assertNoUnexpectedAlerts();

    // bad call (in an attribute that isn't javascript)
View Full Code Here

    compileFiles(callee, caller);
    assertNoUnexpectedAlerts();
  }

  public void testCall_badContentTypeForCallInParam() throws Exception {
    FileRef innerCallee = createFileNoHeader(
        "innerCallee",
        "<!DOCTYPE gxp:template SYSTEM \"http://gxp.googlecode.com/svn/trunk/resources/xhtml.ent\">",
        "<gxp:template name='com.google.gxp.compiler.errortests.innerCallee'",
        "              xmlns:gxp='http://google.com/2001/gxp'",
        "              content-type='text/javascript'>",
        "</gxp:template>");

    FileRef outerCallee = createFile("outerCallee",
                                     "<gxp:param name='x' content-type='text/html'/>");

    FileRef caller = createFile("caller",
                                "<call:outerCallee>",
                                "  <gxp:attr name='x'>",
                                "    <call:innerCallee/>",
                                "  </gxp:attr>",
                                "</call:outerCallee>");
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.fs.FileRef

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.