mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
[uast-java] Don't show type annotations on methods
#IDEA-336319 Fixed GitOrigin-RevId: ce7aa689c95e379f0013899822550c78c51f2309
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e6d7df032
commit
559ba08c10
@@ -2,6 +2,7 @@
|
||||
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.codeInsight.AnnotationTargetUtil
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.light.LightElement
|
||||
import com.intellij.psi.impl.light.LightRecordCanonicalConstructor
|
||||
@@ -37,7 +38,12 @@ open class JavaUMethod(
|
||||
}
|
||||
|
||||
override val uAnnotations: List<UAnnotation>
|
||||
get() = uAnnotationsPart.getOrBuild { javaPsi.annotations.map { JavaUAnnotation(it, this) } }
|
||||
get() = uAnnotationsPart.getOrBuild {
|
||||
javaPsi.annotations.mapNotNull {
|
||||
if (AnnotationTargetUtil.findAnnotationTarget(it, PsiAnnotation.TargetType.METHOD) == null) return@mapNotNull null
|
||||
JavaUAnnotation(it, this)
|
||||
}
|
||||
}
|
||||
|
||||
override val uastParameters: List<UParameter>
|
||||
get() = uastParametersPart.getOrBuild {
|
||||
|
||||
10
uast/uast-tests/java/Simple/TypeAnnotations.java
Normal file
10
uast/uast-tests/java/Simple/TypeAnnotations.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package test.pkg;
|
||||
|
||||
@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
|
||||
public @interface A {}
|
||||
|
||||
public class Foo {
|
||||
public @A int foo1() {}
|
||||
public @A String foo2() {}
|
||||
public @A <T> T foo3() {}
|
||||
}
|
||||
20
uast/uast-tests/java/Simple/TypeAnnotations.log.txt
Normal file
20
uast/uast-tests/java/Simple/TypeAnnotations.log.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
UFile (package = test.pkg)
|
||||
UClass (name = A)
|
||||
UAnnotation (fqName = java.lang.annotation.Target)
|
||||
UNamedExpression (name = null)
|
||||
UQualifiedReferenceExpression
|
||||
UQualifiedReferenceExpression
|
||||
UQualifiedReferenceExpression
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = java)
|
||||
USimpleNameReferenceExpression (identifier = lang)
|
||||
USimpleNameReferenceExpression (identifier = annotation)
|
||||
USimpleNameReferenceExpression (identifier = ElementType)
|
||||
USimpleNameReferenceExpression (identifier = TYPE_USE)
|
||||
UClass (name = Foo)
|
||||
UMethod (name = foo1)
|
||||
UBlockExpression
|
||||
UMethod (name = foo2)
|
||||
UBlockExpression
|
||||
UMethod (name = foo3)
|
||||
UBlockExpression
|
||||
13
uast/uast-tests/java/Simple/TypeAnnotations.render.txt
Normal file
13
uast/uast-tests/java/Simple/TypeAnnotations.render.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
package test.pkg
|
||||
|
||||
public abstract annotation A {
|
||||
}
|
||||
|
||||
public class Foo {
|
||||
public fun foo1() : int {
|
||||
}
|
||||
public fun foo2() : java.lang.String {
|
||||
}
|
||||
public fun foo3() : T {
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,7 @@ class SimpleJavaRenderLogTest : AbstractJavaRenderLogTest(), RenderLogTestBase {
|
||||
|
||||
@Test
|
||||
fun testRecord() = doTest("Simple/Record.java")
|
||||
|
||||
@Test
|
||||
fun testTypeAnnotations() = doTest("Simple/TypeAnnotations.java")
|
||||
}
|
||||
Reference in New Issue
Block a user