update gson to 2.5

support ASAR (https://github.com/atom/asar) — required to debug packed electron ap
do not use VFS to load compiled script or source map — use Java 8 NIO Path directly
This commit is contained in:
Vladimir Krivosheev
2015-12-24 17:32:52 +01:00
parent 36edaad271
commit 02d537faad
11 changed files with 94 additions and 38 deletions

View File

@@ -1,11 +1,11 @@
<component name="libraryTable">
<library name="gson">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/gson-2.3.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/gson-2.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/src/gson-2.3.1-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/src/gson-2.5-sources.jar!/" />
</SOURCES>
</library>
</component>

Binary file not shown.

BIN
lib/gson-2.5.jar Normal file

Binary file not shown.

View File

@@ -18,7 +18,7 @@ fluent-hc-4.4.1.jar
httpmime-4.4.1.jar
ecj-4.4.2.jar
groovy-all-2.3.9.jar
gson-2.3.1.jar
gson-2.5.jar
guava-17.0.jar
hamcrest-core-1.3.jar
imgscalr-lib-4.2.jar

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,18 @@
/*
* 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.io;
import io.netty.buffer.ByteBuf;
@@ -12,13 +27,13 @@ import java.nio.CharBuffer;
public final class ChannelBufferToString {
@NotNull
public static CharSequence readChars(@NotNull ByteBuf buffer) throws IOException {
return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, buffer.readableBytes(), null));
return new CharSequenceBackedByChars(readIntoCharBuffer(buffer, buffer.readableBytes(), null));
}
@SuppressWarnings("unused")
@NotNull
public static CharSequence readChars(@NotNull ByteBuf buffer, int byteCount) throws IOException {
return new JsonReaderEx.CharSequenceBackedByChars(readIntoCharBuffer(buffer, byteCount, null));
return new CharSequenceBackedByChars(readIntoCharBuffer(buffer, byteCount, null));
}
@NotNull

View File

@@ -17,14 +17,10 @@ package org.jetbrains.io;
import com.google.gson.JsonParseException;
import com.google.gson.stream.JsonToken;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.util.text.CharArrayCharSequence;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.Closeable;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.Arrays;
public final class JsonReaderEx implements Closeable {
@@ -120,32 +116,6 @@ 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);
}
public CharSequenceBackedByChars(@NotNull char[] chars) {
super(chars);
}
@NotNull
@Override
public CharSequence subSequence(int start, int end) {
return start == 0 && end == length() ? this : new String(myChars, myStart + start, end - start);
}
@NotNull
public ByteBuffer getByteBuffer() {
return CharsetToolkit.UTF8_CHARSET.encode(CharBuffer.wrap(myChars, myStart, length()));
}
}
private final static class JsonScope {
/**
* An array with no elements requires no separators or newlines before

View File

@@ -1,3 +1,18 @@
/*
* 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.io;
import io.netty.buffer.ByteBuf;
@@ -44,7 +59,7 @@ public abstract class MessageDecoder extends Decoder {
chunkedContent = null;
consumedContentByteCount = 0;
}
return new JsonReaderEx.CharSequenceBackedByChars(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer));
return new CharSequenceBackedByChars(ChannelBufferToString.readIntoCharBuffer(input, required, charBuffer));
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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.io
import com.intellij.openapi.vfs.CharsetToolkit
import com.intellij.util.text.CharArrayCharSequence
import java.io.InputStreamReader
import java.nio.ByteBuffer
import java.nio.CharBuffer
fun InputStreamReader.readCharSequence(length: Int): CharSequence {
use {
val chars = CharArray(length)
var count = 0
while (count < chars.size) {
val n = read(chars, count, chars.size - count)
if (n <= 0) {
break
}
count += n
}
return CharSequenceBackedByChars(chars, 0, count)
}
}
// we must return string on subSequence() - JsonReaderEx will call toString in any case
class CharSequenceBackedByChars : CharArrayCharSequence {
val byteBuffer: ByteBuffer
get() = CharsetToolkit.UTF8_CHARSET.encode(CharBuffer.wrap(myChars, myStart, length))
constructor(charBuffer: CharBuffer) : super(charBuffer.array(), charBuffer.arrayOffset(), charBuffer.position()) {
}
constructor(chars: CharArray, start: Int, end: Int) : super(chars, start, end) {
}
constructor(chars: CharArray) : super(*chars) {
}
override fun subSequence(start: Int, end: Int): CharSequence {
return if (start == 0 && end == length) this else String(myChars, myStart + start, end - start)
}
}

View File

@@ -22,7 +22,7 @@ import com.intellij.openapi.vfs.CharsetToolkit
import io.netty.buffer.ByteBuf
import io.netty.channel.Channel
import org.jetbrains.annotations.PropertyKey
import org.jetbrains.io.JsonReaderEx
import org.jetbrains.io.CharSequenceBackedByChars
import org.jetbrains.io.addListener
import java.io.File
import java.io.FileOutputStream
@@ -94,7 +94,7 @@ fun createDebugLogger(@PropertyKey(resourceBundle = Registry.REGISTRY_BUNDLE) ke
writer.write("\"${entry.marker}\": ")
writer.flush()
if (message is JsonReaderEx.CharSequenceBackedByChars) {
if (message is CharSequenceBackedByChars) {
fileChannel.write(message.byteBuffer)
}
else {