Commit Graph

55 Commits

Author SHA1 Message Date
Pavel Kirpichenkov 14eef4c7fe Minor: move lost comment 2023-08-17 12:03:09 +00:00
Pavel Kirpichenkov 6de54ef762 Minor: workaround false positive IDE error KTIJ-21172 2023-08-17 12:03:09 +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 8a5cab6831 [LL API] Support '_DebugLabel's in code fragments 2023-08-07 16:22:01 +00:00
Marco Pennekamp 03c8654fe3 [AA] KT-58257 Improve modification event API and documentation
- Module state modification events now have a modification kind, which
  allows adding additional kinds of modification in the future (e.g.
  separating module property and content root updates, if the workspace
  model ever supports it).
  - Splitting off modification kinds was also a good opportunity to
    better document when module state modification occurs.
- Changed the documentation of modification events to be (1) less
  reliant on the IDE implementation and (2) more detailed in the
  intended effect of each event.
- Removed the notion of "stable" modules again and replaced it with
  "libraries". Even though an SDK is technically not a library, the
  term "library modules" should be more friendly to API consumers.
2023-07-31 15:58:01 +00:00
Marco Pennekamp d2b05b8f4f [AA] KT-58257 Restore timing guarantees of module state modification events
- Specifically for non-global module state modification, we can
  guarantee that the event is published before the module is modified.
  This allows subscribers to use the provided `KtModule` without needing
  to fear that the module has already been disposed (in case of
  removal).
2023-07-31 15:58:01 +00:00
Marco Pennekamp 62a71b1559 [AA] KT-58257 Remove global out-of-block modification events
- Out-of-block modification of stable modules is meaningless, because
  stable modules should not be affected by out-of-block modification.
  Hence, only global *source* out-of-block modification makes sense and
  global out-of-block modification events can be removed.
2023-07-31 15:58:01 +00:00
Marco Pennekamp 42c879a53c [LL FIR] KT-58257 Invalidate library sessions depending on anchor modules on global source modification
- Any time an anchor module's session is invalidated, we need to make
  sure that all its dependents are also invalidated. Because those
  dependents may include libraries, invalidation after global source
  modification needs to invalidate such libraries, even if other stable
  module sessions should remain untouched.
2023-07-31 15:58:01 +00:00
Marco Pennekamp 24045067bf [LL FIR] KT-58257 Keep library (source) sessions on global source invalidation
- `LLFirSessionCache.sourceCache` can contain library and library
  sources sessions. However, global source modification events should
  not remove such sessions from the cache, because they belong to
  "stable" modules.
- The commit introduces the term "stable module" as a combined term for
  binary and library source modules. Library sources are not binaries,
  but nevertheless they cannot cause nor be affected by out-of-block
  modification.
- The term "source modules" as used by global "source" modification is
  slightly imprecise, as it does *not* include library sources, but for
  the sake of conciseness, I don't plan to change that.
2023-07-31 15:58:01 +00:00
Marco Pennekamp 2d279c5f25 [AA] KT-58257 Remove timing guarantees of Kotlin modification events
- Kotlin modification events are published before or after the
  modification, depending on the underlying cause. For example, PSI tree
  change events in the IDE can occur both before and after the change,
  so module and global out-of-block modification events must not make
  timing guarantees. Similarly, module state modification events
  published by the IDE can both happen before and after a module change,
  with most events happening before the change.
2023-07-31 15:58:00 +00:00
Marco Pennekamp 0c94a3131c [AA] KT-58257 Add API for subscription-directed invalidation
- The commit refactors some modification trackers previously provided by
  `KotlinModificationTrackerFactory` to a subscription-directed
  mechanism implemented via `MessageBus` and `KotlinTopics`. The
  following modification trackers are affected:
  - Module out-of-block modification: The FE10 Analysis API doesn't use
    these modification trackers, so the effect is limited to LL FIR.
  - Module state: Likewise, FE10 doesn't use this modification tracker,
    so again the effect is limited to LL FIR.
- Project and library modifications trackers remain, because many small
  objects in e.g. light classes depend on these trackers (making
  listener management unfeasible), and they are not relevant for
  `LLFirSession` invalidation.
- This new API paves the way for a session invalidation service to
  subscribe to out-of-block and module state changes as events. This
  removes the need to iterate through modification trackers.
  - Also note that the out-of-block modification provided by the new
    subscription mechanism is intended to work for _any_ `KtModule`, as
    long as it makes sense to have out-of-block modifications. For
    example, the subscription should work for script modules. The OOB
    modification tracker previously only supported `KtSourceModule`s,
    which required separate single-file modification trackers for script
    and not-under-content-root modules.
- `MessageBus` is a general utility provided by IntelliJ, but usually it
  is retrieved from `project`. To keep these two concerns decoupled,
  `project.messageBus` should not be used directly. Instead, the commit
  adds a `KotlinMessageBusProvider`, which for now just provides the
  project message bus with its standard implementation, but allows
  swapping out the message bus implementation later.
- Global changes are also supported by the new subscription API. Such
  global changes may for example occur during cache invalidation in
  tests, on global PSI tree changes, or when an SDK is removed.
- Test-only invalidation has been moved from
  `KotlinModificationTrackerFactory` to a new
  `KotlinGlobalModificationService`. This creates one central service
  for invalidation between tests, which is easier from an implementation
  and a usage perspective than calling multiple scattered services and
  providers.
2023-07-31 15:58:00 +00:00
Pavel Kirpichenkov b316aa7d1d [AA] stub-based library symbol providers for non-JVM platforms
Use existing stub-based JVM library symbol provider for .knm and
.kotlin_metadata files. The only real difference is the scope filtering
by file types

KT-58769
2023-07-25 09:15:29 +00:00
Jinseong Jeon 6fc02c3408 SLC: ROOT package exists no matter what
^KT-59843 Fixed
2023-07-11 11:47:23 +02:00
Egor Kulikov 27f4b53570 [FIR] Do not expect builtin imports to be always resolved
Merge-request: KT-MR-10886
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-07-05 14:02:50 +00:00
Anna Kozlova f96b5bae48 [LL] anchor module provider for navigation in monorepo
Use information from IDE about anchor module,
to include everything from that module and dependencies into library session
^ KTIJ-24683
2023-07-03 17:10:51 +00:00
Anna Kozlova 86bed92a46 [AA] ensure psi files from stdlib do not leak 2023-06-07 21:00:26 +00:00
Marco Pennekamp 915c412929 [AA] KT-58580 Add KotlinDeclarationProviderMerger
- A proper merging strategy for declaration providers is required for
  cases where the main declaration provider created by
  `createDeclarationProvider` can't provide all declarations that the
  original declaration providers can provide. Then, only a sublist of
  the declaration providers should be merged, while keeping the
  unmergeable declaration providers intact.

^KT-58580 fixed
2023-05-31 18:34:42 +00:00
Marco Pennekamp fba0648005 [AA] Move impl declaration providers to subpackage 2023-05-31 18:34:42 +00:00
Marco Pennekamp 52f025f39b [AA] Extract SublistMerger to analysis-api-providers utils
- This utility is useful for other places where sublists need to be
  merged.
2023-05-31 18:34:42 +00:00
Ilya Kirillov c646008438 [Analysis API] refactoring, extract forEachNonKotlinPsiElementFinder to a separate file 2023-05-19 11:53:16 +00:00
Yan Zhulanow bb37a959d4 [LL API] Move composite declaration provider to be used in IntelliJ 2023-05-16 08:42:57 +00:00
Yan Zhulanow d3cb41cbab [LL API] Pass contextual modules to 'KotlinDeclarationProvider' factory
^KT-57559 Fixed
2023-05-16 08:42:57 +00:00
Yan Zhulanow 5e04c0d4f7 [LL API] Move 'FileBasedKotlinDeclarationProvider' to be used in IDE 2023-05-16 08:42:57 +00:00
Anna Kozlova 5ca052f87b [LL] [cls] use stubBased symbol provider for builtins
this gives the following benefits:
1. no protobuf in memory, all data is already present in stubs
2. given that symbol provider for libraries is already stub based,
we can get rid of complicated code to find source psi by deserialized fir
3. it's also possible to reduce number of index access,
when fir is requested for given ktElement
2023-05-09 07:36:09 +00:00
Yahor Berdnikau d57623891d Fix explicit api issues in analysis modules
Explicit api mode was not working due to the bug.

^KT-57653
2023-05-08 19:43:43 +00:00
Anna Kozlova d59d66e876 [AA, LL] use stubs to build deserialized Fir elements in IDE
^KTIJ-24638

Notice on `DebugSymbolRenderer`:
stub based deserializer sets source directly,
but it's available in IDE mode only.
Thus, standalone and IDE tests have different results.
In order to avoid this, sources for compiled code are explicitly ignored

Notice on distinct callables:
for a file which belong to multiple libraries, decompiled code would be build per library.
In order to avoid ambiguity errors for members in that file,
we need to distinct provided elements by origins
failed test from IJ repo:
 FirReferenceResolveWithCrossLibTestGenerated#testSetWithTypeParameters
2023-04-27 11:37:28 +00:00
Jinseong Jeon 5298abf2d6 AA/LC: introduce an API to find script files 2023-04-25 14:49:03 +02:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Marco Pennekamp d266f49c7c [LL FIR] KTIJ-25096 Add option to exclude binaries when incrementing modification trackers
- In performance tests, modification trackers were incorrectly
  incremented between tests for binary modules even with library caches
  enabled. The new option `includeBinaryTrackers` can be used by
  performance tests to exclude binary modules.
2023-03-31 15:40:14 +00:00
Ilya Kirillov 4944b454c5 [Analysis API] optimize KotlinPackageProvider.getSubPackageFqNames
Previously, we queried heavy kotlin package provider two times which affected performance
Now it's being queries only a single time

Also, the commit introduces separation for KotlinPackageProvider between kotlin and platform-specific packages

^KTIJ-24640
2023-02-28 13:38:23 +00:00
Ilya Kirillov 769fb835f9 [Analysis API] introduce a KotlinResolutionScopeProvider to optimize the resolutions scope in the IDE 2023-02-13 11:35:24 +01:00
Dmitrii Gridin f9d5534689 [SLC] SymbolKotlinAsJavaSupport: implement getKotlinInternalClasses
^KTIJ-24067
2023-02-01 12:51:31 +00:00
Jinseong Jeon 2da4693cc0 AA: do not use full decompilation for built-ins
This is the major performance bottleneck for AA/UAST artifacts rollout
to Android Lint. KT stubs are good/fast enough.
2023-01-17 16:51:34 +01:00
Jinseong Jeon 669afdd463 AA: place KotlinStaticDeclarationIndex in its own file with less visibility 2023-01-17 16:51:34 +01:00
Ilya Kirillov ae76ce666f [Low Level FIR] optimize getting callables in LLFirProviderHelper 2022-09-30 12:19:35 +02:00
Jinseong Jeon c2daa26118 AA: use fully decompiled file when indexing built-ins 2022-09-17 16:43:10 +02:00
Jinseong Jeon df95602e06 AA: populate index for built-ins 2022-09-17 16:43:10 +02:00
Jinseong Jeon 2580a5c233 AA: migrate PackagePartProviderFactory to general API providers 2022-09-15 20:06:40 +02:00
Dmitry Gridin 924dd38144 [lc] introduce KotlinAsJavaSupportBase with new common facade logic
^KT-53543
2022-08-29 11:51:42 +00:00
Jinseong Jeon b173b1fe24 AA: use package part info (if available) when searching for PSI from binary module 2022-08-10 17:34:48 +02:00
Ilya Kirillov 8be019d9bf [Analysis API] simplify KotlinDeclarationProvider interface 2022-07-26 23:41:11 +02:00
Ilya Kirillov 91cf194a94 [LL FIR] incrementally update module caches 2022-07-24 15:37:44 +02:00
Jinseong Jeon 3f05ba04a9 AA: add JDK_HOME as dependent SDK module 2022-05-09 00:22:52 +02:00
Ilya Kirillov 9a562a0293 [analysis api] optimize search for declarations in IDE 2022-04-19 12:37:49 +02:00
Jinseong Jeon 6797ac7cf2 AA: populate index in factory, not provider 2022-04-13 16:03:52 +02:00
Jinseong Jeon 5b631bff4d AA: populate index for declarations upfront 2022-04-13 16:03:51 +02:00
Jinseong Jeon cbef3faae7 AA: expose library modules in the project structure 2022-03-22 15:44:46 +01:00
Roman Golyshev 1a77643ad0 FIR IDE: Add static implementation of KotlinAnnotationsResolver 2022-02-25 23:08:26 +03:00
Roman Golyshev 76707afc90 FIR: Add KotlinAnnotationsResolver service 2022-02-25 23:08:25 +03:00
Jinseong Jeon 6afd665c8d AA: rename the file according to the static factory in it 2022-02-09 23:11:42 +01:00