Package com.google.caja.parser.js

Examples of com.google.caja.parser.js.CatchStmt


            reason="",
            matches="catch (@e) { @body* }",
            substitutes="catch (@e) { @body* }")
        public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
          if (node instanceof CatchStmt) {
            CatchStmt cs = (CatchStmt) node;
            Scope newScope = Scope.fromCatchStmt(scope, cs);
            NameContext<String, ?> context = contexts.get(scope);
            NameContext<String, ?> newContext = context.makeChildContext();
            contexts.put(newScope, newContext);
            try {
              newContext.declare(cs.getException().getIdentifierName(),
                                 cs.getException().getFilePosition());
            } catch (NameContext.RedeclarationException ex) {
              ex.toMessageQueue(mq);
            }
            return expandAll(cs, newScope);
          }
View Full Code Here


      public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
        Map<String, ParseTreeNode> bindings = this.match(node);
        if (bindings != null) {
          Identifier ex = (Identifier) bindings.get("ex");
          TryStmt ts = (TryStmt) node;
          CatchStmt cs = ts.getCatchClause();
          if (isSynthetic(ex)) {
            return substV(
                "body", rw.expand(bindings.get("body"), scope),
                "ex", rw.noexpand(ex),
                "handler", rw.expand(
                    bindings.get("handler"), Scope.fromCatchStmt(scope, cs)));
          }
        }
        return NONE;
      }
    },

    new Rule() {
      @Override
      @RuleDescription(
          name="syntheticCatches2",
          synopsis="Pass through synthetic variables which are unmentionable.",
          reason="Catching unmentionable exceptions helps maintain invariants.",
          matches=(
               "try { @body*; } catch (/* synthetic */ @ex___) { @handler*; }"
               + " finally { @cleanup*; }"),
          substitutes=(
               "try { @body*; } catch (/* synthetic */ @ex___) { @handler*; }"
               + " finally { @cleanup*; }"))
      public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
        Map<String, ParseTreeNode> bindings = this.match(node);
        if (bindings != null) {
          TryStmt ts = (TryStmt) node;
          CatchStmt cs = ts.getCatchClause();
          Identifier ex = (Identifier) bindings.get("ex");
          if (isSynthetic(ex)) {
            return substV(
                "body", rw.expand(bindings.get("body"), scope),
                "ex", rw.noexpand(ex),
View Full Code Here

TOP

Related Classes of com.google.caja.parser.js.CatchStmt

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.