Skip to content

Commit

Permalink
Upgrade to kotlin 1.1-rc-91
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Feb 20, 2017
1 parent 7f4990c commit 7cfc8db
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.netflix.nebula:nebula-publishing-plugin:4.9.1'
classpath 'com.netflix.nebula:nebula-kotlin-plugin:1.1.0-beta-38'
classpath 'com.netflix.nebula:nebula-kotlin-plugin:1.1.0-rc-91'
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
classpath 'com.netflix.nebula:gradle-netflixoss-project-plugin:3.5.2'
classpath 'org.apache.ant:ant:1.9.4' // otherwise shadowJar blows up in subproject
Expand Down
5 changes: 3 additions & 2 deletions rewrite-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ dependencies {

compile 'com.fasterxml.jackson.core:jackson-databind:2.8.6', optional

compile 'org.ow2.asm:asm:latest.release'
compile 'org.ow2.asm:asm-util:latest.release'

testCompile 'junit:junit:4.+'
testCompile 'org.ow2.asm:asm:latest.release'
testCompile 'org.ow2.asm:asm-util:latest.release'
testCompile 'ch.qos.logback:logback-classic:1.0.13'
testCompile 'org.assertj:assertj-core:latest.release'
}
Expand Down
6 changes: 3 additions & 3 deletions rewrite-core/src/main/kotlin/com/netflix/rewrite/ast/Tree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ sealed class Tr : Serializable, Tree {
fun hasType(clazz: Class<*>): Boolean = HasType(clazz.name).visit(this)
fun hasType(clazz: String): Boolean = HasType(clazz).visit(this)

fun <M: Modifier> hasModifier(modifier: Class<M>) = modifiers.any { it.javaClass == modifier }
fun <M: Modifier> hasModifier(modifier: Class<M>) = modifiers.any { it::class.java == modifier }

fun hasModifier(modifier: String) = Modifier::class.nestedClasses
.filter { it.simpleName?.toLowerCase() == modifier.toLowerCase() }
Expand Down Expand Up @@ -604,7 +604,7 @@ sealed class Tr : Serializable, Tree {
override val formatting: Formatting = Formatting.Empty,
override val id: Long = id()): Tr()

fun <M: Modifier> hasModifier(modifier: Class<M>) = modifiers.any { it.javaClass == modifier }
fun <M: Modifier> hasModifier(modifier: Class<M>) = modifiers.any { it::class.java == modifier }

fun hasModifier(modifier: String) = Modifier::class.nestedClasses
.filter { it.simpleName?.toLowerCase() == modifier.toLowerCase() }
Expand Down Expand Up @@ -896,7 +896,7 @@ sealed class Tr : Serializable, Tree {
@Transient val simpleName: String = name.simpleName
}

fun <M: Modifier> hasModifier(modifier: Class<M>) = modifiers.any { it.javaClass == modifier }
fun <M: Modifier> hasModifier(modifier: Class<M>) = modifiers.any { it::class.java == modifier }

fun hasModifier(modifier: String) = Modifier::class.nestedClasses
.filter { it.simpleName?.toLowerCase() == modifier.toLowerCase() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TransformVisitor(val transformations: Iterable<AstTransform<*>>) : AstVisi
.fold(this) { acc, trans ->
val mutation = trans.mutation(acc)
if(logger.isDebugEnabled) {
logger.debug("Transforming ${acc.javaClass.simpleName} with ${trans.name}")
logger.debug("Transforming ${acc::class.java.simpleName} with ${trans.name}")
logger.debug("Original:")
logger.debug(acc.printTrimmed())
logger.debug("Transformed:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RewriteScanner(classpath: Iterable<Path>) {

fun rewriteRulesOnClasspath(): Map<Rewrite, Rule> {
val scanners = HashMap<Rewrite, Rule>()
val classLoader = URLClassLoader(filteredClasspath.map { it.toFile().toURI().toURL() }.toTypedArray(), javaClass.classLoader)
val classLoader = URLClassLoader(filteredClasspath.map { it.toFile().toURI().toURL() }.toTypedArray(), this::class.java.classLoader)

val reporter = object: AnnotationDetector.TypeReporter {
override fun annotations() = arrayOf(Rewrite::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class OracleJdkParserVisitor(val path: Path, val source: String): TreePathScanne
val select = when(jcSelect) {
is JCTree.JCFieldAccess -> jcSelect.selected.convert<Expression> { sourceBefore(".") }
is JCTree.JCIdent -> null
else -> error("Unexpected method select type ${jcSelect.javaClass}")
else -> error("Unexpected method select type ${jcSelect::class.java}")
}

// generic type parameters can only exist on qualified targets
Expand All @@ -563,7 +563,7 @@ class OracleJdkParserVisitor(val path: Path, val source: String): TreePathScanne
val name = when(jcSelect) {
is JCTree.JCFieldAccess -> Tr.Ident.build(jcSelect.name.toString(), null, format(sourceBefore(jcSelect.name.toString())))
is JCTree.JCIdent -> jcSelect.convert<Tr.Ident>()
else -> error("Unexpected method select type ${jcSelect.javaClass}")
else -> error("Unexpected method select type ${jcSelect::class.java}")
}

val argsPrefix = sourceBefore("(")
Expand Down Expand Up @@ -1028,7 +1028,7 @@ class OracleJdkParserVisitor(val path: Path, val source: String): TreePathScanne
return t
} catch(t: Throwable) {
// this SHOULD never happen, but is here simply as a diagnostic measure in the event of unexpected exceptions
logger.error("Failed to convert ${this.javaClass.simpleName} for the following cursor stack:")
logger.error("Failed to convert ${this::class.java.simpleName} for the following cursor stack:")
logCurrentPathAsError()
throw t
}
Expand All @@ -1043,7 +1043,7 @@ class OracleJdkParserVisitor(val path: Path, val source: String): TreePathScanne
is JCTree.JCClassDecl -> "JCClassDecl(name = ${it.name})"
is JCTree.JCMethodDecl -> "JCMethodDecl(name = ${it.name}, line = $lineNumber)"
is JCTree.JCVariableDecl -> "JCVariableDecl(name = ${it.name}, line = $lineNumber)"
else -> "${it.javaClass.simpleName}(line = $lineNumber)"
else -> "${it::class.java.simpleName}(line = $lineNumber)"
})
}
logger.error("--- END PATH ---")
Expand Down Expand Up @@ -1188,7 +1188,7 @@ class OracleJdkParserVisitor(val path: Path, val source: String): TreePathScanne
* and if not found in the remaining source, the empty String. If <code>stop</code> is reached before
* <code>untilDelim</code> return the empty String.
*/
private fun sourceBefore(untilDelim: String, stop: Char? = null, stopIndex: Int? = null): String {
private fun sourceBefore(untilDelim: String, stop: Char? = null): String {
val delimIndex = positionOfNext(untilDelim, stop)
if(delimIndex < 0) {
return "" // unable to find this delimiter
Expand All @@ -1199,7 +1199,7 @@ class OracleJdkParserVisitor(val path: Path, val source: String): TreePathScanne
return prefix
}

private fun positionOfNext(untilDelim: String, stop: Char? = null, stopIndex: Int? = null): Int {
private fun positionOfNext(untilDelim: String, stop: Char? = null): Int {
var delimIndex = cursor
var inMultiLineComment = false
var inSingleLineComment = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ data class ChangeType(val from: String,
override fun visitFieldAccess(field: Tr.FieldAccess): List<AstTransform<Tree>> {
return super.visitFieldAccess(field) +
field.asClassReference().transformName<Tr.FieldAccess> { name, node ->
val type = node.type.asClass()!!.copy()
node.copy(target = name)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ class RetrieveCursorVisitorTest: Parser by OracleJdkParser() {
val cursor = a.cursor(s)
assertNotNull(cursor)
assertEquals("CompilationUnit,ClassDecl,Block,MethodDecl,Block,VariableDecls",
cursor!!.path.map { it.javaClass.simpleName }.joinToString(","))
cursor!!.path.map { it::class.java.simpleName }.joinToString(","))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TreeJacksonSerializer {
fun write(cus: List<Tr.CompilationUnit>): ByteArray = mapper.writeValueAsBytes(cus)

fun write(cu: Tr.CompilationUnit, out: OutputStream) {
mapper.writeValue(out, this)
mapper.writeValue(out, cu)
}

fun write(cu: Tr.CompilationUnit): ByteArray = mapper.writeValueAsBytes(cu)
Expand Down

0 comments on commit 7cfc8db

Please sign in to comment.