diff --git a/.idea/artifacts/KotlinPlugin.xml b/.idea/artifacts/KotlinPlugin.xml index e69ea537167..13e7256ee9f 100644 --- a/.idea/artifacts/KotlinPlugin.xml +++ b/.idea/artifacts/KotlinPlugin.xml @@ -73,12 +73,9 @@ - - - - + @@ -103,6 +100,7 @@ + diff --git a/.idea/libraries/uast_java.xml b/.idea/libraries/uast_java.xml new file mode 100644 index 00000000000..703d240e89c --- /dev/null +++ b/.idea/libraries/uast_java.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 79e1cc0a506..1d80f7c9453 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -94,9 +94,8 @@ - - + diff --git a/plugins/lint/lint-api/lint-api.iml b/plugins/lint/lint-api/lint-api.iml index b353d109428..6b7b63cfd40 100644 --- a/plugins/lint/lint-api/lint-api.iml +++ b/plugins/lint/lint-api/lint-api.iml @@ -8,11 +8,10 @@ - - + \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/UastContext.kt b/plugins/uast-common/src/org/jetbrains/uast/UastContext.kt deleted file mode 100644 index 61bc61a0611..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/UastContext.kt +++ /dev/null @@ -1,73 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.lang.Language -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiMethod -import com.intellij.psi.PsiVariable -import org.jetbrains.uast.psi.PsiElementBacked - -class UastContext(override val project: Project) : UastLanguagePlugin { - private companion object { - private val CONTEXT_LANGUAGE = object : Language("UastContextLanguage") {} - } - - override val language: Language - get() = CONTEXT_LANGUAGE - - override val priority: Int - get() = 0 - - val languagePlugins: Collection - get() = UastLanguagePlugin.getInstances(project) - - fun findPlugin(element: PsiElement): UastLanguagePlugin? { - val language = element.language - return languagePlugins.firstOrNull { it.language == language } - } - - override fun isFileSupported(fileName: String) = languagePlugins.any { it.isFileSupported(fileName) } - - fun getMethod(method: PsiMethod): UMethod = convertWithParent(method)!! - - fun getVariable(variable: PsiVariable): UVariable = convertWithParent(variable)!! - - fun getClass(clazz: PsiClass): UClass = convertWithParent(clazz)!! - - override fun convertElement(element: PsiElement, parent: UElement?, requiredType: Class?): UElement? { - return findPlugin(element)?.convertElement(element, parent, requiredType) - } - - override fun convertElementWithParent(element: PsiElement, requiredType: Class?): UElement? { - return findPlugin(element)?.convertElementWithParent(element, requiredType) - } - - override fun getMethodCallExpression( - element: PsiElement, - containingClassFqName: String?, - methodName: String - ): UastLanguagePlugin.ResolvedMethod? { - return findPlugin(element)?.getMethodCallExpression(element, containingClassFqName, methodName) - } - - override fun getConstructorCallExpression( - element: PsiElement, - fqName: String - ): UastLanguagePlugin.ResolvedConstructor? { - return findPlugin(element)?.getConstructorCallExpression(element, fqName) - } - - override fun isExpressionValueUsed(element: UExpression): Boolean { - val language = element.getLanguage() - return (languagePlugins.firstOrNull { it.language == language })?.isExpressionValueUsed(element) ?: false - } - - private tailrec fun UElement.getLanguage(): Language { - if (this is PsiElementBacked) { - psi?.language?.let { return it } - } - val containingElement = this.containingElement ?: throw IllegalStateException("At least UFile should have a language") - return containingElement.getLanguage() - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/UastLanguagePlugin.kt b/plugins/uast-common/src/org/jetbrains/uast/UastLanguagePlugin.kt deleted file mode 100644 index 5ce7273a060..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/UastLanguagePlugin.kt +++ /dev/null @@ -1,98 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.lang.Language -import com.intellij.openapi.extensions.ExtensionPointName -import com.intellij.openapi.extensions.Extensions -import com.intellij.openapi.project.Project -import com.intellij.psi.* - -interface UastLanguagePlugin { - companion object { - val extensionPointName = ExtensionPointName.create("org.jetbrains.uast.uastLanguagePlugin") - - fun getInstances(project: Project): Collection { - val projectArea = Extensions.getArea(project) - if (!projectArea.hasExtensionPoint(extensionPointName.name)) return listOf() - return projectArea.getExtensionPoint(extensionPointName).extensions.toList() - } - } - - data class ResolvedMethod(val call: UCallExpression, val method: PsiMethod) - data class ResolvedConstructor(val call: UCallExpression, val constructor: PsiMethod, val clazz: PsiClass) - - val language: Language - - val project: Project - - /** - * Checks if the file with the given [fileName] is supported. - * - * @param fileName the source file name. - * @return true, if the file is supported by this converter, false otherwise. - */ - fun isFileSupported(fileName: String): Boolean - - /** - * Returns the converter priority. Might be positive, negative or 0 (Java's is 0). - * UastConverter with the higher priority will be queried earlier. - * - * Priority is useful when a language N wraps its own elements (NElement) to, for example, Java's PsiElements, - * and Java resolves the reference to such wrapped PsiElements, not the original NElement. - * In this case N implementation can handle such wrappers in UastConverter earlier than Java's converter, - * so N language converter will have a higher priority. - */ - val priority: Int - - fun convertElement(element: PsiElement, parent: UElement?, requiredType: Class? = null): UElement? - - /** - * Convert [element] to the [UElement] with the given parent. - */ - fun convertElementWithParent(element: PsiElement, requiredType: Class?): UElement? - - fun getMethodCallExpression( - element: PsiElement, - containingClassFqName: String?, - methodName: String - ): ResolvedMethod? - - fun getConstructorCallExpression( - element: PsiElement, - fqName: String - ) : ResolvedConstructor? - - fun getMethodBody(element: PsiMethod): UExpression? { - if (element is UMethod) return element.uastBody - return (convertElementWithParent(element, null) as? UMethod)?.uastBody - } - - fun getInitializerBody(element: PsiClassInitializer): UExpression { - if (element is UClassInitializer) return element.uastBody - return (convertElementWithParent(element, null) as? UClassInitializer)?.uastBody ?: UastEmptyExpression - } - - fun getInitializerBody(element: PsiVariable): UExpression? { - if (element is UVariable) return element.uastInitializer - return (convertElementWithParent(element, null) as? UVariable)?.uastInitializer - } - - /** - * Returns true if the expression value is used. - * Do not rely on this property too much, its value can be approximate in some cases. - */ - fun isExpressionValueUsed(element: UExpression): Boolean -} - -inline fun UastLanguagePlugin.convertOpt(element: PsiElement?, parent: UElement?): T? { - if (element == null) return null - return convertElement(element, parent) as? T -} - -inline fun UastLanguagePlugin.convert(element: PsiElement, parent: UElement?): T { - return convertElement(element, parent, T::class.java) as T -} - -inline fun UastLanguagePlugin.convertWithParent(element: PsiElement?): T? { - if (element == null) return null - return convertElementWithParent(element, T::class.java) as? T -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/UastUtils.kt b/plugins/uast-common/src/org/jetbrains/uast/UastUtils.kt deleted file mode 100644 index 978bd09e344..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/UastUtils.kt +++ /dev/null @@ -1,137 +0,0 @@ -@file:JvmMultifileClass -@file:JvmName("UastUtils") -package org.jetbrains.uast - -import com.intellij.openapi.components.ServiceManager -import com.intellij.openapi.vfs.VfsUtilCore -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiNamedElement -import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.psi.PsiElementBacked -import java.io.File - -inline fun UElement.getParentOfType(strict: Boolean = true): T? = getParentOfType(T::class.java, strict) - -@JvmOverloads -fun UElement.getParentOfType(parentClass: Class, strict: Boolean = true): T? { - var element = (if (strict) containingElement else this) ?: return null - while (true) { - if (parentClass.isInstance(element)) { - @Suppress("UNCHECKED_CAST") - return element as T - } - element = element.containingElement ?: return null - } -} - -fun UElement.getParentOfType( - parentClass: Class, - strict: Boolean = true, - vararg terminators: Class -): T? { - var element = (if (strict) containingElement else this) ?: return null - while (true) { - if (parentClass.isInstance(element)) { - @Suppress("UNCHECKED_CAST") - return element as T - } - if (terminators.any { it.isInstance(element) }) { - return null - } - element = element.containingElement ?: return null - } -} - -fun UElement.getParentOfType( - strict: Boolean = true, - firstParentClass: Class, - vararg parentClasses: Class -): T? { - var element = (if (strict) containingElement else this) ?: return null - while (true) { - if (firstParentClass.isInstance(element)) { - @Suppress("UNCHECKED_CAST") - return element as T - } - if (parentClasses.any { it.isInstance(element) }) { - @Suppress("UNCHECKED_CAST") - return element as T - } - element = element.containingElement ?: return null - } -} - -fun UElement.getContainingFile() = getParentOfType(UFile::class.java) - -fun UElement.getContainingUClass() = getParentOfType(UClass::class.java) -fun UElement.getContainingUMethod() = getParentOfType(UMethod::class.java) -fun UElement.getContainingUVariable() = getParentOfType(UVariable::class.java) - -fun UElement.getContainingMethod() = getContainingUMethod()?.psi -fun UElement.getContainingClass() = getContainingUClass()?.psi -fun UElement.getContainingVariable() = getContainingUVariable()?.psi - -fun PsiElement?.getContainingClass() = this?.let { PsiTreeUtil.getParentOfType(it, PsiClass::class.java) } - -fun UElement.isChildOf(probablyParent: UElement?, strict: Boolean = false): Boolean { - tailrec fun isChildOf(current: UElement?, probablyParent: UElement): Boolean { - return when (current) { - null -> false - probablyParent -> true - else -> isChildOf(current.containingElement, probablyParent) - } - } - - if (probablyParent == null) return false - return isChildOf(if (strict) this else containingElement, probablyParent) -} - -/** - * Resolves the receiver element if it implements [UResolvable]. - * - * @return the resolved element, or null if the element was not resolved, or if the receiver element is not an [UResolvable]. - */ -fun UElement.tryResolve(): PsiElement? = (this as? UResolvable)?.resolve() - -fun UElement.tryResolveNamed(): PsiNamedElement? = (this as? UResolvable)?.resolve() as? PsiNamedElement - -fun UElement.tryResolveUDeclaration(context: UastContext): UDeclaration? { - return (this as? UResolvable)?.resolve()?.let { context.convertElementWithParent(it, null) as? UDeclaration } -} - -fun UReferenceExpression?.getQualifiedName() = (this?.resolve() as? PsiClass)?.qualifiedName - -/** - * Returns the String expression value, or null if the value can't be calculated or if the calculated value is not a String. - */ -fun UExpression.evaluateString(): String? = evaluate() as? String - -/** - * Get a physical [File] for this file, or null if there is no such file on disk. - */ -fun UFile.getIoFile(): File? = psi.virtualFile?.let { VfsUtilCore.virtualToIoFile(it) } - -tailrec fun UElement.getUastContext(): UastContext { - if (this is PsiElementBacked) { - val psi = this.psi - if (psi != null) { - return ServiceManager.getService(psi.project, UastContext::class.java) ?: error("UastContext not found") - } - } - - return (containingElement ?: error("PsiElement should exist at least for UFile")).getUastContext() -} - -tailrec fun UElement.getLanguagePlugin(): UastLanguagePlugin { - if (this is PsiElementBacked) { - val psi = this.psi - if (psi != null) { - val uastContext = ServiceManager.getService(psi.project, UastContext::class.java) ?: error("UastContext not found") - return uastContext.findPlugin(psi) ?: error("Language plugin was not found for $this (${this.javaClass.name})") - } - } - - return (containingElement ?: error("PsiElement should exist at least for UFile")).getLanguagePlugin() -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UComment.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UComment.kt deleted file mode 100644 index 4a857a12d9f..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UComment.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiElement -import org.jetbrains.uast.psi.PsiElementBacked - -class UComment(override val psi: PsiElement, override val containingElement: UElement) : UElement, PsiElementBacked { - val text: String - get() = asSourceString() - - override fun asLogString() = "UComment" - override fun asRenderString(): String = asSourceString() - override fun asSourceString(): String = psi.text -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UElement.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UElement.kt deleted file mode 100644 index 0c584e5a6f7..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UElement.kt +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.visitor.UastVisitor - -/** - * The common interface for all Uast elements. - */ -interface UElement { - /** - * Returns the element parent. - */ - val containingElement: UElement? - - /** - * Returns true if this element is valid, false otherwise. - */ - val isPsiValid: Boolean - get() = true - - /** - * Returns the list of comments for this element. - */ - val comments: List - get() = emptyList() - - /** - * Returns the log string. - * - * Output example (should be something like this): - * UWhileExpression - * UBinaryExpression (>) - * USimpleReferenceExpression (i) - * ULiteralExpression (5) - * UBlockExpression - * UCallExpression (println) - * ULiteralExpression (ABC) - * UPostfixExpression (--) - * USimpleReferenceExpression(i) - * - * @return the expression tree for this element. - * @see [UIfExpression] for example. - */ - fun asLogString(): String - - /** - * Returns the string in pseudo-code. - * - * Output example (should be something like this): - * while (i > 5) { - * println("Hello, world") - * i-- - * } - * - * @return the rendered text. - * @see [UIfExpression] for example. - */ - fun asRenderString(): String = asLogString() - - /** - * Returns the string as written in the source file. - * Use this String only for logging and diagnostic text messages. - * - * @return the original text. - */ - fun asSourceString(): String = asRenderString() - - /** - * Passes the element to the specified visitor. - * - * @param visitor the visitor to pass the element to. - */ - fun accept(visitor: UastVisitor) { - visitor.visitElement(this) - visitor.afterVisitElement(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UExpression.kt deleted file mode 100644 index 33ed8bbab7b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UExpression.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiType -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents an expression or statement (which is considered as an expression in Uast). - */ -interface UExpression : UElement, UAnnotated { - /** - * Returns the expression value or null if the value can't be calculated. - */ - fun evaluate(): Any? = null - - /** - * Returns expression type, or null if type can not be inferred, or if this expression is a statement. - */ - fun getExpressionType(): PsiType? = null - - override fun accept(visitor: UastVisitor) { - visitor.visitElement(this) - visitor.afterVisitElement(this) - } -} - -/** - * Represents an annotated element. - */ -interface UAnnotated : UElement { - /** - * Returns the list of annotations applied to the current element. - */ - val annotations: List - - /** - * Looks up for annotation element using the annotation qualified name. - * - * @param fqName the qualified name to search - * @return the first annotation element with the specified qualified name, or null if there is no annotation with such name. - */ - fun findAnnotation(fqName: String): UAnnotation? = annotations.firstOrNull { it.qualifiedName == fqName } -} - -/** - * Represents a labeled element. - */ -interface ULabeled : UElement { - /** - * Returns the label name, or null if the label is empty. - */ - val label: String? - - /** - * Returns the label identifier, or null if the label is empty. - */ - val labelIdentifier: UIdentifier? -} - -/** - * In some cases (user typing, syntax error) elements, which are supposed to exist, are missing. - * The obvious example — the lack of the condition expression in [UIfExpression], e.g. `if () return`. - * [UIfExpression.condition] is required to return not-null values, - * and Uast implementation should return something instead of `null` in this case. - * - * Use [UastEmptyExpression] in this case. - */ -object UastEmptyExpression : UExpression { - override val containingElement: UElement? - get() = null - - override val annotations: List - get() = emptyList() - - override fun asLogString() = "EmptyExpression" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UIdentifier.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UIdentifier.kt deleted file mode 100644 index 28154650fa8..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UIdentifier.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast - -import com.intellij.psi.PsiElement -import org.jetbrains.uast.psi.PsiElementBacked - -class UIdentifier( - override val psi: PsiElement?, - override val containingElement: UElement? -) : UElement, PsiElementBacked { - /** - * Returns the identifier name. - */ - val name: String - get() = psi?.text ?: "" - - override fun asLogString() = "Identifier ($name)" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UNamed.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UNamed.kt deleted file mode 100644 index 0cfdba4a8e1..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UNamed.kt +++ /dev/null @@ -1,19 +0,0 @@ -package org.jetbrains.uast - -/** - * An interface for the [UElement] which has a name. - */ -interface UNamed { - /** - * Returns the element name. - */ - val name: String? - - /** - * Checks if the element name is equal to the passed name. - * - * @param name the name to check against - * @return true if the element name is equal to [name], false otherwise. - */ - fun matchesName(name: String) = this.name == name -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UResolvable.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UResolvable.kt deleted file mode 100644 index 19394f1056c..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UResolvable.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiElement - -interface UResolvable { - /** - * Resolve the reference. - * Note that the reference is *always* resolved to an unwrapped [PsiElement], never to a [UElement]. - * - * @return the resolved element, or null if the reference couldn't be resolved. - */ - fun resolve(): PsiElement? -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UastErrorType.kt b/plugins/uast-common/src/org/jetbrains/uast/baseElements/UastErrorType.kt deleted file mode 100644 index dc2fd282385..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/baseElements/UastErrorType.kt +++ /dev/null @@ -1,16 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiType -import com.intellij.psi.PsiTypeVisitor - -object UastErrorType : PsiType(emptyArray()) { - override fun getInternalCanonicalText() = "" - override fun equalsToText(text: String) = false - override fun getCanonicalText() = internalCanonicalText - override fun getPresentableText() = canonicalText - override fun isValid() = false - override fun getResolveScope() = null - override fun getSuperTypes() = emptyArray() - - override fun accept(visitor: PsiTypeVisitor) = visitor.visitType(this) -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UDoWhileExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UDoWhileExpression.kt deleted file mode 100644 index 583f102b43b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UDoWhileExpression.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represent a - * - * `do { - * // body - * } while (expr)` - * - * loop expression. - */ -interface UDoWhileExpression : ULoopExpression { - /** - * Returns the loop post-condition. - */ - val condition: UExpression - - /** - * Returns an identifier for the 'do' keyword. - */ - val doIdentifier: UIdentifier - - /** - * Returns an identifier for the 'while' keyword. - */ - val whileIdentifier: UIdentifier - - override fun accept(visitor: UastVisitor) { - if (visitor.visitDoWhileExpression(this)) return - annotations.acceptList(visitor) - condition.accept(visitor) - body.accept(visitor) - visitor.afterVisitDoWhileExpression(this) - } - - override fun asRenderString() = buildString { - append("do ") - append(body.asRenderString()) - appendln("while (${condition.asRenderString()})") - } - - override fun asLogString() = log("UDoWhileExpression", condition, body) -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UForEachExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UForEachExpression.kt deleted file mode 100644 index 6c3a3e385c4..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UForEachExpression.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a - * - * `for (element : collectionOfElements) { - * // body - * }` - * - * loop expression. - */ -interface UForEachExpression : ULoopExpression { - /** - * Returns the loop variable. - */ - val variable: UParameter - - /** - * Returns the iterated value (collection, sequence, iterable etc.) - */ - val iteratedValue: UExpression - - /** - * Returns the identifier for the 'for' ('foreach') keyword. - */ - val forIdentifier: UIdentifier - - override fun accept(visitor: UastVisitor) { - if (visitor.visitForEachExpression(this)) return - annotations.acceptList(visitor) - iteratedValue.accept(visitor) - body.accept(visitor) - visitor.afterVisitForEachExpression(this) - } - - override fun asRenderString() = buildString { - append("for (") - append(variable.name) - append(" : ") - append(iteratedValue.asRenderString()) - append(") ") - append(body.asRenderString()) - } - - override fun asLogString() = log("UForEachExpression", variable, iteratedValue, body) -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UForExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UForExpression.kt deleted file mode 100644 index 3f02a60d8a1..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UForExpression.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a - * - * `for (initDeclarations; loopCondition; update) { - * // body - * }` - * - * loop expression. - */ -interface UForExpression : ULoopExpression { - /** - * Returns the [UExpression] containing variable declarations, or null if the are no variables declared. - */ - val declaration: UExpression? - - /** - * Returns the loop condition, or null if the condition is empty. - */ - val condition: UExpression? - - /** - * Returns the loop update expression(s). - */ - val update: UExpression? - - /** - * Returns the identifier for the 'for' keyword. - */ - val forIdentifier: UIdentifier - - override fun accept(visitor: UastVisitor) { - if (visitor.visitForExpression(this)) return - annotations.acceptList(visitor) - declaration?.accept(visitor) - condition?.accept(visitor) - update?.accept(visitor) - body.accept(visitor) - visitor.afterVisitForExpression(this) - } - - override fun asRenderString() = buildString { - append("for (") - declaration?.let { append(it.asRenderString()) } - append("; ") - condition?.let { append(it.asRenderString()) } - append("; ") - update?.let { append(it.asRenderString()) } - append(") ") - append(body.asRenderString()) - } - - override fun asLogString() = log("UForExpression", declaration, condition, update, body) -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UIfExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UIfExpression.kt deleted file mode 100644 index 8c54ce3dec8..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UIfExpression.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents - * - * `if (condition) { - * // do if true - * } else { - * // do if false - * }` - * - * and - * - * `condition : trueExpression ? falseExpression` - * - * condition expressions. - */ -interface UIfExpression : UExpression { - /** - * Returns the condition expression. - */ - val condition: UExpression - - /** - * Returns the expression which is executed if the condition is true, or null if the expression is empty. - */ - val thenExpression: UExpression? - - /** - * Returns the expression which is executed if the condition is false, or null if the expression is empty. - */ - val elseExpression: UExpression? - - /** - * Returns true if the expression is ternary (condition ? trueExpression : falseExpression). - */ - val isTernary: Boolean - - /** - * Returns an identifier for the 'if' keyword. - */ - val ifIdentifier: UIdentifier - - /** - * Returns an identifier for the 'else' keyword, or null if the conditional expression has not the 'else' part. - */ - val elseIdentifier: UIdentifier? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitIfExpression(this)) return - annotations.acceptList(visitor) - condition.accept(visitor) - thenExpression?.accept(visitor) - elseExpression?.accept(visitor) - visitor.afterVisitIfExpression(this) - } - - override fun asLogString() = log("UIfExpression", condition, thenExpression, elseExpression) - - override fun asRenderString() = buildString { - if (isTernary) { - append("(" + condition.asRenderString() + ")") - append(" ? ") - append("(" + (thenExpression?.asRenderString() ?: "") + ")") - append(" : ") - append("(" + (elseExpression?.asRenderString() ?: "") + ")") - } else { - append("if (${condition.asRenderString()}) ") - thenExpression?.let { append(it.asRenderString()) } - val elseBranch = elseExpression - if (elseBranch != null && elseBranch !is UastEmptyExpression) { - if (thenExpression !is UBlockExpression) append(" ") - append("else ") - append(elseBranch.asRenderString()) - } - } - } -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/ULoopExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/ULoopExpression.kt deleted file mode 100644 index a14aba41ef1..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/ULoopExpression.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * Represents a loop expression. - */ -interface ULoopExpression : UExpression { - /** - * Returns the loop body [UExpression]. - */ - val body: UExpression -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/USwitchExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/USwitchExpression.kt deleted file mode 100644 index 3bb199953ef..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/USwitchExpression.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a - * - * ` switch (expression) { - * case value1 -> expr1 - * case value2 -> expr2 - * ... - * else -> exprElse - * } - * - * conditional expression. - */ -interface USwitchExpression : UExpression { - /** - Returns the expression on which the `switch` expression is performed. - */ - val expression: UExpression? - - /** - Returns the switch body. - The body should contain [USwitchClauseExpression] expressions. - */ - val body: UExpression - - /** - * Returns an identifier for the 'switch' ('case', 'when', ...) keyword. - */ - val switchIdentifier: UIdentifier - - override fun accept(visitor: UastVisitor) { - if (visitor.visitSwitchExpression(this)) return - annotations.acceptList(visitor) - expression?.accept(visitor) - body.accept(visitor) - visitor.afterVisitSwitchExpression(this) - } - - override fun asLogString() = log("USwitchExpression", expression, body) - - override fun asRenderString() = buildString { - val expr = expression?.let { "(" + it.asRenderString() + ") " } ?: "" - appendln("switch $expr") - appendln(body.asRenderString()) - } -} - -/** - * Represents a [USwitchExpression] clause. - * [USwitchClauseExpression] does not contain the clause body, - * and the actual body expression should be the next element in the parent expression list. - */ -interface USwitchClauseExpression : UExpression { - /** - * Returns the list of values for this clause, or null if the are no values for this close - * (for example, for the `else` clause). - */ - val caseValues: List? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitSwitchClauseExpression(this)) return - annotations.acceptList(visitor) - caseValues?.acceptList(visitor) - visitor.afterVisitSwitchClauseExpression(this) - } - - override fun asRenderString() = (caseValues?.joinToString { it.asRenderString() } ?: "else") + " -> " - override fun asLogString() = log("USwitchClauseExpression", caseValues) -} - -/** - * Represents a [USwitchExpression] clause with the body. - * [USwitchClauseExpressionWithBody], comparing with [USwitchClauseExpression], contains the body expression. - * - * Implementing this interface *is the right way* to support `switch` clauses in your language. - */ -interface USwitchClauseExpressionWithBody : USwitchClauseExpression { - /** - * Returns the body expression for this clause. - */ - val body: UExpression - - override fun accept(visitor: UastVisitor) { - if (visitor.visitSwitchClauseExpression(this)) return - annotations.acceptList(visitor) - caseValues?.acceptList(visitor) - body.accept(visitor) - visitor.afterVisitSwitchClauseExpression(this) - } - - override fun asRenderString() = (caseValues?.joinToString { it.asRenderString() } ?: "else") + " -> " + body.asRenderString() - override fun asLogString() = log("USwitchClauseExpressionWithBody", caseValues, body) -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UTryExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UTryExpression.kt deleted file mode 100644 index f5c796a235f..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UTryExpression.kt +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiResourceListElement -import com.intellij.psi.PsiType -import org.jetbrains.uast.expressions.UTypeReferenceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents - * - * `try { - * // tryClause body - * } catch (e: Type1, Type2 ... TypeN) { - * // catchClause1 body - * } ... { - * finally { - * //finallyBody - * }` - * - * and - * - * `try (resource1, ..., resourceN) { - * // tryClause body - * }` - * - * expressions. - */ -interface UTryExpression : UExpression { - /** - * Returns `true` if the try expression is a try-with-resources expression. - */ - val isResources: Boolean - - /** - * Returns the list of try resources, or null if this expression is not a `try-with-resources` expression. - */ - val resources: List? - - /** - * Returns the `try` clause expression. - */ - val tryClause: UExpression - - /** - * Returns the `catch` clauses [UCatchClause] expression list. - */ - val catchClauses: List - - /** - * Returns the `finally` clause expression, or null if the `finally` clause is absent. - */ - val finallyClause: UExpression? - - /** - * Returns an identifier for the 'try' keyword. - */ - val tryIdentifier: UIdentifier - - /** - * Returns an identifier for the 'finally' keyword, or null if the 'try' expression has not a 'finally' clause. - */ - val finallyIdentifier: UIdentifier? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitTryExpression(this)) return - annotations.acceptList(visitor) - tryClause.accept(visitor) - catchClauses.acceptList(visitor) - finallyClause?.accept(visitor) - visitor.afterVisitTryExpression(this) - } - - override fun asRenderString() = buildString { - append("try ") - appendln(tryClause.asRenderString().trim('\n', '\r')) - catchClauses.forEach { appendln(it.asRenderString().trim('\n', '\r')) } - finallyClause?.let { append("finally ").append(it.asRenderString().trim('\n', '\r')) } - } - - override fun asLogString() = log("UTryExpression", tryClause, catchClauses, finallyClause) -} - -/** - * Represents the `catch` clause in [UTryExpression]. - */ -interface UCatchClause : UElement { - /** - * Returns the `catch` clause body expression. - */ - val body: UExpression - - /** - * Returns the exception parameter variables for this `catch` clause. - */ - val parameters: List - - /** - * Returns the exception type references for this `catch` clause. - */ - val typeReferences: List - - /** - * Returns the expression types for this `catch` clause. - */ - val types: List - get() = typeReferences.map { it.type } - - override fun accept(visitor: UastVisitor) { - if (visitor.visitCatchClause(this)) return - body.accept(visitor) - visitor.afterVisitCatchClause(this) - } - - override fun asLogString() = log("UCatchClause", body) - override fun asRenderString() = "catch (e) " + body.asRenderString() -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UWhileExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UWhileExpression.kt deleted file mode 100644 index 84896423e25..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/controlStructures/UWhileExpression.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a - * - * `while (condition) { - * // body - * }` - * - * expression. - */ -interface UWhileExpression : ULoopExpression { - /** - * Returns the loop condition. - */ - val condition: UExpression - - /** - * Returns an identifier for the 'while' keyword. - */ - val whileIdentifier: UIdentifier - - override fun accept(visitor: UastVisitor) { - if (visitor.visitWhileExpression(this)) return - annotations.acceptList(visitor) - condition.accept(visitor) - body.accept(visitor) - visitor.afterVisitWhileExpression(this) - } - - override fun asRenderString() = buildString { - append("while (${condition.asRenderString()}) ") - append(body.asRenderString()) - } - - override fun asLogString() = log("UWhileExpression", condition, body) -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UAnnotation.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UAnnotation.kt deleted file mode 100644 index ecf8b664e7e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UAnnotation.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiClass -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.psi.PsiElementBacked -import org.jetbrains.uast.visitor.UastVisitor - -/** - * An annotation wrapper to be used in [UastVisitor]. - */ -interface UAnnotation : UElement, PsiElementBacked, UResolvable { - /** - * Returns the annotation qualified name. - */ - val qualifiedName: String? - - /** - * Returns the annotation class, or null if the class reference was not resolved. - */ - override fun resolve(): PsiClass? - - /** - * Returns the annotation values. - */ - val attributeValues: List - - fun findAttributeValue(name: String?): UNamedExpression? - - fun findDeclaredAttributeValue(name: String?): UNamedExpression? - - override fun asLogString() = "UAnnotation" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitAnnotation(this)) return - attributeValues.acceptList(visitor) - visitor.afterVisitAnnotation(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UClass.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UClass.kt deleted file mode 100644 index a1c3bde6c50..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UClass.kt +++ /dev/null @@ -1,45 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiAnonymousClass -import com.intellij.psi.PsiClass -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * A class wrapper to be used in [UastVisitor]. - */ -interface UClass : UDeclaration, PsiClass { - override val psi: PsiClass - - /** - * Returns a [UClass] wrapper of the superclass of this class, or null if this class is [java.lang.Object]. - */ - val uastSuperClass: UClass? - get() { - val superClass = superClass ?: return null - return getUastContext().convertWithParent(superClass) - } - - /** - * Returns [UDeclaration] wrappers for the class declarations. - */ - val uastDeclarations: List - - val uastFields: List - val uastInitializers: List - val uastMethods: List - val uastNestedClasses: List - - override fun asLogString() = "UClass (name = $name)" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitClass(this)) return - annotations.acceptList(visitor) - uastDeclarations.acceptList(visitor) - visitor.afterVisitClass(this) - } -} - -interface UAnonymousClass : UClass, PsiAnonymousClass { - override val psi: PsiAnonymousClass -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UClassInitializer.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UClassInitializer.kt deleted file mode 100644 index 67571a5e85c..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UClassInitializer.kt +++ /dev/null @@ -1,29 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiClassInitializer -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * A class initializer wrapper to be used in [UastVisitor]. - */ -interface UClassInitializer : UDeclaration, PsiClassInitializer { - override val psi: PsiClassInitializer - - /** - * Returns the body of this class initializer. - */ - val uastBody: UExpression - - @Deprecated("Use uastBody instead.", ReplaceWith("uastBody")) - override fun getBody() = psi.body - - override fun accept(visitor: UastVisitor) { - if (visitor.visitInitializer(this)) return - annotations.acceptList(visitor) - uastBody.accept(visitor) - visitor.afterVisitInitializer(this) - } - - override fun asLogString() = "UMethod (name = ${psi.name}" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt deleted file mode 100644 index 6f071db38a0..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiModifier -import com.intellij.psi.PsiModifierListOwner -import org.jetbrains.uast.psi.PsiElementBacked - -/** - * A [PsiElement] declaration wrapper. - */ -interface UDeclaration : UElement, PsiElementBacked, PsiModifierListOwner, UAnnotated { - /** - * Returns the original declaration (which is *always* unwrapped, never a [UDeclaration]). - */ - override val psi: PsiModifierListOwner - - override fun getOriginalElement(): PsiElement? = psi.originalElement - - /** - * Returns the declaration name identifier, or null if the declaration is anonymous. - */ - val uastAnchor: UElement? - - /** - * Returns `true` if this declaration has a [PsiModifier.STATIC] modifier. - */ - val isStatic: Boolean - get() = hasModifierProperty(PsiModifier.STATIC) - - /** - * Returns `true` if this declaration has a [PsiModifier.FINAL] modifier. - */ - val isFinal: Boolean - get() = hasModifierProperty(PsiModifier.FINAL) - - /** - * Returns a declaration visibility. - */ - val visibility: UastVisibility - get() = UastVisibility[this] -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UFile.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UFile.kt deleted file mode 100644 index 52f76c4485e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UFile.kt +++ /dev/null @@ -1,58 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiFile -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a Uast file. - */ -interface UFile : UElement, UAnnotated { - /** - * Returns the original [PsiFile]. - */ - val psi: PsiFile - - /** - * Returns the Java package name of this file. - * Returns an empty [String] for the default package. - */ - val packageName: String - - /** - * Returns the import statements for this file. - */ - val imports: List - - /** - * Returns the list of top-level classes declared in this file. - */ - val classes: List - - /** - * Returns the plugin for a language used in this file. - */ - val languagePlugin: UastLanguagePlugin - - /** - * Returns all comments in file. - */ - val allCommentsInFile: List - - override fun asLogString() = "UFile" - - /** - * [UFile] is a top-level element of the Uast hierarchy, thus the [containingElement] always returns null for it. - */ - override val containingElement: UElement? - get() = null - - override fun accept(visitor: UastVisitor) { - if (visitor.visitFile(this)) return - annotations.acceptList(visitor) - imports.acceptList(visitor) - classes.acceptList(visitor) - visitor.afterVisitFile(this) - } -} - diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UImportStatement.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UImportStatement.kt deleted file mode 100644 index 2954370929e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UImportStatement.kt +++ /dev/null @@ -1,26 +0,0 @@ -package org.jetbrains.uast - -import org.jetbrains.uast.psi.PsiElementBacked -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents an import statement. - */ -interface UImportStatement : UResolvable, UElement, PsiElementBacked { - /** - * Returns true if the statement is an import-on-demand (star-import) statement. - */ - val isOnDemand: Boolean - - /** - * Returns the reference to the imported element. - */ - val importReference: UElement? - - override fun asLogString() = "UImportStatement (onDemand = $isOnDemand)" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitImportStatement(this)) return - visitor.afterVisitImportStatement(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UMethod.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UMethod.kt deleted file mode 100644 index 482d30ab0a9..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UMethod.kt +++ /dev/null @@ -1,63 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.PsiAnnotationMethod -import com.intellij.psi.PsiMethod -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * A method visitor to be used in [UastVisitor]. - */ -interface UMethod : UDeclaration, PsiMethod { - override val psi: PsiMethod - - /** - * Returns the body expression (which can be also a [UBlockExpression]). - */ - val uastBody: UExpression? - - /** - * Returns the method parameters. - */ - val uastParameters: List - - /** - * Returns true, if the method overrides a method of a super class. - */ - val isOverride: Boolean - - @Deprecated("Use uastBody instead.", ReplaceWith("uastBody")) - override fun getBody() = psi.body - - override fun accept(visitor: UastVisitor) { - if (visitor.visitMethod(this)) return - annotations.acceptList(visitor) - uastParameters.acceptList(visitor) - uastBody?.accept(visitor) - visitor.afterVisitMethod(this) - } - - override fun asLogString() = "UMethod (name = $name)" -} - -interface UAnnotationMethod : UMethod, PsiAnnotationMethod { - override val psi: PsiAnnotationMethod - - /** - * Returns the default value of this annotation method. - */ - val uastDefaultValue: UExpression? - - override fun getDefaultValue() = psi.defaultValue - - override fun accept(visitor: UastVisitor) { - if (visitor.visitMethod(this)) return - annotations.acceptList(visitor) - uastParameters.acceptList(visitor) - uastBody?.accept(visitor) - uastDefaultValue?.accept(visitor) - visitor.afterVisitMethod(this) - } - - override fun asLogString() = "UAnnotationMethod (name = $name)" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/declarations/UVariable.kt b/plugins/uast-common/src/org/jetbrains/uast/declarations/UVariable.kt deleted file mode 100644 index 28a5e3104fd..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/declarations/UVariable.kt +++ /dev/null @@ -1,70 +0,0 @@ -package org.jetbrains.uast - -import com.intellij.psi.* -import org.jetbrains.uast.expressions.UTypeReferenceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * A variable wrapper to be used in [UastVisitor]. - */ -interface UVariable : UDeclaration, PsiVariable { - override val psi: PsiVariable - - /** - * Returns the variable initializer or the parameter default value, or null if the variable has not an initializer. - */ - val uastInitializer: UExpression? - - /** - * Returns variable type reference. - */ - val typeReference: UTypeReferenceExpression? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitVariable(this)) return - annotations.acceptList(visitor) - uastInitializer?.accept(visitor) - visitor.afterVisitVariable(this) - } - - @Deprecated("Use uastInitializer instead.", ReplaceWith("uastInitializer")) - override fun getInitializer() = psi.initializer - - override fun asLogString() = "UVariable (name = $name)" - - override fun asRenderString() = buildString { - val modifiers = PsiModifier.MODIFIERS.filter { psi.hasModifierProperty(it) }.joinToString(" ") - if (modifiers.isNotEmpty()) append(modifiers).append(' ') - append("var ").append(psi.name).append(": ").append(psi.type.getCanonicalText(false)) - } -} - -interface UParameter : UVariable, PsiParameter { - override val psi: PsiParameter -} - -interface UField : UVariable, PsiField { - override val psi: PsiField -} - -interface ULocalVariable : UVariable, PsiLocalVariable { - override val psi: PsiLocalVariable -} - -interface UEnumConstant : UField, UCallExpression, PsiEnumConstant { - override val psi: PsiEnumConstant - - override fun asLogString() = "UEnumConstant (name = ${psi.name}" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitVariable(this)) return - annotations.acceptList(visitor) - methodIdentifier?.accept(visitor) - classReference?.accept(visitor) - valueArguments.acceptList(visitor) - visitor.afterVisitVariable(this) - } - - override fun asRenderString() = name ?: "" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UArrayAccessExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UArrayAccessExpression.kt deleted file mode 100644 index 5c7ec2c66c3..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UArrayAccessExpression.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents `receiver[index0, ..., indexN]` expression. - */ -interface UArrayAccessExpression : UExpression { - /** - * Returns the receiver expression. - */ - val receiver: UExpression - - /** - * Returns the list of index expressions. - */ - val indices: List - - override fun accept(visitor: UastVisitor) { - if (visitor.visitArrayAccessExpression(this)) return - annotations.acceptList(visitor) - receiver.accept(visitor) - indices.acceptList(visitor) - visitor.afterVisitArrayAccessExpression(this) - } - - override fun asLogString() = log("UArrayAccessExpression", receiver, indices) - override fun asRenderString() = receiver.asRenderString() + - indices.joinToString(prefix = "[", postfix = "]") { it.asRenderString() } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBinaryExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UBinaryExpression.kt deleted file mode 100644 index 7681983c8ed..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBinaryExpression.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiMethod -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a binary expression (value1 op value2), eg. `2 + "A"`. - */ -interface UBinaryExpression : UExpression { - /** - * Returns the left operand. - */ - val leftOperand: UExpression - - /** - * Returns the right operand. - */ - val rightOperand: UExpression - - /** - * Returns the binary operator. - */ - val operator: UastBinaryOperator - - /** - * Returns the operator identifier. - */ - val operatorIdentifier: UIdentifier? - - /** - * Resolve the operator method. - * - * @return the resolved method, or null if the method can't be resolved, or if the expression is not a method call. - */ - fun resolveOperator(): PsiMethod? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitBinaryExpression(this)) return - annotations.acceptList(visitor) - leftOperand.accept(visitor) - rightOperand.accept(visitor) - visitor.afterVisitBinaryExpression(this) - } - - override fun asLogString() = - "UBinaryExpression (${operator.text})" + LINE_SEPARATOR + - leftOperand.asLogString().withMargin + LINE_SEPARATOR + - rightOperand.asLogString().withMargin - - override fun asRenderString() = leftOperand.asRenderString() + ' ' + operator.text + ' ' + rightOperand.asRenderString() -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBinaryExpressionWithType.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UBinaryExpressionWithType.kt deleted file mode 100644 index b9a8bd3f654..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBinaryExpressionWithType.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - - -import com.intellij.psi.PsiType -import org.jetbrains.uast.expressions.UTypeReferenceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a binary expression with type (value op type), e.g. ("A" instanceof String). - */ -interface UBinaryExpressionWithType : UExpression { - /** - * Returns the operand expression. - */ - val operand: UExpression - - /** - * Returns the operation kind. - */ - val operationKind: UastBinaryExpressionWithTypeKind - - /** - * Returns the type reference of this expression. - */ - val typeReference: UTypeReferenceExpression? - - /** - * Returns the type. - */ - val type: PsiType - - override fun asLogString() = log("UBinaryExpressionWithType " + - "(${getExpressionType()?.name}, ${operationKind.name})", operand) - - override fun asRenderString() = "${operand.asRenderString()} ${operationKind.name} ${type.name}" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitBinaryExpressionWithType(this)) return - annotations.acceptList(visitor) - operand.accept(visitor) - visitor.afterVisitBinaryExpressionWithType(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBlockExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UBlockExpression.kt deleted file mode 100644 index ca274746b82..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBlockExpression.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents the code block expression: `{ /* code */ }`. - */ -interface UBlockExpression : UExpression { - /** - * Returns the list of block expressions. - */ - val expressions: List - - override fun accept(visitor: UastVisitor) { - if (visitor.visitBlockExpression(this)) return - annotations.acceptList(visitor) - expressions.acceptList(visitor) - visitor.afterVisitBlockExpression(this) - } - - override fun asLogString() = log("UBlockExpression", expressions) - - override fun asRenderString() = buildString { - appendln("{") - expressions.forEach { appendln(it.asRenderString().withMargin) } - appendln("}") - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBreakExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UBreakExpression.kt deleted file mode 100644 index 98f8bc8f1c9..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UBreakExpression.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a `break` expression. - */ -interface UBreakExpression : UExpression { - /** - * Returns the expression label, or null if the label is not specified. - */ - val label: String? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitBreakExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitBreakExpression(this) - } - - override fun asLogString() = "UBreakExpression (" + (label ?: "") + ")" - override fun asRenderString() = label?.let { "break@$it" } ?: "break" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UCallExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UCallExpression.kt deleted file mode 100644 index fcf4eaa89dc..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UCallExpression.kt +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - - -import com.intellij.psi.PsiMethod -import com.intellij.psi.PsiType -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a call expression (method/constructor call, array initializer). - */ -interface UCallExpression : UExpression, UResolvable { - /** - * Returns the call kind. - */ - val kind: UastCallKind - - /** - * Returns the called method name, or null if the call is not a method call. - * This property should return the actual resolved function name. - */ - val methodName: String? - - /** - * Returns the expression receiver. - * For example, for call `a.b.[c()]` the receiver is `a.b`. - */ - val receiver: UExpression? - - /** - * Returns the receiver type, or null if the call has not a receiver. - */ - val receiverType: PsiType? - - /** - * Returns the function reference expression if the call is a non-constructor method call, null otherwise. - */ - val methodIdentifier: UIdentifier? - - /** - * Returns the class reference if the call is a constructor call, null otherwise. - */ - val classReference: UReferenceExpression? - - /** - * Returns the value argument count. - * - * Retrieving the argument count could be faster than getting the [valueArguments.size], - * because there is no need to create actual [UExpression] instances. - */ - val valueArgumentCount: Int - - /** - * Returns the list of value arguments. - */ - val valueArguments: List - - /** - * Returns the type argument count. - */ - val typeArgumentCount: Int - - /** - * Returns the type arguments for the call. - */ - val typeArguments: List - - /** - * Returns the return type of the called function, or null if the call is not a function call. - */ - val returnType: PsiType? - - /** - * Resolve the called method. - * - * @return the [PsiMethod], or null if the method was not resolved. - * Note that the [PsiMethod] is an unwrapped [PsiMethod], not a [UMethod]. - */ - override fun resolve(): PsiMethod? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitCallExpression(this)) return - annotations.acceptList(visitor) - methodIdentifier?.accept(visitor) - classReference?.accept(visitor) - valueArguments.acceptList(visitor) - visitor.afterVisitCallExpression(this) - } - - override fun asLogString() = log("UCallExpression ($kind, argCount = $valueArgumentCount)", methodIdentifier, valueArguments) - - override fun asRenderString(): String { - val ref = classReference?.asRenderString() ?: methodName ?: methodIdentifier?.asRenderString() ?: "" - return ref + "(" + valueArguments.joinToString { it.asRenderString() } + ")" - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UCallableReferenceExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UCallableReferenceExpression.kt deleted file mode 100644 index 6d4460370fb..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UCallableReferenceExpression.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - - -import com.intellij.psi.PsiType -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a callable reference expression, e.g. `Clazz::methodName`. - */ -interface UCallableReferenceExpression : UExpression { - /** - * Returns the qualifier expression. - * Can be null if the [qualifierType] is known. - */ - val qualifierExpression: UExpression? - - /** - * Returns the qualifier type. - * Can be null if the qualifier is an expression. - */ - val qualifierType: PsiType? - - /** - * Returns the callable name. - */ - val callableName: String - - override fun accept(visitor: UastVisitor) { - if (visitor.visitCallableReferenceExpression(this)) return - annotations.acceptList(visitor) - qualifierExpression?.accept(visitor) - visitor.afterVisitCallableReferenceExpression(this) - } - - override fun asLogString() = "UCallableReferenceExpression" - - override fun asRenderString() = buildString { - qualifierExpression?.let { - append(it.asRenderString()) - } ?: qualifierType?.let { - append(it.name) - } - append("::") - append(callableName) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UClassLiteralExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UClassLiteralExpression.kt deleted file mode 100644 index 29470d6fc9e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UClassLiteralExpression.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - - -import com.intellij.psi.PsiType -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents the class literal expression, e.g. `Clazz.class`. - */ -interface UClassLiteralExpression : UExpression { - override fun asLogString() = "UClassLiteralExpression" - override fun asRenderString() = (type?.name) ?: "(${expression?.asRenderString() ?: ""})" + "::class" - - /** - * Returns a type of this class literal, or null if the type can't be determined in a compile-time. - */ - val type: PsiType? - - /** - * Returns an expression for this class literal expression. - * Might be null if the [type] is specified. - */ - val expression: UExpression? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitClassLiteralExpression(this)) return - annotations.acceptList(visitor) - expression?.accept(visitor) - visitor.afterVisitClassLiteralExpression(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UContinueExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UContinueExpression.kt deleted file mode 100644 index 058bddeab13..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UContinueExpression.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a `continue` expression. - */ -interface UContinueExpression : UExpression { - /** - * Returns the expression label, or null if the label is not specified. - */ - val label: String? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitContinueExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitContinueExpression(this) - } - - override fun asLogString() = "UContinueExpression (" + (label ?: "") + ")" - override fun asRenderString() = label?.let { "continue@$it" } ?: "continue" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UExpressionList.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UExpressionList.kt deleted file mode 100644 index 9282bc9d7d5..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UExpressionList.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a generic list of expressions. - */ -interface UExpressionList : UExpression { - /** - * Returns the list of expressions. - */ - val expressions: List - - /** - * Returns the list kind. - */ - val kind: UastSpecialExpressionKind - - override fun accept(visitor: UastVisitor) { - if (visitor.visitExpressionList(this)) return - annotations.acceptList(visitor) - expressions.acceptList(visitor) - visitor.afterVisitExpressionList(this) - } - - fun firstOrNull(): UExpression? = expressions.firstOrNull() - - override fun asLogString() = log("USpecialExpressionList (${kind.name})", expressions) - override fun asRenderString() = kind.name + " " + expressions.joinToString(" : ") { it.asRenderString() } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UInstanceExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UInstanceExpression.kt deleted file mode 100644 index a661677d203..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UInstanceExpression.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.expressions - -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.ULabeled -import org.jetbrains.uast.UResolvable - -/** - * A common parent for "this" and "super" expressions. - */ -interface UInstanceExpression : UExpression, ULabeled, UResolvable \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULabeledExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/ULabeledExpression.kt deleted file mode 100644 index d279c78b713..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULabeledExpression.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents an expression with the label specified. - */ -interface ULabeledExpression : UExpression, ULabeled { - /** - * Returns the expression label. - */ - override val label: String - - /** - * Returns the expression itself. - */ - val expression: UExpression - - override fun accept(visitor: UastVisitor) { - if (visitor.visitLabeledExpression(this)) return - annotations.acceptList(visitor) - expression.accept(visitor) - visitor.afterVisitLabeledExpression(this) - } - - override fun evaluate() = expression.evaluate() - - override fun asLogString() = log("ULabeledExpression ($label)", expression) - override fun asRenderString() = "$label@ ${expression.asRenderString()}" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULambdaExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/ULambdaExpression.kt deleted file mode 100644 index 46495e921b5..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULambdaExpression.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents the lambda expression. - */ -interface ULambdaExpression : UExpression { - /** - * Returns the list of lambda value parameters. - */ - val valueParameters: List - - /** - * Returns the lambda body expression. - */ - val body: UExpression - - override fun accept(visitor: UastVisitor) { - if (visitor.visitLambdaExpression(this)) return - annotations.acceptList(visitor) - valueParameters.acceptList(visitor) - body.accept(visitor) - visitor.afterVisitLambdaExpression(this) - } - - override fun asLogString() = log("ULambdaExpression", valueParameters, body) - - override fun asRenderString(): String { - val renderedValueParameters = if (valueParameters.isEmpty()) - "" - else - valueParameters.joinToString { it.asRenderString() } + " ->" + LINE_SEPARATOR - - return "{ " + renderedValueParameters + body.asRenderString().withMargin + LINE_SEPARATOR + "}" - } -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt deleted file mode 100644 index e048c19387e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/ULiteralExpression.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a literal expression. - */ -interface ULiteralExpression : UExpression { - /** - * Returns the literal expression value. - * This is basically a String, Number or null if the literal is a `null` literal. - */ - val value: Any? - - /** - * Returns true if the literal is a `null`-literal, false otherwise. - */ - val isNull: Boolean - get() = value == null - - /** - * Returns true if the literal is a [String] literal, false otherwise. - */ - val isString: Boolean - get() = evaluate() is String - - /** - * Returns true if the literal is a [Boolean] literal, false otherwise. - */ - val isBoolean: Boolean - get() = evaluate() is Boolean - - override fun accept(visitor: UastVisitor) { - if (visitor.visitLiteralExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitLiteralExpression(this) - } - - override fun asRenderString(): String { - val value = value - return when (value) { - null -> "null" - is Char -> "'$value'" - is String -> '"' + value.replace("\\", "\\\\") - .replace("\r", "\\r").replace("\n", "\\n") - .replace("\t", "\\t").replace("\b", "\\b") - .replace("\"", "\\\"") + '"' - else -> value.toString() - } - } - - override fun asLogString() = "ULiteralExpression (${asRenderString()})" -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UNamedExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UNamedExpression.kt deleted file mode 100644 index 09ba4345dd0..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UNamedExpression.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -class UNamedExpression( - override val name: String, - override val containingElement: UElement? -): UExpression, UNamed { - lateinit var expression: UExpression - - override val annotations: List - get() = emptyList() - - override fun accept(visitor: UastVisitor) { - if (visitor.visitElement(this)) return - annotations.acceptList(visitor) - expression.accept(visitor) - visitor.afterVisitElement(this) - } - - override fun asLogString() = log("UNamedExpression ($name)", expression) - override fun asRenderString() = name + " = " + expression.asRenderString() - - override fun evaluate() = expression.evaluate() - - companion object { - inline fun create(name: String, parent: UElement?, innerExpr: UElement.() -> UExpression): UNamedExpression { - return UNamedExpression(name, parent).apply { - expression = innerExpr(this) - } - } - } -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UObjectLiteralExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UObjectLiteralExpression.kt deleted file mode 100644 index 7285ad13877..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UObjectLiteralExpression.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiType -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents an object literal expression, e.g. `new Runnable() {}` in Java. - */ -interface UObjectLiteralExpression : UCallExpression { - /** - * Returns the class declaration. - */ - val declaration: UClass - - override val methodIdentifier: UIdentifier? - get() = null - - override val kind: UastCallKind - get() = UastCallKind.CONSTRUCTOR_CALL - - override val methodName: String? - get() = null - - override val receiver: UExpression? - get() = null - - override val receiverType: PsiType? - get() = null - - override val returnType: PsiType? - get() = null - - - override fun accept(visitor: UastVisitor) { - if (visitor.visitObjectLiteralExpression(this)) return - annotations.acceptList(visitor) - declaration.accept(visitor) - visitor.afterVisitObjectLiteralExpression(this) - } - - override fun asLogString() = log("UObjectLiteralExpression", declaration) - override fun asRenderString() = "anonymous " + declaration.text -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UParenthesizedExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UParenthesizedExpression.kt deleted file mode 100644 index 81216fb7f12..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UParenthesizedExpression.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a parenthesized expression, e.g. `(23 + 3)`. - */ -interface UParenthesizedExpression : UExpression { - /** - * Returns an expression inside the parenthesis. - */ - val expression: UExpression - - override fun accept(visitor: UastVisitor) { - if (visitor.visitParenthesizedExpression(this)) return - annotations.acceptList(visitor) - expression.accept(visitor) - visitor.afterVisitParenthesizedExpression(this) - } - - override fun evaluate() = expression.evaluate() - - override fun asLogString() = log("UParenthesizedExpression", expression) - override fun asRenderString() = '(' + expression.asRenderString() + ')' -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UQualifiedReferenceExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UQualifiedReferenceExpression.kt deleted file mode 100644 index 8aa81927dd5..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UQualifiedReferenceExpression.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents the qualified expression (receiver.selector). - */ -interface UQualifiedReferenceExpression : UReferenceExpression { - /** - * Returns the expression receiver. - */ - val receiver: UExpression - - /** - * Returns the expression selector. - */ - val selector: UExpression - - /** - * Returns the access type (simple, safe access, etc.). - */ - val accessType: UastQualifiedExpressionAccessType - - override fun asRenderString() = receiver.asRenderString() + accessType.name + selector.asRenderString() - - override fun accept(visitor: UastVisitor) { - if (visitor.visitQualifiedReferenceExpression(this)) return - annotations.acceptList(visitor) - receiver.accept(visitor) - selector.accept(visitor) - visitor.afterVisitQualifiedReferenceExpression(this) - } - - override fun asLogString() = log("UQualifiedExpression", receiver, selector) -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UReferenceExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UReferenceExpression.kt deleted file mode 100644 index 45ec72f1676..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UReferenceExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.expressions - -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.UResolvable - -interface UReferenceExpression : UExpression, UResolvable { - /** - * Returns the resolved name for this reference, or null if the reference can't be resolved. - */ - val resolvedName: String? - - override fun asLogString() = "UReferenceExpression" -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UReturnExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UReturnExpression.kt deleted file mode 100644 index cc8d52b4a17..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UReturnExpression.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a `return` expression. - */ -interface UReturnExpression : UExpression { - /** - * Returns the `return` value. - */ - val returnExpression: UExpression? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitReturnExpression(this)) return - annotations.acceptList(visitor) - returnExpression?.accept(visitor) - visitor.afterVisitReturnExpression(this) - } - - override fun asRenderString() = returnExpression.let { if (it == null) "return" else "return " + it.asRenderString() } - override fun asLogString() = log("UReturnExpression", returnExpression) -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/USimpleNameReferenceExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/USimpleNameReferenceExpression.kt deleted file mode 100644 index e480b6453e2..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/USimpleNameReferenceExpression.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a simple reference expression (a non-qualified identifier). - */ -interface USimpleNameReferenceExpression : UReferenceExpression { - /** - * Returns the identifier name. - */ - val identifier: String - - override fun accept(visitor: UastVisitor) { - if (visitor.visitSimpleNameReferenceExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitSimpleNameReferenceExpression(this) - } - - override fun asLogString() = "USimpleReferenceExpression ($identifier)" - override fun asRenderString() = identifier -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/USuperExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/USuperExpression.kt deleted file mode 100644 index f0770d37790..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/USuperExpression.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.expressions.UInstanceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a `super` expression. - * Qualified `super` is not supported at the moment. - */ -interface USuperExpression : UInstanceExpression { - override fun asLogString() = "USuperExpression" - override fun asRenderString() = "super" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitSuperExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitSuperExpression(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UThisExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UThisExpression.kt deleted file mode 100644 index 6cde5a2de25..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UThisExpression.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.expressions.UInstanceExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a `this` expression. - * Qualified `this` is not supported at the moment. - */ -interface UThisExpression : UInstanceExpression { - override fun asLogString() = "UThisExpression" - override fun asRenderString() = "this" - - override fun accept(visitor: UastVisitor) { - if (visitor.visitThisExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitThisExpression(this) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UThrowExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UThrowExpression.kt deleted file mode 100644 index 56695782f3b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UThrowExpression.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a `throw` expression. - */ -interface UThrowExpression : UExpression { - /** - * Returns ths thrown expression. - */ - val thrownExpression: UExpression - - override fun accept(visitor: UastVisitor) { - if (visitor.visitThrowExpression(this)) return - annotations.acceptList(visitor) - thrownExpression.accept(visitor) - visitor.afterVisitThrowExpression(this) - } - - override fun asRenderString() = "throw " + thrownExpression.asRenderString() - override fun asLogString() = log("UThrowExpression", thrownExpression) -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UTypeReferenceExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UTypeReferenceExpression.kt deleted file mode 100644 index 7d46b177804..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UTypeReferenceExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -package org.jetbrains.uast.expressions - -import com.intellij.psi.PsiType -import com.intellij.psi.util.PsiTypesUtil -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.name -import org.jetbrains.uast.visitor.UastVisitor - -interface UTypeReferenceExpression : UExpression { - /** - * Returns the resolved type for this reference. - */ - val type: PsiType - - /** - * Returns the qualified name of the class type, or null if the [type] is not a class type. - */ - fun getQualifiedName() = PsiTypesUtil.getPsiClass(type)?.qualifiedName - - override fun accept(visitor: UastVisitor) { - if (visitor.visitTypeReferenceExpression(this)) return - annotations.acceptList(visitor) - visitor.afterVisitTypeReferenceExpression(this) - } - - override fun asLogString() = "UTypeReferenceExpression (${type.name})" - override fun asRenderString() = type.name -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UUnaryExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UUnaryExpression.kt deleted file mode 100644 index 2989efafe5b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UUnaryExpression.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiMethod -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -interface UUnaryExpression : UExpression { - /** - * Returns the expression operand. - */ - val operand: UExpression - - /** - * Returns the expression operator. - */ - val operator: UastOperator - - /** - * Returns the operator identifier. - */ - val operatorIdentifier: UIdentifier? - - /** - * Resolve the operator method. - * - * @return the resolved method, or null if the method can't be resolved, or if the expression is not a method call. - */ - fun resolveOperator(): PsiMethod? - - override fun accept(visitor: UastVisitor) { - if (visitor.visitUnaryExpression(this)) return - annotations.acceptList(visitor) - operand.accept(visitor) - visitor.afterVisitUnaryExpression(this) - } -} - -interface UPrefixExpression : UUnaryExpression { - override val operator: UastPrefixOperator - - override fun accept(visitor: UastVisitor) { - if (visitor.visitPrefixExpression(this)) return - annotations.acceptList(visitor) - operand.accept(visitor) - visitor.afterVisitPrefixExpression(this) - } - - override fun asLogString() = log("UPrefixExpression (${operator.text})", operand) - override fun asRenderString() = operator.text + operand.asRenderString() -} - -interface UPostfixExpression : UUnaryExpression { - override val operator: UastPostfixOperator - - override fun accept(visitor: UastVisitor) { - if (visitor.visitPostfixExpression(this)) return - annotations.acceptList(visitor) - operand.accept(visitor) - visitor.afterVisitPostfixExpression(this) - } - - override fun asLogString() = log("UPostfixExpression (${operator.text})", operand) - override fun asRenderString() = operand.asRenderString() + operator.text -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/UVariableDeclarationsExpression.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/UVariableDeclarationsExpression.kt deleted file mode 100644 index 25d32ccca87..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/UVariableDeclarationsExpression.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.internal.log -import org.jetbrains.uast.visitor.UastVisitor - -/** - * Represents a list of declarations. - * Example in Java: `int a = 4, b = 3`. - */ -interface UVariableDeclarationsExpression : UExpression { - /** - * Returns the list of variables inside this [UVariableDeclarationsExpression]. - */ - val variables: List - - override fun accept(visitor: UastVisitor) { - if (visitor.visitDeclarationsExpression(this)) return - annotations.acceptList(visitor) - variables.acceptList(visitor) - visitor.afterVisitDeclarationsExpression(this) - } - - override fun asRenderString() = variables.joinToString(LINE_SEPARATOR) { it.asRenderString() } - override fun asLogString() = log("UDeclarationsExpression", variables) -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/expressions/uastLiteralUtils.kt b/plugins/uast-common/src/org/jetbrains/uast/expressions/uastLiteralUtils.kt deleted file mode 100644 index dd488fb6adc..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/expressions/uastLiteralUtils.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@file:JvmName("UastLiteralUtils") -package org.jetbrains.uast - -/** - * Checks if the [UElement] is a null literal. - * - * @return true if the receiver is a null literal, false otherwise. - */ -fun UElement.isNullLiteral(): Boolean = this is ULiteralExpression && this.isNull - -/** - * Checks if the [UElement] is a boolean literal. - * - * @return true if the receiver is a boolean literal, false otherwise. - */ -fun UElement.isBooleanLiteral(): Boolean = this is ULiteralExpression && this.isBoolean - -/** - * Checks if the [UElement] is a `true` boolean literal. - * - * @return true if the receiver is a `true` boolean literal, false otherwise. - */ -fun UElement.isTrueLiteral(): Boolean = this is ULiteralExpression && this.isBoolean && this.value == true - -/** - * Checks if the [UElement] is a `false` boolean literal. - * - * @return true if the receiver is a `false` boolean literal, false otherwise. - */ -fun UElement.isFalseLiteral(): Boolean = this is ULiteralExpression && this.isBoolean && this.value == false - -/** - * Checks if the [UElement] is a [String] literal. - * - * @return true if the receiver is a [String] literal, false otherwise. - */ -fun UElement.isStringLiteral(): Boolean = this is ULiteralExpression && this.isString - -/** - * Returns the [String] literal value. - * - * @return literal text if the receiver is a valid [String] literal, null otherwise. - */ -fun UElement.getValueIfStringLiteral(): String? = - if (isStringLiteral()) (this as ULiteralExpression).value as String else null - -/** - * Checks if the [UElement] is a [Number] literal (Integer, Long, Float, Double, etc.). - * - * @return true if the receiver is a [Number] literal, false otherwise. - */ -fun UElement.isNumberLiteral(): Boolean = this is ULiteralExpression && this.value is Number - -/** - * Checks if the [UElement] is an integral literal (is an [Integer], [Long], [Short], [Char] or [Byte]). - * - * @return true if the receiver is an integral literal, false otherwise. - */ -fun UElement.isIntegralLiteral(): Boolean = this is ULiteralExpression && when (value) { - is Int -> true - is Long -> true - is Short -> true - is Char -> true - is Byte -> true - else -> false -} - -/** - * Returns the integral value of the literal. - * - * @return long representation of the literal expression value, - * 0 if the receiver literal expression is not a integral one. - */ -fun ULiteralExpression.getLongValue(): Long = value.let { - when (it) { - is Long -> it - is Int -> it.toLong() - is Short -> it.toLong() - is Char -> it.toLong() - is Byte -> it.toLong() - else -> 0 - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/internal/implementationUtils.kt b/plugins/uast-common/src/org/jetbrains/uast/internal/implementationUtils.kt deleted file mode 100644 index e820c94ad21..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/internal/implementationUtils.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.jetbrains.uast.internal - -import com.intellij.psi.PsiElement -import org.jetbrains.uast.LINE_SEPARATOR -import org.jetbrains.uast.UElement -import org.jetbrains.uast.asLogString -import org.jetbrains.uast.visitor.UastVisitor -import org.jetbrains.uast.withMargin - -/** - * Builds the log message for the [UElement.asLogString] function. - * - * @param firstLine the message line (the interface name, some optional information). - * @param nested nested UElements. Could be `List`, [UElement] or `null`. - * @throws IllegalStateException if the [nested] argument is invalid. - * @return the rendered log string. - */ -fun UElement.log(firstLine: String, vararg nested: Any?): String { - return (if (firstLine.isBlank()) "" else firstLine + LINE_SEPARATOR) + nested.joinToString(LINE_SEPARATOR) { - when (it) { - null -> "".withMargin - is List<*> -> { - if (it.firstOrNull() is PsiElement) { - @Suppress("UNCHECKED_CAST") - (it as List).joinToString(LINE_SEPARATOR) { it.text } - } else { - @Suppress("UNCHECKED_CAST") - (it as List).asLogString() - } - } - is UElement -> it.asLogString().withMargin - else -> error("Invalid element type: $it") - } - } -} - -fun List.acceptList(visitor: UastVisitor) { - for (element in this) { - element.accept(visitor) - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/internal/internalUastUtils.kt b/plugins/uast-common/src/org/jetbrains/uast/internal/internalUastUtils.kt deleted file mode 100644 index 5de0428299b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/internal/internalUastUtils.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiType - -internal val ERROR_NAME = "" - -internal val LINE_SEPARATOR = System.getProperty("line.separator") ?: "\n" - -val String.withMargin: String - get() = lines().joinToString(LINE_SEPARATOR) { " " + it } - -internal operator fun String.times(n: Int) = this.repeat(n) - -internal fun List.asLogString() = joinToString(LINE_SEPARATOR) { it.asLogString().withMargin } - -internal fun StringBuilder.appendWithSpace(s: String) { - if (s.isNotEmpty()) { - append(s) - append(' ') - } -} - -internal tailrec fun UExpression.unwrapParenthesis(): UExpression = when (this) { - is UParenthesizedExpression -> expression.unwrapParenthesis() - else -> this -} - -internal fun lz(f: () -> T) = lazy(LazyThreadSafetyMode.NONE, f) - -internal val PsiType.name: String - get() = getCanonicalText(false) \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryExpressionWithTypeKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryExpressionWithTypeKind.kt deleted file mode 100644 index 7d04875e5f5..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryExpressionWithTypeKind.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@file:JvmName("UastBinaryExpressionWithTypeUtils") -package org.jetbrains.uast - -/** - * Kinds of [UBinaryExpressionWithType]. - * Examples: type casts, instance checks. - */ -open class UastBinaryExpressionWithTypeKind(val name: String) { - open class TypeCast(name: String) : UastBinaryExpressionWithTypeKind(name) - open class InstanceCheck(name: String) : UastBinaryExpressionWithTypeKind(name) - - companion object { - @JvmField - val TYPE_CAST = TypeCast("as") - - @JvmField - val INSTANCE_CHECK = InstanceCheck("is") - - @JvmField - val UNKNOWN = UastBinaryExpressionWithTypeKind("") - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt deleted file mode 100644 index 9e55066a67b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastBinaryOperator.kt +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * Kinds of operators in [UBinaryExpression]. - */ -open class UastBinaryOperator(override val text: String): UastOperator { - class LogicalOperator(text: String): UastBinaryOperator(text) - class ComparisonOperator(text: String): UastBinaryOperator(text) - class ArithmeticOperator(text: String): UastBinaryOperator(text) - class BitwiseOperator(text: String): UastBinaryOperator(text) - class AssignOperator(text: String): UastBinaryOperator(text) - - companion object { - @JvmField - val ASSIGN = AssignOperator("=") - - @JvmField - val PLUS = ArithmeticOperator("+") - - @JvmField - val MINUS = ArithmeticOperator("-") - - @JvmField - val MULTIPLY = ArithmeticOperator("*") - - @JvmField - val DIV = ArithmeticOperator("/") - - @JvmField - val MOD = ArithmeticOperator("%") - - @JvmField - val LOGICAL_OR = LogicalOperator("||") - - @JvmField - val LOGICAL_AND = LogicalOperator("&&") - - @JvmField - val BITWISE_OR = BitwiseOperator("|") - - @JvmField - val BITWISE_AND = BitwiseOperator("&") - - @JvmField - val BITWISE_XOR = BitwiseOperator("^") - - @JvmField - val EQUALS = ComparisonOperator("==") - - @JvmField - val NOT_EQUALS = ComparisonOperator("!=") - - @JvmField - val IDENTITY_EQUALS = ComparisonOperator("===") - - @JvmField - val IDENTITY_NOT_EQUALS = ComparisonOperator("!==") - - @JvmField - val GREATER = ComparisonOperator(">") - - @JvmField - val GREATER_OR_EQUAL = ComparisonOperator(">=") - - @JvmField - val LESS = ComparisonOperator("<") - - @JvmField - val LESS_OR_EQUAL = ComparisonOperator("<=") - - @JvmField - val SHIFT_LEFT = BitwiseOperator("<<") - - @JvmField - val SHIFT_RIGHT = BitwiseOperator(">>") - - @JvmField - val UNSIGNED_SHIFT_RIGHT = BitwiseOperator(">>>") - - @JvmField - val OTHER = UastBinaryOperator("") - - @JvmField - val PLUS_ASSIGN = AssignOperator("+=") - - @JvmField - val MINUS_ASSIGN = AssignOperator("-=") - - @JvmField - val MULTIPLY_ASSIGN = AssignOperator("*=") - - @JvmField - val DIVIDE_ASSIGN = AssignOperator("/=") - - @JvmField - val REMAINDER_ASSIGN = AssignOperator("%=") - - @JvmField - val AND_ASSIGN = AssignOperator("&=") - - @JvmField - val XOR_ASSIGN = AssignOperator("^=") - - @JvmField - val OR_ASSIGN = AssignOperator("|=") - - @JvmField - val SHIFT_LEFT_ASSIGN = AssignOperator("<<=") - - @JvmField - val SHIFT_RIGHT_ASSIGN = AssignOperator(">>=") - - @JvmField - val UNSIGNED_SHIFT_RIGHT_ASSIGN = AssignOperator(">>>=") - } - - override fun toString(): String{ - return "UastBinaryOperator(text='$text')" - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt deleted file mode 100644 index af2cc5bda7e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastCallKind.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * Kinds of [UCallExpression]. - */ -open class UastCallKind(val name: String) { - companion object { - @JvmField - val METHOD_CALL = UastCallKind("method_call") - - @JvmField - val CONSTRUCTOR_CALL = UastCallKind("constructor_call") - - @JvmField - val NEW_ARRAY_WITH_DIMENSIONS = UastCallKind("new_array_with_dimensions") - - /** - * Initializer parts are available in call expression as value arguments. - * [NEW_ARRAY_WITH_INITIALIZER] is a top-level initializer. In case of multi-dimensional arrays, inner initializers - * have type of [NESTED_ARRAY_INITIALIZER]. - */ - @JvmField - val NEW_ARRAY_WITH_INITIALIZER = UastCallKind("new_array_with_initializer") - - @JvmField - val NESTED_ARRAY_INITIALIZER = UastCallKind("array_initializer") - } - - override fun toString(): String{ - return "UastCallKind(name='$name')" - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt deleted file mode 100644 index d8d9bb44db4..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastClassKind.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast - -/** - * Kinds of [UClass]. - */ -open class UastClassKind(val text: String) { - companion object { - @JvmField - val CLASS = UastClassKind("class") - - @JvmField - val INTERFACE = UastClassKind("interface") - - @JvmField - val ANNOTATION = UastClassKind("annotation") - - @JvmField - val ENUM = UastClassKind("enum") - - @JvmField - val OBJECT = UastClassKind("object") - } - - override fun toString(): String{ - return "UastClassKind(text='$text')" - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastOperator.kt deleted file mode 100644 index b605642be1e..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastOperator.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * Uast operator base interface. - * - * @see [UastPrefixOperator], [UastPostfixOperator], [UastBinaryOperator] - */ -interface UastOperator { - /** - * Returns the operator text to render in [UElement.asRenderString]. - */ - val text: String -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt deleted file mode 100644 index 1fbd2af5773..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPostfixOperator.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * [UPostfixExpression] operators. - */ -open class UastPostfixOperator(override val text: String): UastOperator { - companion object { - @JvmField - val INC = UastPostfixOperator("++") - - @JvmField - val DEC = UastPostfixOperator("--") - - @JvmField - val UNKNOWN = UastPostfixOperator("") - } - - override fun toString(): String{ - return "UastPostfixOperator(text='$text')" - } -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt deleted file mode 100644 index e4f021998ce..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastPrefixOperator.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * [UPrefixExpression] operators. - */ -class UastPrefixOperator(override val text: String): UastOperator { - companion object { - @JvmField - val INC = UastPrefixOperator("++") - - @JvmField - val DEC = UastPrefixOperator("--") - - @JvmField - val UNARY_MINUS = UastPrefixOperator("-") - - @JvmField - val UNARY_PLUS = UastPrefixOperator("+") - - @JvmField - val LOGICAL_NOT = UastPrefixOperator("!") - - @JvmField - val BITWISE_NOT = UastPrefixOperator("~") - - @JvmField - val UNKNOWN = UastPrefixOperator("") - } - - override fun toString(): String{ - return "UastPrefixOperator(text='$text')" - } -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt deleted file mode 100644 index 2ce4e64273f..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastQualifiedExpressionAccessType.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * Access types of [UQualifiedReferenceExpression]. - * Additional type examples: Kotlin safe call (?.). - */ -open class UastQualifiedExpressionAccessType(val name: String) { - companion object { - @JvmField - val SIMPLE = UastQualifiedExpressionAccessType(".") - } - - override fun toString(): String{ - return "UastQualifiedExpressionAccessType(name='$name')" - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt deleted file mode 100644 index e191d17a081..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastSpecialExpressionKind.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -/** - * Kinds of [UExpressionList]. - */ -open class UastSpecialExpressionKind(val name: String) { - override fun toString(): String{ - return "UastSpecialExpressionKind(name='$name')" - } -} diff --git a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt b/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt deleted file mode 100644 index 8a9d056e242..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/kinds/UastVisibility.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast - -import com.intellij.psi.PsiLocalVariable -import com.intellij.psi.PsiModifier -import com.intellij.psi.PsiModifierListOwner - -enum class UastVisibility(val text: String) { - PUBLIC("public"), - PRIVATE("private"), - PROTECTED("protected"), - PACKAGE_LOCAL("packageLocal"), - LOCAL("local"); - - override fun toString() = text - - companion object { - operator fun get(declaration: PsiModifierListOwner): UastVisibility { - if (declaration.hasModifierProperty(PsiModifier.PUBLIC)) return UastVisibility.PUBLIC - if (declaration.hasModifierProperty(PsiModifier.PROTECTED)) return UastVisibility.PROTECTED - if (declaration.hasModifierProperty(PsiModifier.PRIVATE)) return UastVisibility.PRIVATE - if (declaration is PsiLocalVariable) return UastVisibility.LOCAL - return UastVisibility.PACKAGE_LOCAL - } - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/psi/PsiElementBacked.kt b/plugins/uast-common/src/org/jetbrains/uast/psi/PsiElementBacked.kt deleted file mode 100644 index 10eeaa3db08..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/psi/PsiElementBacked.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@file:JvmName("UastPsiUtils") -package org.jetbrains.uast.psi - -import com.intellij.psi.PsiElement -import org.jetbrains.uast.UElement - -interface PsiElementBacked : UElement { - val psi: PsiElement? - - override val isPsiValid: Boolean - get() = psi?.isValid ?: true -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/psi/UElementWithLocation.kt b/plugins/uast-common/src/org/jetbrains/uast/psi/UElementWithLocation.kt deleted file mode 100644 index e31d775808b..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/psi/UElementWithLocation.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.uast.psi - -import com.intellij.openapi.util.Segment -import org.jetbrains.uast.UElement - -interface UElementWithLocation : UElement, Segment \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/psi/UastPsiParameterNotResolved.kt b/plugins/uast-common/src/org/jetbrains/uast/psi/UastPsiParameterNotResolved.kt deleted file mode 100644 index 544c50cbca9..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/psi/UastPsiParameterNotResolved.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.uast.psi - -import com.intellij.lang.Language -import com.intellij.psi.PsiElement -import com.intellij.psi.impl.light.LightParameter -import org.jetbrains.uast.UastErrorType - -class UastPsiParameterNotResolved( - declarationScope: PsiElement, - language: Language -) : LightParameter("error", UastErrorType, declarationScope, language) \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/qualifiedUtils.kt b/plugins/uast-common/src/org/jetbrains/uast/qualifiedUtils.kt deleted file mode 100644 index 22b5f619e05..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/qualifiedUtils.kt +++ /dev/null @@ -1,160 +0,0 @@ -@file:JvmMultifileClass -@file:JvmName("UastUtils") -package org.jetbrains.uast - -/** - * Get the topmost parent qualified expression for the call expression. - * - * Example 1: - * Code: variable.call(args) - * Call element: E = call(args) - * Qualified parent (return value): Q = [getQualifiedCallElement](E) = variable.call(args) - * - * Example 2: - * Code: call(args) - * Call element: E = call(args) - * Qualified parent (return value): Q = [getQualifiedCallElement](E) = call(args) (no qualifier) - * - * @return containing qualified expression if the call is a child of the qualified expression, call element otherwise. - */ -fun UExpression.getQualifiedParentOrThis(): UExpression { - fun findParent(current: UExpression?, previous: UExpression): UExpression? = when (current) { - is UQualifiedReferenceExpression -> { - if (current.selector == previous) - findParent(current.containingElement as? UExpression, current) ?: current - else - previous - } - is UParenthesizedExpression -> findParent(current.expression, previous) ?: previous - else -> null - } - - return findParent(containingElement as? UExpression, this) ?: this -} - - -fun UExpression.asQualifiedPath(): List? { - if (this is USimpleNameReferenceExpression) { - return listOf(this.identifier) - } else if (this !is UQualifiedReferenceExpression) { - return null - } - - var error = false - val list = mutableListOf() - fun addIdentifiers(expr: UQualifiedReferenceExpression) { - val receiver = expr.receiver.unwrapParenthesis() - val selector = expr.selector as? USimpleNameReferenceExpression ?: run { error = true; return } - when (receiver) { - is UQualifiedReferenceExpression -> addIdentifiers(receiver) - is USimpleNameReferenceExpression -> list += receiver.identifier - else -> { - error = true - return - } - } - list += selector.identifier - } - - addIdentifiers(this) - return if (error) null else list -} - -/** - * Return the list of qualified expressions. - * - * Example: - * Code: obj.call(param).anotherCall(param2).getter - * Qualified chain: [obj, call(param), anotherCall(param2), getter] - * - * @return list of qualified expressions, or the empty list if the received expression is not a qualified expression. - */ -fun UExpression?.getQualifiedChain(): List { - fun collect(expr: UQualifiedReferenceExpression, chains: MutableList) { - val receiver = expr.receiver.unwrapParenthesis() - if (receiver is UQualifiedReferenceExpression) { - collect(receiver, chains) - } else { - chains += receiver - } - - val selector = expr.selector.unwrapParenthesis() - if (selector is UQualifiedReferenceExpression) { - collect(selector, chains) - } else { - chains += selector - } - } - - if (this == null) return emptyList() - val qualifiedExpression = this as? UQualifiedReferenceExpression ?: return listOf(this) - val chains = mutableListOf() - collect(qualifiedExpression, chains) - return chains -} - -/** - * Return the outermost qualified expression. - * - * @return the outermost qualified expression, - * this element if the parent expression is not a qualified expression, - * or null if the element is not a qualified expression. - * - * Example: - * Code: a.b.c(asd).g - * Call element: c(asd) - * Outermost qualified (return value): a.b.c(asd).g - */ -fun UExpression.getOutermostQualified(): UQualifiedReferenceExpression? { - tailrec fun getOutermostQualified(current: UElement?, previous: UExpression): UQualifiedReferenceExpression? = when (current) { - is UQualifiedReferenceExpression -> getOutermostQualified(current.containingElement, current) - is UParenthesizedExpression -> getOutermostQualified(current.containingElement, previous) - else -> if (previous is UQualifiedReferenceExpression) previous else null - } - - return getOutermostQualified(this.containingElement, this) -} - -/** - * Checks if the received expression is a qualified chain of identifiers, and the trailing part of such chain is [fqName]. - * - * @param fqName the chain part to check against. Sequence of identifiers, separated by dot ('.'). Example: "com.example". - * @return true, if the received expression is a qualified chain of identifiers, and the trailing part of such chain is [fqName]. - */ -fun UExpression.matchesQualified(fqName: String): Boolean { - val identifiers = this.asQualifiedPath() ?: return false - val passedIdentifiers = fqName.trim('.').split('.') - return identifiers == passedIdentifiers -} - -/** - * Checks if the received expression is a qualified chain of identifiers, and the leading part of such chain is [fqName]. - * - * @param fqName the chain part to check against. Sequence of identifiers, separated by dot ('.'). Example: "com.example". - * @return true, if the received expression is a qualified chain of identifiers, and the leading part of such chain is [fqName]. - */ -fun UExpression.startsWithQualified(fqName: String): Boolean { - val identifiers = this.asQualifiedPath() ?: return false - val passedIdentifiers = fqName.trim('.').split('.') - if (identifiers.size < passedIdentifiers.size) return false - passedIdentifiers.forEachIndexed { i, passedIdentifier -> - if (passedIdentifier != identifiers[i]) return false - } - return true -} - -/** - * Checks if the received expression is a qualified chain of identifiers, and the trailing part of such chain is [fqName]. - * - * @param fqName the chain part to check against. Sequence of identifiers, separated by dot ('.'). Example: "com.example". - * @return true, if the received expression is a qualified chain of identifiers, and the trailing part of such chain is [fqName]. - */ -fun UExpression.endsWithQualified(fqName: String): Boolean { - val identifiers = this.asQualifiedPath()?.asReversed() ?: return false - val passedIdentifiers = fqName.trim('.').split('.').asReversed() - if (identifiers.size < passedIdentifiers.size) return false - passedIdentifiers.forEachIndexed { i, passedIdentifier -> - if (passedIdentifier != identifiers[i]) return false - } - return true -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/util/callUtils.kt b/plugins/uast-common/src/org/jetbrains/uast/util/callUtils.kt deleted file mode 100644 index dc973a6bcf7..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/util/callUtils.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JvmName("UastExpressionUtils") -package org.jetbrains.uast.util - -import org.jetbrains.uast.* - -fun UElement.isConstructorCall() = (this as? UCallExpression)?.kind == UastCallKind.CONSTRUCTOR_CALL - -fun UElement.isMethodCall() = (this as? UCallExpression)?.kind == UastCallKind.METHOD_CALL - -fun UElement.isNewArray() = isNewArrayWithDimensions() || isNewArrayWithInitializer() - -fun UElement.isNewArrayWithDimensions() = (this as? UCallExpression)?.kind == UastCallKind.NEW_ARRAY_WITH_DIMENSIONS - -fun UElement.isNewArrayWithInitializer() = (this as? UCallExpression)?.kind == UastCallKind.NEW_ARRAY_WITH_INITIALIZER - -@Deprecated("Use isArrayInitializer()", ReplaceWith("isArrayInitializer()")) -fun UElement.isNestedArrayInitializer() = isArrayInitializer() - -fun UElement.isArrayInitializer() = (this as? UCallExpression)?.kind == UastCallKind.NESTED_ARRAY_INITIALIZER - -fun UElement.isTypeCast() = (this as? UBinaryExpressionWithType)?.operationKind is UastBinaryExpressionWithTypeKind.TypeCast - -fun UElement.isInstanceCheck() = (this as? UBinaryExpressionWithType)?.operationKind is UastBinaryExpressionWithTypeKind.InstanceCheck - -fun UElement.isAssignment() = (this as? UBinaryExpression)?.operator is UastBinaryOperator.AssignOperator \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/visitor/DelegatingUastVisitor.kt b/plugins/uast-common/src/org/jetbrains/uast/visitor/DelegatingUastVisitor.kt deleted file mode 100644 index badcc0589a9..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/visitor/DelegatingUastVisitor.kt +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.visitor - -import org.jetbrains.uast.* -import org.jetbrains.uast.expressions.UTypeReferenceExpression - - -class DelegatingUastVisitor(private val visitors: List): UastVisitor { - override fun visitElement(node: UElement): Boolean { - return visitors.all { it.visitElement(node) } - } - - override fun visitVariable(node: UVariable): Boolean { - return visitors.all { it.visitVariable(node) } - } - - override fun visitMethod(node: UMethod): Boolean { - return visitors.all { it.visitMethod(node) } - } - - override fun visitLabeledExpression(node: ULabeledExpression): Boolean { - return visitors.all { it.visitLabeledExpression(node) } - } - - override fun visitDeclarationsExpression(node: UVariableDeclarationsExpression): Boolean { - return visitors.all { it.visitDeclarationsExpression(node) } - } - - override fun visitBlockExpression(node: UBlockExpression): Boolean { - return visitors.all { it.visitBlockExpression(node) } - } - - override fun visitQualifiedReferenceExpression(node: UQualifiedReferenceExpression): Boolean { - return visitors.all { it.visitQualifiedReferenceExpression(node) } - } - - override fun visitSimpleNameReferenceExpression(node: USimpleNameReferenceExpression): Boolean { - return visitors.all { it.visitSimpleNameReferenceExpression(node) } - } - - override fun visitTypeReferenceExpression(node: UTypeReferenceExpression): Boolean { - return visitors.all { it.visitTypeReferenceExpression(node) } - } - - override fun visitCallExpression(node: UCallExpression): Boolean { - return visitors.all { it.visitCallExpression(node) } - } - - override fun visitBinaryExpression(node: UBinaryExpression): Boolean { - return visitors.all { it.visitBinaryExpression(node) } - } - - override fun visitBinaryExpressionWithType(node: UBinaryExpressionWithType): Boolean { - return visitors.all { it.visitBinaryExpressionWithType(node) } - } - - override fun visitParenthesizedExpression(node: UParenthesizedExpression): Boolean { - return visitors.all { it.visitParenthesizedExpression(node) } - } - - override fun visitUnaryExpression(node: UUnaryExpression): Boolean { - return visitors.all { it.visitUnaryExpression(node) } - } - - override fun visitPrefixExpression(node: UPrefixExpression): Boolean { - return visitors.all { it.visitPrefixExpression(node) } - } - - override fun visitPostfixExpression(node: UPostfixExpression): Boolean { - return visitors.all { it.visitPostfixExpression(node) } - } - - override fun visitExpressionList(node: UExpressionList): Boolean { - return visitors.all { it.visitExpressionList(node) } - } - - override fun visitIfExpression(node: UIfExpression): Boolean { - return visitors.all { it.visitIfExpression(node) } - } - - override fun visitSwitchExpression(node: USwitchExpression): Boolean { - return visitors.all { it.visitSwitchExpression(node) } - } - - override fun visitSwitchClauseExpression(node: USwitchClauseExpression): Boolean { - return visitors.all { it.visitSwitchClauseExpression(node) } - } - - override fun visitWhileExpression(node: UWhileExpression): Boolean { - return visitors.all { it.visitWhileExpression(node) } - } - - override fun visitDoWhileExpression(node: UDoWhileExpression): Boolean { - return visitors.all { it.visitDoWhileExpression(node) } - } - - override fun visitForExpression(node: UForExpression): Boolean { - return visitors.all { it.visitForExpression(node) } - } - - override fun visitForEachExpression(node: UForEachExpression): Boolean { - return visitors.all { it.visitForEachExpression(node) } - } - - override fun visitTryExpression(node: UTryExpression): Boolean { - return visitors.all { it.visitTryExpression(node) } - } - - override fun visitCatchClause(node: UCatchClause): Boolean { - return visitors.all { it.visitCatchClause(node) } - } - - override fun visitLiteralExpression(node: ULiteralExpression): Boolean { - return visitors.all { it.visitLiteralExpression(node) } - } - - override fun visitThisExpression(node: UThisExpression): Boolean { - return visitors.all { it.visitThisExpression(node) } - } - - override fun visitSuperExpression(node: USuperExpression): Boolean { - return visitors.all { it.visitSuperExpression(node) } - } - - override fun visitReturnExpression(node: UReturnExpression): Boolean { - return visitors.all { it.visitReturnExpression(node) } - } - - override fun visitBreakExpression(node: UBreakExpression): Boolean { - return visitors.all { it.visitBreakExpression(node) } - } - - override fun visitContinueExpression(node: UContinueExpression): Boolean { - return visitors.all { it.visitContinueExpression(node) } - } - - override fun visitThrowExpression(node: UThrowExpression): Boolean { - return visitors.all { it.visitThrowExpression(node) } - } - - override fun visitArrayAccessExpression(node: UArrayAccessExpression): Boolean { - return visitors.all { it.visitArrayAccessExpression(node) } - } - - override fun visitCallableReferenceExpression(node: UCallableReferenceExpression): Boolean { - return visitors.all { it.visitCallableReferenceExpression(node) } - } - - override fun visitClassLiteralExpression(node: UClassLiteralExpression): Boolean { - return visitors.all { it.visitClassLiteralExpression(node) } - } - - override fun visitLambdaExpression(node: ULambdaExpression): Boolean { - return visitors.all { it.visitLambdaExpression(node) } - } - - override fun visitObjectLiteralExpression(node: UObjectLiteralExpression): Boolean { - return visitors.all { it.visitObjectLiteralExpression(node) } - } -} \ No newline at end of file diff --git a/plugins/uast-common/src/org/jetbrains/uast/visitor/UastVisitor.kt b/plugins/uast-common/src/org/jetbrains/uast/visitor/UastVisitor.kt deleted file mode 100644 index 12e448baf63..00000000000 --- a/plugins/uast-common/src/org/jetbrains/uast/visitor/UastVisitor.kt +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.visitor - -import org.jetbrains.uast.* -import org.jetbrains.uast.expressions.UTypeReferenceExpression - -interface UastVisitor { - fun visitElement(node: UElement): Boolean - - fun visitFile(node: UFile): Boolean = visitElement(node) - fun visitImportStatement(node: UImportStatement): Boolean = visitElement(node) - fun visitClass(node: UClass): Boolean = visitElement(node) - fun visitInitializer(node: UClassInitializer): Boolean = visitElement(node) - fun visitMethod(node: UMethod): Boolean = visitElement(node) - fun visitVariable(node: UVariable): Boolean = visitElement(node) - fun visitAnnotation(node: UAnnotation): Boolean = visitElement(node) - - // Expressions - fun visitLabeledExpression(node: ULabeledExpression) = visitElement(node) - fun visitDeclarationsExpression(node: UVariableDeclarationsExpression) = visitElement(node) - fun visitBlockExpression(node: UBlockExpression) = visitElement(node) - fun visitQualifiedReferenceExpression(node: UQualifiedReferenceExpression) = visitElement(node) - fun visitSimpleNameReferenceExpression(node: USimpleNameReferenceExpression) = visitElement(node) - fun visitTypeReferenceExpression(node: UTypeReferenceExpression) = visitElement(node) - fun visitCallExpression(node: UCallExpression) = visitElement(node) - fun visitBinaryExpression(node: UBinaryExpression) = visitElement(node) - fun visitBinaryExpressionWithType(node: UBinaryExpressionWithType) = visitElement(node) - fun visitParenthesizedExpression(node: UParenthesizedExpression) = visitElement(node) - fun visitUnaryExpression(node: UUnaryExpression) = visitElement(node) - fun visitPrefixExpression(node: UPrefixExpression) = visitElement(node) - fun visitPostfixExpression(node: UPostfixExpression) = visitElement(node) - fun visitExpressionList(node: UExpressionList) = visitElement(node) - fun visitIfExpression(node: UIfExpression) = visitElement(node) - fun visitSwitchExpression(node: USwitchExpression) = visitElement(node) - fun visitSwitchClauseExpression(node: USwitchClauseExpression) = visitElement(node) - fun visitWhileExpression(node: UWhileExpression) = visitElement(node) - fun visitDoWhileExpression(node: UDoWhileExpression) = visitElement(node) - fun visitForExpression(node: UForExpression) = visitElement(node) - fun visitForEachExpression(node: UForEachExpression) = visitElement(node) - fun visitTryExpression(node: UTryExpression) = visitElement(node) - fun visitCatchClause(node: UCatchClause) = visitElement(node) - fun visitLiteralExpression(node: ULiteralExpression) = visitElement(node) - fun visitThisExpression(node: UThisExpression) = visitElement(node) - fun visitSuperExpression(node: USuperExpression) = visitElement(node) - fun visitReturnExpression(node: UReturnExpression) = visitElement(node) - fun visitBreakExpression(node: UBreakExpression) = visitElement(node) - fun visitContinueExpression(node: UContinueExpression) = visitElement(node) - fun visitThrowExpression(node: UThrowExpression) = visitElement(node) - fun visitArrayAccessExpression(node: UArrayAccessExpression) = visitElement(node) - fun visitCallableReferenceExpression(node: UCallableReferenceExpression) = visitElement(node) - fun visitClassLiteralExpression(node: UClassLiteralExpression) = visitElement(node) - fun visitLambdaExpression(node: ULambdaExpression) = visitElement(node) - fun visitObjectLiteralExpression(node: UObjectLiteralExpression) = visitElement(node) - - // After - - fun afterVisitElement(node: UElement) {} - - fun afterVisitFile(node: UFile) { afterVisitElement(node) } - fun afterVisitImportStatement(node: UImportStatement) { afterVisitElement(node) } - fun afterVisitClass(node: UClass) { afterVisitElement(node) } - fun afterVisitInitializer(node: UClassInitializer) { afterVisitElement(node) } - fun afterVisitMethod(node: UMethod) { afterVisitElement(node) } - fun afterVisitVariable(node: UVariable) { afterVisitElement(node) } - fun afterVisitAnnotation(node: UAnnotation) { afterVisitElement(node) } - - // Expressions - fun afterVisitLabeledExpression(node: ULabeledExpression) { afterVisitElement(node) } - fun afterVisitDeclarationsExpression(node: UVariableDeclarationsExpression) { afterVisitElement(node) } - fun afterVisitBlockExpression(node: UBlockExpression) { afterVisitElement(node) } - fun afterVisitQualifiedReferenceExpression(node: UQualifiedReferenceExpression) { afterVisitElement(node) } - fun afterVisitSimpleNameReferenceExpression(node: USimpleNameReferenceExpression) { afterVisitElement(node) } - fun afterVisitTypeReferenceExpression(node: UTypeReferenceExpression) { afterVisitElement(node) } - fun afterVisitCallExpression(node: UCallExpression) { afterVisitElement(node) } - fun afterVisitBinaryExpression(node: UBinaryExpression) { afterVisitElement(node) } - fun afterVisitBinaryExpressionWithType(node: UBinaryExpressionWithType) { afterVisitElement(node) } - fun afterVisitParenthesizedExpression(node: UParenthesizedExpression) { afterVisitElement(node) } - fun afterVisitUnaryExpression(node: UUnaryExpression) { afterVisitElement(node) } - fun afterVisitPrefixExpression(node: UPrefixExpression) { afterVisitElement(node) } - fun afterVisitPostfixExpression(node: UPostfixExpression) { afterVisitElement(node) } - fun afterVisitExpressionList(node: UExpressionList) { afterVisitElement(node) } - fun afterVisitIfExpression(node: UIfExpression) { afterVisitElement(node) } - fun afterVisitSwitchExpression(node: USwitchExpression) { afterVisitElement(node) } - fun afterVisitSwitchClauseExpression(node: USwitchClauseExpression) { afterVisitElement(node) } - fun afterVisitWhileExpression(node: UWhileExpression) { afterVisitElement(node) } - fun afterVisitDoWhileExpression(node: UDoWhileExpression) { afterVisitElement(node) } - fun afterVisitForExpression(node: UForExpression) { afterVisitElement(node) } - fun afterVisitForEachExpression(node: UForEachExpression) { afterVisitElement(node) } - fun afterVisitTryExpression(node: UTryExpression) { afterVisitElement(node) } - fun afterVisitCatchClause(node: UCatchClause) { afterVisitElement(node) } - fun afterVisitLiteralExpression(node: ULiteralExpression) { afterVisitElement(node) } - fun afterVisitThisExpression(node: UThisExpression) { afterVisitElement(node) } - fun afterVisitSuperExpression(node: USuperExpression) { afterVisitElement(node) } - fun afterVisitReturnExpression(node: UReturnExpression) { afterVisitElement(node) } - fun afterVisitBreakExpression(node: UBreakExpression) { afterVisitElement(node) } - fun afterVisitContinueExpression(node: UContinueExpression) { afterVisitElement(node) } - fun afterVisitThrowExpression(node: UThrowExpression) { afterVisitElement(node) } - fun afterVisitArrayAccessExpression(node: UArrayAccessExpression) { afterVisitElement(node) } - fun afterVisitCallableReferenceExpression(node: UCallableReferenceExpression) { afterVisitElement(node) } - fun afterVisitClassLiteralExpression(node: UClassLiteralExpression) { afterVisitElement(node) } - fun afterVisitLambdaExpression(node: ULambdaExpression) { afterVisitElement(node) } - fun afterVisitObjectLiteralExpression(node: UObjectLiteralExpression) { afterVisitElement(node) } -} - -abstract class AbstractUastVisitor : UastVisitor { - override fun visitElement(node: UElement): Boolean = false - -} - -object EmptyUastVisitor : AbstractUastVisitor() \ No newline at end of file diff --git a/plugins/uast-common/uast-common.iml b/plugins/uast-common/uast-common.iml deleted file mode 100644 index 4bb8e8aaeee..00000000000 --- a/plugins/uast-common/uast-common.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/JavaAbstractUElement.kt b/plugins/uast-java/src/org/jetbrains/uast/java/JavaAbstractUElement.kt deleted file mode 100644 index 4b89da6cd94..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/JavaAbstractUElement.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.JavaPsiFacade -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiExpression -import com.intellij.psi.PsiType -import org.jetbrains.uast.UAnnotation -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.java.internal.JavaUElementWithComments -import org.jetbrains.uast.psi.PsiElementBacked - -abstract class JavaAbstractUElement : JavaUElementWithComments { - private val psiElement: PsiElement? - get() = (this as? PsiElementBacked)?.psi - - override fun equals(other: Any?): Boolean { - if (this !is PsiElementBacked || other !is PsiElementBacked) { - return this === other - } - - if (other.javaClass != this.javaClass) return false - return this.psi == other.psi - } - - override fun asSourceString(): String { - if (this is PsiElementBacked) { - return this.psi?.text ?: super.asSourceString() - } - return super.asSourceString() - } - - override fun toString() = asRenderString() -} - -abstract class JavaAbstractUExpression : JavaAbstractUElement(), UExpression { - override fun evaluate(): Any? { - val psi = (this as? PsiElementBacked)?.psi ?: return null - return JavaPsiFacade.getInstance(psi.project).constantEvaluationHelper.computeConstantExpression(psi) - } - - override val annotations: List - get() = emptyList() - - override fun getExpressionType(): PsiType? { - val expression = (this as? PsiElementBacked)?.psi as? PsiExpression ?: return null - return expression.type - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/JavaUastLanguagePlugin.kt b/plugins/uast-java/src/org/jetbrains/uast/java/JavaUastLanguagePlugin.kt deleted file mode 100644 index 8928b3e354c..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/JavaUastLanguagePlugin.kt +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.lang.Language -import com.intellij.lang.java.JavaLanguage -import com.intellij.openapi.project.Project -import com.intellij.psi.* -import org.jetbrains.uast.* -import org.jetbrains.uast.java.expressions.JavaUSynchronizedExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUastLanguagePlugin(override val project: Project) : UastLanguagePlugin { - override val priority = 0 - - override fun isFileSupported(fileName: String) = fileName.endsWith(".java", ignoreCase = true) - - override val language: Language - get() = JavaLanguage.INSTANCE - - override fun isExpressionValueUsed(element: UExpression): Boolean = when (element) { - is JavaUVariableDeclarationsExpression -> false - is UnknownJavaExpression -> (element.containingElement as? UExpression)?.let { isExpressionValueUsed(it) } ?: false - else -> { - val statement = (element as? PsiElementBacked)?.psi as? PsiStatement - statement != null && statement.parent !is PsiExpressionStatement - } - } - - override fun getMethodCallExpression( - element: PsiElement, - containingClassFqName: String?, - methodName: String - ): UastLanguagePlugin.ResolvedMethod? { - if (element !is PsiMethodCallExpression) return null - if (element.methodExpression.referenceName != methodName) return null - - val uElement = convertElementWithParent(element, null) - val callExpression = when (uElement) { - is UCallExpression -> uElement - is UQualifiedReferenceExpression -> uElement.selector as UCallExpression - else -> error("Invalid element type: $uElement") - } - - val method = callExpression.resolve() ?: return null - if (containingClassFqName != null) { - val containingClass = method.containingClass ?: return null - if (containingClass.qualifiedName != containingClassFqName) return null - } - - return UastLanguagePlugin.ResolvedMethod(callExpression, method) - } - - override fun getConstructorCallExpression( - element: PsiElement, - fqName: String - ): UastLanguagePlugin.ResolvedConstructor? { - if (element !is PsiNewExpression) return null - val simpleName = fqName.substringAfterLast('.') - if (element.classReference?.referenceName != simpleName) return null - - val callExpression = convertElementWithParent(element, null) as? UCallExpression ?: return null - - val constructorMethod = element.resolveConstructor() ?: return null - val containingClass = constructorMethod.containingClass ?: return null - if (containingClass.qualifiedName != fqName) return null - - return UastLanguagePlugin.ResolvedConstructor(callExpression, constructorMethod, containingClass) - } - - override fun convertElement(element: PsiElement, parent: UElement?, requiredType: Class?): UElement? { - if (element !is PsiElement) return null - return convertDeclaration(element, parent, requiredType) ?: JavaConverter.convertPsiElement(element, parent, requiredType) - } - - override fun convertElementWithParent(element: PsiElement, requiredType: Class?): UElement? { - if (element !is PsiElement) return null - if (element is PsiJavaFile) return JavaUFile(element, this) - JavaConverter.getCached(element)?.let { return it } - - val parent = JavaConverter.unwrapElements(element.parent) ?: return null - val parentUElement = convertElementWithParent(parent, null) ?: return null - return convertElement(element, parentUElement, requiredType) - } - - private fun convertDeclaration(element: PsiElement, parent: UElement?, requiredType: Class?): UElement? { - if (element.isValid) element.getUserData(JAVA_CACHED_UELEMENT_KEY)?.let { ref -> - ref.get()?.let { return it } - } - - return with (requiredType) { when (element) { - is PsiJavaFile -> el { JavaUFile(element, this@JavaUastLanguagePlugin) } - is UDeclaration -> element - is PsiClass -> el { JavaUClass.create(element, parent) } - is PsiMethod -> el { JavaUMethod.create(element, this@JavaUastLanguagePlugin, parent) } - is PsiClassInitializer -> el { JavaUClassInitializer(element, parent) } - is PsiVariable -> el { JavaUVariable.create(element, parent) } - is PsiAnnotation -> el { JavaUAnnotation(element, parent) } //??? - else -> null - }} - } -} - -internal inline fun Class?.el(f: () -> UElement?): UElement? { - return if (this == null || T::class.java == this) f() else null -} - -internal inline fun Class?.expr(f: () -> UExpression): UExpression { - return if (this == null || T::class.java == this) f() else UastEmptyExpression -} - -internal object JavaConverter { - internal inline fun getCached(element: PsiElement): T? { - return null - //todo - } - - internal tailrec fun unwrapElements(element: PsiElement?): PsiElement? = when (element) { - is PsiExpressionStatement -> unwrapElements(element.parent) - is PsiParameterList -> unwrapElements(element.parent) - is PsiAnnotationParameterList -> unwrapElements(element.parent) - else -> element - } - - internal fun convertPsiElement(el: PsiElement, parent: UElement?, requiredType: Class? = null): UElement? { - getCached(el)?.let { return it } - - return with (requiredType) { when (el) { - is PsiCodeBlock -> el { convertBlock(el, parent) } - is PsiResourceExpression -> convertExpression(el.expression, parent, requiredType) - is PsiExpression -> convertExpression(el, parent, requiredType) - is PsiStatement -> convertStatement(el, parent, requiredType) - is PsiIdentifier -> el { JavaUSimpleNameReferenceExpression(el, el.text, parent) } - is PsiNameValuePair -> el { convertNameValue(el, parent) } - is PsiArrayInitializerMemberValue -> el { JavaAnnotationArrayInitializerUCallExpression(el, parent) } - else -> null - }} - } - - internal fun convertBlock(block: PsiCodeBlock, parent: UElement?): UBlockExpression = - getCached(block) ?: JavaUCodeBlockExpression(block, parent) - - internal fun convertNameValue(pair: PsiNameValuePair, parent: UElement?): UNamedExpression { - return UNamedExpression.create(pair.name.orAnonymous(), parent) { - val value = pair.value as? PsiElement - value?.let { convertPsiElement(it, this, null) as? UExpression } ?: UnknownJavaExpression(value ?: pair, this) - } - } - - internal fun convertReference(expression: PsiReferenceExpression, parent: UElement?, requiredType: Class?): UExpression { - return with (requiredType) { - if (expression.isQualified) { - expr { JavaUQualifiedReferenceExpression(expression, parent) } - } else { - val name = expression.referenceName ?: "" - expr { JavaUSimpleNameReferenceExpression(expression, name, parent, expression) } - } - } - } - - private fun convertPolyadicExpression( - expression: PsiPolyadicExpression, - parent: UElement?, - i: Int - ): UBinaryExpression { - return if (i == 1) JavaSeparatedPolyadicUBinaryExpression(expression, parent).apply { - leftOperand = convertExpression(expression.operands[0], this) - rightOperand = convertExpression(expression.operands[1], this) - } else JavaSeparatedPolyadicUBinaryExpression(expression, parent).apply { - leftOperand = convertPolyadicExpression(expression, parent, i - 1) - rightOperand = convertExpression(expression.operands[i], this) - } - } - - internal fun convertExpression(el: PsiExpression, parent: UElement?, requiredType: Class? = null): UExpression { - getCached(el)?.let { return it } - - return with (requiredType) { when (el) { - is PsiPolyadicExpression -> expr { convertPolyadicExpression(el, parent, el.operands.size - 1) } - is PsiAssignmentExpression -> expr { JavaUAssignmentExpression(el, parent) } - is PsiConditionalExpression -> expr { JavaUTernaryIfExpression(el, parent) } - is PsiNewExpression -> { - if (el.anonymousClass != null) - expr { JavaUObjectLiteralExpression(el, parent) } - else - expr { JavaConstructorUCallExpression(el, parent) } - } - is PsiMethodCallExpression -> { - if (el.methodExpression.qualifierExpression != null) - expr { - JavaUCompositeQualifiedExpression(el, parent).apply { - receiver = convertExpression(el.methodExpression.qualifierExpression!!, this) - selector = JavaUCallExpression(el, this) - } - } - else - expr { JavaUCallExpression(el, parent) } - } - is PsiArrayInitializerExpression -> expr { JavaArrayInitializerUCallExpression(el, parent) } - is PsiBinaryExpression -> expr { JavaUBinaryExpression(el, parent) } - is PsiParenthesizedExpression -> expr { JavaUParenthesizedExpression(el, parent) } - is PsiPrefixExpression -> expr { JavaUPrefixExpression(el, parent) } - is PsiPostfixExpression -> expr { JavaUPostfixExpression(el, parent) } - is PsiLiteralExpression -> expr { JavaULiteralExpression(el, parent) } - is PsiReferenceExpression -> convertReference(el, parent, requiredType) - is PsiThisExpression -> expr { JavaUThisExpression(el, parent) } - is PsiSuperExpression -> expr { JavaUSuperExpression(el, parent) } - is PsiInstanceOfExpression -> expr { JavaUInstanceCheckExpression(el, parent) } - is PsiTypeCastExpression -> expr { JavaUTypeCastExpression(el, parent) } - is PsiClassObjectAccessExpression -> expr { JavaUClassLiteralExpression(el, parent) } - is PsiArrayAccessExpression -> expr { JavaUArrayAccessExpression(el, parent) } - is PsiLambdaExpression -> expr { JavaULambdaExpression(el, parent) } - is PsiMethodReferenceExpression -> expr { JavaUCallableReferenceExpression(el, parent) } - else -> UnknownJavaExpression(el, parent) - }} - } - - internal fun convertStatement(el: PsiStatement, parent: UElement?, requiredType: Class? = null): UExpression { - getCached(el)?.let { return it } - - return with (requiredType) { when (el) { - is PsiDeclarationStatement -> expr { convertDeclarations(el.declaredElements, parent!!) } - is PsiExpressionListStatement -> expr { convertDeclarations(el.expressionList.expressions, parent!!) } - is PsiBlockStatement -> expr { JavaUBlockExpression(el, parent) } - is PsiLabeledStatement -> expr { JavaULabeledExpression(el, parent) } - is PsiExpressionStatement -> convertExpression(el.expression, parent, requiredType) - is PsiIfStatement -> expr { JavaUIfExpression(el, parent) } - is PsiSwitchStatement -> expr { JavaUSwitchExpression(el, parent) } - is PsiSwitchLabelStatement -> expr { - if (el.isDefaultCase) - DefaultUSwitchClauseExpression(parent) - else JavaUCaseSwitchClauseExpression(el, parent) - } - is PsiWhileStatement -> expr { JavaUWhileExpression(el, parent) } - is PsiDoWhileStatement -> expr { JavaUDoWhileExpression(el, parent) } - is PsiForStatement -> expr { JavaUForExpression(el, parent) } - is PsiForeachStatement -> expr { JavaUForEachExpression(el, parent) } - is PsiBreakStatement -> expr { JavaUBreakExpression(el, parent) } - is PsiContinueStatement -> expr { JavaUContinueExpression(el, parent) } - is PsiReturnStatement -> expr { JavaUReturnExpression(el, parent) } - is PsiAssertStatement -> expr { JavaUAssertExpression(el, parent) } - is PsiThrowStatement -> expr { JavaUThrowExpression(el, parent) } - is PsiSynchronizedStatement -> expr { JavaUSynchronizedExpression(el, parent) } - is PsiTryStatement -> expr { JavaUTryExpression(el, parent) } - else -> UnknownJavaExpression(el, parent) - }} - } - - private fun convertDeclarations(elements: Array, parent: UElement): UVariableDeclarationsExpression { - return JavaUVariableDeclarationsExpression(parent).apply { - val variables = mutableListOf() - for (element in elements) { - if (element !is PsiVariable) continue - variables += JavaUVariable.create(element, this) - } - this.variables = variables - } - } - - internal fun convertOrEmpty(statement: PsiStatement?, parent: UElement?): UExpression { - return statement?.let { convertStatement(it, parent, null) } ?: UastEmptyExpression - } - - internal fun convertOrEmpty(expression: PsiExpression?, parent: UElement?): UExpression { - return expression?.let { convertExpression(it, parent) } ?: UastEmptyExpression - } - - internal fun convertOrNull(expression: PsiExpression?, parent: UElement?): UExpression? { - return if (expression != null) convertExpression(expression, parent) else null - } - - internal fun convertOrEmpty(block: PsiCodeBlock?, parent: UElement?): UExpression { - return if (block != null) convertBlock(block, parent) else UastEmptyExpression - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUDoWhileExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUDoWhileExpression.kt deleted file mode 100644 index 266fda92eeb..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUDoWhileExpression.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiDoWhileStatement -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.UDoWhileExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUDoWhileExpression( - override val psi: PsiDoWhileStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UDoWhileExpression, PsiElementBacked { - override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) } - override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) } - - override val doIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.DO_KEYWORD), this) - override val whileIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.WHILE_KEYWORD), this) -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUForEachExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUForEachExpression.kt deleted file mode 100644 index e61e8a5bd6f..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUForEachExpression.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiForeachStatement -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UForEachExpression -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UParameter -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUForEachExpression( - override val psi: PsiForeachStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UForEachExpression, PsiElementBacked { - override val variable: UParameter - get() = JavaUParameter(psi.iterationParameter, this) - - override val iteratedValue by lz { JavaConverter.convertOrEmpty(psi.iteratedValue, this) } - override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) } - - override val forIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.FOR_KEYWORD), this) -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUForExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUForExpression.kt deleted file mode 100644 index 68308958f44..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUForExpression.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiForStatement -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UForExpression -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUForExpression( - override val psi: PsiForStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UForExpression, PsiElementBacked { - override val declaration by lz { psi.initialization?.let { JavaConverter.convertStatement(it, this) } } - override val condition by lz { psi.condition?.let { JavaConverter.convertExpression(it, this) } } - override val update by lz { psi.update?.let { JavaConverter.convertStatement(it, this) } } - override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) } - - override val forIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.FOR_KEYWORD), this) -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUIfExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUIfExpression.kt deleted file mode 100644 index 68ee131a257..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUIfExpression.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiIfStatement -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UIfExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUIfExpression( - override val psi: PsiIfStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UIfExpression, PsiElementBacked { - override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) } - override val thenExpression by lz { JavaConverter.convertOrEmpty(psi.thenBranch, this) } - override val elseExpression by lz { JavaConverter.convertOrEmpty(psi.elseBranch, this) } - - override val isTernary: Boolean - get() = false - - override val ifIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.IF_KEYWORD), this) - - override val elseIdentifier: UIdentifier? - get() = psi.getChildByRole(ChildRole.ELSE_KEYWORD)?.let { UIdentifier(it, this) } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUSwitchExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUSwitchExpression.kt deleted file mode 100644 index 048a103ea20..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUSwitchExpression.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiSwitchLabelStatement -import com.intellij.psi.PsiSwitchStatement -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.* -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUSwitchExpression( - override val psi: PsiSwitchStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), USwitchExpression, PsiElementBacked { - override val expression by lz { JavaConverter.convertOrEmpty(psi.expression, this) } - override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) } - - override val switchIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.SWITCH_KEYWORD), this) -} - -class JavaUCaseSwitchClauseExpression( - override val psi: PsiSwitchLabelStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), USwitchClauseExpression, PsiElementBacked { - override val caseValues by lz { - val value = psi.caseValue ?: return@lz null - listOf(JavaConverter.convertExpression(value, this)) - } -} - -class DefaultUSwitchClauseExpression(override val containingElement: UElement?) : USwitchClauseExpression { - override val caseValues: List? - get() = null - - override val annotations: List - get() = emptyList() - - override fun asLogString() = "DefaultUSwitchClauseExpression" - override fun asRenderString() = "else -> " -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUTernaryIfExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUTernaryIfExpression.kt deleted file mode 100644 index 76eb07f6832..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUTernaryIfExpression.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiConditionalExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UIfExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUTernaryIfExpression( - override val psi: PsiConditionalExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UIfExpression, PsiElementBacked { - override val condition by lz { JavaConverter.convertExpression(psi.condition, this) } - override val thenExpression by lz { JavaConverter.convertOrEmpty(psi.thenExpression, this) } - override val elseExpression by lz { JavaConverter.convertOrEmpty(psi.elseExpression, this) } - - override val isTernary: Boolean - get() = true - - override val ifIdentifier: UIdentifier - get() = UIdentifier(null, this) - - override val elseIdentifier: UIdentifier? - get() = UIdentifier(null, this) -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUTryExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUTryExpression.kt deleted file mode 100644 index 7dedc19c22d..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUTryExpression.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.* -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.UCatchClause -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UTryExpression -import org.jetbrains.uast.expressions.UTypeReferenceExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUTryExpression( - override val psi: PsiTryStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UTryExpression, PsiElementBacked { - override val tryClause by lz { JavaConverter.convertOrEmpty(psi.tryBlock, this) } - override val catchClauses by lz { psi.catchSections.map { JavaUCatchClause(it, this) } } - override val finallyClause by lz { psi.finallyBlock?.let { JavaConverter.convertBlock(it, this) } } - override val resources: List? - get() = psi.resourceList?.toList() ?: emptyList() - override val isResources: Boolean - get() = psi.resourceList != null - - override val tryIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.TRY_KEYWORD), this) - - override val finallyIdentifier: UIdentifier? - get() = psi.getChildByRole(ChildRole.FINALLY_KEYWORD)?.let { UIdentifier(it, this) } -} - -class JavaUCatchClause( - override val psi: PsiCatchSection, - override val containingElement: UElement? -) : JavaAbstractUElement(), UCatchClause, PsiElementBacked { - override val body by lz { JavaConverter.convertOrEmpty(psi.catchBlock, this) } - - override val parameters by lz { - (psi.parameter?.let { listOf(it) } ?: emptyList()).map { JavaUParameter(it, this) } - } - - override val typeReferences by lz { - val typeElement = psi.parameter?.typeElement ?: return@lz emptyList() - if (typeElement.type is PsiDisjunctionType) { - typeElement.children.filterIsInstance().map { JavaUTypeReferenceExpression(it, this) } - } else { - listOf(JavaUTypeReferenceExpression(typeElement, this)) - } - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUWhileExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUWhileExpression.kt deleted file mode 100644 index c8008551405..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/controlStructures/JavaUWhileExpression.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiWhileStatement -import com.intellij.psi.impl.source.tree.ChildRole -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UWhileExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUWhileExpression( - override val psi: PsiWhileStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UWhileExpression, PsiElementBacked { - override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) } - override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) } - - override val whileIdentifier: UIdentifier - get() = UIdentifier(psi.getChildByRole(ChildRole.WHILE_KEYWORD), this) -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUAnnotation.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUAnnotation.kt deleted file mode 100644 index 1ca7264a53a..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUAnnotation.kt +++ /dev/null @@ -1,52 +0,0 @@ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiAnnotation -import com.intellij.psi.PsiClass -import org.jetbrains.uast.* - -class JavaUAnnotation( - override val psi: PsiAnnotation, - override val containingElement: UElement? -) : UAnnotation { - override val qualifiedName: String? - get() = psi.qualifiedName - - override val attributeValues: List by lz { - val context = getUastContext() - val attributes = psi.parameterList.attributes - - attributes.map { attribute -> - UNamedExpression(attribute.name ?: "", this).apply { - val value = attribute.value?.let { context.convertElement(it, this, null) } as? UExpression - expression = value ?: UastEmptyExpression - } - } - } - - override fun resolve(): PsiClass? = psi.nameReferenceElement?.resolve() as? PsiClass - - override fun findAttributeValue(name: String?): UNamedExpression? { - val context = getUastContext() - val attributeValue = psi.findAttributeValue(name) ?: return null - val value = context.convertElement(attributeValue, this, null) - return UNamedExpression(name ?: "", value) - } - - override fun findDeclaredAttributeValue(name: String?): UNamedExpression? { - val context = getUastContext() - val attributeValue = psi.findDeclaredAttributeValue(name) ?: return null - val value = context.convertElement(attributeValue, this, null) - return UNamedExpression(name ?: "", value) - } - - companion object { - @JvmStatic - fun wrap(annotation: PsiAnnotation): UAnnotation = JavaUAnnotation(annotation, null) - - @JvmStatic - fun wrap(annotations: List): List = annotations.map { JavaUAnnotation(it, null) } - - @JvmStatic - fun wrap(annotations: Array): List = annotations.map { JavaUAnnotation(it, null) } - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClass.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClass.kt deleted file mode 100644 index 76b4b5d7857..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClass.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiAnonymousClass -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiElement -import org.jetbrains.uast.* -import org.jetbrains.uast.java.internal.JavaUElementWithComments - -abstract class AbstractJavaUClass : UClass, JavaUElementWithComments { - override val uastDeclarations by lz { - mutableListOf().apply { - addAll(uastFields) - addAll(uastInitializers) - addAll(uastMethods) - addAll(uastNestedClasses) - } - } - - override val uastAnchor: UElement? - get() = UIdentifier(psi.nameIdentifier, this) - - override val annotations: List - get() = psi.annotations.map { JavaUAnnotation(it, this) } - - override val uastFields: List by lz { - psi.fields.map { getLanguagePlugin().convert(it, this) } - } - - override val uastInitializers: List by lz { - psi.initializers.map { getLanguagePlugin().convert(it, this) } - } - - override val uastMethods: List by lz { - psi.methods.map { getLanguagePlugin().convert(it, this) } - } - - override val uastNestedClasses: List by lz { - psi.innerClasses.map { getLanguagePlugin().convert(it, this) } - } - - override fun equals(other: Any?) = this === other - override fun hashCode() = psi.hashCode() -} - -class JavaUClass private constructor(psiClass: PsiClass, override val containingElement: UElement?) : AbstractJavaUClass(), PsiClass by psiClass { - override val psi = unwrap(psiClass) - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } - - companion object { - fun create(psi: PsiClass, containingElement: UElement?): UClass { - return if (psi is PsiAnonymousClass) - JavaUAnonymousClass(psi, containingElement) - else - JavaUClass(psi, containingElement) - } - } -} - -class JavaUAnonymousClass( - psi: PsiAnonymousClass, - override val containingElement: UElement? -) : AbstractJavaUClass(), UAnonymousClass, PsiAnonymousClass by psi { - override val psi: PsiAnonymousClass = unwrap(psi) - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClassInitializer.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClassInitializer.kt deleted file mode 100644 index 04a42fa6133..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClassInitializer.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiClassInitializer -import com.intellij.psi.PsiCodeBlock -import com.intellij.psi.PsiElement -import org.jetbrains.uast.* -import org.jetbrains.uast.java.internal.JavaUElementWithComments - -class JavaUClassInitializer( - psi: PsiClassInitializer, - override val containingElement: UElement? -) : UClassInitializer, JavaUElementWithComments, PsiClassInitializer by psi { - override val psi = unwrap(psi) - - override fun getBody(): PsiCodeBlock { - return super.getBody() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } - - override val uastAnchor: UElement? - get() = null - - override val uastBody by lz { - getLanguagePlugin().convertElement(psi.body, this, null) as? UExpression ?: UastEmptyExpression - } - - override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } } - - override fun equals(other: Any?) = this === other - override fun hashCode() = psi.hashCode() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUFile.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUFile.kt deleted file mode 100644 index 31b616923c4..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUFile.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiComment -import com.intellij.psi.PsiJavaFile -import com.intellij.psi.PsiRecursiveElementWalkingVisitor -import org.jetbrains.uast.UAnnotation -import org.jetbrains.uast.UComment -import org.jetbrains.uast.UFile -import org.jetbrains.uast.UastLanguagePlugin -import java.util.* - -class JavaUFile(override val psi: PsiJavaFile, override val languagePlugin: UastLanguagePlugin) : UFile { - override val packageName: String - get() = psi.packageName - - override val imports by lz { - psi.importList?.allImportStatements?.map { JavaUImportStatement(it, this) } ?: listOf() - } - - override val annotations: List - get() = emptyList() - - override val classes by lz { psi.classes.map { JavaUClass.create(it, this) } } - - override val allCommentsInFile by lz { - val comments = ArrayList(0) - psi.accept(object : PsiRecursiveElementWalkingVisitor() { - override fun visitComment(comment: PsiComment) { - comments += UComment(comment, this@JavaUFile) - } - }) - comments - } - - override fun equals(other: Any?) = (other as? JavaUFile)?.psi == psi -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUImportStatement.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUImportStatement.kt deleted file mode 100644 index 1f4cfcf5e95..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUImportStatement.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiImportStatementBase -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UImportStatement - -class JavaUImportStatement( - override val psi: PsiImportStatementBase, - override val containingElement: UElement? -) : UImportStatement { - override val isOnDemand: Boolean - get() = psi.isOnDemand - override val importReference by lz { psi.importReference?.let { JavaDumbUElement(it, this) } } - override fun resolve() = psi.resolve() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUMethod.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUMethod.kt deleted file mode 100644 index b9cfeb9450e..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUMethod.kt +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.* -import org.jetbrains.uast.* -import org.jetbrains.uast.java.internal.JavaUElementWithComments - -open class JavaUMethod( - psi: PsiMethod, - override val containingElement: UElement? -) : UMethod, JavaUElementWithComments, PsiMethod by psi { - override val psi = unwrap(psi) - - override fun getBody(): PsiCodeBlock? { - return super.getBody() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } - - override val uastBody by lz { - val body = psi.body ?: return@lz null - getLanguagePlugin().convertElement(body, this) as? UExpression - } - - override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } } - - override val uastParameters by lz { - psi.parameterList.parameters.map { JavaUParameter(it, this) } - } - - override val isOverride: Boolean - get() = psi.modifierList.findAnnotation("java.lang.Override") != null - - override val uastAnchor: UElement - get() = UIdentifier((psi.originalElement as? PsiNameIdentifierOwner)?.nameIdentifier ?: psi.nameIdentifier, this) - - override fun equals(other: Any?) = this === other - override fun hashCode() = psi.hashCode() - - companion object { - fun create(psi: PsiMethod, languagePlugin: UastLanguagePlugin, containingElement: UElement?) = when (psi) { - is PsiAnnotationMethod -> JavaUAnnotationMethod(psi, languagePlugin, containingElement) - else -> JavaUMethod(psi, containingElement) - } - } -} - -class JavaUAnnotationMethod( - override val psi: PsiAnnotationMethod, - languagePlugin: UastLanguagePlugin, - containingElement: UElement? -) : JavaUMethod(psi, containingElement), UAnnotationMethod { - override val uastDefaultValue by lz { - val defaultValue = psi.defaultValue ?: return@lz null - languagePlugin.convertElement(defaultValue, this, null) as? UExpression - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt b/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt deleted file mode 100644 index f2722adedcc..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.* -import org.jetbrains.uast.* -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.expressions.UTypeReferenceExpression -import org.jetbrains.uast.java.internal.JavaUElementWithComments -import org.jetbrains.uast.psi.PsiElementBacked - -abstract class AbstractJavaUVariable : PsiVariable, UVariable, JavaUElementWithComments { - override val uastInitializer by lz { - val initializer = psi.initializer ?: return@lz null - getLanguagePlugin().convertElement(initializer, this) as? UExpression - } - - override val annotations by lz { psi.annotations.map { JavaUAnnotation(it, this) } } - override val typeReference by lz { getLanguagePlugin().convertOpt(psi.typeElement, this) } - - override val uastAnchor: UElement - get() = UIdentifier(psi.nameIdentifier, this) - - override fun equals(other: Any?) = this === other - override fun hashCode() = psi.hashCode() -} - -open class JavaUVariable( - psi: PsiVariable, - override val containingElement: UElement? -) : AbstractJavaUVariable(), UVariable, PsiVariable by psi { - override val psi = unwrap(psi) - - override fun getInitializer(): PsiExpression? { - return super.getInitializer() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } - - companion object { - fun create(psi: PsiVariable, containingElement: UElement?): UVariable { - return when (psi) { - is PsiEnumConstant -> JavaUEnumConstant(psi, containingElement) - is PsiLocalVariable -> JavaULocalVariable(psi, containingElement) - is PsiParameter -> JavaUParameter(psi, containingElement) - is PsiField -> JavaUField(psi, containingElement) - else -> JavaUVariable(psi, containingElement) - } - } - } -} - -open class JavaUParameter( - psi: PsiParameter, - override val containingElement: UElement? -) : AbstractJavaUVariable(), UParameter, PsiParameter by psi { - override val psi = unwrap(psi) - - override fun getInitializer(): PsiExpression? { - return super.getInitializer() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } -} - -open class JavaUField( - psi: PsiField, - override val containingElement: UElement? -) : AbstractJavaUVariable(), UField, PsiField by psi { - override val psi = unwrap(psi) - - override fun getInitializer(): PsiExpression? { - return super.getInitializer() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } -} - -open class JavaULocalVariable( - psi: PsiLocalVariable, - override val containingElement: UElement? -) : AbstractJavaUVariable(), ULocalVariable, PsiLocalVariable by psi { - override val psi = unwrap(psi) - - override fun getInitializer(): PsiExpression? { - return super.getInitializer() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } -} - -open class JavaUEnumConstant( - psi: PsiEnumConstant, - override val containingElement: UElement? -) : AbstractJavaUVariable(), UEnumConstant, PsiEnumConstant by psi { - override val psi = unwrap(psi) - - override fun getInitializer(): PsiExpression? { - return super.getInitializer() - } - - override fun getOriginalElement(): PsiElement? { - return super.getOriginalElement() - } - - override val kind: UastCallKind - get() = UastCallKind.CONSTRUCTOR_CALL - override val receiver: UExpression? - get() = null - override val receiverType: PsiType? - get() = null - override val methodIdentifier: UIdentifier? - get() = null - override val classReference: UReferenceExpression? - get() = JavaEnumConstantClassReference(psi, containingElement) - override val typeArgumentCount: Int - get() = 0 - override val typeArguments: List - get() = emptyList() - override val valueArgumentCount: Int - get() = psi.argumentList?.expressions?.size ?: 0 - - override val valueArguments by lz { - psi.argumentList?.expressions?.map { - getLanguagePlugin().convertElement(it, this) as? UExpression ?: UastEmptyExpression - } ?: emptyList() - } - - override val returnType: PsiType? - get() = psi.type - - override fun resolve() = psi.resolveMethod() - - override val methodName: String? - get() = null - - private class JavaEnumConstantClassReference( - override val psi: PsiEnumConstant, - override val containingElement: UElement? - ) : JavaAbstractUExpression(), USimpleNameReferenceExpression, PsiElementBacked { - override fun resolve() = psi.containingClass - override val resolvedName: String? - get() = psi.containingClass?.name - override val identifier: String - get() = psi.containingClass?.name ?: "" - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaDumbUElement.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaDumbUElement.kt deleted file mode 100644 index 9a66e46a0a7..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaDumbUElement.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiElement -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaDumbUElement( - override val psi: PsiElement?, - override val containingElement: UElement? -) : JavaAbstractUElement(), UElement, PsiElementBacked { - override fun asLogString() = "JavaDumbUElement" - override fun asRenderString() = "" -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaSeparatedPolyadicUBinaryExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaSeparatedPolyadicUBinaryExpression.kt deleted file mode 100644 index 27b7b26497a..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaSeparatedPolyadicUBinaryExpression.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiPolyadicExpression -import org.jetbrains.uast.UBinaryExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaSeparatedPolyadicUBinaryExpression( - override val psi: PsiPolyadicExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBinaryExpression, PsiElementBacked { - override lateinit var leftOperand: UExpression - override lateinit var rightOperand: UExpression - override val operator = psi.operationTokenType.getOperatorType() - - override val operatorIdentifier: UIdentifier? - get() = null - - override fun resolveOperator() = null -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUArrayAccessExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUArrayAccessExpression.kt deleted file mode 100644 index 75768d0f7cd..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUArrayAccessExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiArrayAccessExpression -import org.jetbrains.uast.UArrayAccessExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUArrayAccessExpression( - override val psi: PsiArrayAccessExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UArrayAccessExpression, PsiElementBacked { - override val receiver by lz { JavaConverter.convertExpression(psi.arrayExpression, this) } - override val indices by lz { singletonListOrEmpty(JavaConverter.convertOrNull(psi.indexExpression, this)) } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUAssertExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUAssertExpression.kt deleted file mode 100644 index 4909fcb7acb..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUAssertExpression.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiAssertStatement -import com.intellij.psi.PsiType -import org.jetbrains.uast.* -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.psi.PsiElementBacked - - -class JavaUAssertExpression( - override val psi: PsiAssertStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UCallExpression, PsiElementBacked { - val condition: UExpression by lz { JavaConverter.convertOrEmpty(psi.assertCondition, this) } - val message: UExpression? by lz { JavaConverter.convertOrNull(psi.assertDescription, this) } - - override val methodIdentifier: UIdentifier? - get() = null - - override val classReference: UReferenceExpression? - get() = null - - override val methodName: String - get() = "assert" - - override val receiver: UExpression? - get() = null - - override val receiverType: PsiType? - get() = null - - override val valueArgumentCount: Int - get() = if (message != null) 2 else 1 - - override val valueArguments by lz { - val message = this.message - if (message != null) listOf(condition, message) else listOf(condition) - } - - override val typeArgumentCount: Int - get() = 0 - - override val typeArguments: List - get() = emptyList() - - override val returnType: PsiType - get() = PsiType.VOID - - override val kind: UastCallKind - get() = JavaUastCallKinds.ASSERT - - override fun resolve() = null -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUAssignmentExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUAssignmentExpression.kt deleted file mode 100644 index c9dda371e03..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUAssignmentExpression.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiAssignmentExpression -import org.jetbrains.uast.UBinaryExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUAssignmentExpression( - override val psi: PsiAssignmentExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBinaryExpression, PsiElementBacked { - override val leftOperand by lz { JavaConverter.convertExpression(psi.lExpression, this) } - override val rightOperand by lz { JavaConverter.convertOrEmpty(psi.rExpression, this) } - override val operator by lz { psi.operationTokenType.getOperatorType() } - - override fun resolveOperator() = null - - override val operatorIdentifier: UIdentifier - get() = UIdentifier(psi.operationSign, this) -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBinaryExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBinaryExpression.kt deleted file mode 100644 index 88e1105c97a..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBinaryExpression.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiBinaryExpression -import org.jetbrains.uast.UBinaryExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUBinaryExpression( - override val psi: PsiBinaryExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBinaryExpression, PsiElementBacked { - override val leftOperand by lz { JavaConverter.convertExpression(psi.lOperand, this) } - override val rightOperand by lz { JavaConverter.convertOrEmpty(psi.rOperand, this) } - override val operator by lz { psi.operationTokenType.getOperatorType() } - - override val operatorIdentifier: UIdentifier - get() = UIdentifier(psi.operationSign, this) - - override fun resolveOperator() = null -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBlockExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBlockExpression.kt deleted file mode 100644 index 43002e20209..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBlockExpression.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiBlockStatement -import org.jetbrains.uast.UBlockExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUBlockExpression( - override val psi: PsiBlockStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBlockExpression, PsiElementBacked { - override val expressions by lz { psi.codeBlock.statements.map { JavaConverter.convertStatement(it, this) } } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBreakExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBreakExpression.kt deleted file mode 100644 index 72fb296f50a..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUBreakExpression.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiBreakStatement -import org.jetbrains.uast.UBreakExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUBreakExpression( - override val psi: PsiBreakStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBreakExpression, PsiElementBacked { - override val label: String? - get() = psi.labelIdentifier?.text -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCallableReferenceExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCallableReferenceExpression.kt deleted file mode 100644 index e93de5a6d7c..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCallableReferenceExpression.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiMethodReferenceExpression -import com.intellij.psi.PsiType -import org.jetbrains.uast.UCallableReferenceExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUCallableReferenceExpression( - override val psi: PsiMethodReferenceExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UCallableReferenceExpression, PsiElementBacked { - override val qualifierExpression by lz { JavaConverter.convertOrNull(psi.qualifierExpression, this) } - - override val qualifierType: PsiType? - get() = psi.qualifierType?.type - - override val callableName: String - get() = psi.referenceName.orAnonymous() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUClassLiteralExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUClassLiteralExpression.kt deleted file mode 100644 index 02a8f9cef02..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUClassLiteralExpression.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiClassObjectAccessExpression -import com.intellij.psi.PsiType -import org.jetbrains.uast.UClassLiteralExpression -import org.jetbrains.uast.UElement - -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUClassLiteralExpression( - override val psi: PsiClassObjectAccessExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UClassLiteralExpression, PsiElementBacked { - override val type: PsiType - get() = psi.type - - override val expression by lz { JavaUTypeReferenceExpression(psi.operand, this) } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCodeBlockExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCodeBlockExpression.kt deleted file mode 100644 index 8b67a41e268..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCodeBlockExpression.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiCodeBlock -import org.jetbrains.uast.UBlockExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUCodeBlockExpression( - override val psi: PsiCodeBlock, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBlockExpression, PsiElementBacked { - override val expressions by lz { psi.statements.map { JavaConverter.convertStatement(it, this) } } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCompositeQualifiedExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCompositeQualifiedExpression.kt deleted file mode 100644 index 5c9e2007053..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUCompositeQualifiedExpression.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiNamedElement -import org.jetbrains.uast.* -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUCompositeQualifiedExpression( - override val psi: PsiElement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UQualifiedReferenceExpression, PsiElementBacked { - override lateinit var receiver: UExpression - internal set - - override lateinit var selector: UExpression - internal set - - override val resolvedName: String? - get() = (resolve() as? PsiNamedElement)?.name - - override fun resolve() = (selector as? UResolvable)?.resolve() - - override val accessType: UastQualifiedExpressionAccessType - get() = UastQualifiedExpressionAccessType.SIMPLE -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUContinueExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUContinueExpression.kt deleted file mode 100644 index f33e45ef786..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUContinueExpression.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiContinueStatement -import org.jetbrains.uast.UContinueExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUContinueExpression( - override val psi: PsiContinueStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UContinueExpression, PsiElementBacked { - override val label: String? - get() = psi.labelIdentifier?.text -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUInstanceCheckExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUInstanceCheckExpression.kt deleted file mode 100644 index 8ab3fc4963e..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUInstanceCheckExpression.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiInstanceOfExpression -import com.intellij.psi.PsiType -import org.jetbrains.uast.UBinaryExpressionWithType -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UastBinaryExpressionWithTypeKind -import org.jetbrains.uast.UastErrorType -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUInstanceCheckExpression( - override val psi: PsiInstanceOfExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBinaryExpressionWithType, PsiElementBacked { - override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) } - override val typeReference by lz { psi.checkType?.let { JavaUTypeReferenceExpression(it, this) } } - - override val type: PsiType - get() = psi.checkType?.type ?: UastErrorType - - override val operationKind: UastBinaryExpressionWithTypeKind.InstanceCheck - get() = UastBinaryExpressionWithTypeKind.INSTANCE_CHECK -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULabeledExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULabeledExpression.kt deleted file mode 100644 index ff0254195d5..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULabeledExpression.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiLabeledStatement -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.ULabeledExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaULabeledExpression( - override val psi: PsiLabeledStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), ULabeledExpression, PsiElementBacked { - override val label: String - get() = psi.labelIdentifier.text - - override val labelIdentifier: UIdentifier? - get() = UIdentifier(psi.labelIdentifier, this) - - override val expression by lz { JavaConverter.convertOrEmpty(psi.statement, this) } - - override fun evaluate() = expression.evaluate() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULambdaExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULambdaExpression.kt deleted file mode 100644 index 04eabb4609e..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULambdaExpression.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiCodeBlock -import com.intellij.psi.PsiExpression -import com.intellij.psi.PsiLambdaExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.ULambdaExpression -import org.jetbrains.uast.UastEmptyExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaULambdaExpression( - override val psi: PsiLambdaExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), ULambdaExpression, PsiElementBacked { - override val valueParameters by lz { - psi.parameterList.parameters.map { JavaUParameter(it, this) } - } - - override val body by lz { - val b = psi.body - when (b) { - is PsiCodeBlock -> JavaConverter.convertBlock(b, this) - is PsiExpression -> JavaConverter.convertExpression(b, this) - else -> UastEmptyExpression - } - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt deleted file mode 100644 index 1ed0caec37d..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaULiteralExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiLiteralExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.ULiteralExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaULiteralExpression( - override val psi: PsiLiteralExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), ULiteralExpression, PsiElementBacked { - override fun evaluate() = psi.value - override val value by lz { evaluate() } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt deleted file mode 100644 index 42eae7c8bf0..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUObjectLiteralExpression.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiNewExpression -import com.intellij.psi.PsiType -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UObjectLiteralExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUObjectLiteralExpression( - override val psi: PsiNewExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UObjectLiteralExpression, PsiElementBacked { - override val declaration by lz { JavaUClass.create(psi.anonymousClass!!, this) } - - override val classReference by lz { - psi.classReference?.let { ref -> - JavaClassUSimpleNameReferenceExpression(ref.element?.text.orAnonymous(), ref, ref.element, this) - } - } - - override val valueArgumentCount: Int - get() = psi.argumentList?.expressions?.size ?: 0 - - override val valueArguments by lz { - psi.argumentList?.expressions?.map { JavaConverter.convertExpression(it, this) } ?: emptyList() - } - - override val typeArgumentCount by lz { psi.classReference?.typeParameters?.size ?: 0 } - - override val typeArguments: List - get() = psi.classReference?.typeParameters?.toList() ?: emptyList() - - override fun resolve() = psi.resolveMethod() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUParenthesizedExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUParenthesizedExpression.kt deleted file mode 100644 index 16e5d86a55d..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUParenthesizedExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiParenthesizedExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UParenthesizedExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUParenthesizedExpression( - override val psi: PsiParenthesizedExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UParenthesizedExpression, PsiElementBacked { - override val expression by lz { JavaConverter.convertOrEmpty(psi.expression, this) } - override fun evaluate() = expression.evaluate() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt deleted file mode 100644 index 253c4eec02e..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPostfixExpression.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.JavaTokenType -import com.intellij.psi.PsiPostfixExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UPostfixExpression -import org.jetbrains.uast.UastPostfixOperator -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUPostfixExpression( - override val psi: PsiPostfixExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UPostfixExpression, PsiElementBacked { - override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) } - - override val operatorIdentifier: UIdentifier? - get() = UIdentifier(psi.operationSign, this) - - override fun resolveOperator() = null - - override val operator = when (psi.operationTokenType) { - JavaTokenType.PLUSPLUS -> UastPostfixOperator.INC - JavaTokenType.MINUSMINUS -> UastPostfixOperator.DEC - else -> UastPostfixOperator.UNKNOWN - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt deleted file mode 100644 index 72e95ad988c..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUPrefixExpression.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.JavaTokenType -import com.intellij.psi.PsiPrefixExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UPrefixExpression -import org.jetbrains.uast.UastPrefixOperator -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUPrefixExpression( - override val psi: PsiPrefixExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UPrefixExpression, PsiElementBacked { - override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) } - - override val operatorIdentifier: UIdentifier? - get() = UIdentifier(psi.operationSign, this) - - override fun resolveOperator() = null - - override val operator = when (psi.operationTokenType) { - JavaTokenType.PLUS -> UastPrefixOperator.UNARY_PLUS - JavaTokenType.MINUS -> UastPrefixOperator.UNARY_MINUS - JavaTokenType.PLUSPLUS -> UastPrefixOperator.INC - JavaTokenType.MINUSMINUS-> UastPrefixOperator.DEC - JavaTokenType.EXCL -> UastPrefixOperator.LOGICAL_NOT - JavaTokenType.TILDE -> UastPrefixOperator.BITWISE_NOT - else -> UastPrefixOperator.UNKNOWN - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUQualifiedReferenceExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUQualifiedReferenceExpression.kt deleted file mode 100644 index 30d13cf3e89..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUQualifiedReferenceExpression.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiNamedElement -import com.intellij.psi.PsiReferenceExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UQualifiedReferenceExpression -import org.jetbrains.uast.UastQualifiedExpressionAccessType -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUQualifiedReferenceExpression( - override val psi: PsiReferenceExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UQualifiedReferenceExpression, PsiElementBacked { - override val receiver by lz { JavaConverter.convertOrEmpty(psi.qualifierExpression, this) } - override val selector by lz { - JavaUSimpleNameReferenceExpression(psi.referenceNameElement, psi.referenceName ?: "", this, psi) } - - override val accessType: UastQualifiedExpressionAccessType - get() = UastQualifiedExpressionAccessType.SIMPLE - - override val resolvedName: String? - get() = (psi.resolve() as? PsiNamedElement)?.name - - override fun resolve() = psi.resolve() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUReturnExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUReturnExpression.kt deleted file mode 100644 index 445399ecab6..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUReturnExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiReturnStatement -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UReturnExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUReturnExpression( - override val psi: PsiReturnStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UReturnExpression, PsiElementBacked { - override val returnExpression by lz { JavaConverter.convertOrNull(psi.returnValue, this) } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSimpleNameReferenceExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSimpleNameReferenceExpression.kt deleted file mode 100644 index a2194f2e4a2..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSimpleNameReferenceExpression.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.* -import org.jetbrains.uast.UElement -import org.jetbrains.uast.USimpleNameReferenceExpression -import org.jetbrains.uast.expressions.UTypeReferenceExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUSimpleNameReferenceExpression( - override val psi: PsiElement?, - override val identifier: String, - override val containingElement: UElement?, - val reference: PsiReference? = null -) : JavaAbstractUExpression(), USimpleNameReferenceExpression, PsiElementBacked { - override fun resolve() = (reference ?: psi as? PsiReference)?.resolve() - override val resolvedName: String? - get() = ((reference ?: psi as? PsiReference)?.resolve() as? PsiNamedElement)?.name -} - -class JavaUTypeReferenceExpression( - override val psi: PsiTypeElement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UTypeReferenceExpression, PsiElementBacked { - override val type: PsiType - get() = psi.type -} - -class JavaClassUSimpleNameReferenceExpression( - override val identifier: String, - val ref: PsiJavaReference, - override val psi: PsiElement?, - override val containingElement: UElement? -) : JavaAbstractUExpression(), USimpleNameReferenceExpression, PsiElementBacked { - override fun resolve() = ref.resolve() - override val resolvedName: String? - get() = (ref.resolve() as? PsiNamedElement)?.name -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSuperExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSuperExpression.kt deleted file mode 100644 index 8f4c232880d..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSuperExpression.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiSuperExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.USuperExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUSuperExpression( - override val psi: PsiSuperExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), USuperExpression, PsiElementBacked { - override val label: String? - get() = psi.qualifier?.qualifiedName - - override val labelIdentifier: UIdentifier? - get() = psi.qualifier?.let { UIdentifier(it, this) } - - override fun resolve() = psi.qualifier?.resolve() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSynchronizedExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSynchronizedExpression.kt deleted file mode 100644 index 76fcecf972c..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUSynchronizedExpression.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java.expressions - -import com.intellij.psi.PsiSynchronizedStatement -import org.jetbrains.uast.UBlockExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.internal.acceptList -import org.jetbrains.uast.java.JavaAbstractUExpression -import org.jetbrains.uast.java.JavaConverter -import org.jetbrains.uast.java.lz -import org.jetbrains.uast.psi.PsiElementBacked -import org.jetbrains.uast.visitor.UastVisitor - -class JavaUSynchronizedExpression( - override val psi: PsiSynchronizedStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBlockExpression, PsiElementBacked { - override val expressions by lz { psi.body?.statements?.map { JavaConverter.convertStatement(it, this) } ?: listOf() } - val lockExpression by lz { JavaConverter.convertOrEmpty(psi.lockExpression, this) } - - override fun accept(visitor: UastVisitor) { - if (visitor.visitBlockExpression(this)) return - expressions.acceptList(visitor) - lockExpression.accept(visitor) - visitor.afterVisitBlockExpression(this) - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUThisExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUThisExpression.kt deleted file mode 100644 index 339da574ff7..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUThisExpression.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiThisExpression -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UIdentifier -import org.jetbrains.uast.UThisExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUThisExpression( - override val psi: PsiThisExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UThisExpression, PsiElementBacked { - override val label: String? - get() = psi.qualifier?.qualifiedName - - override val labelIdentifier: UIdentifier? - get() = psi.qualifier?.let { UIdentifier(it, this) } - - override fun resolve() = psi.qualifier?.resolve() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUThrowExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUThrowExpression.kt deleted file mode 100644 index fd0922efb83..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUThrowExpression.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.uast.java - -import com.intellij.psi.PsiThrowStatement -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UThrowExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUThrowExpression( - override val psi: PsiThrowStatement, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UThrowExpression, PsiElementBacked { - override val thrownExpression by lz { JavaConverter.convertOrEmpty(psi.exception, this) } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUTypeCastExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUTypeCastExpression.kt deleted file mode 100644 index 1f75ce1e9df..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUTypeCastExpression.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiType -import com.intellij.psi.PsiTypeCastExpression -import org.jetbrains.uast.UBinaryExpressionWithType -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UastBinaryExpressionWithTypeKind -import org.jetbrains.uast.UastErrorType -import org.jetbrains.uast.psi.PsiElementBacked - -class JavaUTypeCastExpression( - override val psi: PsiTypeCastExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UBinaryExpressionWithType, PsiElementBacked { - override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) } - - override val type: PsiType - get() = psi.castType?.type ?: UastErrorType - - override val typeReference by lz { psi.castType?.let { JavaUTypeReferenceExpression(it, this) } } - - override val operationKind: UastBinaryExpressionWithTypeKind.TypeCast - get() = UastBinaryExpressionWithTypeKind.TYPE_CAST -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUVariableDeclarationsExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUVariableDeclarationsExpression.kt deleted file mode 100644 index a51449994ff..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/JavaUVariableDeclarationsExpression.kt +++ /dev/null @@ -1,20 +0,0 @@ -package org.jetbrains.uast.java - -import org.jetbrains.uast.UAnnotation -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UVariable -import org.jetbrains.uast.UVariableDeclarationsExpression - -class JavaUVariableDeclarationsExpression( - override val containingElement: UElement? -) : UVariableDeclarationsExpression { - override lateinit var variables: List - internal set - - constructor(parent: UElement?, variables: List) : this(parent) { - this.variables = variables - } - - override val annotations: List - get() = emptyList() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/UnknownJavaExpression.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/UnknownJavaExpression.kt deleted file mode 100644 index 71d080cbfaf..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/UnknownJavaExpression.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.PsiElement -import org.jetbrains.uast.UAnnotation -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UExpression -import org.jetbrains.uast.psi.PsiElementBacked - -class UnknownJavaExpression( - override val psi: PsiElement, - override val containingElement: UElement? -) : UExpression, PsiElementBacked { - override fun asLogString() = "[!] UnknownJavaExpression ($psi)" - - override val annotations: List - get() = emptyList() -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt b/plugins/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt deleted file mode 100644 index e97b068bafe..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/expressions/javaUCallExpressions.kt +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.psi.* -import com.intellij.psi.util.PsiTypesUtil -import org.jetbrains.uast.* -import org.jetbrains.uast.expressions.UReferenceExpression -import org.jetbrains.uast.psi.PsiElementBacked -import org.jetbrains.uast.psi.UElementWithLocation - -class JavaUCallExpression( - override val psi: PsiMethodCallExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UCallExpression, PsiElementBacked, UElementWithLocation { - override val kind: UastCallKind - get() = UastCallKind.METHOD_CALL - - override val methodIdentifier by lz { - val methodExpression = psi.methodExpression - val nameElement = methodExpression.referenceNameElement ?: return@lz null - UIdentifier(nameElement, this) - } - - override val classReference: UReferenceExpression? - get() = null - - override val valueArgumentCount by lz { psi.argumentList.expressions.size } - override val valueArguments by lz { psi.argumentList.expressions.map { JavaConverter.convertExpression(it, this) } } - - override val typeArgumentCount by lz { psi.typeArguments.size } - - override val typeArguments: List - get() = psi.typeArguments.toList() - - override val returnType: PsiType? - get() = psi.type - - override val methodName: String? - get() = psi.methodExpression.referenceName - - override fun resolve() = psi.resolveMethod() - - override fun getStartOffset(): Int { - return psi.methodExpression.referenceNameElement?.textOffset ?: psi.methodExpression.textOffset - } - - override fun getEndOffset() = psi.textRange.endOffset - - override val receiver: UExpression? - get() { - return if (containingElement is UQualifiedReferenceExpression && containingElement.selector == this) - containingElement.receiver - else - null - } - - override val receiverType: PsiType? - get() { - val qualifierType = psi.methodExpression.qualifierExpression?.type - if (qualifierType != null) { - return qualifierType - } - - val method = resolve() ?: return null - if (method.hasModifierProperty(PsiModifier.STATIC)) return null - return method.containingClass?.let { PsiTypesUtil.getClassType(it) } - } -} - -class JavaConstructorUCallExpression( - override val psi: PsiNewExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UCallExpression, PsiElementBacked { - override val kind by lz { - when { - psi.arrayInitializer != null -> UastCallKind.NEW_ARRAY_WITH_INITIALIZER - psi.arrayDimensions.isNotEmpty() -> UastCallKind.NEW_ARRAY_WITH_DIMENSIONS - else -> UastCallKind.CONSTRUCTOR_CALL - } - } - - override val receiver: UExpression? - get() = null - - override val receiverType: PsiType? - get() = null - - override val methodIdentifier: UIdentifier? - get() = null - - override val classReference by lz { - psi.classReference?.let { ref -> - JavaClassUSimpleNameReferenceExpression(ref.element?.text.orAnonymous(), ref, ref.element, this) - } - } - - override val valueArgumentCount: Int - get() { - val initializer = psi.arrayInitializer - return if (initializer != null) { - initializer.initializers.size - } else if (psi.arrayDimensions.isNotEmpty()) { - psi.arrayDimensions.size - } else { - psi.argumentList?.expressions?.size ?: 0 - } - } - - override val valueArguments by lz { - val initializer = psi.arrayInitializer - if (initializer != null) { - initializer.initializers.map { JavaConverter.convertExpression(it, this) } - } - else if (psi.arrayDimensions.isNotEmpty()) { - psi.arrayDimensions.map { JavaConverter.convertExpression(it, this) } - } - else { - psi.argumentList?.expressions?.map { JavaConverter.convertExpression(it, this) } ?: emptyList() - } - } - - override val typeArgumentCount by lz { psi.classReference?.typeParameters?.size ?: 0 } - - override val typeArguments: List - get() = psi.classReference?.typeParameters?.toList() ?: emptyList() - - override val returnType: PsiType? - get() = (psi.classReference?.resolve() as? PsiClass)?.let { PsiTypesUtil.getClassType(it) } ?: psi.type - - override val methodName: String? - get() = null - - override fun resolve() = psi.resolveMethod() -} - -class JavaArrayInitializerUCallExpression( - override val psi: PsiArrayInitializerExpression, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UCallExpression, PsiElementBacked { - override val methodIdentifier: UIdentifier? - get() = null - - override val classReference: UReferenceExpression? - get() = null - - override val methodName: String? - get() = null - - override val valueArgumentCount by lz { psi.initializers.size } - override val valueArguments by lz { psi.initializers.map { JavaConverter.convertExpression(it, this) } } - - override val typeArgumentCount: Int - get() = 0 - - override val typeArguments: List - get() = emptyList() - - override val returnType: PsiType? - get() = psi.type - - override val kind: UastCallKind - get() = UastCallKind.NESTED_ARRAY_INITIALIZER - - override fun resolve() = null - - override val receiver: UExpression? - get() = null - - override val receiverType: PsiType? - get() = null -} - -class JavaAnnotationArrayInitializerUCallExpression( - override val psi: PsiArrayInitializerMemberValue, - override val containingElement: UElement? -) : JavaAbstractUExpression(), UCallExpression, PsiElementBacked { - override val kind: UastCallKind - get() = UastCallKind.NESTED_ARRAY_INITIALIZER - - override val methodIdentifier: UIdentifier? - get() = null - - override val classReference: UReferenceExpression? - get() = null - - override val methodName: String? - get() = null - - override val valueArgumentCount by lz { psi.initializers.size } - - override val valueArguments by lz { - psi.initializers.map { - JavaConverter.convertPsiElement(it, this) as? UExpression ?: UnknownJavaExpression(it, this) - } - } - - override val typeArgumentCount: Int - get() = 0 - - override val typeArguments: List - get() = emptyList() - - override val returnType: PsiType? - get() = null - - override fun resolve() = null - - override val receiver: UExpression? - get() = null - - override val receiverType: PsiType? - get() = null -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/internal/JavaUElementWithComments.kt b/plugins/uast-java/src/org/jetbrains/uast/java/internal/JavaUElementWithComments.kt deleted file mode 100644 index de9b10dbd4b..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/internal/JavaUElementWithComments.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.uast.java.internal - -import com.intellij.psi.PsiComment -import org.jetbrains.uast.UComment -import org.jetbrains.uast.UElement -import org.jetbrains.uast.psi.PsiElementBacked - -interface JavaUElementWithComments : UElement { - override val comments: List - get() { - val psi = (this as? PsiElementBacked)?.psi ?: return emptyList() - return psi.children.filter { it is PsiComment }.map { UComment(it, this) } - } -} \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt b/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt deleted file mode 100644 index 98b8de99863..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/internal/javaInternalUastUtils.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import com.intellij.openapi.util.Key -import com.intellij.psi.JavaTokenType -import com.intellij.psi.PsiAnnotation -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiModifierListOwner -import com.intellij.psi.impl.source.tree.CompositeElement -import com.intellij.psi.tree.IElementType -import org.jetbrains.uast.UDeclaration -import org.jetbrains.uast.UElement -import org.jetbrains.uast.UastBinaryOperator -import java.lang.ref.WeakReference - -internal val JAVA_CACHED_UELEMENT_KEY = Key.create>("cached-java-uelement") - -internal fun IElementType.getOperatorType() = when (this) { - JavaTokenType.EQ -> UastBinaryOperator.ASSIGN - JavaTokenType.PLUS -> UastBinaryOperator.PLUS - JavaTokenType.MINUS -> UastBinaryOperator.MINUS - JavaTokenType.ASTERISK -> UastBinaryOperator.MULTIPLY - JavaTokenType.DIV -> UastBinaryOperator.DIV - JavaTokenType.PERC -> UastBinaryOperator.MOD - JavaTokenType.OR -> UastBinaryOperator.BITWISE_OR - JavaTokenType.AND -> UastBinaryOperator.BITWISE_AND - JavaTokenType.XOR -> UastBinaryOperator.BITWISE_XOR - JavaTokenType.EQEQ -> UastBinaryOperator.IDENTITY_EQUALS - JavaTokenType.NE -> UastBinaryOperator.IDENTITY_NOT_EQUALS - JavaTokenType.GT -> UastBinaryOperator.GREATER - JavaTokenType.GE -> UastBinaryOperator.GREATER_OR_EQUAL - JavaTokenType.LT -> UastBinaryOperator.LESS - JavaTokenType.LE -> UastBinaryOperator.LESS_OR_EQUAL - JavaTokenType.LTLT -> UastBinaryOperator.SHIFT_LEFT - JavaTokenType.GTGT -> UastBinaryOperator.SHIFT_RIGHT - JavaTokenType.GTGTGT -> UastBinaryOperator.UNSIGNED_SHIFT_RIGHT - JavaTokenType.PLUSEQ -> UastBinaryOperator.PLUS_ASSIGN - JavaTokenType.MINUSEQ -> UastBinaryOperator.MINUS_ASSIGN - JavaTokenType.ASTERISKEQ -> UastBinaryOperator.MULTIPLY_ASSIGN - JavaTokenType.DIVEQ -> UastBinaryOperator.DIVIDE_ASSIGN - JavaTokenType.PERCEQ -> UastBinaryOperator.REMAINDER_ASSIGN - JavaTokenType.ANDEQ -> UastBinaryOperator.AND_ASSIGN - JavaTokenType.XOREQ -> UastBinaryOperator.XOR_ASSIGN - JavaTokenType.OREQ -> UastBinaryOperator.OR_ASSIGN - JavaTokenType.LTLTEQ -> UastBinaryOperator.SHIFT_LEFT_ASSIGN - JavaTokenType.GTGTEQ -> UastBinaryOperator.SHIFT_RIGHT_ASSIGN - JavaTokenType.GTGTGTEQ -> UastBinaryOperator.UNSIGNED_SHIFT_RIGHT_ASSIGN - else -> UastBinaryOperator.OTHER -} - -internal fun singletonListOrEmpty(element: T?) = if (element != null) listOf(element) else emptyList() - -@Suppress("NOTHING_TO_INLINE") -internal inline fun String?.orAnonymous(kind: String = ""): String { - return this ?: "" -} - -internal fun lz(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer) - -val PsiModifierListOwner.annotations: Array - get() = modifierList?.annotations ?: emptyArray() - -internal inline fun unwrap(element: P): P { - val unwrapped = if (element is T) element.psi else element - assert(unwrapped !is UElement) - return unwrapped as P -} - -internal fun PsiElement.getChildByRole(role: Int) = (this as? CompositeElement)?.findChildByRoleAsPsiElement(role) \ No newline at end of file diff --git a/plugins/uast-java/src/org/jetbrains/uast/java/kinds/JavaUastCallKinds.kt b/plugins/uast-java/src/org/jetbrains/uast/java/kinds/JavaUastCallKinds.kt deleted file mode 100644 index 168514b3e19..00000000000 --- a/plugins/uast-java/src/org/jetbrains/uast/java/kinds/JavaUastCallKinds.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.uast.java - -import org.jetbrains.uast.UastCallKind - -object JavaUastCallKinds { - @JvmField - val ASSERT = UastCallKind("assert") -} \ No newline at end of file diff --git a/plugins/uast-java/uast-java.iml b/plugins/uast-java/uast-java.iml deleted file mode 100644 index 2366b1f5805..00000000000 --- a/plugins/uast-java/uast-java.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/IdeaKotlinUastBindingContextProviderService.kt b/plugins/uast-kotlin-idea/src/IdeaKotlinUastBindingContextProviderService.kt similarity index 100% rename from plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/IdeaKotlinUastBindingContextProviderService.kt rename to plugins/uast-kotlin-idea/src/IdeaKotlinUastBindingContextProviderService.kt diff --git a/plugins/uast-kotlin-idea/uast-kotlin-idea.iml b/plugins/uast-kotlin-idea/uast-kotlin-idea.iml new file mode 100644 index 00000000000..86a69835678 --- /dev/null +++ b/plugins/uast-kotlin-idea/uast-kotlin-idea.iml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/uast-kotlin/uast-kotlin.iml b/plugins/uast-kotlin/uast-kotlin.iml index b698d771e9f..6bcdce22838 100644 --- a/plugins/uast-kotlin/uast-kotlin.iml +++ b/plugins/uast-kotlin/uast-kotlin.iml @@ -9,15 +9,11 @@ - - - - - + \ No newline at end of file diff --git a/update_dependencies.xml b/update_dependencies.xml index e258520ecd2..8a54c81332c 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -31,6 +31,8 @@ + + @@ -231,6 +233,11 @@ + + + + +