diff options
author | Tor Norbye <tnorbye@google.com> | 2014-09-04 20:44:00 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-04 20:44:01 +0000 |
commit | fb5a02906f644d044eb0286bf27d413ba0e05216 (patch) | |
tree | bca7d49005d81d10c70bc3f547df041c636b4300 /platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java | |
parent | 9cde0e3c015174898df8b8f3672185941fad4786 (diff) | |
parent | d245f58efbfc26b13b9b9d5e52e6a83a0d76216c (diff) | |
download | idea-fb5a02906f644d044eb0286bf27d413ba0e05216.tar.gz |
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge"
Diffstat (limited to 'platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java')
-rw-r--r-- | platform/script-debugger/backend/src/org/jetbrains/debugger/sourcemap/SourceResolver.java | 23 |
1 files changed, 18 insertions, 5 deletions
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 38693e4ac3ae..665039507ace 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 @@ -8,6 +8,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Url; import com.intellij.util.UrlImpl; import com.intellij.util.Urls; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ObjectIntHashMap; import com.intellij.util.io.URLUtil; import com.intellij.util.text.CaseInsensitiveStringHashingStrategy; @@ -20,6 +21,7 @@ import java.util.List; public class SourceResolver { private final List<String> rawSources; + @Nullable private final List<String> sourcesContent; final Url[] canonicalizedSources; private final ObjectIntHashMap<Url> canonicalizedSourcesMap; @@ -28,14 +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<String> sources, boolean trimFileScheme, @Nullable Url baseFileUrl) { - rawSources = sources; - canonicalizedSources = new Url[sources.size()]; + public SourceResolver(@NotNull List<String> sourcesUrl, boolean trimFileScheme, @Nullable Url baseFileUrl, @Nullable List<String> sourcesContent) { + rawSources = sourcesUrl; + this.sourcesContent = sourcesContent; + canonicalizedSources = new Url[sourcesUrl.size()]; canonicalizedSourcesMap = SystemInfo.isFileSystemCaseSensitive ? new ObjectIntHashMap<Url>(canonicalizedSources.length) : new ObjectIntHashMap<Url>(canonicalizedSources.length, Urls.getCaseInsensitiveUrlHashingStrategy()); - for (int i = 0; i < sources.size(); i++) { - String rawSource = sources.get(i); + for (int i = 0; i < sourcesUrl.size(); i++) { + String rawSource = sourcesUrl.get(i); Url url = canonicalizeUrl(rawSource, baseFileUrl, trimFileScheme, i); canonicalizedSources[i] = url; canonicalizedSourcesMap.put(url, i); @@ -111,6 +114,16 @@ public class SourceResolver { } @Nullable + public String getSourceContent(@NotNull MappingEntry entry) { + if (ContainerUtil.isEmpty(sourcesContent)) { + return null; + } + + int index = entry.getSource(); + return index < 0 || index >= sourcesContent.size() ? null : sourcesContent.get(index); + } + + @Nullable public String getRawSource(@NotNull MappingEntry entry) { int index = entry.getSource(); return index < 0 ? null : rawSources.get(index); |