[Frontend] Make DiagnosticSuppressor a project-level extension
Originally it was an application-level component, which caused non-trivial
logic and cognitive load to carefully handle those extensions to avoid
memory leaks.
6740a596 introduced a way to easily register `DiagnosticSuppressor` to
project, and this commit continues this work, making it a proper
project-level extension
A lot of changes caused by the fact, that this extension is needed to be
obtained from `BindingContext` (see `BindingContextSuppressCache` and
its usages), so almost all changes are introducing `Project` to
`BindingContext`
^KT-66449 Fixed
This commit is contained in:
committed by
Space Team
parent
a552238874
commit
d352cc9d96
@@ -40,9 +40,10 @@ class MutableDiagnosticsTest : KotlinTestWithEnvironment() {
|
||||
get() = bindingContext.diagnostics
|
||||
|
||||
fun testPropagatingModification() {
|
||||
val base = BindingTraceContext()
|
||||
val middle = DelegatingBindingTrace(base.bindingContext, "middle")
|
||||
val derived = DelegatingBindingTrace(middle.bindingContext, "derived")
|
||||
val project = environment.project
|
||||
val base = BindingTraceContext(project)
|
||||
val middle = DelegatingBindingTrace(base.bindingContext, "middle", project)
|
||||
val derived = DelegatingBindingTrace(middle.bindingContext, "derived", project)
|
||||
|
||||
Assert.assertTrue(base.diagnostics.isEmpty())
|
||||
Assert.assertTrue(middle.diagnostics.isEmpty())
|
||||
@@ -83,9 +84,10 @@ class MutableDiagnosticsTest : KotlinTestWithEnvironment() {
|
||||
}
|
||||
|
||||
fun testCaching() {
|
||||
val base = BindingTraceContext()
|
||||
val middle = DelegatingBindingTrace(base.bindingContext, "middle")
|
||||
val derived = DelegatingBindingTrace(middle.bindingContext, "derived")
|
||||
val project = environment.project
|
||||
val base = BindingTraceContext(project)
|
||||
val middle = DelegatingBindingTrace(base.bindingContext, "middle", project)
|
||||
val derived = DelegatingBindingTrace(middle.bindingContext, "derived", project)
|
||||
|
||||
base.reportDiagnostic()
|
||||
middle.reportDiagnostic()
|
||||
|
||||
@@ -73,7 +73,7 @@ class JsVersionRequirementTest : AbstractVersionRequirementTest() {
|
||||
override fun loadModule(directory: File): ModuleDescriptor {
|
||||
val environment = createEnvironment(extraDependencies = listOf(File(directory, "lib.meta.js")))
|
||||
return TopDownAnalyzerFacadeForJS.analyzeFilesWithGivenTrace(
|
||||
emptyList(), BindingTraceContext(), createModule(environment), environment.configuration, CompilerEnvironment, environment.project
|
||||
emptyList(), BindingTraceContext(environment.project), createModule(environment), environment.configuration, CompilerEnvironment, environment.project
|
||||
).moduleDescriptor
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public class DefaultModalityModifiersTest extends KotlinTestWithEnvironment {
|
||||
StorageComponentContainer container = createContainerForLazyResolve(
|
||||
moduleContext,
|
||||
new FileBasedDeclarationProviderFactory(moduleContext.getStorageManager(), files),
|
||||
new BindingTraceContext(),
|
||||
new BindingTraceContext(getProject()),
|
||||
CommonPlatforms.INSTANCE.getDefaultCommonPlatform(),
|
||||
CommonPlatformAnalyzerServices.INSTANCE,
|
||||
CompilerEnvironment.INSTANCE,
|
||||
|
||||
@@ -563,7 +563,7 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
KotlinType type = expressionTypingServices.getType(
|
||||
scope, ktExpression, TypeUtils.NO_EXPECTED_TYPE,
|
||||
DataFlowInfoFactory.EMPTY, InferenceSession.Companion.getDefault(),
|
||||
new BindingTraceContext()
|
||||
new BindingTraceContext(project)
|
||||
);
|
||||
KotlinType expectedType = expectedTypeStr == null ? null : makeType(expectedTypeStr);
|
||||
assertEquals(expectedType, type);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
|
||||
private KotlinType resolveType(String typeStr) {
|
||||
KtTypeReference ktTypeReference = new KtPsiFactory(getProject()).createType(typeStr);
|
||||
AnalyzingUtils.checkForSyntacticErrors(ktTypeReference);
|
||||
BindingTrace trace = new BindingTraceContext();
|
||||
BindingTrace trace = new BindingTraceContext(getProject());
|
||||
KotlinType type = container.getTypeResolver().resolveType(scope, ktTypeReference, trace, true);
|
||||
if (!trace.getBindingContext().getDiagnostics().isEmpty()) {
|
||||
fail("Errors:\n" + StringUtil.join(trace.getBindingContext().getDiagnostics(), DefaultErrorMessages::render, "\n"));
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext;
|
||||
public class TrackingSliceMapTest extends TestCase {
|
||||
public void testSimpleSlice() {
|
||||
WritableSlice<String, Integer> SUPER_COMPUTER = Slices.<String, Integer>sliceBuilder().setDebugName("SUPER_COMPUTER").build();
|
||||
BindingTraceContext traceContext = BindingTraceContext.createTraceableBindingTrace();
|
||||
BindingTraceContext traceContext = BindingTraceContext.createTraceableBindingTrace(null);
|
||||
|
||||
traceContext.record(SUPER_COMPUTER, "Answer", 42);
|
||||
Integer answer = traceContext.get(SUPER_COMPUTER, "Answer");
|
||||
@@ -39,7 +39,7 @@ public class TrackingSliceMapTest extends TestCase {
|
||||
.setFurtherLookupSlices(new ReadOnlySlice[] {NAME_COLOR})
|
||||
.setDebugName("NAME_OBJECT").build();
|
||||
|
||||
BindingTraceContext traceContext = BindingTraceContext.createTraceableBindingTrace();
|
||||
BindingTraceContext traceContext = BindingTraceContext.createTraceableBindingTrace(null);
|
||||
|
||||
traceContext.record(NAME_COLOR, "RED", 0xff0000);
|
||||
Object object = traceContext.get(NAME_OBJECT, "RED");
|
||||
|
||||
Reference in New Issue
Block a user