Commit Graph

593 Commits

Author SHA1 Message Date
Marco Pennekamp 708ed81eb2 [Test] Avoid importing unused @Nested annotations in generated tests
- Unused `Nested` imports frequently cause unused import warnings in the
  IDE, which are especially annoying in after-commit warning/error
  analysis.
2024-02-27 20:30:06 +00:00
Marco Pennekamp 78ef58bef4 [AA] Tests: Remove decompiled files from LibraryBinary and add LibraryBinaryDecompiled
- `LibraryBinary` should not contain any decompiled files, as we want
  FIR symbols in tests to be provided from indexed stubs or class files,
  but definitely not from decompiled PSI. This brings `LibraryBinary`
  much closer to the behavior of binary libraries in the IDE.
- Some tests may still require access to a decompiled file, for example
  when trying to test `getOrBuildFir` for some `KtElement` coming from a
  library. This commit introduces `LibraryBinaryDecompiled`, which
  does contain decompiled files.
- We don't really need `LibraryBinary` as a main test module kind
  anymore, since tests generally want to access some main `KtFile`.
  Hence, test configurators for `LibraryBinary` have been turned into
  configurators for `LibraryBinaryDecompiled`.
- An alternative would be decompiling files on demand, but this is not
  currently feasible because the Standalone API doesn't reconcile stubs
  with decompiled PSI, like the IDE does automatically. (For the same
  declaration, the stub and the PSI will have a different identity.) As
  long as there is no support for this, we'll have to rely on a separate
  test module kind.

^KT-65960
2024-02-26 21:57:23 +00:00
Marco Pennekamp 2060709c03 [AA] Turn KtModuleWithFiles into KtTestModule (AA test framework)
- `KtModuleWithFiles` isn't actually used in a production Standalone API
  context, but it was exposed via `analysis-api-standalone-base`. In
  current production usages, the project structure is built with the
  module builder DSL.
- Hence, `KtModuleWithFiles` is only relevant for tests. This commit
  moves `KtModuleWithFiles` to the Analysis API test framework and
  renames it to `KtTestModule`. This removes any risk that an outside
  user could start using `KtModuleWithFiles` and completely uncouples
  the test project structure from production APIs.
- In addition, we can add the `TestModule` to `KtTestModule`, allowing
  tests to quickly access the original test module, for example to check
  the test module kind.
- The commit also removes the data class status of `KtTestModule` and
  `KtTestModuleProjectStructure` to avoid issues with destructuring when
  properties are added or removed.

^KT-65960
2024-02-26 21:57:23 +00:00
Yahor Berdnikau 6b19b8b9d0 [Repo] Don't use kotlinOptions in repo build scripts
^KT-63419 In Progress
2024-02-22 14:48:10 +00:00
Dmitrii Gridin d64fc9b777 [SLC] map kotlin.Unit type typealias into void return type
^KT-65843 Fixed
2024-02-19 21:24:42 +00:00
Dmitrii Gridin 8dd66c0810 [LC] add test on unit type actualization
^KT-65843
2024-02-19 21:24:42 +00:00
Dmitriy Novozhilov acf2296590 [Test] Regenerate tests after two previous commits 2024-02-16 12:48:24 +00:00
Jinseong Jeon 460339870a K2 UAST: lookup declarations mangled due to value class
^KT-65653 fixed
2024-02-15 17:02:04 +00:00
Dmitrii Gridin c78d3edd24 [SLC] support type parameter annotations
^KT-65112 Fixed
2024-02-15 15:18:02 +00:00
Dmitrii Gridin ae8e9749c8 [SLC] AnnotationsBox: use PsiElement instead of PsiModifierList
Not only PsiModifierList can be the parent of an annotation,
so we should make the restrictions less aggressive.

^KT-65112
2024-02-15 15:18:02 +00:00
Dmitrii Gridin 3e3c932bf6 [LC] add tests on type parameter annotations
^KT-65112
2024-02-15 15:18:02 +00:00
Dmitrii Gridin d5705af8b1 [SLC] AbstractSymbolLightClassesParentingTestBase: make aware of PsiTypeParameter
It can have annotations

^KT-65112
^IDEA-346155
2024-02-15 15:18:02 +00:00
Vladimir Dolzhenko 95ea711659 Fix PsiLiteral#getReferences
#KTIJ-28769


Merge-request: KT-MR-14391
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2024-02-14 13:39:50 +00:00
Vladimir Dolzhenko 038fe15dd4 PsiLiteral have to provide reference(s)
#KTIJ-28769 Fixed


Merge-request: KT-MR-14314
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2024-02-12 17:16:32 +00:00
Jinseong Jeon b0ad91a98c SLC: create backing field for deprecated property
...since they still appear at JVM bytecode.

Also, ULC doesn't look at deprecated annotation for bail-out criteria.

^KT-65393 fixed
2024-02-11 01:41:44 +00:00
Jinseong Jeon 0533c73910 SLC: add tests about deprecated-hidden property/accessor
^KT-65393
^KTIJ-27244
2024-02-11 01:41:43 +00:00
Dmitrii Gridin b1b33475fa [SLC] SymbolLightParameterCommon: drop redundant parameterDeclaration
Now we can replace it with kotlinOrigin

^KT-64772
2024-02-08 19:45:17 +00:00
Dmitrii Gridin 255a2d27f7 [SLC] SymbolLightTypeParameter: drop redundant typeParameterDeclaration
Now we can replace it with kotlinOrigin

^KT-64772
2024-02-08 19:45:17 +00:00
Dmitrii Gridin 042042768f [SLC] prefer sourcePsiSafe to psiSafe
We should use only source declarations as anchors as it is a predictable
contract

^KT-64772
2024-02-08 19:45:17 +00:00
Dmitrii Gridin b8306c8242 [SLC] SymbolLightParameterCommon: use only source kotlinOriginal
We shouldn't return it for, for example, SOURCE_MEMBER_GENERATED

^KT-64772 Fixed
2024-02-08 19:45:17 +00:00
Alexander Udalov 28797a31b4 JVM: refactor JvmDefaultMode, remove/rename some entries
- remove ENABLE/COMPATIBILITY because they can no longer be used
- remove forAllMethodsWithBody because its behavior is now equivalent to
  isEnabled
- inline isCompatibility
- inline DEFAULT
- rename ALL_INCOMPATIBLE -> ALL
2024-02-06 17:18:44 +00:00
Roman Golyshev a55b8d30fd KT-65425 [SLC] Correctly compute getQualifiedName for generated classes
Since the declarations generated by compiler plugins do not have proper
PSI (`classOrObjectDeclaration` in this case), we need to resort to
symbols for such declarations to compute the proper qualified name

^KT-65425 Fixed
2024-02-01 10:14:20 +00:00
Jinseong Jeon 43acc6516b SLC: mangle internal accessors
...by honoring accessors' visibility

We need a special handling for backing field visibility,
e.g., lateinit, const, or JvmField, but that's not the case
for accessors' visibility.

^KT-64937 fixed
2024-01-23 21:55:09 +00:00
strangepleasures 85c9c57da4 [KAPT] KT-65006 fix issues when using Kapt+Serialization
This MR fixes two independent issues causing build failures when using Kapt in combination with the Kotlin serialization plugin (and, very likely, with other plugins as well):
Kapt applied compiler plugins twice, causing errors similar to the one described in KT-65006
Kapt failed to generate @Metadata annotations for plugin-generated companion objects because the corresponding SLC missed containingFile needed for generation of method and class signatures

Merge-request: KT-MR-13970
Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
2024-01-23 20:35:32 +00:00
Jinseong Jeon 0dfaa91970 K2 UAST: simplify PSI declaration provider
In addition to class lookup (done at cec299ac), we can use
JavaFileManager to search classes in a certain package too.
2024-01-23 09:09:37 +00:00
Dmitrii Gridin cf290a73fc [Analysis API] migrate AbstractSymbolLightClassesTestBase to doTestByMainModuleAndOptionalMainFile
^KT-64805
2024-01-10 22:07:03 +00:00
Dmitrii Gridin 476940c06b [Analysis API test] get rid of AbstractAnalysisApiBasedSingleModuleTest
^KT-64805
2024-01-10 22:07:03 +00:00
Jinseong Jeon 45b8f99107 SLC: distinguish last v.s. non-last vararg during binary resolution
^KT-64795 fixed
2024-01-10 15:36:40 +00:00
Dmitrii Gridin 50dd94502b [SLC] fix PsiJavaCodeReferenceElement contract violation
We should provide valid getReferenceName as it is used
in many places (e.g. from com.intellij.psi.impl.PsiImplUtil.findAnnotation)

^KT-61605 Fixed
^KT-64605 Fixed
2024-01-08 13:22:56 +00:00
Yan Zhulanow b7c774b9e5 [Analysis API] Generify 'KtCodeFragmentModule' to support ordinary files
This commit introduces dangling file modules, which may be either
code fragments or ordinary Kotlin files. As before, code fragments are
analyzed against some context element, however ordinary files only
have a context module.

Code fragments can also have a dangling file module as a contextual one,
including other code fragment. This is done to support potential usages
in completion, intentions and refactorings.
2024-01-05 16:04:14 +00:00
Dmitrii Gridin 7c8aff963f [SLC] do not create light classes for expect declarations
We shouldn't build expect declarations as they do not
exist. We can omit check on member declarations as we
won't request them as we skip expect classes

^KT-57536 Fixed
2024-01-05 15:07:55 +00:00
Dmitrii Gridin c14c12479c [SLC] fix multifile-classes in multiplatform case
Multifile-class can contain not only files from the same
module, but also files from the common part.
This commit also fixes KotlinByModulesResolutionScopeProvider as
it should provide all transitive dependencies

^KT-64714 Fixed
2024-01-05 15:07:55 +00:00
Dmitrii Gridin fc519b2339 [SLC] add test on multiplatform facade
^KT-64714
2024-01-05 15:07:55 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Dmitrii Gridin 44388ea15f [SLC] generate correct name for property assessors in case of JvmRecord
^KT-62357 Fixed
2024-01-04 16:32:10 +00:00
Dmitrii Gridin 5c71015b09 [LC] implement isRecord for classes
Java world should better understand our classes with JvmRecord annotation

^KT-62357
2024-01-04 16:32:10 +00:00
Dmitrii Gridin c6004874c1 [SLC] generate light classes for functions with JvmName and value class as parameter
Such functions/accessors have not-mangled names, so they can be called
from Java

^KT-63087 Fixed
2024-01-04 15:16:20 +00:00
Dmitrii Gridin e0f524b6b3 [LC] add tests on declarations with JvmName and value classes
^KT-63087
2024-01-04 15:16:20 +00:00
Dmitrii Gridin af5f76048b [SLC] AbstractSymbolLightClassesByPsiTest: add more stable order
Now more diff between sources and libraries are readable.
Also prefer .descriptors to .fir as FIR is a first-class support

^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin d64f18eaa9 [SLC] AbstractSymbolLightClassesStructureTestBase: add stable order
Now more diff between sources and libraries are readable

^KT-62892
2024-01-03 21:35:12 +00:00
Dmitrii Gridin 6c7d1babf0 [Analysis API] support Java compilation in tests
Previously we just skipped Java sources.
The order of classes in light classes test data is changed due to
differences in implementations of `compileLibraryToJar` and `runJvmCompiler`

^KT-62892
2024-01-03 21:35:12 +00:00
Jinseong Jeon e5095a60ba K2 UAST: lookup properties in the containing class, not companion object
...because properties in the companion object are materialized
in the containing class.

^KTIJ-27684 fixed
2023-12-19 07:03:29 +00:00
Jinseong Jeon 10c9b81c79 AA standalone: introduce multi-module binary dependency test 2023-12-19 07:03:29 +00:00
Dmitrii Gridin f39c72360d [SLC] inherit SymbolPsiLiteral from PsiLiteralExpression
We should use PsiLiteralExpression instead of PsiLiteral as it
is used in the Java world. Effectively, `psiLiteral` property
already has this type (as `createPsiExpression` produce `PsiExpression`),
but we missed this part before and used just PsiLiteral for our
own class

^KT-63949 Fixed
2023-12-18 20:20:06 +00:00
Ivan Kylchik 79c300209e [K2] Avoid type check for Kotlin's property in ConstUtils
When we check Java field for constant initializer, we could
be asked to get and check the type of Kotlin's property that
is used in this Java field. But there is no guarantee that the type
resolve phase was finished and this type is available. So we just
check for `const` modifier and skip type check.

#KT-63752 Fixed
#KT-62558 Obsolete
#KT-61786 Declined
2023-12-12 13:54:32 +00:00
Pavel Kirpichenkov 0eb1a63a2f [AA] Add symbol tests for symbols from JS klibs
Use test compiler runner to compile JS libraries. Determine compiler
by the specified TARGET_PLATFORM. Add tests for dynamic type and
JS-specific .proto extensions.

Refactor the code for mock library compilation to make the switch
between platforms more straightforward.

KTIJ-27566
KT-63217
2023-12-01 18:12:23 +00:00
strangepleasures 03ed1d1d31 KT-62560 [SLC] Fix handling of empty varargs in annotations 2023-11-20 20:57:21 +00:00
Marco Pennekamp 6189d68c3c [AA] Refactoring: Provide default implementations for functions of AnalysisApiTestServiceRegistrar
- Most inheritors of `AnalysisApiTestServiceRegistrar` only need to
  override one or two functions.
2023-11-16 19:50:51 +00:00
Marco Pennekamp 2ec77822e2 [AA] createDeclarationProvider: Rename module to contextualModule
^KTIJ-27411
2023-10-26 21:07:28 +00:00
Jinseong Jeon 1ccb085e68 SLC: use fully expanded type when computing nullability
^KT-62757 fixed
2023-10-25 14:59:50 +00:00