Remove 181 bunch files

This commit is contained in:
Vyacheslav Gerasimov
2019-04-19 18:43:37 +03:00
parent e261e46e52
commit 952d2b6287
249 changed files with 0 additions and 13329 deletions
-193
View File
@@ -1,193 +0,0 @@
// INSPECTION_CLASS: com.android.tools.idea.lint.AndroidLintDrawAllocationInspection
// INSPECTION_CLASS2: com.android.tools.idea.lint.AndroidLintUseSparseArraysInspection
// INSPECTION_CLASS3: com.android.tools.idea.lint.AndroidLintUseValueOfInspection
import android.annotation.SuppressLint
import java.util.HashMap
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.util.SparseArray
import android.widget.Button
@SuppressWarnings("unused")
@Suppress("UsePropertyAccessSyntax", "UNUSED_VARIABLE", "unused", "UNUSED_PARAMETER", "DEPRECATION", "UNNECESSARY_NOT_NULL_ASSERTION", "NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
class JavaPerformanceTest(context: Context, attrs: AttributeSet, defStyle: Int) : Button(context, attrs, defStyle) {
private var cachedRect: Rect? = null
private var shader: LinearGradient? = null
private var lastHeight: Int = 0
private var lastWidth: Int = 0
override fun onDraw(canvas: android.graphics.Canvas) {
super.onDraw(canvas)
// Various allocations:
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">java.lang.String("foo")</warning>
val s = <warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">java.lang.String("bar")</warning>
// This one should not be reported:
@SuppressLint("DrawAllocation")
val i = 5
// Cached object initialized lazily: should not complain about these
if (cachedRect == null) {
cachedRect = Rect(0, 0, 100, 100)
}
if (cachedRect == null || cachedRect!!.width() != 50) {
cachedRect = Rect(0, 0, 50, 100)
}
val b = java.lang.Boolean.valueOf(true)!! // auto-boxing
dummy(1, 2)
// Non-allocations
super.animate()
dummy2(1, 2)
// This will involve allocations, but we don't track
// inter-procedural stuff here
someOtherMethod()
}
internal fun dummy(foo: Int?, bar: Int) {
dummy2(foo!!, bar)
}
internal fun dummy2(foo: Int, bar: Int) {
}
internal fun someOtherMethod() {
// Allocations are okay here
java.lang.String("foo")
val s = java.lang.String("bar")
val b = java.lang.Boolean.valueOf(true)!! // auto-boxing
// Sparse array candidates
val myMap = <warning descr="Use `new SparseArray<String>(...)` instead for better performance">HashMap<Int, String>()</warning>
// Should use SparseBooleanArray
val myBoolMap = <warning descr="Use `new SparseBooleanArray(...)` instead for better performance">HashMap<Int, Boolean>()</warning>
// Should use SparseIntArray
val myIntMap = <warning descr="Use new `SparseIntArray(...)` instead for better performance">java.util.HashMap<Int, Int>()</warning>
// This one should not be reported:
@SuppressLint("UseSparseArrays")
val myOtherMap = <warning descr="Use `new SparseArray<Object>(...)` instead for better performance">HashMap<Int, Any>()</warning>
}
protected fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int,
x: Boolean) {
// wrong signature
java.lang.String("not an error")
}
protected fun onMeasure(widthMeasureSpec: Int) {
// wrong signature
java.lang.String("not an error")
}
protected fun onLayout(changed: Boolean, left: Int, top: Int, right: Int,
bottom: Int, wrong: Int) {
// wrong signature
java.lang.String("not an error")
}
protected fun onLayout(changed: Boolean, left: Int, top: Int, right: Int) {
// wrong signature
java.lang.String("not an error")
}
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int,
bottom: Int) {
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">java.lang.String("flag me")</warning>
}
@SuppressWarnings("null") // not real code
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">java.lang.String("flag me")</warning>
// Forbidden factory methods:
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">Bitmap.createBitmap(100, 100, null)</warning>
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false)</warning>
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">BitmapFactory.decodeFile(null)</warning>
val canvas: Canvas? = null
<warning descr="Avoid object allocations during draw operations: Use `Canvas.getClipBounds(Rect)` instead of `Canvas.getClipBounds()` which allocates a temporary `Rect`">canvas!!.getClipBounds()</warning> // allocates on your behalf
<warning descr="Avoid object allocations during draw operations: Use `Canvas.getClipBounds(Rect)` instead of `Canvas.getClipBounds()` which allocates a temporary `Rect`">canvas.clipBounds</warning> // allocates on your behalf
canvas.getClipBounds(null) // NOT an error
val layoutWidth = width
val layoutHeight = height
if (mAllowCrop && (mOverlay == null || mOverlay!!.width != layoutWidth ||
mOverlay!!.height != layoutHeight)) {
mOverlay = Bitmap.createBitmap(layoutWidth, layoutHeight, Bitmap.Config.ARGB_8888)
mOverlayCanvas = Canvas(mOverlay!!)
}
if (widthMeasureSpec == 42) {
throw IllegalStateException("Test") // NOT an allocation
}
// More lazy init tests
var initialized = false
if (!initialized) {
java.lang.String("foo")
initialized = true
}
// NOT lazy initialization
if (!initialized || mOverlay == null) {
<warning descr="Avoid object allocations during draw/layout operations (preallocate and reuse instead)">java.lang.String("foo")</warning>
}
}
internal fun factories() {
val i1 = 42
val l1 = 42L
val b1 = true
val c1 = 'c'
val f1 = 1.0f
val d1 = 1.0
// The following should not generate errors:
val i3 = Integer.valueOf(42)
}
private val mAllowCrop: Boolean = false
private var mOverlayCanvas: Canvas? = null
private var mOverlay: Bitmap? = null
override fun layout(l: Int, t: Int, r: Int, b: Int) {
// Using "this." to reference fields
if (this.shader == null)
this.shader = LinearGradient(0f, 0f, width.toFloat(), 0f, intArrayOf(0), null,
Shader.TileMode.REPEAT)
val width = width
val height = height
if (shader == null || lastWidth != width || lastHeight != height) {
lastWidth = width
lastHeight = height
shader = LinearGradient(0f, 0f, width.toFloat(), 0f, intArrayOf(0), null, Shader.TileMode.REPEAT)
}
}
fun inefficientSparseArray() {
<warning descr="Use `new SparseIntArray(...)` instead for better performance">SparseArray<Int>()</warning> // Use SparseIntArray instead
SparseArray<Long>() // Use SparseLongArray instead
<warning descr="Use `new SparseBooleanArray(...)` instead for better performance">SparseArray<Boolean>()</warning> // Use SparseBooleanArray instead
SparseArray<Any>() // OK
}
fun longSparseArray() {
// but only minSdkVersion >= 17 or if has v4 support lib
val myStringMap = HashMap<Long, String>()
}
fun byteSparseArray() {
// bytes easily apply to ints
val myByteMap = <warning descr="Use `new SparseArray<String>(...)` instead for better performance">HashMap<Byte, String>()</warning>
}
}
@@ -1,5 +0,0 @@
// ALLOW_MULTIPLE_EXPRESSIONS
fun bar(x: (Int) -> String) = x(1)
fun foo() {
val bar = bar() { y: Int -> "abc" }
}
@@ -1,12 +0,0 @@
LineBreakpoint created at smartStepIntoInlinedFunLiteral.kt:6
Run Java
Connected to the target VM
smartStepIntoInlinedFunLiteral.kt:6
smartStepIntoInlinedFunLiteral.kt:11
smartStepIntoInlinedFunLiteral.kt:12
smartStepIntoInlinedFunLiteral.kt:17
smartStepIntoInlinedFunLiteral.kt:18
smartStepIntoInlinedFunLiteral.kt:1
Disconnected from the target VM
Process finished with exit code 0
@@ -1,12 +0,0 @@
LineBreakpoint created at smartStepIntoInlinedFunctionalExpression.kt:6
Run Java
Connected to the target VM
smartStepIntoInlinedFunctionalExpression.kt:6
smartStepIntoInlinedFunctionalExpression.kt:11
smartStepIntoInlinedFunctionalExpression.kt:12
smartStepIntoInlinedFunctionalExpression.kt:17
smartStepIntoInlinedFunctionalExpression.kt:18
smartStepIntoInlinedFunctionalExpression.kt:1
Disconnected from the target VM
Process finished with exit code 0
@@ -1,8 +0,0 @@
fun testing() {
<caret>SomeClass<List<String>>()
}
//INFO: <div class='definition'><pre>public class <b>SomeClass</b>&lt;T extends <a href="psi_element://java.util.List"><code>List</code></a>&gt;
//INFO: extends <a href="psi_element://java.lang.Object"><code>Object</code></a></pre></div><div class='content'>
//INFO: Some Java Class
//INFO: </div><table class='sections'><p><tr><td valign='top' class='section'><p>Type parameters:</td><td>&lt;T&gt; &ndash; </td></table>
@@ -1,9 +0,0 @@
class A : OverrideMe() {
override fun <caret>overrideMe() {
}
}
//INFO: <div class='definition'><pre><a href="psi_element://A"><code>A</code></a><br>protected open fun <b>overrideMe</b>(): Unit</pre></div></pre></div><table class='sections'><p><tr><td valign='top' class='section'><p>Description copied from class:</td><td><p><a href="psi_element://OverrideMe"><code>OverrideMe</code></a><br>
//INFO: Some comment
//INFO: </td><tr><td valign='top' class='section'><p>Overrides:</td><td><p><a href="psi_element://OverrideMe#overrideMe()"><code>overrideMe</code></a> in class <a href="psi_element://OverrideMe"><code>OverrideMe</code></a></td></table>
@@ -1,9 +0,0 @@
class A : OverrideMe {
override fun <caret>overrideMe() {
}
}
//INFO: <div class='definition'><pre><a href="psi_element://A"><code>A</code></a><br>public open fun <b>overrideMe</b>(): Unit</pre></div></pre></div><table class='sections'><p><tr><td valign='top' class='section'><p>Description copied from interface:</td><td><p><a href="psi_element://OverrideMe"><code>OverrideMe</code></a><br>
//INFO: Some comment
//INFO: </td><tr><td valign='top' class='section'><p>Specified by:</td><td><p><a href="psi_element://OverrideMe#overrideMe()"><code>overrideMe</code></a> in interface <a href="psi_element://OverrideMe"><code>OverrideMe</code></a></td></table>
@@ -1,9 +0,0 @@
fun ktTest() {
Test.<caret>foo("SomeTest")
}
//INFO: <div class='definition'><pre><a href="psi_element://Test"><code>Test</code></a><br><i>@Contract(pure = true)</i>&nbsp;
//INFO: <i>@<a href="psi_element://org.jetbrains.annotations.NotNull"><code>NotNull</code></a></i>&nbsp;
//INFO: public static&nbsp;<a href="psi_element://java.lang.Object"><code>Object</code></a>[]&nbsp;<b>foo</b>(<a href="psi_element://java.lang.String"><code>String</code></a>&nbsp;param)</pre></div><div class='content'>
//INFO: Java Method
//INFO: <p></div><table class='sections'><p><tr><td valign='top' class='section'><p><i>Inferred</i> annotations:</td><td><p><i>@org.jetbrains.annotations.Contract(pure = true)</i> <i>@<a href="psi_element://org.jetbrains.annotations.NotNull"><code>org.jetbrains.annotations.NotNull</code></a></i></td></table>
@@ -1,12 +0,0 @@
enum class E {
A
}
fun use() {
E.valueOf<caret>("A")
}
//INFO: <div class='definition'><pre><a href="psi_element://E"><code>E</code></a><br>public final fun <b>valueOf</b>(
//INFO: value: String
//INFO: ): <a href="psi_element://E">E</a></pre></div><div class='content'><p>Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)</p></div><table class='sections'><tr><td valign='top' class='section'><p>Throws:</td><td><p><code>IllegalArgumentException</code> - if this enum type has no constant with the specified name</td></table>
@@ -1,18 +0,0 @@
package test
/**
*
*
* Test function
*
* @param first Some
* @param second Other
*/
fun <caret>testFun(first: String, second: Int) = 12
//INFO: <div class='definition'><pre><a href="psi_element://test"><code>test</code></a> <font color="808080"><i>OnFunctionDeclarationWithPackage.kt</i></font><br>public fun <b>testFun</b>(
//INFO: first: String,
//INFO: second: Int
//INFO: ): Int</pre></div><div class='content'><p>Test function</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>first</code> - Some<p><code>second</code> - Other</td></table>
-18
View File
@@ -1,18 +0,0 @@
/**
Some documentation
* @param a Some int
* @param b String
*/
fun testMethod(a: Int, b: String) {
}
fun test() {
<caret>testMethod(1, "value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsage.kt</i></font><br>public fun <b>testMethod</b>(
//INFO: a: Int,
//INFO: b: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>a</code> - Some int<p><code>b</code> - String</td></table>
@@ -1,18 +0,0 @@
/**
Some documentation
* @param[a] Some int
* @param[b] String
*/
fun testMethod(a: Int, b: String) {
}
fun test() {
<caret>testMethod(1, "value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithBracketsInParam.kt</i></font><br>public fun <b>testMethod</b>(
//INFO: a: Int,
//INFO: b: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>a</code> - Some int<p><code>b</code> - String</td></table>
@@ -1,17 +0,0 @@
/**
* Some documentation
* on two lines.
*
* @param test String
* on two lines
*/
fun testMethod(test: String) {
}
fun test() {
<caret>testMethod("")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithMultilineParam.kt</i></font><br>public fun <b>testMethod</b>(
//INFO: test: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation on two lines.</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>test</code> - String on two lines</td></table>
@@ -1,18 +0,0 @@
/**
Some documentation
* @receiver Some int
* @param b String
* @return Return [a] and nothing else
*/
fun Int.testMethod(b: String) {
}
fun test() {
1.<caret>testMethod("value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithReceiver.kt</i></font><br>public fun Int.<b>testMethod</b>(
//INFO: b: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation</p></div><table class='sections'><tr><td valign='top' class='section'><p>Receiver:</td><td>Some int</td><tr><td valign='top' class='section'><p>Params:</td><td><p><code>b</code> - String</td><tr><td valign='top' class='section'><p>Returns:</td><td>Return <a href="psi_element://a">a</a> and nothing else</td></table>
@@ -1,19 +0,0 @@
/**
Some documentation
* @param a Some int
* @param b String
* @return Return [a] and nothing else
*/
fun testMethod(a: Int, b: String) {
}
fun test() {
<caret>testMethod(1, "value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithReturnAndLink.kt</i></font><br>public fun <b>testMethod</b>(
//INFO: a: Int,
//INFO: b: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>a</code> - Some int<p><code>b</code> - String</td><tr><td valign='top' class='section'><p>Returns:</td><td>Return <a href="psi_element://a">a</a> and nothing else</td></table>
@@ -1,20 +0,0 @@
/**
Some documentation
* @param a Some int
* @param b String
* @return Return value
* @throws IllegalArgumentException if the weather is bad
*/
fun testMethod(a: Int, b: String) {
}
fun test() {
<caret>testMethod(1, "value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithReturnAndThrows.kt</i></font><br>public fun <b>testMethod</b>(
//INFO: a: Int,
//INFO: b: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>a</code> - Some int<p><code>b</code> - String</td><tr><td valign='top' class='section'><p>Returns:</td><td>Return value</td><tr><td valign='top' class='section'><p>Throws:</td><td><p><code>IllegalArgumentException</code> - if the weather is bad</td></table>
@@ -1,20 +0,0 @@
/**
* @see C
* @see D
* @see <a href="https://kotl.in">kotlin</a>
*/
fun testMethod() {
}
class C {
}
class D {
}
fun test() {
<caret>testMethod(1, "value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithSee.kt</i></font><br>public fun <b>testMethod</b>(): Unit</pre></div><div class='content'></div><table class='sections'><tr><td valign='top' class='section'><p>See Also:</td><td><a href="psi_element://C"><code>C</code></a>, <a href="psi_element://D"><code>D</code></a>, <a href="https://kotl.in">kotlin</a></td></table>
@@ -1,19 +0,0 @@
/**
Some documentation
* @param T the type parameter
* @param a Some int
* @param b String
*/
fun <T> testMethod(a: Int, b: String) {
}
fun test() {
<caret>testMethod(1, "value")
}
//INFO: <div class='definition'><pre><font color="808080"><i>OnMethodUsageWithTypeParameter.kt</i></font><br>public fun &lt;T&gt; <b>testMethod</b>(
//INFO: a: Int,
//INFO: b: String
//INFO: ): Unit</pre></div><div class='content'><p>Some documentation</p></div><table class='sections'><tr><td valign='top' class='section'><p>Params:</td><td><p><code>T</code> - the type parameter<p><code>a</code> - Some int<p><code>b</code> - String</td></table>
-29
View File
@@ -1,29 +0,0 @@
package magic
object Samples {
fun sampleMagic() {
castTextSpell("[asd] [dse] [asz]")
}
}
fun sampleScroll() {
val reader = Scroll("[asd] [dse] [asz]").reader()
castTextSpell(reader.readAll())
}
/**
* @sample Samples.sampleMagic
* @sample sampleScroll
*/
fun <caret>castTextSpell(spell: String) {
throw SecurityException("Magic prohibited outside Hogwarts")
}
//INFO: <div class='definition'><pre><a href="psi_element://magic"><code>magic</code></a> <font color="808080"><i>Samples.kt</i></font><br>public fun <b>castTextSpell</b>(
//INFO: spell: String
//INFO: ): Unit</pre></div><div class='content'></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td><p><a href="psi_element://Samples.sampleMagic"><code>Samples.sampleMagic</code></a><pre><code>
//INFO: castTextSpell("[asd] [dse] [asz]")
//INFO: </code></pre><p><a href="psi_element://sampleScroll"><code>sampleScroll</code></a><pre><code>
//INFO: val reader = Scroll("[asd] [dse] [asz]").reader()
//INFO: castTextSpell(reader.readAll())
//INFO: </code></pre></td></table>
@@ -1,18 +0,0 @@
/**
* @sample samples.SampleGroup.mySample
* @sample samples.megasamples.MegaSamplesGroup.megaSample
* @sample samples.notindir.NotInDirSamples.sssample
* @sample smaplez.a.b.c.Samplez.sssample
*/
fun some<caret>() {
}
//INFO: <div class='definition'><pre><font color="808080"><i>usage.kt</i></font><br>public fun <b>some</b>(): Unit</pre></div><div class='content'></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td><p><a href="psi_element://samples.SampleGroup.mySample"><code>samples.SampleGroup.mySample</code></a><pre><code>
//INFO: println("Hello, world")
//INFO: </code></pre><p><a href="psi_element://samples.megasamples.MegaSamplesGroup.megaSample"><code>samples.megasamples.MegaSamplesGroup.megaSample</code></a><pre><code>
//INFO: println("...---...")
//INFO: </code></pre><p><a href="psi_element://samples.notindir.NotInDirSamples.sssample"><code>samples.notindir.NotInDirSamples.sssample</code></a><pre><code>
//INFO: println("location is samplesTest/")
//INFO: </code></pre><p><a href="psi_element://smaplez.a.b.c.Samplez.sssample"><code>smaplez.a.b.c.Samplez.sssample</code></a><pre><code>// Unresolved</code></pre></td></table>
@@ -1,10 +0,0 @@
/**
* @sample samples.sample
*/
fun some<caret>() {
}
//INFO: <div class='definition'><pre><font color="808080"><i>usage.kt</i></font><br>public fun <b>some</b>(): Unit</pre></div><div class='content'></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td><p><a href="psi_element://samples.sample"><code>samples.sample</code></a><pre><code>
//INFO: println("Hello, world")
//INFO: </code></pre></td></table>
@@ -1,8 +0,0 @@
package test;
import foo.A;
public class ThrowsOnGenericMethod {
public static void main(String[] args) {
new A().<error descr="Unhandled exception: java.io.IOException">foo("");</error>
}
}
@@ -1,5 +0,0 @@
// "Remove function body" "true"
abstract class A() {
/*1*/
abstract fun foo() // 3
}
@@ -1,12 +0,0 @@
// "Surround with lambda" "false"
// ERROR: Type mismatch: inferred type is Object but () -> String was expected
// ACTION: Annotate constructor 'Object' as @Deprecated
// ACTION: Change parameter 'block' type of function 'str' to 'Object'
// ACTION: Create function 'str'
// ACTION: Edit method contract of 'Object'
// ACTION: Introduce import alias
fun fn() {
str(<caret>Object())
}
fun str(block: () -> String) {}
@@ -1,7 +0,0 @@
// "Suppress for declarations annotated by 'xxx.XXX'" "true"
package xxx
annotation class XXX
@XXX
class <caret>UnusedClass
@@ -1,7 +0,0 @@
// "Suppress for declarations annotated by 'xxx.XXX'" "true"
package xxx
annotation class XXX
@XXX
class <caret>UnusedClass