Add ERRORs check to AbstractOutOfBlockModificationTest
This commit is contained in:
+12
-8
@@ -12,24 +12,28 @@ import org.jetbrains.kotlin.diagnostics.Severity
|
|||||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
|
|
||||||
object DirectiveBasedActionUtils {
|
object DirectiveBasedActionUtils {
|
||||||
fun checkForUnexpectedErrors(file: KtFile) {
|
fun checkForUnexpectedErrors(file: KtFile, diagnosticsProvider: (KtFile) -> Diagnostics = { it.analyzeWithContent().diagnostics }) {
|
||||||
if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// DISABLE-ERRORS").isNotEmpty()) {
|
if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// DISABLE-ERRORS").isNotEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ERROR:").sorted()
|
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ERROR:").sorted()
|
||||||
|
|
||||||
val actualErrors = file.analyzeWithContent().diagnostics
|
val diagnostics = diagnosticsProvider(file)
|
||||||
.filter { it.getSeverity() == Severity.ERROR }
|
val actualErrors = diagnostics
|
||||||
.map { DefaultErrorMessages.render(it).replace("\n", "<br>") }
|
.filter { it.severity == Severity.ERROR }
|
||||||
.sorted()
|
.map { DefaultErrorMessages.render(it).replace("\n", "<br>") }
|
||||||
|
.sorted()
|
||||||
|
|
||||||
UsefulTestCase.assertOrderedEquals("All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned",
|
UsefulTestCase.assertOrderedEquals(
|
||||||
actualErrors,
|
"All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned",
|
||||||
expectedErrors)
|
actualErrors,
|
||||||
|
expectedErrors
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection<IntentionAction>) {
|
fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection<IntentionAction>) {
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
fun run(block: () -> Int): Int {
|
||||||
|
return block()
|
||||||
|
}
|
||||||
|
|
||||||
fun some(): Int = run { 12 + <caret> }
|
fun some(): Int = run { 12 + <caret> }
|
||||||
|
|
||||||
// TYPE: 1
|
// TYPE: 1
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// TYPE: 0
|
||||||
fun main() {
|
fun main() {
|
||||||
fun some = 12<caret>
|
fun some = 12<caret>
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
class A {
|
class A {
|
||||||
init {
|
init {
|
||||||
fun f() {
|
fun f() {
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Unresolved reference: a12
|
||||||
|
|
||||||
fun some() = <caret>12
|
fun some() = <caret>12
|
||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Function 'test' must have a body
|
||||||
|
// TYPE: \b
|
||||||
|
|
||||||
fun test() {<caret>
|
fun test() {<caret>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TYPE: \b
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
// (Investigation starts from parent)
|
// (Investigation starts from parent)
|
||||||
|
// ERROR: Unresolved reference: a12
|
||||||
|
|
||||||
fun test() : Int = <caret>12
|
fun test() : Int = <caret>12
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a12
|
||||||
|
|
||||||
fun test() : Int = 12 + <caret>12
|
fun test() : Int = 12 + <caret>12
|
||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
val o = object {
|
val o = object {
|
||||||
fun test() {
|
fun test() {
|
||||||
<caret>
|
<caret>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Function 'a' without a body must be abstract
|
||||||
class Some {
|
class Some {
|
||||||
fun <caret>
|
fun <caret>
|
||||||
}
|
}
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// TYPE: '//'
|
||||||
|
// ERROR: Property must be initialized
|
||||||
|
|
||||||
|
class InClassInUninitializedPropertyAccessor {
|
||||||
|
var prop1: Int
|
||||||
|
set(value) {
|
||||||
|
<caret> println("prop.setter")
|
||||||
|
field = value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
class Test {
|
class Test {
|
||||||
val more : Int = 0
|
val more : Int = 0
|
||||||
val test : Int
|
val test : Int
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
val b = true
|
||||||
|
|
||||||
val a = 1
|
fun test() = if (b) {
|
||||||
fun test() = if (a) {
|
|
||||||
fun hello() {
|
fun hello() {
|
||||||
<caret>
|
<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val some = if () {
|
val some = if () {
|
||||||
fun other() {
|
fun other() {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: A type annotation is required on a value parameter
|
||||||
|
|
||||||
interface Some
|
interface Some
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: jq
|
||||||
|
// ERROR: Unresolved reference: pria
|
||||||
fun main() {
|
fun main() {
|
||||||
jq() { pri<caret> }
|
jq() { pri<caret> }
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: awhen
|
||||||
|
enum class A {
|
||||||
|
e1, e2, e3
|
||||||
|
}
|
||||||
|
|
||||||
class B(val a: A)
|
class B(val a: A)
|
||||||
|
|
||||||
val B.foo: Int
|
val B.foo: Int
|
||||||
get() {
|
get() {
|
||||||
return <caret>when (a) {
|
return <caret>when (a) {
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// TYPE: t
|
||||||
|
|
||||||
|
fun CharSequence.repeat(n: Int): String {
|
||||||
|
val sb = StringBuilder(n * length)
|
||||||
|
for (i in 1..n) {
|
||||||
|
sb.append(this)
|
||||||
|
}
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
|
|
||||||
fun twice(s: String): String {
|
fun twice(s: String): String {
|
||||||
val repeatFun: String.(Int) -> String = { t -> this.repeat(<caret>) }
|
val repeatFun: String.(Int) -> String = { t -> this.repeat(<caret>) }
|
||||||
|
|
||||||
return repeatFun(s, 2)
|
return repeatFun(s, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TYPE: t
|
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
// ERROR: Unsupported [literal prefixes and suffixes]
|
||||||
fun test() {
|
fun test() {
|
||||||
val a = 1<caret>
|
val a = 1<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
class Test {
|
class Test {
|
||||||
class Other {
|
class Other {
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: This variable must either have a type annotation or be initialized
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
class Other {
|
class Other {
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
// TYPE: 'Int`
|
// TYPE: 'Int'
|
||||||
|
|
||||||
class InPropertyAccessorSpecifyType {
|
class InPropertyAccessorSpecifyType {
|
||||||
val prop1: Int
|
val prop1: Int
|
||||||
get():<caret> = 42
|
get():<caret> = 42
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Investigate
|
||||||
|
// SKIP_ANALYZE_CHECK
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
// TYPE: '@Throws(Exception::class)`
|
// TYPE: '@Some("X")'
|
||||||
|
|
||||||
|
annotation class Some(val message: String)
|
||||||
|
|
||||||
class InPropertyAccessorWithAnnotation {
|
class InPropertyAccessorWithAnnotation {
|
||||||
val prop1: Int
|
val prop1: Int
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Unresolved reference: a12
|
||||||
|
|
||||||
val test : Int
|
val test : Int
|
||||||
get() = <caret>12
|
get() = <caret>12
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Unresolved reference: foao
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
fun foo(): Int = 12
|
fun foo(): Int = 12
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: foao
|
||||||
class A {
|
class A {
|
||||||
fun foo(): Int = 12
|
fun foo(): Int = 12
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: apri
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
val a : () -> Int = { <caret>pri }
|
val a : () -> Int = { <caret>pri }
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,4 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: printlna
|
||||||
|
|
||||||
fun more() { println<caret> }
|
fun more() { println<caret> }
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// TYPE: '//'
|
||||||
|
// ERROR: Property must be initialized
|
||||||
|
|
||||||
|
var prop1: Int
|
||||||
|
set(value) {
|
||||||
|
<caret> println("prop.setter")
|
||||||
|
field = value
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: caall
|
||||||
class A {
|
class A {
|
||||||
init {
|
init {
|
||||||
ca<caret>ll()
|
ca<caret>ll()
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
fun hello() {
|
fun hello() {
|
||||||
<caret>
|
<caret>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
class LocalFunWithBodyInClass {
|
class LocalFunWithBodyInClass {
|
||||||
fun test() {
|
fun test() {
|
||||||
fun hello() {
|
fun hello() {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
object Some {
|
object Some {
|
||||||
fun test() {
|
fun test() {
|
||||||
<caret>
|
<caret>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
object Some {
|
object Some {
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
interface Some
|
interface Some
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: This variable must either have a type annotation or be initialized
|
||||||
|
// ERROR: Type mismatch: inferred type is Unit but Int? was expected
|
||||||
|
// ERROR: Type mismatch: inferred type is Unit but Int? was expected
|
||||||
|
|
||||||
val test: Int? = if (true) {
|
val test: Int? = if (true) {
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
|
||||||
// Problem with lazy initialization of nullable properties
|
// Problem with lazy initialization of nullable properties
|
||||||
|
|
||||||
|
// TODO: Investigate
|
||||||
|
// --ERROR: Unresolved reference: q
|
||||||
interface Some
|
interface Some
|
||||||
|
|
||||||
val test: Some? = object: Some {
|
val test: Some? = object: Some {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
// SKIP_ANALYZE_CHECK
|
// SKIP_ANALYZE_CHECK
|
||||||
|
// ERROR: Function declaration must have a name
|
||||||
|
|
||||||
fun test() {<caret>
|
fun test() {<caret>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
|
// RUNTIME_WITH_SCRIPT_RUNTIME
|
||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// OUT_OF_CODE_BLOCK: FALSE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
<caret>
|
<caret>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
// RUNTIME_WITH_SCRIPT_RUNTIME
|
||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Too many arguments for public final fun foo(): Int defined in ScriptTopLevelCallExpression
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
fun foo() = 1
|
fun foo() = 1
|
||||||
|
|
||||||
foo(<caret>)
|
foo(<caret>)
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
|
// RUNTIME_WITH_SCRIPT_RUNTIME
|
||||||
// OUT_OF_CODE_BLOCK: TRUE
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
// ERROR: Unresolved reference: a
|
||||||
|
// ERROR: Unsupported [literal prefixes and suffixes]
|
||||||
|
|
||||||
1<caret>
|
1<caret>
|
||||||
|
|
||||||
// SKIP_ANALYZE_CHECK
|
// SKIP_ANALYZE_CHECK
|
||||||
|
|||||||
+12
@@ -13,8 +13,10 @@ import com.intellij.psi.PsiManager
|
|||||||
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
|
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.caches.trackers.outOfBlockModificationCount
|
import org.jetbrains.kotlin.idea.caches.trackers.outOfBlockModificationCount
|
||||||
|
import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
@@ -39,6 +41,10 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur
|
|||||||
TestCase.assertNotNull("Should be valid element", element)
|
TestCase.assertNotNull("Should be valid element", element)
|
||||||
val oobBeforeType = ktFile.outOfBlockModificationCount
|
val oobBeforeType = ktFile.outOfBlockModificationCount
|
||||||
val modificationCountBeforeType = tracker.modificationCount
|
val modificationCountBeforeType = tracker.modificationCount
|
||||||
|
|
||||||
|
// have to analyze file before any change to support incremental analysis
|
||||||
|
ktFile.analyzeWithAllCompilerChecks()
|
||||||
|
|
||||||
myFixture.type(stringToType)
|
myFixture.type(stringToType)
|
||||||
PsiDocumentManager.getInstance(myFixture.project).commitDocument(myFixture.getDocument(myFixture.file))
|
PsiDocumentManager.getInstance(myFixture.project).commitDocument(myFixture.getDocument(myFixture.file))
|
||||||
val oobAfterCount = ktFile.outOfBlockModificationCount
|
val oobAfterCount = ktFile.outOfBlockModificationCount
|
||||||
@@ -52,11 +58,17 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur
|
|||||||
+ FileUtil.loadFile(testDataFile()),
|
+ FileUtil.loadFile(testDataFile()),
|
||||||
expectedOutOfBlock, oobBeforeType != oobAfterCount
|
expectedOutOfBlock, oobBeforeType != oobAfterCount
|
||||||
)
|
)
|
||||||
|
checkForUnexpectedErrors(ktFile)
|
||||||
|
|
||||||
if (!isSkipCheckDefined) {
|
if (!isSkipCheckDefined) {
|
||||||
checkOOBWithDescriptorsResolve(expectedOutOfBlock)
|
checkOOBWithDescriptorsResolve(expectedOutOfBlock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkForUnexpectedErrors(ktFile: KtFile) {
|
||||||
|
DirectiveBasedActionUtils.checkForUnexpectedErrors(ktFile) { it.analyzeWithAllCompilerChecks().bindingContext.diagnostics }
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkOOBWithDescriptorsResolve(expectedOutOfBlock: Boolean) {
|
private fun checkOOBWithDescriptorsResolve(expectedOutOfBlock: Boolean) {
|
||||||
ApplicationManager.getApplication().runReadAction {
|
ApplicationManager.getApplication().runReadAction {
|
||||||
(PsiManager.getInstance(myFixture.project).modificationTracker as PsiModificationTrackerImpl)
|
(PsiManager.getInstance(myFixture.project).modificationTracker as PsiModificationTrackerImpl)
|
||||||
|
|||||||
+13
-3
@@ -68,9 +68,9 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
|
|||||||
runTest("idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt");
|
runTest("idea/testData/codeInsight/outOfBlock/FunWithType_Initializer_Expression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("InAntonymsObjectDeclaration.kt")
|
@TestMetadata("InAnonymousObjectDeclaration.kt")
|
||||||
public void testInAntonymsObjectDeclaration() throws Exception {
|
public void testInAnonymousObjectDeclaration() throws Exception {
|
||||||
runTest("idea/testData/codeInsight/outOfBlock/InAntonymsObjectDeclaration.kt");
|
runTest("idea/testData/codeInsight/outOfBlock/InAnonymousObjectDeclaration.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("InClass.kt")
|
@TestMetadata("InClass.kt")
|
||||||
@@ -83,6 +83,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
|
|||||||
runTest("idea/testData/codeInsight/outOfBlock/InClassFunctionWithoutInference.kt");
|
runTest("idea/testData/codeInsight/outOfBlock/InClassFunctionWithoutInference.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InClassInUninitializedPropertyAccessor.kt")
|
||||||
|
public void testInClassInUninitializedPropertyAccessor() throws Exception {
|
||||||
|
runTest("idea/testData/codeInsight/outOfBlock/InClassInUninitializedPropertyAccessor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InClassPropertyAccessor.kt")
|
@TestMetadata("InClassPropertyAccessor.kt")
|
||||||
public void testInClassPropertyAccessor() throws Exception {
|
public void testInClassPropertyAccessor() throws Exception {
|
||||||
runTest("idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt");
|
runTest("idea/testData/codeInsight/outOfBlock/InClassPropertyAccessor.kt");
|
||||||
@@ -218,6 +223,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
|
|||||||
runTest("idea/testData/codeInsight/outOfBlock/InTopFun.kt");
|
runTest("idea/testData/codeInsight/outOfBlock/InTopFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InUninitializedPropertyAccessor.kt")
|
||||||
|
public void testInUninitializedPropertyAccessor() throws Exception {
|
||||||
|
runTest("idea/testData/codeInsight/outOfBlock/InUninitializedPropertyAccessor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InitBlock.kt")
|
@TestMetadata("InitBlock.kt")
|
||||||
public void testInitBlock() throws Exception {
|
public void testInitBlock() throws Exception {
|
||||||
runTest("idea/testData/codeInsight/outOfBlock/InitBlock.kt");
|
runTest("idea/testData/codeInsight/outOfBlock/InitBlock.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user