Commit Graph

38528 Commits

Author SHA1 Message Date
Denis Zharkov d65af8f951 Introduce custom Java model implementation for class-files
It's only used for CLI compiler, and it should improve performance
of loading Java descriptors from class-files

For IntelliJ, it leads to 10-15% percent speedup of Kotlin Builder

Before this change, we were using a Java model based on Java PSI that
also read class files, but do it less effectively since it performs
some extra work, that we don't need, e.g. eagerly reading all
the inner classes
2017-04-21 12:56:29 +03:00
Denis Zharkov 88950521a8 Refactor KotlinCliJavaFileManager: make it return JavaClass
It seems to be very natural refactoring considering the
following changes: optimizing KotlinCliJavaFileManagerImpl.findClass
to make it read class files manually instead of requesting PSI
2017-04-21 12:48:31 +03:00
Denis Zharkov 506d7ab3d2 Replace JavaClass.innerClasses with innerClassNames
Also add a findInnerClass method that can find an inner class
by its name

This change helps to avoid loading all the inner class files
eagerly (that may be rather slow), while all the names are available
in InnerClass attribute
2017-04-21 12:48:31 +03:00
Denis Zharkov 5936424659 Replace JavaClassifierType.canonicalText with classifierQualifiedName
The reason is that canonicalText requires some additional
computations to be done when reading class files, while
in fact we only need a class name of the type
2017-04-21 12:48:31 +03:00
Denis Zharkov aba8b4e2ba Add cache for top-level classes' virtual files
The reason is that searching for a class in a VirtualFile-based
directory (i.e. in a package) happens for O(|amount-of-files-in-dir|),
and it may be rather crucial for packages with a huge amount
of classes

Note that it was checked that the cache should not take a lot of heap
since we call findClass only for really existing classes:
see org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageScope.kt:48

For example, there are no more than 10k classes for the whole
intelliJ project (but the cache is flushed for each module)
2017-04-21 12:48:31 +03:00
Denis Zharkov 06ffbb7b93 Minor. Avoid repeating calls to isRaw 2017-04-21 12:48:31 +03:00
Denis Zharkov aef1ca10f7 Add additional cache for packages' directories
It's important because even if we know the root where
the package is located we need to go through its parts,
and it's not as fast as it could be since implementation
of VirtualFile.findChild() traverse all files in the directory
to find the relevant one
2017-04-21 12:48:31 +03:00
Denis Zharkov e4cb5496b8 Optimize getSingleAbstractMethodOrNull
Searching for the single abstract method leads to computing
whole member scopes of given intrefaces, especially when
they contain a lot of methods (i.e. they're definitely not SAMs)

On the other side this method is very hot because it's called
for each Java interface used as a type for some value parameter
(for building SAM adapters)

The idea is to apply some heuristics to understand using only
JavaMethod and supertypes that this interface is definitely not a SAM
2017-04-21 12:48:31 +03:00
Alexander Udalov db3f70cfe9 Drop unneeded hack relating to matching header class to impl typealias
This is not needed anymore because we use a special TypeCheckerContext
which correctly matches header class to impl typealias.

Also fix 'platformModule' in areCompatibleClassifiers: it's not b's
module (b is already the expansion of a typealias), but the module of
"other", original 'impl' classifier
2017-04-20 22:33:26 +03:00
Alexander Udalov ea727ff3f0 Use header->impl mapping in HeaderImplDeclarationChecker.areCompatibleTypes
Construct a special TypeCheckingContext that is aware of the magic
behind the "impl typealias" that implements a "header class"

 #KT-16986 Fixed
2017-04-20 22:33:25 +03:00
Alexander Udalov 1ce4612f74 Refactor module usages in HeaderImplDeclarationChecker
Instead of a vague name "moduleToCheck", use explicit names
"commonModule" and "platformModule".
2017-04-20 22:13:32 +03:00
Alexander Udalov a2e050a3b9 Use correct function to find header for impl in IDE
Also do not call isHeader/isImpl because the returned declarations are
guaranteed to be isHeader in findCompatibleHeaderForImpl and isImpl in
findCompatibleImplForHeader
2017-04-20 22:13:32 +03:00
Alexander Udalov af4f96fb52 Refactor HeaderImplDeclarationChecker
Build the compatibility map when looking for header given an impl, in
the same way as it's done for the search of impl given a header. The map
is mostly unused now (only its value at key=Compatible is used), but
will be used in the future to improve the diagnostic messages here
2017-04-20 22:13:32 +03:00
Simon Ogorodnik 4978a204f0 Make LibraryDependenciesCache cache again!
#KT-17495 fixed
2017-04-20 20:23:11 +03:00
Mikhail Glukhikh 99653b9afc Refactoring: merge doTest in AbstractMultiModuleHighlightingTest 2017-04-20 19:13:20 +03:00
Mikhail Glukhikh 266d36f289 Refactoring: rename header to common in MultiModuleLineMarkerTest 2017-04-20 19:12:13 +03:00
Mikhail Glukhikh 3a1866b405 Refactoring: introduce doTest in MultiModuleLineMarkerTest 2017-04-20 19:12:11 +03:00
Christopher Horner 8df40eaa46 Add support for RxJava's nullability annotations. 2017-04-20 17:20:39 +03:00
Alexander Udalov aee5326ca7 CLI: refactor argument validation out of parsing 2017-04-20 16:20:54 +03:00
Alexander Udalov 8aba862e97 CLI: use "--" to separate free arguments from compiler options
#KT-9370 Fixed
2017-04-20 16:20:54 +03:00
Zalim Bashorov baef649fe4 KJS: change asserter to DefaultAsserter for JS Backend tests
It required for fix JsCodegenBoxTestGenerated.

Right now QUnitAsserter used as default asserter in kotlin-test
and we don't want to change it now to avoid breaking stdlib-js tests
and maybe user code.
2017-04-20 16:19:06 +03:00
Zalim Bashorov 2f4119a8ae KJS: remove obsolete code related to Unit testing 2017-04-20 16:19:06 +03:00
Zalim Bashorov 7cf684f624 KJS: remove unnecessary files from testData 2017-04-20 16:19:06 +03:00
Zalim Bashorov c112542935 KJS: remove unnecessary test runners (mostly for stdlib)
Stdlib tests run separately via gradle.
2017-04-20 16:19:05 +03:00
Zalim Bashorov 5ef75e6e2b KJS: remove PackageTest.java and move actual files to box/ 2017-04-20 16:19:04 +03:00
Vyacheslav Gerasimov dcae66a727 Add quickfix for INAPPLICABLE_JVM_FIELD
replaces with 'const' when possible

#KT-10981 Fixed
2017-04-20 12:10:20 +03:00
Vyacheslav Gerasimov 199bff7e70 Add quickfix for 'Illegal inline parameter modifier'
Adds inline to function if crossinline is used on parameter

#KT-14046 Fixed
2017-04-20 12:09:53 +03:00
Dmitry Jemerov 49a211b3cd Ensure that UElement.nameIdentifier.containingFile is a real file
This is needed to report inspection problems on UAST elements.
2017-04-20 11:02:56 +02:00
Dmitry Jemerov d001cea4c3 Fix tests: add ACTION tags for newly added actions 2017-04-20 11:02:40 +02:00
Dmitry Petrov a3985bbdd3 Substitute underlying constructor when substituting type alias constructor
KT-17426 Constructor call of typealiased class gets suspicious type arguemnts
2017-04-20 10:20:36 +03:00
Simon Ogorodnik 02fec6e4a5 Add fine check of type inference when adding <> in completion
Add check if type inferred via type parameter of upper bound
 of extension receiver or value argument
 #KT-16161 fixed
2017-04-19 21:27:31 +03:00
Zalim Bashorov c021af0fef KJS: fix non-local return inside catch block 2017-04-19 20:20:21 +03:00
Zalim Bashorov 29e7bcce65 Add explicitly the proguard rule to save JAXPParserFactory#createParser
And remove obsolete rules.
2017-04-19 20:18:21 +03:00
Zalim Bashorov d64140a11c Add jars to intellij_core explicitly
It prevents unintended using jars from core dir,
also, it allowis us gradually remove a dependency on some jars.
2017-04-19 20:18:20 +03:00
Zalim Bashorov 2c69198926 Make return type of KotlinScriptDefinitionProvider.getInstance nullable
For example service can be absent in Kotlin JS only compiler.
2017-04-19 20:18:20 +03:00
Anton Bannykh d5bcf18e5c JS: disable JVM specific part of internal visibility resolution 2017-04-19 18:53:27 +03:00
Ilya Gorbunov 2db8714fc5 Fix null values being treated as missing in 'put' method of a specialized string-keyed map 2017-04-19 18:32:47 +03:00
Mikhail Glukhikh 8fdb611e3b Do not try to inline properties from decompiled files
This removes GUI freeze for library properties #KT-17234 Fixed
2017-04-19 18:27:29 +03:00
Mikhail Glukhikh 983611a75f Fix in createBlockStringTemplateEntry (use createExpressionByPattern)
This fixes one more broken test for inlining
2017-04-19 18:27:28 +03:00
Mikhail Glukhikh 6571a573f1 Use correct callElement for variable invoke in replacer
Check only 'status.isSuccess' before inlining, no descriptor check
Add two tests and fixes two other
2017-04-19 18:27:27 +03:00
Mikhail Glukhikh 4ef0096d46 Refactoring: inline val / fun now use the common inliner
This prevents their inconsistent work in some situations
NB: breaks three tests if used alone
2017-04-19 18:27:26 +03:00
Mikhail Glukhikh e6fa7356e1 Inline: support compound case without containing block #KT-17296 Fixed 2017-04-19 18:27:25 +03:00
Mikhail Glukhikh ade838bff2 Inline fun: remove recursion inside includesCallOf
Probably #KT-17330 Fixed
2017-04-19 18:27:24 +03:00
Ilya Gorbunov a87da4338f arrayIterators: Restore index to the previous value after NoSuchElementException has been thrown
Relates to #KT-17453
2017-04-19 18:12:58 +03:00
Ilya Chernikov 731dcf5d6f minor: fix after faulty rebase 2017-04-19 15:22:15 +02:00
Ilya Chernikov c91a3f8bf0 Add sam-with-receiver and source-sections compiler plugins to maven
rename source-sections compiler plugin jar in the dist (add kotlin- prefix),
according to the agreed naming scheme for the artefacts. (The renaming of the
other plugins should follow.)
in addition configure proguard to retain VirtualFile members, since they
are used in the source-sections plugin
2017-04-19 15:22:15 +02:00
Ilya Chernikov ea71d57808 Use script-runtime properly in IDEA project:
use it from the installed plugin for dependent modules (frontend)
use it from bootstrap in the plugin being built
also drop unused daemon-client from the plugin

This makes it consistent with ant build and allow building idea project
without prior ant dist
2017-04-19 15:22:15 +02:00
Sergey Igushkin 2360d5f330 Changed to prepending annotation processor path instead of appending it
to classpath and existing annotation processors.
2017-04-19 16:06:55 +03:00
Mikhail Glukhikh 91f7f19902 ExpressionReplacementPerformer: handle string templates accurately 2017-04-19 13:12:59 +03:00
Mikhail Glukhikh 815a367978 ReplacementPerformer: always copy statement to insert #KT-17273 Fixed 2017-04-19 13:12:58 +03:00