optimize imports
This commit is contained in:
committed by
Yan Zhulanow
parent
19e6b79cae
commit
a56fa7f192
+3
-1
@@ -21,7 +21,9 @@
|
||||
<ConfigurationWrapper RunnerId="Debug" />
|
||||
<ConfigurationWrapper RunnerId="Run" />
|
||||
<method>
|
||||
<option name="BuildArtifacts" enabled="true" />
|
||||
<option name="BuildArtifacts" enabled="true">
|
||||
<artifact name="KotlinPlugin" />
|
||||
</option>
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
+2
-1
@@ -29,7 +29,8 @@ abstract class AndroidResourceManagerBase(project: Project, searchPath: String?)
|
||||
val fileManager = VirtualFileManager.getInstance()
|
||||
val watchDir = fileManager.findFileByUrl("file://" + searchPath)
|
||||
val psiManager = PsiManager.getInstance(project)
|
||||
return watchDir?.getChildren()?.toArrayList()?.map { psiManager.findFile(it) }?.mapNotNull { it } ?: ArrayList(0)
|
||||
val files = watchDir?.getChildren()?.toArrayList()?.map { psiManager.findFile(it) }?.mapNotNull { it } ?: ArrayList(0)
|
||||
return files.sortBy({it.getName()})
|
||||
}
|
||||
|
||||
protected fun vritualFileToPsi(vf: VirtualFile): PsiFile? {
|
||||
|
||||
+6
-6
@@ -47,9 +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 com.intellij.openapi.application.ApplicationManager
|
||||
|
||||
abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
class NoAndroidManifestFound : Exception("No android manifest file found in project root")
|
||||
|
||||
@@ -69,6 +68,8 @@ abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
protected val filesToProcess: Queue<PsiFile> = ConcurrentLinkedQueue()
|
||||
|
||||
public abstract val resourceManager: AndroidResourceManager
|
||||
|
||||
protected val LOG: Logger = Logger.getInstance(this.javaClass)
|
||||
|
||||
public fun parseToString(): String? {
|
||||
@@ -77,7 +78,6 @@ abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
return renderString()
|
||||
}
|
||||
|
||||
public abstract val resourceManager: AndroidResourceManager
|
||||
|
||||
public fun parseToPsi(project: Project): JetFile? {
|
||||
val cacheState = doParse()
|
||||
@@ -121,7 +121,7 @@ abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
return res
|
||||
}
|
||||
|
||||
abstract fun parseSingleFileImpl(file: PsiFile): String
|
||||
protected abstract fun parseSingleFileImpl(file: PsiFile): String
|
||||
|
||||
private fun doParse(): CacheAction? {
|
||||
if (searchPath == null || searchPath == "") return null
|
||||
@@ -138,8 +138,8 @@ abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
private fun renderString(): String {
|
||||
val buffer = writeImports(KotlinStringWriter()).output()
|
||||
for (buf in fileCache.values())
|
||||
buffer.append(buf)
|
||||
for (buf in fileCache.entrySet().sortBy({it.key.getName()}))
|
||||
buffer.append(buf.value)
|
||||
return buffer.toString()
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,6 @@ fun isAndroidSyntheticFile(f: PsiFile?): Boolean {
|
||||
return f?.getUserData(AndroidConst.ANDROID_USER_PACKAGE) != null
|
||||
}
|
||||
|
||||
fun isAndroidSyntheticElement(element: PsiElement?): Boolean {
|
||||
public fun isAndroidSyntheticElement(element: PsiElement?): Boolean {
|
||||
return isAndroidSyntheticFile(element?.getContainingFile())
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
+59
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.JetTestUtils
|
||||
import org.jetbrains.jet.ConfigurationKind
|
||||
import org.jetbrains.jet.TestJdkKind
|
||||
import org.jetbrains.jet.plugin.android.IDEAndroidUIXmlProcessor
|
||||
|
||||
public abstract class AbstractCrossParserTest : UsefulTestCase() {
|
||||
public fun doTest(path: String) {
|
||||
val jetCoreEnvironment = getEnvironment(path)
|
||||
val cliParser = CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
|
||||
// val ideParser = IDEAndroidUIXmlProcessor(jetCoreEnvironment.getProject(), path + "/layout", path + "AndroidManifest.xml")
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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 junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.lang.resolve.android.AbstractAndroidXml2KConversionTest;
|
||||
|
||||
/** 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")
|
||||
public static class Simple extends AbstractAndroidXml2KConversionTest {
|
||||
public void testAllFilesPresentInSimple() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/android/converter/simple"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInAttr")
|
||||
public void testFqNameInAttr() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/fqNameInAttr/");
|
||||
}
|
||||
|
||||
@TestMetadata("fqNameInTag")
|
||||
public void testFqNameInTag() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/fqNameInTag/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiFile")
|
||||
public void testMultiFile() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/multiFile/");
|
||||
}
|
||||
|
||||
@TestMetadata("noIds")
|
||||
public void testNoIds() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/noIds/");
|
||||
}
|
||||
|
||||
@TestMetadata("singleFile")
|
||||
public void testSingleFile() throws Exception {
|
||||
doTest("compiler/testData/android/converter/simple/singleFile/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/android/converter/exceptions")
|
||||
public static class Exceptions extends AbstractAndroidXml2KConversionTest {
|
||||
public void testAllFilesPresentInExceptions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/android/converter/exceptions"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("noManifest")
|
||||
public void testNoManifest() throws Exception {
|
||||
doNoManifestTest("compiler/testData/android/converter/exceptions/noManifest/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("AndroidXml2KConversionTestGenerated");
|
||||
suite.addTestSuite(Simple.class);
|
||||
suite.addTestSuite(Exceptions.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.android;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.*;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
@@ -34,7 +35,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
public class AndroidXmlTest extends UsefulTestCase {
|
||||
|
||||
private static final String singleFilePrefix = getTestDataPath() + "/converter/singleFile/";
|
||||
public static final String singleFileManifestPath = singleFilePrefix + "AndroidManifest.xml";
|
||||
@@ -94,6 +95,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
List<File> files = addDefaultFiles();
|
||||
|
||||
compileManyFilesGetGenerationState(files, singleFileResPath);
|
||||
// TODO: why?
|
||||
Disposer.dispose(getTestRootDisposable());
|
||||
}
|
||||
|
||||
@@ -107,6 +109,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
return files;
|
||||
}
|
||||
|
||||
// TODO: many tests
|
||||
public void testConverterOneFile() throws Exception {
|
||||
JetCoreEnvironment jetCoreEnvironment = getEnvironment(singleFileResPath);
|
||||
AndroidUIXmlProcessor parser = new CliAndroidUIXmlProcessor(jetCoreEnvironment.getProject(),
|
||||
@@ -119,6 +122,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
// todo: unify with box tests
|
||||
public void testGeneratedByteCode() throws Exception {
|
||||
|
||||
String resPath = getTestDataPath() + "/converter/singleFile/res/layout/";
|
||||
@@ -130,6 +134,7 @@ public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
classLoader.loadFiles();
|
||||
Class<?> activity = classLoader.findClass("com.myapp.MyActivity");
|
||||
String res =(String) activity.getMethod("test").invoke(activity.newInstance());
|
||||
// todo: why?
|
||||
Disposer.dispose(getTestRootDisposable());
|
||||
assertEquals("OK", res);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
|
||||
// todo: get rid of this class
|
||||
public class ByteArrayClassLoader extends URLClassLoader {
|
||||
|
||||
private final Queue<OutputFile> q;
|
||||
|
||||
@@ -142,6 +142,7 @@ import org.jetbrains.kotlin.completion.handlers.AbstractKeywordCompletionHandler
|
||||
import org.jetbrains.kotlin.idea.kdoc.AbstractKDocHighlightingTest
|
||||
import org.jetbrains.kotlin.addImport.AbstractAddImportTest
|
||||
import org.jetbrains.kotlin.idea.highlighter.*
|
||||
import org.jetbrains.jet.lang.resolve.android.AbstractAndroidXml2KConversionTest
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
@@ -313,6 +314,11 @@ fun main(args: Array<String>) {
|
||||
testClass(javaClass<AbstractLocalClassProtoTest>()) {
|
||||
model("serialization/local")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractAndroidXml2KConversionTest>()) {
|
||||
model("android/converter/simple", recursive = false, extension = null)
|
||||
model("android/converter/exceptions", recursive = false, extension = null, testMethod = "doNoManifestTest")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/tests", "idea/testData") {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="EclipseModuleManager">
|
||||
<libelement value="jar://$MODULE_DIR$/../lib/asm-util-3.3.1.jar!/" />
|
||||
<src_description expected_position="1">
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.intellij.psi.PsiElement
|
||||
import java.util.HashMap
|
||||
import com.intellij.psi.xml.XmlAttribute
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.android.util.AndroidResourceUtil
|
||||
import org.jetbrains.jps.android.AndroidJpsUtil
|
||||
import org.jetbrains.android.facet.AndroidFacet
|
||||
import org.jetbrains.jet.lang.resolve.android.AndroidManifest
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
@@ -31,7 +29,11 @@ import java.util.ArrayList
|
||||
|
||||
public class IDEAndroidResourceManager(project: Project, searchPath: String?) : AndroidResourceManagerBase(project, searchPath) {
|
||||
|
||||
class NoAndroidFacetException: Exception("No android facet found in project")
|
||||
private class NoAndroidFacetException: Exception("No android facet found in project")
|
||||
|
||||
// TODO: synchronize!
|
||||
// TODO: invalidate on modification?
|
||||
private val idToXmlAttributeCache = HashMap<String, PsiElement>()
|
||||
|
||||
override fun getLayoutXmlFiles(): Collection<PsiFile> {
|
||||
try {
|
||||
@@ -56,8 +58,6 @@ public class IDEAndroidResourceManager(project: Project, searchPath: String?) :
|
||||
return AndroidManifest(attributeValue!!.getRawText()!!)
|
||||
}
|
||||
|
||||
private val idToXmlAttributeCache = HashMap<String, PsiElement>()
|
||||
|
||||
public fun addMapping(name: String, attr: XmlAttribute) {
|
||||
idToXmlAttributeCache[name] = attr
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.jet.lang.resolve.android.AndroidWidget
|
||||
import org.jetbrains.jet.lang.resolve.android.KotlinStringWriter
|
||||
import com.intellij.openapi.application.Application
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.jet.lang.resolve.android.CliAndroidResourceManager
|
||||
import org.jetbrains.jet.lang.resolve.android.AndroidResourceManager
|
||||
|
||||
@@ -16,15 +16,9 @@
|
||||
|
||||
package org.jetbrains.jet.android;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.completion.AbstractJvmBasicCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractJvmSmartCompletionTest;
|
||||
import org.jetbrains.jet.completion.AbstractMultiFileJvmBasicCompletionTest;
|
||||
import org.jetbrains.jet.completion.JetFixtureCompletionBaseTestCase;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.plugin.android.TestConst;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
@TestMetadata("idea/testData/android/completion/")
|
||||
|
||||
Reference in New Issue
Block a user