Commit Graph

310 Commits

Author SHA1 Message Date
Ilya Gorbunov d2aae67e03 Replace kotlin-test project dependencies in the project
Use dependency helper function that chooses whether to take them
from the bootstrap repository or from a configuration of kotlin-test

KT-61969
2023-12-13 15:40:25 +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
Dmitriy Novozhilov 039baf95fc [Test] Add empty platform module for MPP diagnostic test with only one module
After previous commits IrActualizer runs only there are at least two modules
  in backend input. So to check diagnostics from Actualizer all tests
  should contain at least two modules

Diagnostics in test `extendExpectedClassWithAbstractMember.kt` were
  changed because there is an exception from IrActualizer caused by
  errors from frontend (`ABSTRACT_METHOD_NOT_IMPLEMENTED`), which is
  swallowed by this kind of tests
2023-11-27 10:17:54 +00:00
Roman Golyshev 4f5926a88f KT-62675 [AA] Handle labeled this expressions in reference shortener
At the moment, there is no good way to meaningfully filter `this`
expressions. The filters for the reference shortener can work only with
symbols, and it does not make a lot of sense to check any particular
symbol when deciding whether to shorten a labeled `this` expression.

We would probably need a better API for the shortener to be able
to filter more precisely (see KT-63555)

^KT-62675 Fixed
2023-11-20 20:18:18 +00:00
Marco Pennekamp 12b6096b67 [LL] Add a test base for PSI-modifying low-level API tests
- To support PSI modification, the test environment requires some
  additional configuration, which is encapsulated in
  `AnalysisApiPsiModificationTestServiceRegistrar`.
- The test also has to allow write access explicitly, which is
  configured in `AnalysisApiFirModifiablePsiSourceTestConfigurator`.
2023-11-16 19:50:51 +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
Ilya Kirillov 5f5daa0e06 [Decompiler] rename :analysis:decompiled:native -> :analysis:decompiled:decompiler-native
to avoid possible name clashes between different
Gradle subprojects with the same name.

see https://github.com/gradle/gradle/issues/16986
2023-11-10 06:41:03 +00:00
Ilya Kirillov 7c6870f8d2 [Analysis API Standalone] index .knm files in KotlinStaticDeclarationProvider
so `FirSymbolNamesProvider` can know about them

^KT-62910
2023-11-10 06:41:03 +00:00
Roman Golyshev 2f50267d3f KT-63096 [LL] Make KotlinStaticAnnotationsResolver more correct
By using `KotlinDeclarationProvider`, it can now check that the
annotation is actually present in the scope
2023-11-09 23:39:32 +00:00
Roman Golyshev a1155204c7 KT-63096 [LL] Remove KtModuleScopeProvider
It has no usages anymore
2023-11-09 23:39:32 +00:00
Jaebaek Seo e80f044847 K2: Update reference shortener to handle import alias
The existing reference shortener does not use import alias when it
shortens a symbol. Instead, it adds a new import directive for the
symbol that is already imported. This commit updates reference shortener
to let it reuse the existing import alias rather than adding a new one:

 1. When shortening a symbol, check whether the symbol is already
    imported.
 2. If it is already imported by an import alias, keep the symbol
    reference expression and the import alias as a string together in
    `ShortenCommand`.

The actual PSI update (shortening) based on the ShortenCommand is done
by IntelliJ.

^KTIJ-27205
2023-11-09 14:34:38 +00:00
Jinseong Jeon 4110a9971a AA: fix KtTypeProvider#getReceiverTypeForDoubleColonExpression
K1 version has used a wrong expression to retrieve the slice.
K2 version mishandled property access as a receiver.

^KT-63195 fixed
2023-11-08 16:18:21 +00:00
Anna Kozlova 205a125c5f [AA] implement KtFirSimpleNameReference.getImportAlias
^ KT-62980 fixed

Merge-request: KT-MR-12786
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-11-02 21:23:43 +00:00
Roman Golyshev 236a76f779 KT-62676 [AA] Small refactoring of AbstractReferenceShortener*Test 2023-11-01 09:45:40 +00:00
Roman Golyshev b0f15451fd KT-62676 [AA] Collect redundant this qualifiers in reference shortener
^KT-62676 Fixed
2023-11-01 09:45:40 +00:00
Roman Golyshev 4ca1f9d492 KT-62676 [AA] Introduce ShortenOptions class
This class should contain 'global' settings for reference shortening;
ATM it only contains the `removeThis` flag

In the future this setting might be merged together with
`ShortenStrategy` to be computed on per-element basis
2023-11-01 09:45:40 +00:00
Roman Golyshev adf7ee4535 KT-62676 [AA] Rename ShortenOption -> ShortenStrategy
`Option` is going to refer to more global settings of the
reference shortener (like shortening `this` or `Companion`
references)
2023-11-01 09:45:39 +00:00
Ilya Kirillov 1aa5cf031f [Analysis API FIR] fix "ConeClassLikeTypeImpl is not resolved to symbol for on-error type"
We should not expect builtins to be always available as they are taken from indecies.

For K1 and FIR Standalone implementations, the builtins are always available.

^KT-62010 fixed
2023-10-31 12:24:16 +00:00
Roman Golyshev ef31eeae52 KTIJ-26423 [AA] Get rid of the old testdata for KtImportOptimizer
This testdata is some form will be transferred to the `intellij` repo
2023-10-25 20:53:14 +00:00
Roman Golyshev 421793673b KTIJ-26423 [AA] Extend KtImportOptimizer testdata with imports usage information
`KtImportOptimizerResult.unusedImports` should be removed soon, and
part of the testdata for the import optimizer service should go
to `intellij` repository
2023-10-25 20:53:12 +00:00
Ivan Kochurkin 1827df82c4 Removed useless as casts from compiler code
It allows compiling code with K2 and enabled `-Werror`
2023-10-24 20:59:56 +00:00
Anna Kozlova 5cac013d8c [AA] approximate inplace type parameters bounds
^ KTIJ-27211 fixed
2023-10-24 10:54:15 +00:00
Dmitrii Gridin 17ab005668 [Analysis API FIR] KtSymbolContainingDeclarationProvider: support script declarations
This commit also fixes a missing symbol for KtScriptInitializer
and some symbol pointers
Many tests marked as 'DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE'
due to KtFirFileSymbol#createPointer logic – the pointer can
be created only for PSI

^KT-61451
^KT-61887
^KT-62626 Fixed
^KT-62693
2023-10-20 09:27:21 +00:00
Marco Pennekamp b9e3d848a6 [AA] Add KotlinPackageProviderMerger
- In parallel to Kotlin declaration provider merging, we need a proper
  merging strategy for package providers as well, because resolve
  extensions may define additional package providers.
- Additionally, other non-scope-based package providers may be added in
  the future, and the merger preserves these out of the box.

^KT-61791
2023-10-12 16:10:32 +00:00
Marco Pennekamp 239cfa6d29 [AA] Add tests for combined declared member scopes
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 1408556511 [AA] Refactoring: Rename AbstractMemberScopeByFqNameTest to AbstractMemberScopeTest
^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp df54540a81 [AA] Update usages of declared member scopes
- Now that non-static declared member scopes don't contain static
  callables anymore, we have to update some usages in the Analysis API.
- In symbol light classes, many usages of `getDeclaredMemberScope` can
  be kept as-is because Kotlin classes/objects generally cannot declare
  static callables (and we do not need to create symbol light classes
  for Java classes). The only exception are enum classes, which
  implicitly declare some static callables.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 21efd6aff3 [AA] Add tests for *static* (declared) member scopes
^KT-61900
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 4ba0aef23b [AA] Refactoring: Simplify member scope test classes
^KT-61900
2023-10-10 13:38:00 +00:00
Ilya Kirillov 15e4cbc10d [Analysis API] implement an API to get a substitution based on an inheritance relationship between classes
^KT-62090 fixed
2023-10-06 11:39:33 +00:00
Ilya Kirillov 1107e728a2 [Analysis API] implement better rendering for chained KtSubstitutor 2023-10-06 11:39:33 +00:00
Anna Kozlova da385210d8 [AA] provide psiType#asKtType conversion
it's useful for IDE's features such as write UAST or refactorings

^KT-62302 fixed

Merge-request: KT-MR-12414
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-10-05 15:18:55 +00:00
Yan Zhulanow 9ef58f2bdb [LL API] Collect syntax errors in 'KtFirCompilerFacility'
^KTIJ-27167 Fixed
2023-09-22 11:39:49 +00:00
Yan Zhulanow 834cbaac5a [LL API] Run fir2ir separately for files in different modules
Each module may have its own compiler configuration.

^KTIJ-27061 Fixed
2023-09-21 06:19:15 +00:00
Marco Pennekamp 3add7f9db5 [AA] Support enum entry initializers in member scope tests
- Now that the enum entry initializer provides a member scope, not the
  enum entry, we need a way to get to the enum entry initializer in
  tests. This can only be done via the enum entry's name, because the
  initializer is anonymous.

^KT-61425
2023-09-08 11:13:28 +00:00
Alexander.Likhachev 6eaccc997f [Build] Fix the typo junit jupyter -> jupiter 2023-09-06 22:47:34 +00:00
Alexander.Likhachev 6f96be0b76 [Build] Get rid of the testApiJUnit5 method
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Ilya Kirillov 1f290828e5 [Analysis API Standalone] use the full version of jdk root finding from IJ
partial ones only work for jdk >= 9

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 8f824dcff9 [Analysis API Standalone] copy JdkClassFinder from IntelliJ sources
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 56910b70a3 [Analysis API] fix "KotlinIllegalStateExceptionWithAttachments: expected as maximum one expect for the actual"
^KT-61597 fixed
2023-08-31 15:19:29 +00:00
Yan Zhulanow b96c1a644f [LL API] Fix code fragment compilation in library sources (KT-61383)
In complex projects, there might be several library copies (with the
same or different versions). As there is no way to build a reliable
dependency graph between libraries, a project library depends on all
other libraries. As a result, there might be several declarations in the
classpath with the same name and signature.

Normally, K2 issues a 'resolution ambiguity' error on calls to such
libraries. It is acceptable for resolution, as resolution errors are
never shown in the library code. However, the backend, to which
'evaluate expression' needs to pass FIR afterwards, is not designed for
compiling ambiguous (and non-completed) calls.
2023-08-30 06:38:44 +00:00
Yan Zhulanow 4b80c2197f [Analysis API] Run code fragment compilation tests against libraries 2023-08-30 06:38:44 +00:00
Dmitrii Gridin adc853ebd0 [AA] extend SymbolData API to support scripts
^KT-61431
2023-08-28 15:02:24 +00:00
aleksandrina-streltsova aa0eca6d6d [AA] Provide KtCallableSymbol for static Java members
^KTIJ-25126 Fixed
2023-08-24 22:17:48 +03:00
Roman Golyshev 10df37ba8e KTIJ-26423 [AA] Return more info from KtFirImportOptimizer
Deprecate `unusedImports`, since they are supposed to be computed
on the IDE side from now on based on the information from
Analysis API

Currently the `unusedImports` property is not removed completely
so it can still be used by the Kotlin side import optimizer
tests; they should be moved/adapted to the intellij repository
also
2023-08-21 10:46:58 +00:00
Ilya Kirillov 2ce324f1fc [Analysis API] rename AbstractSingleSymbolByPsi -> AbstractSingleSymbolByPsiTest
to match test naming convention
2023-08-17 13:01:02 +00:00
Ilya Kirillov 1b0034b6e7 [Analysis API] allow AbstractSingleSymbolByPsi to accept <expr>-based section in addition to <caret>-based 2023-08-17 13:01:02 +00:00
Pavel Kirpichenkov c0c234e1d2 Minor: rename files to source files in configurators for standalone mode
KT-59793
2023-08-17 12:03:10 +00:00
Pavel Kirpichenkov ef6375f627 [LL] Use package provider to check for existing package
KT-59793
2023-08-17 12:03:08 +00:00
Yan Zhulanow 5a67b0d7dc [LL API] Correct used IR symbols in code fragments
As 'FirCodeFragments' are converted to IR independently of its context,
in some cases duplicate (and not quite correct) symbols for local
classes and functions are created.

Until properly fixed in fir2ir, here we replace such duplicates with
original symbols.
2023-08-08 17:26:39 +00:00