Uast: KotlinStringULiteralExpression.getExpressionType() made always return String

This commit is contained in:
Nicolay Mitropolsky
2018-01-16 20:36:17 +03:00
parent e46f69bb36
commit b4db744a9b
4 changed files with 98 additions and 1 deletions
@@ -17,10 +17,10 @@
package org.jetbrains.uast.kotlin
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiType
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.psi.KtConstantExpression
import org.jetbrains.kotlin.psi.KtEscapeStringTemplateEntry
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
import org.jetbrains.uast.UElement
import org.jetbrains.uast.ULiteralExpression
@@ -46,4 +46,6 @@ class KotlinStringULiteralExpression(
get() = text
override fun evaluate() = value
override fun getExpressionType(): PsiType? = PsiType.getJavaLangString(psi.manager, psi.resolveScope)
}
+23
View File
@@ -0,0 +1,23 @@
UFile (package = ) [public final class StringTemplateKt {...]
UClass (name = StringTemplateKt) [public final class StringTemplateKt {...}]
UField (name = foo) [@org.jetbrains.annotations.NotNull private static final var foo: java.lang.String = "lorem"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
ULiteralExpression (value = "lorem") ["lorem"] : PsiType:String
UField (name = bar) [@org.jetbrains.annotations.NotNull private static final var bar: java.lang.String = "ipsum"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
ULiteralExpression (value = "ipsum") ["ipsum"] : PsiType:String
UField (name = baz) [@org.jetbrains.annotations.NotNull private static final var baz: java.lang.String = "dolor"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
ULiteralExpression (value = "dolor") ["dolor"] : PsiType:String
UField (name = foobarbaz) [@org.jetbrains.annotations.NotNull private static final var foobarbaz: java.lang.String = foo + " " + bar + " " + baz]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UPolyadicExpression (operator = +) [foo + " " + bar + " " + baz] : PsiType:String
USimpleNameReferenceExpression (identifier = foo) [foo] : PsiType:String
ULiteralExpression (value = " ") [" "] : PsiType:String
USimpleNameReferenceExpression (identifier = bar) [bar] : PsiType:String
ULiteralExpression (value = " ") [" "] : PsiType:String
USimpleNameReferenceExpression (identifier = baz) [baz] : PsiType:String
UAnnotationMethod (name = getFoo) [public static final fun getFoo() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getBar) [public static final fun getBar() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getBaz) [public static final fun getBaz() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getFoobarbaz) [public static final fun getFoobarbaz() : java.lang.String = UastEmptyExpression]
@@ -0,0 +1,68 @@
UFile (package = ) [public final class StringTemplateComplexKt {...]
UClass (name = StringTemplateComplexKt) [public final class StringTemplateComplexKt {...}]
UField (name = muchRecur) [@org.jetbrains.annotations.NotNull private static final var muchRecur: java.lang.String = "abc"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
ULiteralExpression (value = "abc") ["abc"] : PsiType:String
UField (name = case4) [@org.jetbrains.annotations.NotNull private static final var case4: java.lang.String = "a " + "literal" + " z"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UPolyadicExpression (operator = +) ["a " + "literal" + " z"] : PsiType:String
ULiteralExpression (value = "a ") ["a "] : PsiType:String
ULiteralExpression (value = "literal") ["literal"] : PsiType:String
ULiteralExpression (value = " z") [" z"] : PsiType:String
UField (name = case5) [@org.jetbrains.annotations.NotNull private static final var case5: java.lang.String = "a " + "literal" + " " + "literal" + " z"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UPolyadicExpression (operator = +) ["a " + "literal" + " " + "literal" + " z"] : PsiType:String
ULiteralExpression (value = "a ") ["a "] : PsiType:String
ULiteralExpression (value = "literal") ["literal"] : PsiType:String
ULiteralExpression (value = " ") [" "] : PsiType:String
ULiteralExpression (value = "literal") ["literal"] : PsiType:String
ULiteralExpression (value = " z") [" z"] : PsiType:String
UField (name = literalInLiteral) [@org.jetbrains.annotations.NotNull private static final var literalInLiteral: java.lang.String = "a " + "literal" + case4 + " z"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UPolyadicExpression (operator = +) ["a " + "literal" + case4 + " z"] : PsiType:String
ULiteralExpression (value = "a ") ["a "] : PsiType:String
UPolyadicExpression (operator = +) ["literal" + case4] : PsiType:String
ULiteralExpression (value = "literal") ["literal"] : PsiType:String
USimpleNameReferenceExpression (identifier = case4) [case4] : PsiType:String
ULiteralExpression (value = " z") [" z"] : PsiType:String
UField (name = literalInLiteral2) [@org.jetbrains.annotations.NotNull private static final var literalInLiteral2: java.lang.String = "a " + "literal" + case4.repeat(4) + " z"]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
UPolyadicExpression (operator = +) ["a " + "literal" + case4.repeat(4) + " z"] : PsiType:String
ULiteralExpression (value = "a ") ["a "] : PsiType:String
UQualifiedReferenceExpression ["literal" + case4.repeat(4)] : PsiType:String
UPolyadicExpression (operator = +) ["literal" + case4] : PsiType:String
ULiteralExpression (value = "literal") ["literal"] : PsiType:String
USimpleNameReferenceExpression (identifier = case4) [case4] : PsiType:String
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [repeat(4)] : PsiType:String
UIdentifier (Identifier (repeat)) [UIdentifier (Identifier (repeat))]
USimpleNameReferenceExpression (identifier = repeat) [repeat] : PsiType:String
ULiteralExpression (value = 4) [4] : PsiType:int
ULiteralExpression (value = " z") [" z"] : PsiType:String
UAnnotationMethod (name = getMuchRecur) [public static final fun getMuchRecur() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getCase4) [public static final fun getCase4() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getCase5) [public static final fun getCase5() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getLiteralInLiteral) [public static final fun getLiteralInLiteral() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = getLiteralInLiteral2) [public static final fun getLiteralInLiteral2() : java.lang.String = UastEmptyExpression]
UAnnotationMethod (name = simpleForTemplate) [public static final fun simpleForTemplate(@org.jetbrains.annotations.NotNull i: int) : java.lang.String = i]
UParameter (name = i) [@org.jetbrains.annotations.NotNull var i: int = 0]
UAnnotation (fqName = org.jetbrains.annotations.NotNull) [@org.jetbrains.annotations.NotNull]
ULiteralExpression (value = 0) [0] : PsiType:int
USimpleNameReferenceExpression (identifier = i) [i] : PsiType:int
UAnnotationMethod (name = foo) [public static final fun foo() : void {...}]
UBlockExpression [{...}] : PsiType:Unit
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [println(baz)] : PsiType:Unit
UIdentifier (Identifier (println)) [UIdentifier (Identifier (println))]
USimpleNameReferenceExpression (identifier = println) [println] : PsiType:Unit
USimpleNameReferenceExpression (identifier = baz) [baz]
UDeclarationsExpression [var template1: java.lang.String = simpleForTemplate()]
ULocalVariable (name = template1) [var template1: java.lang.String = simpleForTemplate()]
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [simpleForTemplate()] : PsiType:String
UIdentifier (Identifier (simpleForTemplate)) [UIdentifier (Identifier (simpleForTemplate))]
USimpleNameReferenceExpression (identifier = simpleForTemplate) [simpleForTemplate] : PsiType:String
UDeclarationsExpression [var template2: java.lang.String = "." + simpleForTemplate()]
ULocalVariable (name = template2) [var template2: java.lang.String = "." + simpleForTemplate()]
UPolyadicExpression (operator = +) ["." + simpleForTemplate()] : PsiType:String
ULiteralExpression (value = ".") ["."] : PsiType:String
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [simpleForTemplate()] : PsiType:String
UIdentifier (Identifier (simpleForTemplate)) [UIdentifier (Identifier (simpleForTemplate))]
USimpleNameReferenceExpression (identifier = simpleForTemplate) [simpleForTemplate] : PsiType:String
@@ -10,4 +10,8 @@ class KotlinUastTypesTest : AbstractKotlinTypesTest() {
@Test fun testCycleInTypeParameters() = doTest("CycleInTypeParameters")
@Test fun testEa101715() = doTest("ea101715")
@Test fun testStringTemplate() = doTest("StringTemplate")
@Test fun testStringTemplateComplex() = doTest("StringTemplateComplex")
}