Report errors in JS source maps as compiler warnings
This commit is contained in:
@@ -49,7 +49,12 @@ private val JS_IDENTIFIER="[$JS_IDENTIFIER_START][$JS_IDENTIFIER_PART]*"
|
||||
private val DEFINE_MODULE_PATTERN = ("($JS_IDENTIFIER)\\.defineModule\\(\\s*(['\"])([^'\"]+)\\2\\s*,\\s*(\\w+)\\s*\\)").toRegex().toPattern()
|
||||
private val DEFINE_MODULE_FIND_PATTERN = ".defineModule("
|
||||
|
||||
class FunctionReader(private val config: JsConfig, private val currentModuleName: JsName, fragments: List<JsProgramFragment>) {
|
||||
class FunctionReader(
|
||||
private val reporter: JsConfig.Reporter,
|
||||
private val config: JsConfig,
|
||||
private val currentModuleName: JsName,
|
||||
fragments: List<JsProgramFragment>
|
||||
) {
|
||||
/**
|
||||
* fileContent: .js file content, that contains this module definition.
|
||||
* One file can contain more than one module definition.
|
||||
@@ -98,7 +103,10 @@ class FunctionReader(private val config: JsConfig, private val currentModuleName
|
||||
val result = SourceMapParser.parse(StringReader(it))
|
||||
when (result) {
|
||||
is SourceMapSuccess -> result.value
|
||||
is SourceMapError -> throw RuntimeException("Error parsing source map file: ${result.message}\n$it")
|
||||
is SourceMapError -> {
|
||||
reporter.warning("Error parsing source map file for $path: ${result.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
node -> node instanceof JsInvocation && hasToBeInlined((JsInvocation) node);
|
||||
|
||||
public static void process(
|
||||
@NotNull JsConfig.Reporter reporter,
|
||||
@NotNull JsConfig config,
|
||||
@NotNull DiagnosticSink trace,
|
||||
@NotNull JsName currentModuleName,
|
||||
@@ -76,7 +77,7 @@ public class JsInliner extends JsVisitorWithContextImpl {
|
||||
accessorInvocationTransformer.accept(fragment.getDeclarationBlock());
|
||||
accessorInvocationTransformer.accept(fragment.getInitializerBlock());
|
||||
}
|
||||
FunctionReader functionReader = new FunctionReader(config, currentModuleName, fragments);
|
||||
FunctionReader functionReader = new FunctionReader(reporter, config, currentModuleName, fragments);
|
||||
JsInliner inliner = new JsInliner(config, functions, accessors, functionReader, trace);
|
||||
for (JsProgramFragment fragment : fragmentsToProcess) {
|
||||
inliner.inliningContexts.push(inliner.new JsInliningContext());
|
||||
|
||||
Reference in New Issue
Block a user