Java Code Examples for org.mozilla.javascript.Token#THIS

The following examples show how to use org.mozilla.javascript.Token#THIS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeywordLiteral.java    From JsDroidCmd with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public String toSource(int depth) {
    StringBuilder sb = new StringBuilder();
    sb.append(makeIndent(depth));
    switch (getType()) {
    case Token.THIS:
        sb.append("this");
        break;
    case Token.NULL:
        sb.append("null");
        break;
    case Token.TRUE:
        sb.append("true");
        break;
    case Token.FALSE:
        sb.append("false");
        break;
    case Token.DEBUGGER:
        sb.append("debugger;\n");
        break;
    default:
        throw new IllegalStateException("Invalid keyword literal type: "
                                        + getType());
    }
    return sb.toString();
}
 
Example 2
Source File: KeywordLiteral.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Override
public String toSource(int depth) {
    StringBuilder sb = new StringBuilder();
    sb.append(makeIndent(depth));
    switch (getType()) {
    case Token.THIS:
        sb.append("this");
        break;
    case Token.NULL:
        sb.append("null");
        break;
    case Token.TRUE:
        sb.append("true");
        break;
    case Token.FALSE:
        sb.append("false");
        break;
    case Token.DEBUGGER:
        sb.append("debugger;\n");
        break;
    default:
        throw new IllegalStateException("Invalid keyword literal type: "
                                        + getType());
    }
    return sb.toString();
}
 
Example 3
Source File: KeywordLiteral.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Sets node token type
 * @throws IllegalArgumentException if {@code nodeType} is unsupported
 */
@Override
public KeywordLiteral setType(int nodeType) {
    if (!(nodeType == Token.THIS
          || nodeType == Token.NULL
          || nodeType == Token.TRUE
          || nodeType == Token.FALSE
          || nodeType == Token.DEBUGGER))
        throw new IllegalArgumentException("Invalid node type: "
                                           + nodeType);
    type = nodeType;
    return this;
}
 
Example 4
Source File: KeywordLiteral.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets node token type
 * @throws IllegalArgumentException if {@code nodeType} is unsupported
 */
@Override
public KeywordLiteral setType(int nodeType) {
    if (!(nodeType == Token.THIS
          || nodeType == Token.NULL
          || nodeType == Token.TRUE
          || nodeType == Token.FALSE
          || nodeType == Token.DEBUGGER))
        throw new IllegalArgumentException("Invalid node type: "
                                           + nodeType);
    type = nodeType;
    return this;
}