Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
4357cb87
Commit
4357cb87
authored
1 year ago
by
Jinseong Jeon
Browse files
Options
Download
Email Patches
Plain Diff
LC: regression test for findAttributeValue for defalut value in Java
^KT-66692
parent
0fd44a8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/kotlin/uast/uast-kotlin-base/tests/test/org/jetbrains/uast/test/common/kotlin/LightClassBehaviorTestBase.kt
+46
-1
...ins/uast/test/common/kotlin/LightClassBehaviorTestBase.kt
plugins/kotlin/uast/uast-kotlin-fir/tests/test/org/jetbrains/fir/uast/test/FirLightClassBehaviorTest.kt
+6
-2
.../org/jetbrains/fir/uast/test/FirLightClassBehaviorTest.kt
plugins/kotlin/uast/uast-kotlin/tests/test/org/jetbrains/uast/test/kotlin/comparison/FE1LightClassBehaviorTest.kt
+6
-2
.../uast/test/kotlin/comparison/FE1LightClassBehaviorTest.kt
with
58 additions
and
5 deletions
+58
-5
plugins/kotlin/uast/uast-kotlin-base/tests/test/org/jetbrains/uast/test/common/kotlin/LightClassBehaviorTestBase.kt
+
46
-
1
View file @
4357cb87
...
...
@@ -594,7 +594,7 @@ interface LightClassBehaviorTestBase : UastPluginSelection {
)
}
fun
checkDefaultValueOfAnnotation
(
myFixture
:
JavaCodeInsightTestFixture
)
{
fun
checkDefaultValueOfAnnotation
_Kotlin
(
myFixture
:
JavaCodeInsightTestFixture
)
{
myFixture
.
configureByText
(
"main.kt"
,
"""
annotation class IntDef(
...
...
@@ -629,6 +629,51 @@ interface LightClassBehaviorTestBase : UastPluginSelection {
TestCase
.
assertEquals
(
"false"
,
flagValue
?.
toString
())
}
fun
checkDefaultValueOfAnnotation_Java
(
myFixture
:
JavaCodeInsightTestFixture
)
{
myFixture
.
addClass
(
"""
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface MyRestrictedApi {
String explanation();
Class<? extends Annotation>[] allowlistAnnotations() default {};
boolean allowedInTestonlyTargets() default false;
}
"""
.
trimIndent
()
)
myFixture
.
configureByText
(
"main.kt"
,
"""
@Target(AnnotationTarget.FUNCTION) annotation class KAllowlist
class Test {
@MyRestrictedApi(
explanation = "umbrella",
allowlistAnnotations = [KAllowlist::class],
)
fun foo() {}
}
"""
.
trimIndent
()
)
val
uFile
=
myFixture
.
file
.
toUElement
()
!!
val
foo
=
uFile
.
findElementByTextFromPsi
<
UMethod
>(
"fun foo"
,
strict
=
false
)
.
orFail
(
"can't convert to UMethod"
)
val
lc
=
foo
.
uAnnotations
.
single
().
javaPsi
!!
val
annos
=
(
lc
.
findAttributeValue
(
"allowlistAnnotations"
)
as
?
PsiArrayInitializerMemberValue
)
?.
initializers
TestCase
.
assertEquals
(
"[KAllowlist]"
,
annos
?.
joinToString
(
separator
=
", "
,
prefix
=
"["
,
postfix
=
"]"
)
{
annoValue
->
(
annoValue
as
?
PsiClassObjectAccessExpression
)
?.
type
?.
canonicalText
?:
annoValue
.
text
}
)
val
flagValue
=
(
lc
.
findAttributeValue
(
"allowedInTestonlyTargets"
)
as
?
PsiLiteralExpression
)
?.
value
TestCase
.
assertEquals
(
"false"
,
flagValue
?.
toString
())
}
fun
checkAnnotationParameterReference
(
myFixture
:
JavaCodeInsightTestFixture
)
{
PsiReferenceContributor
.
EP_NAME
.
point
.
registerExtension
(
PsiReferenceContributorEP
().
apply
{
...
...
This diff is collapsed.
Click to expand it.
plugins/kotlin/uast/uast-kotlin-fir/tests/test/org/jetbrains/fir/uast/test/FirLightClassBehaviorTest.kt
+
6
-
2
View file @
4357cb87
...
...
@@ -77,8 +77,12 @@ class FirLightClassBehaviorTest : KotlinLightCodeInsightFixtureTestCase(), Light
checkUpperBoundForRecursiveTypeParameter
(
myFixture
)
}
fun
testDefaultValueOfAnnotation
()
{
checkDefaultValueOfAnnotation
(
myFixture
)
fun
testDefaultValueOfAnnotation_Kotlin
()
{
checkDefaultValueOfAnnotation_Kotlin
(
myFixture
)
}
fun
testDefaultValueOfAnnotation_Java
()
{
checkDefaultValueOfAnnotation_Java
(
myFixture
)
}
fun
testAnnotationParameterReference
()
{
...
...
This diff is collapsed.
Click to expand it.
plugins/kotlin/uast/uast-kotlin/tests/test/org/jetbrains/uast/test/kotlin/comparison/FE1LightClassBehaviorTest.kt
+
6
-
2
View file @
4357cb87
...
...
@@ -81,8 +81,12 @@ class FE1LightClassBehaviorTest : KotlinLightCodeInsightFixtureTestCase(), Light
checkUpperBoundForRecursiveTypeParameter
(
myFixture
)
}
fun
testDefaultValueOfAnnotation
()
{
checkDefaultValueOfAnnotation
(
myFixture
)
fun
testDefaultValueOfAnnotation_Kotlin
()
{
checkDefaultValueOfAnnotation_Kotlin
(
myFixture
)
}
fun
testDefaultValueOfAnnotation_Java
()
{
checkDefaultValueOfAnnotation_Java
(
myFixture
)
}
fun
testAnnotationParameterReference
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help