Skip to content

Commit 0efd27b

Browse files
lukesandbergBrendan Linn
authored andcommitted
Stop respecting the --isUsingIjData flag in jssrc.
This has been hardcoded on in the soy_js build rule since [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=106355452
1 parent d60e268 commit 0efd27b

18 files changed

+136
-199
lines changed

java/src/com/google/template/soy/SoyToJsSrcCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public final class SoyToJsSrcCompiler {
9494
usage = "User-declared syntax version for the Soy file bundle (e.g. 2.0, 2.3).")
9595
private String syntaxVersion = "";
9696

97+
// TODO(lukes): remove, this is no longer used
9798
@Option(name = "--isUsingIjData",
9899
usage = "Whether to enable use of injected data (syntax is '$ij.*').",
99100
handler = MainClassUtils.BooleanOptionHandler.class)
@@ -277,7 +278,6 @@ private CompilationResult execMain(String[] args) throws IOException {
277278

278279
// Create SoyJsSrcOptions.
279280
SoyJsSrcOptions jsSrcOptions = new SoyJsSrcOptions();
280-
jsSrcOptions.setIsUsingIjData(isUsingIjData);
281281
jsSrcOptions.setShouldGenerateJsdoc(shouldGenerateJsdoc);
282282
jsSrcOptions.setShouldProvideRequireSoyNamespaces(shouldProvideRequireSoyNamespaces);
283283
jsSrcOptions.setShouldDeclareTopLevelNamespaces(shouldDeclareTopLevelNamespaces);

java/src/com/google/template/soy/incrementaldomsrc/GenIncrementalDomCodeVisitor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public final class GenIncrementalDomCodeVisitor extends GenJsCodeVisitor {
8888
SoyTypeOps typeOps,
8989
ErrorReporter errorReporter) {
9090
super(jsSrcOptions,
91-
true,
9291
jsExprTranslator,
9392
genCallCodeUtils,
9493
isComputableAsJsExprsVisitor,

java/src/com/google/template/soy/incrementaldomsrc/IncrementalDomGenCallCodeUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.template.soy.jssrc.internal.JsExprTranslator;
2323
import com.google.template.soy.jssrc.restricted.JsExpr;
2424
import com.google.template.soy.jssrc.restricted.SoyJsSrcPrintDirective;
25-
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.IsUsingIjData;
2625
import com.google.template.soy.soytree.CallParamContentNode;
2726

2827
import java.util.Map;
@@ -37,20 +36,17 @@
3736
public class IncrementalDomGenCallCodeUtils extends GenCallCodeUtils {
3837

3938
/**
40-
* @param isUsingIjData Whether any of the Soy code uses injected data.
4139
* @param jsExprTranslator Instance of JsExprTranslator to use.
4240
* @param isComputableAsJsExprsVisitor The IsComputableAsJsExprsVisitor to be used.
4341
* @param genJsExprsVisitorFactory Factory for creating an instance of GenJsExprsVisitor.
4442
*/
4543
@Inject
4644
IncrementalDomGenCallCodeUtils(
4745
Map<String, SoyJsSrcPrintDirective> soyJsSrcDirectivesMap,
48-
@IsUsingIjData boolean isUsingIjData,
4946
JsExprTranslator jsExprTranslator,
5047
IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor,
5148
GenJsExprsVisitorFactory genJsExprsVisitorFactory) {
5249
super(soyJsSrcDirectivesMap,
53-
isUsingIjData,
5450
jsExprTranslator,
5551
isComputableAsJsExprsVisitor,
5652
genJsExprsVisitorFactory);

java/src/com/google/template/soy/incrementaldomsrc/IncrementalDomSrcMain.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,18 @@
2323
import com.google.common.collect.Iterables;
2424
import com.google.common.collect.Multimap;
2525
import com.google.common.io.Files;
26-
import com.google.inject.Key;
2726
import com.google.template.soy.base.SoySyntaxException;
2827
import com.google.template.soy.error.ErrorReporter;
2928
import com.google.template.soy.html.passes.HtmlTransformVisitor;
3029
import com.google.template.soy.internal.i18n.BidiGlobalDir;
3130
import com.google.template.soy.internal.i18n.SoyBidiUtils;
3231
import com.google.template.soy.jssrc.SoyJsSrcOptions;
3332
import com.google.template.soy.jssrc.internal.OptimizeBidiCodeGenVisitor;
34-
import com.google.template.soy.passes.IjDataQueries;
3533
import com.google.template.soy.shared.internal.ApiCallScopeUtils;
3634
import com.google.template.soy.shared.internal.GuiceSimpleScope;
3735
import com.google.template.soy.shared.internal.GuiceSimpleScope.WithScope;
3836
import com.google.template.soy.shared.internal.MainEntryPointUtils;
3937
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.ApiCall;
40-
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.IsUsingIjData;
4138
import com.google.template.soy.sharedpasses.opti.SimplifyVisitor;
4239
import com.google.template.soy.soytree.SoyFileNode;
4340
import com.google.template.soy.soytree.SoyFileSetNode;
@@ -111,10 +108,6 @@ public List<String> genJsSrc(
111108
SoyJsSrcOptions jsSrcOptions)
112109
throws SoySyntaxException {
113110

114-
// Generate code with the opt_ijData param if either (a) the user specified the compiler flag
115-
// --isUsingIjData or (b) any of the Soy code in the file set references injected data.
116-
boolean isUsingIjData = jsSrcOptions.isUsingIjData()
117-
|| IjDataQueries.isUsingIj(soyTree);
118111

119112
// Make sure that we don't try to use goog.i18n.bidi when we aren't supposed to use Closure.
120113
Preconditions.checkState(
@@ -129,7 +122,6 @@ public List<String> genJsSrc(
129122
try (WithScope withScope = apiCallScope.enter()) {
130123
// Seed the scoped parameters.
131124
apiCallScope.seed(SoyJsSrcOptions.class, jsSrcOptions);
132-
apiCallScope.seed(Key.get(Boolean.class, IsUsingIjData.class), isUsingIjData);
133125
BidiGlobalDir bidiGlobalDir = SoyBidiUtils.decodeBidiGlobalDirFromJsOptions(
134126
jsSrcOptions.getBidiGlobalDir(),
135127
jsSrcOptions.getUseGoogIsRtlForBidiGlobalDir());

java/src/com/google/template/soy/jssrc/SoyJsSrcOptions.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ public final class SoyJsSrcOptions implements Cloneable {
2828
/** Whether to allow deprecated syntax (semi backwards compatible mode). */
2929
private boolean shouldAllowDeprecatedSyntax;
3030

31-
/** Whether to enable use of injected data. */
32-
private boolean isUsingIjData;
33-
3431
/** Whether we should generate JSDoc with type info for the Closure Compiler. */
3532
private boolean shouldGenerateJsdoc;
3633

@@ -73,7 +70,6 @@ public final class SoyJsSrcOptions implements Cloneable {
7370

7471
public SoyJsSrcOptions() {
7572
shouldAllowDeprecatedSyntax = false;
76-
isUsingIjData = false;
7773
shouldGenerateJsdoc = false;
7874
shouldProvideRequireSoyNamespaces = false;
7975
shouldProvideRequireJsFunctions = false;
@@ -88,7 +84,6 @@ public SoyJsSrcOptions() {
8884

8985
private SoyJsSrcOptions(SoyJsSrcOptions orig) {
9086
this.shouldAllowDeprecatedSyntax = orig.shouldAllowDeprecatedSyntax;
91-
this.isUsingIjData = orig.isUsingIjData;
9287
this.shouldGenerateJsdoc = orig.shouldGenerateJsdoc;
9388
this.shouldProvideRequireSoyNamespaces = orig.shouldProvideRequireSoyNamespaces;
9489
this.shouldProvideRequireJsFunctions = orig.shouldProvideRequireJsFunctions;
@@ -122,19 +117,11 @@ public boolean shouldAllowDeprecatedSyntax() {
122117
}
123118

124119

120+
// TODO(lukes): delete this
125121
/**
126-
* Sets whether to enable use of injected data (syntax is '$ij.*').
127-
* @param isUsingIjData The code style to set.
122+
* @deprecated This is ignored and it is no longer possible to disable ij
128123
*/
129-
public void setIsUsingIjData(boolean isUsingIjData) {
130-
this.isUsingIjData = isUsingIjData;
131-
}
132-
133-
134-
/** Returns whether use of injected data is currently enabled. */
135-
public boolean isUsingIjData() {
136-
return isUsingIjData;
137-
}
124+
@Deprecated public void setIsUsingIjData(boolean isUsingIjData) {}
138125

139126

140127
/**

java/src/com/google/template/soy/jssrc/internal/GenCallCodeUtils.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.google.template.soy.jssrc.restricted.JsExpr;
2424
import com.google.template.soy.jssrc.restricted.JsExprUtils;
2525
import com.google.template.soy.jssrc.restricted.SoyJsSrcPrintDirective;
26-
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.IsUsingIjData;
2726
import com.google.template.soy.soytree.CallBasicNode;
2827
import com.google.template.soy.soytree.CallDelegateNode;
2928
import com.google.template.soy.soytree.CallNode;
@@ -45,9 +44,6 @@ public class GenCallCodeUtils {
4544
/** All registered JS print directives. */
4645
private final Map<String, SoyJsSrcPrintDirective> soyJsSrcDirectivesMap;
4746

48-
/** Whether any of the Soy code uses injected data. */
49-
private final boolean isUsingIjData;
50-
5147
/** Instance of JsExprTranslator to use. */
5248
private final JsExprTranslator jsExprTranslator;
5349

@@ -58,7 +54,6 @@ public class GenCallCodeUtils {
5854
private final GenJsExprsVisitorFactory genJsExprsVisitorFactory;
5955

6056
/**
61-
* @param isUsingIjData Whether any of the Soy code uses injected data.
6257
* @param jsExprTranslator Instance of JsExprTranslator to use.
6358
* @param isComputableAsJsExprsVisitor The IsComputableAsJsExprsVisitor to be used.
6459
* @param genJsExprsVisitorFactory Factory for creating an instance of GenJsExprsVisitor.
@@ -67,10 +62,9 @@ public class GenCallCodeUtils {
6762
protected
6863
GenCallCodeUtils(
6964
Map<String, SoyJsSrcPrintDirective> soyJsSrcDirectivesMap,
70-
@IsUsingIjData boolean isUsingIjData, JsExprTranslator jsExprTranslator,
65+
JsExprTranslator jsExprTranslator,
7166
IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor,
7267
GenJsExprsVisitorFactory genJsExprsVisitorFactory) {
73-
this.isUsingIjData = isUsingIjData;
7468
this.jsExprTranslator = jsExprTranslator;
7569
this.isComputableAsJsExprsVisitor = isComputableAsJsExprsVisitor;
7670
this.genJsExprsVisitorFactory = genJsExprsVisitorFactory;
@@ -152,8 +146,7 @@ public JsExpr genCallExpr(
152146
}
153147

154148
// Generate the main call expression.
155-
String ijParam = isUsingIjData ? ", null, opt_ijData" : "";
156-
String callExprText = calleeExprText + "(" + objToPass.getText() + ijParam + ")";
149+
String callExprText = calleeExprText + "(" + objToPass.getText() + ", null, opt_ijData)";
157150
JsExpr result = new JsExpr(callExprText, Integer.MAX_VALUE);
158151

159152
// In strict mode, escaping directives may apply to the call site.

java/src/com/google/template/soy/jssrc/internal/GenJsCodeVisitor.java

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import com.google.template.soy.shared.internal.CodeBuilder;
4949
import com.google.template.soy.shared.internal.FindCalleesNotInFileVisitor;
5050
import com.google.template.soy.shared.internal.HasNodeTypesVisitor;
51-
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.IsUsingIjData;
5251
import com.google.template.soy.soytree.CallBasicNode;
5352
import com.google.template.soy.soytree.CallDelegateNode;
5453
import com.google.template.soy.soytree.CallNode;
@@ -128,8 +127,6 @@ public class GenJsCodeVisitor extends AbstractHtmlSoyNodeVisitor<List<String>> {
128127
private static final SoyError NON_NAMESPACED_TEMPLATE =
129128
SoyError.of("Using the option to provide/require Soy namespaces, but called template "
130129
+ "does not reside in a namespace.");
131-
private static final SoyError IJ_PARAMS_DECLARED_BUT_IJ_DATA_NOT_ENABLED =
132-
SoyError.of("Template declares injected params but injected data is not enabled");
133130

134131
/** Regex pattern to look for dots in a template name. */
135132
private static final Pattern DOT = Pattern.compile("\\.");
@@ -147,9 +144,6 @@ public class GenJsCodeVisitor extends AbstractHtmlSoyNodeVisitor<List<String>> {
147144
/** The options for generating JS source code. */
148145
private final SoyJsSrcOptions jsSrcOptions;
149146

150-
/** Whether any of the Soy code uses injected data. */
151-
private final boolean isUsingIjData;
152-
153147
/** Instance of JsExprTranslator to use. */
154148
private final JsExprTranslator jsExprTranslator;
155149

@@ -200,7 +194,7 @@ public class GenJsCodeVisitor extends AbstractHtmlSoyNodeVisitor<List<String>> {
200194

201195
@Inject
202196
protected GenJsCodeVisitor(
203-
SoyJsSrcOptions jsSrcOptions, @IsUsingIjData boolean isUsingIjData,
197+
SoyJsSrcOptions jsSrcOptions,
204198
JsExprTranslator jsExprTranslator, GenCallCodeUtils genCallCodeUtils,
205199
IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor,
206200
CanInitOutputVarVisitor canInitOutputVarVisitor,
@@ -210,7 +204,6 @@ protected GenJsCodeVisitor(
210204
ErrorReporter errorReporter) {
211205
this.errorReporter = errorReporter;
212206
this.jsSrcOptions = jsSrcOptions;
213-
this.isUsingIjData = isUsingIjData;
214207
this.jsExprTranslator = jsExprTranslator;
215208
this.genCallCodeUtils = genCallCodeUtils;
216209
this.isComputableAsJsExprsVisitor = isComputableAsJsExprsVisitor;
@@ -682,10 +675,6 @@ private void addCodeToRequireJsFunctions(SoyFileNode soyFile) {
682675
genJsExprsVisitor = genJsExprsVisitorFactory.create(localVarTranslations, templateAliases);
683676
assistantForMsgs = null;
684677

685-
if (!node.getInjectedParams().isEmpty() && !isUsingIjData) {
686-
errorReporter.report(node.getSourceLocation(), IJ_PARAMS_DECLARED_BUT_IJ_DATA_NOT_ENABLED);
687-
}
688-
689678
// ------ Generate JS Doc. ------
690679
if (jsSrcOptions.shouldGenerateJsdoc()) {
691680
jsCodeBuilder.appendLine("/**");
@@ -695,9 +684,7 @@ private void addCodeToRequireJsFunctions(SoyFileNode soyFile) {
695684
jsCodeBuilder.appendLine(" * @param {Object<string, *>=} opt_data");
696685
}
697686
jsCodeBuilder.appendLine(" * @param {(null|undefined)=} opt_ignored");
698-
if (isUsingIjData) {
699-
jsCodeBuilder.appendLine(" * @param {Object<string, *>=} opt_ijData");
700-
}
687+
jsCodeBuilder.appendLine(" * @param {Object<string, *>=} opt_ijData");
701688
// For strict autoescaping templates, the result is actually a typesafe wrapper.
702689
// We prepend "!" to indicate it is non-nullable.
703690
String returnType = (node.getContentKind() == null)
@@ -713,11 +700,10 @@ private void addCodeToRequireJsFunctions(SoyFileNode soyFile) {
713700
}
714701

715702
// ------ Generate function definition up to opening brace. ------
716-
String ijParam = isUsingIjData ? ", opt_ijData" : "";
717703
if (addToExports) {
718-
jsCodeBuilder.appendLine("function ", alias, "(opt_data, opt_ignored", ijParam, ") {");
704+
jsCodeBuilder.appendLine("function ", alias, "(opt_data, opt_ignored, opt_ijData) {");
719705
} else {
720-
jsCodeBuilder.appendLine(alias, " = function(opt_data, opt_ignored", ijParam, ") {");
706+
jsCodeBuilder.appendLine(alias, " = function(opt_data, opt_ignored, opt_ijData) {");
721707
}
722708
jsCodeBuilder.increaseIndent();
723709
// If there are any null coalescing operators or switch nodes then we need to generate an

java/src/com/google/template/soy/jssrc/internal/JsSrcMain.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,18 @@
2323
import com.google.common.collect.Iterables;
2424
import com.google.common.collect.Multimap;
2525
import com.google.common.io.Files;
26-
import com.google.inject.Key;
2726
import com.google.template.soy.base.SoySyntaxException;
2827
import com.google.template.soy.error.ErrorReporter;
2928
import com.google.template.soy.internal.i18n.BidiGlobalDir;
3029
import com.google.template.soy.internal.i18n.SoyBidiUtils;
3130
import com.google.template.soy.jssrc.SoyJsSrcOptions;
3231
import com.google.template.soy.msgs.SoyMsgBundle;
3332
import com.google.template.soy.msgs.internal.InsertMsgsVisitor;
34-
import com.google.template.soy.passes.IjDataQueries;
3533
import com.google.template.soy.shared.internal.ApiCallScopeUtils;
3634
import com.google.template.soy.shared.internal.GuiceSimpleScope;
3735
import com.google.template.soy.shared.internal.GuiceSimpleScope.WithScope;
3836
import com.google.template.soy.shared.internal.MainEntryPointUtils;
3937
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.ApiCall;
40-
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.IsUsingIjData;
4138
import com.google.template.soy.sharedpasses.opti.SimplifyVisitor;
4239
import com.google.template.soy.soytree.SoyFileNode;
4340
import com.google.template.soy.soytree.SoyFileSetNode;
@@ -112,11 +109,6 @@ public JsSrcMain(
112109
public List<String> genJsSrc(
113110
SoyFileSetNode soyTree, SoyJsSrcOptions jsSrcOptions, @Nullable SoyMsgBundle msgBundle) {
114111

115-
// Generate code with the opt_ijData param if either (a) the user specified the compiler flag
116-
// --isUsingIjData or (b) any of the Soy code in the file set references injected data.
117-
boolean isUsingIjData = jsSrcOptions.isUsingIjData()
118-
|| IjDataQueries.isUsingIj(soyTree);
119-
120112
// Make sure that we don't try to use goog.i18n.bidi when we aren't supposed to use Closure.
121113
Preconditions.checkState(
122114
!jsSrcOptions.getUseGoogIsRtlForBidiGlobalDir() ||
@@ -128,7 +120,6 @@ public List<String> genJsSrc(
128120
try (WithScope withScope = apiCallScope.enter()) {
129121
// Seed the scoped parameters.
130122
apiCallScope.seed(SoyJsSrcOptions.class, jsSrcOptions);
131-
apiCallScope.seed(Key.get(Boolean.class, IsUsingIjData.class), isUsingIjData);
132123
BidiGlobalDir bidiGlobalDir = SoyBidiUtils.decodeBidiGlobalDirFromJsOptions(
133124
jsSrcOptions.getBidiGlobalDir(),
134125
jsSrcOptions.getUseGoogIsRtlForBidiGlobalDir());

java/src/com/google/template/soy/shared/internal/SharedModule.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.google.template.soy.coredirectives.CoreDirectivesModule;
2424
import com.google.template.soy.internal.i18n.BidiGlobalDir;
2525
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.ApiCall;
26-
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.IsUsingIjData;
2726
import com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.LocaleString;
2827
import com.google.template.soy.shared.restricted.SoyFunction;
2928
import com.google.template.soy.shared.restricted.SoyJavaPrintDirective;
@@ -60,9 +59,6 @@ public final class SharedModule extends AbstractModule {
6059
.toInstance(apiCallScope);
6160

6261
// Bind unscoped providers for parameters in ApiCallScope (these throw exceptions).
63-
bind(Boolean.class).annotatedWith(IsUsingIjData.class)
64-
.toProvider(GuiceSimpleScope.<Boolean>getUnscopedProvider())
65-
.in(ApiCallScope.class);
6662
bind(String.class).annotatedWith(LocaleString.class)
6763
.toProvider(GuiceSimpleScope.<String>getUnscopedProvider())
6864
.in(ApiCallScope.class);

java/src/com/google/template/soy/shared/restricted/ApiCallScopeBindingAnnotations.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ private ApiCallScopeBindingAnnotations() {}
4747
public @interface ApiCall {}
4848

4949

50-
/**
51-
* Annotation for the isIsingIjData parameter in the ApiCallScope.
52-
*/
53-
@BindingAnnotation
54-
@Target({FIELD, PARAMETER, METHOD})
55-
@Retention(RUNTIME)
56-
public @interface IsUsingIjData {}
57-
58-
5950
/**
6051
* Annotation for the localeString parameter in the ApiCallScope.
6152
*/

0 commit comments

Comments
 (0)