[uast-groovy] warnings cleanup

This commit is contained in:
Nicolay Mitropolsky
2019-03-28 11:36:47 +03:00
parent 6fb11dded2
commit bbbcd74f2b
3 changed files with 13 additions and 9 deletions
@@ -9,7 +9,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe
import org.jetbrains.uast.*
class GrUClass(val grElement: GrTypeDefinition,
parentProvider: () -> UElement?) : UClassTypeSpecific, UAnchorOwner, UDeclarationEx, PsiClass by grElement {
parentProvider: () -> UElement?) : UClass, UAnchorOwner, UDeclarationEx, PsiClass by grElement {
override val sourcePsi: GrTypeDefinition = grElement
@@ -52,7 +52,7 @@ class GrUClass(val grElement: GrTypeDefinition,
class GrUMethod(val grElement: GrMethod,
parentProvider: () -> UElement?) : UMethodTypeSpecific, UAnchorOwner, UDeclarationEx, PsiMethod by grElement {
parentProvider: () -> UElement?) : UMethod, UAnchorOwner, UDeclarationEx, PsiMethod by grElement {
override val uastParent: UElement? by lazy(parentProvider)
override val sourcePsi: PsiElement = grElement
@@ -4,26 +4,29 @@
package org.jetbrains.plugins.groovy.lang.psi.uast
import com.intellij.psi.PsiComment
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiRecursiveElementWalkingVisitor
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
import org.jetbrains.uast.*
import java.util.*
class GrUFile(override val psi: GroovyFile, override val languagePlugin: UastLanguagePlugin) : UFile {
class GrUFile(override val sourcePsi: GroovyFile, override val languagePlugin: UastLanguagePlugin) : UFile {
override val psi: PsiFile
get() = sourcePsi
override val packageName: String
get() = psi.packageName
get() = sourcePsi.packageName
override val imports: List<UImportStatement> = emptyList<UImportStatement>() // not implemented
override val annotations: List<UAnnotation>
get() = psi.packageDefinition?.annotationList?.annotations?.map { GrUAnnotation(it, { this }) } ?: emptyList()
get() = sourcePsi.packageDefinition?.annotationList?.annotations?.map { GrUAnnotation(it, { this }) } ?: emptyList()
override val classes: List<GrUClass> by lazy { psi.classes.mapNotNull { (it as? GrTypeDefinition)?.let { GrUClass(it, { this }) } } }
override val classes: List<GrUClass> by lazy { sourcePsi.classes.mapNotNull { (it as? GrTypeDefinition)?.let { GrUClass(it, { this }) } } }
override val allCommentsInFile: ArrayList<UComment> by lazy {
val comments = ArrayList<UComment>(0)
psi.accept(object : PsiRecursiveElementWalkingVisitor() {
sourcePsi.accept(object : PsiRecursiveElementWalkingVisitor() {
override fun visitComment(comment: PsiComment) {
comments += UComment(comment, this@GrUFile)
}
@@ -31,5 +34,6 @@ class GrUFile(override val psi: GroovyFile, override val languagePlugin: UastLan
comments
}
override fun equals(other: Any?): Boolean = (other as? GrUFile)?.psi == psi
override fun equals(other: Any?): Boolean = (other as? GrUFile)?.sourcePsi == sourcePsi
override fun hashCode(): Int = sourcePsi.hashCode()
}
@@ -27,6 +27,6 @@ class GrUReferenceExpression(
override fun resolve(): PsiElement? = sourcePsi.resolve()
override fun multiResolve(): Iterable<ResolveResult> =
(psi as? PsiPolyVariantReference)?.multiResolve(false)?.asIterable() ?: emptyList()
(sourcePsi as? PsiPolyVariantReference)?.multiResolve(false)?.asIterable() ?: emptyList()
}