diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/MappingList.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/MappingList.java index 0248b404e227..b1c3722ffc95 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/MappingList.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/MappingList.java @@ -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 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) { diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMap.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMap.java index b8618af5381d..46f64afc24e2 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMap.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMap.java @@ -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 sourceUrls, int sourceLine, - @NotNull Processor mappingProcessor, + @NotNull MappingList.MappingsProcessorInLine mappingProcessor, @Nullable VirtualFile sourceFile, @Nullable NullableLazyValue resolver) { MappingList mappings = findMappingList(sourceUrls, sourceFile, resolver);