diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java index 2e7a982ee1d8..c3ff56116ed1 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceMapDecoder.java @@ -49,9 +49,10 @@ public final class SourceMapDecoder { public interface SourceResolverFactory { @NotNull - SourceResolver create(@NotNull List sourcesUrl, @Nullable List sourcesContent); + SourceResolver create(@NotNull List sourceUrls, @Nullable List sourceContents); } + @Nullable public static SourceMap decode(@NotNull String contents, @NotNull SourceResolverFactory sourceResolverFactory) throws IOException { if (contents.isEmpty()) { throw new IOException("source map contents cannot be empty"); diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java index 665039507ace..240ea8288562 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java @@ -21,7 +21,7 @@ import java.util.List; public class SourceResolver { private final List rawSources; - @Nullable private final List sourcesContent; + @Nullable private final List sourceContents; final Url[] canonicalizedSources; private final ObjectIntHashMap canonicalizedSourcesMap; @@ -30,15 +30,15 @@ public class SourceResolver { // absoluteLocalPathToSourceIndex contains canonical paths too, but this map contains only used (specified in the source map) path private String[] sourceIndexToAbsoluteLocalPath; - public SourceResolver(@NotNull List sourcesUrl, boolean trimFileScheme, @Nullable Url baseFileUrl, @Nullable List sourcesContent) { - rawSources = sourcesUrl; - this.sourcesContent = sourcesContent; - canonicalizedSources = new Url[sourcesUrl.size()]; + public SourceResolver(@NotNull List sourceUrls, boolean trimFileScheme, @Nullable Url baseFileUrl, @Nullable List sourceContents) { + rawSources = sourceUrls; + this.sourceContents = sourceContents; + canonicalizedSources = new Url[sourceUrls.size()]; canonicalizedSourcesMap = SystemInfo.isFileSystemCaseSensitive ? new ObjectIntHashMap(canonicalizedSources.length) : new ObjectIntHashMap(canonicalizedSources.length, Urls.getCaseInsensitiveUrlHashingStrategy()); - for (int i = 0; i < sourcesUrl.size(); i++) { - String rawSource = sourcesUrl.get(i); + for (int i = 0; i < sourceUrls.size(); i++) { + String rawSource = sourceUrls.get(i); Url url = canonicalizeUrl(rawSource, baseFileUrl, trimFileScheme, i); canonicalizedSources[i] = url; canonicalizedSourcesMap.put(url, i); @@ -50,7 +50,7 @@ public class SourceResolver { } // see canonicalizeUri kotlin impl and https://trac.webkit.org/browser/trunk/Source/WebCore/inspector/front-end/ParsedURL.js completeURL - private Url canonicalizeUrl(@NotNull String url, @Nullable Url baseUrl, boolean trimFileScheme, int sourceIndex) { + protected Url canonicalizeUrl(@NotNull String url, @Nullable Url baseUrl, boolean trimFileScheme, int sourceIndex) { if (trimFileScheme && url.startsWith(StandardFileSystems.FILE_PROTOCOL_PREFIX)) { return Urls.newLocalFileUrl(FileUtil.toCanonicalPath(VfsUtilCore.toIdeaUrl(url, true).substring(StandardFileSystems.FILE_PROTOCOL_PREFIX.length()), '/')); } @@ -115,12 +115,12 @@ public class SourceResolver { @Nullable public String getSourceContent(@NotNull MappingEntry entry) { - if (ContainerUtil.isEmpty(sourcesContent)) { + if (ContainerUtil.isEmpty(sourceContents)) { return null; } int index = entry.getSource(); - return index < 0 || index >= sourcesContent.size() ? null : sourcesContent.get(index); + return index < 0 || index >= sourceContents.size() ? null : sourceContents.get(index); } @Nullable diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java index ca04171af5eb..b5eb802e8dec 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.java @@ -16,6 +16,9 @@ import java.util.concurrent.atomic.AtomicInteger; * Currently WIP implementation doesn't keep such map due to protocol issue. But V8 does. */ public abstract class ValueManager { + public static final RuntimeException OBSOLETE_CONTEXT_ERROR = Promise.createError("Obsolete context"); + public static final Promise OBSOLETE_CONTEXT_PROMISE = Promise.reject(OBSOLETE_CONTEXT_ERROR); + private final AtomicInteger cacheStamp = new AtomicInteger(); private volatile boolean obsolete; @@ -61,7 +64,8 @@ public abstract class ValueManager { @NotNull public static Promise reject() { - return Promise.reject("Obsolete context"); + //noinspection unchecked + return (Promise)OBSOLETE_CONTEXT_PROMISE; } @NotNull diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java index 8aaac1ef0c63..4e0e2feeed3b 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/RejectErrorReporter.java @@ -5,6 +5,7 @@ import com.intellij.xdebugger.XDebugSession; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.concurrency.Promise; +import org.jetbrains.debugger.values.ValueManager; import org.jetbrains.rpc.CommandProcessor; public final class RejectErrorReporter implements Consumer { @@ -25,6 +26,8 @@ public final class RejectErrorReporter implements Consumer { if (!(error instanceof Promise.MessageError)) { CommandProcessor.LOG.error(error); } - session.reportError((description == null ? "" : description + ": ") + error.getMessage()); + if (error != ValueManager.OBSOLETE_CONTEXT_ERROR) { + session.reportError((description == null ? "" : description + ": ") + error.getMessage()); + } } } \ No newline at end of file