Support multi-module configuration in Android plugin
This commit is contained in:
@@ -50,6 +50,7 @@ import org.jetbrains.jet.lang.resolve.lazy.descriptors.LazyClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.analyzer.ModuleInfo
|
||||
|
||||
public object AndroidConfigurationKeys {
|
||||
|
||||
@@ -79,8 +80,8 @@ public class AndroidCommandLineProcessor : CommandLineProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public class AndroidDeclarationsProvider(private val project: Project) : ExternalDeclarationsProvider {
|
||||
override fun getExternalDeclarations(): Collection<JetFile> {
|
||||
public class CliAndroidDeclarationsProvider(private val project: Project) : ExternalDeclarationsProvider {
|
||||
override fun getExternalDeclarations(moduleInfo: ModuleInfo?): Collection<JetFile> {
|
||||
val parser = ServiceManager.getService<AndroidUIXmlProcessor>(project, javaClass<AndroidUIXmlProcessor>())
|
||||
return emptyOrSingletonList(parser?.parseToPsi(project))
|
||||
}
|
||||
@@ -219,7 +220,7 @@ public class AndroidComponentRegistrar : ComponentRegistrar {
|
||||
val androidManifest = configuration.get(AndroidConfigurationKeys.ANDROID_MANIFEST)
|
||||
project.registerService(javaClass<AndroidUIXmlProcessor>(), CliAndroidUIXmlProcessor(project, androidResPath, androidManifest))
|
||||
|
||||
ExternalDeclarationsProvider.registerExtension(project, AndroidDeclarationsProvider(project))
|
||||
ExternalDeclarationsProvider.registerExtension(project, CliAndroidDeclarationsProvider(project))
|
||||
ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegen())
|
||||
}
|
||||
}
|
||||
+2
@@ -47,6 +47,8 @@ import java.util.Queue
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.jet.lang.resolve.android.AndroidConst.*
|
||||
import org.jetbrains.jet.analyzer.ModuleInfo
|
||||
import com.intellij.openapi.module.Module
|
||||
|
||||
public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.myapp
|
||||
package kotlinx.android.synthetic.layout
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.myapp
|
||||
package kotlinx.android.synthetic.layout
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
|
||||
+1
-13
@@ -1,4 +1,4 @@
|
||||
package com.myapp
|
||||
package kotlinx.android.synthetic.layout
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
@@ -16,15 +16,3 @@ val Activity.password: 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
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.myapp
|
||||
package kotlinx.android.synthetic.layout
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.myapp
|
||||
package kotlinx.android.synthetic.layout
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import org.my.cool.MyButton
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import org.my.cool.MyButton
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import org.my.cool.MyButton
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import org.my.cool.MyButton
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.myapp
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
import kotlinx.android.synthetic.layout1.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.myapp
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
import kotlinx.android.synthetic.layout1.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.myapp
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.myapp
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class R {
|
||||
class id {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.MyButton
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.MyButton
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
import kotlinx.android.synthetic.layout1.*
|
||||
|
||||
class MyActivity: Activity() {
|
||||
val button = this.login
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.myapp
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import java.io.File
|
||||
|
||||
import kotlinx.android.synthetic.layout.*
|
||||
|
||||
public class MyActivity : Activity() {
|
||||
{login}
|
||||
|
||||
+4
-3
@@ -28,13 +28,14 @@ import org.jetbrains.kotlin.android.AndroidExpressionCodegen
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.jetbrains.jet.lang.resolve.android.CliAndroidUIXmlProcessor
|
||||
import org.jetbrains.jet.analyzer.ModuleInfo
|
||||
|
||||
private class AndroidTestDeclarationsProvider(
|
||||
private class AndroidTestExternalDeclarationsProvider(
|
||||
val project: Project,
|
||||
val resPath: String,
|
||||
val manifestPath: String
|
||||
) : ExternalDeclarationsProvider {
|
||||
override fun getExternalDeclarations(): Collection<JetFile> {
|
||||
override fun getExternalDeclarations(moduleInfo: ModuleInfo?): Collection<JetFile> {
|
||||
val parser = CliAndroidUIXmlProcessor(project, resPath, manifestPath)
|
||||
return emptyOrSingletonList(parser.parseToPsi(project))
|
||||
}
|
||||
@@ -49,7 +50,7 @@ fun UsefulTestCase.createAndroidTestEnvironment(
|
||||
configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, manifestPath)
|
||||
val myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val project = myEnvironment.getProject()
|
||||
ExternalDeclarationsProvider.registerExtension(project, AndroidTestDeclarationsProvider(project, resPath, manifestPath))
|
||||
ExternalDeclarationsProvider.registerExtension(project, AndroidTestExternalDeclarationsProvider(project, resPath, manifestPath))
|
||||
ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegen())
|
||||
return myEnvironment
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user