[LL FIR] do not create lazy bodies during on-air resolve in scripts

We assume that on-air resolve already has normal bodies,
so depending on this fact, we can omit some redundant work

^KT-61026 Fixed
This commit is contained in:
Dmitrii Gridin
2023-08-07 16:10:49 +02:00
committed by Space Team
parent 601ffb2db4
commit 734a3e5716
10 changed files with 79 additions and 8 deletions
@@ -46,6 +46,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerForWholeFileTestG
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test
@TestMetadata("callInsideScriptExpression.kts")
public void testCallInsideScriptExpression() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/callInsideScriptExpression.kts");
}
@Test @Test
@TestMetadata("fileWithKDoc.kt") @TestMetadata("fileWithKDoc.kt")
public void testFileWithKDoc() throws Exception { public void testFileWithKDoc() throws Exception {
@@ -43,7 +43,7 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
@Test @Test
public void testAllFilesPresentInReferenceShortener() throws Exception { public void testAllFilesPresentInReferenceShortener() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test @Test
@@ -52,6 +52,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/annotaiton.kt"); runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/annotaiton.kt");
} }
@Test
@TestMetadata("callInsideScriptExpression.kts")
public void testCallInsideScriptExpression() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/callInsideScriptExpression.kts");
}
@Test @Test
@TestMetadata("callableFromDefaultImport.kt") @TestMetadata("callableFromDefaultImport.kt")
public void testCallableFromDefaultImport() throws Exception { public void testCallableFromDefaultImport() throws Exception {
@@ -460,7 +466,7 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
public class NestedClasses { public class NestedClasses {
@Test @Test
public void testAllFilesPresentInNestedClasses() throws Exception { public void testAllFilesPresentInNestedClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test @Test
@@ -505,7 +511,7 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
public class ClassHeaderPositions { public class ClassHeaderPositions {
@Test @Test
public void testAllFilesPresentInClassHeaderPositions() throws Exception { public void testAllFilesPresentInClassHeaderPositions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test @Test
@@ -46,6 +46,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerForWholeFi
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test
@TestMetadata("callInsideScriptExpression.kts")
public void testCallInsideScriptExpression() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortenerWholeFile/callInsideScriptExpression.kts");
}
@Test @Test
@TestMetadata("fileWithKDoc.kt") @TestMetadata("fileWithKDoc.kt")
public void testFileWithKDoc() throws Exception { public void testFileWithKDoc() throws Exception {
@@ -43,7 +43,7 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
@Test @Test
public void testAllFilesPresentInReferenceShortener() throws Exception { public void testAllFilesPresentInReferenceShortener() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test @Test
@@ -52,6 +52,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/annotaiton.kt"); runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/annotaiton.kt");
} }
@Test
@TestMetadata("callInsideScriptExpression.kts")
public void testCallInsideScriptExpression() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/callInsideScriptExpression.kts");
}
@Test @Test
@TestMetadata("callableFromDefaultImport.kt") @TestMetadata("callableFromDefaultImport.kt")
public void testCallableFromDefaultImport() throws Exception { public void testCallableFromDefaultImport() throws Exception {
@@ -460,7 +466,7 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
public class NestedClasses { public class NestedClasses {
@Test @Test
public void testAllFilesPresentInNestedClasses() throws Exception { public void testAllFilesPresentInNestedClasses() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test @Test
@@ -505,7 +511,7 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
public class ClassHeaderPositions { public class ClassHeaderPositions {
@Test @Test
public void testAllFilesPresentInClassHeaderPositions() throws Exception { public void testAllFilesPresentInClassHeaderPositions() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions"), Pattern.compile("^(.+)\\.kt$"), null, true); KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions"), Pattern.compile("^(.+)\\.(kt|kts)$"), null, true);
} }
@Test @Test
@@ -0,0 +1,16 @@
package one
class A
class B
fun foo(a: () -> Unit) {
}
foo {
<expr>one.A</expr>
}
foo {
one.B
}
@@ -0,0 +1,7 @@
Before shortening: one.A
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] one.A
with SHORTEN_AND_STAR_IMPORT:
[qualifier] one.A
@@ -0,0 +1,16 @@
package one
class A
class B
fun foo(a: () -> Unit) {
}
foo {
one.A
}
foo {
one.B
}
@@ -0,0 +1,8 @@
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[qualifier] one.A
[qualifier] one.B
with SHORTEN_AND_STAR_IMPORT:
[qualifier] one.A
[qualifier] one.B
@@ -47,7 +47,7 @@ internal class RawFirNonLocalDeclarationBuilder private constructor(
scopeProvider: FirScopeProvider, scopeProvider: FirScopeProvider,
file: KtFile, file: KtFile,
): FirFile { ): FirFile {
val builder = PsiRawFirBuilder(session, scopeProvider, bodyBuildingMode = BodyBuildingMode.LAZY_BODIES) val builder = PsiRawFirBuilder(session, scopeProvider, bodyBuildingMode = BodyBuildingMode.NORMAL)
return builder.buildFirFile(file) return builder.buildFirFile(file)
} }
@@ -249,7 +249,7 @@ private fun AnalysisApiTestGroup.generateAnalysisApiComponentsTests() {
component("referenceShortener", filter = frontendIs(FrontendKind.Fir) and analysisSessionModeIs(AnalysisSessionMode.Normal)) { component("referenceShortener", filter = frontendIs(FrontendKind.Fir) and analysisSessionModeIs(AnalysisSessionMode.Normal)) {
test(AbstractReferenceShortenerTest::class) { test(AbstractReferenceShortenerTest::class) {
model("referenceShortener") model("referenceShortener", pattern = TestGeneratorUtil.KT_OR_KTS)
} }
test(AbstractReferenceShortenerForWholeFileTest::class) { test(AbstractReferenceShortenerForWholeFileTest::class) {
model("referenceShortenerWholeFile", pattern = TestGeneratorUtil.KT_OR_KTS) model("referenceShortenerWholeFile", pattern = TestGeneratorUtil.KT_OR_KTS)