@NotNull public static TranslationContext rootContext(@NotNull StaticContext staticContext) { JsProgram program = staticContext.getProgram(); JsBlock globalBlock = program.getGlobalBlock(); DynamicContext rootDynamicContext = DynamicContext.rootContext(staticContext.getRootScope(), globalBlock); AliasingContext rootAliasingContext = AliasingContext.getCleanContext(); return new TranslationContext(staticContext, rootDynamicContext, rootAliasingContext); }
public void applyAll() { sqlBuffer = new StringBuilder(sqlBuffer.toString().trim()); String trimmedUppercaseSql = sqlBuffer.toString().toUpperCase(Locale.ENGLISH); if (trimmedUppercaseSql.length() > 0) { applyPrefix(sqlBuffer, trimmedUppercaseSql); applySuffix(sqlBuffer, trimmedUppercaseSql); } delegate.appendSql(sqlBuffer.toString()); }
// TODO: consider passing a function here @NotNull public TranslationContext innerContextWithGivenScopeAndBlock( @NotNull JsScope scope, @NotNull JsBlock block) { return contextWithScope(dynamicContext.getScope().innerScope(scope), block); }
@NotNull public TranslationContext innerBlock(@NotNull JsBlock block) { return new TranslationContext(staticContext, dynamicContext.innerBlock(block), aliasingContext); }
@NotNull public TranslationContext contextWithScope( @NotNull NamingScope newScope, @NotNull JsBlock block) { return new TranslationContext( staticContext, DynamicContext.newContext(newScope, block), aliasingContext); }
public void addStatementToCurrentBlock(@NotNull JsStatement statement) { dynamicContext.jsBlock().getStatements().add(statement); }
@NotNull public JsScope jsScope() { return dynamicContext.jsScope(); }
@NotNull public TemporaryVariable declareTemporary( @NotNull JsExpression initExpression, boolean initialize) { return dynamicContext.declareTemporary(initExpression, initialize); }
@NotNull public TemporaryVariable declareTemporary(@NotNull JsExpression initExpression) { return dynamicContext.declareTemporary(initExpression); }
public void bind(String name, Object value) { delegate.bind(name, value); }
public Map<String, Object> getBindings() { return delegate.getBindings(); }
public String getSql() { return delegate.getSql(); }
public int getUniqueNumber() { return delegate.getUniqueNumber(); }