Intention&inspection to use synthetic property instead of get/set method call

This commit is contained in:
Valentin Kipyatkov
2015-07-08 23:12:44 +03:00
parent a014f5c8db
commit bfdc74ce74
27 changed files with 365 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.UsePropertyAccessSyntaxIntention
@@ -0,0 +1,8 @@
// WITH_RUNTIME
import java.io.File
class MyFile : File("file")
fun foo(file: MyFile) {
file.getAbsolutePath()<caret>
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
import java.io.File
class MyFile : File("file")
fun foo(file: MyFile) {
file.absolutePath<caret>
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
import java.io.File
class MyFile : File("file") {
override fun getCanonicalFile(): File {
return super.getCanonicalFile()
}
}
fun foo(file: MyFile) {
file.getCanonicalFile()<caret>
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
import java.io.File
class MyFile : File("file") {
override fun getCanonicalFile(): File {
return super.getCanonicalFile()
}
}
fun foo(file: MyFile) {
file.canonicalFile<caret>
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
import java.io.File
fun File.foo(absolutePath: String) {
getAbsolutePath()<caret>
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
import java.io.File
val File.absolutePath: String get() = ""
fun foo(file: File) {
file.getAbsolutePath()<caret>
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
import java.io.File
fun foo(file: File) {
file.getAbsolutePath()<caret>
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
import java.io.File
fun foo(file: File) {
file.absolutePath<caret>
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
import java.io.File
fun File.foo() {
getAbsolutePath()<caret>
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
import java.io.File
fun File.foo() {
absolutePath<caret>
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
import java.io.File
fun foo(file: File?) {
file?.getAbsolutePath()<caret>
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
import java.io.File
fun foo(file: File?) {
file?.absolutePath<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(thread: Thread) {
thread.setName("name")<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(thread: Thread) {
thread.name = "name"<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun Thread.foo() {
setName("name")<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun Thread.foo() {
name = "name"<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(thread: Thread?) {
thread?.setName("name")<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(thread: Thread?) {
thread?.name = "name"<caret>
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
import java.io.File
class MyFile : File("file") {
override fun getCanonicalFile(): File {
return super.getCanonicalFile()<caret>
}
}