From 4963f53e03b84920c4b33bac7a2bdea168b99c63 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 10 Apr 2017 14:35:58 +0200 Subject: [PATCH] Add missing UAST testdata --- uast/uast-tests/java/DataClass/DataClass.java | 61 +++++ .../java/DataClass/DataClass.log.txt | 221 ++++++++++++++++++ .../java/DataClass/DataClass.render.txt | 33 +++ .../uast-tests/java/Simple/AliveThenElse.java | 29 +++ .../java/Simple/AliveThenElse.values.txt | 25 ++ uast/uast-tests/java/Simple/Anonymous.java | 31 +++ .../java/Simple/Anonymous.values.txt | 24 ++ uast/uast-tests/java/Simple/Bitwise.java | 30 +++ .../uast-tests/java/Simple/Bitwise.values.txt | 46 ++++ uast/uast-tests/java/Simple/ByteShort.java | 29 +++ .../java/Simple/ByteShort.values.txt | 46 ++++ uast/uast-tests/java/Simple/CascadeIf.java | 37 +++ .../java/Simple/CascadeIf.values.txt | 45 ++++ uast/uast-tests/java/Simple/Characters.java | 27 +++ .../java/Simple/Characters.values.txt | 48 ++++ uast/uast-tests/java/Simple/ClassLiteral.java | 20 ++ .../java/Simple/ClassLiteral.values.txt | 9 + uast/uast-tests/java/Simple/DeadElse.java | 30 +++ .../java/Simple/DeadElse.values.txt | 27 +++ uast/uast-tests/java/Simple/DeadFor.java | 24 ++ .../uast-tests/java/Simple/DeadFor.values.txt | 24 ++ .../java/Simple/DeadIfComparison.java | 29 +++ .../java/Simple/DeadIfComparison.values.txt | 26 +++ .../java/Simple/DeadSwitchEntries.java | 40 ++++ .../java/Simple/DeadSwitchEntries.values.txt | 48 ++++ .../DeadSwitchEntriesWithoutBreaks.java | 38 +++ .../DeadSwitchEntriesWithoutBreaks.values.txt | 46 ++++ uast/uast-tests/java/Simple/DeadThen.java | 30 +++ .../java/Simple/DeadThen.values.txt | 28 +++ uast/uast-tests/java/Simple/Dependents.java | 24 ++ .../java/Simple/Dependents.values.txt | 18 ++ uast/uast-tests/java/Simple/DoWhile.java | 28 +++ .../uast-tests/java/Simple/DoWhile.values.txt | 32 +++ .../java/Simple/DoWhileInfinite.java | 27 +++ .../java/Simple/DoWhileInfinite.values.txt | 27 +++ .../java/Simple/DoWhileWithReturn.java | 27 +++ .../java/Simple/DoWhileWithReturn.values.txt | 28 +++ uast/uast-tests/java/Simple/EnumChoice.java | 30 +++ .../java/Simple/EnumChoice.values.txt | 23 ++ uast/uast-tests/java/Simple/EnumSwitch.java | 39 ++++ .../uast-tests/java/Simple/EnumSwitch.log.txt | 46 ++++ .../java/Simple/EnumSwitch.render.txt | 31 +++ .../java/Simple/EnumSwitch.values.txt | 46 ++++ .../Simple/EnumSwitchConditionalBreak.java | 39 ++++ .../EnumSwitchConditionalBreak.values.txt | 50 ++++ .../java/Simple/EnumSwitchWithoutBreaks.java | 37 +++ .../Simple/EnumSwitchWithoutBreaks.values.txt | 44 ++++ .../java/Simple/EnumValueMembers.java | 31 +++ .../java/Simple/EnumValueMembers.log.txt | 18 ++ .../java/Simple/EnumValueMembers.render.txt | 13 ++ .../java/Simple/EvaluatorExtension.java | 23 ++ .../java/Simple/EvaluatorExtension.values.txt | 16 ++ uast/uast-tests/java/Simple/External.java | 27 +++ .../java/Simple/External.values.txt | 21 ++ uast/uast-tests/java/Simple/Field.java | 18 ++ uast/uast-tests/java/Simple/FieldRef.java | 21 ++ .../java/Simple/FieldRef.values.txt | 16 ++ uast/uast-tests/java/Simple/FloatDouble.java | 26 +++ .../java/Simple/FloatDouble.values.txt | 36 +++ uast/uast-tests/java/Simple/For.java | 24 ++ uast/uast-tests/java/Simple/For.values.txt | 24 ++ uast/uast-tests/java/Simple/ForEach.java | 24 ++ .../uast-tests/java/Simple/ForEach.values.txt | 18 ++ .../java/Simple/ForEachMutableIterable.java | 38 +++ .../Simple/ForEachMutableIterable.values.txt | 60 +++++ .../java/Simple/IdentityEquals.java | 31 +++ .../java/Simple/IdentityEquals.values.txt | 41 ++++ .../java/Simple/ImmutableField.java | 28 +++ .../java/Simple/ImmutableField.values.txt | 19 ++ uast/uast-tests/java/Simple/IncDec.java | 25 ++ uast/uast-tests/java/Simple/IncDec.values.txt | 27 +++ uast/uast-tests/java/Simple/IntLong.java | 34 +++ .../uast-tests/java/Simple/IntLong.values.txt | 73 ++++++ uast/uast-tests/java/Simple/Labeled.java | 28 +++ .../uast-tests/java/Simple/Labeled.values.txt | 25 ++ uast/uast-tests/java/Simple/LabeledOuter.java | 30 +++ .../java/Simple/LabeledOuter.values.txt | 37 +++ uast/uast-tests/java/Simple/Lambda.java | 28 +++ uast/uast-tests/java/Simple/Lambda.values.txt | 22 ++ uast/uast-tests/java/Simple/LocalClass.java | 23 ++ .../uast-tests/java/Simple/LocalClass.log.txt | 13 ++ .../java/Simple/LocalClass.render.txt | 8 + uast/uast-tests/java/Simple/Logicals.java | 28 +++ .../java/Simple/Logicals.values.txt | 55 +++++ .../java/Simple/MethodReference.java | 32 +++ .../java/Simple/MethodReference.values.txt | 24 ++ uast/uast-tests/java/Simple/Modification.java | 27 +++ .../java/Simple/Modification.values.txt | 35 +++ uast/uast-tests/java/Simple/MutableField.java | 28 +++ .../java/Simple/MutableField.values.txt | 18 ++ uast/uast-tests/java/Simple/NotANumber.java | 38 +++ .../java/Simple/NotANumber.values.txt | 94 ++++++++ .../Simple/ParamViaEvaluatorExtension.java | 20 ++ .../ParamViaEvaluatorExtension.values.txt | 10 + .../java/Simple/QualifiedConstructorCall.java | 26 +++ .../Simple/QualifiedConstructorCall.log.txt | 14 ++ .../QualifiedConstructorCall.render.txt | 10 + uast/uast-tests/java/Simple/ReturnMinusX.java | 21 ++ .../java/Simple/ReturnMinusX.values.txt | 10 + uast/uast-tests/java/Simple/ReturnSum.java | 23 ++ .../java/Simple/ReturnSum.values.txt | 23 ++ uast/uast-tests/java/Simple/ReturnX.java | 21 ++ uast/uast-tests/java/Simple/ReturnX.log.txt | 9 + .../uast-tests/java/Simple/ReturnX.render.txt | 6 + .../uast-tests/java/Simple/ReturnX.values.txt | 9 + uast/uast-tests/java/Simple/Shift.java | 38 +++ uast/uast-tests/java/Simple/Shift.values.txt | 68 ++++++ uast/uast-tests/java/Simple/Simple.java | 17 ++ uast/uast-tests/java/Simple/Simple.log.txt | 2 + uast/uast-tests/java/Simple/Simple.render.txt | 2 + uast/uast-tests/java/Simple/Strings.java | 25 ++ .../uast-tests/java/Simple/Strings.values.txt | 27 +++ uast/uast-tests/java/Simple/SuperTypes.java | 26 +++ .../uast-tests/java/Simple/SuperTypes.log.txt | 4 + .../java/Simple/SuperTypes.render.txt | 8 + uast/uast-tests/java/Simple/Ternary.java | 20 ++ .../uast-tests/java/Simple/Ternary.values.txt | 10 + uast/uast-tests/java/Simple/TryCatch.java | 32 +++ .../java/Simple/TryCatch.values.txt | 42 ++++ .../java/Simple/TryWithResources.java | 23 ++ .../java/Simple/TryWithResources.log.txt | 17 ++ .../java/Simple/TryWithResources.render.txt | 8 + .../uast-tests/java/Simple/TypeReference.java | 21 ++ uast/uast-tests/java/Simple/While.java | 24 ++ uast/uast-tests/java/Simple/While.values.txt | 22 ++ .../java/Simple/WhileWithContinue.java | 48 ++++ .../java/Simple/WhileWithContinue.values.txt | 60 +++++ .../java/Simple/WhileWithIncrement.java | 25 ++ .../java/Simple/WhileWithIncrement.values.txt | 22 ++ .../Simple/WhileWithMutableCondition.java | 24 ++ .../WhileWithMutableCondition.values.txt | 17 ++ .../java/Simple/WhileWithReturn.java | 28 +++ .../java/Simple/WhileWithReturn.values.txt | 27 +++ 133 files changed, 3961 insertions(+) create mode 100644 uast/uast-tests/java/DataClass/DataClass.java create mode 100644 uast/uast-tests/java/DataClass/DataClass.log.txt create mode 100644 uast/uast-tests/java/DataClass/DataClass.render.txt create mode 100644 uast/uast-tests/java/Simple/AliveThenElse.java create mode 100644 uast/uast-tests/java/Simple/AliveThenElse.values.txt create mode 100644 uast/uast-tests/java/Simple/Anonymous.java create mode 100644 uast/uast-tests/java/Simple/Anonymous.values.txt create mode 100644 uast/uast-tests/java/Simple/Bitwise.java create mode 100644 uast/uast-tests/java/Simple/Bitwise.values.txt create mode 100644 uast/uast-tests/java/Simple/ByteShort.java create mode 100644 uast/uast-tests/java/Simple/ByteShort.values.txt create mode 100644 uast/uast-tests/java/Simple/CascadeIf.java create mode 100644 uast/uast-tests/java/Simple/CascadeIf.values.txt create mode 100644 uast/uast-tests/java/Simple/Characters.java create mode 100644 uast/uast-tests/java/Simple/Characters.values.txt create mode 100644 uast/uast-tests/java/Simple/ClassLiteral.java create mode 100644 uast/uast-tests/java/Simple/ClassLiteral.values.txt create mode 100644 uast/uast-tests/java/Simple/DeadElse.java create mode 100644 uast/uast-tests/java/Simple/DeadElse.values.txt create mode 100644 uast/uast-tests/java/Simple/DeadFor.java create mode 100644 uast/uast-tests/java/Simple/DeadFor.values.txt create mode 100644 uast/uast-tests/java/Simple/DeadIfComparison.java create mode 100644 uast/uast-tests/java/Simple/DeadIfComparison.values.txt create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntries.java create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java create mode 100644 uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt create mode 100644 uast/uast-tests/java/Simple/DeadThen.java create mode 100644 uast/uast-tests/java/Simple/DeadThen.values.txt create mode 100644 uast/uast-tests/java/Simple/Dependents.java create mode 100644 uast/uast-tests/java/Simple/Dependents.values.txt create mode 100644 uast/uast-tests/java/Simple/DoWhile.java create mode 100644 uast/uast-tests/java/Simple/DoWhile.values.txt create mode 100644 uast/uast-tests/java/Simple/DoWhileInfinite.java create mode 100644 uast/uast-tests/java/Simple/DoWhileInfinite.values.txt create mode 100644 uast/uast-tests/java/Simple/DoWhileWithReturn.java create mode 100644 uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt create mode 100644 uast/uast-tests/java/Simple/EnumChoice.java create mode 100644 uast/uast-tests/java/Simple/EnumChoice.values.txt create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.java create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.log.txt create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.render.txt create mode 100644 uast/uast-tests/java/Simple/EnumSwitch.values.txt create mode 100644 uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java create mode 100644 uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt create mode 100644 uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java create mode 100644 uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt create mode 100644 uast/uast-tests/java/Simple/EnumValueMembers.java create mode 100644 uast/uast-tests/java/Simple/EnumValueMembers.log.txt create mode 100644 uast/uast-tests/java/Simple/EnumValueMembers.render.txt create mode 100644 uast/uast-tests/java/Simple/EvaluatorExtension.java create mode 100644 uast/uast-tests/java/Simple/EvaluatorExtension.values.txt create mode 100644 uast/uast-tests/java/Simple/External.java create mode 100644 uast/uast-tests/java/Simple/External.values.txt create mode 100644 uast/uast-tests/java/Simple/Field.java create mode 100644 uast/uast-tests/java/Simple/FieldRef.java create mode 100644 uast/uast-tests/java/Simple/FieldRef.values.txt create mode 100644 uast/uast-tests/java/Simple/FloatDouble.java create mode 100644 uast/uast-tests/java/Simple/FloatDouble.values.txt create mode 100644 uast/uast-tests/java/Simple/For.java create mode 100644 uast/uast-tests/java/Simple/For.values.txt create mode 100644 uast/uast-tests/java/Simple/ForEach.java create mode 100644 uast/uast-tests/java/Simple/ForEach.values.txt create mode 100644 uast/uast-tests/java/Simple/ForEachMutableIterable.java create mode 100644 uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt create mode 100644 uast/uast-tests/java/Simple/IdentityEquals.java create mode 100644 uast/uast-tests/java/Simple/IdentityEquals.values.txt create mode 100644 uast/uast-tests/java/Simple/ImmutableField.java create mode 100644 uast/uast-tests/java/Simple/ImmutableField.values.txt create mode 100644 uast/uast-tests/java/Simple/IncDec.java create mode 100644 uast/uast-tests/java/Simple/IncDec.values.txt create mode 100644 uast/uast-tests/java/Simple/IntLong.java create mode 100644 uast/uast-tests/java/Simple/IntLong.values.txt create mode 100644 uast/uast-tests/java/Simple/Labeled.java create mode 100644 uast/uast-tests/java/Simple/Labeled.values.txt create mode 100644 uast/uast-tests/java/Simple/LabeledOuter.java create mode 100644 uast/uast-tests/java/Simple/LabeledOuter.values.txt create mode 100644 uast/uast-tests/java/Simple/Lambda.java create mode 100644 uast/uast-tests/java/Simple/Lambda.values.txt create mode 100644 uast/uast-tests/java/Simple/LocalClass.java create mode 100644 uast/uast-tests/java/Simple/LocalClass.log.txt create mode 100644 uast/uast-tests/java/Simple/LocalClass.render.txt create mode 100644 uast/uast-tests/java/Simple/Logicals.java create mode 100644 uast/uast-tests/java/Simple/Logicals.values.txt create mode 100644 uast/uast-tests/java/Simple/MethodReference.java create mode 100644 uast/uast-tests/java/Simple/MethodReference.values.txt create mode 100644 uast/uast-tests/java/Simple/Modification.java create mode 100644 uast/uast-tests/java/Simple/Modification.values.txt create mode 100644 uast/uast-tests/java/Simple/MutableField.java create mode 100644 uast/uast-tests/java/Simple/MutableField.values.txt create mode 100644 uast/uast-tests/java/Simple/NotANumber.java create mode 100644 uast/uast-tests/java/Simple/NotANumber.values.txt create mode 100644 uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java create mode 100644 uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt create mode 100644 uast/uast-tests/java/Simple/QualifiedConstructorCall.java create mode 100644 uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt create mode 100644 uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt create mode 100644 uast/uast-tests/java/Simple/ReturnMinusX.java create mode 100644 uast/uast-tests/java/Simple/ReturnMinusX.values.txt create mode 100644 uast/uast-tests/java/Simple/ReturnSum.java create mode 100644 uast/uast-tests/java/Simple/ReturnSum.values.txt create mode 100644 uast/uast-tests/java/Simple/ReturnX.java create mode 100644 uast/uast-tests/java/Simple/ReturnX.log.txt create mode 100644 uast/uast-tests/java/Simple/ReturnX.render.txt create mode 100644 uast/uast-tests/java/Simple/ReturnX.values.txt create mode 100644 uast/uast-tests/java/Simple/Shift.java create mode 100644 uast/uast-tests/java/Simple/Shift.values.txt create mode 100644 uast/uast-tests/java/Simple/Simple.java create mode 100644 uast/uast-tests/java/Simple/Simple.log.txt create mode 100644 uast/uast-tests/java/Simple/Simple.render.txt create mode 100644 uast/uast-tests/java/Simple/Strings.java create mode 100644 uast/uast-tests/java/Simple/Strings.values.txt create mode 100644 uast/uast-tests/java/Simple/SuperTypes.java create mode 100644 uast/uast-tests/java/Simple/SuperTypes.log.txt create mode 100644 uast/uast-tests/java/Simple/SuperTypes.render.txt create mode 100644 uast/uast-tests/java/Simple/Ternary.java create mode 100644 uast/uast-tests/java/Simple/Ternary.values.txt create mode 100644 uast/uast-tests/java/Simple/TryCatch.java create mode 100644 uast/uast-tests/java/Simple/TryCatch.values.txt create mode 100644 uast/uast-tests/java/Simple/TryWithResources.java create mode 100644 uast/uast-tests/java/Simple/TryWithResources.log.txt create mode 100644 uast/uast-tests/java/Simple/TryWithResources.render.txt create mode 100644 uast/uast-tests/java/Simple/TypeReference.java create mode 100644 uast/uast-tests/java/Simple/While.java create mode 100644 uast/uast-tests/java/Simple/While.values.txt create mode 100644 uast/uast-tests/java/Simple/WhileWithContinue.java create mode 100644 uast/uast-tests/java/Simple/WhileWithContinue.values.txt create mode 100644 uast/uast-tests/java/Simple/WhileWithIncrement.java create mode 100644 uast/uast-tests/java/Simple/WhileWithIncrement.values.txt create mode 100644 uast/uast-tests/java/Simple/WhileWithMutableCondition.java create mode 100644 uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt create mode 100644 uast/uast-tests/java/Simple/WhileWithReturn.java create mode 100644 uast/uast-tests/java/Simple/WhileWithReturn.values.txt diff --git a/uast/uast-tests/java/DataClass/DataClass.java b/uast/uast-tests/java/DataClass/DataClass.java new file mode 100644 index 000000000000..e476d0c3e83a --- /dev/null +++ b/uast/uast-tests/java/DataClass/DataClass.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2017 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. + */ +public class DataClass { + public final String STRING_CONSTANT = "ABC"; + + private final String firstName; + private final String lastName; + private final String age; + + public DataClass(String firstName, String lastName, String age) { + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + } + + @Override + public String toString() { + return "DataClass{" + + "STRING_CONSTANT='" + STRING_CONSTANT + '\'' + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", age='" + age + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + DataClass dataClass = (DataClass) o; + + if (STRING_CONSTANT != null ? !STRING_CONSTANT.equals(dataClass.STRING_CONSTANT) : dataClass.STRING_CONSTANT != null) + return false; + if (firstName != null ? !firstName.equals(dataClass.firstName) : dataClass.firstName != null) return false; + if (lastName != null ? !lastName.equals(dataClass.lastName) : dataClass.lastName != null) return false; + return age != null ? age.equals(dataClass.age) : dataClass.age == null; + } + + @Override + public int hashCode() { + int result = STRING_CONSTANT != null ? STRING_CONSTANT.hashCode() : 0; + result = 31 * result + (firstName != null ? firstName.hashCode() : 0); + result = 31 * result + (lastName != null ? lastName.hashCode() : 0); + result = 31 * result + (age != null ? age.hashCode() : 0); + return result; + } +} diff --git a/uast/uast-tests/java/DataClass/DataClass.log.txt b/uast/uast-tests/java/DataClass/DataClass.log.txt new file mode 100644 index 000000000000..e75078c3cbb9 --- /dev/null +++ b/uast/uast-tests/java/DataClass/DataClass.log.txt @@ -0,0 +1,221 @@ +UFile (package = ) + UClass (name = DataClass) + UField (name = STRING_CONSTANT) + ULiteralExpression (value = "ABC") + UField (name = firstName) + UField (name = lastName) + UField (name = age) + UMethod (name = DataClass) + UParameter (name = firstName) + UParameter (name = lastName) + UParameter (name = age) + UBlockExpression + UBinaryExpression (operator = =) + UQualifiedReferenceExpression + UThisExpression (label = null) + USimpleNameReferenceExpression (identifier = firstName) + USimpleNameReferenceExpression (identifier = firstName) + UBinaryExpression (operator = =) + UQualifiedReferenceExpression + UThisExpression (label = null) + USimpleNameReferenceExpression (identifier = lastName) + USimpleNameReferenceExpression (identifier = lastName) + UBinaryExpression (operator = =) + UQualifiedReferenceExpression + UThisExpression (label = null) + USimpleNameReferenceExpression (identifier = age) + USimpleNameReferenceExpression (identifier = age) + UMethod (name = toString) + UAnnotation (fqName = java.lang.Override) + UBlockExpression + UReturnExpression + UPolyadicExpression (operator = +) + ULiteralExpression (value = "DataClass{") + ULiteralExpression (value = "STRING_CONSTANT='") + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + ULiteralExpression (value = ''') + ULiteralExpression (value = ", firstName='") + USimpleNameReferenceExpression (identifier = firstName) + ULiteralExpression (value = ''') + ULiteralExpression (value = ", lastName='") + USimpleNameReferenceExpression (identifier = lastName) + ULiteralExpression (value = ''') + ULiteralExpression (value = ", age='") + USimpleNameReferenceExpression (identifier = age) + ULiteralExpression (value = ''') + ULiteralExpression (value = '}') + UMethod (name = equals) + UAnnotation (fqName = java.lang.Override) + UParameter (name = o) + UBlockExpression + UIfExpression + UBinaryExpression (operator = ===) + UThisExpression (label = null) + USimpleNameReferenceExpression (identifier = o) + UReturnExpression + ULiteralExpression (value = true) + UastEmptyExpression + UIfExpression + UBinaryExpression (operator = ||) + UBinaryExpression (operator = ===) + USimpleNameReferenceExpression (identifier = o) + ULiteralExpression (value = null) + UBinaryExpression (operator = !==) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (getClass)) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = o) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (getClass)) + UReturnExpression + ULiteralExpression (value = false) + UastEmptyExpression + UDeclarationsExpression + ULocalVariable (name = dataClass) + UBinaryExpressionWithType + USimpleNameReferenceExpression (identifier = o) + UTypeReferenceExpression (name = DataClass) + UIfExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + ULiteralExpression (value = null) + UPrefixExpression (operator = !) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (equals)) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + UBinaryExpression (operator = !==) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + ULiteralExpression (value = null) + UReturnExpression + ULiteralExpression (value = false) + UastEmptyExpression + UIfExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = firstName) + ULiteralExpression (value = null) + UPrefixExpression (operator = !) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = firstName) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (equals)) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = firstName) + UBinaryExpression (operator = !==) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = firstName) + ULiteralExpression (value = null) + UReturnExpression + ULiteralExpression (value = false) + UastEmptyExpression + UIfExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = lastName) + ULiteralExpression (value = null) + UPrefixExpression (operator = !) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = lastName) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (equals)) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = lastName) + UBinaryExpression (operator = !==) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = lastName) + ULiteralExpression (value = null) + UReturnExpression + ULiteralExpression (value = false) + UastEmptyExpression + UReturnExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = age) + ULiteralExpression (value = null) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = age) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) + UIdentifier (Identifier (equals)) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = age) + UBinaryExpression (operator = ===) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = dataClass) + USimpleNameReferenceExpression (identifier = age) + ULiteralExpression (value = null) + UMethod (name = hashCode) + UAnnotation (fqName = java.lang.Override) + UBlockExpression + UDeclarationsExpression + ULocalVariable (name = result) + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + ULiteralExpression (value = null) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = STRING_CONSTANT) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (hashCode)) + ULiteralExpression (value = 0) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + UBinaryExpression (operator = +) + UBinaryExpression (operator = *) + ULiteralExpression (value = 31) + USimpleNameReferenceExpression (identifier = result) + UParenthesizedExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = firstName) + ULiteralExpression (value = null) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = firstName) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (hashCode)) + ULiteralExpression (value = 0) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + UBinaryExpression (operator = +) + UBinaryExpression (operator = *) + ULiteralExpression (value = 31) + USimpleNameReferenceExpression (identifier = result) + UParenthesizedExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = lastName) + ULiteralExpression (value = null) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = lastName) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (hashCode)) + ULiteralExpression (value = 0) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + UBinaryExpression (operator = +) + UBinaryExpression (operator = *) + ULiteralExpression (value = 31) + USimpleNameReferenceExpression (identifier = result) + UParenthesizedExpression + UIfExpression + UBinaryExpression (operator = !==) + USimpleNameReferenceExpression (identifier = age) + ULiteralExpression (value = null) + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = age) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (hashCode)) + ULiteralExpression (value = 0) + UReturnExpression + USimpleNameReferenceExpression (identifier = result) diff --git a/uast/uast-tests/java/DataClass/DataClass.render.txt b/uast/uast-tests/java/DataClass/DataClass.render.txt new file mode 100644 index 000000000000..593ce02f1c31 --- /dev/null +++ b/uast/uast-tests/java/DataClass/DataClass.render.txt @@ -0,0 +1,33 @@ +public class DataClass { + public final var STRING_CONSTANT: java.lang.String = "ABC" + private final var firstName: java.lang.String + private final var lastName: java.lang.String + private final var age: java.lang.String + public fun DataClass(firstName: java.lang.String, lastName: java.lang.String, age: java.lang.String) { + this.firstName = firstName + this.lastName = lastName + this.age = age + } + @java.lang.Override + public fun toString() : java.lang.String { + return "DataClass{" + "STRING_CONSTANT='" + STRING_CONSTANT + ''' + ", firstName='" + firstName + ''' + ", lastName='" + lastName + ''' + ", age='" + age + ''' + '}' + } + @java.lang.Override + public fun equals(o: java.lang.Object) : boolean { + if (this === o) return true + if (o === null || getClass() !== o.getClass()) return false + var dataClass: DataClass = o as DataClass + if ((STRING_CONSTANT !== null) ? (!STRING_CONSTANT.equals(dataClass.STRING_CONSTANT)) : (dataClass.STRING_CONSTANT !== null)) return false + if ((firstName !== null) ? (!firstName.equals(dataClass.firstName)) : (dataClass.firstName !== null)) return false + if ((lastName !== null) ? (!lastName.equals(dataClass.lastName)) : (dataClass.lastName !== null)) return false + return (age !== null) ? (age.equals(dataClass.age)) : (dataClass.age === null) + } + @java.lang.Override + public fun hashCode() : int { + var result: int = (STRING_CONSTANT !== null) ? (STRING_CONSTANT.hashCode()) : (0) + result = 31 * result + ((firstName !== null) ? (firstName.hashCode()) : (0)) + result = 31 * result + ((lastName !== null) ? (lastName.hashCode()) : (0)) + result = 31 * result + ((age !== null) ? (age.hashCode()) : (0)) + return result + } +} diff --git a/uast/uast-tests/java/Simple/AliveThenElse.java b/uast/uast-tests/java/Simple/AliveThenElse.java new file mode 100644 index 000000000000..ac9157a42416 --- /dev/null +++ b/uast/uast-tests/java/Simple/AliveThenElse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2017 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. + */ +public class AliveThenElse { + public static int foo(boolean f) { + int x = 0; + int y = 1; + int z; + if (f) { + z = y; + } + else { + z = x; + } + return z; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/AliveThenElse.values.txt b/uast/uast-tests/java/Simple/AliveThenElse.values.txt new file mode 100644 index 000000000000..9d4fa95960ab --- /dev/null +++ b/uast/uast-tests/java/Simple/AliveThenElse.values.txt @@ -0,0 +1,25 @@ +UFile (package = ) [public class AliveThenElse {...] + UClass (name = AliveThenElse) [public class AliveThenElse {...}] + UMethod (name = foo) [public static fun foo(f: boolean) : int {...}] + UParameter (name = f) [var f: boolean] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 0] = Undetermined + ULocalVariable (name = x) [var x: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var y: int = 1] = Undetermined + ULocalVariable (name = y) [var y: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var z: int] = Undetermined + ULocalVariable (name = z) [var z: int] + UIfExpression [if (f) {...}] = Phi((var y = 1), (var x = 0)) + USimpleNameReferenceExpression (identifier = f) [f] = Undetermined + UBlockExpression [{...}] = (var y = 1) + UBinaryExpression (operator = =) [z = y] = (var y = 1) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1) + UBlockExpression [{...}] = (var x = 0) + UBinaryExpression (operator = =) [z = x] = (var x = 0) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0) + UReturnExpression [return z] = Nothing + USimpleNameReferenceExpression (identifier = z) [z] = Phi((var z = (var y = 1)), (var z = (var x = 0))) diff --git a/uast/uast-tests/java/Simple/Anonymous.java b/uast/uast-tests/java/Simple/Anonymous.java new file mode 100644 index 000000000000..0992c52cf3c9 --- /dev/null +++ b/uast/uast-tests/java/Simple/Anonymous.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2017 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. + */ +public class Anonymous { + public static int foo() { + int variable = 42; + + Runnable runnable = new Runnable() { + + public void run() { + int variable = 24; + variable++; + } + }; + runnable.run(); + + return variable; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Anonymous.values.txt b/uast/uast-tests/java/Simple/Anonymous.values.txt new file mode 100644 index 000000000000..2b3cb21457a8 --- /dev/null +++ b/uast/uast-tests/java/Simple/Anonymous.values.txt @@ -0,0 +1,24 @@ +UFile (package = ) [public class Anonymous {...] + UClass (name = Anonymous) [public class Anonymous {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var variable: int = 42] = Undetermined + ULocalVariable (name = variable) [var variable: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UDeclarationsExpression [var runnable: java.lang.Runnable = anonymous Runnable() {... }] = Undetermined + ULocalVariable (name = runnable) [var runnable: java.lang.Runnable = anonymous Runnable() {... }] + UObjectLiteralExpression [anonymous Runnable() {... }] = Undetermined + UClass (name = null) [final class null {...}] + UMethod (name = run) [public fun run() : void {...}] + UBlockExpression [{...}] = (var variable = 24) + UDeclarationsExpression [var variable: int = 24] = Undetermined + ULocalVariable (name = variable) [var variable: int = 24] + ULiteralExpression (value = 24) [24] = 24 + UPostfixExpression (operator = ++) [variable++] = (var variable = 24) + USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 24) + UQualifiedReferenceExpression [runnable.run()] = external run()() + USimpleNameReferenceExpression (identifier = runnable) [runnable] = (var runnable = Undetermined) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [run()] = external run()() + UIdentifier (Identifier (run)) [UIdentifier (Identifier (run))] + UReturnExpression [return variable] = Nothing + USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 42) diff --git a/uast/uast-tests/java/Simple/Bitwise.java b/uast/uast-tests/java/Simple/Bitwise.java new file mode 100644 index 000000000000..76e6f18b5de9 --- /dev/null +++ b/uast/uast-tests/java/Simple/Bitwise.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 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. + */ +public class Bitwise { + public static int foo() { + int first = 0x1234567; + int second = 0x89abcde; + + return (first & second) + (first | second) + (first ^ second); + } + + public static long bar() { + long first = 0x123456789abcdefL; + long second = 0xfedcba987654321L; + + return (first & second) + (first | second) + (first ^ second); + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Bitwise.values.txt b/uast/uast-tests/java/Simple/Bitwise.values.txt new file mode 100644 index 000000000000..d218f59de384 --- /dev/null +++ b/uast/uast-tests/java/Simple/Bitwise.values.txt @@ -0,0 +1,46 @@ +UFile (package = ) [public class Bitwise {...] + UClass (name = Bitwise) [public class Bitwise {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var first: int = 19088743] = Undetermined + ULocalVariable (name = first) [var first: int = 19088743] + ULiteralExpression (value = 19088743) [19088743] = 19088743 + UDeclarationsExpression [var second: int = 144358622] = Undetermined + ULocalVariable (name = second) [var second: int = 144358622] + ULiteralExpression (value = 144358622) [144358622] = 144358622 + UReturnExpression [return (first & second) + (first | second) + (first ^ second)] = Nothing + UPolyadicExpression (operator = +) [(first & second) + (first | second) + (first ^ second)] = 326630398 (depending on: (var first = 19088743), (var second = 144358622)) + UParenthesizedExpression [(first & second)] = 132166 (depending on: (var first = 19088743), (var second = 144358622)) + UBinaryExpression (operator = &) [first & second] = 132166 (depending on: (var first = 19088743), (var second = 144358622)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 19088743) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 144358622) + UParenthesizedExpression [(first | second)] = 163315199 (depending on: (var first = 19088743), (var second = 144358622)) + UBinaryExpression (operator = |) [first | second] = 163315199 (depending on: (var first = 19088743), (var second = 144358622)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 19088743) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 144358622) + UParenthesizedExpression [(first ^ second)] = 163183033 (depending on: (var first = 19088743), (var second = 144358622)) + UBinaryExpression (operator = ^) [first ^ second] = 163183033 (depending on: (var first = 19088743), (var second = 144358622)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 19088743) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 144358622) + UMethod (name = bar) [public static fun bar() : long {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var first: long = 81985529216486895] = Undetermined + ULocalVariable (name = first) [var first: long = 81985529216486895] + ULiteralExpression (value = 81985529216486895) [81985529216486895] = (long)81985529216486895 + UDeclarationsExpression [var second: long = 1147797409030816545] = Undetermined + ULocalVariable (name = second) [var second: long = 1147797409030816545] + ULiteralExpression (value = 1147797409030816545) [1147797409030816545] = (long)1147797409030816545 + UReturnExpression [return (first & second) + (first | second) + (first ^ second)] = Nothing + UPolyadicExpression (operator = +) [(first & second) + (first | second) + (first ^ second)] = (long)2296730115643514846 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + UParenthesizedExpression [(first & second)] = (long)81417880425546017 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + UBinaryExpression (operator = &) [first & second] = (long)81417880425546017 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = (long)81985529216486895) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = (long)1147797409030816545) + UParenthesizedExpression [(first | second)] = (long)1148365057821757423 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + UBinaryExpression (operator = |) [first | second] = (long)1148365057821757423 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = (long)81985529216486895) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = (long)1147797409030816545) + UParenthesizedExpression [(first ^ second)] = (long)1066947177396211406 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + UBinaryExpression (operator = ^) [first ^ second] = (long)1066947177396211406 (depending on: (var first = (long)81985529216486895), (var second = (long)1147797409030816545)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = (long)81985529216486895) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = (long)1147797409030816545) diff --git a/uast/uast-tests/java/Simple/ByteShort.java b/uast/uast-tests/java/Simple/ByteShort.java new file mode 100644 index 000000000000..b601dd58d081 --- /dev/null +++ b/uast/uast-tests/java/Simple/ByteShort.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2017 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. + */ +public class ByteShort { + public static int foo() { + byte b1 = 100; + short s2 = 2; + byte b11 = b1; + short s21 = s2; + int i3 = b11 + b1; + int i4 = s21 + s2; + int i5 = b11 + s21; + byte b3 = (byte) i3; + short s4 = (short) i4; + return i5 + b3 + s4; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ByteShort.values.txt b/uast/uast-tests/java/Simple/ByteShort.values.txt new file mode 100644 index 000000000000..d8e3cad80b6a --- /dev/null +++ b/uast/uast-tests/java/Simple/ByteShort.values.txt @@ -0,0 +1,46 @@ +UFile (package = ) [public class ByteShort {...] + UClass (name = ByteShort) [public class ByteShort {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var b1: byte = 100] = Undetermined + ULocalVariable (name = b1) [var b1: byte = 100] + ULiteralExpression (value = 100) [100] = 100 + UDeclarationsExpression [var s2: short = 2] = Undetermined + ULocalVariable (name = s2) [var s2: short = 2] + ULiteralExpression (value = 2) [2] = 2 + UDeclarationsExpression [var b11: byte = b1] = Undetermined + ULocalVariable (name = b11) [var b11: byte = b1] + USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = (byte)100) + UDeclarationsExpression [var s21: short = s2] = Undetermined + ULocalVariable (name = s21) [var s21: short = s2] + USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = (short)2) + UDeclarationsExpression [var i3: int = b11 + b1] = Undetermined + ULocalVariable (name = i3) [var i3: int = b11 + b1] + UBinaryExpression (operator = +) [b11 + b1] = 200 (depending on: (var b11 = (var b1 = (byte)100)), (var b1 = (byte)100)) + USimpleNameReferenceExpression (identifier = b11) [b11] = (var b11 = (var b1 = (byte)100)) + USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = (byte)100) + UDeclarationsExpression [var i4: int = s21 + s2] = Undetermined + ULocalVariable (name = i4) [var i4: int = s21 + s2] + UBinaryExpression (operator = +) [s21 + s2] = 4 (depending on: (var s21 = (var s2 = (short)2)), (var s2 = (short)2)) + USimpleNameReferenceExpression (identifier = s21) [s21] = (var s21 = (var s2 = (short)2)) + USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = (short)2) + UDeclarationsExpression [var i5: int = b11 + s21] = Undetermined + ULocalVariable (name = i5) [var i5: int = b11 + s21] + UBinaryExpression (operator = +) [b11 + s21] = 102 (depending on: (var b11 = (var b1 = (byte)100)), (var s21 = (var s2 = (short)2))) + USimpleNameReferenceExpression (identifier = b11) [b11] = (var b11 = (var b1 = (byte)100)) + USimpleNameReferenceExpression (identifier = s21) [s21] = (var s21 = (var s2 = (short)2)) + UDeclarationsExpression [var b3: byte = i3 as byte] = Undetermined + ULocalVariable (name = b3) [var b3: byte = i3 as byte] + UBinaryExpressionWithType [i3 as byte] = (byte)-56 + USimpleNameReferenceExpression (identifier = i3) [i3] = (var i3 = 200 (depending on: (var b11 = (var b1 = (byte)100)), (var b1 = (byte)100))) + UTypeReferenceExpression (name = byte) [byte] = Undetermined + UDeclarationsExpression [var s4: short = i4 as short] = Undetermined + ULocalVariable (name = s4) [var s4: short = i4 as short] + UBinaryExpressionWithType [i4 as short] = (short)4 + USimpleNameReferenceExpression (identifier = i4) [i4] = (var i4 = 4 (depending on: (var s21 = (var s2 = (short)2)), (var s2 = (short)2))) + UTypeReferenceExpression (name = short) [short] = Undetermined + UReturnExpression [return i5 + b3 + s4] = Nothing + UPolyadicExpression (operator = +) [i5 + b3 + s4] = 50 (depending on: (var i5 = 102 (depending on: (var b11 = (var b1 = (byte)100)), (var s21 = (var s2 = (short)2)))), (var b3 = (byte)-56), (var s4 = (short)4)) + USimpleNameReferenceExpression (identifier = i5) [i5] = (var i5 = 102 (depending on: (var b11 = (var b1 = (byte)100)), (var s21 = (var s2 = (short)2)))) + USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = (byte)-56) + USimpleNameReferenceExpression (identifier = s4) [s4] = (var s4 = (short)4) diff --git a/uast/uast-tests/java/Simple/CascadeIf.java b/uast/uast-tests/java/Simple/CascadeIf.java new file mode 100644 index 000000000000..e42d0b0a92c6 --- /dev/null +++ b/uast/uast-tests/java/Simple/CascadeIf.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2017 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. + */ +public class CascadeIf { + public static int foo(boolean f, boolean g, boolean h) { + int x = 0; + int y = 1; + int v = 2; + int w = 3; + int z; + if (f) { + z = y; + } + else if (g) { + z = x; + } + else if (h) { + z = v; + } + else { + z = w; + } + return z; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/CascadeIf.values.txt b/uast/uast-tests/java/Simple/CascadeIf.values.txt new file mode 100644 index 000000000000..baad4b1f1f73 --- /dev/null +++ b/uast/uast-tests/java/Simple/CascadeIf.values.txt @@ -0,0 +1,45 @@ +UFile (package = ) [public class CascadeIf {...] + UClass (name = CascadeIf) [public class CascadeIf {...}] + UMethod (name = foo) [public static fun foo(f: boolean, g: boolean, h: boolean) : int {...}] + UParameter (name = f) [var f: boolean] + UParameter (name = g) [var g: boolean] + UParameter (name = h) [var h: boolean] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 0] = Undetermined + ULocalVariable (name = x) [var x: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var y: int = 1] = Undetermined + ULocalVariable (name = y) [var y: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var v: int = 2] = Undetermined + ULocalVariable (name = v) [var v: int = 2] + ULiteralExpression (value = 2) [2] = 2 + UDeclarationsExpression [var w: int = 3] = Undetermined + ULocalVariable (name = w) [var w: int = 3] + ULiteralExpression (value = 3) [3] = 3 + UDeclarationsExpression [var z: int] = Undetermined + ULocalVariable (name = z) [var z: int] + UIfExpression [if (f) {...}] = Phi((var y = 1), (var x = 0), (var v = 2), (var w = 3)) + USimpleNameReferenceExpression (identifier = f) [f] = Undetermined + UBlockExpression [{...}] = (var y = 1) + UBinaryExpression (operator = =) [z = y] = (var y = 1) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1) + UIfExpression [if (g) {...}] = Phi((var x = 0), (var v = 2), (var w = 3)) + USimpleNameReferenceExpression (identifier = g) [g] = Undetermined + UBlockExpression [{...}] = (var x = 0) + UBinaryExpression (operator = =) [z = x] = (var x = 0) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0) + UIfExpression [if (h) {...}] = Phi((var v = 2), (var w = 3)) + USimpleNameReferenceExpression (identifier = h) [h] = Undetermined + UBlockExpression [{...}] = (var v = 2) + UBinaryExpression (operator = =) [z = v] = (var v = 2) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = v) [v] = (var v = 2) + UBlockExpression [{...}] = (var w = 3) + UBinaryExpression (operator = =) [z = w] = (var w = 3) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = w) [w] = (var w = 3) + UReturnExpression [return z] = Nothing + USimpleNameReferenceExpression (identifier = z) [z] = Phi((var z = (var y = 1)), (var z = (var x = 0)), (var z = (var v = 2)), (var z = (var w = 3))) diff --git a/uast/uast-tests/java/Simple/Characters.java b/uast/uast-tests/java/Simple/Characters.java new file mode 100644 index 000000000000..6c509284f86a --- /dev/null +++ b/uast/uast-tests/java/Simple/Characters.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2017 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. + */ +public class Characters { + public static char foo() { + char a = 'a'; + char c = (char) (a + 2); + char f = (char) (c + 3); + char d = (char) (f - 2); + int diff = f - a; + int aa = a + a; + char cdiff = (char) diff; + return d; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Characters.values.txt b/uast/uast-tests/java/Simple/Characters.values.txt new file mode 100644 index 000000000000..2c138eccc6cf --- /dev/null +++ b/uast/uast-tests/java/Simple/Characters.values.txt @@ -0,0 +1,48 @@ +UFile (package = ) [public class Characters {...] + UClass (name = Characters) [public class Characters {...}] + UMethod (name = foo) [public static fun foo() : char {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var a: char = 'a'] = Undetermined + ULocalVariable (name = a) [var a: char = 'a'] + ULiteralExpression (value = 'a') ['a'] = 'a' + UDeclarationsExpression [var c: char = (a + 2) as char] = Undetermined + ULocalVariable (name = c) [var c: char = (a + 2) as char] + UBinaryExpressionWithType [(a + 2) as char] = 'c' (depending on: (var a = 'a')) + UParenthesizedExpression [(a + 2)] = 'c' (depending on: (var a = 'a')) + UBinaryExpression (operator = +) [a + 2] = 'c' (depending on: (var a = 'a')) + USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a') + ULiteralExpression (value = 2) [2] = 2 + UTypeReferenceExpression (name = char) [char] = Undetermined + UDeclarationsExpression [var f: char = (c + 3) as char] = Undetermined + ULocalVariable (name = f) [var f: char = (c + 3) as char] + UBinaryExpressionWithType [(c + 3) as char] = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))) + UParenthesizedExpression [(c + 3)] = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))) + UBinaryExpression (operator = +) [c + 3] = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))) + USimpleNameReferenceExpression (identifier = c) [c] = (var c = 'c' (depending on: (var a = 'a'))) + ULiteralExpression (value = 3) [3] = 3 + UTypeReferenceExpression (name = char) [char] = Undetermined + UDeclarationsExpression [var d: char = (f - 2) as char] = Undetermined + ULocalVariable (name = d) [var d: char = (f - 2) as char] + UBinaryExpressionWithType [(f - 2) as char] = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))))) + UParenthesizedExpression [(f - 2)] = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))))) + UBinaryExpression (operator = -) [f - 2] = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a')))))) + USimpleNameReferenceExpression (identifier = f) [f] = (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))) + ULiteralExpression (value = 2) [2] = 2 + UTypeReferenceExpression (name = char) [char] = Undetermined + UDeclarationsExpression [var diff: int = f - a] = Undetermined + ULocalVariable (name = diff) [var diff: int = f - a] + UBinaryExpression (operator = -) [f - a] = 5 (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))), (var a = 'a')) + USimpleNameReferenceExpression (identifier = f) [f] = (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))) + USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a') + UDeclarationsExpression [var aa: int = a + a] = Undetermined + ULocalVariable (name = aa) [var aa: int = a + a] + UBinaryExpression (operator = +) [a + a] = 'Â' (depending on: (var a = 'a')) + USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a') + USimpleNameReferenceExpression (identifier = a) [a] = (var a = 'a') + UDeclarationsExpression [var cdiff: char = diff as char] = Undetermined + ULocalVariable (name = cdiff) [var cdiff: char = diff as char] + UBinaryExpressionWithType [diff as char] = '' + USimpleNameReferenceExpression (identifier = diff) [diff] = (var diff = 5 (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))), (var a = 'a'))) + UTypeReferenceExpression (name = char) [char] = Undetermined + UReturnExpression [return d] = Nothing + USimpleNameReferenceExpression (identifier = d) [d] = (var d = 'd' (depending on: (var f = 'f' (depending on: (var c = 'c' (depending on: (var a = 'a'))))))) diff --git a/uast/uast-tests/java/Simple/ClassLiteral.java b/uast/uast-tests/java/Simple/ClassLiteral.java new file mode 100644 index 000000000000..5e7fa5ccd7c4 --- /dev/null +++ b/uast/uast-tests/java/Simple/ClassLiteral.java @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2017 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. + */ +public class Foo { + public static void bar() { + Class<*> FOO_CLASS = Foo.class; + } +} diff --git a/uast/uast-tests/java/Simple/ClassLiteral.values.txt b/uast/uast-tests/java/Simple/ClassLiteral.values.txt new file mode 100644 index 000000000000..cda616f7e52a --- /dev/null +++ b/uast/uast-tests/java/Simple/ClassLiteral.values.txt @@ -0,0 +1,9 @@ +UFile (package = ) [public class Foo {...] + UClass (name = Foo) [public class Foo {...}] + UMethod (name = bar) [public static fun bar() : void {...}] + UBlockExpression [{...}] = Undetermined + UDeclarationsExpression [] = Undetermined + UBinaryExpression (operator = =) [FOO_CLASS = Foo] = Undetermined + USimpleNameReferenceExpression (identifier = FOO_CLASS) [FOO_CLASS] = external FOO_CLASS() + UClassLiteralExpression [Foo] = Foo + UTypeReferenceExpression (name = Foo) [Foo] = Undetermined diff --git a/uast/uast-tests/java/Simple/DeadElse.java b/uast/uast-tests/java/Simple/DeadElse.java new file mode 100644 index 000000000000..d180cc4d42eb --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadElse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 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. + */ +public class DeadElse { + public static int foo() { + boolean f = true; + int x = 0; + int y = 1; + int z; + if (f) { + z = y; + } + else { + z = x; + } + return z; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DeadElse.values.txt b/uast/uast-tests/java/Simple/DeadElse.values.txt new file mode 100644 index 000000000000..37c520928801 --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadElse.values.txt @@ -0,0 +1,27 @@ +UFile (package = ) [public class DeadElse {...] + UClass (name = DeadElse) [public class DeadElse {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var f: boolean = true] = Undetermined + ULocalVariable (name = f) [var f: boolean = true] + ULiteralExpression (value = true) [true] = true + UDeclarationsExpression [var x: int = 0] = Undetermined + ULocalVariable (name = x) [var x: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var y: int = 1] = Undetermined + ULocalVariable (name = y) [var y: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var z: int] = Undetermined + ULocalVariable (name = z) [var z: int] + UIfExpression [if (f) {...}] = (var y = 1) + USimpleNameReferenceExpression (identifier = f) [f] = (var f = true) + UBlockExpression [{...}] = (var y = 1) + UBinaryExpression (operator = =) [z = y] = (var y = 1) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1) + UBlockExpression [{...}] = (var x = 0) + UBinaryExpression (operator = =) [z = x] = (var x = 0) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0) + UReturnExpression [return z] = Nothing + USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var y = 1)) diff --git a/uast/uast-tests/java/Simple/DeadFor.java b/uast/uast-tests/java/Simple/DeadFor.java new file mode 100644 index 000000000000..9eab78a9d71a --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadFor.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2017 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. + */ +public class DeadFor { + public static int foo() { + int result = 0; + for (int i = 9; i < 5; i++) { + result = result + i; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DeadFor.values.txt b/uast/uast-tests/java/Simple/DeadFor.values.txt new file mode 100644 index 000000000000..43e2220ae986 --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadFor.values.txt @@ -0,0 +1,24 @@ +UFile (package = ) [public class DeadFor {...] + UClass (name = DeadFor) [public class DeadFor {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int = 0] = Undetermined + ULocalVariable (name = result) [var result: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UForExpression [for (var i: int = 9; i < 5; i++) {...}] = Undetermined + UDeclarationsExpression [var i: int = 9] = Undetermined + ULocalVariable (name = i) [var i: int = 9] + ULiteralExpression (value = 9) [9] = 9 + UBinaryExpression (operator = <) [i < 5] = false (depending on: (var i = 9)) + USimpleNameReferenceExpression (identifier = i) [i] = (var i = 9) + ULiteralExpression (value = 5) [5] = 5 + UPostfixExpression (operator = ++) [i++] = Undetermined + USimpleNameReferenceExpression (identifier = i) [i] = Undetermined + UBlockExpression [{...}] = Undetermined + UBinaryExpression (operator = =) [result = result + i] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + UBinaryExpression (operator = +) [result + i] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + USimpleNameReferenceExpression (identifier = i) [i] = Undetermined + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = (var result = 0) diff --git a/uast/uast-tests/java/Simple/DeadIfComparison.java b/uast/uast-tests/java/Simple/DeadIfComparison.java new file mode 100644 index 000000000000..ee1c3fcb649c --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadIfComparison.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2017 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. + */ +public class DeadIfComparison { + public static int foo() { + int x = 0; + int y = 1; + int z; + if (x == y) { + z = y; + } + else { + z = x; + } + return z; + } +} diff --git a/uast/uast-tests/java/Simple/DeadIfComparison.values.txt b/uast/uast-tests/java/Simple/DeadIfComparison.values.txt new file mode 100644 index 000000000000..cc18b781974b --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadIfComparison.values.txt @@ -0,0 +1,26 @@ +UFile (package = ) [public class DeadIfComparison {...] + UClass (name = DeadIfComparison) [public class DeadIfComparison {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 0] = Undetermined + ULocalVariable (name = x) [var x: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var y: int = 1] = Undetermined + ULocalVariable (name = y) [var y: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var z: int] = Undetermined + ULocalVariable (name = z) [var z: int] + UIfExpression [if (x === y) {...}] = (var x = 0) + UBinaryExpression (operator = ===) [x === y] = false (depending on: (var x = 0), (var y = 1)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1) + UBlockExpression [{...}] = (var y = 1) + UBinaryExpression (operator = =) [z = y] = (var y = 1) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1) + UBlockExpression [{...}] = (var x = 0) + UBinaryExpression (operator = =) [z = x] = (var x = 0) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0) + UReturnExpression [return z] = Nothing + USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var x = 0)) diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntries.java b/uast/uast-tests/java/Simple/DeadSwitchEntries.java new file mode 100644 index 000000000000..98d62cd6de5e --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadSwitchEntries.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2017 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. + */ +public enum DeadSwitchEntries { + FIRST, + SECOND, + THIRD; + + public static int bar() { + DeadSwitchEntries key = THIRD; + int result; + switch (key) { + case FIRST: + result = 3; + break; + case SECOND: + result = 7; + break; + case THIRD: + result = 13; + break; + default: + result = 66; + break; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt b/uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt new file mode 100644 index 000000000000..c56fd22f053e --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadSwitchEntries.values.txt @@ -0,0 +1,48 @@ +UFile (package = ) [public final enum DeadSwitchEntries {...] + UClass (name = DeadSwitchEntries) [public final enum DeadSwitchEntries {...}] + UEnumConstant (name = FIRST) [FIRST] = Undetermined + USimpleNameReferenceExpression (identifier = DeadSwitchEntries) [DeadSwitchEntries] = Undetermined + UEnumConstant (name = SECOND) [SECOND] = Undetermined + USimpleNameReferenceExpression (identifier = DeadSwitchEntries) [DeadSwitchEntries] = Undetermined + UEnumConstant (name = THIRD) [THIRD] = Undetermined + USimpleNameReferenceExpression (identifier = DeadSwitchEntries) [DeadSwitchEntries] = Undetermined + UMethod (name = bar) [public static fun bar() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var key: DeadSwitchEntries = THIRD] = Undetermined + ULocalVariable (name = key) [var key: DeadSwitchEntries = THIRD] + USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry) + UDeclarationsExpression [var result: int] = Undetermined + ULocalVariable (name = result) [var result: int] + USwitchExpression [switch (key) ...] = Undetermined + USimpleNameReferenceExpression (identifier = key) [key] = (var key = THIRD (enum entry)) + UExpressionList (switch) [ FIRST -> {... ] = Undetermined + USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 3] = 3 + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + ULiteralExpression (value = 3) [3] = 3 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 7] = 7 + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + ULiteralExpression (value = 7) [7] = 7 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 13] = 13 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 13) [13] = 13 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [else -> {...] = Undetermined + UDefaultCaseExpression [else] = Undetermined + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 66] = 66 + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + ULiteralExpression (value = 66) [66] = 66 + UBreakExpression (label = null) [break] = Nothing(break) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = (var result = 13) diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java new file mode 100644 index 000000000000..ba706c0611e8 --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2017 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. + */ +public enum DeadSwitchEntriesWithoutBreaks { + FIRST, + SECOND, + THIRD; + + public static int bar() { + DeadSwitchEntriesWithoutBreaks key = SECOND; + int result; + switch (key) { + case FIRST: + result = 3; + break; + case SECOND: + result = 7; + case THIRD: + result = 13; + default: + result = 66; + break; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt new file mode 100644 index 000000000000..9f45b9fdee13 --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadSwitchEntriesWithoutBreaks.values.txt @@ -0,0 +1,46 @@ +UFile (package = ) [public final enum DeadSwitchEntriesWithoutBreaks {...] + UClass (name = DeadSwitchEntriesWithoutBreaks) [public final enum DeadSwitchEntriesWithoutBreaks {...}] + UEnumConstant (name = FIRST) [FIRST] = Undetermined + USimpleNameReferenceExpression (identifier = DeadSwitchEntriesWithoutBreaks) [DeadSwitchEntriesWithoutBreaks] = Undetermined + UEnumConstant (name = SECOND) [SECOND] = Undetermined + USimpleNameReferenceExpression (identifier = DeadSwitchEntriesWithoutBreaks) [DeadSwitchEntriesWithoutBreaks] = Undetermined + UEnumConstant (name = THIRD) [THIRD] = Undetermined + USimpleNameReferenceExpression (identifier = DeadSwitchEntriesWithoutBreaks) [DeadSwitchEntriesWithoutBreaks] = Undetermined + UMethod (name = bar) [public static fun bar() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var key: DeadSwitchEntriesWithoutBreaks = SECOND] = Undetermined + ULocalVariable (name = key) [var key: DeadSwitchEntriesWithoutBreaks = SECOND] + USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry) + UDeclarationsExpression [var result: int] = Undetermined + ULocalVariable (name = result) [var result: int] + USwitchExpression [switch (key) ...] = Undetermined + USimpleNameReferenceExpression (identifier = key) [key] = (var key = SECOND (enum entry)) + UExpressionList (switch) [ FIRST -> {... ] = Undetermined + USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 3] = 3 + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + ULiteralExpression (value = 3) [3] = 3 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 7] = 7 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 7) [7] = 7 + USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 13] = 13 + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 7), (var result = Undetermined)) + ULiteralExpression (value = 13) [13] = 13 + USwitchClauseExpressionWithBody [else -> {...] = Undetermined + UDefaultCaseExpression [else] = Undetermined + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 66] = 66 + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 13), (var result = Undetermined)) + ULiteralExpression (value = 66) [66] = 66 + UBreakExpression (label = null) [break] = Nothing(break) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = (var result = 66) diff --git a/uast/uast-tests/java/Simple/DeadThen.java b/uast/uast-tests/java/Simple/DeadThen.java new file mode 100644 index 000000000000..b56b175612fd --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadThen.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 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. + */ +public class DeadThen { + public static int foo() { + boolean f = true; + int x = 0; + int y = 1; + int z; + if (!f) { + z = y; + } + else { + z = x; + } + return z; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DeadThen.values.txt b/uast/uast-tests/java/Simple/DeadThen.values.txt new file mode 100644 index 000000000000..14528bcb2a84 --- /dev/null +++ b/uast/uast-tests/java/Simple/DeadThen.values.txt @@ -0,0 +1,28 @@ +UFile (package = ) [public class DeadThen {...] + UClass (name = DeadThen) [public class DeadThen {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var f: boolean = true] = Undetermined + ULocalVariable (name = f) [var f: boolean = true] + ULiteralExpression (value = true) [true] = true + UDeclarationsExpression [var x: int = 0] = Undetermined + ULocalVariable (name = x) [var x: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var y: int = 1] = Undetermined + ULocalVariable (name = y) [var y: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var z: int] = Undetermined + ULocalVariable (name = z) [var z: int] + UIfExpression [if (!f) {...}] = (var x = 0) + UPrefixExpression (operator = !) [!f] = false (depending on: (var f = true)) + USimpleNameReferenceExpression (identifier = f) [f] = (var f = true) + UBlockExpression [{...}] = (var y = 1) + UBinaryExpression (operator = =) [z = y] = (var y = 1) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 1) + UBlockExpression [{...}] = (var x = 0) + UBinaryExpression (operator = =) [z = x] = (var x = 0) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = Undetermined) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 0) + UReturnExpression [return z] = Nothing + USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var x = 0)) diff --git a/uast/uast-tests/java/Simple/Dependents.java b/uast/uast-tests/java/Simple/Dependents.java new file mode 100644 index 000000000000..db5662b48b09 --- /dev/null +++ b/uast/uast-tests/java/Simple/Dependents.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2017 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. + */ +public class Dependents { + public static int foo() { + int x = 42; + int y = x; + int z = y; + int w = z; + return w; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Dependents.values.txt b/uast/uast-tests/java/Simple/Dependents.values.txt new file mode 100644 index 000000000000..4a1e915fe974 --- /dev/null +++ b/uast/uast-tests/java/Simple/Dependents.values.txt @@ -0,0 +1,18 @@ +UFile (package = ) [public class Dependents {...] + UClass (name = Dependents) [public class Dependents {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 42] = Undetermined + ULocalVariable (name = x) [var x: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UDeclarationsExpression [var y: int = x] = Undetermined + ULocalVariable (name = y) [var y: int = x] + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 42) + UDeclarationsExpression [var z: int = y] = Undetermined + ULocalVariable (name = z) [var z: int = y] + USimpleNameReferenceExpression (identifier = y) [y] = (var y = (var x = 42)) + UDeclarationsExpression [var w: int = z] = Undetermined + ULocalVariable (name = w) [var w: int = z] + USimpleNameReferenceExpression (identifier = z) [z] = (var z = (var y = (var x = 42))) + UReturnExpression [return w] = Nothing + USimpleNameReferenceExpression (identifier = w) [w] = (var w = (var z = (var y = (var x = 42)))) diff --git a/uast/uast-tests/java/Simple/DoWhile.java b/uast/uast-tests/java/Simple/DoWhile.java new file mode 100644 index 000000000000..835c25676a82 --- /dev/null +++ b/uast/uast-tests/java/Simple/DoWhile.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class DoWhile { + public static int foo() { + int count = 0; + int number = 42; + do { + if (number % 10 == 7) { + count++; + } + number = number / 10; + } while (number > 0); + return count; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DoWhile.values.txt b/uast/uast-tests/java/Simple/DoWhile.values.txt new file mode 100644 index 000000000000..5fc329e61778 --- /dev/null +++ b/uast/uast-tests/java/Simple/DoWhile.values.txt @@ -0,0 +1,32 @@ +UFile (package = ) [public class DoWhile {...] + UClass (name = DoWhile) [public class DoWhile {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var count: int = 0] = Undetermined + ULocalVariable (name = count) [var count: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var number: int = 42] = Undetermined + ULocalVariable (name = number) [var number: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UDoWhileExpression [do {...] = Undetermined + UBinaryExpression (operator = >) [number > 0] = Undetermined + USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4)) + ULiteralExpression (value = 0) [0] = 0 + UBlockExpression [{...}] = Undetermined + UIfExpression [if (number % 10 === 7) {...}] = Phi((var count = Undetermined), (var count = 0), (var count = 1), Undetermined) + UBinaryExpression (operator = ===) [number % 10 === 7] = Undetermined + UBinaryExpression (operator = %) [number % 10] = Undetermined + USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4)) + ULiteralExpression (value = 10) [10] = 10 + ULiteralExpression (value = 7) [7] = 7 + UBlockExpression [{...}] = Phi((var count = Undetermined), (var count = 0), (var count = 1)) + UPostfixExpression (operator = ++) [count++] = Phi((var count = Undetermined), (var count = 0), (var count = 1)) + USimpleNameReferenceExpression (identifier = count) [count] = Phi((var count = Undetermined), (var count = 0), (var count = 1)) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UBinaryExpression (operator = =) [number = number / 10] = Undetermined + USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4)) + UBinaryExpression (operator = /) [number / 10] = Undetermined + USimpleNameReferenceExpression (identifier = number) [number] = Phi((var number = Undetermined), (var number = 0), (var number = 4)) + ULiteralExpression (value = 10) [10] = 10 + UReturnExpression [return count] = Nothing + USimpleNameReferenceExpression (identifier = count) [count] = Phi((var count = Undetermined), (var count = 0), (var count = 1)) diff --git a/uast/uast-tests/java/Simple/DoWhileInfinite.java b/uast/uast-tests/java/Simple/DoWhileInfinite.java new file mode 100644 index 000000000000..596790528e55 --- /dev/null +++ b/uast/uast-tests/java/Simple/DoWhileInfinite.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2017 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. + */ +public class DoWhileInfinite { + public static int foo() { + int count = 0; + int number = 42; + do { + if (number % 10 == 7) { + count++; + } + } while (number > 0); + return count; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DoWhileInfinite.values.txt b/uast/uast-tests/java/Simple/DoWhileInfinite.values.txt new file mode 100644 index 000000000000..e668733bdf39 --- /dev/null +++ b/uast/uast-tests/java/Simple/DoWhileInfinite.values.txt @@ -0,0 +1,27 @@ +UFile (package = ) [public class DoWhileInfinite {...] + UClass (name = DoWhileInfinite) [public class DoWhileInfinite {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var count: int = 0] = Undetermined + ULocalVariable (name = count) [var count: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var number: int = 42] = Undetermined + ULocalVariable (name = number) [var number: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UDoWhileExpression [do {...] = Undetermined + UBinaryExpression (operator = >) [number > 0] = true (depending on: (var number = 42)) + USimpleNameReferenceExpression (identifier = number) [number] = (var number = 42) + ULiteralExpression (value = 0) [0] = 0 + UBlockExpression [{...}] = Undetermined + UIfExpression [if (number % 10 === 7) {...}] = Undetermined + UBinaryExpression (operator = ===) [number % 10 === 7] = false (depending on: (var number = 42)) + UBinaryExpression (operator = %) [number % 10] = 2 (depending on: (var number = 42)) + USimpleNameReferenceExpression (identifier = number) [number] = (var number = 42) + ULiteralExpression (value = 10) [10] = 10 + ULiteralExpression (value = 7) [7] = 7 + UBlockExpression [{...}] = (var count = 0) + UPostfixExpression (operator = ++) [count++] = (var count = 0) + USimpleNameReferenceExpression (identifier = count) [count] = (var count = 0) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UReturnExpression [return count] = Nothing + USimpleNameReferenceExpression (identifier = count) [count] = (var count = 0) diff --git a/uast/uast-tests/java/Simple/DoWhileWithReturn.java b/uast/uast-tests/java/Simple/DoWhileWithReturn.java new file mode 100644 index 000000000000..393beaf41142 --- /dev/null +++ b/uast/uast-tests/java/Simple/DoWhileWithReturn.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2017 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. + */ +public class DoWhileWithReturn { + public static int foo() { + int count = 0; + int number = 1; + do { + if (number > 0) return count; + count++; + number--; + } while (number >= 0); + return count; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt b/uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt new file mode 100644 index 000000000000..42194a60f153 --- /dev/null +++ b/uast/uast-tests/java/Simple/DoWhileWithReturn.values.txt @@ -0,0 +1,28 @@ +UFile (package = ) [public class DoWhileWithReturn {...] + UClass (name = DoWhileWithReturn) [public class DoWhileWithReturn {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var count: int = 0] = Undetermined + ULocalVariable (name = count) [var count: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var number: int = 1] = Undetermined + ULocalVariable (name = number) [var number: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDoWhileExpression [do {...] = Nothing + UBinaryExpression (operator = >=) [number >= 0] = true (depending on: (var number = 1)) + USimpleNameReferenceExpression (identifier = number) [number] = (var number = 1) + ULiteralExpression (value = 0) [0] = 0 + UBlockExpression [{...}] = Nothing + UIfExpression [if (number > 0) return count] = Nothing + UBinaryExpression (operator = >) [number > 0] = true (depending on: (var number = 1)) + USimpleNameReferenceExpression (identifier = number) [number] = (var number = 1) + ULiteralExpression (value = 0) [0] = 0 + UReturnExpression [return count] = Nothing + USimpleNameReferenceExpression (identifier = count) [count] = (var count = 0) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UPostfixExpression (operator = ++) [count++] = Undetermined + USimpleNameReferenceExpression (identifier = count) [count] = Undetermined + UPostfixExpression (operator = --) [number--] = Undetermined + USimpleNameReferenceExpression (identifier = number) [number] = Undetermined + UReturnExpression [return count] = Nothing + USimpleNameReferenceExpression (identifier = count) [count] = Undetermined diff --git a/uast/uast-tests/java/Simple/EnumChoice.java b/uast/uast-tests/java/Simple/EnumChoice.java new file mode 100644 index 000000000000..b51fe3c8fe83 --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumChoice.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 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. + */ +public enum EnumChoice { + FIRST, + SECOND; + + public EnumChoice foo(boolean flag) { + EnumChoice result; + if (flag) { + result = FIRST; + } + else { + result = SECOND; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/EnumChoice.values.txt b/uast/uast-tests/java/Simple/EnumChoice.values.txt new file mode 100644 index 000000000000..6cd8576fb434 --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumChoice.values.txt @@ -0,0 +1,23 @@ +UFile (package = ) [public final enum EnumChoice {...] + UClass (name = EnumChoice) [public final enum EnumChoice {...}] + UEnumConstant (name = FIRST) [FIRST] = Undetermined + USimpleNameReferenceExpression (identifier = EnumChoice) [EnumChoice] = Undetermined + UEnumConstant (name = SECOND) [SECOND] = Undetermined + USimpleNameReferenceExpression (identifier = EnumChoice) [EnumChoice] = Undetermined + UMethod (name = foo) [public fun foo(flag: boolean) : EnumChoice {...}] + UParameter (name = flag) [var flag: boolean] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: EnumChoice] = Undetermined + ULocalVariable (name = result) [var result: EnumChoice] + UIfExpression [if (flag) {...}] = Phi(FIRST (enum entry), SECOND (enum entry)) + USimpleNameReferenceExpression (identifier = flag) [flag] = Undetermined + UBlockExpression [{...}] = FIRST (enum entry) + UBinaryExpression (operator = =) [result = FIRST] = FIRST (enum entry) + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry) + UBlockExpression [{...}] = SECOND (enum entry) + UBinaryExpression (operator = =) [result = SECOND] = SECOND (enum entry) + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = FIRST (enum entry)), (var result = SECOND (enum entry))) diff --git a/uast/uast-tests/java/Simple/EnumSwitch.java b/uast/uast-tests/java/Simple/EnumSwitch.java new file mode 100644 index 000000000000..445a20ddaa5a --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitch.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2017 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. + */ +public enum EnumSwitch { + FIRST, + SECOND, + THIRD; + + public static int foo(EnumSwitch key) { + int result; + switch (key) { + case FIRST: + result = 3; + break; + case SECOND: + result = 7; + break; + case THIRD: + result = 13; + break; + default: + result = 66; + break; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/EnumSwitch.log.txt b/uast/uast-tests/java/Simple/EnumSwitch.log.txt new file mode 100644 index 000000000000..a515b98f5770 --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitch.log.txt @@ -0,0 +1,46 @@ +UFile (package = ) + UClass (name = EnumSwitch) + UEnumConstant (name = FIRST) + USimpleNameReferenceExpression (identifier = EnumSwitch) + UEnumConstant (name = SECOND) + USimpleNameReferenceExpression (identifier = EnumSwitch) + UEnumConstant (name = THIRD) + USimpleNameReferenceExpression (identifier = EnumSwitch) + UMethod (name = foo) + UParameter (name = key) + UBlockExpression + UDeclarationsExpression + ULocalVariable (name = result) + USwitchExpression + USimpleNameReferenceExpression (identifier = key) + UExpressionList (switch) + USwitchClauseExpressionWithBody + USimpleNameReferenceExpression (identifier = FIRST) + UExpressionList (switch_entry) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + ULiteralExpression (value = 3) + UBreakExpression (label = null) + USwitchClauseExpressionWithBody + USimpleNameReferenceExpression (identifier = SECOND) + UExpressionList (switch_entry) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + ULiteralExpression (value = 7) + UBreakExpression (label = null) + USwitchClauseExpressionWithBody + USimpleNameReferenceExpression (identifier = THIRD) + UExpressionList (switch_entry) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + ULiteralExpression (value = 13) + UBreakExpression (label = null) + USwitchClauseExpressionWithBody + UDefaultCaseExpression + UExpressionList (switch_entry) + UBinaryExpression (operator = =) + USimpleNameReferenceExpression (identifier = result) + ULiteralExpression (value = 66) + UBreakExpression (label = null) + UReturnExpression + USimpleNameReferenceExpression (identifier = result) diff --git a/uast/uast-tests/java/Simple/EnumSwitch.render.txt b/uast/uast-tests/java/Simple/EnumSwitch.render.txt new file mode 100644 index 000000000000..cf067075fdad --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitch.render.txt @@ -0,0 +1,31 @@ +public final enum EnumSwitch { + FIRST + SECOND + THIRD + public static fun foo(key: EnumSwitch) : int { + var result: int + switch (key) + FIRST -> { + result = 3 + break + } + + SECOND -> { + result = 7 + break + } + + THIRD -> { + result = 13 + break + } + + else -> { + result = 66 + break + } + + + return result + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/EnumSwitch.values.txt b/uast/uast-tests/java/Simple/EnumSwitch.values.txt new file mode 100644 index 000000000000..7b16d1328964 --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitch.values.txt @@ -0,0 +1,46 @@ +UFile (package = ) [public final enum EnumSwitch {...] + UClass (name = EnumSwitch) [public final enum EnumSwitch {...}] + UEnumConstant (name = FIRST) [FIRST] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitch) [EnumSwitch] = Undetermined + UEnumConstant (name = SECOND) [SECOND] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitch) [EnumSwitch] = Undetermined + UEnumConstant (name = THIRD) [THIRD] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitch) [EnumSwitch] = Undetermined + UMethod (name = foo) [public static fun foo(key: EnumSwitch) : int {...}] + UParameter (name = key) [var key: EnumSwitch] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int] = Undetermined + ULocalVariable (name = result) [var result: int] + USwitchExpression [switch (key) ...] = Undetermined + USimpleNameReferenceExpression (identifier = key) [key] = Undetermined + UExpressionList (switch) [ FIRST -> {... ] = Undetermined + USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 3] = 3 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 3) [3] = 3 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 7] = 7 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 7) [7] = 7 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 13] = 13 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 13) [13] = 13 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [else -> {...] = Undetermined + UDefaultCaseExpression [else] = Undetermined + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 66] = 66 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 66) [66] = 66 + UBreakExpression (label = null) [break] = Nothing(break) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 66), (var result = 13), (var result = 3), (var result = 7)) diff --git a/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java new file mode 100644 index 000000000000..8489559bf10d --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2017 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. + */ +public enum EnumSwitchConditionalBreak { + FIRST, + SECOND, + THIRD; + + public static int foo(EnumSwitchConditionalBreak key, int result) { + int newResult; + int counter = 0; + switch (key) { + case FIRST: + if (result > 0) { + newResult = 42; + counter++; + break; + } + counter++; + default: + newResult = 42; + counter++; + break; + } + return newResult + counter; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt new file mode 100644 index 000000000000..cc1f591a577e --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitchConditionalBreak.values.txt @@ -0,0 +1,50 @@ +UFile (package = ) [public final enum EnumSwitchConditionalBreak {...] + UClass (name = EnumSwitchConditionalBreak) [public final enum EnumSwitchConditionalBreak {...}] + UEnumConstant (name = FIRST) [FIRST] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitchConditionalBreak) [EnumSwitchConditionalBreak] = Undetermined + UEnumConstant (name = SECOND) [SECOND] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitchConditionalBreak) [EnumSwitchConditionalBreak] = Undetermined + UEnumConstant (name = THIRD) [THIRD] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitchConditionalBreak) [EnumSwitchConditionalBreak] = Undetermined + UMethod (name = foo) [public static fun foo(key: EnumSwitchConditionalBreak, result: int) : int {...}] + UParameter (name = key) [var key: EnumSwitchConditionalBreak] + UParameter (name = result) [var result: int] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var newResult: int] = Undetermined + ULocalVariable (name = newResult) [var newResult: int] + UDeclarationsExpression [var counter: int = 0] = Undetermined + ULocalVariable (name = counter) [var counter: int = 0] + ULiteralExpression (value = 0) [0] = 0 + USwitchExpression [switch (key) ...] = Undetermined + USimpleNameReferenceExpression (identifier = key) [key] = Undetermined + UExpressionList (switch) [ FIRST -> {... ] = Undetermined + USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UIfExpression [if (result > 0) {...}] = Undetermined + UBinaryExpression (operator = >) [result > 0] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Undetermined + ULiteralExpression (value = 0) [0] = 0 + UBlockExpression [{...}] = Nothing(break) + UBinaryExpression (operator = =) [newResult = 42] = 42 + USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = Undetermined) + ULiteralExpression (value = 42) [42] = 42 + UPostfixExpression (operator = ++) [counter++] = (var counter = 0) + USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = 0) + UBreakExpression (label = null) [break] = Nothing(break) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UPostfixExpression (operator = ++) [counter++] = (var counter = 0) + USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = 0) + USwitchClauseExpressionWithBody [else -> {...] = Undetermined + UDefaultCaseExpression [else] = Undetermined + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [newResult = 42] = 42 + USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = Undetermined) + ULiteralExpression (value = 42) [42] = 42 + UPostfixExpression (operator = ++) [counter++] = Phi((var counter = 1), (var counter = 0)) + USimpleNameReferenceExpression (identifier = counter) [counter] = Phi((var counter = 1), (var counter = 0)) + UBreakExpression (label = null) [break] = Nothing(break) + UReturnExpression [return newResult + counter] = Nothing + UBinaryExpression (operator = +) [newResult + counter] = Undetermined (depending on: (var newResult = 42), (var counter = Undetermined)) + USimpleNameReferenceExpression (identifier = newResult) [newResult] = (var newResult = 42) + USimpleNameReferenceExpression (identifier = counter) [counter] = (var counter = Undetermined) diff --git a/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java new file mode 100644 index 000000000000..b79b9059d3be --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2017 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. + */ +public enum EnumSwitchWithoutBreaks { + FIRST, + SECOND, + THIRD; + + public static int foo(EnumSwitchWithoutBreaks key) { + int result; + switch (key) { + case FIRST: + result = 3; + break; + case SECOND: + result = 7; + case THIRD: + result = 13; + default: + result = 66; + break; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt new file mode 100644 index 000000000000..f05f090d2b70 --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumSwitchWithoutBreaks.values.txt @@ -0,0 +1,44 @@ +UFile (package = ) [public final enum EnumSwitchWithoutBreaks {...] + UClass (name = EnumSwitchWithoutBreaks) [public final enum EnumSwitchWithoutBreaks {...}] + UEnumConstant (name = FIRST) [FIRST] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitchWithoutBreaks) [EnumSwitchWithoutBreaks] = Undetermined + UEnumConstant (name = SECOND) [SECOND] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitchWithoutBreaks) [EnumSwitchWithoutBreaks] = Undetermined + UEnumConstant (name = THIRD) [THIRD] = Undetermined + USimpleNameReferenceExpression (identifier = EnumSwitchWithoutBreaks) [EnumSwitchWithoutBreaks] = Undetermined + UMethod (name = foo) [public static fun foo(key: EnumSwitchWithoutBreaks) : int {...}] + UParameter (name = key) [var key: EnumSwitchWithoutBreaks] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int] = Undetermined + ULocalVariable (name = result) [var result: int] + USwitchExpression [switch (key) ...] = Undetermined + USimpleNameReferenceExpression (identifier = key) [key] = Undetermined + UExpressionList (switch) [ FIRST -> {... ] = Undetermined + USwitchClauseExpressionWithBody [FIRST -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = FIRST) [FIRST] = FIRST (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 3] = 3 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 3) [3] = 3 + UBreakExpression (label = null) [break] = Nothing(break) + USwitchClauseExpressionWithBody [SECOND -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = SECOND) [SECOND] = SECOND (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 7] = 7 + USimpleNameReferenceExpression (identifier = result) [result] = (var result = Undetermined) + ULiteralExpression (value = 7) [7] = 7 + USwitchClauseExpressionWithBody [THIRD -> {...] = Undetermined + USimpleNameReferenceExpression (identifier = THIRD) [THIRD] = THIRD (enum entry) + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 13] = 13 + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 7), (var result = Undetermined)) + ULiteralExpression (value = 13) [13] = 13 + USwitchClauseExpressionWithBody [else -> {...] = Undetermined + UDefaultCaseExpression [else] = Undetermined + UExpressionList (switch_entry) [{...] = Undetermined + UBinaryExpression (operator = =) [result = 66] = 66 + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 13), (var result = Undetermined)) + ULiteralExpression (value = 66) [66] = 66 + UBreakExpression (label = null) [break] = Nothing(break) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = 3), (var result = 66)) diff --git a/uast/uast-tests/java/Simple/EnumValueMembers.java b/uast/uast-tests/java/Simple/EnumValueMembers.java new file mode 100644 index 000000000000..969a169b8ceb --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumValueMembers.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2017 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. + */ +public enum Style { + SHEET("foo") { + @Override + public String getExitAnimation() { + return "bar"; + } + }; + + Style(String s) { + } + + public String getExitAnimation() { + return null; + } +} + diff --git a/uast/uast-tests/java/Simple/EnumValueMembers.log.txt b/uast/uast-tests/java/Simple/EnumValueMembers.log.txt new file mode 100644 index 000000000000..388659dbdbd0 --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumValueMembers.log.txt @@ -0,0 +1,18 @@ +UFile (package = ) + UClass (name = Style) + UEnumConstant (name = SHEET) + USimpleNameReferenceExpression (identifier = Style) + ULiteralExpression (value = "foo") + UClass (name = null) + UMethod (name = getExitAnimation) + UAnnotation (fqName = java.lang.Override) + UBlockExpression + UReturnExpression + ULiteralExpression (value = "bar") + UMethod (name = Style) + UParameter (name = s) + UBlockExpression + UMethod (name = getExitAnimation) + UBlockExpression + UReturnExpression + ULiteralExpression (value = null) diff --git a/uast/uast-tests/java/Simple/EnumValueMembers.render.txt b/uast/uast-tests/java/Simple/EnumValueMembers.render.txt new file mode 100644 index 000000000000..36242a0117ed --- /dev/null +++ b/uast/uast-tests/java/Simple/EnumValueMembers.render.txt @@ -0,0 +1,13 @@ +public enum Style { + SHEET("foo") { + @java.lang.Override + public fun getExitAnimation() : java.lang.String { + return "bar" + } + } + private fun Style(s: java.lang.String) { + } + public fun getExitAnimation() : java.lang.String { + return null + } +} diff --git a/uast/uast-tests/java/Simple/EvaluatorExtension.java b/uast/uast-tests/java/Simple/EvaluatorExtension.java new file mode 100644 index 000000000000..7ce432f94203 --- /dev/null +++ b/uast/uast-tests/java/Simple/EvaluatorExtension.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2017 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. + */ +public abstract class Foo { + public abstract String getTestName(boolean upper); + + public void bar() { + String t1 = getTestName(false); + String t2 = getTestName(true); + } +} diff --git a/uast/uast-tests/java/Simple/EvaluatorExtension.values.txt b/uast/uast-tests/java/Simple/EvaluatorExtension.values.txt new file mode 100644 index 000000000000..8086de82bd51 --- /dev/null +++ b/uast/uast-tests/java/Simple/EvaluatorExtension.values.txt @@ -0,0 +1,16 @@ +UFile (package = ) [public abstract class Foo {...] + UClass (name = Foo) [public abstract class Foo {...}] + UMethod (name = getTestName) [public abstract fun getTestName(upper: boolean) : java.lang.String = UastEmptyExpression] + UParameter (name = upper) [var upper: boolean] + UMethod (name = bar) [public fun bar() : void {...}] + UBlockExpression [{...}] = Undetermined + UDeclarationsExpression [var t1: java.lang.String = getTestName(false)] = Undetermined + ULocalVariable (name = t1) [var t1: java.lang.String = getTestName(false)] + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [getTestName(false)] = "lower" + UIdentifier (Identifier (getTestName)) [UIdentifier (Identifier (getTestName))] + ULiteralExpression (value = false) [false] = false + UDeclarationsExpression [var t2: java.lang.String = getTestName(true)] = Undetermined + ULocalVariable (name = t2) [var t2: java.lang.String = getTestName(true)] + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [getTestName(true)] = "UPPER" + UIdentifier (Identifier (getTestName)) [UIdentifier (Identifier (getTestName))] + ULiteralExpression (value = true) [true] = true diff --git a/uast/uast-tests/java/Simple/External.java b/uast/uast-tests/java/Simple/External.java new file mode 100644 index 000000000000..42b1b4bee5ec --- /dev/null +++ b/uast/uast-tests/java/Simple/External.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2017 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. + */ +import java.util.LinkedList; + +public class External { + public static boolean foo() { + return new LinkedList() == new LinkedList(); + } + + public static boolean bar() { + List list = new LinkedList(); + return list == list; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/External.values.txt b/uast/uast-tests/java/Simple/External.values.txt new file mode 100644 index 000000000000..ae5881ee5965 --- /dev/null +++ b/uast/uast-tests/java/Simple/External.values.txt @@ -0,0 +1,21 @@ +UFile (package = ) [import java.util.LinkedList...] + UImportStatement (isOnDemand = false) [import java.util.LinkedList] + UClass (name = External) [public class External {...}] + UMethod (name = foo) [public static fun foo() : boolean {...}] + UBlockExpression [{...}] = Nothing + UReturnExpression [return LinkedList() === LinkedList()] = Nothing + UBinaryExpression (operator = ===) [LinkedList() === LinkedList()] = Undetermined + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()() + USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList() + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()() + USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList() + UMethod (name = bar) [public static fun bar() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var list: List = LinkedList()] = Undetermined + ULocalVariable (name = list) [var list: List = LinkedList()] + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()() + USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList() + UReturnExpression [return list === list] = Nothing + UBinaryExpression (operator = ===) [list === list] = Undetermined (depending on: (var list = external LinkedList()())) + USimpleNameReferenceExpression (identifier = list) [list] = (var list = external LinkedList()()) + USimpleNameReferenceExpression (identifier = list) [list] = (var list = external LinkedList()()) diff --git a/uast/uast-tests/java/Simple/Field.java b/uast/uast-tests/java/Simple/Field.java new file mode 100644 index 000000000000..f29d37bcc956 --- /dev/null +++ b/uast/uast-tests/java/Simple/Field.java @@ -0,0 +1,18 @@ +/* + * Copyright 2000-2017 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. + */ +public class Simple { + public static String foo = "a"; +} diff --git a/uast/uast-tests/java/Simple/FieldRef.java b/uast/uast-tests/java/Simple/FieldRef.java new file mode 100644 index 000000000000..60954fdfc184 --- /dev/null +++ b/uast/uast-tests/java/Simple/FieldRef.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2017 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. + */ +public class Foo { + public static void bar() { + int s = Integer.SIZE; + System.out.println(s); + } +} diff --git a/uast/uast-tests/java/Simple/FieldRef.values.txt b/uast/uast-tests/java/Simple/FieldRef.values.txt new file mode 100644 index 000000000000..70a313911c62 --- /dev/null +++ b/uast/uast-tests/java/Simple/FieldRef.values.txt @@ -0,0 +1,16 @@ +UFile (package = ) [public class Foo {...] + UClass (name = Foo) [public class Foo {...}] + UMethod (name = bar) [public static fun bar() : void {...}] + UBlockExpression [{...}] = external println(s)((var s = 32)) + UDeclarationsExpression [var s: int = Integer.SIZE] = Undetermined + ULocalVariable (name = s) [var s: int = Integer.SIZE] + UQualifiedReferenceExpression [Integer.SIZE] = 32 + USimpleNameReferenceExpression (identifier = Integer) [Integer] = external Integer() + USimpleNameReferenceExpression (identifier = SIZE) [SIZE] = 32 + UQualifiedReferenceExpression [System.out.println(s)] = external println(s)((var s = 32)) + UQualifiedReferenceExpression [System.out] = Undetermined + USimpleNameReferenceExpression (identifier = System) [System] = external System() + USimpleNameReferenceExpression (identifier = out) [out] = Undetermined + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [println(s)] = external println(s)((var s = 32)) + UIdentifier (Identifier (println)) [UIdentifier (Identifier (println))] + USimpleNameReferenceExpression (identifier = s) [s] = (var s = 32) diff --git a/uast/uast-tests/java/Simple/FloatDouble.java b/uast/uast-tests/java/Simple/FloatDouble.java new file mode 100644 index 000000000000..e66365bdd84e --- /dev/null +++ b/uast/uast-tests/java/Simple/FloatDouble.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2017 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. + */ +public class FloatDouble { + public static double foo() { + float f1 = 1.0F; + double d2 = 2.0; + double d3 = f1 + d2; + float f2 = f1 + f1; + float f3 = (float) d3; + double d1 = (double) f1; + return d1 + f1 + f2 + f3; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/FloatDouble.values.txt b/uast/uast-tests/java/Simple/FloatDouble.values.txt new file mode 100644 index 000000000000..ee1d2a94717c --- /dev/null +++ b/uast/uast-tests/java/Simple/FloatDouble.values.txt @@ -0,0 +1,36 @@ +UFile (package = ) [public class FloatDouble {...] + UClass (name = FloatDouble) [public class FloatDouble {...}] + UMethod (name = foo) [public static fun foo() : double {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var f1: float = 1.0] = Undetermined + ULocalVariable (name = f1) [var f1: float = 1.0] + ULiteralExpression (value = 1.0) [1.0] = (float)1.0 + UDeclarationsExpression [var d2: double = 2.0] = Undetermined + ULocalVariable (name = d2) [var d2: double = 2.0] + ULiteralExpression (value = 2.0) [2.0] = 2.0 + UDeclarationsExpression [var d3: double = f1 + d2] = Undetermined + ULocalVariable (name = d3) [var d3: double = f1 + d2] + UBinaryExpression (operator = +) [f1 + d2] = 3.0 (depending on: (var f1 = (float)1.0), (var d2 = 2.0)) + USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0) + USimpleNameReferenceExpression (identifier = d2) [d2] = (var d2 = 2.0) + UDeclarationsExpression [var f2: float = f1 + f1] = Undetermined + ULocalVariable (name = f2) [var f2: float = f1 + f1] + UBinaryExpression (operator = +) [f1 + f1] = (float)2.0 (depending on: (var f1 = (float)1.0)) + USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0) + USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0) + UDeclarationsExpression [var f3: float = d3 as float] = Undetermined + ULocalVariable (name = f3) [var f3: float = d3 as float] + UBinaryExpressionWithType [d3 as float] = (float)3.0 + USimpleNameReferenceExpression (identifier = d3) [d3] = (var d3 = 3.0 (depending on: (var f1 = (float)1.0), (var d2 = 2.0))) + UTypeReferenceExpression (name = float) [float] = Undetermined + UDeclarationsExpression [var d1: double = f1 as double] = Undetermined + ULocalVariable (name = d1) [var d1: double = f1 as double] + UBinaryExpressionWithType [f1 as double] = 1.0 + USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0) + UTypeReferenceExpression (name = double) [double] = Undetermined + UReturnExpression [return d1 + f1 + f2 + f3] = Nothing + UPolyadicExpression (operator = +) [d1 + f1 + f2 + f3] = 7.0 (depending on: (var d1 = 1.0), (var f1 = (float)1.0), (var f2 = (float)2.0 (depending on: (var f1 = (float)1.0))), (var f3 = (float)3.0)) + USimpleNameReferenceExpression (identifier = d1) [d1] = (var d1 = 1.0) + USimpleNameReferenceExpression (identifier = f1) [f1] = (var f1 = (float)1.0) + USimpleNameReferenceExpression (identifier = f2) [f2] = (var f2 = (float)2.0 (depending on: (var f1 = (float)1.0))) + USimpleNameReferenceExpression (identifier = f3) [f3] = (var f3 = (float)3.0) diff --git a/uast/uast-tests/java/Simple/For.java b/uast/uast-tests/java/Simple/For.java new file mode 100644 index 000000000000..890908365954 --- /dev/null +++ b/uast/uast-tests/java/Simple/For.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2017 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. + */ +public class For { + public static int foo() { + int result = 0; + for (int i = 0; i < 10; i++) { + result = result + i; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/For.values.txt b/uast/uast-tests/java/Simple/For.values.txt new file mode 100644 index 000000000000..23f047977deb --- /dev/null +++ b/uast/uast-tests/java/Simple/For.values.txt @@ -0,0 +1,24 @@ +UFile (package = ) [public class For {...] + UClass (name = For) [public class For {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int = 0] = Undetermined + ULocalVariable (name = result) [var result: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UForExpression [for (var i: int = 0; i < 10; i++) {...}] = Undetermined + UDeclarationsExpression [var i: int = 0] = Undetermined + ULocalVariable (name = i) [var i: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UBinaryExpression (operator = <) [i < 10] = Undetermined + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + ULiteralExpression (value = 10) [10] = 10 + UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + UBlockExpression [{...}] = Undetermined + UBinaryExpression (operator = =) [result = result + i] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0)) + UBinaryExpression (operator = +) [result + i] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0)) + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0)) diff --git a/uast/uast-tests/java/Simple/ForEach.java b/uast/uast-tests/java/Simple/ForEach.java new file mode 100644 index 000000000000..da4089f53351 --- /dev/null +++ b/uast/uast-tests/java/Simple/ForEach.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2017 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. + */ +public class For { + public static int sum(List numbers) { + int result = 0; + for (int number: numbers) { + result = result + number; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ForEach.values.txt b/uast/uast-tests/java/Simple/ForEach.values.txt new file mode 100644 index 000000000000..9de4c4192e3b --- /dev/null +++ b/uast/uast-tests/java/Simple/ForEach.values.txt @@ -0,0 +1,18 @@ +UFile (package = ) [public class For {...] + UClass (name = For) [public class For {...}] + UMethod (name = sum) [public static fun sum(numbers: List) : int {...}] + UParameter (name = numbers) [var numbers: List] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int = 0] = Undetermined + ULocalVariable (name = result) [var result: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UForEachExpression [for (number : numbers) {...}] = Undetermined + USimpleNameReferenceExpression (identifier = numbers) [numbers] = Undetermined + UBlockExpression [{...}] = Undetermined + UBinaryExpression (operator = =) [result = result + number] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0)) + UBinaryExpression (operator = +) [result + number] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0)) + USimpleNameReferenceExpression (identifier = number) [number] = Undetermined + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0)) diff --git a/uast/uast-tests/java/Simple/ForEachMutableIterable.java b/uast/uast-tests/java/Simple/ForEachMutableIterable.java new file mode 100644 index 000000000000..bec500fa634d --- /dev/null +++ b/uast/uast-tests/java/Simple/ForEachMutableIterable.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2017 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. + */ +import java.util.*; + +public class For { + + public static List getList(int size) { + List result = new LinkedList(); + int a = 0; + for (int i = a++; i < size; i++) { + result.add(i); + } + result.add(a); + return result; + } + + public static int sum(List numbers) { + int result = 0; + int size = 3; + for (int number: getList(++size)) { + result = result + number; + } + return result + size; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt b/uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt new file mode 100644 index 000000000000..11b4815d6d7d --- /dev/null +++ b/uast/uast-tests/java/Simple/ForEachMutableIterable.values.txt @@ -0,0 +1,60 @@ +UFile (package = ) [import java.util...] + UImportStatement (isOnDemand = true) [import java.util] + UClass (name = For) [public class For {...}] + UMethod (name = getList) [public static fun getList(size: int) : java.util.List {...}] + UParameter (name = size) [var size: int] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: java.util.List = LinkedList()] = Undetermined + ULocalVariable (name = result) [var result: java.util.List = LinkedList()] + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) [LinkedList()] = external LinkedList()() + USimpleNameReferenceExpression (identifier = LinkedList) [LinkedList] = external LinkedList() + UDeclarationsExpression [var a: int = 0] = Undetermined + ULocalVariable (name = a) [var a: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UForExpression [for (var i: int = a++; i < size; i++) {...}] = Undetermined + UDeclarationsExpression [var i: int = a++] = Undetermined + ULocalVariable (name = i) [var i: int = a++] + UPostfixExpression (operator = ++) [a++] = (var a = 0) + USimpleNameReferenceExpression (identifier = a) [a] = (var a = 0) + UBinaryExpression (operator = <) [i < size] = Undetermined + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))) + USimpleNameReferenceExpression (identifier = size) [size] = Undetermined + UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))) + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))) + UBlockExpression [{...}] = external add(i)(Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))) + UQualifiedReferenceExpression [result.add(i)] = external add(i)(Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))) + USimpleNameReferenceExpression (identifier = result) [result] = (var result = external LinkedList()()) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [add(i)] = external add(i)(Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0)))) + UIdentifier (Identifier (add)) [UIdentifier (Identifier (add))] + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = (var a = 0))) + UQualifiedReferenceExpression [result.add(a)] = external add(a)((var a = 1)) + USimpleNameReferenceExpression (identifier = result) [result] = (var result = external LinkedList()()) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [add(a)] = external add(a)((var a = 1)) + UIdentifier (Identifier (add)) [UIdentifier (Identifier (add))] + USimpleNameReferenceExpression (identifier = a) [a] = (var a = 1) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = (var result = external LinkedList()()) + UMethod (name = sum) [public static fun sum(numbers: java.util.List) : int {...}] + UParameter (name = numbers) [var numbers: java.util.List] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int = 0] = Undetermined + ULocalVariable (name = result) [var result: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UDeclarationsExpression [var size: int = 3] = Undetermined + ULocalVariable (name = size) [var size: int = 3] + ULiteralExpression (value = 3) [3] = 3 + UForEachExpression [for (number : getList(++size)) {...}] = Undetermined + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [getList(++size)] = external getList(++size)(4 (depending on: (var size = 3))) + UIdentifier (Identifier (getList)) [UIdentifier (Identifier (getList))] + UPrefixExpression (operator = ++) [++size] = 4 (depending on: (var size = 3)) + USimpleNameReferenceExpression (identifier = size) [size] = (var size = 3) + UBlockExpression [{...}] = Undetermined + UBinaryExpression (operator = =) [result = result + number] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0)) + UBinaryExpression (operator = +) [result + number] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0)) + USimpleNameReferenceExpression (identifier = number) [number] = Undetermined + UReturnExpression [return result + size] = Nothing + UBinaryExpression (operator = +) [result + size] = Undetermined (depending on: (var size = 4)) + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0)) + USimpleNameReferenceExpression (identifier = size) [size] = (var size = 4) diff --git a/uast/uast-tests/java/Simple/IdentityEquals.java b/uast/uast-tests/java/Simple/IdentityEquals.java new file mode 100644 index 000000000000..4a1661cd7ec7 --- /dev/null +++ b/uast/uast-tests/java/Simple/IdentityEquals.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2017 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. + */ +public class IdentityEquals { + public static boolean foo() { + Integer i1 = 111; + Integer i2 = 222; + Integer i12 = i1 + i2; + Integer i21 = i2 + i1; + return i12 == i21; + } + + public static boolean bar() { + String s1 = "hello"; + String s2 = s1 + s1; + String s3 = "hellohello"; + return s2 == s3; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/IdentityEquals.values.txt b/uast/uast-tests/java/Simple/IdentityEquals.values.txt new file mode 100644 index 000000000000..893208fe9337 --- /dev/null +++ b/uast/uast-tests/java/Simple/IdentityEquals.values.txt @@ -0,0 +1,41 @@ +UFile (package = ) [public class IdentityEquals {...] + UClass (name = IdentityEquals) [public class IdentityEquals {...}] + UMethod (name = foo) [public static fun foo() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var i1: java.lang.Integer = 111] = Undetermined + ULocalVariable (name = i1) [var i1: java.lang.Integer = 111] + ULiteralExpression (value = 111) [111] = 111 + UDeclarationsExpression [var i2: java.lang.Integer = 222] = Undetermined + ULocalVariable (name = i2) [var i2: java.lang.Integer = 222] + ULiteralExpression (value = 222) [222] = 222 + UDeclarationsExpression [var i12: java.lang.Integer = i1 + i2] = Undetermined + ULocalVariable (name = i12) [var i12: java.lang.Integer = i1 + i2] + UBinaryExpression (operator = +) [i1 + i2] = 333 (depending on: (var i1 = 111), (var i2 = 222)) + USimpleNameReferenceExpression (identifier = i1) [i1] = (var i1 = 111) + USimpleNameReferenceExpression (identifier = i2) [i2] = (var i2 = 222) + UDeclarationsExpression [var i21: java.lang.Integer = i2 + i1] = Undetermined + ULocalVariable (name = i21) [var i21: java.lang.Integer = i2 + i1] + UBinaryExpression (operator = +) [i2 + i1] = 333 (depending on: (var i2 = 222), (var i1 = 111)) + USimpleNameReferenceExpression (identifier = i2) [i2] = (var i2 = 222) + USimpleNameReferenceExpression (identifier = i1) [i1] = (var i1 = 111) + UReturnExpression [return i12 === i21] = Nothing + UBinaryExpression (operator = ===) [i12 === i21] = Undetermined + USimpleNameReferenceExpression (identifier = i12) [i12] = (var i12 = 333 (depending on: (var i1 = 111), (var i2 = 222))) + USimpleNameReferenceExpression (identifier = i21) [i21] = (var i21 = 333 (depending on: (var i2 = 222), (var i1 = 111))) + UMethod (name = bar) [public static fun bar() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var s1: java.lang.String = "hello"] = Undetermined + ULocalVariable (name = s1) [var s1: java.lang.String = "hello"] + ULiteralExpression (value = "hello") ["hello"] = "hello" + UDeclarationsExpression [var s2: java.lang.String = s1 + s1] = Undetermined + ULocalVariable (name = s2) [var s2: java.lang.String = s1 + s1] + UBinaryExpression (operator = +) [s1 + s1] = "hellohello" (depending on: (var s1 = "hello")) + USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "hello") + USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "hello") + UDeclarationsExpression [var s3: java.lang.String = "hellohello"] = Undetermined + ULocalVariable (name = s3) [var s3: java.lang.String = "hellohello"] + ULiteralExpression (value = "hellohello") ["hellohello"] = "hellohello" + UReturnExpression [return s2 === s3] = Nothing + UBinaryExpression (operator = ===) [s2 === s3] = Undetermined + USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = "hellohello" (depending on: (var s1 = "hello"))) + USimpleNameReferenceExpression (identifier = s3) [s3] = (var s3 = "hellohello") diff --git a/uast/uast-tests/java/Simple/ImmutableField.java b/uast/uast-tests/java/Simple/ImmutableField.java new file mode 100644 index 000000000000..243b610d65fa --- /dev/null +++ b/uast/uast-tests/java/Simple/ImmutableField.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class ImmutableField { + final int immutable; + + public ImmutableField() { + immutable = 1; + bar(immutable); + bar(immutable); + } + + public static int bar(int arg) { + return arg; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ImmutableField.values.txt b/uast/uast-tests/java/Simple/ImmutableField.values.txt new file mode 100644 index 000000000000..66381b3068b8 --- /dev/null +++ b/uast/uast-tests/java/Simple/ImmutableField.values.txt @@ -0,0 +1,19 @@ +UFile (package = ) [public class ImmutableField {...] + UClass (name = ImmutableField) [public class ImmutableField {...}] + UField (name = immutable) [final var immutable: int] + UMethod (name = ImmutableField) [public fun ImmutableField() {...}] + UBlockExpression [{...}] = external bar(immutable)((var immutable = 1)) + UBinaryExpression (operator = =) [immutable = 1] = 1 + USimpleNameReferenceExpression (identifier = immutable) [immutable] = Undetermined + ULiteralExpression (value = 1) [1] = 1 + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [bar(immutable)] = external bar(immutable)((var immutable = 1)) + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + USimpleNameReferenceExpression (identifier = immutable) [immutable] = (var immutable = 1) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [bar(immutable)] = external bar(immutable)((var immutable = 1)) + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + USimpleNameReferenceExpression (identifier = immutable) [immutable] = (var immutable = 1) + UMethod (name = bar) [public static fun bar(arg: int) : int {...}] + UParameter (name = arg) [var arg: int] + UBlockExpression [{...}] = Nothing + UReturnExpression [return arg] = Nothing + USimpleNameReferenceExpression (identifier = arg) [arg] = Undetermined diff --git a/uast/uast-tests/java/Simple/IncDec.java b/uast/uast-tests/java/Simple/IncDec.java new file mode 100644 index 000000000000..3706f0386acf --- /dev/null +++ b/uast/uast-tests/java/Simple/IncDec.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2017 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. + */ +public class IncDec { + public static int foo() { + int i1 = 1; // 1 + int i2 = ++i1; // 2, 2 + int i3 = i2++; // 2, 3 + int i4 = --i3; // 1, 1 + int i5 = i4--; // 1, 0 + return i4 + i5;// 1 + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/IncDec.values.txt b/uast/uast-tests/java/Simple/IncDec.values.txt new file mode 100644 index 000000000000..a59a78c6b32f --- /dev/null +++ b/uast/uast-tests/java/Simple/IncDec.values.txt @@ -0,0 +1,27 @@ +UFile (package = ) [public class IncDec {...] + UClass (name = IncDec) [public class IncDec {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var i1: int = 1] = Undetermined + ULocalVariable (name = i1) [var i1: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var i2: int = ++i1] = Undetermined + ULocalVariable (name = i2) [var i2: int = ++i1] + UPrefixExpression (operator = ++) [++i1] = 2 (depending on: (var i1 = 1)) + USimpleNameReferenceExpression (identifier = i1) [i1] = (var i1 = 1) + UDeclarationsExpression [var i3: int = i2++] = Undetermined + ULocalVariable (name = i3) [var i3: int = i2++] + UPostfixExpression (operator = ++) [i2++] = (var i2 = 2 (depending on: (var i1 = 1))) + USimpleNameReferenceExpression (identifier = i2) [i2] = (var i2 = 2 (depending on: (var i1 = 1))) + UDeclarationsExpression [var i4: int = --i3] = Undetermined + ULocalVariable (name = i4) [var i4: int = --i3] + UPrefixExpression (operator = --) [--i3] = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1))))) + USimpleNameReferenceExpression (identifier = i3) [i3] = (var i3 = (var i2 = 2 (depending on: (var i1 = 1)))) + UDeclarationsExpression [var i5: int = i4--] = Undetermined + ULocalVariable (name = i5) [var i5: int = i4--] + UPostfixExpression (operator = --) [i4--] = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1)))))) + USimpleNameReferenceExpression (identifier = i4) [i4] = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1)))))) + UReturnExpression [return i4 + i5] = Nothing + UBinaryExpression (operator = +) [i4 + i5] = 1 (depending on: (var i4 = 0), (var i5 = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1)))))))) + USimpleNameReferenceExpression (identifier = i4) [i4] = (var i4 = 0) + USimpleNameReferenceExpression (identifier = i5) [i5] = (var i5 = (var i4 = 1 (depending on: (var i3 = (var i2 = 2 (depending on: (var i1 = 1))))))) diff --git a/uast/uast-tests/java/Simple/IntLong.java b/uast/uast-tests/java/Simple/IntLong.java new file mode 100644 index 000000000000..c092f0fe0952 --- /dev/null +++ b/uast/uast-tests/java/Simple/IntLong.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2017 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. + */ +public class IntLong { + public static long foo() { + int one = 1; + int two = one + one; + int four = two * two; + int sixteen = four * four; + int twoPowerEight = sixteen * sixteen; + int twoPowerSixteen = twoPowerEight * twoPowerEight; + int twoPowerTwentyFour = twoPowerSixteen * twoPowerEight; + int twoPowerThirtyTwo = twoPowerSixteen * twoPowerSixteen; + + long twoPowerFourty = ((long) twoPowerSixteen) * ((long) twoPowerTwentyFour); + long eight = 8L; + long twoPowerFourtyThree = twoPowerFourty * eight; + long twoPowerFourtyEight = twoPowerFourty * twoPowerEight; + long twoPowerFiftySix = twoPowerEight * twoPowerFourty; + return twoPowerFiftySix; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/IntLong.values.txt b/uast/uast-tests/java/Simple/IntLong.values.txt new file mode 100644 index 000000000000..f88de3aac911 --- /dev/null +++ b/uast/uast-tests/java/Simple/IntLong.values.txt @@ -0,0 +1,73 @@ +UFile (package = ) [public class IntLong {...] + UClass (name = IntLong) [public class IntLong {...}] + UMethod (name = foo) [public static fun foo() : long {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var one: int = 1] = Undetermined + ULocalVariable (name = one) [var one: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var two: int = one + one] = Undetermined + ULocalVariable (name = two) [var two: int = one + one] + UBinaryExpression (operator = +) [one + one] = 2 (depending on: (var one = 1)) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1) + UDeclarationsExpression [var four: int = two * two] = Undetermined + ULocalVariable (name = four) [var four: int = two * two] + UBinaryExpression (operator = *) [two * two] = 4 (depending on: (var two = 2 (depending on: (var one = 1)))) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2 (depending on: (var one = 1))) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2 (depending on: (var one = 1))) + UDeclarationsExpression [var sixteen: int = four * four] = Undetermined + ULocalVariable (name = sixteen) [var sixteen: int = four * four] + UBinaryExpression (operator = *) [four * four] = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))) + USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))) + USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))) + UDeclarationsExpression [var twoPowerEight: int = sixteen * sixteen] = Undetermined + ULocalVariable (name = twoPowerEight) [var twoPowerEight: int = sixteen * sixteen] + UBinaryExpression (operator = *) [sixteen * sixteen] = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))) + USimpleNameReferenceExpression (identifier = sixteen) [sixteen] = (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))) + USimpleNameReferenceExpression (identifier = sixteen) [sixteen] = (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))) + UDeclarationsExpression [var twoPowerSixteen: int = twoPowerEight * twoPowerEight] = Undetermined + ULocalVariable (name = twoPowerSixteen) [var twoPowerSixteen: int = twoPowerEight * twoPowerEight] + UBinaryExpression (operator = *) [twoPowerEight * twoPowerEight] = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))) + USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))) + USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))) + UDeclarationsExpression [var twoPowerTwentyFour: int = twoPowerSixteen * twoPowerEight] = Undetermined + ULocalVariable (name = twoPowerTwentyFour) [var twoPowerTwentyFour: int = twoPowerSixteen * twoPowerEight] + UBinaryExpression (operator = *) [twoPowerSixteen * twoPowerEight] = 16777216 (depending on: (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))), (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))) + USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))) + USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))) + UDeclarationsExpression [var twoPowerThirtyTwo: int = twoPowerSixteen * twoPowerSixteen] = Undetermined + ULocalVariable (name = twoPowerThirtyTwo) [var twoPowerThirtyTwo: int = twoPowerSixteen * twoPowerSixteen] + UBinaryExpression (operator = *) [twoPowerSixteen * twoPowerSixteen] = 0 (depending on: (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))))) + USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))) + USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))) + UDeclarationsExpression [var twoPowerFourty: long = (twoPowerSixteen as long) * (twoPowerTwentyFour as long)] = Undetermined + ULocalVariable (name = twoPowerFourty) [var twoPowerFourty: long = (twoPowerSixteen as long) * (twoPowerTwentyFour as long)] + UBinaryExpression (operator = *) [(twoPowerSixteen as long) * (twoPowerTwentyFour as long)] = (long)1099511627776 + UParenthesizedExpression [(twoPowerSixteen as long)] = (long)65536 + UBinaryExpressionWithType [twoPowerSixteen as long] = (long)65536 + USimpleNameReferenceExpression (identifier = twoPowerSixteen) [twoPowerSixteen] = (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))) + UTypeReferenceExpression (name = long) [long] = Undetermined + UParenthesizedExpression [(twoPowerTwentyFour as long)] = (long)16777216 + UBinaryExpressionWithType [twoPowerTwentyFour as long] = (long)16777216 + USimpleNameReferenceExpression (identifier = twoPowerTwentyFour) [twoPowerTwentyFour] = (var twoPowerTwentyFour = 16777216 (depending on: (var twoPowerSixteen = 65536 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))), (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))))) + UTypeReferenceExpression (name = long) [long] = Undetermined + UDeclarationsExpression [var eight: long = 8] = Undetermined + ULocalVariable (name = eight) [var eight: long = 8] + ULiteralExpression (value = 8) [8] = (long)8 + UDeclarationsExpression [var twoPowerFourtyThree: long = twoPowerFourty * eight] = Undetermined + ULocalVariable (name = twoPowerFourtyThree) [var twoPowerFourtyThree: long = twoPowerFourty * eight] + UBinaryExpression (operator = *) [twoPowerFourty * eight] = (long)8796093022208 (depending on: (var twoPowerFourty = (long)1099511627776), (var eight = (long)8)) + USimpleNameReferenceExpression (identifier = twoPowerFourty) [twoPowerFourty] = (var twoPowerFourty = (long)1099511627776) + USimpleNameReferenceExpression (identifier = eight) [eight] = (var eight = (long)8) + UDeclarationsExpression [var twoPowerFourtyEight: long = twoPowerFourty * twoPowerEight] = Undetermined + ULocalVariable (name = twoPowerFourtyEight) [var twoPowerFourtyEight: long = twoPowerFourty * twoPowerEight] + UBinaryExpression (operator = *) [twoPowerFourty * twoPowerEight] = (long)281474976710656 (depending on: (var twoPowerFourty = (long)1099511627776), (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1)))))))))) + USimpleNameReferenceExpression (identifier = twoPowerFourty) [twoPowerFourty] = (var twoPowerFourty = (long)1099511627776) + USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))) + UDeclarationsExpression [var twoPowerFiftySix: long = twoPowerEight * twoPowerFourty] = Undetermined + ULocalVariable (name = twoPowerFiftySix) [var twoPowerFiftySix: long = twoPowerEight * twoPowerFourty] + UBinaryExpression (operator = *) [twoPowerEight * twoPowerFourty] = (long)281474976710656 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))), (var twoPowerFourty = (long)1099511627776)) + USimpleNameReferenceExpression (identifier = twoPowerEight) [twoPowerEight] = (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))) + USimpleNameReferenceExpression (identifier = twoPowerFourty) [twoPowerFourty] = (var twoPowerFourty = (long)1099511627776) + UReturnExpression [return twoPowerFiftySix] = Nothing + USimpleNameReferenceExpression (identifier = twoPowerFiftySix) [twoPowerFiftySix] = (var twoPowerFiftySix = (long)281474976710656 (depending on: (var twoPowerEight = 256 (depending on: (var sixteen = 16 (depending on: (var four = 4 (depending on: (var two = 2 (depending on: (var one = 1))))))))), (var twoPowerFourty = (long)1099511627776))) diff --git a/uast/uast-tests/java/Simple/Labeled.java b/uast/uast-tests/java/Simple/Labeled.java new file mode 100644 index 000000000000..98a142acba67 --- /dev/null +++ b/uast/uast-tests/java/Simple/Labeled.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class Labeled { + public static int foo() { + int first = 1; + int second = 2; + + labeled: while (true) { + second = 3; + if (first > 0) break labeled; + } + + return second; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Labeled.values.txt b/uast/uast-tests/java/Simple/Labeled.values.txt new file mode 100644 index 000000000000..e0fa02bda527 --- /dev/null +++ b/uast/uast-tests/java/Simple/Labeled.values.txt @@ -0,0 +1,25 @@ +UFile (package = ) [public class Labeled {...] + UClass (name = Labeled) [public class Labeled {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var first: int = 1] = Undetermined + ULocalVariable (name = first) [var first: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var second: int = 2] = Undetermined + ULocalVariable (name = second) [var second: int = 2] + ULiteralExpression (value = 2) [2] = 2 + ULabeledExpression (label = labeled) [labeled@ while (true) {...}] = Undetermined + UWhileExpression [while (true) {...}] = Undetermined + ULiteralExpression (value = true) [true] = true + UBlockExpression [{...}] = Nothing(break) + UBinaryExpression (operator = =) [second = 3] = 3 + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2) + ULiteralExpression (value = 3) [3] = 3 + UIfExpression [if (first > 0) break@labeled] = Nothing(break) + UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1) + ULiteralExpression (value = 0) [0] = 0 + UBreakExpression (label = labeled) [break@labeled] = Nothing(break) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UReturnExpression [return second] = Nothing + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3) diff --git a/uast/uast-tests/java/Simple/LabeledOuter.java b/uast/uast-tests/java/Simple/LabeledOuter.java new file mode 100644 index 000000000000..7fdd00fcbb86 --- /dev/null +++ b/uast/uast-tests/java/Simple/LabeledOuter.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 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. + */ +public class LabeledOuter { + public static int foo() { + + int second = 2; + labeled: for (int first = 1; first < 4; first++) { + while (second < 10) { + second = 3; + if (first > 0) break labeled; + } + second = 4; + } + + return second; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/LabeledOuter.values.txt b/uast/uast-tests/java/Simple/LabeledOuter.values.txt new file mode 100644 index 000000000000..f9fba44b5ce0 --- /dev/null +++ b/uast/uast-tests/java/Simple/LabeledOuter.values.txt @@ -0,0 +1,37 @@ +UFile (package = ) [public class LabeledOuter {...] + UClass (name = LabeledOuter) [public class LabeledOuter {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var second: int = 2] = Undetermined + ULocalVariable (name = second) [var second: int = 2] + ULiteralExpression (value = 2) [2] = 2 + ULabeledExpression (label = labeled) [labeled@ for (var first: int = 1; first < 4; first++) {...}] = Undetermined + UForExpression [for (var first: int = 1; first < 4; first++) {...}] = Undetermined + UDeclarationsExpression [var first: int = 1] = Undetermined + ULocalVariable (name = first) [var first: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UBinaryExpression (operator = <) [first < 4] = true (depending on: (var first = 1)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1) + ULiteralExpression (value = 4) [4] = 4 + UPostfixExpression (operator = ++) [first++] = Undetermined + USimpleNameReferenceExpression (identifier = first) [first] = Undetermined + UBlockExpression [{...}] = Nothing(break) + UWhileExpression [while (second < 10) {...}] = Nothing(break) + UBinaryExpression (operator = <) [second < 10] = true (depending on: (var second = 2)) + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2) + ULiteralExpression (value = 10) [10] = 10 + UBlockExpression [{...}] = Nothing(break) + UBinaryExpression (operator = =) [second = 3] = 3 + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2) + ULiteralExpression (value = 3) [3] = 3 + UIfExpression [if (first > 0) break@labeled] = Nothing(break) + UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1) + ULiteralExpression (value = 0) [0] = 0 + UBreakExpression (label = labeled) [break@labeled] = Nothing(break) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UBinaryExpression (operator = =) [second = 4] = 4 + USimpleNameReferenceExpression (identifier = second) [second] = Undetermined + ULiteralExpression (value = 4) [4] = 4 + UReturnExpression [return second] = Nothing + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3) diff --git a/uast/uast-tests/java/Simple/Lambda.java b/uast/uast-tests/java/Simple/Lambda.java new file mode 100644 index 000000000000..73132ada0cd8 --- /dev/null +++ b/uast/uast-tests/java/Simple/Lambda.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class Lambda { + public static int foo() { + int variable = 42; + + Runnable runnable = () -> { + int variable1 = 24; + variable1++; + }; + runnable.run(); + + return variable; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Lambda.values.txt b/uast/uast-tests/java/Simple/Lambda.values.txt new file mode 100644 index 000000000000..24ffdef44238 --- /dev/null +++ b/uast/uast-tests/java/Simple/Lambda.values.txt @@ -0,0 +1,22 @@ +UFile (package = ) [public class Lambda {...] + UClass (name = Lambda) [public class Lambda {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var variable: int = 42] = Undetermined + ULocalVariable (name = variable) [var variable: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UDeclarationsExpression [var runnable: java.lang.Runnable = { {...}] = Undetermined + ULocalVariable (name = runnable) [var runnable: java.lang.Runnable = { {...}] + ULambdaExpression [{ {...}] = Undetermined + UBlockExpression [{...}] = (var variable1 = 24) + UDeclarationsExpression [var variable1: int = 24] = Undetermined + ULocalVariable (name = variable1) [var variable1: int = 24] + ULiteralExpression (value = 24) [24] = 24 + UPostfixExpression (operator = ++) [variable1++] = (var variable1 = 24) + USimpleNameReferenceExpression (identifier = variable1) [variable1] = (var variable1 = 24) + UQualifiedReferenceExpression [runnable.run()] = external run()() + USimpleNameReferenceExpression (identifier = runnable) [runnable] = (var runnable = Undetermined) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [run()] = external run()() + UIdentifier (Identifier (run)) [UIdentifier (Identifier (run))] + UReturnExpression [return variable] = Nothing + USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 42) diff --git a/uast/uast-tests/java/Simple/LocalClass.java b/uast/uast-tests/java/Simple/LocalClass.java new file mode 100644 index 000000000000..bbde570f9b60 --- /dev/null +++ b/uast/uast-tests/java/Simple/LocalClass.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2017 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. + */ +public class LocalClass { + public static int foo() { + + class Local {}; + + return new Local().hashCode(); + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/LocalClass.log.txt b/uast/uast-tests/java/Simple/LocalClass.log.txt new file mode 100644 index 000000000000..ea3fbc4c0482 --- /dev/null +++ b/uast/uast-tests/java/Simple/LocalClass.log.txt @@ -0,0 +1,13 @@ +UFile (package = ) + UClass (name = LocalClass) + UMethod (name = foo) + UBlockExpression + UDeclarationsExpression + UClass (name = Local) + UastEmptyExpression + UReturnExpression + UQualifiedReferenceExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) + USimpleNameReferenceExpression (identifier = Local) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (hashCode)) diff --git a/uast/uast-tests/java/Simple/LocalClass.render.txt b/uast/uast-tests/java/Simple/LocalClass.render.txt new file mode 100644 index 000000000000..cbafd0e13e3c --- /dev/null +++ b/uast/uast-tests/java/Simple/LocalClass.render.txt @@ -0,0 +1,8 @@ +public class LocalClass { + public static fun foo() : int { + class Local { + } + UastEmptyExpression + return Local().hashCode() + } +} diff --git a/uast/uast-tests/java/Simple/Logicals.java b/uast/uast-tests/java/Simple/Logicals.java new file mode 100644 index 000000000000..13cb161cc8b8 --- /dev/null +++ b/uast/uast-tests/java/Simple/Logicals.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class Logicals { + public static boolean foo() { + int one = 1; + int two = 2; + int three = 3; + int four = 4; + boolean b1 = two > one && four > three; + boolean b2 = one > two && four > three; + boolean b3 = b1 || b2; + boolean b4 = two > one || three > four; + return b1 && !b2 && b3 && b4; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Logicals.values.txt b/uast/uast-tests/java/Simple/Logicals.values.txt new file mode 100644 index 000000000000..ac9f049a7a3d --- /dev/null +++ b/uast/uast-tests/java/Simple/Logicals.values.txt @@ -0,0 +1,55 @@ +UFile (package = ) [public class Logicals {...] + UClass (name = Logicals) [public class Logicals {...}] + UMethod (name = foo) [public static fun foo() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var one: int = 1] = Undetermined + ULocalVariable (name = one) [var one: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var two: int = 2] = Undetermined + ULocalVariable (name = two) [var two: int = 2] + ULiteralExpression (value = 2) [2] = 2 + UDeclarationsExpression [var three: int = 3] = Undetermined + ULocalVariable (name = three) [var three: int = 3] + ULiteralExpression (value = 3) [3] = 3 + UDeclarationsExpression [var four: int = 4] = Undetermined + ULocalVariable (name = four) [var four: int = 4] + ULiteralExpression (value = 4) [4] = 4 + UDeclarationsExpression [var b1: boolean = two > one && four > three] = Undetermined + ULocalVariable (name = b1) [var b1: boolean = two > one && four > three] + UBinaryExpression (operator = &&) [two > one && four > three] = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3)) + UBinaryExpression (operator = >) [two > one] = true (depending on: (var two = 2), (var one = 1)) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1) + UBinaryExpression (operator = >) [four > three] = true (depending on: (var four = 4), (var three = 3)) + USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4) + USimpleNameReferenceExpression (identifier = three) [three] = (var three = 3) + UDeclarationsExpression [var b2: boolean = one > two && four > three] = Undetermined + ULocalVariable (name = b2) [var b2: boolean = one > two && four > three] + UBinaryExpression (operator = &&) [one > two && four > three] = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3)) + UBinaryExpression (operator = >) [one > two] = false (depending on: (var one = 1), (var two = 2)) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2) + UBinaryExpression (operator = >) [four > three] = true (depending on: (var four = 4), (var three = 3)) + USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4) + USimpleNameReferenceExpression (identifier = three) [three] = (var three = 3) + UDeclarationsExpression [var b3: boolean = b1 || b2] = Undetermined + ULocalVariable (name = b3) [var b3: boolean = b1 || b2] + UBinaryExpression (operator = ||) [b1 || b2] = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3)))) + USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))) + USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))) + UDeclarationsExpression [var b4: boolean = two > one || three > four] = Undetermined + ULocalVariable (name = b4) [var b4: boolean = two > one || three > four] + UBinaryExpression (operator = ||) [two > one || three > four] = true (depending on: (var two = 2), (var one = 1), (var three = 3), (var four = 4)) + UBinaryExpression (operator = >) [two > one] = true (depending on: (var two = 2), (var one = 1)) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1) + UBinaryExpression (operator = >) [three > four] = false (depending on: (var three = 3), (var four = 4)) + USimpleNameReferenceExpression (identifier = three) [three] = (var three = 3) + USimpleNameReferenceExpression (identifier = four) [four] = (var four = 4) + UReturnExpression [return b1 && !b2 && b3 && b4] = Nothing + UPolyadicExpression (operator = &&) [b1 && !b2 && b3 && b4] = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))), (var b3 = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))))), (var b4 = true (depending on: (var two = 2), (var one = 1), (var three = 3), (var four = 4)))) + USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))) + UPrefixExpression (operator = !) [!b2] = true (depending on: (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3)))) + USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))) + USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = true (depending on: (var b1 = true (depending on: (var two = 2), (var one = 1), (var four = 4), (var three = 3))), (var b2 = false (depending on: (var one = 1), (var two = 2), (var four = 4), (var three = 3))))) + USimpleNameReferenceExpression (identifier = b4) [b4] = (var b4 = true (depending on: (var two = 2), (var one = 1), (var three = 3), (var four = 4))) diff --git a/uast/uast-tests/java/Simple/MethodReference.java b/uast/uast-tests/java/Simple/MethodReference.java new file mode 100644 index 000000000000..0e2d3e13e7b0 --- /dev/null +++ b/uast/uast-tests/java/Simple/MethodReference.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2017 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. + */ +public class Anonymous { + + public static void bar() { + int variable1 = 24; + variable1++; + + } + + public static int foo() { + int variable = 42; + + Runnable runnable = User::bar; + runnable.run(); + + return variable; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/MethodReference.values.txt b/uast/uast-tests/java/Simple/MethodReference.values.txt new file mode 100644 index 000000000000..4d27136513cd --- /dev/null +++ b/uast/uast-tests/java/Simple/MethodReference.values.txt @@ -0,0 +1,24 @@ +UFile (package = ) [public class Anonymous {...] + UClass (name = Anonymous) [public class Anonymous {...}] + UMethod (name = bar) [public static fun bar() : void {...}] + UBlockExpression [{...}] = (var variable1 = 24) + UDeclarationsExpression [var variable1: int = 24] = Undetermined + ULocalVariable (name = variable1) [var variable1: int = 24] + ULiteralExpression (value = 24) [24] = 24 + UPostfixExpression (operator = ++) [variable1++] = (var variable1 = 24) + USimpleNameReferenceExpression (identifier = variable1) [variable1] = (var variable1 = 24) + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var variable: int = 42] = Undetermined + ULocalVariable (name = variable) [var variable: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UDeclarationsExpression [var runnable: java.lang.Runnable = User::bar] = Undetermined + ULocalVariable (name = runnable) [var runnable: java.lang.Runnable = User::bar] + UCallableReferenceExpression (name = bar) [User::bar] = external User::bar() + USimpleNameReferenceExpression (identifier = User) [User] = external User() + UQualifiedReferenceExpression [runnable.run()] = external run()() + USimpleNameReferenceExpression (identifier = runnable) [runnable] = (var runnable = external User::bar()) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [run()] = external run()() + UIdentifier (Identifier (run)) [UIdentifier (Identifier (run))] + UReturnExpression [return variable] = Nothing + USimpleNameReferenceExpression (identifier = variable) [variable] = (var variable = 42) diff --git a/uast/uast-tests/java/Simple/Modification.java b/uast/uast-tests/java/Simple/Modification.java new file mode 100644 index 000000000000..6bd1d17213cf --- /dev/null +++ b/uast/uast-tests/java/Simple/Modification.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2017 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. + */ +public class Modification { + public static String foo() { + String s1 = "Hello "; + s1 += "world"; + int m = 10; + int n = 5; + m += n -= 3; + m /= n *= 2; + s1 += " = "; + return s1 + m + " / " + n; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Modification.values.txt b/uast/uast-tests/java/Simple/Modification.values.txt new file mode 100644 index 000000000000..4c56d62f7b20 --- /dev/null +++ b/uast/uast-tests/java/Simple/Modification.values.txt @@ -0,0 +1,35 @@ +UFile (package = ) [public class Modification {...] + UClass (name = Modification) [public class Modification {...}] + UMethod (name = foo) [public static fun foo() : java.lang.String {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var s1: java.lang.String = "Hello "] = Undetermined + ULocalVariable (name = s1) [var s1: java.lang.String = "Hello "] + ULiteralExpression (value = "Hello ") ["Hello "] = "Hello " + UBinaryExpression (operator = +=) [s1 += "world"] = "Hello world" (depending on: (var s1 = "Hello ")) + USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello ") + ULiteralExpression (value = "world") ["world"] = "world" + UDeclarationsExpression [var m: int = 10] = Undetermined + ULocalVariable (name = m) [var m: int = 10] + ULiteralExpression (value = 10) [10] = 10 + UDeclarationsExpression [var n: int = 5] = Undetermined + ULocalVariable (name = n) [var n: int = 5] + ULiteralExpression (value = 5) [5] = 5 + UBinaryExpression (operator = +=) [m += n -= 3] = 12 (depending on: (var m = 10), (var n = 5)) + USimpleNameReferenceExpression (identifier = m) [m] = (var m = 10) + UBinaryExpression (operator = -=) [n -= 3] = 2 (depending on: (var n = 5)) + USimpleNameReferenceExpression (identifier = n) [n] = (var n = 5) + ULiteralExpression (value = 3) [3] = 3 + UBinaryExpression (operator = /=) [m /= n *= 2] = 3 (depending on: (var m = 12 (depending on: (var n = 5))), (var n = 2)) + USimpleNameReferenceExpression (identifier = m) [m] = (var m = 12 (depending on: (var n = 5))) + UBinaryExpression (operator = *=) [n *= 2] = 4 (depending on: (var n = 2)) + USimpleNameReferenceExpression (identifier = n) [n] = (var n = 2) + ULiteralExpression (value = 2) [2] = 2 + UBinaryExpression (operator = +=) [s1 += " = "] = "Hello world = " (depending on: (var s1 = "Hello world")) + USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello world") + ULiteralExpression (value = " = ") [" = "] = " = " + UReturnExpression [return s1 + m + " / " + n] = Nothing + UPolyadicExpression (operator = +) [s1 + m + " / " + n] = "Hello world = 3 / 4" (depending on: (var s1 = "Hello world = "), (var m = 3 (depending on: (var n = 2))), (var n = 4)) + USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello world = ") + USimpleNameReferenceExpression (identifier = m) [m] = (var m = 3 (depending on: (var n = 2))) + ULiteralExpression (value = " / ") [" / "] = " / " + USimpleNameReferenceExpression (identifier = n) [n] = (var n = 4) diff --git a/uast/uast-tests/java/Simple/MutableField.java b/uast/uast-tests/java/Simple/MutableField.java new file mode 100644 index 000000000000..cebe2389496d --- /dev/null +++ b/uast/uast-tests/java/Simple/MutableField.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class MutableField { + static int mutable = 0; + + public static int foo() { + mutable = 1; + bar(); + return mutable; + } + + public static void bar() { + mutable = 2; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/MutableField.values.txt b/uast/uast-tests/java/Simple/MutableField.values.txt new file mode 100644 index 000000000000..4e40e71579d4 --- /dev/null +++ b/uast/uast-tests/java/Simple/MutableField.values.txt @@ -0,0 +1,18 @@ +UFile (package = ) [public class MutableField {...] + UClass (name = MutableField) [public class MutableField {...}] + UField (name = mutable) [static var mutable: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UBinaryExpression (operator = =) [mutable = 1] = 1 + USimpleNameReferenceExpression (identifier = mutable) [mutable] = external mutable() + ULiteralExpression (value = 1) [1] = 1 + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()() + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + UReturnExpression [return mutable] = Nothing + USimpleNameReferenceExpression (identifier = mutable) [mutable] = external mutable() + UMethod (name = bar) [public static fun bar() : void {...}] + UBlockExpression [{...}] = 2 + UBinaryExpression (operator = =) [mutable = 2] = 2 + USimpleNameReferenceExpression (identifier = mutable) [mutable] = external mutable() + ULiteralExpression (value = 2) [2] = 2 diff --git a/uast/uast-tests/java/Simple/NotANumber.java b/uast/uast-tests/java/Simple/NotANumber.java new file mode 100644 index 000000000000..40e08441189e --- /dev/null +++ b/uast/uast-tests/java/Simple/NotANumber.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2017 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. + */ +public class NotANumber { + public static boolean foo() { + double x = 0.0 / 0.0; + boolean b1 = x < x; + boolean b2 = x > x; + boolean b3 = x <= x; + boolean b4 = x >= x; + boolean b5 = x == x; + boolean b6 = x != x; + return b1 || b2 || b3 || b4 || b5 || !b6; + } + + public static boolean bar() { + float x = 0.0f / 0.0f; + boolean b1 = x <= x; + boolean b2 = x >= x; + boolean b3 = x < x; + boolean b4 = x > x; + boolean b5 = x == x; + boolean b6 = x != x; + return b1 || b2 || b3 || b4 || b5 || !b6; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/NotANumber.values.txt b/uast/uast-tests/java/Simple/NotANumber.values.txt new file mode 100644 index 000000000000..73cb8d5de2f6 --- /dev/null +++ b/uast/uast-tests/java/Simple/NotANumber.values.txt @@ -0,0 +1,94 @@ +UFile (package = ) [public class NotANumber {...] + UClass (name = NotANumber) [public class NotANumber {...}] + UMethod (name = foo) [public static fun foo() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: double = 0.0 / 0.0] = Undetermined + ULocalVariable (name = x) [var x: double = 0.0 / 0.0] + UBinaryExpression (operator = /) [0.0 / 0.0] = NaN + ULiteralExpression (value = 0.0) [0.0] = 0.0 + ULiteralExpression (value = 0.0) [0.0] = 0.0 + UDeclarationsExpression [var b1: boolean = x < x] = Undetermined + ULocalVariable (name = b1) [var b1: boolean = x < x] + UBinaryExpression (operator = <) [x < x] = false (depending on: (var x = NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + UDeclarationsExpression [var b2: boolean = x > x] = Undetermined + ULocalVariable (name = b2) [var b2: boolean = x > x] + UBinaryExpression (operator = >) [x > x] = false (depending on: (var x = NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + UDeclarationsExpression [var b3: boolean = x <= x] = Undetermined + ULocalVariable (name = b3) [var b3: boolean = x <= x] + UBinaryExpression (operator = <=) [x <= x] = false (depending on: (var x = NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + UDeclarationsExpression [var b4: boolean = x >= x] = Undetermined + ULocalVariable (name = b4) [var b4: boolean = x >= x] + UBinaryExpression (operator = >=) [x >= x] = false (depending on: (var x = NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + UDeclarationsExpression [var b5: boolean = x === x] = Undetermined + ULocalVariable (name = b5) [var b5: boolean = x === x] + UBinaryExpression (operator = ===) [x === x] = false (depending on: (var x = NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + UDeclarationsExpression [var b6: boolean = x !== x] = Undetermined + ULocalVariable (name = b6) [var b6: boolean = x !== x] + UBinaryExpression (operator = !==) [x !== x] = true (depending on: (var x = NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = NaN) + UReturnExpression [return b1 || b2 || b3 || b4 || b5 || !b6] = Nothing + UPolyadicExpression (operator = ||) [b1 || b2 || b3 || b4 || b5 || !b6] = false (depending on: (var b1 = false (depending on: (var x = NaN))), (var b2 = false (depending on: (var x = NaN))), (var b3 = false (depending on: (var x = NaN))), (var b4 = false (depending on: (var x = NaN))), (var b5 = false (depending on: (var x = NaN))), (var b6 = true (depending on: (var x = NaN)))) + USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = false (depending on: (var x = NaN))) + USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var x = NaN))) + USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = false (depending on: (var x = NaN))) + USimpleNameReferenceExpression (identifier = b4) [b4] = (var b4 = false (depending on: (var x = NaN))) + USimpleNameReferenceExpression (identifier = b5) [b5] = (var b5 = false (depending on: (var x = NaN))) + UPrefixExpression (operator = !) [!b6] = false (depending on: (var b6 = true (depending on: (var x = NaN)))) + USimpleNameReferenceExpression (identifier = b6) [b6] = (var b6 = true (depending on: (var x = NaN))) + UMethod (name = bar) [public static fun bar() : boolean {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: float = 0.0 / 0.0] = Undetermined + ULocalVariable (name = x) [var x: float = 0.0 / 0.0] + UBinaryExpression (operator = /) [0.0 / 0.0] = (float)NaN + ULiteralExpression (value = 0.0) [0.0] = (float)0.0 + ULiteralExpression (value = 0.0) [0.0] = (float)0.0 + UDeclarationsExpression [var b1: boolean = x <= x] = Undetermined + ULocalVariable (name = b1) [var b1: boolean = x <= x] + UBinaryExpression (operator = <=) [x <= x] = false (depending on: (var x = (float)NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + UDeclarationsExpression [var b2: boolean = x >= x] = Undetermined + ULocalVariable (name = b2) [var b2: boolean = x >= x] + UBinaryExpression (operator = >=) [x >= x] = false (depending on: (var x = (float)NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + UDeclarationsExpression [var b3: boolean = x < x] = Undetermined + ULocalVariable (name = b3) [var b3: boolean = x < x] + UBinaryExpression (operator = <) [x < x] = false (depending on: (var x = (float)NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + UDeclarationsExpression [var b4: boolean = x > x] = Undetermined + ULocalVariable (name = b4) [var b4: boolean = x > x] + UBinaryExpression (operator = >) [x > x] = false (depending on: (var x = (float)NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + UDeclarationsExpression [var b5: boolean = x === x] = Undetermined + ULocalVariable (name = b5) [var b5: boolean = x === x] + UBinaryExpression (operator = ===) [x === x] = false (depending on: (var x = (float)NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + UDeclarationsExpression [var b6: boolean = x !== x] = Undetermined + ULocalVariable (name = b6) [var b6: boolean = x !== x] + UBinaryExpression (operator = !==) [x !== x] = true (depending on: (var x = (float)NaN)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = (float)NaN) + UReturnExpression [return b1 || b2 || b3 || b4 || b5 || !b6] = Nothing + UPolyadicExpression (operator = ||) [b1 || b2 || b3 || b4 || b5 || !b6] = false (depending on: (var b1 = false (depending on: (var x = (float)NaN))), (var b2 = false (depending on: (var x = (float)NaN))), (var b3 = false (depending on: (var x = (float)NaN))), (var b4 = false (depending on: (var x = (float)NaN))), (var b5 = false (depending on: (var x = (float)NaN))), (var b6 = true (depending on: (var x = (float)NaN)))) + USimpleNameReferenceExpression (identifier = b1) [b1] = (var b1 = false (depending on: (var x = (float)NaN))) + USimpleNameReferenceExpression (identifier = b2) [b2] = (var b2 = false (depending on: (var x = (float)NaN))) + USimpleNameReferenceExpression (identifier = b3) [b3] = (var b3 = false (depending on: (var x = (float)NaN))) + USimpleNameReferenceExpression (identifier = b4) [b4] = (var b4 = false (depending on: (var x = (float)NaN))) + USimpleNameReferenceExpression (identifier = b5) [b5] = (var b5 = false (depending on: (var x = (float)NaN))) + UPrefixExpression (operator = !) [!b6] = false (depending on: (var b6 = true (depending on: (var x = (float)NaN)))) + USimpleNameReferenceExpression (identifier = b6) [b6] = (var b6 = true (depending on: (var x = (float)NaN))) diff --git a/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java new file mode 100644 index 000000000000..82d67bce1709 --- /dev/null +++ b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.java @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2017 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. + */ +public class Foo { + public void bar(String x) { + String f = x + "1"; + } +} diff --git a/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt new file mode 100644 index 000000000000..74ce53b3f529 --- /dev/null +++ b/uast/uast-tests/java/Simple/ParamViaEvaluatorExtension.values.txt @@ -0,0 +1,10 @@ +UFile (package = ) [public class Foo {...] + UClass (name = Foo) [public class Foo {...}] + UMethod (name = bar) [public fun bar(x: java.lang.String) : void {...}] + UParameter (name = x) [var x: java.lang.String] + UBlockExpression [{...}] = Undetermined + UDeclarationsExpression [var f: java.lang.String = x + "1"] = Undetermined + ULocalVariable (name = f) [var f: java.lang.String = x + "1"] + UBinaryExpression (operator = +) [x + "1"] = "01" + USimpleNameReferenceExpression (identifier = x) [x] = "0" + ULiteralExpression (value = "1") ["1"] = "1" diff --git a/uast/uast-tests/java/Simple/QualifiedConstructorCall.java b/uast/uast-tests/java/Simple/QualifiedConstructorCall.java new file mode 100644 index 000000000000..b0227c5627f5 --- /dev/null +++ b/uast/uast-tests/java/Simple/QualifiedConstructorCall.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2017 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 A.B.C; + +class Foo { + +} + +class Bar { + public Foo getFoo() { + return new A.B.C.Foo(); + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt b/uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt new file mode 100644 index 000000000000..bd859e793ac1 --- /dev/null +++ b/uast/uast-tests/java/Simple/QualifiedConstructorCall.log.txt @@ -0,0 +1,14 @@ +UFile (package = A.B.C) + UClass (name = Foo) + UClass (name = Bar) + UMethod (name = getFoo) + UBlockExpression + UReturnExpression + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 0)) + UQualifiedReferenceExpression + UQualifiedReferenceExpression + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = A) + USimpleNameReferenceExpression (identifier = B) + USimpleNameReferenceExpression (identifier = C) + USimpleNameReferenceExpression (identifier = Foo) diff --git a/uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt b/uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt new file mode 100644 index 000000000000..bdc0e8955a32 --- /dev/null +++ b/uast/uast-tests/java/Simple/QualifiedConstructorCall.render.txt @@ -0,0 +1,10 @@ +package A.B.C + +class Foo { +} + +class Bar { + public fun getFoo() : A.B.C.Foo { + return A.B.C.Foo() + } +} diff --git a/uast/uast-tests/java/Simple/ReturnMinusX.java b/uast/uast-tests/java/Simple/ReturnMinusX.java new file mode 100644 index 000000000000..1c2c270c2591 --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnMinusX.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2017 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. + */ +public class ReturnMinusX { + public static int foo() { + int x = 42; + return -x; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ReturnMinusX.values.txt b/uast/uast-tests/java/Simple/ReturnMinusX.values.txt new file mode 100644 index 000000000000..66c9678cfc92 --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnMinusX.values.txt @@ -0,0 +1,10 @@ +UFile (package = ) [public class ReturnMinusX {...] + UClass (name = ReturnMinusX) [public class ReturnMinusX {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 42] = Undetermined + ULocalVariable (name = x) [var x: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UReturnExpression [return -x] = Nothing + UPrefixExpression (operator = -) [-x] = -42 (depending on: (var x = 42)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 42) diff --git a/uast/uast-tests/java/Simple/ReturnSum.java b/uast/uast-tests/java/Simple/ReturnSum.java new file mode 100644 index 000000000000..8b20e1c3f6a8 --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnSum.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2017 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. + */ +public class ReturnSum { + public static int foo() { + int x = 1 + 2; + int y = 3 + 4; + int z = x + y; + return z + z; // 20 + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ReturnSum.values.txt b/uast/uast-tests/java/Simple/ReturnSum.values.txt new file mode 100644 index 000000000000..6c2ac3ef30fd --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnSum.values.txt @@ -0,0 +1,23 @@ +UFile (package = ) [public class ReturnSum {...] + UClass (name = ReturnSum) [public class ReturnSum {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 1 + 2] = Undetermined + ULocalVariable (name = x) [var x: int = 1 + 2] + UBinaryExpression (operator = +) [1 + 2] = 3 + ULiteralExpression (value = 1) [1] = 1 + ULiteralExpression (value = 2) [2] = 2 + UDeclarationsExpression [var y: int = 3 + 4] = Undetermined + ULocalVariable (name = y) [var y: int = 3 + 4] + UBinaryExpression (operator = +) [3 + 4] = 7 + ULiteralExpression (value = 3) [3] = 3 + ULiteralExpression (value = 4) [4] = 4 + UDeclarationsExpression [var z: int = x + y] = Undetermined + ULocalVariable (name = z) [var z: int = x + y] + UBinaryExpression (operator = +) [x + y] = 10 (depending on: (var x = 3), (var y = 7)) + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 3) + USimpleNameReferenceExpression (identifier = y) [y] = (var y = 7) + UReturnExpression [return z + z] = Nothing + UBinaryExpression (operator = +) [z + z] = 20 (depending on: (var z = 10 (depending on: (var x = 3), (var y = 7)))) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = 10 (depending on: (var x = 3), (var y = 7))) + USimpleNameReferenceExpression (identifier = z) [z] = (var z = 10 (depending on: (var x = 3), (var y = 7))) diff --git a/uast/uast-tests/java/Simple/ReturnX.java b/uast/uast-tests/java/Simple/ReturnX.java new file mode 100644 index 000000000000..d3e19fec0a8a --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnX.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2017 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. + */ +public class ReturnX { + public static int foo() { + int x = 42; + return x; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/ReturnX.log.txt b/uast/uast-tests/java/Simple/ReturnX.log.txt new file mode 100644 index 000000000000..fe73c63683e4 --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnX.log.txt @@ -0,0 +1,9 @@ +UFile (package = ) + UClass (name = ReturnX) + UMethod (name = foo) + UBlockExpression + UDeclarationsExpression + ULocalVariable (name = x) + ULiteralExpression (value = 42) + UReturnExpression + USimpleNameReferenceExpression (identifier = x) diff --git a/uast/uast-tests/java/Simple/ReturnX.render.txt b/uast/uast-tests/java/Simple/ReturnX.render.txt new file mode 100644 index 000000000000..1d1c273e2c77 --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnX.render.txt @@ -0,0 +1,6 @@ +public class ReturnX { + public static fun foo() : int { + var x: int = 42 + return x + } +} diff --git a/uast/uast-tests/java/Simple/ReturnX.values.txt b/uast/uast-tests/java/Simple/ReturnX.values.txt new file mode 100644 index 000000000000..9e63d7990cbc --- /dev/null +++ b/uast/uast-tests/java/Simple/ReturnX.values.txt @@ -0,0 +1,9 @@ +UFile (package = ) [public class ReturnX {...] + UClass (name = ReturnX) [public class ReturnX {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var x: int = 42] = Undetermined + ULocalVariable (name = x) [var x: int = 42] + ULiteralExpression (value = 42) [42] = 42 + UReturnExpression [return x] = Nothing + USimpleNameReferenceExpression (identifier = x) [x] = (var x = 42) diff --git a/uast/uast-tests/java/Simple/Shift.java b/uast/uast-tests/java/Simple/Shift.java new file mode 100644 index 000000000000..2f95814a8c6d --- /dev/null +++ b/uast/uast-tests/java/Simple/Shift.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2017 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. + */ +public class Shift { + public static int foo() { + int one = 1; + int two = one << 1; + int sixteen = two << 3; + int minInt = 0x80000000; + int quarter = minInt >> 2; + int unsignedQuarter = minInt >>> 2; + + return sixteen + quarter + unsignedQuarter; + } + + public static long bar() { + long one = 1L; + long two = one << 1; + long large = two << 61; + long minLong = 0x8000000000000000L; + long eighth = minLong >> 3; + long unsignedEighth = minLong >>> 3; + + return large + eighth + unsignedEighth; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Shift.values.txt b/uast/uast-tests/java/Simple/Shift.values.txt new file mode 100644 index 000000000000..aea68b579aca --- /dev/null +++ b/uast/uast-tests/java/Simple/Shift.values.txt @@ -0,0 +1,68 @@ +UFile (package = ) [public class Shift {...] + UClass (name = Shift) [public class Shift {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var one: int = 1] = Undetermined + ULocalVariable (name = one) [var one: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var two: int = one << 1] = Undetermined + ULocalVariable (name = two) [var two: int = one << 1] + UBinaryExpression (operator = <<) [one << 1] = 2 (depending on: (var one = 1)) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = 1) + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var sixteen: int = two << 3] = Undetermined + ULocalVariable (name = sixteen) [var sixteen: int = two << 3] + UBinaryExpression (operator = <<) [two << 3] = 16 (depending on: (var two = 2 (depending on: (var one = 1)))) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = 2 (depending on: (var one = 1))) + ULiteralExpression (value = 3) [3] = 3 + UDeclarationsExpression [var minInt: int = -2147483648] = Undetermined + ULocalVariable (name = minInt) [var minInt: int = -2147483648] + ULiteralExpression (value = -2147483648) [-2147483648] = -2147483648 + UDeclarationsExpression [var quarter: int = minInt >> 2] = Undetermined + ULocalVariable (name = quarter) [var quarter: int = minInt >> 2] + UBinaryExpression (operator = >>) [minInt >> 2] = -536870912 (depending on: (var minInt = -2147483648)) + USimpleNameReferenceExpression (identifier = minInt) [minInt] = (var minInt = -2147483648) + ULiteralExpression (value = 2) [2] = 2 + UDeclarationsExpression [var unsignedQuarter: int = minInt >>> 2] = Undetermined + ULocalVariable (name = unsignedQuarter) [var unsignedQuarter: int = minInt >>> 2] + UBinaryExpression (operator = >>>) [minInt >>> 2] = 536870912 (depending on: (var minInt = -2147483648)) + USimpleNameReferenceExpression (identifier = minInt) [minInt] = (var minInt = -2147483648) + ULiteralExpression (value = 2) [2] = 2 + UReturnExpression [return sixteen + quarter + unsignedQuarter] = Nothing + UPolyadicExpression (operator = +) [sixteen + quarter + unsignedQuarter] = 16 (depending on: (var sixteen = 16 (depending on: (var two = 2 (depending on: (var one = 1))))), (var quarter = -536870912 (depending on: (var minInt = -2147483648))), (var unsignedQuarter = 536870912 (depending on: (var minInt = -2147483648)))) + USimpleNameReferenceExpression (identifier = sixteen) [sixteen] = (var sixteen = 16 (depending on: (var two = 2 (depending on: (var one = 1))))) + USimpleNameReferenceExpression (identifier = quarter) [quarter] = (var quarter = -536870912 (depending on: (var minInt = -2147483648))) + USimpleNameReferenceExpression (identifier = unsignedQuarter) [unsignedQuarter] = (var unsignedQuarter = 536870912 (depending on: (var minInt = -2147483648))) + UMethod (name = bar) [public static fun bar() : long {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var one: long = 1] = Undetermined + ULocalVariable (name = one) [var one: long = 1] + ULiteralExpression (value = 1) [1] = (long)1 + UDeclarationsExpression [var two: long = one << 1] = Undetermined + ULocalVariable (name = two) [var two: long = one << 1] + UBinaryExpression (operator = <<) [one << 1] = (long)2 (depending on: (var one = (long)1)) + USimpleNameReferenceExpression (identifier = one) [one] = (var one = (long)1) + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var large: long = two << 61] = Undetermined + ULocalVariable (name = large) [var large: long = two << 61] + UBinaryExpression (operator = <<) [two << 61] = (long)4611686018427387904 (depending on: (var two = (long)2 (depending on: (var one = (long)1)))) + USimpleNameReferenceExpression (identifier = two) [two] = (var two = (long)2 (depending on: (var one = (long)1))) + ULiteralExpression (value = 61) [61] = 61 + UDeclarationsExpression [var minLong: long = -9223372036854775808] = Undetermined + ULocalVariable (name = minLong) [var minLong: long = -9223372036854775808] + ULiteralExpression (value = -9223372036854775808) [-9223372036854775808] = (long)-9223372036854775808 + UDeclarationsExpression [var eighth: long = minLong >> 3] = Undetermined + ULocalVariable (name = eighth) [var eighth: long = minLong >> 3] + UBinaryExpression (operator = >>) [minLong >> 3] = (long)-1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808)) + USimpleNameReferenceExpression (identifier = minLong) [minLong] = (var minLong = (long)-9223372036854775808) + ULiteralExpression (value = 3) [3] = 3 + UDeclarationsExpression [var unsignedEighth: long = minLong >>> 3] = Undetermined + ULocalVariable (name = unsignedEighth) [var unsignedEighth: long = minLong >>> 3] + UBinaryExpression (operator = >>>) [minLong >>> 3] = (long)1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808)) + USimpleNameReferenceExpression (identifier = minLong) [minLong] = (var minLong = (long)-9223372036854775808) + ULiteralExpression (value = 3) [3] = 3 + UReturnExpression [return large + eighth + unsignedEighth] = Nothing + UPolyadicExpression (operator = +) [large + eighth + unsignedEighth] = (long)4611686018427387904 (depending on: (var large = (long)4611686018427387904 (depending on: (var two = (long)2 (depending on: (var one = (long)1))))), (var eighth = (long)-1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))), (var unsignedEighth = (long)1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808)))) + USimpleNameReferenceExpression (identifier = large) [large] = (var large = (long)4611686018427387904 (depending on: (var two = (long)2 (depending on: (var one = (long)1))))) + USimpleNameReferenceExpression (identifier = eighth) [eighth] = (var eighth = (long)-1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))) + USimpleNameReferenceExpression (identifier = unsignedEighth) [unsignedEighth] = (var unsignedEighth = (long)1152921504606846976 (depending on: (var minLong = (long)-9223372036854775808))) diff --git a/uast/uast-tests/java/Simple/Simple.java b/uast/uast-tests/java/Simple/Simple.java new file mode 100644 index 000000000000..4be305a21ea9 --- /dev/null +++ b/uast/uast-tests/java/Simple/Simple.java @@ -0,0 +1,17 @@ +/* + * Copyright 2000-2017 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. + */ +public class Simple { +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Simple.log.txt b/uast/uast-tests/java/Simple/Simple.log.txt new file mode 100644 index 000000000000..da0855030aed --- /dev/null +++ b/uast/uast-tests/java/Simple/Simple.log.txt @@ -0,0 +1,2 @@ +UFile (package = ) + UClass (name = Simple) \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Simple.render.txt b/uast/uast-tests/java/Simple/Simple.render.txt new file mode 100644 index 000000000000..10f71395e452 --- /dev/null +++ b/uast/uast-tests/java/Simple/Simple.render.txt @@ -0,0 +1,2 @@ +public class Simple { +} diff --git a/uast/uast-tests/java/Simple/Strings.java b/uast/uast-tests/java/Simple/Strings.java new file mode 100644 index 000000000000..ffcb89ee1b63 --- /dev/null +++ b/uast/uast-tests/java/Simple/Strings.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2017 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. + */ +public class Strings { + public static String foo() { + String s1 = "Hello "; + String s2 = s1 + "wounderful"; + String s3 = " world "; + String s4 = s2 + s3; + String s5 = s4 + 2016; + return s5; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Strings.values.txt b/uast/uast-tests/java/Simple/Strings.values.txt new file mode 100644 index 000000000000..a9e424b6e1c0 --- /dev/null +++ b/uast/uast-tests/java/Simple/Strings.values.txt @@ -0,0 +1,27 @@ +UFile (package = ) [public class Strings {...] + UClass (name = Strings) [public class Strings {...}] + UMethod (name = foo) [public static fun foo() : java.lang.String {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var s1: java.lang.String = "Hello "] = Undetermined + ULocalVariable (name = s1) [var s1: java.lang.String = "Hello "] + ULiteralExpression (value = "Hello ") ["Hello "] = "Hello " + UDeclarationsExpression [var s2: java.lang.String = s1 + "wounderful"] = Undetermined + ULocalVariable (name = s2) [var s2: java.lang.String = s1 + "wounderful"] + UBinaryExpression (operator = +) [s1 + "wounderful"] = "Hello wounderful" (depending on: (var s1 = "Hello ")) + USimpleNameReferenceExpression (identifier = s1) [s1] = (var s1 = "Hello ") + ULiteralExpression (value = "wounderful") ["wounderful"] = "wounderful" + UDeclarationsExpression [var s3: java.lang.String = " world "] = Undetermined + ULocalVariable (name = s3) [var s3: java.lang.String = " world "] + ULiteralExpression (value = " world ") [" world "] = " world " + UDeclarationsExpression [var s4: java.lang.String = s2 + s3] = Undetermined + ULocalVariable (name = s4) [var s4: java.lang.String = s2 + s3] + UBinaryExpression (operator = +) [s2 + s3] = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world ")) + USimpleNameReferenceExpression (identifier = s2) [s2] = (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))) + USimpleNameReferenceExpression (identifier = s3) [s3] = (var s3 = " world ") + UDeclarationsExpression [var s5: java.lang.String = s4 + 2016] = Undetermined + ULocalVariable (name = s5) [var s5: java.lang.String = s4 + 2016] + UBinaryExpression (operator = +) [s4 + 2016] = "Hello wounderful world 2016" (depending on: (var s4 = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world ")))) + USimpleNameReferenceExpression (identifier = s4) [s4] = (var s4 = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world "))) + ULiteralExpression (value = 2016) [2016] = 2016 + UReturnExpression [return s5] = Nothing + USimpleNameReferenceExpression (identifier = s5) [s5] = (var s5 = "Hello wounderful world 2016" (depending on: (var s4 = "Hello wounderful world " (depending on: (var s2 = "Hello wounderful" (depending on: (var s1 = "Hello "))), (var s3 = " world "))))) diff --git a/uast/uast-tests/java/Simple/SuperTypes.java b/uast/uast-tests/java/Simple/SuperTypes.java new file mode 100644 index 000000000000..323fbbdb7163 --- /dev/null +++ b/uast/uast-tests/java/Simple/SuperTypes.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2017 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. + */ +class A { + +} + +interface B { + +} + +class Test extends A implements B { + +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/SuperTypes.log.txt b/uast/uast-tests/java/Simple/SuperTypes.log.txt new file mode 100644 index 000000000000..ad8f041d703b --- /dev/null +++ b/uast/uast-tests/java/Simple/SuperTypes.log.txt @@ -0,0 +1,4 @@ +UFile (package = ) + UClass (name = A) + UClass (name = B) + UClass (name = Test) diff --git a/uast/uast-tests/java/Simple/SuperTypes.render.txt b/uast/uast-tests/java/Simple/SuperTypes.render.txt new file mode 100644 index 000000000000..37b885785f78 --- /dev/null +++ b/uast/uast-tests/java/Simple/SuperTypes.render.txt @@ -0,0 +1,8 @@ +class A { +} + +abstract interface B { +} + +class Test : A, B { +} diff --git a/uast/uast-tests/java/Simple/Ternary.java b/uast/uast-tests/java/Simple/Ternary.java new file mode 100644 index 000000000000..5fb7f71e820c --- /dev/null +++ b/uast/uast-tests/java/Simple/Ternary.java @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2017 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. + */ +public class Ternary { + public static int foo(boolean flag) { + return flag ? 1 : 0; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/Ternary.values.txt b/uast/uast-tests/java/Simple/Ternary.values.txt new file mode 100644 index 000000000000..3eeda2ed597a --- /dev/null +++ b/uast/uast-tests/java/Simple/Ternary.values.txt @@ -0,0 +1,10 @@ +UFile (package = ) [public class Ternary {...] + UClass (name = Ternary) [public class Ternary {...}] + UMethod (name = foo) [public static fun foo(flag: boolean) : int {...}] + UParameter (name = flag) [var flag: boolean] + UBlockExpression [{...}] = Nothing + UReturnExpression [return (flag) ? (1) : (0)] = Nothing + UIfExpression [(flag) ? (1) : (0)] = Phi(1, 0) + USimpleNameReferenceExpression (identifier = flag) [flag] = Undetermined + ULiteralExpression (value = 1) [1] = 1 + ULiteralExpression (value = 0) [0] = 0 diff --git a/uast/uast-tests/java/Simple/TryCatch.java b/uast/uast-tests/java/Simple/TryCatch.java new file mode 100644 index 000000000000..235d63d33434 --- /dev/null +++ b/uast/uast-tests/java/Simple/TryCatch.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2017 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. + */ +public class TryCatch { + public static int foo(String str) { + int sum = 0; + for (String part: str.split(" ")) { + int b = 0; + try { + sum = sum + Integer.parseInt(part); + b = 1; + } + catch (NumberFormatException ex) { + b = 1; + } + int c = b; + } + return sum; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/TryCatch.values.txt b/uast/uast-tests/java/Simple/TryCatch.values.txt new file mode 100644 index 000000000000..e6b6fa985964 --- /dev/null +++ b/uast/uast-tests/java/Simple/TryCatch.values.txt @@ -0,0 +1,42 @@ +UFile (package = ) [public class TryCatch {...] + UClass (name = TryCatch) [public class TryCatch {...}] + UMethod (name = foo) [public static fun foo(str: java.lang.String) : int {...}] + UParameter (name = str) [var str: java.lang.String] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var sum: int = 0] = Undetermined + ULocalVariable (name = sum) [var sum: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UForEachExpression [for (part : str.split(" ")) {...}] = Undetermined + UQualifiedReferenceExpression [str.split(" ")] = external split(" ")(" ") + USimpleNameReferenceExpression (identifier = str) [str] = Undetermined + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [split(" ")] = external split(" ")(" ") + UIdentifier (Identifier (split)) [UIdentifier (Identifier (split))] + ULiteralExpression (value = " ") [" "] = " " + UBlockExpression [{...}] = Undetermined + UDeclarationsExpression [var b: int = 0] = Undetermined + ULocalVariable (name = b) [var b: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UTryExpression [try {...] = Phi(1, Undetermined) + UBlockExpression [{...}] = 1 + UBinaryExpression (operator = =) [sum = sum + Integer.parseInt(part)] = Undetermined + USimpleNameReferenceExpression (identifier = sum) [sum] = Phi((var sum = 0), (var sum = Undetermined)) + UBinaryExpression (operator = +) [sum + Integer.parseInt(part)] = Undetermined + USimpleNameReferenceExpression (identifier = sum) [sum] = Phi((var sum = 0), (var sum = Undetermined)) + UQualifiedReferenceExpression [Integer.parseInt(part)] = external parseInt(part)(Undetermined) + USimpleNameReferenceExpression (identifier = Integer) [Integer] = external Integer() + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1)) [parseInt(part)] = external parseInt(part)(Undetermined) + UIdentifier (Identifier (parseInt)) [UIdentifier (Identifier (parseInt))] + USimpleNameReferenceExpression (identifier = part) [part] = Undetermined + UBinaryExpression (operator = =) [b = 1] = 1 + USimpleNameReferenceExpression (identifier = b) [b] = (var b = 0) + ULiteralExpression (value = 1) [1] = 1 + UCatchClause (ex) [catch (e) {...}] + UBlockExpression [{...}] = 1 + UBinaryExpression (operator = =) [b = 1] = 1 + USimpleNameReferenceExpression (identifier = b) [b] = Undetermined + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var c: int = b] = Undetermined + ULocalVariable (name = c) [var c: int = b] + USimpleNameReferenceExpression (identifier = b) [b] = Phi((var b = 1), (var b = 0)) + UReturnExpression [return sum] = Nothing + USimpleNameReferenceExpression (identifier = sum) [sum] = Phi((var sum = Undetermined), (var sum = 0)) diff --git a/uast/uast-tests/java/Simple/TryWithResources.java b/uast/uast-tests/java/Simple/TryWithResources.java new file mode 100644 index 000000000000..9093205483d6 --- /dev/null +++ b/uast/uast-tests/java/Simple/TryWithResources.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2017 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. + */ +public class TryWithResources { + public void foo() { + try (BufferedReader br = + new BufferedReader(new FileReader(path))) { + return br.readLine(); + } + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/TryWithResources.log.txt b/uast/uast-tests/java/Simple/TryWithResources.log.txt new file mode 100644 index 000000000000..1261b0e13552 --- /dev/null +++ b/uast/uast-tests/java/Simple/TryWithResources.log.txt @@ -0,0 +1,17 @@ +UFile (package = ) + UClass (name = TryWithResources) + UMethod (name = foo) + UBlockExpression + UTryExpression (with resources) + ULocalVariable (name = br) + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + USimpleNameReferenceExpression (identifier = BufferedReader) + UCallExpression (kind = UastCallKind(name='constructor_call'), argCount = 1)) + USimpleNameReferenceExpression (identifier = FileReader) + USimpleNameReferenceExpression (identifier = path) + UBlockExpression + UReturnExpression + UQualifiedReferenceExpression + USimpleNameReferenceExpression (identifier = br) + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) + UIdentifier (Identifier (readLine)) diff --git a/uast/uast-tests/java/Simple/TryWithResources.render.txt b/uast/uast-tests/java/Simple/TryWithResources.render.txt new file mode 100644 index 000000000000..3f3b1da675b4 --- /dev/null +++ b/uast/uast-tests/java/Simple/TryWithResources.render.txt @@ -0,0 +1,8 @@ +public class TryWithResources { + public fun foo() : void { + try (final var br: BufferedReader = BufferedReader(FileReader(path))){ + return br.readLine() + } + + } +} diff --git a/uast/uast-tests/java/Simple/TypeReference.java b/uast/uast-tests/java/Simple/TypeReference.java new file mode 100644 index 000000000000..4f9383e7e621 --- /dev/null +++ b/uast/uast-tests/java/Simple/TypeReference.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2017 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. + */ +public class Foo { + public void bar() { + String s; + s = 1; + } +} diff --git a/uast/uast-tests/java/Simple/While.java b/uast/uast-tests/java/Simple/While.java new file mode 100644 index 000000000000..5e3bb51140da --- /dev/null +++ b/uast/uast-tests/java/Simple/While.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2017 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. + */ +public class While { + public static int foo() { + int result = 0, i = 0; + while (i < 10) { + result = result + i++; + } + return result; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/While.values.txt b/uast/uast-tests/java/Simple/While.values.txt new file mode 100644 index 000000000000..595b63082ebe --- /dev/null +++ b/uast/uast-tests/java/Simple/While.values.txt @@ -0,0 +1,22 @@ +UFile (package = ) [public class While {...] + UClass (name = While) [public class While {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var result: int = 0...var i: int = 0] = Undetermined + ULocalVariable (name = result) [var result: int = 0] + ULiteralExpression (value = 0) [0] = 0 + ULocalVariable (name = i) [var i: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UWhileExpression [while (i < 10) {...}] = Undetermined + UBinaryExpression (operator = <) [i < 10] = Undetermined + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + ULiteralExpression (value = 10) [10] = 10 + UBlockExpression [{...}] = Undetermined + UBinaryExpression (operator = =) [result = result + i++] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0)) + UBinaryExpression (operator = +) [result + i++] = Undetermined + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0)) + UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + UReturnExpression [return result] = Nothing + USimpleNameReferenceExpression (identifier = result) [result] = Phi((var result = Undetermined), (var result = 0 (depending on: (var i = 0))), (var result = 0)) diff --git a/uast/uast-tests/java/Simple/WhileWithContinue.java b/uast/uast-tests/java/Simple/WhileWithContinue.java new file mode 100644 index 000000000000..66fdef096cae --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithContinue.java @@ -0,0 +1,48 @@ +/* + * Copyright 2000-2017 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. + */ +public class WhileWithContinue { + + public static boolean bar() { + return true; + } + + public static int foo() { + int first = 1; + int second = 2; + + while (bar()) { + second = 3; + if (first > 0) continue; + second = 4; + } + + return second; + } + + public static int baz() { + int first = 2; + int second = 2; + + while (bar()) { + second = 3; + first--; + if (first > 0) continue; + second = 4; + } + + return second; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/WhileWithContinue.values.txt b/uast/uast-tests/java/Simple/WhileWithContinue.values.txt new file mode 100644 index 000000000000..5cd5760dc995 --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithContinue.values.txt @@ -0,0 +1,60 @@ +UFile (package = ) [public class WhileWithContinue {...] + UClass (name = WhileWithContinue) [public class WhileWithContinue {...}] + UMethod (name = bar) [public static fun bar() : boolean {...}] + UBlockExpression [{...}] = Nothing + UReturnExpression [return true] = Nothing + ULiteralExpression (value = true) [true] = true + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var first: int = 1] = Undetermined + ULocalVariable (name = first) [var first: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var second: int = 2] = Undetermined + ULocalVariable (name = second) [var second: int = 2] + ULiteralExpression (value = 2) [2] = 2 + UWhileExpression [while (bar()) {...}] = Undetermined + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()() + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + UBlockExpression [{...}] = Nothing(continue) + UBinaryExpression (operator = =) [second = 3] = 3 + USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 3), (var second = 2)) + ULiteralExpression (value = 3) [3] = 3 + UIfExpression [if (first > 0) continue] = Nothing(continue) + UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1) + ULiteralExpression (value = 0) [0] = 0 + UContinueExpression (label = null) [continue] = Nothing(continue) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UBinaryExpression (operator = =) [second = 4] = 4 + USimpleNameReferenceExpression (identifier = second) [second] = Undetermined + ULiteralExpression (value = 4) [4] = 4 + UReturnExpression [return second] = Nothing + USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 3), (var second = 2)) + UMethod (name = baz) [public static fun baz() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var first: int = 2] = Undetermined + ULocalVariable (name = first) [var first: int = 2] + ULiteralExpression (value = 2) [2] = 2 + UDeclarationsExpression [var second: int = 2] = Undetermined + ULocalVariable (name = second) [var second: int = 2] + ULiteralExpression (value = 2) [2] = 2 + UWhileExpression [while (bar()) {...}] = Undetermined + UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0)) [bar()] = external bar()() + UIdentifier (Identifier (bar)) [UIdentifier (Identifier (bar))] + UBlockExpression [{...}] = 4 + UBinaryExpression (operator = =) [second = 3] = 3 + USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 4), (var second = 3), (var second = 2)) + ULiteralExpression (value = 3) [3] = 3 + UPostfixExpression (operator = --) [first--] = Phi((var first = Undetermined), (var first = 1), (var first = 2)) + USimpleNameReferenceExpression (identifier = first) [first] = Phi((var first = Undetermined), (var first = 1), (var first = 2)) + UIfExpression [if (first > 0) continue] = Undetermined + UBinaryExpression (operator = >) [first > 0] = Undetermined (depending on: (var first = Undetermined)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = Undetermined) + ULiteralExpression (value = 0) [0] = 0 + UContinueExpression (label = null) [continue] = Nothing(continue) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UBinaryExpression (operator = =) [second = 4] = 4 + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3) + ULiteralExpression (value = 4) [4] = 4 + UReturnExpression [return second] = Nothing + USimpleNameReferenceExpression (identifier = second) [second] = Phi((var second = 4), (var second = 3), (var second = 2)) diff --git a/uast/uast-tests/java/Simple/WhileWithIncrement.java b/uast/uast-tests/java/Simple/WhileWithIncrement.java new file mode 100644 index 000000000000..8c2cbab055c7 --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithIncrement.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2017 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. + */ +public class WhileWithIncrement { + public static int foo() { + int i = 0; + while (true) { + i++; + if (i % 42 == 0) break; + } + return i; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/WhileWithIncrement.values.txt b/uast/uast-tests/java/Simple/WhileWithIncrement.values.txt new file mode 100644 index 000000000000..98c2a255a416 --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithIncrement.values.txt @@ -0,0 +1,22 @@ +UFile (package = ) [public class WhileWithIncrement {...] + UClass (name = WhileWithIncrement) [public class WhileWithIncrement {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var i: int = 0] = Undetermined + ULocalVariable (name = i) [var i: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UWhileExpression [while (true) {...}] = Undetermined + ULiteralExpression (value = true) [true] = true + UBlockExpression [{...}] = Undetermined + UPostfixExpression (operator = ++) [i++] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) + UIfExpression [if (i % 42 === 0) break] = Undetermined + UBinaryExpression (operator = ===) [i % 42 === 0] = Undetermined (depending on: (var i = Undetermined)) + UBinaryExpression (operator = %) [i % 42] = Undetermined (depending on: (var i = Undetermined)) + USimpleNameReferenceExpression (identifier = i) [i] = (var i = Undetermined) + ULiteralExpression (value = 42) [42] = 42 + ULiteralExpression (value = 0) [0] = 0 + UBreakExpression (label = null) [break] = Nothing(break) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UReturnExpression [return i] = Nothing + USimpleNameReferenceExpression (identifier = i) [i] = Phi((var i = Undetermined), (var i = 1), (var i = 0)) diff --git a/uast/uast-tests/java/Simple/WhileWithMutableCondition.java b/uast/uast-tests/java/Simple/WhileWithMutableCondition.java new file mode 100644 index 000000000000..d39b5b5a3600 --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithMutableCondition.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2017 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. + */ +public class WhileWithMutableCondition { + public static int foo() { + int i = 0; + while (++i < 2) { + i--; + } + return i; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt b/uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt new file mode 100644 index 000000000000..e2b6751b467d --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithMutableCondition.values.txt @@ -0,0 +1,17 @@ +UFile (package = ) [public class WhileWithMutableCondition {...] + UClass (name = WhileWithMutableCondition) [public class WhileWithMutableCondition {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var i: int = 0] = Undetermined + ULocalVariable (name = i) [var i: int = 0] + ULiteralExpression (value = 0) [0] = 0 + UWhileExpression [while (++i < 2) {...}] = Undetermined + UBinaryExpression (operator = <) [++i < 2] = true (depending on: (var i = 0)) + UPrefixExpression (operator = ++) [++i] = 1 (depending on: (var i = 0)) + USimpleNameReferenceExpression (identifier = i) [i] = (var i = 0) + ULiteralExpression (value = 2) [2] = 2 + UBlockExpression [{...}] = (var i = 1) + UPostfixExpression (operator = --) [i--] = (var i = 1) + USimpleNameReferenceExpression (identifier = i) [i] = (var i = 1) + UReturnExpression [return i] = Nothing + USimpleNameReferenceExpression (identifier = i) [i] = (var i = 0) diff --git a/uast/uast-tests/java/Simple/WhileWithReturn.java b/uast/uast-tests/java/Simple/WhileWithReturn.java new file mode 100644 index 000000000000..b2870046571f --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithReturn.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2017 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. + */ +public class WhileWithReturn { + public static int foo() { + int first = 1; + int second = 2; + + while (first == 1) { + second = 3; + if (first > 0) return second; + } + + return second; + } +} \ No newline at end of file diff --git a/uast/uast-tests/java/Simple/WhileWithReturn.values.txt b/uast/uast-tests/java/Simple/WhileWithReturn.values.txt new file mode 100644 index 000000000000..1b13429edf66 --- /dev/null +++ b/uast/uast-tests/java/Simple/WhileWithReturn.values.txt @@ -0,0 +1,27 @@ +UFile (package = ) [public class WhileWithReturn {...] + UClass (name = WhileWithReturn) [public class WhileWithReturn {...}] + UMethod (name = foo) [public static fun foo() : int {...}] + UBlockExpression [{...}] = Nothing + UDeclarationsExpression [var first: int = 1] = Undetermined + ULocalVariable (name = first) [var first: int = 1] + ULiteralExpression (value = 1) [1] = 1 + UDeclarationsExpression [var second: int = 2] = Undetermined + ULocalVariable (name = second) [var second: int = 2] + ULiteralExpression (value = 2) [2] = 2 + UWhileExpression [while (first === 1) {...}] = Nothing + UBinaryExpression (operator = ===) [first === 1] = true (depending on: (var first = 1)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1) + ULiteralExpression (value = 1) [1] = 1 + UBlockExpression [{...}] = Nothing + UBinaryExpression (operator = =) [second = 3] = 3 + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 2) + ULiteralExpression (value = 3) [3] = 3 + UIfExpression [if (first > 0) return second] = Nothing + UBinaryExpression (operator = >) [first > 0] = true (depending on: (var first = 1)) + USimpleNameReferenceExpression (identifier = first) [first] = (var first = 1) + ULiteralExpression (value = 0) [0] = 0 + UReturnExpression [return second] = Nothing + USimpleNameReferenceExpression (identifier = second) [second] = (var second = 3) + UastEmptyExpression [UastEmptyExpression] = Undetermined + UReturnExpression [return second] = Nothing + USimpleNameReferenceExpression (identifier = second) [second] = Undetermined