Add lazy debug diagnostic DEBUG_INFO_EXPRESSION_TYPE
This commit is contained in:
+8
-2
@@ -175,9 +175,15 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
if (platform is MultiTargetPlatform.Specific) platform to moduleBindings[testModule]!!
|
||||
else null
|
||||
}
|
||||
val moduleDescriptor = modules[module]!!
|
||||
|
||||
ok = ok and testFile.getActualText(
|
||||
moduleBindings[module]!!, implementingModulesBindings, actualText,
|
||||
shouldSkipJvmSignatureDiagnostics(groupedByModule) || isCommonModule
|
||||
moduleBindings[module]!!,
|
||||
implementingModulesBindings,
|
||||
actualText,
|
||||
shouldSkipJvmSignatureDiagnostics(groupedByModule) || isCommonModule,
|
||||
languageVersionSettingsByModule[module]!!,
|
||||
moduleDescriptor
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.load.java.InternalFlexibleTypeTransformer
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -45,6 +46,7 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.MultiTargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactoryImpl
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.junit.Assert
|
||||
@@ -132,8 +134,9 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
textWithMarkers: String,
|
||||
val directives: Map<String, String>
|
||||
) {
|
||||
private val diagnosedRanges: MutableList<DiagnosedRange> = ArrayList()
|
||||
val actualDiagnostics: MutableList<ActualDiagnostic> = ArrayList()
|
||||
private val diagnosedRanges: MutableList<DiagnosedRange> = mutableListOf()
|
||||
private val diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>> = mutableMapOf()
|
||||
val actualDiagnostics: MutableList<ActualDiagnostic> = mutableListOf()
|
||||
val expectedText: String
|
||||
val clearText: String
|
||||
private val createKtFile: Lazy<KtFile?>
|
||||
@@ -144,7 +147,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
val declareFlexibleType: Boolean
|
||||
val checkLazyLog: Boolean
|
||||
private val markDynamicCalls: Boolean
|
||||
val dynamicCallDescriptors: MutableList<DeclarationDescriptor> = ArrayList()
|
||||
val dynamicCallDescriptors: MutableList<DeclarationDescriptor> = mutableListOf()
|
||||
val withNewInferenceDirective: Boolean
|
||||
val newInferenceEnabled: Boolean
|
||||
val renderDiagnosticMessages: Boolean
|
||||
@@ -167,7 +170,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
this.expectedText = this.clearText
|
||||
} else {
|
||||
this.expectedText = textWithMarkers
|
||||
this.clearText = CheckerTestUtil.parseDiagnosedRanges(addExtras(expectedText), diagnosedRanges)
|
||||
this.clearText = CheckerTestUtil.parseDiagnosedRanges(addExtras(expectedText), diagnosedRanges, diagnosedRangesToDiagnosticNames)
|
||||
this.createKtFile = lazy { TestCheckerUtil.createCheckAndReturnPsiFile(fileName, clearText, project) }
|
||||
}
|
||||
this.renderDiagnosticMessages = RENDER_DIAGNOSTICS_MESSAGES in directives
|
||||
@@ -223,7 +226,9 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
bindingContext: BindingContext,
|
||||
implementingModulesBindings: List<Pair<MultiTargetPlatform, BindingContext>>,
|
||||
actualText: StringBuilder,
|
||||
skipJvmSignatureDiagnostics: Boolean
|
||||
skipJvmSignatureDiagnostics: Boolean,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
moduleDescriptor: ModuleDescriptorImpl
|
||||
): Boolean {
|
||||
val ktFile = this.ktFile
|
||||
if (ktFile == null) {
|
||||
@@ -242,21 +247,31 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
|
||||
val ok = booleanArrayOf(true)
|
||||
val withNewInference = newInferenceEnabled && withNewInferenceDirective && !USE_OLD_INFERENCE_DIAGNOSTICS_FOR_NI
|
||||
val diagnostics = ContainerUtil.filter(
|
||||
CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(
|
||||
bindingContext, implementingModulesBindings, ktFile, markDynamicCalls, dynamicCallDescriptors, newInferenceEnabled
|
||||
) + jvmSignatureDiagnostics,
|
||||
val diagnostics = CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(
|
||||
bindingContext,
|
||||
implementingModulesBindings,
|
||||
ktFile,
|
||||
markDynamicCalls,
|
||||
dynamicCallDescriptors,
|
||||
newInferenceEnabled,
|
||||
languageVersionSettings,
|
||||
DataFlowValueFactoryImpl(languageVersionSettings),
|
||||
moduleDescriptor,
|
||||
this.diagnosedRangesToDiagnosticNames
|
||||
)
|
||||
val filteredDiagnostics = ContainerUtil.filter(
|
||||
diagnostics + jvmSignatureDiagnostics,
|
||||
{ whatDiagnosticsToConsider.value(it.diagnostic) }
|
||||
)
|
||||
|
||||
actualDiagnostics.addAll(diagnostics)
|
||||
actualDiagnostics.addAll(filteredDiagnostics)
|
||||
|
||||
val uncheckedDiagnostics = mutableListOf<PositionalTextDiagnostic>()
|
||||
val inferenceCompatibilityOfTest = asInferenceCompatibility(withNewInference)
|
||||
val invertedInferenceCompatibilityOfTest = asInferenceCompatibility(!withNewInference)
|
||||
|
||||
val diagnosticToExpectedDiagnostic =
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, diagnostics, object : DiagnosticDiffCallbacks {
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, filteredDiagnostics, object : DiagnosticDiffCallbacks {
|
||||
override fun missingDiagnostic(diagnostic: TextDiagnostic, expectedStart: Int, expectedEnd: Int) {
|
||||
if (withNewInferenceDirective && diagnostic.inferenceCompatibility != inferenceCompatibilityOfTest) {
|
||||
updateUncheckedDiagnostics(diagnostic, expectedStart, expectedEnd)
|
||||
@@ -307,7 +322,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
actualText.append(
|
||||
CheckerTestUtil.addDiagnosticMarkersToText(
|
||||
ktFile,
|
||||
diagnostics,
|
||||
filteredDiagnostics,
|
||||
diagnosticToExpectedDiagnostic,
|
||||
{ file -> file.text },
|
||||
uncheckedDiagnostics,
|
||||
|
||||
@@ -33,6 +33,10 @@ private data class DiagnosticData(
|
||||
private abstract class Test(private vararg val expectedMessages: String) {
|
||||
fun test(psiFile: PsiFile, environment: KotlinCoreEnvironment) {
|
||||
val bindingContext = JvmResolveUtil.analyze(psiFile as KtFile, environment).bindingContext
|
||||
val emptyModule = KotlinTestUtils.createEmptyModule()
|
||||
val container = createContainerForTests(environment.project, emptyModule)
|
||||
val dataFlowValueFactory = container.dataFlowValueFactory
|
||||
val languageVersionSettings = container.expressionTypingServices.languageVersionSettings
|
||||
val expectedText = CheckerTestUtil.addDiagnosticMarkersToText(
|
||||
psiFile,
|
||||
CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(
|
||||
@@ -40,12 +44,15 @@ private abstract class Test(private vararg val expectedMessages: String) {
|
||||
false,
|
||||
mutableListOf(),
|
||||
null,
|
||||
false
|
||||
false,
|
||||
languageVersionSettings,
|
||||
dataFlowValueFactory,
|
||||
emptyModule
|
||||
)
|
||||
).toString()
|
||||
val diagnosedRanges = Lists.newArrayList<DiagnosedRange>()
|
||||
|
||||
CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges)
|
||||
CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges, mutableMapOf())
|
||||
|
||||
val actualDiagnostics = CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(
|
||||
bindingContext,
|
||||
@@ -53,7 +60,10 @@ private abstract class Test(private vararg val expectedMessages: String) {
|
||||
false,
|
||||
mutableListOf(),
|
||||
null,
|
||||
false
|
||||
false,
|
||||
languageVersionSettings,
|
||||
dataFlowValueFactory,
|
||||
emptyModule
|
||||
)
|
||||
|
||||
makeTestData(actualDiagnostics, diagnosedRanges)
|
||||
|
||||
@@ -367,7 +367,8 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
||||
List<KtFile> ktFiles = new ArrayList<>(files.size());
|
||||
for (TestFile file : files) {
|
||||
if (file.name.endsWith(".kt")) {
|
||||
String content = CheckerTestUtil.INSTANCE.parseDiagnosedRanges(file.content, new ArrayList<>(0));
|
||||
// `rangesToDiagnosticNames` parameter is not-null only for diagnostic tests, it's using for lazy diagnostics
|
||||
String content = CheckerTestUtil.INSTANCE.parseDiagnosedRanges(file.content, new ArrayList<>(0), null);
|
||||
ktFiles.add(KotlinTestUtils.createFile(file.name, content, project));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,8 @@ public class CodegenTestFiles {
|
||||
|
||||
@NotNull
|
||||
public static CodegenTestFiles create(@NotNull String fileName, @NotNull String contentWithDiagnosticMarkup, @NotNull Project project) {
|
||||
String content = CheckerTestUtil.INSTANCE.parseDiagnosedRanges(contentWithDiagnosticMarkup, new ArrayList<>());
|
||||
// `rangesToDiagnosticNames` parameter is not-null only for diagnostic tests, it's using for lazy diagnostics
|
||||
String content = CheckerTestUtil.INSTANCE.parseDiagnosedRanges(contentWithDiagnosticMarkup, new ArrayList<>(), null);
|
||||
KtFile file = KotlinTestUtils.createFile(fileName, content, project);
|
||||
List<PsiErrorElement> ranges = AnalyzingUtils.getSyntaxErrorRanges(file);
|
||||
assert ranges.isEmpty() : "Syntax errors found in " + file + ": " + ranges;
|
||||
|
||||
Reference in New Issue
Block a user