fix chrome evaluator SourceEntriesProcessor — mapping can cover the whole line

This commit is contained in:
Vladimir Krivosheev
2015-06-10 15:44:54 +02:00
parent 9f1bfe5f55
commit fde1f62b67
2 changed files with 46 additions and 6 deletions
@@ -1,7 +1,21 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.debugger.sourcemap;
import com.intellij.openapi.editor.Document;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -161,8 +175,12 @@ public abstract class MappingList {
return mappings.get(index);
}
public interface MappingsProcessorInLine {
boolean process(@NotNull MappingEntry entry, @Nullable MappingEntry nextEntry);
}
// entries will be processed in this list order
public boolean processMappingsInLine(int line, @NotNull Processor<MappingEntry> entryProcessor) {
public boolean processMappingsInLine(int line, @NotNull MappingsProcessorInLine entryProcessor) {
int low = 0;
int high = mappings.size() - 1;
while (low <= high) {
@@ -176,12 +194,20 @@ public abstract class MappingList {
firstIndex--;
}
MappingEntry entry = mappings.get(firstIndex);
do {
if (!entryProcessor.process(mappings.get(firstIndex))) {
MappingEntry nextEntry = ++firstIndex < mappings.size() ? mappings.get(firstIndex) : null;
if (nextEntry != null && getLine(nextEntry) != line) {
nextEntry = null;
}
if (!entryProcessor.process(entry, nextEntry)) {
return true;
}
entry = nextEntry;
}
while (++firstIndex < mappings.size() && getLine(mappings.get(firstIndex)) == line);
while (entry != null);
return true;
}
else if (line > mappingLine) {
@@ -1,8 +1,22 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.debugger.sourcemap;
import com.intellij.openapi.util.NullableLazyValue;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Processor;
import com.intellij.util.Url;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -73,7 +87,7 @@ public class SourceMap {
public boolean processMappingsInLine(@NotNull List<Url> sourceUrls,
int sourceLine,
@NotNull Processor<MappingEntry> mappingProcessor,
@NotNull MappingList.MappingsProcessorInLine mappingProcessor,
@Nullable VirtualFile sourceFile,
@Nullable NullableLazyValue<SourceResolver.Resolver> resolver) {
MappingList mappings = findMappingList(sourceUrls, sourceFile, resolver);