diff --git a/src/com/google/javascript/jscomp/JsAst.java b/src/com/google/javascript/jscomp/JsAst.java index d1a8ecc422f..c38a2f26c61 100644 --- a/src/com/google/javascript/jscomp/JsAst.java +++ b/src/com/google/javascript/jscomp/JsAst.java @@ -19,16 +19,12 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.javascript.jscomp.base.JSCompObjects.identical; -import com.google.common.collect.ImmutableList; import com.google.javascript.jscomp.parsing.ParserRunner; import com.google.javascript.jscomp.parsing.parser.FeatureSet; -import com.google.javascript.rhino.ErrorReporter; import com.google.javascript.rhino.IR; import com.google.javascript.rhino.InputId; import com.google.javascript.rhino.Node; import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; import java.util.function.Supplier; import org.jspecify.annotations.Nullable; @@ -93,74 +89,21 @@ public FeatureSet getFeatures(AbstractCompiler compiler) { return features; } - /** Representation of Rhino parser error. */ - public static class RhinoError implements Serializable { - private static final long serialVersionUID = 1L; - - public final String message; - public final String sourceName; - public final int line; - public final int lineOffset; - - public RhinoError(String message, String sourceName, int line, int lineOffset) { - this.message = message; - this.sourceName = sourceName; - this.line = line; - this.lineOffset = lineOffset; - } - } - - /** Simple class to share parse results between compilation jobs */ - public static class ParseResult implements Serializable { - private static final long serialVersionUID = 1L; - - public final ImmutableList errors; - public final ImmutableList warnings; - - ParseResult(ImmutableList errors, ImmutableList warnings) { - this.errors = errors; - this.warnings = warnings; - } - } - - private static class RecordingReporterProxy implements ErrorReporter { - final ArrayList errors = new ArrayList<>(); - final ArrayList warnings = new ArrayList<>(); - private final ErrorReporter delegateReporter; - - RecordingReporterProxy(ErrorReporter delegateReporter) { - this.delegateReporter = delegateReporter; - } - - @Override - public void warning(String message, String sourceName, int line, int lineOffset) { - warnings.add(new RhinoError(message, sourceName, line, lineOffset)); - delegateReporter.warning(message, sourceName, line, lineOffset); - } - - @Override - public void error(String message, String sourceName, int line, int lineOffset) { - errors.add(new RhinoError(message, sourceName, line, lineOffset)); - delegateReporter.error(message, sourceName, line, lineOffset); - } - } - boolean isParsed() { return root != null; } private void parse(AbstractCompiler compiler) { - RecordingReporterProxy reporter = new RecordingReporterProxy( - compiler.getDefaultErrorReporter()); - try { - ParserRunner.ParseResult result = ParserRunner.parse( - sourceFile, - sourceFile.getCode(), - compiler.getParserConfig(sourceFile.isExtern() - ? AbstractCompiler.ConfigContext.EXTERNS - : AbstractCompiler.ConfigContext.DEFAULT), - reporter); + ParserRunner.ParseResult result = + ParserRunner.parse( + sourceFile, + sourceFile.getCode(), + compiler.getParserConfig( + sourceFile.isExtern() + ? AbstractCompiler.ConfigContext.EXTERNS + : AbstractCompiler.ConfigContext.DEFAULT), + compiler.getDefaultErrorReporter()); root = result.ast; features = result.features; @@ -184,13 +127,6 @@ private void parse(AbstractCompiler compiler) { root = IR.script(); } - if (!reporter.errors.isEmpty() || !reporter.warnings.isEmpty()) { - ParseResult result = new ParseResult( - ImmutableList.copyOf(reporter.errors), - ImmutableList.copyOf(reporter.warnings)); - root.putProp(Node.PARSE_RESULTS, result); - } - // Set the source name so that the compiler passes can track // the source file and module. root.setStaticSourceFile(sourceFile); diff --git a/src/com/google/javascript/rhino/Node.java b/src/com/google/javascript/rhino/Node.java index 596d1b427d7..cb77741ecc1 100644 --- a/src/com/google/javascript/rhino/Node.java +++ b/src/com/google/javascript/rhino/Node.java @@ -163,9 +163,6 @@ enum Prop { ACCESS_MODIFIER, // Indicates the node should not be indexed by analysis tools. NON_INDEXABLE, - // Parse results stored on SCRIPT nodes to allow replaying parse warnings/errors when cloning - // cached ASTs. - PARSE_RESULTS, // Indicates that a SCRIPT node is a goog.module. Remains set after the goog.module is // desugared. GOOG_MODULE, @@ -284,7 +281,6 @@ public final boolean getIsParenthesized() { public static final Prop IMPLEMENTS = Prop.IMPLEMENTS; public static final Prop CONSTRUCT_SIGNATURE = Prop.CONSTRUCT_SIGNATURE; public static final Prop ACCESS_MODIFIER = Prop.ACCESS_MODIFIER; - public static final Prop PARSE_RESULTS = Prop.PARSE_RESULTS; public static final Prop GOOG_MODULE = Prop.GOOG_MODULE; public static final Prop FEATURE_SET = Prop.FEATURE_SET; public static final Prop IS_TYPESCRIPT_ABSTRACT = Prop.IS_TYPESCRIPT_ABSTRACT; diff --git a/src/com/google/javascript/rhino/PropTranslator.java b/src/com/google/javascript/rhino/PropTranslator.java index 57f981a8856..0c890f497ed 100644 --- a/src/com/google/javascript/rhino/PropTranslator.java +++ b/src/com/google/javascript/rhino/PropTranslator.java @@ -172,7 +172,6 @@ private static final void setProps() { case IMPLEMENTS: case CONSTRUCT_SIGNATURE: case ACCESS_MODIFIER: - case PARSE_RESULTS: case IS_TYPESCRIPT_ABSTRACT: case TYPEDEF_TYPE: // These cases cannot be translated to a NodeProperty