Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update StoryRecorder.java #9808

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,13 @@ private void analyzeFragment(MemberFactory memberFactory, TreeSet<ClassMember> 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
Expand Down Expand Up @@ -271,7 +268,7 @@ private void emitStory(StoryImpl story, Range range) throws IOException {
builder.append("\"/>\n</story>\n");
} else {
builder.append("\">");
SizeMapRecorder.escapeXml(jsCode, start, end, false, builder);
SizeMapRecorder.escapeXml(jsCode, start, Math.min(end,jsCode.length()), false, builder);
builder.append("</storyref>\n</story>\n");
}
}
Expand All @@ -297,7 +294,7 @@ private void popAndRecord(Stack<RangeInfo> 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();

Expand Down Expand Up @@ -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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check start < length was added outside of emitStory, check that end <= length was added inside that method -- maybe both checks should be in one place -- inside emitStory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think so.
It seems that the value of the end of range property is wrong.
The call to emitStory must be kept to get the description of the story.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, feel free to disregard

emitStory(theStory, range);
}
}

}