WEB-13490 Debug for Meteor packages doesn't work

This commit is contained in:
Vladimir Krivosheev
2015-02-10 12:58:43 +01:00
parent 21e31ea959
commit f0e4ca1afb
4 changed files with 21 additions and 13 deletions
@@ -49,9 +49,10 @@ public final class SourceMapDecoder {
public interface SourceResolverFactory {
@NotNull
SourceResolver create(@NotNull List<String> sourcesUrl, @Nullable List<String> sourcesContent);
SourceResolver create(@NotNull List<String> sourceUrls, @Nullable List<String> 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");
@@ -21,7 +21,7 @@ import java.util.List;
public class SourceResolver {
private final List<String> rawSources;
@Nullable private final List<String> sourcesContent;
@Nullable private final List<String> sourceContents;
final Url[] canonicalizedSources;
private final ObjectIntHashMap<Url> 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<String> sourcesUrl, boolean trimFileScheme, @Nullable Url baseFileUrl, @Nullable List<String> sourcesContent) {
rawSources = sourcesUrl;
this.sourcesContent = sourcesContent;
canonicalizedSources = new Url[sourcesUrl.size()];
public SourceResolver(@NotNull List<String> sourceUrls, boolean trimFileScheme, @Nullable Url baseFileUrl, @Nullable List<String> sourceContents) {
rawSources = sourceUrls;
this.sourceContents = sourceContents;
canonicalizedSources = new Url[sourceUrls.size()];
canonicalizedSourcesMap = SystemInfo.isFileSystemCaseSensitive
? new ObjectIntHashMap<Url>(canonicalizedSources.length)
: new ObjectIntHashMap<Url>(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
@@ -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<VM extends Vm> {
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<VM extends Vm> {
@NotNull
public static <T> Promise<T> reject() {
return Promise.reject("Obsolete context");
//noinspection unchecked
return (Promise<T>)OBSOLETE_CONTEXT_PROMISE;
}
@NotNull
@@ -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<Throwable> {
@@ -25,6 +26,8 @@ public final class RejectErrorReporter implements Consumer<Throwable> {
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());
}
}
}