From 4d4e9cc342b08d1d533e923dcc713bbbeeddc1d5 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sun, 2 Jan 2011 21:25:40 +0300 Subject: [PATCH] Better testing framework, examples added as tests --- examples/src/collections/LinkedList.jetl | 2 +- examples/src/collections/List.jetl | 2 + examples/src/io/IOSamples.jetl | 11 +- examples/src/priorityqueues/BinaryHeap.jetl | 6 +- .../PriorityQueueAsPushPop.jetl | 3 +- examples/src/util/Comparison.jetl | 2 +- .../psi/examples/AnonymousObjects.jet | 24 + .../psi/examples/AnonymousObjects.txt | 194 ++ idea/testData/psi/examples/BinaryTree.jet | 195 ++ idea/testData/psi/examples/BinaryTree.txt | 2268 +++++++++++++++++ idea/testData/psi/examples/BitArith.jet | 29 + idea/testData/psi/examples/BitArith.txt | 578 +++++ idea/testData/psi/examples/Builder.jet | 43 + idea/testData/psi/examples/Builder.txt | 413 +++ idea/testData/psi/examples/Color.jet | 5 + idea/testData/psi/examples/Color.txt | 140 + .../psi/examples/FunctionsAndTypes.jet | 34 + .../psi/examples/FunctionsAndTypes.txt | 625 +++++ idea/testData/psi/examples/Graph.jet | 60 + idea/testData/psi/examples/Graph.txt | 880 +++++++ idea/testData/psi/examples/IPushPop.jet | 5 + idea/testData/psi/examples/IPushPop.txt | 64 + idea/testData/psi/examples/LINQ.jet | 3 + idea/testData/psi/examples/LINQ.txt | 68 + .../psi/examples/PolymorphicClassObjects.jet | 31 + .../psi/examples/PolymorphicClassObjects.txt | 367 +++ idea/testData/psi/examples/Queue.jet | 33 + idea/testData/psi/examples/Queue.txt | 353 +++ idea/testData/psi/examples/Stack.jet | 13 + idea/testData/psi/examples/Stack.txt | 141 + idea/testData/psi/examples/UnionFind.jet | 33 + idea/testData/psi/examples/UnionFind.txt | 360 +++ .../testData/psi/examples/UpdateOperation.jet | 14 + .../testData/psi/examples/UpdateOperation.txt | 219 ++ idea/testData/psi/examples/With.jet | 15 + idea/testData/psi/examples/With.txt | 160 ++ .../psi/examples/array/MutableArray.jet | 13 + .../psi/examples/array/MutableArray.txt | 176 ++ .../psi/examples/collections/ArrayList.jet | 77 + .../psi/examples/collections/ArrayList.txt | 823 ++++++ .../psi/examples/collections/HashMap.jet | 58 + .../psi/examples/collections/HashMap.txt | 908 +++++++ .../psi/examples/collections/IIterable.jet | 3 + .../psi/examples/collections/IIterable.txt | 44 + .../psi/examples/collections/IIterator.jet | 25 + .../psi/examples/collections/IIterator.txt | 354 +++ .../psi/examples/collections/IList.jet | 4 + .../psi/examples/collections/IList.txt | 87 + .../examples/collections/IMutableIterable.jet | 3 + .../examples/collections/IMutableIterable.txt | 59 + .../examples/collections/IMutableIterator.jet | 13 + .../examples/collections/IMutableIterator.txt | 55 + .../psi/examples/collections/IMutableList.jet | 6 + .../psi/examples/collections/IMutableList.txt | 155 ++ .../psi/examples/collections/IMutableSet.jet | 4 + .../psi/examples/collections/IMutableSet.txt | 95 + .../psi/examples/collections/ISet.jet | 3 + .../psi/examples/collections/ISet.txt | 65 + .../psi/examples/collections/ISized.jet | 3 + .../psi/examples/collections/ISized.txt | 27 + .../psi/examples/collections/LinkedList.jet | 73 + .../psi/examples/collections/LinkedList.txt | 798 ++++++ .../psi/examples/collections/List.jet | 27 + .../psi/examples/collections/List.txt | 314 +++ idea/testData/psi/examples/io/IOSamples.jet | 62 + idea/testData/psi/examples/io/IOSamples.txt | 643 +++++ idea/testData/psi/examples/map/IMap.jet | 4 + idea/testData/psi/examples/map/IMap.txt | 29 + .../examples/priorityqueues/BinaryHeap.jet | 106 + .../examples/priorityqueues/BinaryHeap.txt | 1175 +++++++++ .../priorityqueues/IPriorityQueue.jet | 5 + .../priorityqueues/IPriorityQueue.txt | 64 + .../priorityqueues/PriorityQueueAsPushPop.jet | 7 + .../priorityqueues/PriorityQueueAsPushPop.txt | 128 + .../testData/psi/examples/util/Comparison.jet | 19 + .../testData/psi/examples/util/Comparison.txt | 377 +++ .../psi/examples/util/IComparable.jet | 3 + .../psi/examples/util/IComparable.txt | 46 + .../jetbrains/jet/parsing/JetParsingTest.java | 106 +- 79 files changed, 14379 insertions(+), 60 deletions(-) create mode 100644 idea/testData/psi/examples/AnonymousObjects.jet create mode 100644 idea/testData/psi/examples/AnonymousObjects.txt create mode 100644 idea/testData/psi/examples/BinaryTree.jet create mode 100644 idea/testData/psi/examples/BinaryTree.txt create mode 100644 idea/testData/psi/examples/BitArith.jet create mode 100644 idea/testData/psi/examples/BitArith.txt create mode 100644 idea/testData/psi/examples/Builder.jet create mode 100644 idea/testData/psi/examples/Builder.txt create mode 100644 idea/testData/psi/examples/Color.jet create mode 100644 idea/testData/psi/examples/Color.txt create mode 100644 idea/testData/psi/examples/FunctionsAndTypes.jet create mode 100644 idea/testData/psi/examples/FunctionsAndTypes.txt create mode 100644 idea/testData/psi/examples/Graph.jet create mode 100644 idea/testData/psi/examples/Graph.txt create mode 100644 idea/testData/psi/examples/IPushPop.jet create mode 100644 idea/testData/psi/examples/IPushPop.txt create mode 100644 idea/testData/psi/examples/LINQ.jet create mode 100644 idea/testData/psi/examples/LINQ.txt create mode 100644 idea/testData/psi/examples/PolymorphicClassObjects.jet create mode 100644 idea/testData/psi/examples/PolymorphicClassObjects.txt create mode 100644 idea/testData/psi/examples/Queue.jet create mode 100644 idea/testData/psi/examples/Queue.txt create mode 100644 idea/testData/psi/examples/Stack.jet create mode 100644 idea/testData/psi/examples/Stack.txt create mode 100644 idea/testData/psi/examples/UnionFind.jet create mode 100644 idea/testData/psi/examples/UnionFind.txt create mode 100644 idea/testData/psi/examples/UpdateOperation.jet create mode 100644 idea/testData/psi/examples/UpdateOperation.txt create mode 100644 idea/testData/psi/examples/With.jet create mode 100644 idea/testData/psi/examples/With.txt create mode 100644 idea/testData/psi/examples/array/MutableArray.jet create mode 100644 idea/testData/psi/examples/array/MutableArray.txt create mode 100644 idea/testData/psi/examples/collections/ArrayList.jet create mode 100644 idea/testData/psi/examples/collections/ArrayList.txt create mode 100644 idea/testData/psi/examples/collections/HashMap.jet create mode 100644 idea/testData/psi/examples/collections/HashMap.txt create mode 100644 idea/testData/psi/examples/collections/IIterable.jet create mode 100644 idea/testData/psi/examples/collections/IIterable.txt create mode 100644 idea/testData/psi/examples/collections/IIterator.jet create mode 100644 idea/testData/psi/examples/collections/IIterator.txt create mode 100644 idea/testData/psi/examples/collections/IList.jet create mode 100644 idea/testData/psi/examples/collections/IList.txt create mode 100644 idea/testData/psi/examples/collections/IMutableIterable.jet create mode 100644 idea/testData/psi/examples/collections/IMutableIterable.txt create mode 100644 idea/testData/psi/examples/collections/IMutableIterator.jet create mode 100644 idea/testData/psi/examples/collections/IMutableIterator.txt create mode 100644 idea/testData/psi/examples/collections/IMutableList.jet create mode 100644 idea/testData/psi/examples/collections/IMutableList.txt create mode 100644 idea/testData/psi/examples/collections/IMutableSet.jet create mode 100644 idea/testData/psi/examples/collections/IMutableSet.txt create mode 100644 idea/testData/psi/examples/collections/ISet.jet create mode 100644 idea/testData/psi/examples/collections/ISet.txt create mode 100644 idea/testData/psi/examples/collections/ISized.jet create mode 100644 idea/testData/psi/examples/collections/ISized.txt create mode 100644 idea/testData/psi/examples/collections/LinkedList.jet create mode 100644 idea/testData/psi/examples/collections/LinkedList.txt create mode 100644 idea/testData/psi/examples/collections/List.jet create mode 100644 idea/testData/psi/examples/collections/List.txt create mode 100644 idea/testData/psi/examples/io/IOSamples.jet create mode 100644 idea/testData/psi/examples/io/IOSamples.txt create mode 100644 idea/testData/psi/examples/map/IMap.jet create mode 100644 idea/testData/psi/examples/map/IMap.txt create mode 100644 idea/testData/psi/examples/priorityqueues/BinaryHeap.jet create mode 100644 idea/testData/psi/examples/priorityqueues/BinaryHeap.txt create mode 100644 idea/testData/psi/examples/priorityqueues/IPriorityQueue.jet create mode 100644 idea/testData/psi/examples/priorityqueues/IPriorityQueue.txt create mode 100644 idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.jet create mode 100644 idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt create mode 100644 idea/testData/psi/examples/util/Comparison.jet create mode 100644 idea/testData/psi/examples/util/Comparison.txt create mode 100644 idea/testData/psi/examples/util/IComparable.jet create mode 100644 idea/testData/psi/examples/util/IComparable.txt diff --git a/examples/src/collections/LinkedList.jetl b/examples/src/collections/LinkedList.jetl index d1901a24fea..9519bcefbb1 100644 --- a/examples/src/collections/LinkedList.jetl +++ b/examples/src/collections/LinkedList.jetl @@ -6,7 +6,7 @@ class LinkedList : IMutableList { private var head : Item = null private var tail : Item = null - override var size get private set; + override var size get private set override fun add(index : Int, value : T) { size++ diff --git a/examples/src/collections/List.jetl b/examples/src/collections/List.jetl index e7bee51ca45..0a8d852eb41 100644 --- a/examples/src/collections/List.jetl +++ b/examples/src/collections/List.jetl @@ -6,9 +6,11 @@ enum class List(theSize : Int) : IList { override val size : Int get() = theSize + override val isEmpty : Boolean get() = this == Nil + override fun iterator() = new IIterator() { private var current = List.this diff --git a/examples/src/io/IOSamples.jetl b/examples/src/io/IOSamples.jetl index c51b03a643f..4304fc00a38 100644 --- a/examples/src/io/IOSamples.jetl +++ b/examples/src/io/IOSamples.jetl @@ -28,18 +28,19 @@ class FileInput : IIterator, JavaCloseableWrapper { } return } - + override val hasNext get() { // implicitly throws IOException if (nextUsed && next != -1) { nextUsed = false next = stream.read() // throws IOException } - return next != -1 + return next != -1 } + } -class FileOutput throws IOException : IAdder, JavaCloseableWrapper { +class FileOutput : IAdder, JavaCloseableWrapper { private val stream : OutputStream this(file : File) : JavaCloseableWrapper(stream) { @@ -53,8 +54,8 @@ class FileOutput throws IOException : IAdder, JavaCloseableWrapper { fun example() { // this does not rethrow, no appropriate parameters given - val f1 : File = ... - val f2 : File = ... + val f1 : File //= ... + val f2 : File //= ... streamCopy(FileInput(f1), f2) // throws IOException, you must catch or rethrow explicitly diff --git a/examples/src/priorityqueues/BinaryHeap.jetl b/examples/src/priorityqueues/BinaryHeap.jetl index 6a87b434c1f..98990fb32f6 100644 --- a/examples/src/priorityqueues/BinaryHeap.jetl +++ b/examples/src/priorityqueues/BinaryHeap.jetl @@ -5,12 +5,12 @@ class BinaryHeap : IPriorityQueue { this(data : IIterable, compare : Comparison = naturalOrder) { this.compare = compare this.data = ArrayList(data) - siftDown(* this.data.size / 2 .. 0) -/* +// siftDown(* this.data.size / 2 .. 0) + for (val i in data.size / 2 .. 0) { siftDown(i) } -*/ + } this(compare : Comparison) { diff --git a/examples/src/priorityqueues/PriorityQueueAsPushPop.jetl b/examples/src/priorityqueues/PriorityQueueAsPushPop.jetl index 2502a91b39f..2d20c5666e7 100644 --- a/examples/src/priorityqueues/PriorityQueueAsPushPop.jetl +++ b/examples/src/priorityqueues/PriorityQueueAsPushPop.jetl @@ -1,6 +1,7 @@ class PriorityQueueAsPushPop wraps(wrapped : IPriorityQueue) : IPushPop { override fun pop() = wrapped.extract() override fun push(item : T) = wrapped.add(item) - override val isEmpty + override val isEmpty get() = wrapped.isEmpty + } \ No newline at end of file diff --git a/examples/src/util/Comparison.jetl b/examples/src/util/Comparison.jetl index cd8935ff025..12a9fdc35c0 100644 --- a/examples/src/util/Comparison.jetl +++ b/examples/src/util/Comparison.jetl @@ -5,7 +5,7 @@ fun naturalOrder>(a : T, b : T) : Int = a.compareTo(b) fun castingNaturalOrder(a : Object, b : Object) : Int = (a as Comparable).compareTo(b as Comparable) enum class ComparisonResult { - LS, EQ, GR + LS; EQ; GR } type MatchableComparison = {(T, T) : ComparisonResult} diff --git a/idea/testData/psi/examples/AnonymousObjects.jet b/idea/testData/psi/examples/AnonymousObjects.jet new file mode 100644 index 00000000000..6c5a97b66b1 --- /dev/null +++ b/idea/testData/psi/examples/AnonymousObjects.jet @@ -0,0 +1,24 @@ +fun foo() { + +addMouseListener(object MouseAdapter() { + + private var clickCount = 0; + + override fun mouseClicked(e : MouseEvent) { + clickCount++; + if (clickCount > 3) GOD.sendMessage(GodMEssages.TOO_MANY_CLICKS); + } +}) + +enum class GodMessages { + TOO_MANY_CLICKS + ONE_MORE_MESSAGE +} + +// Type of this variable is GOD_AnonymousClass +val GOD = object { + fun sendMessage(message : GodMEssage) = throw new RuntimeException(message.name) +}; + + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/AnonymousObjects.txt b/idea/testData/psi/examples/AnonymousObjects.txt new file mode 100644 index 00000000000..60f17549b88 --- /dev/null +++ b/idea/testData/psi/examples/AnonymousObjects.txt @@ -0,0 +1,194 @@ +JetFile: AnonymousObjects.jet + NAMESPACE + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('addMouseListener') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(object)('object') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('MouseAdapter') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('clickCount') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mouseClicked') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('e') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('MouseEvent') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('clickCount') + PsiElement(PLUSPLUS)('++') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('clickCount') + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('3') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('GOD') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('sendMessage') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('GodMEssages') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('TOO_MANY_CLICKS') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('GodMessages') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('TOO_MANY_CLICKS') + PsiWhiteSpace('\n ') + TYPE_PARAMETER_LIST + + ENUM_ENTRY + PsiElement(IDENTIFIER)('ONE_MORE_MESSAGE') + PsiWhiteSpace('\n') + TYPE_PARAMETER_LIST + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiComment(EOL_COMMENT)('// Type of this variable is GOD_AnonymousClass') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('GOD') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('sendMessage') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('message') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('GodMEssage') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('RuntimeException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('message') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('name') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/BinaryTree.jet b/idea/testData/psi/examples/BinaryTree.jet new file mode 100644 index 00000000000..03a4f0a399f --- /dev/null +++ b/idea/testData/psi/examples/BinaryTree.jet @@ -0,0 +1,195 @@ +class BinaryTree : IMutableSet { + private class TreeNode( + var value : T, var parent : TreeNode + ) { + var left : TreeNode + var right : TreeNode + + } + + private val compare : MatchableComparison + private var root : TreeNode + private var version = 0 + +// override var size : Int { get; private set; } + + this(compare : Comparison) { + this.compare = asMatchableComparison(comparison) + } + + this() : this(naturalOrder()) { + } + + private [operator] fun T.compareTo(other : T) : Int = compare(this, other) + + override fun contains(item : T) : Boolean { + return contains(root, item) + + fun contains(node : TreeNode, item : T) : Boolean { + if (node == null) return false + compare(item, node.value) match { + case EQ => true + case LS => contains(node.left, item) + case GT => contains(node.right, item) + } + } + } + + override fun add(item : T) : Boolean { + if (add(ref root, null)) { + size++ + version++ + return true + } + return false + + // In principle, this has access to item anyway, but then it's unreachable code + // BAD: the naive implementation of ref will create H(T) ref objects, but can be optimized to create only one + fun add(ref node : TreeNode, parent : TreeNode) : Boolean { + if (node == null) { + node = TreeNode(item, parent) + return true + } + compare(item, node.value) match { + case EQ => false + case LS => add(ref node.left, node) + case GT => add(ref node.right, node) + } + } + + // In principle, this has access to item anyway + fun addNoRef(node : TreeNode) : Boolean { + if (node == null) { + root = TreeNode(item, null) + return true + } + compare(item, node.value) match { + case EQ => return false + case LS => + if (node.left == null) { + node.left = TreeNode(item, node) + return true + } else return add(node.left) + case GT => + if (node.right == null) { + node.right = TreeNode(item, node) + return true + } else return add(node.right) + } + } + } + + override fun remove(item : T) : Boolean { + val toRemove = find(root, item) + if (toRemove == null) return false + remove(toRemove) + size-- + version++ + return true + + fun find(node : TreeNode) : TreeNode { + if (node == null) return null + compare(item, node.value) match { + case EQ => node + case LS => find(node.left) + case GT => find(node.right) + } + } + } + + private fun remove(node : TreeNode) { + node match { + case TreeNode(null, null) => replace(node, null) + case TreeNode(null, right) => replace(node, right) + case TreeNode(left, null) => replace(node, left) + case TreeNode(left, right) => { + val min = min(node.right) + node.value = min.value + remove(min) + } + } + + fun replace(node : TreeNode, replace : TreeNode) { + if (node == root) { + root = replace + return + } + if (node.parent.left == node) { + node.parent.left = replace + } else if (node.parent.right == node) { + node.parent.right = replace + } else Assert(false) + } + } + + // Relies on tail-recursion optimization + private fun min(node : TreeNode) { + if (node.left == null) node else min(node.left) + } + + override fun iterator() : IIterator = mutableIterator() + + override fun mutableIterator() : IMutableIterator = object IMutableIterator { + val version = BinaryTree.this.version + val down = Stack() + val up = Stack() + var lastNode : TreeNode + + this() { + if (root != null) + down.push(root) + } + + override fun next() : T { + if (!hasNext) + throw NoMoreElementsException() + checkVersion() + + lastNode = nextNode() + return lastNode.value + } + + private fun nextNode() : TreeNode { + while (true) { + if (!down.isEmpty) { + val curNode = down.pop() + if (curNode.left != null) { + up.push(curNode) + down.push(curNode.left) + } else { + if (curNode.right != null) { + down.push(curNode.right) + } + return curNode; + } + } else { + val curNode = up.pop() + if (curNode.right != null) { + down.push(curNode.right) + } + return curNode + } + } + } + + override val hasNext : Boolean + get() = !down.isEmpty || !up.isEmpty + + + override fun remove() { + checkVersion() + if (lastNode == null) + throw IterationException("Nothing to remove") + remove(lastNode) + version++ + BinaryTree.this.version = version + } + + private fun checkVersion() { + if (version != BinaryTree.this.version) { + throw ConcurrentModificationException() + } + } + } + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/BinaryTree.txt b/idea/testData/psi/examples/BinaryTree.txt new file mode 100644 index 00000000000..26f2716d811 --- /dev/null +++ b/idea/testData/psi/examples/BinaryTree.txt @@ -0,0 +1,2268 @@ +JetFile: BinaryTree.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('BinaryTree') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableSet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('TreeNode') + TYPE_PARAMETER_LIST + + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('parent') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace('\n ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('MatchableComparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('root') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n\n') + PsiComment(EOL_COMMENT)('// override var size : Int { get; private set; }') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Comparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('asMatchableComparison') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('comparison') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + THIS_CALL + PsiElement(this)('this') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + CALL_EXPRESSION + PsiElement(IDENTIFIER)('naturalOrder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('compareTo') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('other') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('compare') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(this)('this') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('other') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('contains') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('contains') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('root') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('contains') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('compare') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(match)('match') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('EQ') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('LS') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('contains') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('GT') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('contains') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(ref)('ref') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('root') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('size') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('version') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// In principle, this has access to item anyway, but then it's unreachable code') + PsiWhiteSpace('\n ') + PsiComment(EOL_COMMENT)('// BAD: the naive implementation of ref will create H(T) ref objects, but can be optimized to create only one') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiElement(ref)('ref') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('parent') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('TreeNode') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('parent') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('compare') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(match)('match') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('EQ') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('LS') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(ref)('ref') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('GT') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(ref)('ref') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// In principle, this has access to item anyway') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('addNoRef') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('root') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('TreeNode') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('compare') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(match)('match') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('EQ') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('LS') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('TreeNode') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('GT') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' \n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('TreeNode') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('toRemove') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('find') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('root') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('toRemove') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('remove') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('toRemove') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('size') + PsiElement(MINUSMINUS)('--') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('version') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('find') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('compare') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(match)('match') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('EQ') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('LS') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('find') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('GT') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('find') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(match)('match') + PsiWhiteSpace(' ') + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + TUPLE_PATTERN + PsiElement(LPAR)('(') + PATTERN + NULL + PsiElement(null)('null') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PATTERN + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('replace') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + TUPLE_PATTERN + PsiElement(LPAR)('(') + PATTERN + NULL + PsiElement(null)('null') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('replace') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + TUPLE_PATTERN + PsiElement(LPAR)('(') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('left') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PATTERN + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('replace') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('node') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('left') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + MATCH_ENTRY + PsiElement(case)('case') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + TUPLE_PATTERN + PsiElement(LPAR)('(') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('left') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PATTERN + USER_TYPE + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('min') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('min') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('min') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('remove') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('min') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('replace') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('replace') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('root') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('root') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('replace') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('node') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('replace') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('node') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('replace') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Assert') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// Relies on tail-recursion optimization') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('min') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + PsiElement(IDENTIFIER)('node') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + CALL_EXPRESSION + PsiElement(IDENTIFIER)('min') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('node') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('iterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('mutableIterator') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableIterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('BinaryTree') + PsiElement(DOT)('.') + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('down') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Stack') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('up') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Stack') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('lastNode') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('root') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('root') + PsiElement(RPAR)(')') + PsiWhiteSpace(' \n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + PsiElement(IDENTIFIER)('hasNext') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('NoMoreElementsException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkVersion') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('lastNode') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('nextNode') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('lastNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('nextNode') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('TreeNode') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + WHILE + PsiElement(while)('while') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('curNode') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('pop') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('curNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('up') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('curNode') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('curNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('curNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('curNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('curNode') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('curNode') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('up') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('pop') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('curNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('curNode') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('curNode') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hasNext') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('down') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace(' ') + PsiElement(OROR)('||') + PsiWhiteSpace(' ') + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('up') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkVersion') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('lastNode') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('IterationException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"Nothing to remove"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('remove') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('lastNode') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('version') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('BinaryTree') + PsiElement(DOT)('.') + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('checkVersion') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('BinaryTree') + PsiElement(DOT)('.') + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('version') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('ConcurrentModificationException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' \n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/BitArith.jet b/idea/testData/psi/examples/BitArith.jet new file mode 100644 index 00000000000..d9bdf1dbcc0 --- /dev/null +++ b/idea/testData/psi/examples/BitArith.jet @@ -0,0 +1,29 @@ +fun oneBit(index : Int) = 1 shl index + +fun setBit(x : Int, index : Int) = x or oneBit(index) +fun unsetBit(x : Int, index : Int) = x and not(oneBit(index)) + +fun getBit(x : Int, index : Int) = x and oneBit(index) != 0 +fun getBit(x : Int, index : Int) = (x shr index) shl 31 != 0 + +fun countOnes(x : INumber) { + var result = 0 + while (x != 0) { + result += x and 1 + x = x ushr 1 + } + result +} + +fun mostSignificantBit(x : INumber) = (x and oneBit(x.bits - 1) != 0) as Int + +fun countOnes(x : INumber) = if (x == 0) 0 else mostSignificantBit(x) + countOnes(x shl 1) + +fun Int.matchMask(mask : Int) = this and mask == mask + +virtual class INumber : IComparable { + val bits : Int + [operator] fun plus(other : T) : T + [operator] fun shl(bits : Int) : T + // ... +} \ No newline at end of file diff --git a/idea/testData/psi/examples/BitArith.txt b/idea/testData/psi/examples/BitArith.txt new file mode 100644 index 00000000000..aa00fb2006c --- /dev/null +++ b/idea/testData/psi/examples/BitArith.txt @@ -0,0 +1,578 @@ +JetFile: BitArith.jet + NAMESPACE + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('oneBit') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('shl') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('setBit') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('or') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('oneBit') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('unsetBit') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('and') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('not') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + CALL_EXPRESSION + PsiElement(IDENTIFIER)('oneBit') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('getBit') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('and') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('oneBit') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('getBit') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('shr') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('shl') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('31') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('countOnes') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('INumber') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n ') + WHILE + PsiElement(while)('while') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(PLUSEQ)('+=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('and') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ushr') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mostSignificantBit') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('INumber') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('and') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('oneBit') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('bits') + PsiWhiteSpace(' ') + PsiElement(MINUS)('-') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('countOnes') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('INumber') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + BINARY_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('mostSignificantBit') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('countOnes') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('shl') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('matchMask') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('mask') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('and') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mask') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mask') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('INumber') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + PsiElement(this)('this') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IComparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bits') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('plus') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('other') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('shl') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('bits') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + PsiComment(EOL_COMMENT)('// ...') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/Builder.jet b/idea/testData/psi/examples/Builder.jet new file mode 100644 index 00000000000..8aaf8c6dc85 --- /dev/null +++ b/idea/testData/psi/examples/Builder.jet @@ -0,0 +1,43 @@ +val foo = object AntBuilder() { + + lazy val groovy = library { + classpath("$libs/groovy-...") + } + + lazy val gant = library { + new File("$gantHome/lib").files.each { + classpath(it) + } + } + + lazy val JPS = module { + targetLevel = "1.5" + classpath(antLayout, gant, groovy) + src("$projectHome/antLayout/src") + } + +}.build() + +class AntBuilder { + abstract class ClassPathEntry {} + + class Module : ClassPathEntry { + fun classpath(entries : ClassPathEntry/*...*/) { /*...*/ } + var targetLevel : String + fun src(src : String) { /*...*/ } + } + + class Library : ClassPathEntry { + fun classpath(entries : ClassPathEntry/*...*/) { /*...*/ } + } + + fun library(initializer : { Library.() : Library}) { + val lib = new Library() + lib.initializer() + return lib + } + + fun classpath(/*...*/) + + fun module(/*...*/) +} \ No newline at end of file diff --git a/idea/testData/psi/examples/Builder.txt b/idea/testData/psi/examples/Builder.txt new file mode 100644 index 00000000000..49f77be7439 --- /dev/null +++ b/idea/testData/psi/examples/Builder.txt @@ -0,0 +1,413 @@ +JetFile: Builder.jet + NAMESPACE + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(object)('object') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('AntBuilder') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(lazy)('lazy') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('groovy') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('library') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('classpath') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"$libs/groovy-..."') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(lazy)('lazy') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('gant') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('library') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('File') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"$gantHome/lib"') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('files') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('each') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('classpath') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(lazy)('lazy') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('JPS') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('module') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('targetLevel') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"1.5"') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('classpath') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('antLayout') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('gant') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('groovy') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('src') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"$projectHome/antLayout/src"') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('build') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('AntBuilder') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + MODIFIER_LIST + PsiElement(abstract)('abstract') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ClassPathEntry') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Module') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ClassPathEntry') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('classpath') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('entries') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ClassPathEntry') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('targetLevel') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('String') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('src') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('src') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('String') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Library') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ClassPathEntry') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('classpath') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('entries') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ClassPathEntry') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('library') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('initializer') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + RECEIVER_TYPE + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Library') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Library') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('lib') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Library') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('lib') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('initializer') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('lib') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('classpath') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('module') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/Color.jet b/idea/testData/psi/examples/Color.jet new file mode 100644 index 00000000000..7b36277efee --- /dev/null +++ b/idea/testData/psi/examples/Color.jet @@ -0,0 +1,5 @@ +enum class Color(val r : Int, val g : Int, val sb : Int) { + RED : Color(255, 0, 0) + GREEN : Color(0, 255, 0) + BLUE : Color(0, 0, 255) +} \ No newline at end of file diff --git a/idea/testData/psi/examples/Color.txt b/idea/testData/psi/examples/Color.txt new file mode 100644 index 00000000000..67346ae3419 --- /dev/null +++ b/idea/testData/psi/examples/Color.txt @@ -0,0 +1,140 @@ +JetFile: Color.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Color') + TYPE_PARAMETER_LIST + + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('r') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('g') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('sb') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('RED') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Color') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('255') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('GREEN') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Color') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('255') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('BLUE') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Color') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('255') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/FunctionsAndTypes.jet b/idea/testData/psi/examples/FunctionsAndTypes.jet new file mode 100644 index 00000000000..623e765c4ac --- /dev/null +++ b/idea/testData/psi/examples/FunctionsAndTypes.jet @@ -0,0 +1,34 @@ +type f1 = {(T) : X} +// type f1 = {(T) => X} +type f2 = {(T, E) : X} +// type f2 = {(T, E) => X} +type f_tuple = {((T, E)) : X} +//type f_tuple = {((T, E)) => X} +type hof = { (X) : {(T) : Y} } +//type hof = { (X) => {(T) => Y} } +type hof2 = { ({(X) : Y}) : {(Y) : Z} } +//type hof2 = { {(X) => Y} => {(Y) => Z} } + + +type Comparison = {(a : T, b : T) : Int} +//type Comparison = {(a : T, b : T) => Int} +type Equality = {(a : T, b : T) : Boolean} +//type Equality = {(a : T, b : T) => Boolean} +type HashFunction = {(obj : T) : Int} +//type HashFunction = {(obj : T) => Int} +type Runnable = {() : ()} +//type Runnable = {() => ()} +type Function1 = {(input : T) : R} +//type Function1 = {(input : T) => R} + + +val f1 = {(t : T) : X => something(t)} +fun f1(t : T) : X = something(t) + +val f1 = {(t : T) => something(t)} +val f1 = {(T) : X => something(it)} +val f1 = {t => something(t)} +val f1 = {something(it)} + +val f1 : {(T) : X} = {X()} + diff --git a/idea/testData/psi/examples/FunctionsAndTypes.txt b/idea/testData/psi/examples/FunctionsAndTypes.txt new file mode 100644 index 00000000000..9176aa595bf --- /dev/null +++ b/idea/testData/psi/examples/FunctionsAndTypes.txt @@ -0,0 +1,625 @@ +JetFile: FunctionsAndTypes.jet + NAMESPACE + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('// type f1 = {(T) => X}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f2') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('// type f2 = {(T, E) => X}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f_tuple') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + TUPLE_TYPE + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type f_tuple = {((T, E)) => X}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hof') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Y') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type hof = { (X) => {(T) => Y} }') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hof2') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Y') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Z') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type hof2 = { {(X) => Y} => {(Y) => Z} }') + PsiWhiteSpace('\n\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Comparison') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type Comparison = {(a : T, b : T) => Int}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Equality') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type Equality = {(a : T, b : T) => Boolean}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('HashFunction') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('obj') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type HashFunction = {(obj : T) => Int}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Runnable') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + TUPLE_TYPE + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type Runnable = {() => ()}') + PsiWhiteSpace('\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Function1') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('input') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('R') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('//type Function1 = {(input : T) => R}') + PsiWhiteSpace('\n\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('t') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('t') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('t') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('t') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('something') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('X') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('X') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/Graph.jet b/idea/testData/psi/examples/Graph.jet new file mode 100644 index 00000000000..225d387f10d --- /dev/null +++ b/idea/testData/psi/examples/Graph.jet @@ -0,0 +1,60 @@ +class Vertex(val data : V) + +class Edge(val from : V, val data : E, val to : V) + +class Graph { + + private val mutableEdges = new ArrayList>() // type is ArrayList, but I want IMutableList +/* options: + private val edges : IMutableList> = new ArrayList>() + private val edges : IMutableList> = new ArrayList() // not an erasure, but a request to infer parameters +*/ + + private val mutableVertices = new HashSet>() + + val edges : IList> = mutableEdges; + val vertices : ISet> = mutableVertices; + + fun addEdge(from : V, data : E, to : V) { + mutableEdges.add(new Edge(from, data, to)) // constructor parameters are inferred + } + fun addVertex(v : V) { + mutableEdges.add(new Edge(from, data, to)) // constructor parameters are inferred + } + + fun neighbours(v : Vertex) = edges.filter{it.from == v}.map{it.to} // type is IIterable> + + fun dfs(handler : {(V) : Unit}) { + val visited = new HashSet>() + vertices.foreach{dfs(it, visited, handler)} + + fun dfs(current : Vertex, visited : ISet>, handler : {(V) : Unit}) { + if (!visited.add(current)) + return + handler(current) + neighbours(current).foreach{dfs(it, visited, handler)} + } + } + + public fun traverse(pending : IPushPop>, visited : ISet>, handler : {(V) : Unit}) { + vertices.foreach { + if (!visited.add(it)) + continue + pending.push(it) + while (!pending.isEmpty) { + val current = pending.pop() + handler(current); + neighbours(current).foreach { n => + if (visited.add(n)) { + pending.push(n) + } + } + /* alternative + pending->push(neighbours(current).filter{n => !visited[n])}) + // -> means that if push(x : T) and actual parameter y is IIterable, this compiles into + y.foreach{ n => push(n) } + */ + } + } + } +} diff --git a/idea/testData/psi/examples/Graph.txt b/idea/testData/psi/examples/Graph.txt new file mode 100644 index 00000000000..c9b54c9221d --- /dev/null +++ b/idea/testData/psi/examples/Graph.txt @@ -0,0 +1,880 @@ +JetFile: Graph.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Vertex') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Edge') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(GT)('>') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('to') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Graph') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableEdges') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ArrayList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Edge') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(GT)('>') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// type is ArrayList, but I want IMutableList') + PsiWhiteSpace('\n') + PsiComment(BLOCK_COMMENT)('/* options:\n private val edges : IMutableList> = new ArrayList>()\n private val edges : IMutableList> = new ArrayList() // not an erasure, but a request to infer parameters\n*/') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableVertices') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('HashSet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('edges') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Edge') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableEdges') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('vertices') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Edge') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableVertices') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('addEdge') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('to') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('mutableEdges') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Edge') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('from') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('data') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('to') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// constructor parameters are inferred') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('addVertex') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('v') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('mutableEdges') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Edge') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('from') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('data') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('to') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// constructor parameters are inferred') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('neighbours') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('v') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('edges') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('filter') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('it') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('v') + PsiElement(RBRACE)('}') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('map') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('it') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('to') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// type is IIterable>') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('dfs') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('handler') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Unit') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('visited') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('HashSet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('vertices') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('foreach') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('dfs') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('visited') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('handler') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('dfs') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('visited') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('handler') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Unit') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('visited') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('handler') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('neighbours') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('foreach') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('dfs') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('visited') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('handler') + PsiElement(RPAR)(')') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(public)('public') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('traverse') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('pending') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IPushPop') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('visited') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Vertex') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('handler') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Unit') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('vertices') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('foreach') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('visited') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + CONTINUE + PsiElement(continue)('continue') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('pending') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('it') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + WHILE + PsiElement(while)('while') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('pending') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('pending') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('pop') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('handler') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('neighbours') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('foreach') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('n') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('visited') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('n') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('pending') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('push') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('n') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiComment(BLOCK_COMMENT)('/* alternative\n pending->push(neighbours(current).filter{n => !visited[n])})\n // -> means that if push(x : T) and actual parameter y is IIterable, this compiles into\n y.foreach{ n => push(n) }\n */') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/IPushPop.jet b/idea/testData/psi/examples/IPushPop.jet new file mode 100644 index 00000000000..09b1f2d8267 --- /dev/null +++ b/idea/testData/psi/examples/IPushPop.jet @@ -0,0 +1,5 @@ +virtual class IPushPop { + val isEmpty : Boolean + fun push(item : T) + fun pop() : T +} \ No newline at end of file diff --git a/idea/testData/psi/examples/IPushPop.txt b/idea/testData/psi/examples/IPushPop.txt new file mode 100644 index 00000000000..ddef3e59312 --- /dev/null +++ b/idea/testData/psi/examples/IPushPop.txt @@ -0,0 +1,64 @@ +JetFile: IPushPop.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IPushPop') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('push') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pop') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/LINQ.jet b/idea/testData/psi/examples/LINQ.jet new file mode 100644 index 00000000000..e492a0c22d3 --- /dev/null +++ b/idea/testData/psi/examples/LINQ.jet @@ -0,0 +1,3 @@ +fun foo() { + l filter {it.x} map {it.foo} aggregate {(a, b) => a + b} +} \ No newline at end of file diff --git a/idea/testData/psi/examples/LINQ.txt b/idea/testData/psi/examples/LINQ.txt new file mode 100644 index 00000000000..7feca5659f9 --- /dev/null +++ b/idea/testData/psi/examples/LINQ.txt @@ -0,0 +1,68 @@ +JetFile: LINQ.jet + NAMESPACE + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('l') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('filter') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('it') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('x') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('map') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BODY + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('it') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('foo') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('aggregate') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('b') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/PolymorphicClassObjects.jet b/idea/testData/psi/examples/PolymorphicClassObjects.jet new file mode 100644 index 00000000000..86fcb9ade5b --- /dev/null +++ b/idea/testData/psi/examples/PolymorphicClassObjects.jet @@ -0,0 +1,31 @@ +virtual class Builder { + [operator] fun plusAssign(item : E) + fun result() : R +} + +virtual class Buildable { + fun newBuilder() : Builder +} + +class List { + + class object Buildable { + override fun newBuilder() : Builder + + } + +} + +extension Map + where + T : Iterable, + class object T : Buildable for T { + + fun map(f : {(E) : R}) : T = { + val builder = T.newBuilder() + for (e in this) { + builder += f(e) + } + builder.result() + } +} \ No newline at end of file diff --git a/idea/testData/psi/examples/PolymorphicClassObjects.txt b/idea/testData/psi/examples/PolymorphicClassObjects.txt new file mode 100644 index 00000000000..160ab00758c --- /dev/null +++ b/idea/testData/psi/examples/PolymorphicClassObjects.txt @@ -0,0 +1,367 @@ +JetFile: PolymorphicClassObjects.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Builder') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('plusAssign') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('R') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Buildable') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newBuilder') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Builder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('List') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + CLASS_OBJECT + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Buildable') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newBuilder') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Builder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + EXTENSION + PsiElement(extension)('extension') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Map') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PsiElement(where)('where') + PsiWhiteSpace('\n ') + TYPE_CONSTRAINT_LIST + TYPE_CONSTRAINT + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Iterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + TYPE_CONSTRAINT + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Buildable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(for)('for') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('map') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('f') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('E') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('R') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('R') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('builder') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('newBuilder') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(IDENTIFIER)('e') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + PsiElement(this)('this') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('builder') + PsiWhiteSpace(' ') + PsiElement(PLUSEQ)('+=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('f') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('e') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('builder') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('result') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/Queue.jet b/idea/testData/psi/examples/Queue.jet new file mode 100644 index 00000000000..375f9babd53 --- /dev/null +++ b/idea/testData/psi/examples/Queue.jet @@ -0,0 +1,33 @@ +class Queue : IPushPop { + private class Item(val data : T, var next : Item) + + private var head : Item = null + private var tail : Item = null + + override fun push(item : T) { + val i = new Item(item) + if (tail == null) { + head = i + tail = head + } else { + tail.next = i + tail = i + } + } + + override fun pop() = + if (head == null) + throw new UnderflowException() + else { + val result = head.data + head = head.next + if (head == null) + tail = null + result + } + + override val isEmpty + get() = head == null + + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/Queue.txt b/idea/testData/psi/examples/Queue.txt new file mode 100644 index 00000000000..ff9fb8f1681 --- /dev/null +++ b/idea/testData/psi/examples/Queue.txt @@ -0,0 +1,353 @@ +JetFile: Queue.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Queue') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IPushPop') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Item') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('push') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pop') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('UnderflowException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/Stack.jet b/idea/testData/psi/examples/Stack.jet new file mode 100644 index 00000000000..426bc28c9a9 --- /dev/null +++ b/idea/testData/psi/examples/Stack.jet @@ -0,0 +1,13 @@ +class Stack : IPushPop { + private val data = new ArrayList(); + + override fun push(item : T) { + data.add(item) // Problem: I would like to write push(...) = data.add(...), but the types do not match + } + + override fun pop() = data.removeLast() + + override val isEmpty + get() = data.isEmpty + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/Stack.txt b/idea/testData/psi/examples/Stack.txt new file mode 100644 index 00000000000..93ca4517042 --- /dev/null +++ b/idea/testData/psi/examples/Stack.txt @@ -0,0 +1,141 @@ +JetFile: Stack.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Stack') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IPushPop') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ArrayList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('push') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// Problem: I would like to write push(...) = data.add(...), but the types do not match') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pop') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('removeLast') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/UnionFind.jet b/idea/testData/psi/examples/UnionFind.jet new file mode 100644 index 00000000000..917d724d9b0 --- /dev/null +++ b/idea/testData/psi/examples/UnionFind.jet @@ -0,0 +1,33 @@ +class UnionFind { + private val data = IMutableList() + + fun add() : Int { + val size = data.size + data.add(size) + size + } + + private fun parent(x : Int) : Int { + val p = data[x]; + if (p == x) { + return x; + } + val result = parent(p); + data[x] = result; + } + + fun union(a : Int, b : Int) { + val pa = parent(a) + val pb = parent(b) + if (pa != pb) { + if (Random.nextInt().isOdd) { + data[pb] = pa + } else { + data[pa] = pb + } + } + } +} + +val Int.isOdd : Boolean + get() = this % 2 != 0 diff --git a/idea/testData/psi/examples/UnionFind.txt b/idea/testData/psi/examples/UnionFind.txt new file mode 100644 index 00000000000..67ebaf6df76 --- /dev/null +++ b/idea/testData/psi/examples/UnionFind.txt @@ -0,0 +1,360 @@ +JetFile: UnionFind.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('UnionFind') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('IMutableList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('size') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('parent') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('p') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('x') + PsiElement(RBRACKET)(']') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('p') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('parent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('p') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('x') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('union') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pa') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('parent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pb') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('parent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('pa') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pb') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('Random') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('nextInt') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isOdd') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('pb') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pa') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('pa') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pb') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isOdd') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(PERC)('%') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') \ No newline at end of file diff --git a/idea/testData/psi/examples/UpdateOperation.jet b/idea/testData/psi/examples/UpdateOperation.jet new file mode 100644 index 00000000000..4d2aa3586f5 --- /dev/null +++ b/idea/testData/psi/examples/UpdateOperation.jet @@ -0,0 +1,14 @@ +class Pair(x : Int, y : Int) { + class object { + fun copy(from : Pair, x : Int = from.x, y : Int = from.y) = new Pair(x, y) + } +} + +// One can say: +val p = new Point(1, 2) +val p1 = Point.Copy(p, x = 2) +val p2 = Point.Copy(p1, y = -1) +val p3 = Point.Copy(p) + +// Such copy(...) methods can be automatically generated by the compiler +// whenever there is a primary constructor \ No newline at end of file diff --git a/idea/testData/psi/examples/UpdateOperation.txt b/idea/testData/psi/examples/UpdateOperation.txt new file mode 100644 index 00000000000..4d81fd223d1 --- /dev/null +++ b/idea/testData/psi/examples/UpdateOperation.txt @@ -0,0 +1,219 @@ +JetFile: UpdateOperation.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Pair') + TYPE_PARAMETER_LIST + + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS_OBJECT + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('copy') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Pair') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('from') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('from') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Pair') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiComment(EOL_COMMENT)('// One can say:') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('p') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Point') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('p1') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('Point') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('Copy') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('p') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + NAMED_ARGUMENT + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('p2') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('Point') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('Copy') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('p1') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + NAMED_ARGUMENT + PsiElement(IDENTIFIER)('y') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PREFIX_EXPRESSION + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('p3') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('Point') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('Copy') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('p') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + PsiComment(EOL_COMMENT)('// Such copy(...) methods can be automatically generated by the compiler') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('// whenever there is a primary constructor') \ No newline at end of file diff --git a/idea/testData/psi/examples/With.jet b/idea/testData/psi/examples/With.jet new file mode 100644 index 00000000000..8dc0a46640b --- /dev/null +++ b/idea/testData/psi/examples/With.jet @@ -0,0 +1,15 @@ +[inline] fun with(receiver : T, body : {T.() : Unit}) = receiver.body() + +fun example() { + + with(java.lang.System.out) { + println("foo"); + print("bar"); + } + + System.out.{ + println("foo"); + print("bar"); + }() + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/With.txt b/idea/testData/psi/examples/With.txt new file mode 100644 index 00000000000..951eacd738e --- /dev/null +++ b/idea/testData/psi/examples/With.txt @@ -0,0 +1,160 @@ +JetFile: With.jet + NAMESPACE + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('inline') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('with') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('receiver') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('body') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + RECEIVER_TYPE + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Unit') + PsiElement(RBRACE)('}') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('receiver') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('body') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('example') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('with') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lang') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('System') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('out') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"foo"') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('print') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"bar"') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('System') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('out') + PsiElement(DOT)('.') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('println') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"foo"') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('print') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + STRING_CONSTANT + PsiElement(STRING_LITERAL)('"bar"') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/array/MutableArray.jet b/idea/testData/psi/examples/array/MutableArray.jet new file mode 100644 index 00000000000..311279c875c --- /dev/null +++ b/idea/testData/psi/examples/array/MutableArray.jet @@ -0,0 +1,13 @@ +/** + These declarations are "shallow" in the sense that they are not really compiled, only the type-checker uses them +*/ + +virtual class ReadOnlyArray : ISized { + [operator] fun get(index : Int) : T +} + +virtual class WriteOnlyArray : ISized { // This is needed to keep IIterator's covariant + [operator] fun set(index : Int, value : T) +} + +class MutableArray : ReadOnlyArray, WriteOnlyArray {/*...*/} \ No newline at end of file diff --git a/idea/testData/psi/examples/array/MutableArray.txt b/idea/testData/psi/examples/array/MutableArray.txt new file mode 100644 index 00000000000..1493dec7142 --- /dev/null +++ b/idea/testData/psi/examples/array/MutableArray.txt @@ -0,0 +1,176 @@ +JetFile: MutableArray.jet + PsiComment(DOC_COMMENT)('/**\n These declarations are "shallow" in the sense that they are not really compiled, only the type-checker uses them\n*/') + PsiWhiteSpace('\n\n') + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ReadOnlyArray') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISized') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('get') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('WriteOnlyArray') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISized') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// This is needed to keep IIterator's covariant') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('set') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('MutableArray') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ReadOnlyArray') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('WriteOnlyArray') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiComment(BLOCK_COMMENT)('/*...*/') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/ArrayList.jet b/idea/testData/psi/examples/collections/ArrayList.jet new file mode 100644 index 00000000000..2f076052068 --- /dev/null +++ b/idea/testData/psi/examples/collections/ArrayList.jet @@ -0,0 +1,77 @@ +class ArrayList : IMutableList { + private var data = MutableArray(10) + private var used = 0 + private var version = 0 + + override fun iterator() : IIterator = mutableIterator() + + override fun mutableIterator() : IMutableIterator = object IMutableIterator() { // T is inferred + private val index = 0 + private var myVersion = version + + private fun checkVersion() { + if (version != myVersion) + throw new ConcurrentModificationException() + } + + override fun next() { + checkVersion() + if (hasNext) + throw new NoMoreElementsException() + data[index++] + } + + override val hasNext + get() = index < used + + + override fun remove() { + checkVersion() + val result = ArrayList.this.remove(index - 1) + myVersion = version + result + } + } + + override fun get(index : Int) { + checkIndex(index) + data[index] + } + + private fun checkIndex(index : Int) { + if (index > used) + throw new IndexOutOfBoundsException(index) + } + + override val isEmpty + get() = used == 0 + + + override val size + get() = used + + + override fun set(index : Int, value : T) { + checkIndex(index) + var result = data[index] + data[index] = value + result + } + + override fun add(index : Int, value : T) { + ensureSize(used + 1) + if (index == used) { + data[used++] = value + } else if (index < used) { + for (i in used-1..index) // backwards, special operator... Need to optimize this to be a real indexed loop + data[i + 1] = data[i] + data[index] = value + used++ + } else throw IndexOutOfBoundsException(index) + } + + override fun remove(index : Int) { + for (i in index..used-1) + data[i] = data[i + 1] + } +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/ArrayList.txt b/idea/testData/psi/examples/collections/ArrayList.txt new file mode 100644 index 00000000000..c00f2b120e9 --- /dev/null +++ b/idea/testData/psi/examples/collections/ArrayList.txt @@ -0,0 +1,823 @@ +JetFile: ArrayList.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ArrayList') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('MutableArray') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('used') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('iterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('mutableIterator') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableIterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(object)('object') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// T is inferred') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('myVersion') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('checkVersion') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('myVersion') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ConcurrentModificationException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkVersion') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PsiElement(IDENTIFIER)('hasNext') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('NoMoreElementsException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiElement(PLUSPLUS)('++') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hasNext') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('used') + PsiWhiteSpace('\n\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkVersion') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('ArrayList') + PsiElement(DOT)('.') + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('remove') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(MINUS)('-') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('myVersion') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('version') + PsiWhiteSpace('\n ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('get') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkIndex') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('index') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('checkIndex') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('used') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IndexOutOfBoundsException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('used') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('used') + PsiWhiteSpace('\n\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('set') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkIndex') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('index') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('index') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('ensureSize') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('used') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('used') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('used') + PsiElement(PLUSPLUS)('++') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('used') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('used') + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RANGE)('..') + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// backwards, special operator... Need to optimize this to be a real indexed loop') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('i') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('index') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('used') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('IndexOutOfBoundsException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiElement(RANGE)('..') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('used') + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('i') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/HashMap.jet b/idea/testData/psi/examples/collections/HashMap.jet new file mode 100644 index 00000000000..ab95747b4d4 --- /dev/null +++ b/idea/testData/psi/examples/collections/HashMap.jet @@ -0,0 +1,58 @@ +virtual class IEquality { + fun equals(other : Any) : Boolean + = (this as java.lang.Object).equals(other as java.lang.Object) +} + +virtual class IHashable : IEquality { + val hashCode : Integer + get() = (this as java.lang.Object).hashCode() + +} + +virtual class IMap { + fun get(key : K) : V + fun set(key : K, value : V) : V + fun remove(key : K) : V + fun containsKey(key : K) : Boolean +} + +class HashableWrapper wraps (val obj : Any) : IHashable + // equals and hashCode implementations are inherited + +[inline] fun Any.hashable() : HashableWrapper = new HashableWrapper(this) + +virtual class IHashingStrategy { + fun equals(a : K, b : K) : Boolean + fun hashCode(a : K) : Integer +} + +class DefaultHashingStrategy : IHashingStrategy { + override fun equals(a : K, b : K) : Boolean = a.equals(b) + override fun hashCode(a : K) : Integer = a.hashCode +} + +class JavaObjectHashingStrategy : IHashingStrategy { + override fun equals(a : K, b : K) : Boolean + = a.hashable().equals(b) + override fun hashCode(a : K) : Integer + = a.hashable().hashCode +} + +class HashMap : IMap { + private [inline] fun hashCode(a : K) = a.hashable().hashCode + private [inline] fun equals(a : K, b : K) = a.hashable() == b + + // everything else uses these equals() and hashCode()... + +} + +class StrategyHashMap(hashingStrategy : IHashingStrategy) : IMap { + + + // where !(K : IHashable) + this() : this(new JavaObjectHashingStrategy()) {} + + //this() where (K : IHashable) : this(new DefaultHashingStrategy()) {} + //... + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/HashMap.txt b/idea/testData/psi/examples/collections/HashMap.txt new file mode 100644 index 00000000000..4d37794515e --- /dev/null +++ b/idea/testData/psi/examples/collections/HashMap.txt @@ -0,0 +1,908 @@ +JetFile: HashMap.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IEquality') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('equals') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('other') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lang') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('Object') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('equals') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('other') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lang') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('Object') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IHashable') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IEquality') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hashCode') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Integer') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lang') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('Object') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashCode') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IMap') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('get') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('key') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('set') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('key') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('key') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('containsKey') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('key') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('HashableWrapper') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(wraps)('wraps') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('obj') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Any') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IHashable') + PsiWhiteSpace('\n ') + PsiComment(EOL_COMMENT)('// equals and hashCode implementations are inherited') + PsiWhiteSpace('\n\n') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('inline') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Any') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashable') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('HashableWrapper') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('HashableWrapper') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(this)('this') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IHashingStrategy') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('K') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('equals') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hashCode') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Integer') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('DefaultHashingStrategy') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('K') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IHashable') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IHashingStrategy') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('equals') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('equals') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hashCode') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Integer') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashCode') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('JavaObjectHashingStrategy') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('K') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IHashingStrategy') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('equals') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashable') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('equals') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hashCode') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Integer') + PsiWhiteSpace('\n ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashable') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashCode') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('HashMap') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMap') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('inline') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hashCode') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashable') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashCode') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('inline') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('equals') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('hashable') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// everything else uses these equals() and hashCode()... ') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('StrategyHashMap') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(IDENTIFIER)('hashingStrategy') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IHashingStrategy') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMap') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n\n\n ') + PsiComment(EOL_COMMENT)('// where !(K : IHashable)') + PsiWhiteSpace('\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + THIS_CALL + PsiElement(this)('this') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('JavaObjectHashingStrategy') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('K') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('//this() where (K : IHashable) : this(new DefaultHashingStrategy()) {}') + PsiWhiteSpace('\n ') + PsiComment(EOL_COMMENT)('//...') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IIterable.jet b/idea/testData/psi/examples/collections/IIterable.jet new file mode 100644 index 00000000000..5e69296338c --- /dev/null +++ b/idea/testData/psi/examples/collections/IIterable.jet @@ -0,0 +1,3 @@ +virtual class IIterable { + fun iterator() : IIterator +} diff --git a/idea/testData/psi/examples/collections/IIterable.txt b/idea/testData/psi/examples/collections/IIterable.txt new file mode 100644 index 00000000000..dd8d0ebbd17 --- /dev/null +++ b/idea/testData/psi/examples/collections/IIterable.txt @@ -0,0 +1,44 @@ +JetFile: IIterable.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IIterable') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('iterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IIterator.jet b/idea/testData/psi/examples/collections/IIterator.jet new file mode 100644 index 00000000000..faeb4d40a5c --- /dev/null +++ b/idea/testData/psi/examples/collections/IIterator.jet @@ -0,0 +1,25 @@ +virtual class IIterator { + fun next() : T + val hasNext : Boolean + + fun toArray(buffer : MutableArray) : Int { // T is still an in-parameter + return fillBuffer(buffer, 0, buffer.size) + } + + fun toArray(buffer : MutableArray, from : Int, length : Int) : Int { // T is still an in-parameter + if (from < 0 || from > buffer.lastIndex || length < 0 || length > buffer.size - from) { + throw IndexOutOfBoundsException(); + } + + if (len == 0) return 0 + + var count = 0; + for (i in from .. from + length - 1) { + if (!hasNext) + return count + buffer[i] = next() + count++ + } + return count + } +} diff --git a/idea/testData/psi/examples/collections/IIterator.txt b/idea/testData/psi/examples/collections/IIterator.txt new file mode 100644 index 00000000000..794732de7c4 --- /dev/null +++ b/idea/testData/psi/examples/collections/IIterator.txt @@ -0,0 +1,354 @@ +JetFile: IIterator.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IIterator') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hasNext') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('toArray') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('buffer') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('MutableArray') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// T is still an in-parameter') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('fillBuffer') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('buffer') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('buffer') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('toArray') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('buffer') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('MutableArray') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('length') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// T is still an in-parameter') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + BINARY_EXPRESSION + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace(' ') + PsiElement(OROR)('||') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('buffer') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lastIndex') + PsiWhiteSpace(' ') + PsiElement(OROR)('||') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('length') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace(' ') + PsiElement(OROR)('||') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('length') + PsiWhiteSpace(' ') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('buffer') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(MINUS)('-') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('from') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('IndexOutOfBoundsException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('len') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('count') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(SEMICOLON)(';') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(RANGE)('..') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('length') + PsiWhiteSpace(' ') + PsiElement(MINUS)('-') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + PsiElement(IDENTIFIER)('hasNext') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('count') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('buffer') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('i') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('next') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('count') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('count') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IList.jet b/idea/testData/psi/examples/collections/IList.jet new file mode 100644 index 00000000000..6daa67bac0f --- /dev/null +++ b/idea/testData/psi/examples/collections/IList.jet @@ -0,0 +1,4 @@ +virtual class IList : IIterable, ISized { + [operator] fun get(index : Int) : T + val isEmpty : Boolean +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IList.txt b/idea/testData/psi/examples/collections/IList.txt new file mode 100644 index 00000000000..97661755b21 --- /dev/null +++ b/idea/testData/psi/examples/collections/IList.txt @@ -0,0 +1,87 @@ +JetFile: IList.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IList') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISized') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('get') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableIterable.jet b/idea/testData/psi/examples/collections/IMutableIterable.jet new file mode 100644 index 00000000000..22b6e017d8e --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableIterable.jet @@ -0,0 +1,3 @@ +virtual class IMutableIterable : IIterable { + fun mutableIterator() : IMutableIterator +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableIterable.txt b/idea/testData/psi/examples/collections/IMutableIterable.txt new file mode 100644 index 00000000000..1a9b7d287ea --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableIterable.txt @@ -0,0 +1,59 @@ +JetFile: IMutableIterable.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IMutableIterable') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableIterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableIterator.jet b/idea/testData/psi/examples/collections/IMutableIterator.jet new file mode 100644 index 00000000000..51111049926 --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableIterator.jet @@ -0,0 +1,13 @@ +virtual class IMutableIterator : IIterator { + fun remove() : T + +/* + Considerations: + pro: why not + non iteration breaking + con: counter-intuitive for, e.g., TreeSet + + + fun addBefore(item : T) : Boolean + fun addAfter(item : T) : Boolean +*/ +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableIterator.txt b/idea/testData/psi/examples/collections/IMutableIterator.txt new file mode 100644 index 00000000000..6969f5e81f9 --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableIterator.txt @@ -0,0 +1,55 @@ +JetFile: IMutableIterator.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IMutableIterator') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n\n') + PsiComment(BLOCK_COMMENT)('/*\n Considerations:\n pro: why not + non iteration breaking\n con: counter-intuitive for, e.g., TreeSet\n\n\n fun addBefore(item : T) : Boolean\n fun addAfter(item : T) : Boolean\n*/') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableList.jet b/idea/testData/psi/examples/collections/IMutableList.jet new file mode 100644 index 00000000000..711f0d6bfc7 --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableList.jet @@ -0,0 +1,6 @@ +virtual class IMutableList : IList, IMutableIterable { + fun set(index : Int, value : T) : T + fun add(index : Int, value : T) + fun remove(index : Int) : T + fun mutableIterator() : IMutableIterator +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableList.txt b/idea/testData/psi/examples/collections/IMutableList.txt new file mode 100644 index 00000000000..8288204bd1a --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableList.txt @@ -0,0 +1,155 @@ +JetFile: IMutableList.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IMutableList') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('set') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableIterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableSet.jet b/idea/testData/psi/examples/collections/IMutableSet.jet new file mode 100644 index 00000000000..eacb0d740ec --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableSet.jet @@ -0,0 +1,4 @@ +virtual class IMutableSet : ISet, IMutableIterable { + fun add(item : T) : Boolean + fun remove(item : T) : Boolean +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/IMutableSet.txt b/idea/testData/psi/examples/collections/IMutableSet.txt new file mode 100644 index 00000000000..fab87bdb9f7 --- /dev/null +++ b/idea/testData/psi/examples/collections/IMutableSet.txt @@ -0,0 +1,95 @@ +JetFile: IMutableSet.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IMutableSet') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISet') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/ISet.jet b/idea/testData/psi/examples/collections/ISet.jet new file mode 100644 index 00000000000..bfe2753b8df --- /dev/null +++ b/idea/testData/psi/examples/collections/ISet.jet @@ -0,0 +1,3 @@ +virtual class ISet : IIterable, ISized { + fun contains(item : T) : Boolean +} diff --git a/idea/testData/psi/examples/collections/ISet.txt b/idea/testData/psi/examples/collections/ISet.txt new file mode 100644 index 00000000000..e4e04078f9d --- /dev/null +++ b/idea/testData/psi/examples/collections/ISet.txt @@ -0,0 +1,65 @@ +JetFile: ISet.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ISet') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ISized') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('contains') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/ISized.jet b/idea/testData/psi/examples/collections/ISized.jet new file mode 100644 index 00000000000..9f12cb218b0 --- /dev/null +++ b/idea/testData/psi/examples/collections/ISized.jet @@ -0,0 +1,3 @@ +virtual class ISized { + val size : Int +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/ISized.txt b/idea/testData/psi/examples/collections/ISized.txt new file mode 100644 index 00000000000..be622e499eb --- /dev/null +++ b/idea/testData/psi/examples/collections/ISized.txt @@ -0,0 +1,27 @@ +JetFile: ISized.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ISized') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/LinkedList.jet b/idea/testData/psi/examples/collections/LinkedList.jet new file mode 100644 index 00000000000..9519bcefbb1 --- /dev/null +++ b/idea/testData/psi/examples/collections/LinkedList.jet @@ -0,0 +1,73 @@ +class LinkedList : IMutableList { + private class Item(var value : Item) { + var next : Item + var previous : Item + } + + private var head : Item = null + private var tail : Item = null + override var size get private set + + override fun add(index : Int, value : T) { + size++ + checkIndex(index) + val newItem = Item(value) + if (index == 0) { + newItem.next = head + head = newItem + if (tail === null) { + tail = head + } + } else { + var insertAfter = itemAt(index) + newItem.next = insertAfter.next + insertAfter.next = newItem + if (tail === insertAfter) { + tail = newItem + } + } + } + + private fun checkIndex(index : Int) { + if (index !in 0..size-1) { + throw IndexOutOfBoundsException(index) + } + } + + override fun remove(index : Int) : T { + checkIndex(index) + val item = itemAt(index) + if (item === head) { + head = item.next + if (head === null) + tail= null + } else { + item.previous.next = item.next + if (item.next === null) { + item.next.previous = item.previous + } else { + tail = tail.previous + } + } + size-- + return item.value + } + + override fun set(index : Int, value : T) : T { + checkIndex(index) + val item = itemAt(index) + val result = item.value + item.value = value + return result + } + + private fun itemAt(index : Int) { + var result = head + for (i in 1..index) { + result = result.next + } + return result + } + + override fun mutableIterator() : IMutableIterator +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/LinkedList.txt b/idea/testData/psi/examples/collections/LinkedList.txt new file mode 100644 index 00000000000..4ce72b96d99 --- /dev/null +++ b/idea/testData/psi/examples/collections/LinkedList.txt @@ -0,0 +1,798 @@ +JetFile: LinkedList.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('LinkedList') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Item') + TYPE_PARAMETER_LIST + + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('previous') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Item') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiWhiteSpace(' ') + PROPERTY_ACCESSOR + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(set)('set') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('size') + PsiElement(PLUSPLUS)('++') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkIndex') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newItem') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Item') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('newItem') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newItem') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQEQEQ)('===') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('insertAfter') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('itemAt') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('newItem') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('insertAfter') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('insertAfter') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newItem') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQEQEQ)('===') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('insertAfter') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('newItem') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('checkIndex') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(NOT_IN)('!in') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RANGE)('..') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('size') + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('IndexOutOfBoundsException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('remove') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkIndex') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('itemAt') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(EQEQEQ)('===') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace(' ') + PsiElement(EQEQEQ)('===') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('previous') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQEQEQ)('===') + PsiWhiteSpace(' ') + NULL + PsiElement(null)('null') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('previous') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('previous') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace(' ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('previous') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + POSTFIX_EXPRESSION + PsiElement(IDENTIFIER)('size') + PsiElement(MINUSMINUS)('--') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('set') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('checkIndex') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('itemAt') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('item') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('itemAt') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('head') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RANGE)('..') + PsiElement(IDENTIFIER)('index') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('result') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('mutableIterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/List.jet b/idea/testData/psi/examples/collections/List.jet new file mode 100644 index 00000000000..0a8d852eb41 --- /dev/null +++ b/idea/testData/psi/examples/collections/List.jet @@ -0,0 +1,27 @@ +enum class List(theSize : Int) : IList { + Nil : List(0) + + Cons(val value : T, val tail : List) : List(1 + tail.size) + + override val size : Int + get() = theSize + + + override val isEmpty : Boolean + get() = this == Nil + + + override fun iterator() = new IIterator() { + private var current = List.this + + override val hasNext { + get() = current == Nil + } + + override fun next() { + val result = current.value + current = current.tail + return result + } + } +} \ No newline at end of file diff --git a/idea/testData/psi/examples/collections/List.txt b/idea/testData/psi/examples/collections/List.txt new file mode 100644 index 00000000000..d54eb563f6b --- /dev/null +++ b/idea/testData/psi/examples/collections/List.txt @@ -0,0 +1,314 @@ +JetFile: List.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('List') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(IDENTIFIER)('theSize') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('Nil') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Nothing') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('Cons') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('List') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('tail') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('theSize') + PsiWhiteSpace('\n\n\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Nil') + PsiWhiteSpace('\n\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('iterator') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + NEW + PsiElement(new)('new') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterator') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('List') + PsiElement(DOT)('.') + PsiElement(this)('this') + PsiWhiteSpace('\n\n ') + CALL_EXPRESSION + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hasNext') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + CALL_EXPRESSION + PsiElement(IDENTIFIER)('get') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Nil') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('tail') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('result') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/io/IOSamples.jet b/idea/testData/psi/examples/io/IOSamples.jet new file mode 100644 index 00000000000..4304fc00a38 --- /dev/null +++ b/idea/testData/psi/examples/io/IOSamples.jet @@ -0,0 +1,62 @@ +virtual class IAdder { + fun add(item : T) : Boolean +} + +virtual class ICloseable { + fun close() +} + +abstract class JavaCloseableWrapper(closeable : java.io.Closeable) : ICloseable(closeable) + +fun streamCopy(from : IIterable, to : IAdder) { + for (item in from) t.add(item) +} + +class FileInput : IIterator, JavaCloseableWrapper { + private val stream : InputStream + private var next : Int + private var nextUsed = false + + this(file : File) : JavaCloseableWrapper(stream) { // implicitly throws IOException + stream = FileInputStream(file) // throws IOException + } + + override fun next() { + if (!nextUsed) { + nextUsed = true + return next as Byte + } + return + } + + override val hasNext + get() { // implicitly throws IOException + if (nextUsed && next != -1) { + nextUsed = false + next = stream.read() // throws IOException + } + return next != -1 + } + +} + +class FileOutput : IAdder, JavaCloseableWrapper { + private val stream : OutputStream + + this(file : File) : JavaCloseableWrapper(stream) { + stream = FileOutputStream(file) + } + + override fun add(item : Byte) { + stream.write(item) + } +} + +fun example() { // this does not rethrow, no appropriate parameters given + + val f1 : File //= ... + val f2 : File //= ... + + streamCopy(FileInput(f1), f2) // throws IOException, you must catch or rethrow explicitly + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/io/IOSamples.txt b/idea/testData/psi/examples/io/IOSamples.txt new file mode 100644 index 00000000000..81b8befce58 --- /dev/null +++ b/idea/testData/psi/examples/io/IOSamples.txt @@ -0,0 +1,643 @@ +JetFile: IOSamples.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IAdder') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ICloseable') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('close') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(abstract)('abstract') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('JavaCloseableWrapper') + TYPE_PARAMETER_LIST + + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(IDENTIFIER)('closeable') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + USER_TYPE + PsiElement(IDENTIFIER)('io') + PsiElement(DOT)('.') + USER_TYPE + PsiElement(IDENTIFIER)('Closeable') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ICloseable') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('closeable') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('streamCopy') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('from') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('to') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IAdder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + PsiElement(IDENTIFIER)('from') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('t') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('FileInput') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterator') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Byte') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('JavaCloseableWrapper') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('stream') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('InputStream') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('nextUsed') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('file') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('File') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('JavaCloseableWrapper') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('stream') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// implicitly throws IOException') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('stream') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('FileInputStream') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('file') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// throws IOException') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('next') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + PsiElement(IDENTIFIER)('nextUsed') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('nextUsed') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Byte') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n \n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('hasNext') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// implicitly throws IOException') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('nextUsed') + PsiWhiteSpace(' ') + PsiElement(ANDAND)('&&') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + PREFIX_EXPRESSION + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('nextUsed') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('stream') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('read') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// throws IOException') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('next') + PsiWhiteSpace(' ') + PsiElement(EXCLEQ)('!=') + PsiWhiteSpace(' ') + PREFIX_EXPRESSION + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace(' \n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('FileOutput') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IAdder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Byte') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('JavaCloseableWrapper') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('stream') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('OutputStream') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('file') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('File') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + INITIALIZER_LIST + DELEGATOR_SUPER_CALL + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('JavaCloseableWrapper') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('stream') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('stream') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('FileOutputStream') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('file') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Byte') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('stream') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('write') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('example') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// this does not rethrow, no appropriate parameters given') + PsiWhiteSpace('\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f1') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('File') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('//= ...') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('f2') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('File') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('//= ...') + PsiWhiteSpace('\n\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('streamCopy') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + CALL_EXPRESSION + PsiElement(IDENTIFIER)('FileInput') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('f1') + PsiElement(RPAR)(')') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('f2') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// throws IOException, you must catch or rethrow explicitly') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/map/IMap.jet b/idea/testData/psi/examples/map/IMap.jet new file mode 100644 index 00000000000..0b912bb838d --- /dev/null +++ b/idea/testData/psi/examples/map/IMap.jet @@ -0,0 +1,4 @@ +virtual class IMap { + + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/map/IMap.txt b/idea/testData/psi/examples/map/IMap.txt new file mode 100644 index 00000000000..db79dcc4753 --- /dev/null +++ b/idea/testData/psi/examples/map/IMap.txt @@ -0,0 +1,29 @@ +JetFile: IMap.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IMap') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('K') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(out)('out') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('V') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n \n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/priorityqueues/BinaryHeap.jet b/idea/testData/psi/examples/priorityqueues/BinaryHeap.jet new file mode 100644 index 00000000000..d7e5aaf8285 --- /dev/null +++ b/idea/testData/psi/examples/priorityqueues/BinaryHeap.jet @@ -0,0 +1,106 @@ +class BinaryHeap : IPriorityQueue { + private val data : IMutableList + private val compare : Comparison + + this(data : IIterable, compare : Comparison = naturalOrder) { + this.compare = compare + this.data = ArrayList(data) +// siftDown(* this.data.size / 2 .. 0) + + for (val i in data.size / 2 .. 0) { + siftDown(i) + } + + } + + this(compare : Comparison) { + this.compare = compare + this.data = ArrayList() + } + + this() { + this.data = ArrayList() + Assert(T is IComparable) + this.comparator = naturalOrder + } + + override fun extract() : T { + if (this.isEmpty) + throw UnderflowException() + data.swap(0, data.lastIndex) + data.remove(data.lastIndex) + siftDown(0) + } + + override fun add(item : T) { + data.add(item) + siftUp(data.lastItem) + } + + private fun siftDown(index : Int) { + var current = index + while (current.left.exists) { + var min = current + if (current.left.value < min.value) { + min = current.left + } + if (current.right.exists && current.right.value < min.value) { + min = current.right + } + if (min == current) break + data.swap(min, current) + current = min + } + } + + private fun siftUp(index : Int) { + if (!current.exists) return + var current = index + while (current.parent.exists) { + if (current.value < current.parent.value) { + data.swap(current, current.parent) + current = current.parent + } + } + } + + private extension HeapIndex for Int { + val parent : Int + get() = (this - 1) / 2 + + + val left : Int + get() = this * 2 + 1 + + + val right : Int + get() = this * 2 + 2 + + + val value : T = foo.bar() + get() = data[this] + set(it) { + $value = it + } + + + val exists : Boolean + get() = (this < data.size) && (this >= 0) + + } + + private extension for T { + [operator] fun compareTo(other : T) : Int = compare(this, other) + } + +} + +fun IMutableList.swap(a : Int, b : Int) { + val t = this[a] + this[a] = this[b] + this[b] = t +} + +val IList.lastIndex : Int + get() = this.size - 1 + diff --git a/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt b/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt new file mode 100644 index 00000000000..2ba9fdb9103 --- /dev/null +++ b/idea/testData/psi/examples/priorityqueues/BinaryHeap.txt @@ -0,0 +1,1175 @@ +JetFile: BinaryHeap.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('BinaryHeap') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IPriorityQueue') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Comparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IIterable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Comparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('naturalOrder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('ArrayList') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('data') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiComment(EOL_COMMENT)('// siftDown(* this.data.size / 2 .. 0)') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + LOOP_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('i') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + BINARY_EXPRESSION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(DIV)('/') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace(' ') + PsiElement(RANGE)('..') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + PsiElement(IDENTIFIER)('siftDown') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('i') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Comparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('compare') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('ArrayList') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + CONSTRUCTOR + PsiElement(this)('this') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('ArrayList') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Assert') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(is)('is') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('IComparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('comparator') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('naturalOrder') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('extract') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + THEN + THROW + PsiElement(throw)('throw') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('UnderflowException') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('swap') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lastIndex') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('remove') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lastIndex') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('siftDown') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('siftUp') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lastItem') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('siftDown') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace('\n ') + WHILE + PsiElement(while)('while') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('exists') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('min') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('min') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('min') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('exists') + PsiWhiteSpace(' ') + PsiElement(ANDAND)('&&') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('min') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('min') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('min') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + BREAK + PsiElement(break)('break') + PsiWhiteSpace('\n ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('swap') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('min') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('min') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUN + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('siftUp') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + PREFIX_EXPRESSION + PsiElement(EXCL)('!') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('exists') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('index') + PsiWhiteSpace('\n ') + WHILE + PsiElement(while)('while') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('exists') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BODY + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('swap') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('current') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('current') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('parent') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + EXTENSION + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(extension)('extension') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('HeapIndex') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(for)('for') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('parent') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(MINUS)('-') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DIV)('/') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace('\n\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('left') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(MUL)('*') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('right') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(MUL)('*') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace(' ') + PsiElement(PLUS)('+') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('2') + PsiWhiteSpace('\n\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('value') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('bar') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(IDENTIFIER)('data') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(this)('this') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(set)('set') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('it') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('$value') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('it') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('exists') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(ANDAND)('&&') + PsiWhiteSpace(' ') + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(this)('this') + PsiWhiteSpace(' ') + PsiElement(GTEQ)('>=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + EXTENSION + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(extension)('extension') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + PsiElement(for)('for') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + ATTRIBUTE_ANNOTATION + PsiElement(LBRACKET)('[') + ATTRIBUTE + USER_TYPE + PsiElement(IDENTIFIER)('operator') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('compareTo') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('other') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('compare') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(this)('this') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('other') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IMutableList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('swap') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(this)('this') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(this)('this') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + ARRAY_ACCESS_EXPRESSION + PsiElement(this)('this') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('b') + PsiElement(RBRACKET)(']') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + ARRAY_ACCESS_EXPRESSION + PsiElement(this)('this') + INDICES + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('b') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IList') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('lastIndex') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BINARY_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(this)('this') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(MINUS)('-') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') \ No newline at end of file diff --git a/idea/testData/psi/examples/priorityqueues/IPriorityQueue.jet b/idea/testData/psi/examples/priorityqueues/IPriorityQueue.jet new file mode 100644 index 00000000000..b343cd49cc3 --- /dev/null +++ b/idea/testData/psi/examples/priorityqueues/IPriorityQueue.jet @@ -0,0 +1,5 @@ +virtual class IPriorityQueue { + fun extract() : T + fun add(item : T) + val isEmpty : Boolean +} diff --git a/idea/testData/psi/examples/priorityqueues/IPriorityQueue.txt b/idea/testData/psi/examples/priorityqueues/IPriorityQueue.txt new file mode 100644 index 00000000000..bbeb7c42334 --- /dev/null +++ b/idea/testData/psi/examples/priorityqueues/IPriorityQueue.txt @@ -0,0 +1,64 @@ +JetFile: IPriorityQueue.jet + NAMESPACE + CLASS + MODIFIER_LIST + PsiElement(virtual)('virtual') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IPriorityQueue') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('extract') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('add') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.jet b/idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.jet new file mode 100644 index 00000000000..2d20c5666e7 --- /dev/null +++ b/idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.jet @@ -0,0 +1,7 @@ +class PriorityQueueAsPushPop wraps(wrapped : IPriorityQueue) : IPushPop { + override fun pop() = wrapped.extract() + override fun push(item : T) = wrapped.add(item) + override val isEmpty + get() = wrapped.isEmpty + +} \ No newline at end of file diff --git a/idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt b/idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt new file mode 100644 index 00000000000..5ca1a884b05 --- /dev/null +++ b/idea/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt @@ -0,0 +1,128 @@ +JetFile: PriorityQueueAsPushPop.jet + NAMESPACE + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('PriorityQueueAsPushPop') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(wraps)('wraps') + PRIMARY_CONSTRUCTOR_PARAMETERS_LIST + PsiElement(LPAR)('(') + PRIMARY_CONSTRUCTOR_PARAMETER + PsiElement(IDENTIFIER)('wrapped') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IPriorityQueue') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + DELEGATION_SPECIFIER_LIST + DELEGATION_SPECIFIER + DELEGATOR_SUPER_CLASS + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IPushPop') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('pop') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('wrapped') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('extract') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + FUN + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('push') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('item') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('wrapped') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('add') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('item') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + PsiElement(override)('override') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('wrapped') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('isEmpty') + PsiWhiteSpace('\n\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/util/Comparison.jet b/idea/testData/psi/examples/util/Comparison.jet new file mode 100644 index 00000000000..12a9fdc35c0 --- /dev/null +++ b/idea/testData/psi/examples/util/Comparison.jet @@ -0,0 +1,19 @@ +type Comparison = {(T, T) : Int} + +fun naturalOrder>(a : T, b : T) : Int = a.compareTo(b) + +fun castingNaturalOrder(a : Object, b : Object) : Int = (a as Comparable).compareTo(b as Comparable) + +enum class ComparisonResult { + LS; EQ; GR +} + +type MatchableComparison = {(T, T) : ComparisonResult} + +fun asMatchableComparison(cmp : Comparison) : MatchableComparison = {(a, b) => + val res = cmp(a, b) + if (res == 0) return ComparisonResult.EQ + if (res < 0) return ComparisonResult.LS + return ComparisonResult.GR +} + diff --git a/idea/testData/psi/examples/util/Comparison.txt b/idea/testData/psi/examples/util/Comparison.txt new file mode 100644 index 00000000000..b8865cb47ac --- /dev/null +++ b/idea/testData/psi/examples/util/Comparison.txt @@ -0,0 +1,377 @@ +JetFile: Comparison.jet + NAMESPACE + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Comparison') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('naturalOrder') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('IComparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('compareTo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('castingNaturalOrder') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Object') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Object') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + DOT_QIALIFIED_EXPRESSION + TUPLE + PsiElement(LPAR)('(') + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Object') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('compareTo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(as)('as') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('Comparable') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Object') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ComparisonResult') + PsiWhiteSpace(' ') + TYPE_PARAMETER_LIST + + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('LS') + TYPE_PARAMETER_LIST + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace(' ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('EQ') + TYPE_PARAMETER_LIST + + PsiElement(SEMICOLON)(';') + PsiWhiteSpace(' ') + ENUM_ENTRY + PsiElement(IDENTIFIER)('GR') + PsiWhiteSpace('\n') + TYPE_PARAMETER_LIST + + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + TYPEDEF + PsiElement(type)('type') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('MatchableComparison') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + TYPE_REFERENCE + FUNCTION_TYPE + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('ComparisonResult') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('asMatchableComparison') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('cmp') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Comparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('MatchableComparison') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace('\n ') + BODY + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('res') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + CALL_EXPRESSION + PsiElement(IDENTIFIER)('cmp') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('res') + PsiWhiteSpace(' ') + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('ComparisonResult') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('EQ') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + PsiElement(IDENTIFIER)('res') + PsiWhiteSpace(' ') + PsiElement(LT)('<') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('ComparisonResult') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('LS') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + DOT_QIALIFIED_EXPRESSION + PsiElement(IDENTIFIER)('ComparisonResult') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('GR') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/psi/examples/util/IComparable.jet b/idea/testData/psi/examples/util/IComparable.jet new file mode 100644 index 00000000000..79d19a364e6 --- /dev/null +++ b/idea/testData/psi/examples/util/IComparable.jet @@ -0,0 +1,3 @@ +interface class IComparable { + fun compareTo(other : T) : Int +} \ No newline at end of file diff --git a/idea/testData/psi/examples/util/IComparable.txt b/idea/testData/psi/examples/util/IComparable.txt new file mode 100644 index 00000000000..d9b26cc9353 --- /dev/null +++ b/idea/testData/psi/examples/util/IComparable.txt @@ -0,0 +1,46 @@ +JetFile: IComparable.jet + NAMESPACE + PsiErrorElement:Expecting namespace or top level declaration + PsiElement(IDENTIFIER)('interface') + PsiWhiteSpace(' ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('IComparable') + TYPE_PARAMETER_LIST + PsiElement(LT)('<') + TYPE_PARAMETER + MODIFIER_LIST + PsiElement(in)('in') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('compareTo') + TYPE_PARAMETER_LIST + + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('other') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('T') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java b/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java index 9ea79be05b4..91f4e978215 100644 --- a/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java +++ b/idea/tests/org/jetbrains/jet/parsing/JetParsingTest.java @@ -5,21 +5,30 @@ package org.jetbrains.jet.parsing; import com.intellij.openapi.application.PathManager; import com.intellij.testFramework.ParsingTestCase; -import org.jetbrains.annotations.NonNls; +import junit.framework.TestSuite; import java.io.File; +import java.io.FileFilter; +import java.io.FilenameFilter; public class JetParsingTest extends ParsingTestCase { static { System.setProperty("idea.platform.prefix", "Idea"); } - public JetParsingTest() { - super("", "jet"); + private final String name; + + public JetParsingTest(String dataPath, String name) { + super(dataPath, "jet"); + this.name = name; } @Override protected String getTestDataPath() { + return getTestDataDir(); + } + + private static String getTestDataDir() { return getHomeDirectory() + "/idea/testData"; } @@ -27,50 +36,49 @@ public class JetParsingTest extends ParsingTestCase { return new File(PathManager.getResourceRoot(JetParsingTest.class, "/")).getParentFile().getParentFile().getParent(); } - public void testAnnotatedExpressions() throws Exception {doTest(true);} - public void testAttributes() throws Exception {doTest(true);} - public void testAttributes_ERR() throws Exception {doTest(true);} - public void testBabySteps() throws Exception {doTest(true);} - public void testBabySteps_ERR() throws Exception {doTest(true);} - public void testConstructors() throws Exception {doTest(true);} - public void testControlStructures() throws Exception {doTest(true);} - public void testDecomposers() throws Exception {doTest(true);} - public void testDecomposers_ERR() throws Exception {doTest(true);} - public void testEmptyFile() throws Exception {doTest(true);} - public void testEnums() throws Exception {doTest(true);} - public void testEOLsInComments() throws Exception {doTest(true);} - public void testEOLsOnRollback() throws Exception {doTest(true);} - public void testExtensions() throws Exception {doTest(true);} - public void testExtensions_ERR() throws Exception {doTest(true);} - public void testFileStart_ERR() throws Exception {doTest(true);} - public void testFunctionCalls() throws Exception {doTest(true);} - public void testFunctionLiterals() throws Exception {doTest(true);} - public void testFunctionLiterals_ERR() throws Exception {doTest(true);} - public void testFunctions() throws Exception {doTest(true);} - public void testFunctions_ERR() throws Exception {doTest(true);} - public void testFunctionTypes() throws Exception {doTest(true);} - public void testFunctionTypes_ERR() throws Exception {doTest(true);} - public void testImports() throws Exception {doTest(true);} - public void testImports_ERR() throws Exception {doTest(true);} - public void testImportSoftKW() throws Exception {doTest(true);} - public void testLocalDeclarations() throws Exception {doTest(true);} - public void testMatch() throws Exception {doTest(true);} - public void testMatch_ERR() throws Exception {doTest(true);} - public void testNamespaceBlock_ERR() throws Exception {doTest(true);} - public void testNamespaceBlock() throws Exception {doTest(true);} - public void testNewlinesInParentheses() throws Exception {doTest(true);} - public void testPrecedence() throws Exception {doTest(true);} - public void testProperties() throws Exception {doTest(true);} - public void testProperties_ERR() throws Exception {doTest(true);} - public void testSimpleClassMembers() throws Exception {doTest(true);} - public void testSimpleClassMembers_ERR() throws Exception {doTest(true);} - public void testSimpleExpressions() throws Exception {doTest(true);} - public void testSimpleModifiers() throws Exception {doTest(true);} - public void testSoftKeywords() throws Exception {doTest(true);} - public void testTupleTypes() throws Exception {doTest(true);} - public void testTupleTypes_ERR() throws Exception {doTest(true);} - public void testTypeAnnotations() throws Exception {doTest(true);} - public void testTypeConstraints() throws Exception {doTest(true);} - public void testTypeDef() throws Exception {doTest(true);} - public void testTypeDef_ERR() throws Exception {doTest(true);} + @Override + protected void runTest() throws Throwable { + doTest(true); + } + + @Override + public String getName() { + return "test" + name; + } + + public static TestSuite suite() { + TestSuite suite = new TestSuite(); + suite.addTest(suiteForDirectory("/", false)); + suite.addTest(suiteForDirectory("examples", true)); + return suite; + } + + private static TestSuite suiteForDirectory(final String dataPath, boolean recursive) { + TestSuite suite = new TestSuite(dataPath); + final String extension = ".jet"; + FilenameFilter extensionFilter = new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith(extension); + } + }; + File dir = new File(getTestDataDir() + "/psi/" + dataPath); + FileFilter dirFilter = new FileFilter() { + @Override + public boolean accept(File pathname) { + return pathname.isDirectory(); + } + }; + if (recursive) { + for (File subDir : dir.listFiles(dirFilter)) { + suite.addTest(suiteForDirectory(dataPath + "/" + subDir.getName(), recursive)); + } + } + for (File file : dir.listFiles(extensionFilter)) { + String fileName = file.getName(); + suite.addTest(new JetParsingTest(dataPath, fileName.substring(0, fileName.length() - extension.length()))); + } + return suite; + } + }