Commit Graph

3063 Commits

Author SHA1 Message Date
Mikhail Glukhikh 9e263b6af2 FIR IDE: use registry to obtain kotlin.use.fir.resolution 2019-12-11 13:01:38 +03:00
Mikhail Glukhikh fa89aa0b49 Do not use member scope provider from FIR resolution API
In this commit we build self importing scope from scratch.
Using member scope provider is probably incorrect because of possible changes.
At any invalidation we should rebuild it.
2019-12-10 12:58:39 +03:00
Mikhail Glukhikh 718a679b72 FIR IDE API: add preliminary control of file in-block modifications
In this commit, we build FirFile from the beginning if in-block modifications are detected.
However, better way would be to rebuild only part of FirFile in this case
2019-12-10 12:58:39 +03:00
Mikhail Glukhikh 83ccd7dd1c FIR: implement separate diagnostic collector/reporter for IDE 2019-12-10 12:58:38 +03:00
Mikhail Glukhikh cd089658bd IdeFirProvider: insert protection against ProcessCanceledException 2019-12-10 12:57:56 +03:00
Mikhail Glukhikh 4b251eb986 FIR IDE: lock FIR files before calling runResolve on them
This also fixes various synchronization problems
2019-12-10 12:57:13 +03:00
Mikhail Glukhikh 63121df6ba Synchronized IdeFirProvider.getOrBuild file, don't share RawFirBuilder
Before this commit RawFirBuilder was reused,
that provoked a lot of synchronization problems
2019-12-10 12:57:13 +03:00
Mikhail Glukhikh ccb343e26b FIR: preliminary implementation of diagnostics highlighter (~30% supported) 2019-12-10 12:57:13 +03:00
Mikhail Glukhikh 34202faaa5 Code cleanup: KotlinPsiChecker 2019-12-10 12:57:12 +03:00
Mikhail Glukhikh 900227fdfa KtReferenceResolver: implement resolveToPsiElements() via FE IR (~60% supported) 2019-12-10 12:57:11 +03:00
Mikhail Glukhikh 809b7d8381 FirResolution: store enabled value in field with initial reading from component
Before this commit, we read/wrote 'enabled' directly from PropertiesComponent.
Now we do only initial reading and then store modified value in field.
This should make 'enabled' reading faster.
2019-12-10 12:57:11 +03:00
Mikhail Glukhikh 0d2d76696c Add FirResolution.enabled wrapper 2019-12-10 12:57:10 +03:00
Mikhail Glukhikh bef344b33e Optimization / clarifying: getFirClassifierContainerFile 2019-12-05 18:02:04 +03:00
Mikhail Glukhikh c1789a0ecc FIR IDE: synchronous creation/registration of sessions 2019-12-05 18:02:04 +03:00
Mikhail Glukhikh 1539ee30ff FIR IDE: fix local class containing file search 2019-12-05 18:02:03 +03:00
Mikhail Glukhikh d35a26a75b Optimization: introduce FirIdeResolveStateService to cache FirResolveState 2019-12-05 18:02:02 +03:00
Mikhail Glukhikh 8808c775a4 Introduce FirResolvedTypeRef.delegatedTypeRef to see children types in IDE
This is needed to have access to resolved children types (e.g. type arguments) from IDE
2019-12-05 18:02:02 +03:00
Nikolay Krasko 0cbb3a3956 Remove unused ProjectRootModificationTrackerFixer.kt 2019-12-02 13:29:37 +03:00
Vladimir Dolzhenko f8a6217fb5 Fix compilation for 183 after adding support incremental analysis of comment and kdoc
Relates to #KT-35189
2019-11-30 18:50:44 +01:00
Vladimir Dolzhenko 95129939d4 Add secondary ctors to incremental analysis
#KT-35121 Fixed
2019-11-29 15:45:09 +01:00
Vladimir Dolzhenko f709377735 Support incremental analysis of comment and kdoc
#KT-35189 Fixed
2019-11-29 15:44:58 +01:00
Dmitry Gridin 70185ba2a6 Formatter, NJ2K: fix indent for comments inside function literals
#KT-4194 Fixed
#KT-31881 Fixed
#KT-34673 Fixed
#KT-35152 Fixed
2019-11-29 16:28:59 +07:00
Nikolay Krasko c341a3e709 Avoid collecting events from other projects in PerModulePackageCacheService (KT-33802)
It looks like VFS_CHANGES subscription ignores project boundaries so all events are processed by every listener. If event has a hard reference to project in the requestor field, it might leak through the collection of pending events.

An attempt to fix holding test projects through pending events.

 #KT-33802 Fixed
2019-11-27 22:34:48 +03:00
Nikolay Krasko 7245bbd822 Explicitly disconnect in KotlinPackageContentModificationListener (KT-33802) 2019-11-27 22:34:48 +03:00
Vladimir Dolzhenko 1c4c5520a2 Fix incremental analysis in case of property does not have initializer but could be initialized on a class level
#KT-35028 Fixed
2019-11-27 13:43:30 +01:00
Igor Yakovlev 12f29bacab Exclude checking for unimplemented method for binary origin classes
Fixed #KT-34971
2019-11-26 21:13:10 +03:00
Yan Zhulanow f75288b480 EA-216333: check PsiElement validity before light class generation 2019-11-25 17:26:28 +09:00
Dmitriy Dolovov 58dd9a6004 Fix AWT freeze in KotlinNativeABICompatibilityChecker (part 2)
Issue #KT-35052
2019-11-25 09:07:09 +07:00
Dmitriy Dolovov 0747a4d9b7 Fix AWT freeze in KotlinNativeABICompatibilityChecker
Issue #KT-35052
2019-11-25 09:07:02 +07:00
Vladimir Dolzhenko e321c9e4e7 Fix diagnostics calculations for incremental analysis 2019-11-23 23:36:49 +01:00
Dmitry Savvinov 0dc7c37b62 Choose SDK consistently at least for non-COMPOSITE analysis
In COMPOSITE analysis we don't have a constant SDK dependency for whole
ResolutionFacade, so we have to find it manually via calling
'findSdkAcrossDependencies'

In SEPARATE mode we do have such a constant SDK dependency, but there
was an assumption that it doesn't make a difference (i.e.
findSdkAcrossDependencies always return the same SDK as passed constant
one)

Turns out that assumption was wrong, particularly for projects with
duplicate SDK entries in project structure. Then we would choose one SDK
in some cases, and the other one on other cases - even though they a
bit-to-bit equal, we will create separate descriptors for them, which
might lead to some issues, like in KT-34802

^KT-34802 Fixed
2019-11-21 18:56:49 +03:00
Mikhail Glukhikh 802ed9b502 FIR: implement protected visibility checker #KT-34788 Fixed 2019-11-19 13:07:52 +03:00
Vladimir Dolzhenko fa62d0c325 Don't clear InBlockModifications on CanceledException
#KT-34914 Fixed
2019-11-15 15:48:27 +01:00
Vladimir Ilmov ab3f9586b3 Suspend function calls highlighting added.
'If' highlighting fixed at settings sample area.

 #KT-27496 Fixed
2019-11-14 08:07:56 +03:00
Vladimir Ilmov 46423443e9 'it' parameter highlighting fixed for chain usage.
#KT-31037 Fixed
2019-11-14 08:07:56 +03:00
Igor Yakovlev 1ccda6a8d4 Add fast find usages for data class components
This commit add feature for disabling searching for data class ComponentN method and destruction declarations that could encrease usages search.
See KT-23278
2019-11-13 17:38:35 +03:00
Sergey Rostov 9d2cc484aa ide, scripting: rework script configuration caching, introduce persistent fs cache
## Simplify ScriptConfigurationManager mental model
Everything related to cache managing moved to `org.jetbrains.kotlin.idea.core.script.configuration`.
DefaultScriptConfigurationManager slitted into:
- `AbstractScriptConfigurationManager`
- `DefaultScriptConfigurationManager`
- `ScriptClassRootsCache`
The main idea is to simplify the mental model of ScriptConfigurationManager.
Concrete implementation should provide just two things:
- `createCache(): ScriptConfigurationCache` that should return cache implementation with `get` and `set` methods
- `reloadOutOfDateConfiguration(...)` will be called on [cache] miss or when [file] is changed.

Implementation should initiate loading of [file]'s script configuration and call [saveChangedConfiguration]
immediately or in some future (e.g. after user will click "apply context" or/and configuration will be
calculated by some background thread).
Everything around it is implemented in `AbstractScriptConfigurationManager`.

`ScriptClassRootsCache` is extracted from `DefaultScriptConfigurationManager`:
this simplifies `AbstractScriptConfigurationManager`
Also it simplifies ScriptClassRootsCache reset: we can just drop old `ScriptClassRootsCache`
and create new one instead of resetting all internals of `ScriptClassRootsCache`.
Please see KDoc of these classes for more details:
- AbstractScriptConfigurationManager
- DefaultScriptConfigurationManager
- ScriptClassRootsCache

## Cache and up-to-date checks
Writer should put related inputs snapshot for loaded configuration.
This allows reader make up-to-date check for existed entry to avoid starting loading
process for same inputs.
Cache entry may be marked out-of-date.
Also it can be marked up-to-date, but it means that we have up-to-date loaded configuration,
ScriptConfigurationSnapshot.configuration will still contain old applied configuration.
todo: make it more clear by splitting cache entry into loaded and applied configuration with
it's own inputs.

## Loaders
Previously both sync and background loaders may be started for same files - this was useful, but not
required anymore and at the same time greatly complicates the model. So, it was dropped
and now exactly one loader should work for given file (first applicable loader will be called).
Also `ScriptConfigurationLoadingContext` is introduced to limit access to the `ScriptConfigurationManager`
internals.

## Listeners and updating configuration
This things is introduces:
- `ScriptChangesNotifier`
- `ScriptChangeListener`
- `ScriptConfigurationUpdater`
`ScriptChangesNotifier` will call first applicable `ScriptChangeListener` when editor is activated or document changed.
(it treated as applicable if [editorActivated] or [documentChanged] will return true).
Listener may call [ScriptConfigurationUpdater] to invalidate configuration and schedule reloading.
Plugins may override default listening logic by adding it's oven `ScriptChangeListener`.
`ScriptConfigurationUpdater` was extracted from `ScriptConfigurationManagerImpl`.

## Fixed issues and implement persistent FS cache
- Script configuration was not reloaded if query for same file already in progress or ready but not yet applied
- Don't start async loaders for outsider files
- Unused imports: don't start loading script configuration if the result will be not applied automatically
- Fix cases when virtual file can be null

See `DefaultScriptConfigurationManager.reloadOutOfDateConfiguration` KDoc for more details on
dealing with concurrent operations.

## Background executor and progress indicator
This things changed and fixed:
- progress displayed not only when we have more then 3 loading tasks, but also
after 1sec of loading (including case with 1 loading task for example)
- current file is displayed under the progress bar
- progress indication added: it works similar to indexing indicator. When
progress bar is displayed, max is fixed. When all work done for this max,
progress will be started from zero and new max is fixed, and so on
- cancel will drop all loading operation, not just current
- concurrency issues fixed: EA-5244265 and other related to switching between silent and
under progress worker
See `BackgroundExecutor` for more details.

## Gradle specific behavior
We have plans to extract separate implementation for Gradle scripts, but it
would be better to support something at this point.
For now, we have custom listener, loader and up-to-date check for default configuration manager:
- listener will do forced reload on editor activation, even it is already up-to-date
this is required for Gradle scripts, since it's classpath may depend on other files (`.properties` for example)
- loader will force save fails before running loader. also it will skip loading if
`kotlin.gradle.scripts.useIdeaProjectImport` registry key is enabled
- loader will return inputs with overridden up-to-date checks: file will be considered
out-of-date only when `buildscript` or `plugins` blocks are changed
2019-11-11 15:15:15 +03:00
Vladimir Ilmov e2b91cfec7 Properties with custom property declarations highlighting rule.
Added support for package and class-level properties with custom PD.
Java syntethic extensions are ignored from this rule.

 #KT-30806 Fixed
2019-11-08 17:58:49 +03:00
Vladimir Ilmov 9fb95e776e [HIGHLIGHT] Specific keyword rules for val,var highlighting.
'Kotlin keyword' rule configured as fallback rule for all Kotlin keywords:
- Created 'var'/'val' rules with fallback to 'Kotlin keyword'
- BUILTIN_ANNOTATION rule fallback changed from Java to 'Kotlin keyword'

 #KT-13344 Fixed
2019-11-07 18:48:59 +03:00
Dmitriy Novozhilov c58ca27b2e [FIR] Introduce ResolutionMode as data for body resolve instead of Any? 2019-11-05 15:22:23 +03:00
Vladimir Dolzhenko 4b2834c4a8 Provide incremental analysis of a file when it is applicable
#KT32868 Fixed
2019-10-30 21:41:29 +01:00
Vladimir Dolzhenko 26255f8501 Added AllowNullableArrayArgsInMain (1.4+) language setting 2019-10-29 19:20:35 +01:00
Mikhail Glukhikh a13ae08b52 FIR: add classifiers to local scopes, process local class symbols correctly 2019-10-29 16:27:40 +03:00
Dmitry Savvinov 2c6fbb6ece Fix dependsOn module names
Use Gradle Project IDs instead of names, because for composite Gradle
builds module names are appended with some additional prefixes, which
causes mismatch
2019-10-29 14:27:38 +03:00
Dmitry Gridin 18aa9ffce8 expectActualUtil: introduce runCommandOnAllExpectAndActualDeclaration function 2019-10-29 17:26:34 +07:00
Dmitry Gridin 9aa49e61fe expectActualUtil: add parameter useOnSelf to runOnExpectAndAllActuals 2019-10-29 17:26:34 +07:00
Dmitry Gridin 9c61f42121 ChangeVisibilityModifierIntention: should affect all actual/expect declarations
#KT-29737 Fixed
2019-10-29 17:26:34 +07:00
Dmitriy Novozhilov 0d15ff1ddd [FIR] Introduce FirSourceElement instead of FirElement as source in fir nodes 2019-10-29 13:03:13 +03:00
Denis Zharkov 1564e72b59 FIR: Rename FirResolvedCallableReference -> FirResolvedNamedReference
^KT-32725 In Progress
2019-10-28 17:07:18 +03:00
Vladimir Dolzhenko 00055fc20a Wrap KtClassOrObject.isLocal, KtFile.isScript with runReadAction in LightClasses
#EA-211576 Fixed

(cherry picked from commit 75a59d4bced714af51abd7e354bc873313b28051)
2019-10-26 09:42:49 +02:00