本文整理汇总了Java中com.google.caja.reporting.RenderContext.getOut方法的典型用法代码示例。如果您正苦于以下问题:Java RenderContext.getOut方法的具体用法?Java RenderContext.getOut怎么用?Java RenderContext.getOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.caja.reporting.RenderContext
的用法示例。
在下文中一共展示了RenderContext.getOut方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderShort
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
/**
* Renders the short form without the "var" keyword.
* This is used in multi declarations, such as in
* {@code for (var a = 0, b = 1, ...)}.
*/
void renderShort(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
if (identifier.getName() == null) {
throw new IllegalStateException(
"null name for declaration at " + getFilePosition());
}
identifier.render(rc);
if (null != initializer) {
out.consume("=");
boolean isComma = Operation.is(initializer, Operator.COMMA);
if (isComma) { out.consume("("); }
initializer.render(rc);
if (isComma) { out.consume(")"); }
}
}
示例2: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
String label = getRenderedLabel();
if (null != label) {
out.consume(label);
out.consume(":");
}
out.consume("for");
out.consume("(");
if (!(initializer instanceof Noop)) { initializer.render(rc); }
out.consume(JsMinimalPrinter.NOOP);
if (!(condition instanceof BooleanLiteral
&& ((BooleanLiteral) condition).getValue())) {
condition.render(rc);
}
out.consume(JsMinimalPrinter.NOOP);
if (!(increment instanceof Noop)) { increment.render(rc); }
out.consume(")");
getBody().renderBlock(rc, false);
}
示例3: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
@Override
public void render(RenderContext rc) {
FunctionConstructor fc = getInitializer();
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
out.consume("function");
getIdentifier().render(rc);
out.consume("(");
boolean seen = false;
for (FormalParam p : fc.getParams()) {
if (seen) {
out.consume(",");
} else {
seen = true;
}
p.render(rc);
}
out.consume(")");
fc.getBody().renderBlock(rc, false);
}
示例4: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext r) {
TokenConsumer out = r.getOut();
children().get(0).render(r);
out.consume("{");
out.consume(String.valueOf(minCount));
if (minCount != maxCount) {
out.consume(",");
if (Integer.MAX_VALUE != maxCount) {
out.consume(String.valueOf(maxCount));
}
}
out.consume("}");
}
示例5: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
String label = getRenderedLabel();
if (null != label) {
out.consume(label);
out.consume(":");
}
getBody().render(rc);
}
示例6: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
Expression value = children().get(1);
TokenConsumer out = rc.getOut();
renderPropertyName(rc, false);
out.consume(":");
if (!Operation.is(value, Operator.COMMA)) {
value.render(rc);
} else {
out.mark(value.getFilePosition());
out.consume("(");
value.render(rc);
out.consume(")");
}
}
示例7: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public final void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
renderHead(rc);
out.consume(":");
out.consume("\n");
Block body = getBody();
rc.getOut().mark(body.getFilePosition());
body.renderBody(rc);
}
示例8: renderBody
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void renderBody(RenderContext rc) {
TokenConsumer out = rc.getOut();
for (Statement stmt : children()) {
out.mark(stmt.getFilePosition());
stmt.render(rc);
if (!stmt.isTerminal()) {
out.mark(FilePosition.endOfOrNull(stmt.getFilePosition()));
out.consume(";");
}
}
out.mark(FilePosition.endOfOrNull(getFilePosition()));
}
示例9: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
@Override
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
String body = value.getMatchText();
String mods = value.getModifiers();
if ("".equals(body) || !areRegexpModifiersValid(mods)) {
// (new (/./.constructor))('', 'g')
out.consume("(");
out.consume("new");
out.consume("(");
out.consume("/./");
out.consume(".");
out.consume("constructor");
out.consume(")");
out.consume("(");
StringLiteral.renderUnquotedValue(body, rc);
out.consume(",");
StringLiteral.renderUnquotedValue(mods, rc);
out.consume(")");
out.consume(")");
} else {
StringBuilder sb = new StringBuilder();
sb.append('/');
Escaping.normalizeRegex(body, sb);
sb.append('/');
sb.append(mods);
out.consume(sb.toString());
}
}
示例10: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
String label = getRenderedLabel();
if (null != label) {
out.consume(label);
out.consume(":");
}
out.consume("while");
out.consume("(");
condition.render(rc);
out.consume(")");
body.renderBlock(rc, false);
}
示例11: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
Expression e = getExpression();
if (e instanceof FunctionConstructor
|| e instanceof ObjectConstructor
|| startsWithRegex(e)) {
// We need to parenthesize Object constructors because otherwise an
// object constructor with only one entry:
// { x : 4 }
// is ambiguous. It could be a block containing a labeled expression
// statement, and depending on semicolon insertion.
// We need to parenthesize Function constructors because otherwise
// we might output something like
// function a () {
// ;
// };
// which is interpreted as two statements -- a declaration and a noop for
// the semicolon.
// Rhino fails to parse
// if(...)/foo/.test(x)?bar:baz;
// so we parenthesize operator trees whose left-most operand is a regex
// literal.
out.consume("(");
e.render(rc);
out.consume(")");
} else {
e.render(rc);
}
}
示例12: renderActuals
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
void renderActuals(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.consume("(");
boolean seen = false;
for (FormalParam e : params) {
if (seen) {
out.consume(",");
} else {
seen = true;
}
e.render(rc);
}
out.consume(")");
}
示例13: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
out.consume("catch");
out.consume("(");
out.mark(exception.getFilePosition());
exception.getIdentifier().render(rc);
out.consume(")");
body.renderBlock(rc, false);
}
示例14: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
out.consume("continue");
if (null != label && !"".equals(label)) {
out.consume(label);
}
}
示例15: render
import com.google.caja.reporting.RenderContext; //导入方法依赖的package包/类
public void render(RenderContext rc) {
TokenConsumer out = rc.getOut();
out.mark(getFilePosition());
out.consume("var");
renderShort(rc);
}