From 9b8a771df3f711af1ef6e5db014f54333394efde Mon Sep 17 00:00:00 2001 From: drawsvg Date: Tue, 14 Mar 2023 22:26:10 +0100 Subject: [PATCH] Update StoryRecorder.java --- .../gwt/core/ext/soyc/impl/StoryRecorder.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorder.java b/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorder.java index beada0d13e1..bfa7223d38b 100644 --- a/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorder.java +++ b/dev/core/src/com/google/gwt/core/ext/soyc/impl/StoryRecorder.java @@ -169,16 +169,13 @@ private void analyzeFragment(MemberFactory memberFactory, TreeSet c assert info != null; // Infer dependency information - if (!dependencyScope.isEmpty()) { - + while (!dependencyScope.isEmpty() && !dependencyScope.peek().range.contains(range)) { /* * Pop frames until we get back to a container, using this as a chance * to build up our list of non-overlapping Ranges to report back to the * user. */ - while (!dependencyScope.peek().range.contains(range)) { - popAndRecord(dependencyScope, fragment); - } + popAndRecord(dependencyScope, fragment); } // Possibly create and record Members @@ -271,7 +268,7 @@ private void emitStory(StoryImpl story, Range range) throws IOException { builder.append("\"/>\n\n"); } else { builder.append("\">"); - SizeMapRecorder.escapeXml(jsCode, start, end, false, builder); + SizeMapRecorder.escapeXml(jsCode, start, Math.min(end,jsCode.length()), false, builder); builder.append("\n\n"); } } @@ -297,7 +294,7 @@ private void popAndRecord(Stack dependencyScope, int fragment) throws * Make a new Range for the gap between the popped Range and whatever we * last stored. */ - if (lastEnd < toStore.getStart()) { + if (lastEnd < toStore.getStart() && !dependencyScope.isEmpty()) { Range newRange = new Range(lastEnd, toStore.getStart()); assert !dependencyScope.isEmpty(); @@ -351,7 +348,9 @@ private void recordStory(SourceInfo info, int fragment, int length, Range range) theStory = new StoryImpl(storyCache.get(info), length); } - emitStory(theStory, range); + if (range.getStart() < js[curHighestFragment].length()) { + emitStory(theStory, range); + } } }