mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[uast tests] refactoring: move java-specific code away from intellij.platform.uast.testFramework module
...and remove dependency on intellij.java.uast from it. GitOrigin-RevId: 05fdf2279cbf3aaa1394d2c3a14163620a936b4c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3a58bfc028
commit
69115d62d6
@@ -12,6 +12,5 @@
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.java.testFramework" />
|
||||
<orderEntry type="module" module-name="intellij.platform.vcs.impl" />
|
||||
<orderEntry type="module" module-name="intellij.java.uast" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.uast.testFramework.common
|
||||
|
||||
import com.intellij.testFramework.assertEqualsToFile
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UExpression
|
||||
import org.jetbrains.uast.UFile
|
||||
@@ -8,8 +9,6 @@ import org.jetbrains.uast.evaluation.MapBasedEvaluationContext
|
||||
import org.jetbrains.uast.evaluation.UEvaluationContext
|
||||
import org.jetbrains.uast.evaluation.UEvaluatorExtension
|
||||
import org.jetbrains.uast.evaluation.analyzeAll
|
||||
import org.jetbrains.uast.java.JavaUFile
|
||||
import com.intellij.testFramework.assertEqualsToFile
|
||||
import org.jetbrains.uast.visitor.UastVisitor
|
||||
import java.io.File
|
||||
|
||||
@@ -17,9 +16,6 @@ interface ValuesTestBase {
|
||||
fun getTestDataPath(): String
|
||||
fun getEvaluatorExtension(): UEvaluatorExtension? = null
|
||||
|
||||
// TODO: when JavaUFile (and/or its constructor) becomes `internal`, this should move into JavaUFile.
|
||||
private fun JavaUFile.copy() : JavaUFile = JavaUFile(sourcePsi, languagePlugin)
|
||||
|
||||
private fun UFile.analyzeAll() = analyzeAll(extensions = getEvaluatorExtension()?.let { listOf(it) } ?: emptyList())
|
||||
|
||||
private fun UFile.asLogValues(evaluationContext: UEvaluationContext, cachedOnly: Boolean) =
|
||||
@@ -33,12 +29,14 @@ interface ValuesTestBase {
|
||||
val evaluationContext = file.analyzeAll()
|
||||
assertEqualsToFile("Log values", valuesFile, file.asLogValues(evaluationContext, cachedOnly = false))
|
||||
|
||||
if (file is JavaUFile) {
|
||||
val copyFile = file.copy()
|
||||
val copyFile = createCopyToCheck(file)
|
||||
if (copyFile != null) {
|
||||
assertEqualsToFile("Log cached values", valuesFile, copyFile.asLogValues(evaluationContext, cachedOnly = true))
|
||||
}
|
||||
}
|
||||
|
||||
fun createCopyToCheck(file: UFile): UFile? = null
|
||||
|
||||
class ValueLogger(private val evaluationContext: UEvaluationContext, private val cachedOnly: Boolean) : UastVisitor {
|
||||
private val builder = StringBuilder()
|
||||
private var level = 0
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.uast.test.java
|
||||
|
||||
import org.jetbrains.uast.evaluation.UEvaluatorExtension
|
||||
import com.intellij.platform.uast.testFramework.common.ValuesTestBase
|
||||
import org.jetbrains.uast.UFile
|
||||
import org.jetbrains.uast.evaluation.UEvaluatorExtension
|
||||
import org.jetbrains.uast.java.JavaUFile
|
||||
|
||||
abstract class AbstractJavaValuesTest : AbstractJavaUastTest(), ValuesTestBase {
|
||||
private var _evaluatorExtension: UEvaluatorExtension? = null
|
||||
|
||||
override fun getEvaluatorExtension(): UEvaluatorExtension? = _evaluatorExtension
|
||||
|
||||
override fun createCopyToCheck(file: UFile): UFile? {
|
||||
// TODO: when JavaUFile (and/or its constructor) becomes `internal`, this should move into JavaUFile.
|
||||
return if (file is JavaUFile) JavaUFile(file.sourcePsi, file.languagePlugin) else null
|
||||
}
|
||||
|
||||
fun doTest(name: String, extension: UEvaluatorExtension) {
|
||||
_evaluatorExtension = extension
|
||||
|
||||
Reference in New Issue
Block a user