mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
init WEB-16829 "too soon" typescript breakpoints are not hit
This commit is contained in:
@@ -44,7 +44,7 @@ public final class UrlImpl implements Url {
|
||||
public UrlImpl(@Nullable String scheme, @Nullable String authority, @Nullable String path, @Nullable String parameters) {
|
||||
this.scheme = scheme;
|
||||
this.authority = authority;
|
||||
this.path = StringUtil.isEmpty(path) && !StringUtil.isEmpty(authority) ? "/" : StringUtil.notNullize(path);
|
||||
this.path = StringUtil.notNullize(path);
|
||||
this.parameters = StringUtil.nullize(parameters);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public final class UrlImpl implements Url {
|
||||
|
||||
// relative path - special url, encoding is not required
|
||||
// authority is null in case of URI
|
||||
if ((path.charAt(0) != '/' || authority == null) && !isInLocalFileSystem()) {
|
||||
if ((authority == null || (!path.isEmpty() && path.charAt(0) != '/')) && !isInLocalFileSystem()) {
|
||||
return toDecodedForm();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.jetbrains.io;
|
||||
|
||||
import com.intellij.util.text.CharArrayCharSequence;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.ByteBufUtilEx;
|
||||
@@ -13,13 +12,13 @@ import java.nio.CharBuffer;
|
||||
public final class ChannelBufferToString {
|
||||
@NotNull
|
||||
public static CharSequence readChars(@NotNull ByteBuf buffer) throws IOException {
|
||||
return new MyCharArrayCharSequence(readIntoCharBuffer(buffer, buffer.readableBytes(), null));
|
||||
return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, buffer.readableBytes(), null));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@NotNull
|
||||
public static CharSequence readChars(@NotNull ByteBuf buffer, int byteCount) throws IOException {
|
||||
return new MyCharArrayCharSequence(readIntoCharBuffer(buffer, byteCount, null));
|
||||
return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, byteCount, null));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -34,16 +33,4 @@ public final class ChannelBufferToString {
|
||||
public static void writeIntAsAscii(int value, @NotNull ByteBuf buffer) {
|
||||
ByteBufUtil.writeAscii(buffer, new StringBuilder().append(value));
|
||||
}
|
||||
|
||||
// we must return string on subSequence() - JsonReaderEx will call toString in any case
|
||||
public static final class MyCharArrayCharSequence extends CharArrayCharSequence {
|
||||
public MyCharArrayCharSequence(@NotNull CharBuffer charBuffer) {
|
||||
super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,12 @@ package org.jetbrains.io;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.intellij.util.text.CharArrayCharSequence;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.nio.CharBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class JsonReaderEx implements Closeable {
|
||||
@@ -116,6 +118,22 @@ public final class JsonReaderEx implements Closeable {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
// we must return string on subSequence() - JsonReaderEx will call toString in any case
|
||||
public static final class CharSequenceBackedByChars extends CharArrayCharSequence {
|
||||
public CharSequenceBackedByChars(@NotNull CharBuffer charBuffer) {
|
||||
super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position());
|
||||
}
|
||||
|
||||
public CharSequenceBackedByChars(@NotNull char[] chars, int start, int end) {
|
||||
super(chars, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start);
|
||||
}
|
||||
}
|
||||
|
||||
private final static class JsonScope {
|
||||
/**
|
||||
* An array with no elements requires no separators or newlines before
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class MessageDecoder extends Decoder {
|
||||
chunkedContent = null;
|
||||
consumedContentByteCount = 0;
|
||||
}
|
||||
return new ChannelBufferToString.MyCharArrayCharSequence(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer));
|
||||
return new JsonReaderEx.CharSequenceBackedByChars(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class DebugEventAdapter implements DebugEventListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scriptAdded(@NotNull Script script, @Nullable String sourceMapData) {
|
||||
public void scriptAdded(@NotNull Script script, @Nullable CharSequence sourceMapData) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface DebugEventListener extends EventListener {
|
||||
/**
|
||||
* Reports that a new script has been loaded.
|
||||
*/
|
||||
void scriptAdded(@NotNull Script script, @Nullable String sourceMapData);
|
||||
void scriptAdded(@NotNull Script script, @Nullable CharSequence sourceMapData);
|
||||
|
||||
void sourceMapFound(@NotNull Script script, @Nullable Url sourceMapUrl, @NotNull String sourceMapData);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.debugger;
|
||||
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Url;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
@@ -37,6 +38,9 @@ public interface ScriptManager {
|
||||
@Nullable
|
||||
Script findScriptByUrl(@NotNull String rawUrl);
|
||||
|
||||
@Nullable
|
||||
Script findScriptByUrl(@NotNull Url url);
|
||||
|
||||
@Nullable
|
||||
Script findScriptById(@NotNull String id);
|
||||
|
||||
|
||||
+6
-1
@@ -35,7 +35,12 @@ public abstract class ScriptManagerBaseEx<SCRIPT extends ScriptBase> extends Scr
|
||||
@Nullable
|
||||
@Override
|
||||
public final Script findScriptByUrl(@NotNull String rawUrl) {
|
||||
Url url = rawUrlToOurUrl(rawUrl);
|
||||
return findScriptByUrl(rawUrlToOurUrl(rawUrl));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final Script findScriptByUrl(@NotNull Url url) {
|
||||
for (SCRIPT script : idToScript.values()) {
|
||||
if (url.equalsIgnoreParameters(script.getUrl())) {
|
||||
return script;
|
||||
|
||||
+4
-13
@@ -22,7 +22,6 @@ import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.UriUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.CharSequenceSubSequence;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.io.JsonReaderEx;
|
||||
@@ -69,27 +68,19 @@ public final class SourceMapDecoder {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SourceMap decode(@NotNull String contents, @NotNull SourceResolverFactory sourceResolverFactory) throws IOException {
|
||||
if (contents.isEmpty()) {
|
||||
public static SourceMap decode(@NotNull CharSequence in, @NotNull SourceResolverFactory sourceResolverFactory) throws IOException {
|
||||
if (in.length() == 0) {
|
||||
throw new IOException("source map contents cannot be empty");
|
||||
}
|
||||
|
||||
CharSequence in = contents;
|
||||
if (contents.startsWith(")]}")) {
|
||||
in = new CharSequenceSubSequence(contents, contents.indexOf('\n') + 1, contents.length());
|
||||
}
|
||||
return decode(in, sourceResolverFactory);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SourceMap decode(@NotNull CharSequence in, @NotNull SourceResolverFactory sourceResolverFactory) throws IOException {
|
||||
JsonReaderEx reader = new JsonReaderEx(in);
|
||||
reader.setLenient(true);
|
||||
List<MappingEntry> mappings = new ArrayList<MappingEntry>();
|
||||
return parseMap(reader, 0, 0, mappings, sourceResolverFactory);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static SourceMap parseMap(JsonReaderEx reader,
|
||||
private static SourceMap parseMap(@NotNull JsonReaderEx reader,
|
||||
int line,
|
||||
int column,
|
||||
List<MappingEntry> mappings,
|
||||
|
||||
+17
-8
@@ -47,6 +47,10 @@ public class SourceResolver {
|
||||
private String[] sourceIndexToAbsoluteLocalPath;
|
||||
|
||||
public SourceResolver(@NotNull List<String> sourceUrls, boolean trimFileScheme, @Nullable Url baseFileUrl, @Nullable List<String> sourceContents) {
|
||||
this(sourceUrls, trimFileScheme, baseFileUrl, true, sourceContents);
|
||||
}
|
||||
|
||||
public SourceResolver(@NotNull List<String> sourceUrls, boolean trimFileScheme, @Nullable Url baseFileUrl, boolean baseUrlIsFile, @Nullable List<String> sourceContents) {
|
||||
rawSources = sourceUrls;
|
||||
this.sourceContents = sourceContents;
|
||||
canonicalizedSources = new Url[sourceUrls.size()];
|
||||
@@ -55,7 +59,7 @@ public class SourceResolver {
|
||||
: new ObjectIntHashMap<Url>(canonicalizedSources.length, Urls.getCaseInsensitiveUrlHashingStrategy());
|
||||
for (int i = 0; i < sourceUrls.size(); i++) {
|
||||
String rawSource = sourceUrls.get(i);
|
||||
Url url = canonicalizeUrl(rawSource, baseFileUrl, trimFileScheme, i);
|
||||
Url url = canonicalizeUrl(rawSource, baseFileUrl, trimFileScheme, i, baseUrlIsFile);
|
||||
canonicalizedSources[i] = url;
|
||||
canonicalizedSourcesMap.put(url, i);
|
||||
}
|
||||
@@ -66,7 +70,7 @@ public class SourceResolver {
|
||||
}
|
||||
|
||||
// see canonicalizeUri kotlin impl and https://trac.webkit.org/browser/trunk/Source/WebCore/inspector/front-end/ParsedURL.js completeURL
|
||||
protected 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, boolean baseUrlIsFile) {
|
||||
if (trimFileScheme && url.startsWith(StandardFileSystems.FILE_PROTOCOL_PREFIX)) {
|
||||
return Urls.newLocalFileUrl(FileUtil.toCanonicalPath(VfsUtilCore.toIdeaUrl(url, true).substring(StandardFileSystems.FILE_PROTOCOL_PREFIX.length()), '/'));
|
||||
}
|
||||
@@ -77,15 +81,20 @@ public class SourceResolver {
|
||||
String path = url;
|
||||
if (url.charAt(0) != '/') {
|
||||
String basePath = baseUrl.getPath();
|
||||
int lastSlashIndex = basePath.lastIndexOf('/');
|
||||
StringBuilder pathBuilder = new StringBuilder();
|
||||
if (lastSlashIndex == -1) {
|
||||
pathBuilder.append(basePath).append('/');
|
||||
if (baseUrlIsFile) {
|
||||
int lastSlashIndex = basePath.lastIndexOf('/');
|
||||
StringBuilder pathBuilder = new StringBuilder();
|
||||
if (lastSlashIndex == -1) {
|
||||
pathBuilder.append('/');
|
||||
}
|
||||
else {
|
||||
pathBuilder.append(basePath, 0, lastSlashIndex + 1);
|
||||
}
|
||||
path = pathBuilder.append(url).toString();
|
||||
}
|
||||
else {
|
||||
pathBuilder.append(basePath, 0, lastSlashIndex + 1);
|
||||
path = basePath + '/' + url;
|
||||
}
|
||||
path = pathBuilder.append(url).toString();
|
||||
}
|
||||
path = FileUtil.toCanonicalPath(path, '/');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user