Move AndroidPsiTreeChangePreprocessor to android-idea-plugin module
This commit is contained in:
@@ -681,7 +681,6 @@
|
||||
</src>
|
||||
<classpath>
|
||||
<pathelement path="${idea.sdk}/core/intellij-core.jar"/>
|
||||
<pathelement path="${idea.sdk}/core-analysis/intellij-core-analysis.jar"/>
|
||||
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
||||
<pathelement path="${bootstrap.runtime}"/>
|
||||
</classpath>
|
||||
|
||||
@@ -19,6 +19,5 @@
|
||||
<orderEntry type="library" scope="TEST" name="jps-test" level="project" />
|
||||
<orderEntry type="module" module-name="compiler-tests" scope="TEST" />
|
||||
<orderEntry type="library" name="intellij-core" level="project" />
|
||||
<orderEntry type="library" name="intellij-core-analysis" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -80,8 +80,6 @@ public class AndroidComponentRegistrar : ComponentRegistrar {
|
||||
|
||||
ExternalDeclarationsProvider.registerExtension(project, CliAndroidDeclarationsProvider(project))
|
||||
ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegenExtension())
|
||||
Extensions.getArea(project).getExtensionPoint(
|
||||
PsiTreeChangePreprocessor.EP_NAME).registerExtension(AndroidPsiTreeChangePreprocessor())
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -62,13 +62,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
public abstract val resourceManager: AndroidResourceManager
|
||||
|
||||
public abstract val psiTreeChangePreprocessor: PsiTreeChangePreprocessor
|
||||
|
||||
private val cachedSources: CachedValue<List<String>> by Delegates.lazy {
|
||||
cachedValue {
|
||||
Result.create(parse(), psiTreeChangePreprocessor)
|
||||
}
|
||||
}
|
||||
protected abstract val cachedSources: CachedValue<List<String>>
|
||||
|
||||
private val cachedJetFiles: CachedValue<List<JetFile>> by Delegates.lazy {
|
||||
cachedValue {
|
||||
@@ -151,7 +145,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
|
||||
|
||||
private fun renderClearCacheFunction(receiver: String) = "public fun $receiver.${AndroidConst.CLEAR_FUNCTION_NAME}() {}\n"
|
||||
|
||||
private fun <T> cachedValue(result: () -> CachedValueProvider.Result<T>): CachedValue<T> {
|
||||
protected fun <T> cachedValue(result: () -> CachedValueProvider.Result<T>): CachedValue<T> {
|
||||
return CachedValuesManager.getManager(project).createCachedValue(result, false)
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -23,6 +23,9 @@ import java.io.ByteArrayInputStream
|
||||
import kotlin.properties.Delegates
|
||||
import com.intellij.psi.impl.*
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import com.intellij.psi.util.CachedValue
|
||||
import com.intellij.psi.util.CachedValueProvider.Result
|
||||
|
||||
public class CliAndroidUIXmlProcessor(
|
||||
project: Project,
|
||||
@@ -34,8 +37,10 @@ public class CliAndroidUIXmlProcessor(
|
||||
CliAndroidResourceManager(project, manifestPath, mainResDirectory)
|
||||
}
|
||||
|
||||
override val psiTreeChangePreprocessor: PsiTreeChangePreprocessor by Delegates.lazy {
|
||||
project.getExtensions(PsiTreeChangePreprocessor.EP_NAME).first { it is AndroidPsiTreeChangePreprocessor }
|
||||
override val cachedSources: CachedValue<List<String>> by Delegates.lazy {
|
||||
cachedValue {
|
||||
Result.create(parse(), ModificationTracker.NEVER_CHANGED)
|
||||
}
|
||||
}
|
||||
|
||||
override fun parseSingleFile(file: PsiFile): List<AndroidWidget> {
|
||||
|
||||
-2
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.lang.resolve.android.AndroidPsiTreeChangePreprocessor
|
||||
import org.jetbrains.kotlin.lang.resolve.android.CliAndroidUIXmlProcessor
|
||||
|
||||
private class AndroidTestExternalDeclarationsProvider(
|
||||
@@ -54,6 +53,5 @@ fun UsefulTestCase.createAndroidTestEnvironment(
|
||||
val project = myEnvironment.getProject()
|
||||
ExternalDeclarationsProvider.registerExtension(project, AndroidTestExternalDeclarationsProvider(project, resPath, manifestPath))
|
||||
ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegenExtension())
|
||||
Extensions.getArea(project).getExtensionPoint(PsiTreeChangePreprocessor.EP_NAME).registerExtension(AndroidPsiTreeChangePreprocessor())
|
||||
return myEnvironment
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
serviceImplementation="org.jetbrains.kotlin.plugin.android.IDEAndroidResourceManager"/>
|
||||
<compileServer.plugin classpath="jps/kotlin-android-extensions-jps.jar;android-compiler-plugin.jar"/>
|
||||
<gotoDeclarationHandler implementation="org.jetbrains.kotlin.plugin.android.AndroidGotoDeclarationHandler"/>
|
||||
<psi.treeChangePreprocessor implementation="org.jetbrains.kotlin.lang.resolve.android.AndroidPsiTreeChangePreprocessor"/>
|
||||
<psi.treeChangePreprocessor implementation="org.jetbrains.kotlin.plugin.android.AndroidPsiTreeChangePreprocessor"/>
|
||||
<renamePsiElementProcessor id="KotlinAndroidSyntheticProperty"
|
||||
implementation="org.jetbrains.kotlin.plugin.android.AndroidRenameProcessor"
|
||||
order="first"/>
|
||||
|
||||
+6
-7
@@ -14,16 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.lang.resolve.android
|
||||
package org.jetbrains.kotlin.plugin.android
|
||||
|
||||
import com.intellij.ide.highlighter.XmlFileType
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.psi.impl.*
|
||||
import com.intellij.openapi.util.*
|
||||
import com.intellij.openapi.roots.*
|
||||
import com.intellij.openapi.module.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.util.SimpleModificationTracker
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.impl.PsiTreeChangeEventImpl
|
||||
import com.intellij.psi.impl.PsiTreeChangePreprocessor
|
||||
import org.jetbrains.kotlin.lang.resolve.android.AndroidResourceManager
|
||||
|
||||
public class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, SimpleModificationTracker() {
|
||||
|
||||
+9
-1
@@ -24,15 +24,23 @@ import org.jetbrains.kotlin.plugin.android.AndroidXmlVisitor
|
||||
import com.intellij.psi.impl.*
|
||||
import kotlin.properties.*
|
||||
import org.jetbrains.kotlin.lang.resolve.android.*
|
||||
import com.intellij.psi.util.CachedValue
|
||||
import com.intellij.psi.util.CachedValueProvider.Result
|
||||
|
||||
class IDEAndroidUIXmlProcessor(val module: Module) : AndroidUIXmlProcessor(module.getProject()) {
|
||||
|
||||
override val resourceManager: IDEAndroidResourceManager = IDEAndroidResourceManager(module)
|
||||
|
||||
override val psiTreeChangePreprocessor by Delegates.lazy {
|
||||
private val psiTreeChangePreprocessor by Delegates.lazy {
|
||||
module.getProject().getExtensions(PsiTreeChangePreprocessor.EP_NAME).first { it is AndroidPsiTreeChangePreprocessor }
|
||||
}
|
||||
|
||||
override val cachedSources: CachedValue<List<String>> by Delegates.lazy {
|
||||
cachedValue {
|
||||
Result.create(parse(), psiTreeChangePreprocessor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun parseSingleFile(file: PsiFile): List<AndroidWidget> {
|
||||
val widgets = arrayListOf<AndroidWidget>()
|
||||
file.accept(AndroidXmlVisitor({ id, wClass, valueElement ->
|
||||
|
||||
Reference in New Issue
Block a user