Commit Graph

1465 Commits

Author SHA1 Message Date
Alexander Udalov a67382fdec Daemon: do not exit with internal error on invalid arguments
Invalid compiler arguments should lead to a compilation error, not
internal error. This has been fixed by splitting the
"parseArguments(...)" call (which does parsing + validation) in
CompileServiceImpl into two calls of parseCommandLineArguments +
validateArguments, and returning with a compilation error if the latter
did not succeed

 #KT-16057 Fixed
 #KT-14848 In Progress
2017-06-06 19:52:02 +03:00
Alexander Udalov 6a4c1b138f Remove dependency of module 'cli' on 'builtins-serializer'
This breaks the circular dependency between them
2017-06-06 14:29:27 +03:00
Alexander Udalov 7febd846e8 Export 'intellij-core' in module 'frontend'
Remove intellij-core from dependencies of modules which already depend
on frontend or any module that exports frontend (such as frontend.java)
2017-06-06 14:29:26 +03:00
Alexander Udalov 2ed027219c Remove dependency of module 'frontend' on 'plugin-api'
This breaks the circular dependency between them
2017-06-06 14:29:25 +03:00
Alexander Udalov cc2f607be3 Remove dependency of module 'frontend.java' on 'javac-wrapper'
This breaks the circular dependency between them
2017-06-06 14:29:24 +03:00
Alexander Udalov 1df13e0bc9 Move TopDownAnalyzerFacadeForJVM to module 'cli'
It's only used in the command line compiler and in tests
2017-06-06 14:29:23 +03:00
Alexander Udalov f6c263b54d Remove dependency of module 'javac-wrapper' on 'cli' and 'cli-common'
This breaks the circular dependency between them
2017-06-06 14:29:22 +03:00
Alexander Udalov a236400785 CLI: drop CommonCompilerArguments.createDefaultInstance
Move the corresponding default value initializers to the field
declarations
2017-06-06 14:17:26 +03:00
Alexander Udalov 26e3d2cf5d Use TopLevelDeclarations analysis mode in REPL
#KT-12564 Fixed
2017-06-06 14:00:45 +03:00
Alexey Andreev ee18c0f4e7 Fix name of JS DCE tool 2017-06-05 11:22:37 +03:00
Dmitry Jemerov 286f82a5c5 Don't set java.awt.headless if it was set externally 2017-05-31 16:02:26 +02:00
Alexey Tsvetkov 6e07b1cd99 Gradle: set default values of languageVersion and apiVersion to null
Before the change, Gradle always explicitly set language and api
version to the latest version, preventing the compiler
from inferencing the arguments.

     #KT-18047 fixed
2017-05-31 16:59:03 +03:00
Alexander Udalov 1572d2cf2b Improve modular JDK root module detection
According to the spec, "java.se" and every other non-"java.*" module
that exports at least one package without qualification, is a root.
Currently we only support compilation of a single unnamed module, and
apparently unnamed module should read all root modules.

 #KT-18180 Fixed
2017-05-30 17:35:25 +03:00
Alexander Udalov 5042bbe4a1 Minor refactoring in ContentRoots, JvmContentRoots and usages 2017-05-30 17:35:23 +03:00
Alexander Udalov 227c2d2c23 Minor, display multiline argument help prettier 2017-05-30 17:33:11 +03:00
Alexander Udalov a583a2f171 Move JavaModuleInfo and JavaModuleGraph to frontend.java 2017-05-26 19:38:49 +03:00
Alexey Andreev 522a56947c Add -keep command line option to JS DCE tool 2017-05-26 18:20:23 +03:00
Alexey Andreev 8a8fdf1968 Command-line tool for JS DCE 2017-05-26 18:20:17 +03:00
Alexey Andreev 9e89213d66 Prototyping DCE tool for JS 2017-05-26 18:20:15 +03:00
Alexey Tsvetkov 3de679fb23 Minor: add comment for CompilerMessageSeverity.OUTPUT 2017-05-26 15:16:41 +03:00
Mikhail Zarechenskiy 400ecd5e13 Support destructuring declarations in scripts and REPL
#KT-5620 In Progress
 #KT-15810 In Progress
2017-05-25 16:46:04 +03:00
Alexander Udalov 965b4199f4 Fix compilation against JRE 9 on JPS
Write the modular JDK (9+) path to the module.xml file passed to the
compiler from the JPS plugin. This path is then recorded in the compiler
configuration in KotlinToJVMBytecodeCompiler.configureSourceRoots. This
is needed because in JPS plugin, we pass "-no-jdk" and thus no JDK home
path was recorded in the compiler configuration in
K2JVMCompiler.setupJdkClasspathRoots. Presence of JDK home path in the
configuration is crucial for JDK 9 support (see
KotlinCoreEnvironment.Companion.createApplicationEnvironment), because
classes there can only be loaded with the special "jrt" file system, not
as .class files in .jar files

 #KT-17801 Fixed
2017-05-24 15:46:57 +03:00
Alexander Udalov 671aed252d Support single Java source files in kotlinc arguments
E.g. "kotlinc foo.kt test/Bar.java" will compile foo.kt, and
declarations from Bar.java will be accessible to Kotlin code in foo.kt.

The change in AbstractTopLevelMembersInvocationTest is needed because an
incorrect configuration was created in that test where a library jar was
also a Java source root (the compiler is never configured this way in
production), which led to an exception in
JavaCoreProjectEnvironment#addSourcesToClasspath

 #KT-17697 Fixed
2017-05-18 19:22:17 +03:00
Alexander Udalov 9b85fed3c4 Fix typo in kotlinc-js help
File separator is '/', path separator is ':' or ';'
2017-05-18 13:29:03 +03:00
baratynskiy 5eea3b6569 Introduce experimental -Xuse-javac compilation mode
In this mode, javac AST and Symbol files are used during
Kotlin compilation instead of PSI / binary stuff.
Later, they are reused for Java file compilation.
javac in this mode is integrated into kotlinc.
2017-05-17 17:48:17 +03:00
Denis Zharkov 692840860e Use allScope when resolving classifiers of binary classes
Otherwise it might lead to the problems when reading class files
from the source scope (e.g. a groovy file or an already compiled java file)

Note that it may be reproduced only with Maven because in JPS
and Gradle we reading source java files even when they're shouldn't be
recompiled, while in Maven we read class files in the case

 #KT-17897 Fixed
2017-05-17 14:33:23 +03:00
Pavel V. Talanov 798c80ed07 Use wrappers around java.util.* to emulate kotlin.collection.* behaviour
Backend: If kotlin class extends kotlin.collection.List
    write it as it's super interface (light class mode only)
IDE: Provide wrapper classes to java resolve
    that try to emulate backend behaviour

For example if kotlin class implements kotlin.collections.Map,
    we provide a superinterface that has abstract 'getEntries' method
    and 'entrySet' method that is considered default.
In reality all those methods are generated in the class itself.

In IDE supporting this case without hacks is not feasible performance-wise
    since kotlin.collection.* may not be an immediate supertype and we need
    to compute all supertypes just to calculate own methods of the class
2017-05-16 22:01:03 +03:00
Alexander Udalov 3f5b8b3f68 Refactor JvmDependenciesIndexImpl.search
- use nullable type "T?" instead of HandleResult consisting of the found
  value and the "should continue" flag
- inline all local functions because they don't add any value now
2017-05-15 12:17:46 +03:00
Anton Bannykh 2e9a59819a JS: support internal visibility from friend modules
Friend modules should be provided using the -Xfriend-modules flag
in the same format as -libraries. No manual configuration required for
JPS, Gradle and Maven plugins.

Friend modules could be switched off using the -Xfriend-modules-disabled
flag. Doing that will
  * prevent internal declarations from being exported,
  * values provided by -Xfriend-modules ignored,
  * raise a compilation error on attemps to use internal declarations from other modules

Fixes #KT-15135 and #KT-16568.
2017-05-04 21:44:17 +03:00
Ilya Chernikov 732367e671 Pass earlier scripts as array, removes 255-lines repl limitation
fixes #KT-10060
2017-05-03 18:11:46 +02:00
Ilya Chernikov 15ccd28e2e Switch old IDE/CLI repls to the new infrastructure
should also fix #KT-5822
2017-05-03 18:11:45 +02:00
Ilya Chernikov e384268c8b minor: unwrapping InvocationTargetException on repl line evaluation...
To provide better error diagnostics
2017-05-03 18:11:44 +02:00
Ilya Chernikov 8cc576d44f Add total reset to repl history and state interfaces 2017-05-03 18:11:43 +02:00
Alexander Udalov fcf44af294 Change how kotlinc and tools display their version
- Display the Kotlin version in kotlin-gradle-plugin. This is needed
  because if "-version" is specified in compiler arguments, the "info"
  level of the message printed by the compiler in CLICompiler prevents
  it from being displayed by default (unless "--debug" is passed to
  Gradle).
- Display the version of JRE the compiler is running on. This will be
  helpful to diagnose Java 9 related issues in the future.
- In CLI, also display the executable name (kotlinc-jvm or kotlinc-js)
2017-04-28 20:49:54 +03:00
Alexander Udalov d8d3bafbe9 Introduce "-Xreport-output-files" to report source-output mapping for JPS
This makes "-verbose" not required for JPS to run correctly and
therefore allows to print more useful debugging stuff in the compiler
and read them in CLI, for example. The output will also be more readable
because there'll be no "output" messages
2017-04-28 20:49:28 +03:00
Alexander Udalov 82e6324c45 Support compilation against modular JDK (9+)
For more information about the "jrt" file system, see
http://openjdk.java.net/jeps/220 and
https://bugs.openjdk.java.net/browse/JDK-8066492.

This commit fixes DiagnosticsWithJdk9TestGenerated.testKt11167

 #KT-11167 Fixed
2017-04-27 20:48:24 +03:00
Alexander Udalov 7f5d87ea17 Rename PathUtil.getJdkClassesRoots to avoid confusion
Two of these methods return roots given a path to the JRE, and the third
one returns roots given a path to the _JDK_.
2017-04-27 20:35:14 +03:00
Sergey Mashkov e03a842317 KT-15050 Use more stable way to specify idea compatible version
Here we have to specify build number static field
 as system properties are out of our control
 and they could be wiped out externally

#KT-15050 Fixed
2017-04-25 01:56:08 +03:00
Anton Bannykh 0db3649da1 Added EnvironmentConfigFiles.NATIVE_CONFIG_FILES for Kotlin/Native 2017-04-24 13:20:57 +03:00
Alexander Udalov c9769ab454 Do not serialize/deserialize CommonCompilerArguments#errors
This prevents .idea/kotlinc.xml from being added with an empty
ArgumentParseErrors object and also fixes
ConfigureKotlinInTempDirTest.testKotlincExistsNoSettingsRuntime11
2017-04-22 02:17:49 +03:00
Dmitry Jemerov 4e8fe18ca8 Fix facet validation: change ArgumentParseErrors to a data class
BaseCompilerSettings.validateInheritedFieldsUnchanged() compares
old and new properties of the compiler settings, and the check requires
ArgumentParseErrors.equals() to be correctly implemented
2017-04-21 13:20:49 +02:00
Denis Zharkov a5c352dc9f Add -Xuse-old-class-files-reading CLI argument
By default we use the fast implementation in CLI compiler,
but in the most of the tests the old one is enabled

Also add tests on CompiledJava with the fast class reading
implementation
2017-04-21 12:56:29 +03:00
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 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 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
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 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