Compare commits

...

90 Commits

Author SHA1 Message Date
Andrey Breslav
15dbfa7184 ++ android-ide-plugin module extracted 2014-10-08 18:23:51 +04:00
Andrey Breslav
b0196ac1ad ++ Logic related to command-line options moved to android-compiler-plugin 2014-10-08 18:18:29 +04:00
Andrey Breslav
0e07cb9872 ++ Expression codegen extension: receiver passed through 2014-10-07 23:58:38 +04:00
Andrey Breslav
0c6622489b ~ read actions added here and there 2014-10-01 16:43:01 +04:00
Andrey Breslav
a4bbf9b3ec Artifact for Android extensions plugin 2014-10-01 16:43:00 +04:00
Andrey Breslav
bb0141b85f Missing public added 2014-10-01 16:43:00 +04:00
Andrey Breslav
abc17943d7 Find Usages extension extracted 2014-10-01 16:42:59 +04:00
Andrey Breslav
5f209d4351 ExpressionCodegenExtension extracted 2014-10-01 16:42:59 +04:00
Andrey Breslav
a1989dc5e0 ExternalDeclarationsProvider introduced 2014-10-01 16:42:58 +04:00
Andrey Breslav
da32f47d2a android-ide-plugin module extracted 2014-10-01 16:42:58 +04:00
Andrey Breslav
78b3613cf5 Logic related to command-line options moved to android-compiler-plugin 2014-10-01 16:42:56 +04:00
Andrey Breslav
eae40ab965 Compiler plugins can provide extra command line parameters in JPS 2014-10-01 16:42:56 +04:00
Andrey Breslav
18ff58e4e7 CommandLineProcessor infrastructure added 2014-10-01 16:42:55 +04:00
Andrey Breslav
2d6ec5bd5d frontend.android renamed to android-compiler-plugin 2014-10-01 16:42:55 +04:00
Andrey Breslav
50ec0d7f8d Plugin component registrar introduced
CompilerConfiguration moved to plugin-api
2014-09-30 21:52:52 +04:00
Andrey Breslav
01b22a1dd1 plugin-api module introduced 2014-09-30 21:52:52 +04:00
Mikhail Mutcianko
73c2db8f44 fix android jps build test case
- add proper way of setting up android sdk for jps
- add missing android plugin runtime library
2014-09-30 21:52:51 +04:00
Mikhail Mutcianko
84690dd9ee add android bytecode persistence test 2014-09-30 21:52:51 +04:00
Mikhail Mutcianko
7402cf8356 add android find usages test 2014-09-30 21:52:50 +04:00
Mikhail Mutcianko
5a3186a7f8 fix find usage handler not returning android property as secondary element 2014-09-30 21:52:50 +04:00
Mikhail Mutcianko
9e75390895 add reverse renaming to android rename tests 2014-09-30 21:52:49 +04:00
Mikhail Mutcianko
0c180275f1 add android rename tests 2014-09-30 21:52:49 +04:00
Mikhail Mutcianko
06d173ca44 eliminate idToXml cache leftovers from android resource manger 2014-09-30 21:52:48 +04:00
Mikhail Mutcianko
f8dcbd8477 fix kotlin property renamer npe
- fix npe when element usage has no reference(e.g. xml cross usage)
2014-09-30 21:52:48 +04:00
Mikhail Mutcianko
cc6a9d5183 factor base android test case
- move common initialization code to base class
2014-09-30 21:52:47 +04:00
Mikhail Mutcianko
67a3932615 add all goto tests
- fix base test case failing when no res directory present
- get rid of JetProperty -> XmlAttr caching
2014-09-30 21:52:47 +04:00
Mikhail Mutcianko
b934402b55 fix android kotlin test framework
- fix android jars not indexed by java indexer
- fix goto test
2014-09-30 21:52:46 +04:00
Mikhail Mutcianko
1e25af94c0 add android jps builder test stub
wtf
2014-09-30 21:52:46 +04:00
Mikhail Mutcianko
ab7177e251 add android goto declaration test stub 2014-09-30 21:52:45 +04:00
Mikhail Mutcianko
52e0bf88f7 regenerate android tests after rebase 2014-09-30 21:52:45 +04:00
Mikhail Mutcianko
bbd4cb93ed fix android resource path arguments after rebase 2014-09-30 21:52:44 +04:00
Mikhail Mutcianko
4866168a21 fix android cross parser tests
- reorganize tests folder structure
- fix class attribute ignored in ide xml parser
2014-09-30 21:52:44 +04:00
Mikhail Mutcianko
fd125e07b6 refactor android kotlin fixture test
- move more setup code to base class
2014-09-30 21:52:43 +04:00
Mikhail Mutcianko
74b1017fcf delete obsolete android test 2014-09-30 21:52:42 +04:00
Mikhail Mutcianko
c3a668c8ca fix R class field resolving
- resolve by class name and package defined in AndroidManifest.xml
2014-09-30 21:52:42 +04:00
Mikhail Mutcianko
f20731548d add android completion tests
- add android plugin test classes as test library
- add base android test cases for kotlin, setting up android facet and sdk
2014-09-30 21:52:41 +04:00
Mikhail Mutcianko
b9b3575eb4 add android properties box tests 2014-09-30 21:52:41 +04:00
dedoz
28b8c8b5d6 add generated tests 2014-09-30 21:52:40 +04:00
Mikhail Mutcianko
8eba35cd76 optimize imports
tmp

stmp
2014-09-30 21:52:40 +04:00
Mikhail Mutcianko
530d6caa47 minor refactorings 2014-09-30 21:52:39 +04:00
Mikhail Mutcianko
6211485143 update android synthetic properties completion test
- add missing android classes as text into fixture
2014-09-30 21:52:39 +04:00
Mikhail Mutcianko
82cfb218e0 fix android plugin libs dependencies 2014-09-30 21:52:38 +04:00
Mikhail Mutcianko
9deea1caad fix cli argument tests 2014-09-30 21:52:38 +04:00
Mikhail Mutcianko
ca701f40e9 fix android plugin dependencies not unpacked 2014-09-30 21:52:37 +04:00
dedoz
e92f26123f add kotlin gradle plugin integration 2014-09-30 21:52:37 +04:00
dedoz
785a2d4200 add android xml to properties completion test 2014-09-30 21:52:36 +04:00
Mikhail Mutcianko
6554258166 add configuration key to pass android manifest file 2014-09-30 21:52:36 +04:00
Mikhail Mutcianko
7a06c8176e add android layout file searching to kotlin jps plugin 2014-09-30 21:52:35 +04:00
Mikhail Mutcianko
f582159d72 delegate android resource and manifest reading in ide to android support plugin 2014-09-30 21:52:35 +04:00
Mikhail Mutcianko
a84b3e82e6 correct interpretation of android id usage mixed with id declarations 2014-09-30 21:52:34 +04:00
Mikhail Mutcianko
7834423136 implement find usages action for android synthetic properties 2014-09-30 21:52:34 +04:00
Mikhail Mutcianko
aef7523b79 add android xml reference and rename handling to JetSimpleNameReference 2014-09-30 21:52:33 +04:00
Mikhail Mutcianko
b516cdffa8 android goto declaration handler reference fix
- goto handler now utilizes full featured reference resolving instead of simple name based resolving
2014-09-30 21:52:33 +04:00
Mikhail Mutcianko
7857302c47 fix excess xml parsing when renaming resources
- rebuild resource name -> xml attribute mappings same time as rebuilding synthetic properties
- update mappings during rename
2014-09-30 21:52:32 +04:00
Mikhail Mutcianko
b6bc9a92d6 add synthetic property renaming by renaming R light class field 2014-09-30 21:52:32 +04:00
Mikhail Mutcianko
ffd3d1ffa3 add bound property renaming by renaming xml attribute value 2014-09-30 21:52:31 +04:00
Mikhail Mutcianko
a18c97e6c5 refactor AndroidResourceManager
- move more common methods from xml processor implementations to resource manager
- optimize imports, reformat code
2014-09-30 21:52:31 +04:00
Mikhail Mutcianko
89908524ab fix double renaming issue
- rebuild resource mapping cache on external layout file changes
- move duplicated code to AndroidResourceManager
2014-09-30 21:52:31 +04:00
Mikhail Mutcianko
f3875cfde6 add missing android plugin dependency 2014-09-30 21:52:30 +04:00
Mikhail Mutcianko
c5d412e496 move android rename handler out of kotlin property renamer, extract resource manager class 2014-09-30 21:52:30 +04:00
Mikhail Mutcianko
c5689f5c26 reformat code, optimize imports 2014-09-30 21:31:12 +04:00
Mikhail Mutcianko
70253a61b6 revert cli converter to stream parsing 2014-09-30 21:31:12 +04:00
Mikhail Mutcianko
6e7c27d9fd add goto declaration support for synthetic android properties 2014-09-30 21:31:11 +04:00
Mikhail Mutcianko
5a994db798 rename android synthetic id property also renames respective xml resource 2014-09-30 21:31:08 +04:00
Mikhail Mutcianko
d959d4dbd0 add android synthetic element detecting helpers 2014-09-30 21:30:17 +04:00
dedoz
7a8bbccda3 replace sax with psi based android ui xml parsing in plugin 2014-09-30 21:30:17 +04:00
Mikhail Mutcianko
795177ca80 fix xml resolving
- replace VirtualFileListener based approach with direct PsiFile reading
2014-09-30 21:30:16 +04:00
Mikhail Mutcianko
8a191bb1a2 check if android metadata is present before inlining property 2014-09-30 21:30:16 +04:00
Mikhail Mutcianko
b7308b9b7c fix compiler argument tests 2014-09-30 21:30:15 +04:00
Mikhail Mutcianko
cc31520089 insert missing copyrights, move ByteArrayClassLoader up 2014-09-30 21:30:14 +04:00
dedoz
80547cf292 add android xml bridge invocation test 2014-09-30 21:30:14 +04:00
Mikhail Mutcianko
2a0a03e011 add byte code generation 2014-09-30 21:30:13 +04:00
Mikhail Mutcianko
ffbe0a3e4e add android manifest support 2014-09-30 21:30:12 +04:00
Mikhail Mutcianko
8a7bc4fa71 fix R class not resolved in dummy file 2014-09-30 21:30:12 +04:00
Mikhail Mutcianko
a682a1d208 refactor XmlHandler, optimize imports, remove unused files 2014-09-30 21:30:11 +04:00
Mikhail Mutcianko
d955cc87dc add missing module and build dependencies 2014-09-30 21:30:04 +04:00
Mikhail Mutcianko
cb1da3b07b add writePackage to KotlinWriter 2014-09-30 21:29:08 +04:00
Mikhail Mutcianko
e2ef7efcb4 refactor converter initialization
- push lazyInit() down to IDE and Cli implementations
- no file listeners created in cli implementation anymore
- fix tests
2014-09-30 21:29:07 +04:00
Mikhail Mutcianko
ee46064f02 event based file processing
- use VirtualFileListener to wait for ui xml file updates
- optimize imports
2014-09-30 21:29:07 +04:00
Mikhail Mutcianko
770a732449 suppress xml errors in converter
- simply ignore malformed layouts, xml editor in ide will highlight them anyway
2014-09-30 21:29:06 +04:00
Mikhail Mutcianko
03732ac606 add converter output caching
- add two level caching: per xml conversion result and complete resulting JetFile,
  so that only modified xmls are actually converted, and if no change has been
  made to any of those, last successfully built psi file is returned
- merge AndroidUIXmlPathProvider and AndroidUIXmlParser
- update tests
2014-09-30 21:29:05 +04:00
Mikhail Mutcianko
9683bc385a fix ant build
- add frontend.android content to sources path
2014-09-30 21:29:05 +04:00
Mikhail Mutcianko
e35cb603f9 add compiler key for providing android resources path 2014-09-30 21:29:04 +04:00
Mikhail Mutcianko
71edc602c8 fix npe when layout xml search path does not exist 2014-09-30 21:29:04 +04:00
Mikhail Mutcianko
958ea49978 obey android project structure when searching for ui xmls
- search for android layout xmls in ProjectRoot/res/layout/ when using IDEPathProvider
2014-09-30 21:29:03 +04:00
Mikhail Mutcianko
86b2a3e5a5 missing files handling in converter
- silently continue if no files were found to convert
2014-09-30 21:29:02 +04:00
Mikhail Mutcianko
de56576d15 ide analyzer integration stub
- add android ui xml path providers/stubs
- add generated file injection during analysis
2014-09-30 21:29:02 +04:00
Mikhail Mutcianko
a5d1936393 auto cast widget to its original type
- change property return type signatures from View to actual widget type
- simplify and update tests
2014-09-30 21:29:01 +04:00
Mikhail Mutcianko
c63281f91a add converted result compilation test 2014-09-30 21:29:01 +04:00
Mikhail Mutcianko
f4c83d88eb android UI xml bridge initial
- add frontend.android module
- add xml ids to kotlin extension properties converter
- add converter basic functional test
2014-09-30 21:29:00 +04:00
199 changed files with 6442 additions and 30 deletions

View File

@@ -0,0 +1,18 @@
<component name="ArtifactManager">
<artifact name="KotlinAndroidExtensionsPlugin">
<output-path>$PROJECT_DIR$/out/artifacts/KotlinAndroidExtensionsPlugin</output-path>
<root id="root">
<element id="directory" name="lib">
<element id="archive" name="kotlin-android-extensions-plugin.jar">
<element id="module-output" name="android-compiler-plugin" />
<element id="module-output" name="android-idea-plugin" />
</element>
<element id="directory" name="jps">
<element id="archive" name="kotlin-android-extensions-jps.jar">
<element id="module-output" name="android-jps-plugin" />
</element>
</element>
</element>
</root>
</artifact>
</component>

View File

@@ -31,6 +31,8 @@
<element id="module-output" name="eval4j" />
<element id="module-output" name="idea-analysis" />
<element id="module-output" name="ide-lazy-resolve" />
<element id="module-output" name="android-compiler-plugin" />
<element id="module-output" name="android-idea-plugin" />
</element>
<element id="library" level="project" name="javax.inject" />
<element id="directory" name="jps">

38
.idea/libraries/android.xml generated Normal file
View File

@@ -0,0 +1,38 @@
<component name="libraryTable">
<library name="android">
<ANNOTATIONS>
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/android.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/jps/android-jps-plugin.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/android-common.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/jps/android-gradle-jps.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/manifest-merger.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/builder-model-0.12.0.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/commons-compress-1.0.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/layoutlib-api.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/common.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/sdklib.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/resources_en.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/sdk-tools.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/jarutils.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/lib/android-rt.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/rt/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/gen" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/common/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/common/testSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/testSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/ultimate/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/guiTestSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/jps-plugin/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/jps-plugin/testSrc" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/android-gradle-jps/src" />
<root url="jar://$PROJECT_DIR$/ideaSDK/plugins/android/android-src.zip!/android-gradle-jps/testSrc" />
</SOURCES>
</library>
</component>

9
.idea/libraries/android_tests.xml generated Normal file
View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="android_tests">
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/android_tests.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

4
.idea/modules.xml generated
View File

@@ -3,6 +3,9 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Kotlin.iml" filepath="$PROJECT_DIR$/Kotlin.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-compiler-plugin/android-compiler-plugin.iml" filepath="$PROJECT_DIR$/plugins/android-compiler-plugin/android-compiler-plugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-idea-plugin/android-idea-plugin.iml" filepath="$PROJECT_DIR$/plugins/android-idea-plugin/android-idea-plugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-jps-plugin/android-jps-plugin.iml" filepath="$PROJECT_DIR$/plugins/android-jps-plugin/android-jps-plugin.iml" group="plugins" />
<module fileurl="file://$PROJECT_DIR$/android-studio/android-studio.iml" filepath="$PROJECT_DIR$/android-studio/android-studio.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/compiler/android-tests/android-tests.iml" filepath="$PROJECT_DIR$/compiler/android-tests/android-tests.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/compiler/backend/backend.iml" filepath="$PROJECT_DIR$/compiler/backend/backend.iml" group="compiler/java" />
@@ -37,6 +40,7 @@
<module fileurl="file://$PROJECT_DIR$/js/js.tests/js.tests.iml" filepath="$PROJECT_DIR$/js/js.tests/js.tests.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/js/js.translator/js.translator.iml" filepath="$PROJECT_DIR$/js/js.translator/js.translator.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" filepath="$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" filepath="$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/compiler/preloader/preloader.iml" filepath="$PROJECT_DIR$/compiler/preloader/preloader.iml" group="compiler/cli" />
<module fileurl="file://$PROJECT_DIR$/core/reflection/reflection.iml" filepath="$PROJECT_DIR$/core/reflection/reflection.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />

View File

@@ -2,7 +2,7 @@
<configuration default="false" name="IDEA" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=450m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Dkotlin.internal.mode.enabled=true" />
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=450m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin:$PROJECT_DIR$/out/artifacts/KotlinAndroidExtensionsPlugin -Dkotlin.internal.mode.enabled=true" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/ideaSDK/bin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />

View File

@@ -2,7 +2,7 @@
<configuration default="false" name="IDEA (No ProcessCanceledException)" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=250m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true" />
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=250m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin:$PROJECT_DIR$/out/artifacts/KotlinAndroidExtensionsPlugin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/ideaSDK/bin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />

View File

@@ -8,6 +8,7 @@
<excludeFolder url="file://$MODULE_DIR$/android.tests.dependencies" />
<excludeFolder url="file://$MODULE_DIR$/dependencies" />
<excludeFolder url="file://$MODULE_DIR$/dist" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/androidSDK" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/config" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/config-idea" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/system" />

View File

@@ -63,6 +63,7 @@
<include name="core/serialization/src"/>
<include name="core/descriptor.loader.java/src"/>
<include name="compiler/frontend.java/src"/>
<include name="compiler/frontend.android/src"/>
<include name="core/serialization.java/src"/>
<include name="compiler/backend-common/src"/>
<include name="compiler/backend/src"/>
@@ -86,6 +87,7 @@
<include name="serialization/**"/>
<include name="descriptor.loader.java/**"/>
<include name="frontend.java/**"/>
<include name="frontend.android/**"/>
<include name="serialization.java/**"/>
<include name="backend/**"/>
<include name="backend-common/**"/>

View File

@@ -31,6 +31,7 @@ import org.jetbrains.jet.codegen.binding.CalculatedClosure;
import org.jetbrains.jet.codegen.binding.CodegenBinding;
import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.codegen.context.*;
import org.jetbrains.jet.codegen.extensions.ExpressionCodegenExtension;
import org.jetbrains.jet.codegen.inline.InlineCodegen;
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
import org.jetbrains.jet.codegen.inline.NameGenerator;
@@ -1730,6 +1731,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (descriptor instanceof PropertyDescriptor) {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
for (ExpressionCodegenExtension extension : ExpressionCodegenExtension.OBJECT$.getInstances(state.getProject())) {
StackValue result = extension.apply(receiver, resolvedCall, new ExpressionCodegenExtension.Context(typeMapper, v));
if (result != null) return result;
}
boolean directToField =
expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER && contextKind() != OwnerKind.TRAIT_IMPL;
JetExpression r = getReceiverForSelector(expression);

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen.extensions
import org.jetbrains.jet.extensions.ProjectExtensionDescriptor
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
import org.jetbrains.jet.codegen.StackValue
import org.jetbrains.jet.codegen.state.JetTypeMapper
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
public trait ExpressionCodegenExtension {
class object : ProjectExtensionDescriptor<ExpressionCodegenExtension>("org.jetbrains.kotlin.expressionCodegenExtension", javaClass<ExpressionCodegenExtension>())
public class Context(
public val typeMapper: JetTypeMapper,
public val v: InstructionAdapter
)
// return null if not applicable
public fun apply(receiver: StackValue, resolvedCall: ResolvedCall<*>, c: ExpressionCodegenExtension.Context): StackValue?
}

View File

@@ -23,6 +23,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public abstract class CommonCompilerArguments {
public static final String PLUGIN_OPTION_FORMAT = "<pluginId>:<optionName>=<value>";
@Argument(value = "nowarn", description = "Generate no warnings")
public boolean suppressWarnings;
@@ -38,6 +40,14 @@ public abstract class CommonCompilerArguments {
@Argument(value = "X", description = "Print a synopsis of advanced options")
public boolean extraHelp;
@Argument(value = "Xplugin", description = "Load a plugin from the given classpath")
@ValueDescription("<path>")
public String[] pluginClasspaths;
@Argument(value = "P", description = "Pass an option to a plugin")
@ValueDescription(PLUGIN_OPTION_FORMAT)
public String[] pluginOptions;
public List<String> freeArgs = new SmartList<String>();
@NotNull

View File

@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.IncrementalCacheP
import org.jetbrains.jet.utils.KotlinPaths;
import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
import org.jetbrains.jet.utils.PathUtil;
import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException;
import java.io.File;
import java.util.Collections;
@@ -87,6 +88,15 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
return INTERNAL_ERROR;
}
try {
PluginCliParser.processPluginOptions(arguments, configuration);
}
catch (CliOptionProcessingException e) {
// TODO Print usage?
messageCollector.report(CompilerMessageSeverity.ERROR, e.getMessage(), CompilerMessageLocation.NO_LOCATION);
return INTERNAL_ERROR;
}
if (!arguments.script &&
arguments.module == null &&
arguments.freeArgs.isEmpty() &&

View File

@@ -0,0 +1,109 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.cli.jvm
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments
import kotlin.platform.*
import java.util.jar.JarFile
import java.util.jar.Attributes
import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException
import java.util.regex.Pattern
import org.jetbrains.jet.utils.valuesToMap
import org.jetbrains.jet.config.CompilerConfiguration
import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.compiler.plugin.CliOption
public object PluginCliParser {
public val PLUGIN_ARGUMENT_PREFIX: String = "plugin:"
private fun getCommandLineProcessors(arguments: CommonCompilerArguments): Collection<CommandLineProcessor> {
return arguments.pluginClasspaths!!.map {
loadCommandLineProcessor(JarFile(it).getManifest()?.getAttributes("org.jetbrains.kotlin.compiler.plugin"))
}.filterNotNull()
}
private fun loadCommandLineProcessor(attributes: Attributes?): CommandLineProcessor? {
if (attributes == null) return null
val processorClassName = attributes.getValue("CommandLineProcessor")
if (processorClassName == null) return null
try {
val processorClass = Class.forName(processorClassName)
return processorClass.newInstance() as CommandLineProcessor
}
catch (e: Throwable) {
throw CliOptionProcessingException("Loading plugin component failed: $processorClassName", e)
}
}
[platformStatic]
fun processPluginOptions(arguments: CommonCompilerArguments, configuration: CompilerConfiguration) {
val optionValuesByPlugin = arguments.pluginOptions!!.map { parsePluginOption(it) }.groupBy {
if (it == null) throw CliOptionProcessingException("Wrong plugin option format: $it, should be ${CommonCompilerArguments.PLUGIN_OPTION_FORMAT}")
it.optionName
}
val processors = getCommandLineProcessors(arguments)
for (processor in processors) {
val declaredOptions = processor.pluginOptions.valuesToMap { it.name }
val optionsToValues = MultiMap<CliOption, PluginOptionValue>()
for (optionValue in optionValuesByPlugin[processor.pluginId].orEmpty()) {
val option = declaredOptions[optionValue!!.optionName]
if (option == null) {
throw CliOptionProcessingException("Unsupported plugin option: $optionValue")
}
optionsToValues.putValue(option, optionValue)
}
for (option in processor.pluginOptions) {
val values = optionsToValues[option]
if (option.required && values.isEmpty()) {
throw CliOptionProcessingException("Required plugin option not present: ${processor.pluginId}:${option.name}")
}
if (!option.allowMultipleOccurrences && values.size() > 1) {
throw CliOptionProcessingException("Multiple values not allowed for plugin option ${processor.pluginId}:${option.name}")
}
for (value in values) {
processor.processOption(option, value.value, configuration)
}
}
}
}
private class PluginOptionValue(
val pluginId: String,
val optionName: String,
val value: String
) {
override fun toString() = "$pluginId:$optionName=$value"
}
private fun parsePluginOption(argumentValue: String): PluginOptionValue? {
val pattern = Pattern.compile("""^([^:]*):([^=]*)=(.*)$""")
val matcher = pattern.matcher(argumentValue)
if (matcher.matches()) {
return PluginOptionValue(matcher.group(1)!!, matcher.group(2)!!, matcher.group(3)!!)
}
return null
}
}

View File

@@ -48,8 +48,10 @@ import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
import org.jetbrains.jet.codegen.extensions.ExpressionCodegenExtension;
import org.jetbrains.jet.config.CommonConfigurationKeys;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.extensions.ExternalDeclarationsProvider;
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
import org.jetbrains.jet.lang.psi.JetFile;
@@ -59,6 +61,7 @@ import org.jetbrains.jet.lang.resolve.lazy.declarations.CliDeclarationProviderFa
import org.jetbrains.jet.lang.resolve.lazy.declarations.DeclarationProviderFactoryService;
import org.jetbrains.jet.plugin.JetFileType;
import org.jetbrains.jet.utils.PathUtil;
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar;
import java.io.File;
import java.util.ArrayList;
@@ -208,6 +211,13 @@ public class JetCoreEnvironment {
configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY));
project.registerService(VirtualFileFinderFactory.class, new CliVirtualFileFinderFactory(classPath));
for (ComponentRegistrar registrar : configuration.getList(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS)) {
registrar.registerProjectComponents(project, configuration);
}
ExternalDeclarationsProvider.OBJECT$.registerExtensionPoint(project);
ExpressionCodegenExtension.OBJECT$.registerExtensionPoint(project);
}
// made public for Upsource

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-runtime" level="project" />
<orderEntry type="library" name="intellij-core" level="project" />
<orderEntry type="module" module-name="frontend" />
</component>
</module>

View File

@@ -33,6 +33,10 @@ import org.jetbrains.jet.lang.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.jet.analyzer.ModuleInfo
import org.jetbrains.jet.analyzer.ModuleContent
import org.jetbrains.jet.di.InjectorForLazyResolveWithJava
import org.jetbrains.jet.lang.psi.JetFile
import java.util.ArrayList
import org.jetbrains.jet.extensions.ExternalDeclarationsProvider
import kotlin.platform.platformStatic
public class JvmResolverForModule(
override val lazyResolveSession: ResolveSession,
@@ -54,8 +58,9 @@ public object JvmAnalyzerFacade : AnalyzerFacade<JvmResolverForModule, JvmPlatfo
resolverForProject: ResolverForProject<M, JvmResolverForModule>
): JvmResolverForModule {
val (syntheticFiles, moduleContentScope) = moduleContent
val filesToAnalyze = getAllFilesToAnalyze(project, syntheticFiles)
val declarationProviderFactory = DeclarationProviderFactoryService.createDeclarationProviderFactory(
project, globalContext.storageManager, syntheticFiles, moduleContentScope
project, globalContext.storageManager, filesToAnalyze, moduleContentScope
)
val moduleClassResolver = ModuleClassResolverImpl { javaClass ->
@@ -76,4 +81,12 @@ public object JvmAnalyzerFacade : AnalyzerFacade<JvmResolverForModule, JvmPlatfo
override val defaultImports = TopDownAnalyzerFacadeForJVM.DEFAULT_IMPORTS
override val platformToKotlinClassMap = JavaToKotlinClassMap.getInstance()
public platformStatic fun getAllFilesToAnalyze(project: Project, baseFiles: Collection<JetFile>): List<JetFile> {
val allFiles = ArrayList(baseFiles)
for (externalDeclarationsProvider in ExternalDeclarationsProvider.getInstances(project)) {
allFiles.addAll(externalDeclarationsProvider.getExternalDeclarations())
}
return allFiles
}
}

View File

@@ -75,6 +75,8 @@ public enum TopDownAnalyzerFacadeForJVM {
false
);
List<JetFile> allFiles = JvmAnalyzerFacade.getAllFilesToAnalyze(project, files);
InjectorForTopDownAnalyzerForJvm injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module);
try {
List<PackageFragmentProvider> additionalProviders = new ArrayList<PackageFragmentProvider>();
@@ -85,7 +87,7 @@ public enum TopDownAnalyzerFacadeForJVM {
additionalProviders.add(
new IncrementalPackageFragmentProvider(
files, module, globalContext.getStorageManager(), injector.getDeserializationGlobalContextForJava(),
allFiles, module, globalContext.getStorageManager(), injector.getDeserializationGlobalContextForJava(),
incrementalCache, moduleId, injector.getJavaDescriptorResolver()
)
);
@@ -93,7 +95,7 @@ public enum TopDownAnalyzerFacadeForJVM {
}
additionalProviders.add(injector.getJavaDescriptorResolver().getPackageFragmentProvider());
injector.getTopDownAnalyzer().analyzeFiles(topDownAnalysisParameters, files, additionalProviders);
injector.getTopDownAnalyzer().analyzeFiles(topDownAnalysisParameters, allFiles, additionalProviders);
return AnalyzeExhaust.success(trace.getBindingContext(), module);
}
finally {

View File

@@ -13,6 +13,7 @@
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="serialization" />
<orderEntry type="module" module-name="descriptors" exported="" />
<orderEntry type="module" module-name="plugin-api" exported="" />
</component>
</module>

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.extensions
import org.jetbrains.jet.lang.psi.JetFile
public trait ExternalDeclarationsProvider {
class object : ProjectExtensionDescriptor<ExternalDeclarationsProvider>(
"org.jetbrains.kotlin.externalDeclarationsProvider",
javaClass<ExternalDeclarationsProvider>()
)
public fun getExternalDeclarations(): Collection<JetFile>
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.extensions
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.project.Project
import com.intellij.openapi.extensions.Extensions
import com.intellij.openapi.extensions.ExtensionPoint
public open class ProjectExtensionDescriptor<T>(name: String, private val extensionClass: Class<T>) {
public val extensionPointName: ExtensionPointName<T> = ExtensionPointName.create(name)!!
public fun registerExtensionPoint(project: Project) {
Extensions.getArea(project).registerExtensionPoint(
extensionPointName.getName()!!,
extensionClass.getName(),
ExtensionPoint.Kind.INTERFACE
)
}
public fun registerExtension(project: Project, extension: T) {
Extensions.getArea(project).getExtensionPoint(extensionPointName).registerExtension(extension)
}
public fun getInstances(project: Project): Collection<T> {
val projectArea = Extensions.getArea(project)
if (!projectArea.hasExtensionPoint(extensionPointName.getName()!!)) return listOf()
return projectArea.getExtensionPoint(extensionPointName).getExtensions().toList()
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="intellij-core" level="project" />
<orderEntry type="library" name="kotlin-runtime" level="project" />
</component>
</module>

View File

@@ -27,6 +27,7 @@ public class CompilerConfigurationKey<T> {
ideaKey = Key.create(name);
}
@NotNull
public static <T> CompilerConfigurationKey<T> create(@NotNull @NonNls String name) {
return new CompilerConfigurationKey<T>(name);
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.compiler.plugin
import org.jetbrains.jet.config.CompilerConfiguration
public class CliOption(
public val name: String,
public val valueDescription: String,
public val description: String,
public val required: Boolean = true,
public val allowMultipleOccurrences: Boolean = false
)
public class CliOptionProcessingException(message: String, cause: Throwable? = null): RuntimeException(message, cause)
public trait CommandLineProcessor {
public val pluginId: String
public val pluginOptions: Collection<CliOption>
[throws(javaClass<CliOptionProcessingException>())]
public fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration)
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.compiler.plugin
import org.jetbrains.jet.config.CompilerConfigurationKey
import org.jetbrains.jet.config.CompilerConfiguration
import com.intellij.mock.MockProject
public trait ComponentRegistrar {
class object {
public val PLUGIN_COMPONENT_REGISTRARS: CompilerConfigurationKey<MutableList<ComponentRegistrar>> = CompilerConfigurationKey.create("plugin component registrars")
}
public fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration)
}

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,9 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
val Activity.MyButton: org.my.cool.Button
get() = findViewById(0) as org.my.cool.Button

View File

@@ -0,0 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<view
class="org.my.cool.Button"
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,9 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
val Activity.MyButton: org.my.cool.Button
get() = findViewById(0) as org.my.cool.Button

View File

@@ -0,0 +1,14 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<org.my.cool.Button
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,30 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
val Activity.item_detail_container: FrameLayout
get() = findViewById(0) as FrameLayout
val Activity.textView1: TextView
get() = findViewById(0) as TextView
val Activity.password: EditText
get() = findViewById(0) as EditText
val Activity.login: Button
get() = findViewById(0) as Button
val Activity.frameLayout: FrameLayout
get() = findViewById(0) as FrameLayout
val Activity.passwordField: TextView
get() = findViewById(0) as TextView
val Activity.passwordCaption: EditText
get() = findViewById(0) as EditText
val Activity.loginButton: Button
get() = findViewById(0) as Button

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/passwordField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/passwordCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,6 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*

View File

@@ -0,0 +1,25 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,18 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
val Activity.item_detail_container: FrameLayout
get() = findViewById(0) as FrameLayout
val Activity.textView1: TextView
get() = findViewById(0) as TextView
val Activity.password: EditText
get() = findViewById(0) as EditText
val Activity.login: Button
get() = findViewById(0) as Button

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,6 @@
package android.app
import android.view.View
abstract class Activity {
open abstract fun findViewById(id: Int): View?
}

View File

@@ -0,0 +1,3 @@
package android.view
trait View

View File

@@ -0,0 +1,16 @@
package android.widget
import android.view.View
class EditText: View {
override fun toString(): String {return "EditText"}
}
class TextView: View {
override fun toString(): String {return "TextView"}
}
class Button: View {
override fun toString(): String {return "Button"}
}
class FrameLayout: View {
override fun toString(): String {return "FrameLayout"}
}

View File

@@ -10,6 +10,8 @@ where possible options include:
-module <path> Path to the module file to compile
-script Evaluate the script file
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-androidRes <path> Android resources path
-androidManifest <path> Android manifest file
-nowarn Generate no warnings
-verbose Enable verbose logging output
-version Display compiler version

View File

@@ -11,6 +11,8 @@ where possible options include:
-module <path> Path to the module file to compile
-script Evaluate the script file
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-androidRes <path> Android resources path
-androidManifest <path> Android manifest file
-nowarn Generate no warnings
-verbose Enable verbose logging output
-version Display compiler version

View File

@@ -0,0 +1,8 @@
package android.app
import android.view.View
import android.content.Context
abstract class Activity: Context {
abstract fun findViewById(id: Int): View?
}

View File

@@ -0,0 +1,3 @@
package android.content
trait Context

View File

@@ -0,0 +1,5 @@
package android.view
import android.content.Context
open class View(ctx: Context)

View File

@@ -0,0 +1,11 @@
package android.widget
import android.view.View
import android.content.Context
open class Button(ctx: Context): View(ctx) {override fun toString() = "Button"}
open class EditText(ctx: Context): View(ctx) {override fun toString() = "EditText"}
open class TextView(ctx: Context): View(ctx) {override fun toString() = "TextView"}
open class FrameLayout(ctx: Context): View(ctx) {override fun toString() = "FrameLayout"}
open class RelativeLayout(ctx: Context): View(ctx) {override fun toString() = "RelativeLayout"}
open class ImageView(ctx: Context): View(ctx) {override fun toString() = "ImageView"}

View File

@@ -0,0 +1,33 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
import org.my.cool.MyButton
class R {
class id {
class object {
val login = 5
}
}
}
class MyActivity(): Activity() {
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.login -> buttonWidget
else -> null
}
}
public fun box(): String {
return if (login.toString() == "MyButton") "OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}

View File

@@ -0,0 +1,29 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
import org.my.cool.MyButton
class R {
class id {
class object {
val login = 5
}
}
}
class MyActivity(): Activity() {
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.login -> buttonWidget
else -> null
}
}
}
fun box(): String {
return "OK"
}

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,8 @@
package org.my.cool
import android.widget.Button
import android.app.Activity
class MyButton(ctx: Activity): Button(ctx) {
override fun toString(): String {return "MyButton"}
}

View File

@@ -0,0 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<view
class="org.my.cool.MyButton"
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,33 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
import org.my.cool.MyButton
class R {
class id {
class object {
val login = 5
}
}
}
class MyActivity(): Activity() {
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.login -> buttonWidget
else -> null
}
}
public fun box(): String {
return if (login.toString() == "MyButton") "OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}

View File

@@ -0,0 +1,29 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
import org.my.cool.MyButton
class R {
class id {
class object {
val login = 5
}
}
}
class MyActivity(): Activity() {
val buttonWidget = MyButton(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.login -> buttonWidget
else -> null
}
}
}
fun box(): String {
return "OK"
}

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,8 @@
package org.my.cool
import android.widget.Button
import android.content.Context
class MyButton(ctx: Context): Button(ctx) {
override fun toString(): String {return "MyButton"}
}

View File

@@ -0,0 +1,14 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<org.my.cool.MyButton
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1 @@
fun box() = "OK"

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/req_who_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"
android:gravity="left"
android:src="@drawable/icon" />
<TextView
android:id="@+id/req_state_who"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/req_who_icon"
android:textSize="10dip"
android:layout_alignParentRight="false"
android:layout_alignParentTop="false"
android:layout_alignWithParentIfMissing="true"
android:gravity="left"
android:text="who" />
<TextView
android:id="@+id/req_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/req_state_who"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:gravity="right"
android:text="No summary"
android:textSize="10dip"
android:textColor="#FFFF00" />
<TextView
android:id="@+id/req_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/req_header"
android:layout_toRightOf="@id/req_state_who"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true"
android:gravity="right"
android:textSize="10dip"
android:text="No summary" />
<TextView
android:id="@+id/req_description"
android:layout_below="@id/req_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/req_state_who"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:gravity="right"
android:ellipsize="marquee"
android:text="No description"
android:textSize="10dip" />
<ImageView
android:id="@+id/req_state_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/req_description"
android:layout_marginRight="6dip"/>
</RelativeLayout>

View File

@@ -0,0 +1,57 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
class R {
class id {
class object {
val item_detail_container = 0
val textView1 = 1
val password = 2
val textView2 = 3
val passwordConfirmation = 4
val login = 5
val passwordField = 6
val passwordCaption = 7
val loginButton = 8
}
}
}
class MyActivity(): Activity() {
val textViewWidget = TextView(this)
val editTextWidget = EditText(this)
val buttonWidget = Button(this)
val textViewWidget2 = TextView(this)
val editTextWidget2 = EditText(this)
val buttonWidget2 = Button(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.textView1 -> textViewWidget
R.id.password -> editTextWidget
R.id.login -> buttonWidget
R.id.passwordField -> textViewWidget2
R.id.passwordCaption -> editTextWidget2
R.id.loginButton -> buttonWidget2
else -> null
}
}
public fun box(): String{
return if (textView1.toString() == "TextView" &&
password.toString() == "EditText" &&
login.toString() == "Button" &&
passwordField.toString() == "TextView" &&
passwordCaption.toString() == "EditText" &&
loginButton.toString() == "Button")
"OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}

View File

@@ -0,0 +1,37 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
class R {
class id {
class object {
val item_detail_container = 0
val textView1 = 1
val password = 2
val textView2 = 3
val passwordConfirmation = 4
val login = 5
}
}
}
class MyActivity(): Activity() {
val textViewWidget = TextView(this)
val editTextWidget = EditText(this)
val buttonWidget = Button(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.textView1 -> textViewWidget
R.id.password -> editTextWidget
R.id.login -> buttonWidget
else -> null
}
}
}
fun box(): String {
return "OK"
}

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/passwordField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/passwordCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,44 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
class R {
class id {
class object {
val item_detail_container = 0
val textView1 = 1
val password = 2
val textView2 = 3
val passwordConfirmation = 4
val login = 5
}
}
}
class MyActivity(): Activity() {
val textViewWidget = TextView(this)
val editTextWidget = EditText(this)
val buttonWidget = Button(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.textView1 -> textViewWidget
R.id.password -> editTextWidget
R.id.login -> buttonWidget
else -> null
}
}
public fun box(): String{
return if (textView1.toString() == "TextView" &&
password.toString() == "EditText" &&
login.toString() == "Button")
"OK" else ""
}
}
fun box(): String {
return MyActivity().box()
}

View File

@@ -0,0 +1,37 @@
package com.myapp
import android.app.Activity
import android.view.View
import android.widget.*
class R {
class id {
class object {
val item_detail_container = 0
val textView1 = 1
val password = 2
val textView2 = 3
val passwordConfirmation = 4
val login = 5
}
}
}
class MyActivity(): Activity() {
val textViewWidget = TextView(this)
val editTextWidget = EditText(this)
val buttonWidget = Button(this)
override fun findViewById(id: Int): View? {
return when (id) {
R.id.textView1 -> textViewWidget
R.id.password -> editTextWidget
R.id.login -> buttonWidget
else -> null
}
}
}
fun box(): String {
return "OK"
}

View File

@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="android"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
</manifest>

View File

@@ -0,0 +1,11 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
val button = this.MyButton
}
// 1 GETSTATIC
// 1 INVOKEVIRTUAL
// 1 CHECKCAST

View File

@@ -0,0 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<view
class="android.widget.Button"
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,12 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
val button = this.MyButton
}
// 1 GETSTATIC
// 1 INVOKEVIRTUAL
// 1 CHECKCAST

View File

@@ -0,0 +1,14 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<android.widget.Button
android:id="@+id/MyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,13 @@
package com.myapp
import android.app.Activity
class MyActivity: Activity() {
val button = this.login
val button1 = this.loginButton
}
// 2 GETSTATIC
// 2 INVOKEVIRTUAL
// 2 CHECKCAST

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,29 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/passwordField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter your password" />
<EditText
android:id="@+id/passwordCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,17 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_detail_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetailActivity"
tools:ignore="MergeRootFrame" >
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in" />
</FrameLayout>

View File

@@ -0,0 +1,14 @@
package com.myapp
import android.app.Activity
import android.os.Bundle
import java.io.File
public class MyActivity : Activity() {
{login}
}
// 1 GETSTATIC
// 1 INVOKEVIRTUAL
// 1 CHECKCAST

View File

@@ -19,6 +19,7 @@
<orderEntry type="module" module-name="serialization.java" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="builtins-serializer" />
<orderEntry type="module" module-name="android-compiler-plugin" />
</component>
</module>

View File

@@ -160,7 +160,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
blackBox();
}
private void blackBox() {
protected void blackBox() {
// If there are many files, the first of them should contain the 'box(): String' function
JetFile firstFile = myFiles.getPsiFiles().get(0);
String fqName = getPackageClassFqName(firstFile.getPackageFqName()).asString();

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.android
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest
import org.jetbrains.jet.ConfigurationKind
import org.jetbrains.jet.TestJdkKind
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
import org.jetbrains.jet.JetTestUtils
import java.util.Collections
import com.intellij.util.ArrayUtil
import com.intellij.openapi.util.io.FileUtil
import java.io.File
import java.util.ArrayList
import com.intellij.util.Processor
import org.jetbrains.jet.codegen.CodegenTestFiles
import java.util.regex.Pattern
import org.jetbrains.jet.config.CompilerConfiguration
import org.jetbrains.kotlin.android.AndroidConfigurationKeys
public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
private fun createAndroidAPIEnvironment(path: String) {
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
}
private fun createFakeAndroidEnvironment(path: String) {
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path)
}
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, path + "layout/");
configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, path + "AndroidManifest.xml");
myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration);
}
public fun doCompileAgainstAndroidSdkTest(path: String) {
createAndroidAPIEnvironment(path)
doMultiFileTest(path)
}
public fun doFakeInvocationTest(path: String) {
if (needsInvocationTest(path)) {
createFakeAndroidEnvironment(path)
doMultiFileTest(path, getFakeFiles(path))
}
}
private fun getFakeFiles(path: String): Collection<String> {
return FileUtil.findFilesByMask(Pattern.compile("^Fake.*\\.kt$"), File(path.replace(getTestName(true), ""))) map { relativePath(it) }
}
private fun needsInvocationTest(path: String): Boolean {
return !FileUtil.findFilesByMask(Pattern.compile("^0.kt$"), File(path)).empty
}
private fun doMultiFileTest(path: String, additionalFiles: Collection<String>? = null) {
val files = ArrayList<String>(2)
FileUtil.processFilesRecursively(File(path), object : Processor<File> {
override fun process(file: File?): Boolean {
when (file!!.getName()) {
"1.kt" -> { if (additionalFiles == null) files.add(relativePath(file)) }
"0.kt" -> { if (additionalFiles != null) files.add(relativePath(file)) }
else -> { if (file.getName().endsWith(".kt")) files.add(relativePath(file)) }
}
return true
}
})
Collections.sort(files);
if (additionalFiles != null) {
files.addAll(additionalFiles)
}
myFiles = CodegenTestFiles.create(myEnvironment!!.getProject(), ArrayUtil.toStringArray(files))
blackBox();
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.android
import org.jetbrains.jet.codegen.AbstractBytecodeTextTest
import org.jetbrains.jet.JetTestUtils
import org.jetbrains.jet.ConfigurationKind
import org.jetbrains.jet.TestJdkKind
import org.jetbrains.jet.config.CompilerConfiguration
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
import org.jetbrains.kotlin.android.AndroidConfigurationKeys
public abstract class AbstractAndroidBytecodePersistenceTest : AbstractBytecodeTextTest() {
private fun createAndroidAPIEnvironment(path: String) {
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.ANDROID_API), path)
}
private fun createFakeAndroidEnvironment(path: String) {
return createEnvironmentForConfiguration(JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK), path)
}
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, path + "res/layout/");
configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, path + "../AndroidManifest.xml");
myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration);
}
public override fun doTest(path: String) {
val fileName = path + getTestName(true) + ".kt"
createAndroidAPIEnvironment(path)
loadFileByFullPath(fileName)
val expected = readExpectedOccurrences(fileName)
countAndCompareActualOccurrences(expected)
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.android
import com.intellij.testFramework.UsefulTestCase
import java.io.File
import java.io.IOException
import java.util.Scanner
import java.io.FileWriter
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
import org.jetbrains.jet.config.CompilerConfiguration
import org.jetbrains.jet.JetTestUtils
import org.jetbrains.jet.ConfigurationKind
import org.jetbrains.jet.TestJdkKind
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys
import org.junit.Assert
import kotlin.test.fail
public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() {
public fun doTest(path: String) {
val jetCoreEnvironment = getEnvironment(path)
val parser = CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
val actual = parser.parseToString()
JetTestUtils.assertEqualsToFile(File(path + "/layout.kt"), actual!!)
}
public fun doNoManifestTest(path: String) {
try {
doTest(path)
fail("NoAndroidManifestFound not thrown")
}
catch (e: AndroidUIXmlProcessor.NoAndroidManifestFound) {
}
}
private fun getEnvironment(testPath: String): JetCoreEnvironment {
val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK)
// configuration.put<String>(JVMConfigurationKeys.ANDROID_RES_PATH, testPath + "/layout")
// configuration.put<String>(JVMConfigurationKeys.ANDROID_MANIFEST, testPath + "/AndroidManifest.xml")
return JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration)
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.android;
import com.intellij.testFramework.TestDataPath;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@InnerTestClasses({AndroidBoxTestGenerated.Android.class, AndroidBoxTestGenerated.Invoke.class})
public class AndroidBoxTestGenerated extends AbstractAndroidBoxTest {
@TestMetadata("compiler/testData/codegen/android")
@TestDataPath("$PROJECT_ROOT")
public static class Android extends AbstractAndroidBoxTest {
public void testAllFilesPresentInAndroid() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/fqNameInAttr/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/fqNameInTag/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("manyWidgets")
public void testManyWidgets() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/manyWidgets/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/multiFile/");
doCompileAgainstAndroidSdkTest(fileName);
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/singleFile/");
doCompileAgainstAndroidSdkTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/android")
@TestDataPath("$PROJECT_ROOT")
public static class Invoke extends AbstractAndroidBoxTest {
public void testAllFilesPresentInInvoke() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/android"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/fqNameInAttr/");
doFakeInvocationTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/fqNameInTag/");
doFakeInvocationTest(fileName);
}
@TestMetadata("manyWidgets")
public void testManyWidgets() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/manyWidgets/");
doFakeInvocationTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/multiFile/");
doFakeInvocationTest(fileName);
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/android/singleFile/");
doFakeInvocationTest(fileName);
}
}
public static Test suite() {
TestSuite suite = new TestSuite("AndroidBoxTestGenerated");
suite.addTestSuite(Android.class);
suite.addTestSuite(Invoke.class);
return suite;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.android;
import com.intellij.testFramework.TestDataPath;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/androidPersistence")
@TestDataPath("$PROJECT_ROOT")
public class AndroidBytecodePersistenceTestGenerated extends AbstractAndroidBytecodePersistenceTest {
public void testAllFilesPresentInAndroidPersistence() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/androidPersistence"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/fqNameInAttr/");
doTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/fqNameInTag/");
doTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/multiFile/");
doTest(fileName);
}
@TestMetadata("simple")
public void testSimple() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/androidPersistence/simple/");
doTest(fileName);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.android;
import com.intellij.testFramework.TestDataPath;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@InnerTestClasses({AndroidXml2KConversionTestGenerated.Simple.class, AndroidXml2KConversionTestGenerated.Exceptions.class})
public class AndroidXml2KConversionTestGenerated extends AbstractAndroidXml2KConversionTest {
@TestMetadata("compiler/testData/android/converter/simple")
@TestDataPath("$PROJECT_ROOT")
public static class Simple extends AbstractAndroidXml2KConversionTest {
public void testAllFilesPresentInSimple() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/android/converter/simple"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("fqNameInAttr")
public void testFqNameInAttr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/android/converter/simple/fqNameInAttr/");
doTest(fileName);
}
@TestMetadata("fqNameInTag")
public void testFqNameInTag() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/android/converter/simple/fqNameInTag/");
doTest(fileName);
}
@TestMetadata("multiFile")
public void testMultiFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/android/converter/simple/multiFile/");
doTest(fileName);
}
@TestMetadata("noIds")
public void testNoIds() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/android/converter/simple/noIds/");
doTest(fileName);
}
@TestMetadata("singleFile")
public void testSingleFile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/android/converter/simple/singleFile/");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/android/converter/exceptions")
@TestDataPath("$PROJECT_ROOT")
public static class Exceptions extends AbstractAndroidXml2KConversionTest {
public void testAllFilesPresentInExceptions() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/android/converter/exceptions"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("noManifest")
public void testNoManifest() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/android/converter/exceptions/noManifest/");
doNoManifestTest(fileName);
}
}
public static Test suite() {
TestSuite suite = new TestSuite("AndroidXml2KConversionTestGenerated");
suite.addTestSuite(Simple.class);
suite.addTestSuite(Exceptions.class);
return suite;
}
}

View File

@@ -24,6 +24,7 @@
<orderEntry type="library" scope="TEST" name="kotlin-runtime" level="project" />
<orderEntry type="library" scope="TEST" name="jps-test" level="project" />
<orderEntry type="module" module-name="js.dart-ast" />
<orderEntry type="module" module-name="android-compiler-plugin" scope="TEST" />
</component>
</module>

View File

@@ -123,6 +123,15 @@ import org.jetbrains.jet.completion.weighers.AbstractBasicCompletionWeigherTest
import org.jetbrains.jet.completion.weighers.AbstractSmartCompletionWeigherTest
import org.jetbrains.jet.generators.tests.reservedWords.generateTestDataForReservedWords
import org.jetbrains.k2js.test.semantics.AbstractReservedWordTest
import org.jetbrains.jet.lang.resolve.android.AbstractAndroidXml2KConversionTest
import org.jetbrains.jet.android.AbstractCrossParserTest
import org.jetbrains.jet.lang.resolve.android.AbstractAndroidBoxTest
import org.jetbrains.jet.android.AbstractAndroidCompletionTest
import org.jetbrains.jet.android.AbstractAndroidGotoTest
import org.jetbrains.jet.jps.build.android.AbstractAndroidJpsTestCase
import org.jetbrains.jet.android.AbstractAndroidRenameTest
import org.jetbrains.jet.android.AbstractAndroidFindUsagesTest
import org.jetbrains.jet.lang.resolve.android.AbstractAndroidBytecodePersistenceTest
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
@@ -287,6 +296,20 @@ fun main(args: Array<String>) {
testClass(javaClass<AbstractKotlinLightClassTest>()) {
model("asJava/lightClasses")
}
testClass(javaClass<AbstractAndroidXml2KConversionTest>()) {
model("android/converter/simple", recursive = false, extension = null)
model("android/converter/exceptions", recursive = false, extension = null, testMethod = "doNoManifestTest")
}
testClass(javaClass<AbstractAndroidBoxTest>()) {
model("codegen/android", recursive = false, extension = null, testMethod = "doCompileAgainstAndroidSdkTest")
model("codegen/android", recursive = false, extension = null, testMethod = "doFakeInvocationTest", testClassName = "Invoke")
}
testClass(javaClass<AbstractAndroidBytecodePersistenceTest>()) {
model("codegen/androidPersistence", recursive = false, extension = null)
}
}
testGroup("idea/tests", "idea/testData") {
@@ -606,6 +629,26 @@ fun main(args: Array<String>) {
testClass(javaClass<AbstractSelectExpressionForDebuggerTest>()) {
model("debugger/selectExpression")
}
testClass(javaClass<AbstractCrossParserTest>()) {
model("android/crossParser", recursive = false, extension = null)
}
testClass(javaClass<AbstractAndroidCompletionTest>()) {
model("android/completion", recursive = false, extension = null)
}
testClass(javaClass<AbstractAndroidGotoTest>()) {
model("android/goto", recursive = false, extension = null)
}
testClass(javaClass<AbstractAndroidRenameTest>()) {
model("android/rename", recursive = false, extension = null)
}
testClass(javaClass<AbstractAndroidFindUsagesTest>()) {
model("android/findUsages", recursive = false, extension = null)
}
}
testGroup("idea/tests", "compiler/testData") {
@@ -624,6 +667,10 @@ fun main(args: Array<String>) {
testClass(javaClass<AbstractIncrementalJpsTest>()) {
model("incremental", extension = null, excludeParentDirs = true)
}
testClass(javaClass<AbstractAndroidJpsTestCase>()) {
model("android", recursive = false, extension = null)
}
}
generateTestDataForReservedWords()

View File

@@ -16,12 +16,13 @@
package org.jetbrains.jet.plugin;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetCodeFragment;
import org.jetbrains.jet.plugin.configuration.JetModuleTypeManager;
public class ProjectRootsUtil {
@@ -29,8 +30,15 @@ public class ProjectRootsUtil {
return isInSource(element, true);
}
public static boolean isInSource(@NotNull PsiElement element, boolean includeLibrarySources) {
PsiFile containingFile = element.getContainingFile();
public static boolean isInSource(@NotNull final PsiElement element, boolean includeLibrarySources) {
PsiFile containingFile = ApplicationManager.getApplication().runReadAction(
new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return element.getContainingFile();
}
}
);
if (containingFile == null) {
return false;
}
@@ -38,7 +46,7 @@ public class ProjectRootsUtil {
if (virtualFile == null) {
return false;
}
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(element.getProject());
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(containingFile.getProject());
return includeLibrarySources ? index.isInSource(virtualFile) : index.isInSourceContent(virtualFile);
}

View File

@@ -36,12 +36,12 @@ public fun warnTimeConsuming(logger: Logger) {
Throwable().printStackTrace()
}
public fun runReadAction<T: Any>(action: () -> T?): T? {
return ApplicationManager.getApplication()?.runReadAction<T>(action)
public fun runReadAction<T>(action: () -> T): T {
return ApplicationManager.getApplication()?.runReadAction<T>(action) as T
}
public fun runWriteAction<T: Any>(action: () -> T?): T? {
return ApplicationManager.getApplication()?.runWriteAction<T>(action)
public fun runWriteAction<T>(action: () -> T): T {
return ApplicationManager.getApplication()?.runWriteAction<T>(action) as T
}
public fun Project.executeWriteCommand(name: String, command: () -> Unit) {

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/META-INF/plugin.xml" />
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/../lib/asm-util-3.3.1.jar!/" />
<src_description expected_position="1">
@@ -42,6 +41,7 @@
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="eval4j" />
<orderEntry type="module" module-name="idea-analysis" exported="" />
<orderEntry type="module" module-name="android-idea-plugin" />
</component>
</module>

View File

@@ -804,6 +804,15 @@
<extensionPoints>
<extensionPoint name="updater" beanClass="com.intellij.openapi.fileTypes.FileTypeExtensionPoint"/>
<extensionPoint name="projectConfigurator" interface="org.jetbrains.jet.plugin.configuration.KotlinProjectConfigurator"/>
<extensionPoint name="externalDeclarationsProvider"
interface="org.jetbrains.jet.extensions.ExternalDeclarationsProvider"
area="IDEA_PROJECT"/>
<extensionPoint name="expressionCodegenExtension"
interface="org.jetbrains.jet.codegen.extensions.ExpressionCodegenExtension"
area="IDEA_PROJECT"/>
<extensionPoint name="findUsagesHandlerDecorator"
interface="org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindUsagesHandlerDecorator"
area="IDEA_PROJECT"/>
</extensionPoints>
<extensions defaultExtensionNs="org.jetbrains.kotlin">

View File

@@ -31,15 +31,15 @@ import org.jetbrains.jet.plugin.findUsages.handlers.KotlinTypeParameterFindUsage
import org.jetbrains.jet.lang.psi.JetParameter
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
import org.jetbrains.jet.lang.psi.JetClassOrObject
import com.intellij.find.findUsages.FindUsagesManager
import com.intellij.find.findUsages.JavaFindUsagesHandlerFactory
import com.intellij.psi.PsiMethod
import org.jetbrains.jet.plugin.findUsages.handlers.DelegatingFindMemberUsagesHandler
import com.intellij.openapi.extensions.Extensions
import org.jetbrains.jet.plugin.findUsages.handlers.KotlinFindUsagesHandlerDecorator
public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactory() {
val javaHandlerFactory = JavaFindUsagesHandlerFactory(project)
val findFunctionOptions = KotlinFunctionFindUsagesOptions(project)
public val findFunctionOptions: KotlinFunctionFindUsagesOptions = KotlinFunctionFindUsagesOptions(project)
val findPropertyOptions = KotlinPropertyFindUsagesOptions(project)
val findClassOptions = KotlinClassFindUsagesOptions(project)
val defaultOptions = FindUsagesOptions(project)
@@ -52,25 +52,31 @@ public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandle
element is JetTypeParameter
public override fun createFindUsagesHandler(element: PsiElement, forHighlightUsages: Boolean): FindUsagesHandler? {
when(element) {
val handler = when (element) {
is JetClassOrObject ->
return KotlinFindClassUsagesHandler(element, this)
KotlinFindClassUsagesHandler(element, this)
is JetNamedFunction, is JetProperty, is JetParameter -> {
val declaration = element as JetNamedDeclaration
if (forHighlightUsages) return KotlinFindMemberUsagesHandler.getInstance(declaration, this)
return JetRefactoringUtil.checkSuperMethods(declaration, null, "super.methods.action.key.find.usages")?.let { callables ->
JetRefactoringUtil.checkSuperMethods(declaration, null, "super.methods.action.key.find.usages")?.let { callables ->
if (callables.empty) FindUsagesHandler.NULL_HANDLER else DelegatingFindMemberUsagesHandler(declaration, callables, this)
}
}
is JetTypeParameter ->
return KotlinTypeParameterFindUsagesHandler(element, this)
KotlinTypeParameterFindUsagesHandler(element, this)
else ->
throw IllegalArgumentException("unexpected element type: " + element)
}
for (decorator in Extensions.getArea(element.getProject()).getExtensionPoint(KotlinFindUsagesHandlerDecorator.EP_NAME).getExtensions()) {
val decorated = decorator.decorateHandler(element, forHighlightUsages, handler!!)
if (decorated != handler) return decorated
}
return handler
}
}

View File

@@ -26,10 +26,17 @@ import kotlin.properties.Delegates
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
import com.intellij.psi.PsiMethod
import com.intellij.find.findUsages.JavaFindUsagesHandler
import com.intellij.find.findUsages.JavaMethodFindUsagesOptions
import org.jetbrains.jet.plugin.findUsages.KotlinFunctionFindUsagesOptions
import org.jetbrains.jet.plugin.findUsages.toJavaMethodOptions
import com.intellij.openapi.actionSystem.DataContext
import org.jetbrains.jet.lang.resolve.android.isAndroidSyntheticElement
import com.intellij.openapi.components.ServiceManager
import org.jetbrains.jet.lang.resolve.android.AndroidUIXmlProcessor
import com.intellij.psi.xml.XmlAttribute
import org.jetbrains.jet.lang.psi.JetProperty
import org.jetbrains.android.util.AndroidResourceUtil
import java.util.ArrayList
import com.intellij.find.findUsages.JavaVariableFindUsagesOptions
class DelegatingFindMemberUsagesHandler(
val declaration: JetNamedDeclaration,
@@ -42,7 +49,7 @@ class DelegatingFindMemberUsagesHandler(
JavaFindUsagesHandler(declaration, elementsToSearch.copyToArray(), factory.javaHandlerFactory)
}
fun getHandler(element: PsiElement): FindUsagesHandler? =
private fun getHandler(element: PsiElement): FindUsagesHandler? =
when (element) {
is JetNamedDeclaration ->
KotlinFindMemberUsagesHandler.getInstance(element, elementsToSearch, factory)
@@ -53,8 +60,9 @@ class DelegatingFindMemberUsagesHandler(
else -> null
}
override fun getPrimaryElements(): Array<PsiElement> =
kotlinHandler.getPrimaryElements()
override fun getPrimaryElements(): Array<PsiElement> {
return kotlinHandler.getPrimaryElements()
}
override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions {
return kotlinHandler.getFindUsagesOptions(dataContext)

Some files were not shown because too many files have changed in this diff Show More