diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/ArrayVariable.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/ArrayVariable.kt new file mode 100644 index 000000000000..654d2d9431ae --- /dev/null +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/ArrayVariable.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.streams.trace.dsl + +import com.intellij.debugger.streams.trace.dsl.impl.TextExpression + + +/** + * @author Vitaliy.Bibaev + */ +interface ArrayVariable : Variable { + val elementType: String + + operator fun get(index: Expression): Expression + operator fun get(index: Int): Expression = get(TextExpression(index.toString())) + operator fun set(index: Expression, value: Expression): Expression + operator fun set(index: Int, value: Expression): Expression = set(TextExpression(index.toString()), value) +} \ No newline at end of file diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/DslFactory.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/DslFactory.kt index d44f9d745466..7ccc18293cdc 100644 --- a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/DslFactory.kt +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/DslFactory.kt @@ -26,6 +26,8 @@ interface DslFactory { fun variable(type: String, name: String): Variable + fun array(elementType: String, name: String): ArrayVariable + fun map(keyType: GenericType, valueType: GenericType, name: String): MapVariable fun linkedMap(keyType: GenericType, valueType: GenericType, name: String): MapVariable diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/StatementFactory.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/StatementFactory.kt index de655867874b..ea2cff83d87f 100644 --- a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/StatementFactory.kt +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/StatementFactory.kt @@ -55,4 +55,6 @@ interface StatementFactory { fun createAssignmentStatement(variable: Variable, expression: Expression): AssignmentStatement fun createMapVariable(keyType: GenericType, valueType: GenericType, name: String, linked: Boolean): MapVariable + + fun createArrayVariable(elementType: String, name: String): ArrayVariable } diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/DslImpl.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/DslImpl.kt index 22b6c0a1fc53..58ff480a05c3 100644 --- a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/DslImpl.kt +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/DslImpl.kt @@ -34,6 +34,8 @@ class DslImpl(override val statementFactory: StatementFactory) : Dsl { return fragment.toCode(0) } + override fun array(elementType: String, name: String): ArrayVariable = statementFactory.createArrayVariable(elementType, name) + override fun map(keyType: GenericType, valueType: GenericType, name: String): MapVariable = statementFactory.createMapVariable(keyType, valueType, name, false) diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaArrayVariable.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaArrayVariable.kt new file mode 100644 index 000000000000..a4a39c901cf5 --- /dev/null +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaArrayVariable.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.streams.trace.dsl.impl.java + +import com.intellij.debugger.streams.trace.dsl.ArrayVariable +import com.intellij.debugger.streams.trace.dsl.Expression +import com.intellij.debugger.streams.trace.dsl.impl.TextExpression +import com.intellij.debugger.streams.trace.dsl.impl.VariableImpl + +/** + * @author Vitaliy.Bibaev + */ +class JavaArrayVariable(override val elementType: String, name: String) : VariableImpl("$elementType[]", name), ArrayVariable { + override fun get(index: Expression): Expression = TextExpression("$name[${index.toCode()}]") + + override fun set(index: Expression, value: Expression): Expression = TextExpression("$name[${index.toCode()}] = ${value.toCode()}") +} \ No newline at end of file diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaStatementFactory.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaStatementFactory.kt index 6041d65decba..7dabc7b3430b 100644 --- a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaStatementFactory.kt +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/java/JavaStatementFactory.kt @@ -69,4 +69,6 @@ class JavaStatementFactory : StatementFactory { override fun createMapVariable(keyType: GenericType, valueType: GenericType, name: String, linked: Boolean): MapVariable = JavaMapVariable(keyType, valueType, name, linked) -} \ No newline at end of file + + override fun createArrayVariable(elementType: String, name: String): ArrayVariable = JavaArrayVariable(elementType, name) +} diff --git a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/kotlin/KotlinStatementFactory.kt b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/kotlin/KotlinStatementFactory.kt index 63a25ebe71ab..92fa47016ccc 100644 --- a/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/kotlin/KotlinStatementFactory.kt +++ b/plugins/stream-debugger/src/main/java/com/intellij/debugger/streams/trace/dsl/impl/kotlin/KotlinStatementFactory.kt @@ -89,4 +89,8 @@ class KotlinStatementFactory : StatementFactory { override fun createMapVariable(keyType: GenericType, valueType: GenericType, name: String, linked: Boolean): MapVariable { TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } + + override fun createArrayVariable(elementType: String, name: String): ArrayVariable { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } }