Code review changes
This commit is contained in:
@@ -1504,8 +1504,8 @@ public class LintDriver {
|
||||
continue;
|
||||
}
|
||||
|
||||
String path = file.getPath();
|
||||
if (!path.endsWith(DOT_JAVA) && !UastConverterUtils.isFileSupported(plugins, path)) {
|
||||
String filename = file.getName();
|
||||
if (!filename.endsWith(DOT_JAVA) && !UastConverterUtils.isFileSupported(plugins, filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -29,10 +29,10 @@ public abstract class LintLanguageExtension implements UastLanguagePlugin {
|
||||
public static final ExtensionPointName<LintLanguageExtension> EP_NAME =
|
||||
ExtensionPointName.create("com.android.tools.klint.client.api.lintLanguageExtension");
|
||||
|
||||
public static boolean isFileSupported(@Nullable Project project, String path) {
|
||||
public static boolean isFileSupported(@Nullable Project project, String name) {
|
||||
LintLanguageExtension[] extensions = getExtensions(project);
|
||||
for (LintLanguageExtension ext : extensions) {
|
||||
if (ext.getConverter().isFileSupported(path)) {
|
||||
if (ext.getConverter().isFileSupported(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-8
@@ -96,24 +96,23 @@ public class AppCompatCallDetector extends Detector implements UastScanner {
|
||||
@Override
|
||||
public void visitFunctionCall(UastAndroidContext context, UCallExpression node) {
|
||||
if (mDependsOnAppCompat && isAppBarActivityCall(context, node)) {
|
||||
String name = node.getFunctionName();
|
||||
String replace = null;
|
||||
if (GET_ACTION_BAR.equals(name)) {
|
||||
if (node.functionNameMatches(GET_ACTION_BAR)) {
|
||||
replace = "getSupportActionBar";
|
||||
} else if (START_ACTION_MODE.equals(name)) {
|
||||
} else if (node.functionNameMatches(START_ACTION_MODE)) {
|
||||
replace = "startSupportActionMode";
|
||||
} else if (SET_PROGRESS_BAR_VIS.equals(name)) {
|
||||
} else if (node.functionNameMatches(SET_PROGRESS_BAR_VIS)) {
|
||||
replace = "setSupportProgressBarVisibility";
|
||||
} else if (SET_PROGRESS_BAR_IN_VIS.equals(name)) {
|
||||
} else if (node.functionNameMatches(SET_PROGRESS_BAR_IN_VIS)) {
|
||||
replace = "setSupportProgressBarIndeterminateVisibility";
|
||||
} else if (SET_PROGRESS_BAR_INDETERMINATE.equals(name)) {
|
||||
} else if (node.functionNameMatches(SET_PROGRESS_BAR_INDETERMINATE)) {
|
||||
replace = "setSupportProgressBarIndeterminate";
|
||||
} else if (REQUEST_WINDOW_FEATURE.equals(name)) {
|
||||
} else if (node.functionNameMatches(REQUEST_WINDOW_FEATURE)) {
|
||||
replace = "supportRequestWindowFeature";
|
||||
}
|
||||
|
||||
if (replace != null) {
|
||||
String message = String.format(ERROR_MESSAGE_FORMAT, replace, name);
|
||||
String message = String.format(ERROR_MESSAGE_FORMAT, replace, node.getFunctionName());
|
||||
context.report(ISSUE, node, UastAndroidUtils.getLocation(node), message);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class CipherGetInstanceDetector extends Detector implements UastScanner {
|
||||
UExpression expression = argumentList.get(0);
|
||||
if (expression instanceof ULiteralExpression) {
|
||||
ULiteralExpression argument = (ULiteralExpression)expression;
|
||||
String parameter = argument.getText();
|
||||
String parameter = argument.asString();
|
||||
checkParameter(context, node, argument, parameter, false);
|
||||
} else if (expression instanceof UResolvable) {
|
||||
UDeclaration declaration = ((UResolvable)expression).resolve(context);
|
||||
|
||||
@@ -157,11 +157,10 @@ public class CleanupDetector extends Detector implements UastScanner {
|
||||
|
||||
@Override
|
||||
public void visitFunctionCall(UastAndroidContext context, UCallExpression node) {
|
||||
String name = node.getFunctionName();
|
||||
if (BEGIN_TRANSACTION.equals(name)) {
|
||||
if (node.functionNameMatches(BEGIN_TRANSACTION)) {
|
||||
checkTransactionCommits(context, node);
|
||||
} else {
|
||||
checkResourceRecycled(context, node, name);
|
||||
checkResourceRecycled(context, node, node.getFunctionName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,8 +245,7 @@ public class CleanupDetector extends Detector implements UastScanner {
|
||||
FinishVisitor visitor = new FinishVisitor(context, boundVariable) {
|
||||
@Override
|
||||
protected boolean isCleanupCall(@NonNull UCallExpression call) {
|
||||
String methodName = call.getFunctionName();
|
||||
if (!recycleName.equals(methodName)) {
|
||||
if (!call.functionNameMatches(recycleName)) {
|
||||
return false;
|
||||
}
|
||||
UDeclaration resolved = call.resolve(mContext);
|
||||
@@ -385,8 +383,7 @@ public class CleanupDetector extends Detector implements UastScanner {
|
||||
private static boolean isTransactionCommitMethodCall(@NonNull UastAndroidContext context,
|
||||
@NonNull UCallExpression call) {
|
||||
|
||||
String methodName = call.getFunctionName();
|
||||
return (COMMIT.equals(methodName) || COMMIT_ALLOWING_LOSS.equals(methodName)) &&
|
||||
return (call.functionNameMatches(COMMIT) || call.functionNameMatches(COMMIT_ALLOWING_LOSS)) &&
|
||||
isMethodOnFragmentClass(context, call,
|
||||
FRAGMENT_TRANSACTION_CLS,
|
||||
FRAGMENT_TRANSACTION_V4_CLS);
|
||||
@@ -394,8 +391,7 @@ public class CleanupDetector extends Detector implements UastScanner {
|
||||
|
||||
private static boolean isShowFragmentMethodCall(@NonNull UastAndroidContext context,
|
||||
@NonNull UCallExpression call) {
|
||||
String methodName = call.getFunctionName();
|
||||
return SHOW.equals(methodName)
|
||||
return call.functionNameMatches(SHOW)
|
||||
&& isMethodOnFragmentClass(context, call,
|
||||
DIALOG_FRAGMENT, DIALOG_V4_FRAGMENT);
|
||||
}
|
||||
@@ -439,9 +435,8 @@ public class CleanupDetector extends Detector implements UastScanner {
|
||||
|
||||
private static boolean isBeginTransaction(@NonNull UastAndroidContext context,
|
||||
@NonNull UCallExpression node) {
|
||||
String methodName = node.getFunctionName();
|
||||
assert BEGIN_TRANSACTION.equals(methodName) : methodName;
|
||||
if (BEGIN_TRANSACTION.equals(methodName)) {
|
||||
assert node.functionNameMatches(BEGIN_TRANSACTION) : node.renderString();
|
||||
if (node.functionNameMatches(BEGIN_TRANSACTION)) {
|
||||
UFunction method = node.resolve(context);
|
||||
if (method != null) {
|
||||
UClass containingClass = UastUtils.getContainingClassOrEmpty(method);
|
||||
|
||||
+9
-7
@@ -46,6 +46,7 @@ import com.android.utils.XmlUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import kotlin.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.uast.*;
|
||||
import org.jetbrains.uast.check.UastAndroidContext;
|
||||
@@ -1103,9 +1104,9 @@ public class SupportAnnotationDetector extends Detector implements UastScanner {
|
||||
private static void checkTypeDefConstant(@NonNull UastAndroidContext context,
|
||||
@NonNull UAnnotation annotation, @NonNull UElement argument,
|
||||
@Nullable UElement errorNode, boolean flag, Object value) {
|
||||
List<Object> valueArguments = annotation.getValues();
|
||||
for (Object o : valueArguments) {
|
||||
if (o.equals(value)) {
|
||||
List<Pair<String, Object>> valueArguments = annotation.getValues();
|
||||
for (Pair<String, Object> o : valueArguments) {
|
||||
if (o.getSecond().equals(value)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1115,12 +1116,12 @@ public class SupportAnnotationDetector extends Detector implements UastScanner {
|
||||
private static void reportTypeDef(@NonNull UastAndroidContext context,
|
||||
@NonNull UAnnotation annotation, @NonNull UElement argument,
|
||||
@Nullable UElement errorNode) {
|
||||
List<Object> allowed = annotation.getValues();
|
||||
List<Pair<String, Object>> allowed = annotation.getValues();
|
||||
reportTypeDef(context, argument, errorNode, false, allowed);
|
||||
}
|
||||
|
||||
private static void reportTypeDef(@NonNull UastAndroidContext context, @NonNull UElement node,
|
||||
@Nullable UElement errorNode, boolean flag, @NonNull List<Object> allowedValues) {
|
||||
@Nullable UElement errorNode, boolean flag, @NonNull List<Pair<String, Object>> allowedValues) {
|
||||
String values = listAllowedValues(allowedValues);
|
||||
String message;
|
||||
if (flag) {
|
||||
@@ -1134,9 +1135,10 @@ public class SupportAnnotationDetector extends Detector implements UastScanner {
|
||||
context.report(TYPE_DEF, errorNode, context.getLocation(errorNode), message);
|
||||
}
|
||||
|
||||
private static String listAllowedValues(@NonNull List<Object> allowedValues) {
|
||||
private static String listAllowedValues(@NonNull List<Pair<String, Object>> allowedValues) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Object allowedValue : allowedValues) {
|
||||
for (Pair<String, Object> namedValue : allowedValues) {
|
||||
Object allowedValue = namedValue.getSecond();
|
||||
String s;
|
||||
if (allowedValue instanceof Integer) {
|
||||
s = allowedValue.toString();
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public class AndroidLintExternalAnnotator extends ExternalAnnotator<State, State
|
||||
} else if (fileType == StdFileTypes.PROPERTIES) {
|
||||
scope = Scope.PROPERTY_SCOPE;
|
||||
} else {
|
||||
if (UastConverterUtils.isFileSupported(client.getLanguagePlugins(), mainFile.getPath())) {
|
||||
if (UastConverterUtils.isFileSupported(client.getLanguagePlugins(), mainFile.getName())) {
|
||||
scope = Scope.JAVA_FILE_SCOPE;
|
||||
} else {
|
||||
// #collectionInformation above should have prevented this
|
||||
|
||||
@@ -19,7 +19,7 @@ interface UastConverter {
|
||||
fun convert(element: Any?, parent: UElement): UElement?
|
||||
fun convertWithParent(element: Any?): UElement?
|
||||
|
||||
fun isFileSupported(path: String): Boolean
|
||||
fun isFileSupported(name: String): Boolean
|
||||
}
|
||||
|
||||
interface UastLanguagePlugin {
|
||||
@@ -33,7 +33,7 @@ interface UastAdditionalChecker {
|
||||
|
||||
object UastConverterUtils {
|
||||
@JvmStatic
|
||||
fun isFileSupported(converters: List<UastLanguagePlugin>, path: String): Boolean {
|
||||
return converters.any { it.converter.isFileSupported(path) }
|
||||
fun isFileSupported(converters: List<UastLanguagePlugin>, name: String): Boolean {
|
||||
return converters.any { it.converter.isFileSupported(name) }
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ abstract class UastVisitor {
|
||||
open fun visitQualifiedExpression(node: UQualifiedExpression): Boolean = false
|
||||
open fun visitSimpleReferenceExpression(node: USimpleReferenceExpression): Boolean = false
|
||||
open fun visitCallExpression(node: UCallExpression): Boolean = false
|
||||
open fun visitAssignmentExpression(node: UAssignmentExpression): Boolean = false
|
||||
open fun visitBinaryExpression(node: UBinaryExpression): Boolean = false
|
||||
open fun visitBinaryExpressionWithType(node: UBinaryExpressionWithType): Boolean = false
|
||||
open fun visitParenthesizedExpression(node: UParenthesizedExpression): Boolean = false
|
||||
@@ -80,7 +79,6 @@ abstract class UastVisitor {
|
||||
is UQualifiedExpression -> visitQualifiedExpression(node)
|
||||
is USimpleReferenceExpression -> visitSimpleReferenceExpression(node)
|
||||
is UCallExpression -> visitCallExpression(node)
|
||||
is UAssignmentExpression -> visitAssignmentExpression(node)
|
||||
is UBinaryExpression -> visitBinaryExpression(node)
|
||||
is UBinaryExpressionWithType -> visitBinaryExpressionWithType(node)
|
||||
is UParenthesizedExpression -> visitParenthesizedExpression(node)
|
||||
|
||||
@@ -20,7 +20,8 @@ interface UAnnotation : UElement, UNamed, UFqNamed, LeafUElement {
|
||||
|
||||
val valueArguments: List<UNamedExpression>
|
||||
fun getValue(name: String) = valueArguments.firstOrNull { it.name == name }?.expression?.evaluate()
|
||||
fun getValues() = valueArguments.map { it.expression.evaluate() }
|
||||
|
||||
fun getValues() = valueArguments.map { Pair(it.name, it.expression.evaluate()) }
|
||||
|
||||
override fun logString() = log("UAnnotation ($name)")
|
||||
override fun renderString() = if (valueArguments.isEmpty()) "@$name" else "@$name(" +
|
||||
|
||||
@@ -17,6 +17,10 @@ package org.jetbrains.uast
|
||||
|
||||
interface UElement {
|
||||
val parent: UElement?
|
||||
|
||||
open val isValid: Boolean
|
||||
get() = true
|
||||
|
||||
fun logString(): String
|
||||
fun renderString(): String = logString()
|
||||
fun traverse(callback: UastCallback)
|
||||
|
||||
@@ -16,15 +16,11 @@
|
||||
package org.jetbrains.uast
|
||||
|
||||
interface UExpression : UElement {
|
||||
fun evaluate(): Any?
|
||||
open fun evaluate(): Any? = null
|
||||
fun evaluateString(): String? = evaluate() as? String
|
||||
fun getExpressionType(): UType? = null
|
||||
}
|
||||
|
||||
interface NoEvaluate : UExpression {
|
||||
override fun evaluate() = null
|
||||
}
|
||||
|
||||
interface NoAnnotations : UAnnotated {
|
||||
override val annotations: List<UAnnotation>
|
||||
get() = emptyList()
|
||||
@@ -34,6 +30,6 @@ interface NoModifiers : UModifierOwner {
|
||||
override fun hasModifier(modifier: UastModifier) = false
|
||||
}
|
||||
|
||||
class EmptyExpression(override val parent: UElement) : UExpression, LeafUElement, NoEvaluate {
|
||||
class EmptyExpression(override val parent: UElement) : UExpression, LeafUElement {
|
||||
override fun logString() = "EmptyExpression"
|
||||
}
|
||||
+4
-5
@@ -16,24 +16,23 @@
|
||||
package org.jetbrains.uast
|
||||
|
||||
interface UForEachExpression : ULoopExpression {
|
||||
val variableName: String?
|
||||
val variable: UVariable
|
||||
val iteratedValue: UExpression
|
||||
|
||||
override fun traverse(callback: UastCallback) {
|
||||
variable.handleTraverse(callback)
|
||||
iteratedValue.handleTraverse(callback)
|
||||
body.handleTraverse(callback)
|
||||
}
|
||||
|
||||
override fun renderString() = buildString {
|
||||
append("for (")
|
||||
append(variableName ?: "<error name>")
|
||||
append(variable.name)
|
||||
append(" : ")
|
||||
append(iteratedValue.renderString())
|
||||
append(") ")
|
||||
append(body.renderString())
|
||||
}
|
||||
|
||||
override fun logString() = "UForEachExpression ($variableName)\n" +
|
||||
iteratedValue.logString().withMargin + "\n" +
|
||||
body.logString().withMargin
|
||||
override fun logString() = log("UForEachExpression", variable, iteratedValue, body)
|
||||
}
|
||||
@@ -51,4 +51,4 @@ interface UDefaultSwitchClauseExpression : USwitchClauseExpression {
|
||||
override fun renderString() = "else -> "
|
||||
}
|
||||
|
||||
class SimpleUDefaultSwitchClauseExpression(override val parent: UElement) : UDefaultSwitchClauseExpression, NoEvaluate
|
||||
class SimpleUDefaultSwitchClauseExpression(override val parent: UElement) : UDefaultSwitchClauseExpression
|
||||
@@ -22,6 +22,7 @@ interface UTryExpression : UExpression {
|
||||
val finallyClause: UExpression?
|
||||
|
||||
override fun traverse(callback: UastCallback) {
|
||||
resources?.handleTraverseList(callback)
|
||||
tryClause.handleTraverse(callback)
|
||||
catchClauses.handleTraverseList(callback)
|
||||
finallyClause?.handleTraverse(callback)
|
||||
@@ -47,6 +48,8 @@ interface UCatchClause : UElement {
|
||||
|
||||
override fun traverse(callback: UastCallback) {
|
||||
body.handleTraverse(callback)
|
||||
parameters.handleTraverseList(callback)
|
||||
types.handleTraverseList(callback)
|
||||
}
|
||||
|
||||
override fun logString() = log("UCatchClause", body)
|
||||
|
||||
@@ -47,7 +47,7 @@ interface UClass : UDeclaration, UFqNamed, UModifierOwner, UAnnotated {
|
||||
val constructors: List<UFunction>
|
||||
get() = declarations.filter { it is UFunction && it.kind == UastFunctionKind.CONSTRUCTOR } as List<UFunction>
|
||||
|
||||
fun isSubclassOf(name: String) : Boolean
|
||||
fun isSubclassOf(fqName: String) : Boolean
|
||||
|
||||
fun getSuperClass(context: UastContext): UClass?
|
||||
|
||||
@@ -81,7 +81,7 @@ object UClassNotResolved : UClass {
|
||||
override val visibility = UastVisibility.PRIVATE
|
||||
override val superTypes = emptyList<UType>()
|
||||
override val declarations = emptyList<UDeclaration>()
|
||||
override fun isSubclassOf(name: String) = false
|
||||
override fun isSubclassOf(fqName: String) = false
|
||||
override val companions = emptyList<UClass>()
|
||||
override val defaultType = UastErrorType
|
||||
override val nameElement = null
|
||||
|
||||
@@ -22,6 +22,9 @@ interface UImportStatement : UElement {
|
||||
val isStarImport: Boolean
|
||||
val kind: UastImportKind
|
||||
|
||||
/* Returns null if isStarImport = true */
|
||||
fun resolve(context: UastContext): UDeclaration?
|
||||
|
||||
override fun traverse(callback: UastCallback) {}
|
||||
override fun logString() = "UImport ($fqNameToImport)"
|
||||
override fun renderString() = "import ${fqNameToImport ?: ""}"
|
||||
|
||||
@@ -35,6 +35,10 @@ interface UType : UElement, UNamed, UFqNamed, UAnnotated, UResolvable, LeafUElem
|
||||
|
||||
override fun resolve(context: UastContext): UClass?
|
||||
override fun resolveOrEmpty(context: UastContext) = resolve(context) ?: UClassNotResolved
|
||||
|
||||
override fun traverse(callback: UastCallback) {
|
||||
annotations.handleTraverseList(callback)
|
||||
}
|
||||
}
|
||||
|
||||
interface UTypeReference : UDeclaration, UResolvable, LeafUElement {
|
||||
|
||||
@@ -19,6 +19,13 @@ interface UVariable : UDeclaration, UModifierOwner, UAnnotated {
|
||||
val initializer: UExpression?
|
||||
val kind: UastVariableKind
|
||||
val type: UType
|
||||
val visibility: UastVisibility
|
||||
|
||||
open val getters: List<UFunction>?
|
||||
get() = null
|
||||
|
||||
open val setters: List<UFunction>?
|
||||
get() = null
|
||||
|
||||
override fun traverse(callback: UastCallback) {
|
||||
nameElement?.handleTraverse(callback)
|
||||
@@ -37,3 +44,16 @@ interface UVariable : UDeclaration, UModifierOwner, UAnnotated {
|
||||
override fun logString() = "UVariable ($name, kind = ${kind.name})\n" +
|
||||
(initializer?.let { it.logString().withMargin } ?: "<no initializer>")
|
||||
}
|
||||
|
||||
object UVariableNotResolved : UVariable {
|
||||
override val initializer = null
|
||||
override val kind = UastVariableKind.MEMBER
|
||||
override val type = UastErrorType
|
||||
override val nameElement = null
|
||||
override val parent = null
|
||||
override val name = "<variable not resolved>"
|
||||
override val visibility = UastVisibility.LOCAL
|
||||
|
||||
override fun hasModifier(modifier: UastModifier) = false
|
||||
override val annotations = emptyList<UAnnotation>()
|
||||
}
|
||||
@@ -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
|
||||
|
||||
interface UAssignmentExpression : UExpression {
|
||||
val reference: UExpression
|
||||
val operator: String
|
||||
val value: UExpression
|
||||
|
||||
override fun traverse(callback: UastCallback) {
|
||||
reference.handleTraverse(callback)
|
||||
value.handleTraverse(callback)
|
||||
}
|
||||
|
||||
override fun logString() = "UAssignmentExpression ($operator)\n" + reference.logString().withMargin + "\n" + value.logString().withMargin
|
||||
|
||||
override fun renderString() = reference.renderString() + ' ' + operator + ' ' + value.renderString()
|
||||
}
|
||||
@@ -23,6 +23,8 @@ interface ULabeledExpression : UExpression {
|
||||
expression.handleTraverse(callback)
|
||||
}
|
||||
|
||||
override fun evaluate() = expression.evaluate()
|
||||
|
||||
override fun logString() = log("ULabeledExpression ($label)", expression)
|
||||
|
||||
override fun renderString() = "$label@ ${expression.renderString()}"
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package org.jetbrains.uast
|
||||
|
||||
interface ULiteralExpression : UExpression {
|
||||
val text: String
|
||||
|
||||
val value: Any?
|
||||
|
||||
val isNull: Boolean
|
||||
@@ -28,7 +26,9 @@ interface ULiteralExpression : UExpression {
|
||||
val isBoolean: Boolean
|
||||
get() = evaluate() is Boolean
|
||||
|
||||
fun asString() = value?.toString() ?: ""
|
||||
|
||||
override fun traverse(callback: UastCallback) {}
|
||||
override fun logString() = "ULiteralExpression ($text)"
|
||||
override fun renderString() = text
|
||||
override fun logString() = "ULiteralExpression (${asString()})"
|
||||
override fun renderString() = asString()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ interface UParenthesizedExpression : UExpression {
|
||||
expression.handleTraverse(callback)
|
||||
}
|
||||
|
||||
override fun evaluate() = expression.evaluate()
|
||||
|
||||
override fun logString() = log("UParenthesizedExpression", expression)
|
||||
override fun renderString() = '(' + expression.renderString() + ')'
|
||||
}
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.uast
|
||||
|
||||
interface USuperExpression : UExpression {
|
||||
interface USuperExpression : UExpression, LeafUElement {
|
||||
override fun logString() = "USuperExpression"
|
||||
override fun renderString() = "super"
|
||||
override fun traverse(callback: UastCallback) {}
|
||||
}
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.uast
|
||||
|
||||
interface UThisExpression : UExpression {
|
||||
interface UThisExpression : UExpression, LeafUElement {
|
||||
override fun logString() = "UThisExpression"
|
||||
override fun renderString() = "this"
|
||||
override fun traverse(callback: UastCallback) {}
|
||||
}
|
||||
@@ -17,13 +17,20 @@ package org.jetbrains.uast
|
||||
|
||||
open class UastFunctionKind(val text: String) {
|
||||
class UastInitializerKind(val name: String) : UastFunctionKind("INITIALIZER ($name)")
|
||||
class UastVariableAccessor(val name: String) : UastFunctionKind(name)
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val FUNCTION = UastFunctionKind("function")
|
||||
|
||||
@JvmField
|
||||
val CONSTRUCTOR = UastFunctionKind("CONSTRUCTOR")
|
||||
val CONSTRUCTOR = UastFunctionKind("constructor")
|
||||
|
||||
@JvmField
|
||||
val GETTER = UastVariableAccessor("getter")
|
||||
|
||||
@JvmField
|
||||
val SETTER = UastVariableAccessor("setter")
|
||||
}
|
||||
|
||||
override fun toString(): String{
|
||||
|
||||
@@ -24,6 +24,9 @@ class UastImportKind(val text: String) {
|
||||
|
||||
@JvmField
|
||||
val MEMBER = UastImportKind("member")
|
||||
|
||||
@JvmField
|
||||
val UNKNOWN = UastImportKind("unknown")
|
||||
}
|
||||
|
||||
override fun toString(): String{
|
||||
|
||||
@@ -25,8 +25,8 @@ object JavaUastLanguagePlugin : UastLanguagePlugin {
|
||||
}
|
||||
|
||||
internal object JavaConverter : UastConverter {
|
||||
override fun isFileSupported(path: String): Boolean {
|
||||
return path.endsWith(".java", ignoreCase = true)
|
||||
override fun isFileSupported(name: String): Boolean {
|
||||
return name.endsWith(".java", ignoreCase = true)
|
||||
}
|
||||
|
||||
fun convert(file: PsiJavaFile): UFile = JavaUFile(file)
|
||||
@@ -125,10 +125,10 @@ internal object JavaConverter : UastConverter {
|
||||
parent: UElement,
|
||||
i: Int
|
||||
): UExpression {
|
||||
return if (i == 1) JavaCombinedUBinaryExpression(expression, parent).apply {
|
||||
return if (i == 1) JavaSeparatedPolyadicUBinaryExpression(expression, parent).apply {
|
||||
leftOperand = convert(expression.operands[0], this)
|
||||
rightOperand = convert(expression.operands[1], this)
|
||||
} else JavaCombinedUBinaryExpression(expression, parent).apply {
|
||||
} else JavaSeparatedPolyadicUBinaryExpression(expression, parent).apply {
|
||||
leftOperand = convertPolyadicExpression(expression, parent, i - 1)
|
||||
rightOperand = convert(expression.operands[i], this)
|
||||
}
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiDoWhileStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UDoWhileExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUDoWhileExpression(
|
||||
override val psi: PsiDoWhileStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UDoWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UDoWhileExpression, PsiElementBacked {
|
||||
override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
+2
-4
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiForeachStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UForEachExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,9 +23,8 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUForEachExpression(
|
||||
override val psi: PsiForeachStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UForEachExpression, PsiElementBacked, NoEvaluate {
|
||||
override val variableName: String?
|
||||
get() = psi.iterationParameter.name
|
||||
) : JavaAbstractUElement(), UForEachExpression, PsiElementBacked {
|
||||
override val variable by lz { JavaConverter.convert(psi.iterationParameter, this) }
|
||||
|
||||
override val iteratedValue by lz { JavaConverter.convertOrEmpty(psi.iteratedValue, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiForStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UForExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUForExpression(
|
||||
override val psi: PsiForStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UForExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UForExpression, PsiElementBacked {
|
||||
override val declaration by lz { psi.initialization?.let { JavaConverter.convert(it, this) } }
|
||||
override val condition by lz { psi.condition?.let { JavaConverter.convert(it, this) } }
|
||||
override val update by lz { psi.update?.let { JavaConverter.convert(it, this) } }
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiIfStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UIfExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUIfExpression(
|
||||
override val psi: PsiIfStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UIfExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UIfExpression, PsiElementBacked {
|
||||
override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val thenBranch by lz { JavaConverter.convertOrEmpty(psi.thenBranch, this) }
|
||||
override val elseBranch by lz { JavaConverter.convertOrEmpty(psi.elseBranch, this) }
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@ package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiSwitchLabelStatement
|
||||
import com.intellij.psi.PsiSwitchStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UExpressionSwitchClauseExpression
|
||||
import org.jetbrains.uast.USwitchExpression
|
||||
@@ -26,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUSwitchExpression(
|
||||
override val psi: PsiSwitchStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), USwitchExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), USwitchExpression, PsiElementBacked {
|
||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.expression, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
@@ -34,6 +33,6 @@ class JavaUSwitchExpression(
|
||||
class JavaUExpressionSwitchClauseExpression(
|
||||
override val psi: PsiSwitchLabelStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UExpressionSwitchClauseExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UExpressionSwitchClauseExpression, PsiElementBacked {
|
||||
override val caseValue by lz { JavaConverter.convertOrEmpty(psi.caseValue, this) }
|
||||
}
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUTernaryIfExpression(
|
||||
override val psi: PsiConditionalExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UIfExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UIfExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val condition by lz { JavaConverter.convert(psi.condition, this) }
|
||||
override val thenBranch by lz { JavaConverter.convertOrEmpty(psi.thenExpression, this) }
|
||||
override val elseBranch by lz { JavaConverter.convertOrEmpty(psi.elseExpression, this) }
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUTryExpression(
|
||||
override val psi: PsiTryStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UTryExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), 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.convert(it, this) } }
|
||||
@@ -40,5 +40,5 @@ class JavaUCatchClause(
|
||||
) : JavaAbstractUElement(), UCatchClause, PsiElementBacked {
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.catchBlock, this) }
|
||||
override val parameters by lz { psi.parameter?.let { listOf(JavaConverter.convert(it, this)) } ?: emptyList() }
|
||||
override val types by lz { listOf(JavaConverter.convert(psi.catchType, this)) }
|
||||
override val types by lz { psi.preciseCatchTypes.map { JavaConverter.convert(it, this) } }
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiWhileStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UWhileExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUWhileExpression(
|
||||
override val psi: PsiWhileStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UWhileExpression, PsiElementBacked {
|
||||
override val condition by lz { JavaConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { JavaConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
@@ -92,14 +92,14 @@ class JavaUClass(
|
||||
declarations
|
||||
}
|
||||
|
||||
override fun isSubclassOf(name: String): Boolean {
|
||||
override fun isSubclassOf(fqName: String): Boolean {
|
||||
tailrec fun isSubClassOf(clazz: PsiClass?, name: String): Boolean = when {
|
||||
clazz == null -> false
|
||||
clazz.qualifiedName == name -> true
|
||||
else -> isSubClassOf(clazz.superClass, name)
|
||||
}
|
||||
|
||||
return isSubClassOf(psi, name)
|
||||
return isSubClassOf(psi, fqName)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
@@ -169,13 +169,7 @@ private class JavaUAnonymousClassConstructor(
|
||||
|
||||
override val valueParameters by lz {
|
||||
val args = newExpression.argumentList ?: return@lz emptyList<UVariable>()
|
||||
val variables = ArrayList<UVariable>(args.expressions.size)
|
||||
|
||||
for (i in 0..(args.expressions.size - 1)) {
|
||||
variables += JavaUAnonymousClassConstructorParameter(args, i, this)
|
||||
}
|
||||
|
||||
variables
|
||||
args.expressions.mapIndexed { i, psiExpression -> JavaUAnonymousClassConstructorParameter(args, i, this) }
|
||||
}
|
||||
override val typeParameters by lz { psi.typeParameters.map { JavaConverter.convert(it, this) } }
|
||||
|
||||
@@ -216,4 +210,7 @@ private class JavaUAnonymousClassConstructorParameter(
|
||||
|
||||
override val name: String
|
||||
get() = "p$index"
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = UastVisibility.LOCAL
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.uast.UImportStatement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaUFile(override val psi: PsiJavaFile): JavaAbstractUElement(), UFile, PsiElementBacked {
|
||||
override val packageFqName by lz { psi.packageName.let { if (it.isNotBlank()) it else null } }
|
||||
override val packageFqName by lz { psi.packageName }
|
||||
|
||||
override val importStatements: List<UImportStatement> by lz {
|
||||
val importList = psi.importList ?: return@lz emptyList<UImportStatement>()
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiImportStatement
|
||||
import org.jetbrains.uast.UDeclaration
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UImportStatement
|
||||
import org.jetbrains.uast.UastContext
|
||||
import org.jetbrains.uast.kinds.UastImportKind
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
@@ -32,5 +34,11 @@ class JavaUImportStatement(
|
||||
get() = UastImportKind.CLASS
|
||||
|
||||
override val isStarImport: Boolean
|
||||
get() = false
|
||||
get() = psi.isOnDemand
|
||||
|
||||
override fun resolve(context: UastContext): UDeclaration? {
|
||||
if (psi.isOnDemand) return null
|
||||
val resolvedElement = psi.resolve() ?: return null
|
||||
return context.convert(resolvedElement) as? UDeclaration
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -16,8 +16,10 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiImportStaticStatement
|
||||
import org.jetbrains.uast.UDeclaration
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UImportStatement
|
||||
import org.jetbrains.uast.UastContext
|
||||
import org.jetbrains.uast.kinds.UastImportKind
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
@@ -32,5 +34,11 @@ class JavaUStaticImportStatement(
|
||||
get() = UastImportKind.MEMBER
|
||||
|
||||
override val isStarImport: Boolean
|
||||
get() = true
|
||||
get() = psi.isOnDemand
|
||||
|
||||
override fun resolve(context: UastContext): UDeclaration? {
|
||||
if (psi.isOnDemand) return null
|
||||
val resolvedElement = psi.resolve() ?: return null
|
||||
return context.convert(resolvedElement) as? UDeclaration
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,7 @@ package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiField
|
||||
import com.intellij.psi.PsiVariable
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UVariable
|
||||
import org.jetbrains.uast.UastModifier
|
||||
import org.jetbrains.uast.UastVariableKind
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaUVariable(
|
||||
@@ -40,6 +37,9 @@ class JavaUVariable(
|
||||
else -> UastVariableKind.LOCAL_VARIABLE
|
||||
}
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = psi.getVisibility()
|
||||
|
||||
override fun hasModifier(modifier: UastModifier) = psi.hasModifier(modifier)
|
||||
override val annotations by lz { psi.modifierList.getAnnotations(this) }
|
||||
}
|
||||
+5
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaValueParameterUVariable(
|
||||
override val psi: PsiParameter,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UVariable, PsiElementBacked, NoModifiers {
|
||||
) : JavaAbstractUElement(), UVariable, PsiElementBacked {
|
||||
override val name: String
|
||||
get() = psi.name.orAnonymous()
|
||||
|
||||
@@ -35,5 +35,9 @@ class JavaValueParameterUVariable(
|
||||
override val kind: UastVariableKind
|
||||
get() = UastVariableKind.VALUE_PARAMETER
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = UastVisibility.LOCAL
|
||||
|
||||
override fun hasModifier(modifier: UastModifier) = psi.hasModifier(modifier)
|
||||
override val annotations by lz { psi.modifierList.getAnnotations(this) }
|
||||
}
|
||||
@@ -24,6 +24,6 @@ class JavaDumbUElement(
|
||||
override val psi: PsiElement?,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UElement, PsiElementBacked, LeafUElement {
|
||||
override fun logString() = "JavaPsiElementStub"
|
||||
override fun logString() = "JavaDumbUElement"
|
||||
override fun renderString() = "<stub@$psi>"
|
||||
}
|
||||
+2
-2
@@ -21,10 +21,10 @@ import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaCombinedUBinaryExpression(
|
||||
class JavaSeparatedPolyadicUBinaryExpression(
|
||||
override val psi: PsiPolyadicExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override lateinit var leftOperand: UExpression
|
||||
override lateinit var rightOperand: UExpression
|
||||
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiArrayAccessExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UArrayAccessExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUArrayAccessExpression(
|
||||
override val psi: PsiArrayAccessExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UArrayAccessExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UArrayAccessExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val receiver by lz { JavaConverter.convert(psi.arrayExpression, this) }
|
||||
override val indices by lz { singletonListOrEmpty(JavaConverter.convertOrNull(psi.indexExpression, this)) }
|
||||
}
|
||||
+7
-6
@@ -16,18 +16,19 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiAssignmentExpression
|
||||
import org.jetbrains.uast.UAssignmentExpression
|
||||
import org.jetbrains.uast.UBinaryExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UastBinaryOperator
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaUAssignmentExpression(
|
||||
override val psi: PsiAssignmentExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UAssignmentExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
override val reference by lz { JavaConverter.convert(psi.lExpression, this) }
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val leftOperand by lz { JavaConverter.convert(psi.lExpression, this) }
|
||||
|
||||
override val operator: String
|
||||
get() = psi.operationSign.text
|
||||
override val operator: UastBinaryOperator
|
||||
get() = UastBinaryOperator.ASSIGN
|
||||
|
||||
override val value by lz { JavaConverter.convertOrEmpty(psi.rExpression, this) }
|
||||
override val rightOperand by lz { JavaConverter.convertOrEmpty(psi.rExpression, this) }
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUBinaryExpression(
|
||||
override val psi: PsiBinaryExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val leftOperand by lz { JavaConverter.convert(psi.lOperand, this) }
|
||||
override val rightOperand by lz { JavaConverter.convertOrEmpty(psi.rOperand, this) }
|
||||
override val operator by lz { psi.operationTokenType.getOperatorType() }
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiBlockStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UBlockExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,6 +23,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUBlockExpression(
|
||||
override val psi: PsiBlockStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UBlockExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UBlockExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val expressions by lz { psi.codeBlock.statements.map { JavaConverter.convert(it, this) } }
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiMethodReferenceExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UCallableReferenceExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,6 +23,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUCallableReferenceExpression(
|
||||
override val psi: PsiMethodReferenceExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UCallableReferenceExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UCallableReferenceExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val qualifierType by lz { JavaConverter.convert(psi.qualifierType?.type, this) }
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiClassObjectAccessExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UClassLiteralExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UType
|
||||
@@ -25,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUClassLiteralExpression(
|
||||
override val psi: PsiClassObjectAccessExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UClassLiteralExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UClassLiteralExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val type: UType by lz { JavaConverter.convert(psi.type, this) }
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiCodeBlock
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UBlockExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,6 +23,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUCodeBlockExpression(
|
||||
override val psi: PsiCodeBlock,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UBlockExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UBlockExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val expressions by lz { psi.statements.map { JavaConverter.convert(it, this) } }
|
||||
}
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class JavaUCompositeQualifiedExpression(
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UQualifiedExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UQualifiedExpression, PsiElementBacked {
|
||||
override lateinit var receiver: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUInstanceCheckExpression(
|
||||
override val psi: PsiInstanceOfExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
override val type by lz { JavaConverter.convert(psi.checkType?.type, this) }
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiLabeledStatement
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.ULabeledExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaULabeledExpression(
|
||||
override val psi: PsiLabeledStatement,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), ULabeledExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), ULabeledExpression, PsiElementBacked {
|
||||
override val label by lz { psi.labelIdentifier.text }
|
||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.statement, this) }
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import com.intellij.psi.PsiCodeBlock
|
||||
import com.intellij.psi.PsiExpression
|
||||
import com.intellij.psi.PsiLambdaExpression
|
||||
import org.jetbrains.uast.EmptyExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.ULambdaExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -27,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaULambdaExpression(
|
||||
override val psi: PsiLambdaExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), ULambdaExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), ULambdaExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val valueParameters by lz { psi.parameterList.parameters.map { JavaConverter.convert(it, this) } }
|
||||
|
||||
override val body by lz {
|
||||
|
||||
@@ -23,11 +23,11 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaULiteralExpression(
|
||||
override val psi: PsiLiteralExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), ULiteralExpression, PsiElementBacked, JavaTypeHelper {
|
||||
override val text by lz { psi.text }
|
||||
) : JavaAbstractUElement(), ULiteralExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val asString by lz { psi.text }
|
||||
override fun evaluate() = psi.value
|
||||
override val value by lz { evaluate() }
|
||||
|
||||
override val isNull: Boolean
|
||||
get() = text == "null"
|
||||
get() = asString() == "null"
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiNewExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UClassNotResolved
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UObjectLiteralExpression
|
||||
@@ -24,7 +23,7 @@ import org.jetbrains.uast.UObjectLiteralExpression
|
||||
class JavaUObjectLiteralExpression(
|
||||
override val psi: PsiNewExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UObjectLiteralExpression, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UObjectLiteralExpression, JavaUElementWithType {
|
||||
override val declaration by lz {
|
||||
psi.anonymousClass?.let { JavaUClass(it, this, psi) } ?: UClassNotResolved
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,6 +23,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUParenthesizedExpression(
|
||||
override val psi: PsiParenthesizedExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UParenthesizedExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UParenthesizedExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val expression by lz { JavaConverter.convertOrEmpty(psi.expression, this) }
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUPostfixExpression(
|
||||
override val psi: PsiPostfixExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UPostfixExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UPostfixExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
|
||||
override val operator = when (psi.operationSign.text) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUPrefixExpression(
|
||||
override val psi: PsiPrefixExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UPrefixExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UPrefixExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
|
||||
override val operator = when (psi.operationSign.text) {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUQualifiedExpression(
|
||||
override val psi: PsiReferenceExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UQualifiedExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UQualifiedExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val receiver by lz { JavaConverter.convertOrEmpty(psi.qualifierExpression, this) }
|
||||
override val selector by lz { JavaConverter.convert(psi.referenceNameElement, this) as? UExpression ?: EmptyExpression(this) }
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ class JavaUSimpleReferenceExpression(
|
||||
override val psi: PsiElement,
|
||||
override val identifier: String,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override fun resolve(context: UastContext) = psi.reference?.resolve()?.let { context.convert(it) } as? UDeclaration
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class JavaClassUSimpleReferenceExpression(
|
||||
override val identifier: String,
|
||||
val ref: PsiJavaReference,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), USimpleReferenceExpression, PsiElementBacked, NoEvaluate {
|
||||
) : JavaAbstractUElement(), USimpleReferenceExpression, PsiElementBacked {
|
||||
override val psi: PsiElement?
|
||||
get() = ref.element
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiSuperExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.USuperExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,4 +23,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUSuperExpression(
|
||||
override val psi: PsiSuperExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), USuperExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
) : JavaAbstractUElement(), USuperExpression, PsiElementBacked, JavaUElementWithType
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.uast.java
|
||||
|
||||
import com.intellij.psi.PsiThisExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UThisExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -24,4 +23,4 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUThisExpression(
|
||||
override val psi: PsiThisExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UThisExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate
|
||||
) : JavaAbstractUElement(), UThisExpression, PsiElementBacked, JavaUElementWithType
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUTypeCastExpression(
|
||||
override val psi: PsiTypeCastExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val operand by lz { JavaConverter.convertOrEmpty(psi.operand, this) }
|
||||
override val type by lz { JavaConverter.convert(psi.castType?.type, this) }
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class UnknownJavaExpression(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : UExpression, PsiElementBacked, NoEvaluate, LeafUElement {
|
||||
) : UExpression, PsiElementBacked, LeafUElement {
|
||||
override fun logString() = "[!] UnknownJavaExpression ($psi)"
|
||||
}
|
||||
@@ -20,13 +20,13 @@ import com.intellij.psi.PsiExpression
|
||||
import org.jetbrains.uast.UExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
interface JavaEvaluateHelper : UExpression, PsiElementBacked {
|
||||
interface JavaEvaluatableUElement : UExpression, PsiElementBacked {
|
||||
override fun evaluate(): Any? {
|
||||
val psi = this.psi ?: return null
|
||||
return JavaPsiFacade.getInstance(psi.project).constantEvaluationHelper.computeConstantExpression(psi)
|
||||
}
|
||||
}
|
||||
|
||||
interface JavaTypeHelper : UExpression, PsiElementBacked {
|
||||
interface JavaUElementWithType : UExpression, PsiElementBacked {
|
||||
override fun getExpressionType() = (psi as? PsiExpression)?.type?.let { JavaConverter.convert(it, this) }
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class JavaUCallExpression(
|
||||
override val psi: PsiMethodCallExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val kind: UastCallKind
|
||||
get() = UastCallKind.FUNCTION_CALL
|
||||
|
||||
@@ -54,7 +54,7 @@ class JavaUCallExpression(
|
||||
class JavaConstructorUCallExpression(
|
||||
override val psi: PsiNewExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaTypeHelper, NoEvaluate {
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaUElementWithType {
|
||||
override val kind by lz {
|
||||
when {
|
||||
psi.arrayInitializer != null -> JavaUastCallKinds.ARRAY_INITIALIZER
|
||||
@@ -118,7 +118,7 @@ class JavaConstructorUCallExpression(
|
||||
class JavaArrayInitializerUCallExpression(
|
||||
override val psi: PsiArrayInitializerExpression,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val functionReference: USimpleReferenceExpression?
|
||||
get() = null
|
||||
|
||||
@@ -150,7 +150,7 @@ class JavaArrayInitializerUCallExpression(
|
||||
class JavaAnnotationArrayInitializerUCallExpression(
|
||||
override val psi: PsiArrayInitializerMemberValue,
|
||||
override val parent: UElement
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaTypeHelper, JavaEvaluateHelper {
|
||||
) : JavaAbstractUElement(), UCallExpression, PsiElementBacked, JavaUElementWithType, JavaEvaluatableUElement {
|
||||
override val kind = JavaUastCallKinds.ARRAY_INITIALIZER
|
||||
|
||||
override val functionReference: USimpleReferenceExpression?
|
||||
|
||||
@@ -30,6 +30,9 @@ internal fun PsiModifierListOwner.hasModifier(modifier: UastModifier): Boolean {
|
||||
if (modifier == UastModifier.OVERRIDE && this is PsiAnnotationOwner) {
|
||||
return this.annotations.any { it.qualifiedName == "java.lang.Override" }
|
||||
}
|
||||
if (modifier == UastModifier.VARARG && this is PsiParameter) {
|
||||
return this.isVarArgs
|
||||
}
|
||||
val javaModifier = MODIFIER_MAP[modifier] ?: return false
|
||||
return hasModifierProperty(javaModifier)
|
||||
}
|
||||
@@ -43,7 +46,7 @@ internal fun PsiModifierListOwner.getVisibility(): UastVisibility {
|
||||
if (hasModifierProperty(PsiModifier.PUBLIC)) return UastVisibility.PUBLIC
|
||||
if (hasModifierProperty(PsiModifier.PROTECTED)) return UastVisibility.PROTECTED
|
||||
if (hasModifierProperty(PsiModifier.PRIVATE)) return UastVisibility.PRIVATE
|
||||
return JavaUastVisibilities.DEFAULT
|
||||
return JavaUastVisibilities.PACKAGE_LOCAL
|
||||
}
|
||||
|
||||
internal fun IElementType.getOperatorType() = when (this) {
|
||||
@@ -87,4 +90,6 @@ internal inline fun String?.orAnonymous(kind: String = ""): String {
|
||||
|
||||
internal fun <T> runReadAction(action: () -> T): T {
|
||||
return ApplicationManager.getApplication().runReadAction<T>(action)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T> lz(initializer: () -> T) = lazy(LazyThreadSafetyMode.NONE, initializer)
|
||||
@@ -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 kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
internal fun <T> lz(initializer: () -> T): ReadOnlyProperty<Any, T> = UnsafeLazyInsideReadAction(initializer, false)
|
||||
|
||||
private class UnsafeLazyInsideReadAction<out T>(initializer: () -> T, private val readAction: Boolean) : ReadOnlyProperty<Any, T> {
|
||||
private var initializer: (() -> T)? = initializer
|
||||
private var _value: Any? = UNINITIALIZED_VALUE
|
||||
|
||||
override fun getValue(thisRef: Any, property: KProperty<*>): T {
|
||||
if (_value === UNINITIALIZED_VALUE) {
|
||||
if (readAction) {
|
||||
_value = runReadAction { initializer!!() }
|
||||
}
|
||||
else {
|
||||
_value = initializer!!()
|
||||
}
|
||||
initializer = null
|
||||
}
|
||||
return _value as T
|
||||
}
|
||||
}
|
||||
|
||||
private object UNINITIALIZED_VALUE
|
||||
@@ -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.UastModifier
|
||||
|
||||
object JavaUastModifiers {
|
||||
@JvmField
|
||||
val INITIALIZER = UastModifier("static")
|
||||
}
|
||||
@@ -19,8 +19,5 @@ import org.jetbrains.uast.UastVisibility
|
||||
|
||||
object JavaUastVisibilities {
|
||||
@JvmField
|
||||
val DEFAULT = UastVisibility("default")
|
||||
|
||||
@JvmField
|
||||
val INSTANCE = UastVisibility("instance")
|
||||
val PACKAGE_LOCAL = UastVisibility("package_local")
|
||||
}
|
||||
@@ -17,7 +17,11 @@
|
||||
package org.jetbrains.uast.psi
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.uast.UElement
|
||||
|
||||
interface PsiElementBacked {
|
||||
interface PsiElementBacked : UElement {
|
||||
val psi: PsiElement?
|
||||
|
||||
override val isValid: Boolean
|
||||
get() = psi?.isValid ?: true
|
||||
}
|
||||
@@ -35,7 +35,7 @@ object KotlinUastLanguagePlugin : UastLanguagePlugin {
|
||||
}
|
||||
|
||||
internal object KotlinConverter : UastConverter {
|
||||
override fun isFileSupported(path: String) = path.endsWith(".kt", false) || path.endsWith(".kts", false)
|
||||
override fun isFileSupported(name: String) = name.endsWith(".kt", false) || name.endsWith(".kts", false)
|
||||
|
||||
override fun convert(element: Any?, parent: UElement): UElement? {
|
||||
if (element !is KtElement) return null
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ class KotlinDumbUElement(
|
||||
override val psi: PsiElement?,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UElement, PsiElementBacked, LeafUElement {
|
||||
override fun logString() = "KotlinPsiElementStub"
|
||||
override fun logString() = "KotlinDumbUElement"
|
||||
override fun renderString() = "<stub@$psi>"
|
||||
}
|
||||
@@ -134,10 +134,10 @@ class KotlinUClass(
|
||||
|
||||
override val visibility by lz { psi.getVisibility() }
|
||||
|
||||
override fun isSubclassOf(name: String): Boolean {
|
||||
override fun isSubclassOf(fqName: String): Boolean {
|
||||
val descriptor = psi.resolveToDescriptorIfAny() as? ClassDescriptor ?: return false
|
||||
return descriptor.defaultType.supertypes().any {
|
||||
it.constructor.declarationDescriptor?.fqNameSafe?.asString() == name
|
||||
it.constructor.declarationDescriptor?.fqNameSafe?.asString() == fqName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,8 @@ import org.jetbrains.uast.UFile
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class KotlinUFile(override val psi: KtFile): KotlinAbstractUElement(), UFile, PsiElementBacked {
|
||||
override val packageFqName by lz {
|
||||
val packageName = psi.packageFqName.asString()
|
||||
if (packageName.isNotBlank()) packageName else null
|
||||
}
|
||||
override val packageFqName: String?
|
||||
get() = psi.packageFqName.asString()
|
||||
|
||||
override val declarations by lz { psi.declarations.map { KotlinConverter.convert(it, this) }.filterNotNull() }
|
||||
override val importStatements by lz { psi.importDirectives.map { KotlinUImportStatement(it, this) } }
|
||||
|
||||
+5
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.uast
|
||||
import org.jetbrains.kotlin.psi.KtImportDirective
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UImportStatement
|
||||
import org.jetbrains.uast.UastContext
|
||||
import org.jetbrains.uast.kinds.UastImportKind
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
@@ -30,8 +31,11 @@ class KotlinUImportStatement(
|
||||
|
||||
//TODO support member imports
|
||||
override val kind: UastImportKind
|
||||
get() = UastImportKind.CLASS
|
||||
get() = UastImportKind.UNKNOWN
|
||||
|
||||
override val isStarImport: Boolean
|
||||
get() = psi.isAllUnder
|
||||
|
||||
//TODO support
|
||||
override fun resolve(context: UastContext) = null
|
||||
}
|
||||
@@ -42,6 +42,14 @@ open class KotlinUVariable(
|
||||
KotlinConverter.convert(type, psi.project, this)
|
||||
}
|
||||
|
||||
override val getters: List<UFunction>? by lz {
|
||||
(psi as? KtProperty)?.accessors?.filter { it.isGetter }?.map { VariableAccessorFunction(it, this) }
|
||||
}
|
||||
|
||||
override val setters: List<UFunction>? by lz {
|
||||
(psi as? KtProperty)?.accessors?.filter { it.isSetter }?.map { VariableAccessorFunction(it, this) }
|
||||
}
|
||||
|
||||
override val kind: UastVariableKind
|
||||
get() = when (psi.parent) {
|
||||
is KtClassBody -> UastVariableKind.MEMBER
|
||||
@@ -49,8 +57,58 @@ open class KotlinUVariable(
|
||||
else -> UastVariableKind.LOCAL_VARIABLE
|
||||
}
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = psi.getVisibility()
|
||||
|
||||
override fun hasModifier(modifier: UastModifier) = psi.hasModifier(modifier)
|
||||
override val annotations by lz { psi.getUastAnnotations(this) }
|
||||
|
||||
private class VariableAccessorFunction(
|
||||
override val psi: KtPropertyAccessor,
|
||||
override val parent: UVariable
|
||||
) : KotlinAbstractUElement(), UFunction, PsiElementBacked {
|
||||
override val kind: UastFunctionKind
|
||||
get() = if (psi.isGetter)
|
||||
UastFunctionKind.GETTER
|
||||
else if (psi.isSetter)
|
||||
UastFunctionKind.SETTER
|
||||
else
|
||||
UastFunctionKind.FUNCTION
|
||||
|
||||
override val valueParameters by lz { psi.valueParameters.map { KotlinConverter.convert(it, this) } }
|
||||
|
||||
override val valueParameterCount: Int
|
||||
get() = psi.valueParameters.size
|
||||
|
||||
override val typeParameters: List<UTypeReference>
|
||||
get() = emptyList()
|
||||
override val typeParameterCount: Int
|
||||
get() = 0
|
||||
|
||||
override val returnType: UType?
|
||||
get() = if (psi.isSetter) null else parent.type
|
||||
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = psi.getVisibility()
|
||||
|
||||
override fun getSuperFunctions(context: UastContext): List<UFunction> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override val nameElement: UElement?
|
||||
get() = throw UnsupportedOperationException()
|
||||
override val name: String
|
||||
get() = throw UnsupportedOperationException()
|
||||
|
||||
override fun hasModifier(modifier: UastModifier): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override val annotations: List<UAnnotation>
|
||||
get() = throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinDestructuredUVariable(
|
||||
@@ -66,6 +124,9 @@ class KotlinDestructuredUVariable(
|
||||
val returnType = resolvedCall.resultingDescriptor.returnType ?: return@lz UastErrorType
|
||||
KotlinConverter.convert(returnType, entry.project, this)
|
||||
}
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = UastVisibility.LOCAL
|
||||
}
|
||||
|
||||
class KotlinDestructuringUVariable(
|
||||
@@ -81,6 +142,9 @@ class KotlinDestructuringUVariable(
|
||||
override val nameElement = null
|
||||
override fun hasModifier(modifier: UastModifier) = false
|
||||
override val annotations = emptyList<UAnnotation>()
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = UastVisibility.LOCAL
|
||||
}
|
||||
|
||||
class KotlinParameterUVariable(
|
||||
@@ -102,6 +166,9 @@ class KotlinParameterUVariable(
|
||||
KotlinConverter.convert(param.type, psi.project, this)
|
||||
}
|
||||
|
||||
override val visibility: UastVisibility
|
||||
get() = UastVisibility.LOCAL
|
||||
|
||||
override fun hasModifier(modifier: UastModifier) = psi.hasModifier(modifier)
|
||||
override val annotations = psi.getUastAnnotations(this)
|
||||
}
|
||||
@@ -211,6 +211,8 @@ open class KotlinObjectLiteralConstructorUFunction(
|
||||
get() = this@KotlinObjectLiteralConstructorUFunction
|
||||
override val name: String
|
||||
get() = param.name.asString()
|
||||
override val visibility: UastVisibility
|
||||
get() = UastVisibility.LOCAL
|
||||
|
||||
override fun hasModifier(modifier: UastModifier) = when(modifier) {
|
||||
UastModifier.VARARG -> param.varargElementType != null
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinStringTemplateUBinaryExpression(
|
||||
override val psi: KtStringTemplateExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override lateinit var leftOperand: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUArrayAccessExpression(
|
||||
override val psi: KtArrayAccessExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UArrayAccessExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UArrayAccessExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.arrayExpression, this) }
|
||||
override val indices by lz { psi.indexExpressions.map { KotlinConverter.convert(it, this) } }
|
||||
}
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUBinaryExpression(
|
||||
override val psi: KtBinaryExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val leftOperand by lz { KotlinConverter.convertOrEmpty(psi.left, this) }
|
||||
override val rightOperand by lz { KotlinConverter.convertOrEmpty(psi.right, this) }
|
||||
|
||||
@@ -63,7 +63,7 @@ class KotlinUBinaryExpression(
|
||||
class KotlinCustomUBinaryExpression(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UBinaryExpression, PsiElementBacked {
|
||||
lateinit override var leftOperand: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUBinaryExpressionWithType(
|
||||
override val psi: KtBinaryExpressionWithTypeRHS,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val operand by lz { KotlinConverter.convert(psi.left, this) }
|
||||
override val type by lz { KotlinConverter.convert(psi.right, this) }
|
||||
override val operationKind = when (psi.operationReference.getReferencedNameElementType()) {
|
||||
@@ -38,7 +38,7 @@ class KotlinUBinaryExpressionWithType(
|
||||
class KotlinCustomUBinaryExpressionWithType(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UBinaryExpressionWithType, PsiElementBacked {
|
||||
lateinit override var operand: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtBlockExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UBlockExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -25,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUBlockExpression(
|
||||
override val psi: KtBlockExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UBlockExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UBlockExpression, PsiElementBacked, KotlinUElementWithType {
|
||||
override val expressions by lz { psi.statements.map { KotlinConverter.convertOrEmpty(it, this) } }
|
||||
}
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtClassLiteralExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UClassLiteralExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -25,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUClassLiteralExpression(
|
||||
override val psi: KtClassLiteralExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UClassLiteralExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UClassLiteralExpression, PsiElementBacked, KotlinUElementWithType {
|
||||
override val type by lz { KotlinConverter.convert(psi.typeReference, this) }
|
||||
}
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtDoWhileExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UDoWhileExpression
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -25,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUDoWhileExpression(
|
||||
override val psi: KtDoWhileExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UDoWhileExpression, PsiElementBacked, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UDoWhileExpression, PsiElementBacked {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.uast.UExpression
|
||||
import org.jetbrains.uast.UType
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
interface KotlinTypeHelper : UExpression, PsiElementBacked {
|
||||
interface KotlinUElementWithType : UExpression, PsiElementBacked {
|
||||
override fun getExpressionType(): UType? {
|
||||
val ktElement = psi as? KtExpression ?: return null
|
||||
val ktType = ktElement.analyze(BodyResolveMode.PARTIAL)[BindingContext.EXPECTED_EXPRESSION_TYPE, ktElement] ?: return null
|
||||
@@ -33,7 +33,7 @@ interface KotlinTypeHelper : UExpression, PsiElementBacked {
|
||||
}
|
||||
}
|
||||
|
||||
interface KotlinEvaluateHelper : UExpression, PsiElementBacked {
|
||||
interface KotlinEvaluatableUElement : UExpression, PsiElementBacked {
|
||||
override fun evaluate(): Any? {
|
||||
val ktElement = psi as? KtExpression ?: return null
|
||||
val compileTimeConst = ktElement.analyze(BodyResolveMode.PARTIAL)[BindingContext.COMPILE_TIME_VALUE, ktElement]
|
||||
|
||||
+3
-5
@@ -17,16 +17,14 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtForExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UForEachExpression
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
|
||||
class KotlinUForEachExpression(
|
||||
override val psi: KtForExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UForEachExpression, PsiElementBacked, NoEvaluate {
|
||||
override val variableName by lz { psi.loopParameter?.name }
|
||||
) : KotlinAbstractUElement(), UForEachExpression, PsiElementBacked {
|
||||
override val variable by lz { psi.loopParameter?.let { KotlinConverter.convert(it, this) } ?: UVariableNotResolved }
|
||||
override val iteratedValue by lz { KotlinConverter.convertOrEmpty(psi.loopRange, this) }
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.body, this) }
|
||||
}
|
||||
+4
-4
@@ -30,7 +30,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUFunctionCallExpression(
|
||||
override val psi: KtCallExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UCallExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), UCallExpression, PsiElementBacked, KotlinUElementWithType {
|
||||
override val functionName: String?
|
||||
get() = (psi.calleeExpression as? KtSimpleNameExpression)?.getReferencedName()
|
||||
|
||||
@@ -84,7 +84,7 @@ class KotlinUComponentFunctionCallExpression(
|
||||
override val psi: PsiElement,
|
||||
val n: Int,
|
||||
override val parent: UElement
|
||||
) : UCallExpression, PsiElementBacked, NoEvaluate {
|
||||
) : UCallExpression, PsiElementBacked {
|
||||
override val valueArgumentCount = 0
|
||||
override val valueArguments = emptyList<UExpression>()
|
||||
override val typeArgumentCount = 0
|
||||
@@ -101,13 +101,13 @@ class KotlinUSuperConstructorCallExpression(
|
||||
override val psi: KtObjectDeclaration,
|
||||
override val parent: UElement,
|
||||
val resolvedCall: () -> ResolvedCall<*>?
|
||||
) : UCallExpression, PsiElementBacked, NoEvaluate {
|
||||
) : UCallExpression, PsiElementBacked {
|
||||
override val functionReference: USimpleReferenceExpression?
|
||||
get() = null
|
||||
|
||||
override val classReference: USimpleReferenceExpression by lz {
|
||||
val referenceParent = this
|
||||
object : USimpleReferenceExpression, PsiElementBacked, NoEvaluate {
|
||||
object : USimpleReferenceExpression, PsiElementBacked {
|
||||
override val parent: UElement?
|
||||
get() = referenceParent
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUIfExpression(
|
||||
override val psi: KtIfExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UIfExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UIfExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val condition by lz { KotlinConverter.convertOrEmpty(psi.condition, this) }
|
||||
override val thenBranch by lz { KotlinConverter.convertOrNull(psi.then, this) }
|
||||
override val elseBranch by lz { KotlinConverter.convertOrNull(psi.`else`, this) }
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinULambdaExpression(
|
||||
override val psi: KtLambdaExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), ULambdaExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : KotlinAbstractUElement(), ULambdaExpression, PsiElementBacked, KotlinUElementWithType {
|
||||
override val body by lz { KotlinConverter.convertOrEmpty(psi.bodyExpression, this) }
|
||||
override val valueParameters by lz { psi.valueParameters.map { KotlinConverter.convert(it, this) } }
|
||||
override fun renderString(): String {
|
||||
|
||||
+4
-5
@@ -26,12 +26,11 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinULiteralExpression(
|
||||
override val psi: KtConstantExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val isNull: Boolean
|
||||
get() = psi.isNullExpression()
|
||||
|
||||
override val text: String
|
||||
get() = psi.text
|
||||
override fun asString(): String = psi.text
|
||||
|
||||
override val value by lz { evaluate() }
|
||||
}
|
||||
@@ -39,9 +38,9 @@ class KotlinULiteralExpression(
|
||||
class KotlinStringULiteralExpression(
|
||||
override val psi: PsiElement,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), ULiteralExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val isNull = false
|
||||
override val text: String
|
||||
override val asString: String
|
||||
get() = '"' + psi.text + '"'
|
||||
|
||||
override val value: String
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.uast
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||
import org.jetbrains.uast.NoEvaluate
|
||||
import org.jetbrains.uast.UElement
|
||||
import org.jetbrains.uast.UObjectLiteralExpression
|
||||
import org.jetbrains.uast.psi.PsiElementBacked
|
||||
@@ -25,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUObjectLiteralExpression(
|
||||
override val psi: KtObjectLiteralExpression,
|
||||
override val parent: UElement
|
||||
) : UObjectLiteralExpression, PsiElementBacked, KotlinTypeHelper, NoEvaluate {
|
||||
) : UObjectLiteralExpression, PsiElementBacked, KotlinUElementWithType {
|
||||
override val declaration by lz { KotlinUClass(psi.objectDeclaration, this, true) }
|
||||
}
|
||||
+1
-1
@@ -24,6 +24,6 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUParenthesizedExpression(
|
||||
override val psi: KtParenthesizedExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UParenthesizedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UParenthesizedExpression, PsiElementBacked, KotlinUElementWithType {
|
||||
override val expression by lz { KotlinConverter.convertOrEmpty(psi.expression, this) }
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUPostfixExpression(
|
||||
override val psi: KtPostfixExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UPostfixExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UPostfixExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||
|
||||
override val operator = when (psi.operationToken) {
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUPrefixExpression(
|
||||
override val psi: KtPrefixExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UPrefixExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UPrefixExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val operand by lz { KotlinConverter.convertOrEmpty(psi.baseExpression, this) }
|
||||
|
||||
override val operator = when (psi.operationToken) {
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUQualifiedExpression(
|
||||
override val psi: KtDotQualifiedExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||
override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) }
|
||||
override val accessType = UastQualifiedExpressionAccessType.SIMPLE
|
||||
@@ -35,7 +35,7 @@ class KotlinUQualifiedExpression(
|
||||
class KotlinUComponentQualifiedExpression(
|
||||
override val psi: KtDestructuringDeclarationEntry,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override lateinit var receiver: UExpression
|
||||
internal set
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.uast.psi.PsiElementBacked
|
||||
class KotlinUSafeQualifiedExpression(
|
||||
override val psi: KtSafeQualifiedExpression,
|
||||
override val parent: UElement
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinTypeHelper, KotlinEvaluateHelper {
|
||||
) : KotlinAbstractUElement(), UQualifiedExpression, PsiElementBacked, KotlinUElementWithType, KotlinEvaluatableUElement {
|
||||
override val receiver by lz { KotlinConverter.convertOrEmpty(psi.receiverExpression, this) }
|
||||
override val selector by lz { KotlinConverter.convertOrEmpty(psi.selectorExpression, this) }
|
||||
override val accessType = KotlinQualifiedExpressionAccessTypes.SAFE
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user