Made it possible to run incremental compiler from IDEA.

Two guava functions used were replaced with custom tiny functions, because JPS plugin won't have guava in classpath.
This commit is contained in:
Evgeny Gerashchenko
2014-07-08 14:10:37 +04:00
parent 7212597e61
commit 40703c125c
3 changed files with 18 additions and 13 deletions
-7
View File
@@ -44,14 +44,7 @@
<element id="file-copy" path="$PROJECT_DIR$/resources/manifest.properties" />
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.1.jar" path-in-jar="/" />
<element id="module-output" name="util.runtime" />
<element id="module-output" name="cli" />
<element id="module-output" name="descriptor.loader.java" />
<element id="module-output" name="frontend.java" />
<element id="module-output" name="serialization.java" />
<element id="module-output" name="descriptors" />
<element id="library" level="project" name="kotlin-runtime" />
</element>
<element id="file-copy" path="$PROJECT_DIR$/dist/kotlinc/lib/kotlin-runtime.jar" />
</element>
<element id="file-copy" path="$PROJECT_DIR$/dist/kotlinc/lib/kotlin-runtime.jar" />
</element>
+1 -1
View File
@@ -168,7 +168,7 @@
<fileTypeFactory implementation="org.jetbrains.jet.plugin.JetFileFactory"/>
<compileServer.plugin classpath="jps/kotlin-jps-plugin.jar;jps/kotlin-runtime.jar"/>
<compileServer.plugin classpath="jps/kotlin-jps-plugin.jar;kotlin-runtime.jar;kotlin-plugin.jar"/>
<lang.syntaxHighlighterFactory key="jet" implementationClass="org.jetbrains.jet.plugin.highlighter.JetSyntaxHighlighterFactory"/>
<lang.braceMatcher language="jet" implementationClass="org.jetbrains.jet.plugin.JetPairMatcher"/>
@@ -36,11 +36,10 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName
import java.util.HashSet
import org.jetbrains.jet.lang.resolve.kotlin.incremental.IncrementalCache
import java.util.HashMap
import com.google.common.collect.Maps
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils
import com.intellij.util.containers.MultiMap
import com.intellij.openapi.util.io.FileUtil
import com.google.common.hash.Hashing
import java.security.MessageDigest
val INLINE_ANNOTATION_DESC = "Lkotlin/inline;"
@@ -251,7 +250,7 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
override fun read(`in`: DataInput): Map<String, Any>? {
val size = `in`.readInt()
val map = Maps.newHashMapWithExpectedSize<String, Any>(size)!!
val map = HashMap<String, Any>(size)
for (i in size.indices) {
val name = IOUtil.readString(`in`)!!
@@ -301,7 +300,7 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
override fun visitEnd() {
if (hasInlineAnnotation) {
val dummyBytes = dummyClassWriter.toByteArray()!!
val hash = Hashing.md5()!!.hashBytes(dummyBytes)!!.asLong()
val hash = dummyBytes.md5()
result[name + desc] = hash
}
@@ -343,7 +342,7 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
override fun read(`in`: DataInput): Map<String, Long>? {
val size = `in`.readInt()
val map = Maps.newHashMapWithExpectedSize<String, Long>(size)!!
val map = HashMap<String, Long>(size)
for (i in size.indices) {
val name = IOUtil.readString(`in`)!!
@@ -438,6 +437,19 @@ public class IncrementalCacheImpl(val baseDir: File): IncrementalCache {
}
}
private fun ByteArray.md5(): Long {
val d = MessageDigest.getInstance("MD5").digest(this)!!
return ((d[0].toLong() and 0xFFL)
or ((d[1].toLong() and 0xFFL) shl 8)
or ((d[2].toLong() and 0xFFL) shl 16)
or ((d[3].toLong() and 0xFFL) shl 24)
or ((d[4].toLong() and 0xFFL) shl 32)
or ((d[5].toLong() and 0xFFL) shl 40)
or ((d[6].toLong() and 0xFFL) shl 48)
or ((d[7].toLong() and 0xFFL) shl 56)
)
}
private object ByteArrayExternalizer: DataExternalizer<ByteArray> {
override fun save(out: DataOutput, value: ByteArray?) {
out.writeInt(value!!.size)