@@ -39,7 +39,7 @@ public JavaScriptHTMLElementHandler(TextualExtractor textualExtractor) {
3939 this .textualExtractor = textualExtractor ;
4040
4141 this .scopeManager =
42- new ScopeManager (textualExtractor .getTrapwriter (), config .getEcmaVersion ());
42+ new ScopeManager (textualExtractor .getTrapwriter (), config .getEcmaVersion (), true );
4343 }
4444
4545 /*
@@ -382,21 +382,6 @@ private void emitTopLevelXmlNodeBinding(
382382 writer .addTuple ("toplevel_parent_xml_node" , topLevelLabel , htmlNodeLabel );
383383 }
384384
385- private static final String MUSTACHE_TAG_DOUBLE = "\\ {\\ {(?!\\ {)(.*?)\\ }\\ }" ; // {{ x }}
386- private static final String MUSTACHE_TAG_TRIPLE = "\\ {\\ {\\ {(.*?)\\ }\\ }\\ }" ; // {{{ x }}}
387- private static final String MUSTACHE_TAG_PERCENT = "\\ {%(?!>)(.*?)%\\ }" ; // {% x %}
388- private static final String EJS_TAG = "<%(?![%<>}])[-=]?(.*?)[_-]?%>" ; // <% x %>
389-
390- /** Pattern for a template tag whose contents should be parsed as an expression */
391- private static final Pattern TEMPLATE_EXPR_OPENING_TAG =
392- Pattern .compile ("^(?:\\ {\\ {\\ {?|<%[-=])" ); // {{, {{{, <%=, <%-
393-
394- private static final Pattern TEMPLATE_TAGS =
395- Pattern .compile (
396- StringUtil .glue (
397- "|" , MUSTACHE_TAG_DOUBLE , MUSTACHE_TAG_TRIPLE , MUSTACHE_TAG_PERCENT , EJS_TAG ),
398- Pattern .DOTALL );
399-
400385 private void extractTemplateTags (
401386 TextualExtractor textualExtractor ,
402387 ScopeManager scopeManager ,
@@ -407,9 +392,8 @@ private void extractTemplateTags(
407392 if (start >= end ) return ;
408393 if (isEmbedded ) return ; // Do not extract template tags for HTML snippets embedded in a JS file
409394
410- LocationManager locationManager = textualExtractor .getLocationManager ();
411395 TrapWriter trapwriter = textualExtractor .getTrapwriter ();
412- Matcher m = TEMPLATE_TAGS .matcher (textualExtractor .getSource ()).region (start , end );
396+ Matcher m = TemplateEngines . TEMPLATE_TAGS .matcher (textualExtractor .getSource ()).region (start , end );
413397 while (m .find ()) {
414398 int startOffset = m .start ();
415399 int endOffset = m .end ();
@@ -424,15 +408,12 @@ private void extractTemplateTags(
424408 String rawText = m .group ();
425409 trapwriter .addTuple ("template_placeholder_tag_info" , lbl , parentLabel .get (), rawText );
426410
427- // Emit location
428- Position startPos = textualExtractor .getSourceMap ().getStart (startOffset );
429- Position endPos = textualExtractor .getSourceMap ().getEnd (endOffset - 1 );
430- int endColumn = endPos .getColumn () - 1 ; // Convert to inclusive end position (still 1-based)
431- locationManager .emitFileLocation (
432- lbl , startPos .getLine (), startPos .getColumn (), endPos .getLine (), endColumn );
411+ // Emit location entity
412+ Label locationLbl = TemplateEngines .makeLocation (textualExtractor , startOffset , endOffset );
413+ trapwriter .addTuple ("hasLocation" , lbl , locationLbl );
433414
434415 // Parse the contents as a template expression, if the delimiter expects an expression.
435- Matcher delimMatcher = TEMPLATE_EXPR_OPENING_TAG .matcher (rawText );
416+ Matcher delimMatcher = TemplateEngines . TEMPLATE_EXPR_OPENING_TAG .matcher (rawText );
436417 if (delimMatcher .find ()) {
437418 // The body of the template tag is stored in the first capture group of each pattern
438419 int bodyGroup = getNonNullCaptureGroup (m );
0 commit comments