Commit Graph

1134 Commits

Author SHA1 Message Date
Sergey Rostov 698d675efe Scripting: fix saving to file attributes 2019-11-11 15:15:17 +03:00
Sergey Rostov 05e8acffa7 Scripting: restore reports for applied configuration in case of previous error 2019-11-11 15:15:17 +03:00
Sergey Rostov 96b4ceb067 scripting: skip loading when reverting to applied configuration 2019-11-11 15:15:17 +03:00
Sergey Rostov 2499c42ac4 scripting: PsiModificationStamp add virtual file modification stamp 2019-11-11 15:15:17 +03:00
Sergey Rostov 789ad23e8d Minor: isScriptDependenciesUpdaterDisabled -> isScriptChangesNotifierDisabled 2019-11-11 15:15:17 +03:00
Sergey Rostov 61b17de625 Minor: change ScriptConfigurationCache.kt declarations order for better readability, more docs 2019-11-11 15:15:16 +03:00
Sergey Rostov fbb2b260dd Split script configuration state into applied and loaded to make markUpToDate more clear 2019-11-11 15:15:16 +03:00
Natalia Selezneva fde1d3fdf7 Wrap exceptions from external script configuration loader with error handling 2019-11-11 15:15:16 +03:00
Sergey Rostov e2928550ca Fix retrieving virtual file 2019-11-11 15:15:16 +03:00
Sergey Rostov 9105e38041 Mark not applied configuration as up-to-date, simplify concurrency handling 2019-11-11 15:15:16 +03:00
Sergey Rostov 0422abdb7b LoadedScriptConfiguration and CachedConfigurationSnapshot are merged to ScriptConfigurationSnapshot 2019-11-11 15:15:15 +03:00
Sergey Rostov a89ce4c590 BackgroundExecutor: cancel all tasks on user cancel, remove useless updateProgress call 2019-11-11 15:15:15 +03:00
Sergey Rostov 19d35d7f27 Implement Gradle specific behavior for script configuration update logic
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 failures 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
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
Natalia Selezneva 915c9c367c Minor: rename script related classes 2019-11-11 15:15:15 +03:00
Natalia Selezneva 33475f30bc Minor: move files 2019-11-11 15:15:15 +03:00
Vadim Brilyantov ba77e5eba8 #KT-29622: Fix bunches for 191 and earlier idea versions 2019-11-09 16:44:12 +03:00
Vadim Brilyantov 66eeeb4705 Add Focus Mode support to kotlin language 2019-11-09 16:44:10 +03:00
Roman Golyshev da4097f488 KT-29926: Support completion of suspend lambda parameters in the body
- `suspendLambdaSignature` directory is just a copy of `lambdaSignature`
2019-11-08 19:24:05 +03:00
Leonid Startsev 7fada51c42 Add quickfix for setting explicit public visibility for diagnostic reported in API mode 2019-11-06 19:53:59 +03:00
Alexander Podkhalyuzin d2ae39489f SmartPointers in Smart Completion for anonymous object generation
#KT-32615 Fixed
2019-11-05 17:51:34 +03:00
Anton Yalyshev e146d308db Add statistics collector 2019-10-29 16:40:53 +03:00
Yan Zhulanow 39662c09e9 Debugger: Fix breakpoints and stepping on a first line (KT-33304)
This commit fixes the 'SmartStepIntoTestGenerated#testFunWithExpressionBody' test.
2019-10-24 21:32:59 +09:00
Dmitry Gridin 474645f04f idea-core: fix compatibility of insertMembersAfter function 2019-10-23 20:10:34 +07:00
Vladimir Dolzhenko 30229da95a Don't render pure error types in OverrideMemberChooserObject
#KT-34379 Fixed
2019-10-21 17:18:23 +02:00
Vladimir Dolzhenko 15997bf635 Save change script configuration within a transaction
#EA-214281 Fixed
2019-10-21 17:18:22 +02:00
Igor Yakovlev 6ce37fff95 Add UL support for AllOpen compiler plugin 2019-10-18 23:22:47 +03:00
Dmitry Gridin 92bfb2788e idea: cleanup "Remove redundant qualifier name" 2019-10-17 14:30:25 +07:00
Dmitry Gridin 8161403e69 ShortenReferences: shouldn't analyze root prefix elements & should get rid of them at end
Relates to #KT-33937
2019-10-16 15:59:47 +07:00
Anton Yalyshev 1e921647fe Bump FUS Collectors versions after last changes for proper data fetching 2019-10-15 16:15:10 +03:00
Dmitry Gridin 2eb035aff2 generateUtil: fix PIEAE
#EA-142347 Fixed
2019-10-14 21:45:11 +07:00
Dmitry Gridin 585222b4bb ScriptDefinitionsManager: shouldn't catch ControlFlowException
#EA-209928 Fixed
2019-10-14 21:45:10 +07:00
Alexey Kudravtsev 9c1e59c720 Use ReentrantLock instead of ReadWriteLock as a more cheaper alternative more suitable to usage pattern 2019-10-08 18:20:05 +03:00
Nikolay Krasko 343502125b Rename ResolveInWriteActionManager -> ResolveInDispatchThreadManager 2019-10-02 15:58:44 +03:00
Sergey Rostov 4c579f5286 build.gradle.kts: collect statistics about auto reload, fix 183 as as34 2019-09-30 14:08:43 +03:00
Sergey Rostov 46f8feaf98 build.gradle.kts: collect statistics about auto reload 2019-09-30 09:44:52 +03:00
Anton Yalyshev 6fa7da57a4 It's better to get plugin version once but not in cycle 2019-09-27 20:06:53 +03:00
Anton Yalyshev db189fa218 Remove Maven and JPS targets collectors that are unused now 2019-09-27 20:06:53 +03:00
Anton Yalyshev d4266e1be6 Bunches for ProjectConfigurationCollector 2019-09-27 20:06:53 +03:00
Anton Yalyshev 21b7d873e7 Move build system and targets statistics collection from StartupActivity to FUS State Collector 2019-09-27 20:06:53 +03:00
Alexander Podkhalyuzin 9a2da67919 ShortenReferences: cleanup code & add tests for property-function conflicts 2019-09-27 17:52:11 +07:00
Natalia Selezneva 917a7f572d Check that project is open before starting highlighting
This may be false when user opens Kotlin Scripting Settings, so default project is passed to ScriptDefinitionsManager
^KT-30206 Fixed
2019-09-27 12:59:43 +03:00
Ilya Kirillov 4e27d2e658 New J2K: do not use global write action for some post-processings which may use resolving while applying
Also, modify that post-processings & inspections to explicitly use write action
when modifying PSI elements

#KT-33875 fixed
2019-09-24 17:21:49 +03:00
Vladimir Dolzhenko 8b0aeb9a55 Do not resolve services in non-default ctors 2019-09-24 15:15:37 +02:00
Vladimir Dolzhenko 027c60080b Added KotlinCodeInsightWorkspaceSettings in place of sharing kotlin settings with java CodeInsightSettings 2019-09-23 16:05:11 +02:00
Natalia Selezneva eca7bbdb8c Scripts: Check if file is in all script dependencies class files scope instead of searching for module info
^KT-32799 Fixed
^KT-16760 Add test
2019-09-23 12:06:25 +03:00
Natalia Selezneva a62863128c Fix exception from ProjectResolutionFacade when switching some definition off in settings
Fix AbstractScriptDefinitionsOrderTest
Remove updating script dependencies in test because in affects cache behavior: script will be already up to date when highlighting is called for the second time
2019-09-20 10:35:52 +03:00
Natalia Selezneva 5872a47c0e Scripts: rehighlighting should be called for opened scripts after changing script definitions
In case when script dependencies were absent for script, highlighting was called only when the script changed
2019-09-20 10:35:52 +03:00
Anton Yalyshev dfde3b4076 Rename collector of debugger events 2019-09-18 10:06:45 +03:00
Anton Yalyshev 61eb9faecd Move status of evaluation from eventId to context for better data analytics 2019-09-18 10:06:45 +03:00