Commit Graph

254 Commits

Author SHA1 Message Date
Ilya Chernikov
0a1aff4f80 Do not add updated script classpath to the compilation configuration
it is added via the updateClasspath call with proper duplicates control
2019-09-26 07:16:24 +02:00
Ilya Chernikov
d3b826c71d Improve class name generation for scripts and REPL snippets
- allow to override default name/scheme
- implement host/engine specific names for jsr223 to avoid classloading
  clashes (also fix "eval in eval" test)
2019-09-17 16:05:38 +02:00
Ilya Chernikov
6de05bb2c7 Drop hardcoded extraction of the snippet id from script name
rely on the userdate instead
2019-09-17 16:05:38 +02:00
Ilya Chernikov
61d517fb31 Implement script dependencies resolution directly from classloader
#KT-27956 fixed
2019-09-17 12:43:18 +02:00
Ilya Chernikov
f8db150a2b [minor] Drop some usages of kotlin reflection in scripting compiler plugin 2019-09-17 12:43:16 +02:00
Ilya Chernikov
b2d2ba5811 Refactor test utils: don't add main-kts to the classpath...
by default on running scripting tests via the call to K2JVMCompiler
2019-09-13 13:19:26 +02:00
Ilya Chernikov
45f5c42a53 Add appropriate script extension to the source name, if not provided
#KT-31704 fixed
2019-09-13 13:19:26 +02:00
Ilya Chernikov
939d76fd2a Isolate script execution from compiler classloader
Since fix of KT-33554, the script execution classpath is set correctly
according to the compilation classpath, so isolation makes sense now.
2019-09-13 13:19:26 +02:00
Ilya Chernikov
771f5c13dd Fix imported script functionality in JSR-223/REPL:
- setup compilation properly to take imported scripts into account
- add compiled imported scripts into generated results
= calculate ScriptLightVirtualFile path as relative - simplifies imported scripts location
2019-09-13 13:19:26 +02:00
Natalia Selezneva
961e8c2c74 Refactor the mechanism how script configurations are updated
Introduce file attributes cache, which is only applicable when no dependencies are cached in memory cache
Refactor ScriptDependenciesCache to memory cache that is able to get configuration from cache and checks if it is up to date
Move all public methods to ScriptDependenciesManager
Introduce ScriptClassRootsManager that checks if root change event should be called after script configuration update
2019-09-06 10:52:17 +03:00
Natalia Selezneva
dc46f73ecf Rewrite scripting related API to PsiFile instead of VirtualFile
There were several places where we converted virtualFile to PsiFile. This operation need a read access and may throw ProcessCanceledException,
so we want to minimize its usages in IDE
2019-09-06 10:51:26 +03:00
Ilya Chernikov
fda37eaaae [minor] Rearrange test utils for easier reuse 2019-08-28 17:59:12 +02:00
Ilya Chernikov
947867286c [minor] Fix potential problems with sequence, add a todo 2019-08-28 17:59:12 +02:00
Ilya Chernikov
c9b25cad01 Fix classpath handling when evaluating legacy scripts from kotlinc
#KT-33554 fixed
2019-08-28 17:59:12 +02:00
Ilya Chernikov
0f41dc814f Switch many common tasks defined in buildSrc to lazy creation
also refactor some locally defined tasks to the creation avoidance API
2019-08-21 20:20:08 +02:00
Denis Zharkov
c20d565d93 [Core API] Introduce API for getting scopes with refinement
- All refinement-related methods are incapsulated in
ModuleAwareClassDescriptor

- most of classes implement it trivially by retning unchanged scope

- LazyClassDescriptor and DeserializedClassDescriptor have non-trivial
implementations of the refinement-related methods

- General idea is to return new scope which captures refiner and will
later use it to get correct content of itself (currently, refiner is
unused, and will be used for that in later commits)

- In order to not repeat similar work, those new instances of scopes are
cached in ScopeHolderForClass, which is essentially a cache of form
KotlinTypeRefiner -> MemberScope
2019-07-30 12:41:37 +03:00
Ilya Chernikov
2a5c4a2409 Move caching to after all configuration refinements and ...
move compilation cache setting to the scripting host configuration
The cache implementation can now take into account all external
dependencies that may appear during refinement.
Also change initial refinement location accordingly and rearrange
caching interfaces to make it available in scripting plugin.
2019-07-26 08:55:16 +02:00
Ilya Chernikov
0af52f2fa6 Implement composable refinement handlers...
for compilation and evaluation configurations.
Add utilities to apply refinements uniformly.
Also fix one invoke for list values - it was not consistent with
other builders
2019-07-26 08:55:14 +02:00
Ilya Chernikov
5ed6573a60 Fix testLazyScriptDefinitionProvider:
The KtUsefulTestCase functionality is not used here but seems causes
the side effects resulting in failing test, probably exactly because
the infrastructure loaded by the KtUsefulTestCase is never called
2019-07-19 16:37:50 +02:00
Ilya Chernikov
823cb70ba0 Fix script definition matching for REPL console
fixes IdeReplCompletionTestGenerated tests
in addition, fix default ScriptDefinition generation
2019-07-19 16:37:49 +02:00
Ilya Chernikov
425deb42ec Convert paths to unix format before matching with filePathPattern
should also fix testPathPattern5_kts test
2019-07-19 16:37:49 +02:00
Natalia Selezneva
763f1e8606 Scripts: check that file is non-script starting script compilation configuration update
Replace FileType check with more precise method isNonScript
2019-07-18 12:30:03 +03:00
Natalia Selezneva
63767b4dca Performance: do not check file type for scripts with standard extension 2019-07-12 16:24:57 +03:00
Ilya Chernikov
bd50454a73 Change default for script displayName parameter to empty, generate name from base class in definition 2019-07-12 13:44:09 +03:00
Ilya Chernikov
0cc40440fb Implement filePathPattern in the script configuration with handling
also
- tests
- extending kdoc for the definitions
2019-07-12 13:44:09 +03:00
Ilya Chernikov
1396b3e682 Return default configuration when refinement failed on resolving script descriptor
also fixes appropriate IDE tests
2019-07-11 15:50:27 +02:00
Ilya Chernikov
382e55284c Fix legacy definitions error propagation
also fixes script-util test with resolving errors
2019-07-11 15:50:26 +02:00
Ilya Chernikov
10e19bccb1 Abort script evaluation if environment is created with errors
also fixes appropriate test
2019-07-11 15:50:26 +02:00
Ilya Chernikov
9c004c3a52 Refactor scripting compiler plugin - move cli dependent parts out of the -impl jar
The kotlin-scripting-compiler-impl jar is used in the idea plugin and
therefore should not depend on the cli parts of the compiler to avoid
dependency from the plugin to the kotlin-compiler.jar.
Therefore the cli-dependent parts were moved to the scripting plugin
jar, which is used only in cli compiler based environments.
Also implement required abstractions to allow this movement and
drop some redundant dependencies to the cli parts in other projects.
2019-07-11 15:50:26 +02:00
Ilya Chernikov
9ae0ff03fa Improve script and REPL result handling:
- implement error result
- refactor other result classes
- implement handling in the script evaluation extension - also restores
  previous script error reporting functionality
- add possibility to customize result fileds in script and REPL
- refactor result calculation in the backend: cleanup, rename (since
  it is not only about REPL now)
2019-07-11 15:50:26 +02:00
Ilya Chernikov
dc4370ff08 Implement support for new script customizations in command line compiler
refactor and fix internals in many places to make it work
add appropriate tests for main-kts case
2019-07-11 15:50:25 +02:00
Natalia Selezneva
e4d0c2cb0e Scripts: switch ScriptReportSink to new scripting API
Use ScriptDiagnostic instead of ScripReport
2019-07-10 10:10:21 +03:00
Natalia Selezneva
923e89db69 Provide toString method for ScriptCompilationConfigurationWrapper
This is needed for debug and logging proposes
2019-07-10 10:10:20 +03:00
Natalia Selezneva
b0c9339dee Scripts: search for script definition using PsiFile instead of file name 2019-07-10 10:10:07 +03:00
Natalia Selezneva
fbe965be9d Scripts: pass File finding script definition instead of File.name 2019-07-10 10:08:19 +03:00
Ilya Chernikov
a96a938f87 Fix creating of the script definition from legacy template
adding classpath needed to load template and related class to the
appropriate host configuration
fixes tests
2019-07-08 13:20:06 +02:00
Ilya Chernikov
4940f64265 Refactor scripting infrastructure - convert usages to the new entities 2019-07-05 17:02:10 +02:00
Vyacheslav Gerasimov
db3b01d2d4 Build: Centralize compiler dist build logic in :kotlin-compiler project 2019-06-27 17:56:48 +03:00
Ilya Chernikov
432d500c40 Fix custom script definition cashing and script validity check:
- reorder initialization logic, so that script definitions are
  requested only after plugins loading
- clear definitions cache after adding explicit definitions or sources

#KT-32206 fixed
#KT-32169 fixed

Note: any of these modification fix the problem alone, but the second
may prevent other similar problems, while the first fixes actual logic
of the script validity checks as well.
2019-06-26 13:01:39 +02:00
Vyacheslav Gerasimov
5a664a86a8 Build: Fix test runtime for kotlin-scripting-compiler tests 2019-06-14 18:10:24 +03:00
Vyacheslav Gerasimov
0514437fba Build: Workaround scripting dependencies on full Idea 2019-06-13 21:03:55 +03:00
Ilya Chernikov
e542c9ea84 Refactor script definitions and resolving/refining infrastructure:
- implement wrappers to wrap old and new API providers and resolvers
- make old API deprecated (with error where possible)
- drop old internal classes related to the old API
- refactor usages accordingly
- fix and add missing features to the scripting API where necessary
2019-06-06 17:21:00 +02:00
Ilya Chernikov
e95569a273 Report definition-related error diagnostic on the whole script file
#KT-31452 fixed
2019-05-31 13:34:17 +02:00
Ilya Chernikov
e7c99cd494 Fix scripting-compiler tests, add them to the global scriptingTest task 2019-05-25 10:10:34 +02:00
Ilya Chernikov
46915df56f Implement "legacy" REPL wrappers on top of the "new" scripting infrastructure 2019-05-25 10:10:29 +02:00
Ilya Chernikov
89006f16cd Prepare scripting infrastructure for REPL:
- refactor script compiler to simplify extending it for repl
- add repl snippet compilation functions to the new scripting compiler
- extract util functions into appropriate files
- extract repl part into separate class
- extract bridge definition and related definitions into separate file
2019-05-25 10:10:28 +02:00
Ilya Chernikov
a4c049d26e Replace message collector with reporting lambda
to simplify usages and slightly reduce dependencies
2019-05-25 10:10:28 +02:00
Ilya Chernikov
61c1312f1a Add another method for fetching classpath from classloader, refactor 2019-05-25 10:10:27 +02:00
Natalia Selezneva
ba7d66eb4b Fix 'Invalid file' Exception during script definition search (EA-125840)
EA-125840 - assert: FileManagerImpl.findFile
2019-05-08 15:17:12 +03:00
Dmitry Gridin
37c856290f Fix minor compile warnings 2019-04-25 19:47:39 +07:00