Commit Graph

57795 Commits

Author SHA1 Message Date
Sergey Igushkin f2d2fb9e6b Fix Kapt-generated sources not compiled by jvm.withJava(), KT-32804
Given that the Kapt subplugin creates new tasks, it is impossible
to run it in the context of lazy task configuration. Disable lazy
task configuration for Kotlin/JVM by always accessing the task
instance until subplugins are refactored to be able to properly
work with task configuration avoidance.
2019-09-25 15:46:05 +03:00
Sergey Igushkin 0456220f7a Fix issues found in KOTLIN-CR-3233 2019-09-25 15:46:05 +03:00
Sergey Igushkin f0ef5a90b3 Add an integration test for the test runs API
Issue #KT-32679
2019-09-25 15:46:05 +03:00
Sergey Igushkin d1016f0221 Reimplement friend task/friend paths using associated compilations
Replace the old ad-hoc task matching mechanism used for connecting the
compilation tasks that need to share internal visibility with an
implementation based on the associate compilations and compilation
outputs rather than `destinationDir`s of the tasks.

The only place that still requires ad-hoc friend paths is the Android
instrumented tests compiling against the JAR of the main variant, not
its classes dirs. Support that with `friendArtifacts`.

Issue #KT-17630 Fixed
Issue #KT-20760 Fixed
2019-09-25 15:46:05 +03:00
Sergey Igushkin c4d9c4cee4 Group associated compilations into modules with a single module name
As associated compilations will see internals of each other, they now
need to share the module name for the compiler to be able to correctly
generate calls to the internals.

Move `moduleName` to `KotlinCompilation`.

Group associate compilations into modules in a DSU-like way, use a
single module name for all of the compilations grouped into a module.
2019-09-25 15:46:04 +03:00
Sergey Igushkin 94fd5c2884 Implement source sets visibility inference via associate compilations
Add non-public API for the IDE to query additional visible source sets
for each source set.
Implement visibility inference via associate compilation links.
Implement visibility requirements for source sets and requirements
satisfaction checks in Gradle build.
2019-09-25 15:46:04 +03:00
Sergey Igushkin 8c1c687e92 Implement associate compilations, KT-34009
Partial implementation of the associate compilations proposal. A
compilation can now contain links to other compilation that it compiles
against. This links will replace ad-hoc inter-compilation dependencies.

Issue #KT-34009 Fixed
2019-09-25 15:46:04 +03:00
Sergey Igushkin bb6f406be4 Partial cleanup & refactoring of the Android plugin
The `KotlinAndroidPlugin` used to support two different sets of APIs of
the Android Gradle plugin and used `AbstractAndroidProjectHandler` to
wrap those APIs. Now that there's only one implementation, it
doesn't need the generic `V` (variant data), and some cleanup is needed.
2019-09-25 15:46:03 +03:00
Sergey Igushkin 0e59553d12 Add Kotlin & Java destination dirs as output of Android compilation
The compilation outputs of Android compilations accidentally were left
empty. The `destinationDir`s of the Kotlin & Java tasks should be
registered in the `output.classesDirs`.
2019-09-25 15:46:03 +03:00
Sergey Igushkin 9836a1ca4a Make compilationsBySourceSets safe to use during evaluation
This function used to only calculate the mapping once and store it for
the project, so it was unsafe to use early. Fix that by evaluating the
value each time and then freezing it at the point of either task graph
being ready, or any task being executed.

Also, store the map in the project's `ext` rather than in a static weak
hash map, which is safer wrt memory leaks.
2019-09-25 15:46:03 +03:00
Sergey Igushkin 5dd4e0ed42 Track the compilation outputs as inputs of Gradle JS test tasks, KT-33313
Issue #KT-33313 Fixed
2019-09-25 15:46:02 +03:00
Sergey Igushkin 3011a3cf81 Create objects via Gradle ObjectFactory to allow access from Groovy 2019-09-25 15:46:02 +03:00
Sergey Igushkin fe50029beb Adjust task output detection for Gradle 4.9 2019-09-25 15:46:02 +03:00
Sergey Igushkin 43c3122a13 Drop Gradle versions older than 4.9
* Replace `TaskHolder` with `TaskProvider`, remove `TaskHolder`
* Migrate Gradle integration tests to Gradle 4.9+
2019-09-25 15:46:01 +03:00
Sergey Igushkin 9f0c5675bd Introduce execution & test run API, KT-32679
* KotlinExecution
* KotlinExecutionSource
* KotlinTestRun
* Aggregating executions and execution sources
* KotlinTargetWithTests

* Add a `testableTargets` extension
* Make some Kotlin/Native targets testable (this requires
  having a separate preset type for them)
* Implement test runs encapsulating the tests for all
  existing testable targets by refactoring their
  TargetConfigurator classes

Issue #KT-32679 Fixed
2019-09-25 15:46:01 +03:00
Pavel Kirpichenkov 6c8e829f19 Update diagnostics for trailing lambdas, add quickfix
Alternative message for errors, caused by unexpected lambda expression arguments on a new line.
Both diagnostic are reported, if multiple lambda expressions were passed to the call.
For other errors trailing lambda diagnostic overrides the original one.

Quickfix for erroneous trailing lambdas on a new line after call.
Fix separates lambda expression from previous call with semicolon.
All trailing lambda arguments become standalone lambda expressions.
2019-09-25 15:38:17 +03:00
Nikolay Krasko f00d609459 Fix KotlinConfidenceTest tests 2019-09-25 14:06:36 +03:00
Ivan Gavrilovic f89885224e Add tests for running incremental KAPT on JDK9
Add test for aggregating incremental annotation processors and JDK9.
This makes sure the implementation is not using any types that have
been removed in JDK 9.
2019-09-25 19:21:10 +09:00
Ivan Gavrilovic 4da6675640 Do not depend on BaseFileObject type for incremental KAPT
This class does not exist in JDK9, so running incremental KAPT on
JDK9 fails. Because it is used only to get the name of the file,
this has been replaced with usage of the public JavaFileObject API.
2019-09-25 19:21:10 +09:00
Ivan Gavrilovic aaa00b0f6f KT-33889: Do not use private non-API methods from JavacProcessingEnvironment
Avoid using JavacProcessingEnvironment.validImportStringToPattern method
because it has been removed in JDK9. This commit changes how we compute
pattern to match the class names, and it create instances of Pattern
manually by following spec for Processor.getSupportedAnnotationTypes().
Support for module prefix is not added yet.
2019-09-25 19:21:10 +09:00
LepilkinaElena 594f4a6f56 New flag for KotlinNativeCompilation to enable endorsed libraries (#2618) 2019-09-25 10:28:09 +03:00
Alex Chmyr b8cce67d2e KT-19355 fix for "Variable expected" error after J2K for increment/decrement of an object field 2019-09-25 10:08:42 +03:00
Toshiaki Kameyama 748e458ad7 "Override members": add semicolon between enum entry and function
#KT-31139 Fixed
2019-09-25 12:34:49 +07:00
Toshiaki Kameyama 7fcca71b4b Replace with dot call quickfix: don't break formatting
#KT-25697 Fixed
2019-09-25 12:06:51 +07:00
Toshiaki Kameyama 7b56733bda Reforma ReplaceCallFix 2019-09-25 12:06:51 +07:00
Mikhail Zarechenskiy 78affdd2b4 Fix old testdata: add missing operator modifier
This testdata was written when there was no "operator" modifier.

 After a83225218f rules for operators become stricter and now functions without operators are not considered as such
2019-09-25 01:52:55 +03:00
Vladimir Dolzhenko a98c610958 Fix KotlinCodeStyleSettings and IDEKotlinBinaryClassCache.kt 191 compilation 2019-09-24 22:01:05 +02:00
Vladimir Dolzhenko c961de7289 Fix kotlinRefactoringUtil.kt.193 compilation 2019-09-24 21:03:35 +02:00
Mads Ager b00858a886 Start local var scope for destructuring variables after init.
If the scope for a local variable is started before a value
has been written, another value from a previous use of the local
slot can be present. That value could have a different type which
would lead to weird debugging situations and also leads to other
tools (such as D8) rejecting the locals information as it is
invalid.

Fixes KT-33959.
2019-09-24 18:32:19 +03:00
Vyacheslav Gerasimov d54bc3a4bb 193: Fix tests compilation for 193 platform 2019-09-24 18:22:35 +03:00
Vladimir Dolzhenko a8c72b7e84 Do not resolve services in static initializers in IDEKotlinBinaryClassCache, KT-33973 2019-09-24 16:47:49 +02:00
Vladimir Dolzhenko 6f739db3b1 Fixed KotlinCodeInsightWorkspaceSettings plugin service description for 193 2019-09-24 16:42:58 +02:00
Ilya Kirillov cb569f8493 Do not use resolving to understand which method we use in "replace get or set inspection" 2019-09-24 17:21:49 +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
Ilya Kirillov 74ba5b210a New J2K: do not analyze code for post-processings in edt thread 2019-09-24 17:21:48 +03:00
Ilya Kirillov e6f2e0041c New J2K: get rid of generalInspectionPostProcessing 2019-09-24 17:21:47 +03:00
Ilya Kirillov a4cf7a912b Split some non applicability based inspections into isApplicable and apply
This is needed to fit new nj2k post-processing structure
2019-09-24 17:21:47 +03:00
Ilya Kirillov 3724e2bb02 New J2K: convert all custom post-processing to applicability based ones 2019-09-24 17:21:46 +03:00
Ilya Kirillov 509fcb17c7 New J2K: consider empty/singleton children list when comparing trees in default arguments conversion 2019-09-24 17:13:13 +03:00
Ilya Kirillov 704b3bd2e6 New J2K: always print real fqNames for static calls
As fqNames of some symbols may change during conversion
E.g, when moving Java static method to Kotlin companion object

#KT-19607 fixed
#KT-32903 fixed
#KT-33743 fixed
#KT-33556 fixed
2019-09-24 17:13:12 +03:00
Ilya Kirillov f9fac0acf5 New J2K: do not save import statements in files as we print fqNames for calls
This may cause conflicts on shortening fq references post-processing step
2019-09-24 17:13:11 +03:00
Dmitry Savvinov e3b7b41544 Minor: rename globalFacade -> facadeForModules 2019-09-24 17:05:05 +03:00
Dmitry Savvinov 937d041bc3 Minor: rename file ResolverForProjectImpl.kt -> AbstractResolverForProject 2019-09-24 17:05:05 +03:00
Dmitry Savvinov bef33e971f Make ResolverForProject own BuiltInsCache
Previously, BuiltInsCache was a separate abstraction with its own
lifecycle. In particular, it had a CachedValue inside, which uses
SoftReference to hold the computed data. This is bad, because this might
lead to disalignment of lifetimes with respective ResolverForProject,
leading to potential exceptions in analysis, see KT-33504 for details.

This commit fixes it by making root ResolverForProject own BuiltInsCache
and removing any logic about invalidation from BuiltInsCache. So, now,
BuiltInsCache is disposed iff corresponding ResolverForProject is
disposed

^KT-33504 Fixed
2019-09-24 17:05:05 +03:00
Dmitry Savvinov bfacc1a3c5 Introduce AbstractResolverForProject
Previously, ResolverForProjectImpl had multiple callbacks in
constructor. Some of those callbacks were used only to overcome module
visibility and provide an ability to inject IDE-specific logic into
compiler (ResolverForProject is in the 'compiler'-module)

This commit introduces abstract class which implements
environment-independent logic (previously, this logic had been stored in
ResolverForProjectImpl) with several abstract met hods (previously,
callbacks). Then, we provide few concrete implementations of
AbstractResolverForProject with clear semantics:

- IdeaResolverForProject: resolver used in IDE, where we have indices,
  oracles, multiple modules, etc.
- ResolverForSingleModuleProject: resolver for project with only one
  module, commonly used for CLI compiler/tests
- one anonymous implementation for MultimoduleTests

This refactoring achieves several things:
- now it is easier to see what kinds of ResolverForProject you might see
  in some particular environment (previously, one had to inspect all
  call-sites of constructor)
- we can easily add IDE-specific logic in IdeaResolverForProject without
  adding noisy callbacks (which most probably wouldn't have any other
  non-trivial implementations)
2019-09-24 17:05:05 +03:00
Dmitry Savvinov 48719c4050 Minor: extract ResolverForProjectImpl into separate file 2019-09-24 17:05:05 +03:00
Dmitry Savvinov 1e288c03c3 Minor: fix typos in KDoc 2019-09-24 17:05:04 +03:00
Dmitry Savvinov 4f700f5df3 Minor: drop unused parameter from createFacadeForScriptDependencies 2019-09-24 17:05:04 +03:00
Andrey Uskov 8ff4a92562 Fix serialization of data nodes tree
#KT-33987 Fixed
2019-09-24 16:27:13 +03:00
Ilya Kirillov 41f7519244 Fix old j2k test data to actual one 2019-09-24 16:22:24 +03:00