Skip to content

Commit 1798aec

Browse files
lauraharkercopybara-github
authored andcommitted
Add a checkNotNull precondition check to CompilerInput & clean up some comments
PiperOrigin-RevId: 696970971
1 parent 150b5ad commit 1798aec

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/com/google/javascript/jscomp/CompilerInput.java

+7-14
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
import org.jspecify.annotations.Nullable;
4848

4949
/**
50-
* A class for the internal representation of an input to the compiler. Wraps a {@link SourceAst}
51-
* and maintain state such as module for the input and whether the input is an extern. Also
52-
* calculates provided and required types.
50+
* A class for the internal representation of an input to the compiler. Wraps a {@link JsAst} and
51+
* maintain state such as module for the input and whether the input is an extern. Also calculates
52+
* provided and required types.
5353
*/
5454
public class CompilerInput implements DependencyInfo {
5555

@@ -108,20 +108,20 @@ public CompilerInput(SourceFile file, InputId inputId) {
108108
}
109109

110110
/**
111-
* @deprecated the inputId is read from the SourceAst. Use CompilerInput(ast, isExtern)
111+
* @deprecated the inputId is read from the SourceFile. Use CompilerInput(file, isExtern)
112112
*/
113113
@Deprecated
114114
public CompilerInput(SourceFile sourceFile, String inputId, boolean isExtern) {
115115
this(sourceFile, new InputId(inputId), isExtern);
116116
}
117117

118118
/**
119-
* @deprecated the inputId is read from the SourceAst. Use CompilerInput(ast, isExtern)
119+
* @deprecated the inputId is read from the SourceFile. Use CompilerInput(file, isExtern)
120120
*/
121121
@Deprecated
122122
public CompilerInput(SourceFile sourceFile, InputId inputId, boolean isExtern) {
123-
this.sourceFile = sourceFile;
124-
this.id = inputId;
123+
this.sourceFile = checkNotNull(sourceFile);
124+
this.id = checkNotNull(inputId);
125125
if (isExtern) {
126126
setIsExtern();
127127
}
@@ -568,17 +568,10 @@ void overrideModule(JSChunk chunk) {
568568
}
569569

570570
public boolean isExtern() {
571-
if (sourceFile == null) {
572-
return false;
573-
}
574571
return sourceFile.isExtern();
575572
}
576573

577574
void setIsExtern() {
578-
// TODO(tjgq): Add a precondition check here. People are passing in null, but they shouldn't be.
579-
if (sourceFile == null) {
580-
return;
581-
}
582575
sourceFile.setKind(SourceKind.EXTERN);
583576
}
584577

0 commit comments

Comments
 (0)