GitHub PullRequestReviewCommentEvent at 2014-02-28 10:51:57
Repository: kotlin
Actor: asedunov
Payload: {"comment":{"url":"https://api.github.com/repos/JetBrains/kotlin/pulls/comments/10160465","id":10160465,"diff_hunk":"@@ -0,0 +1,78 @@\n+/*\n+ * Copyright 2010-2014 JetBrains s.r.o.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.jetbrains.jet.plugin.intentions\n+\n+import org.jetbrains.jet.lang.psi.JetBinaryExpression\n+import com.intellij.openapi.editor.Editor\n+import org.jetbrains.jet.lexer.JetTokens\n+import org.jetbrains.jet.lang.psi.JetPsiFactory\n+import org.jetbrains.jet.plugin.references.JetSimpleNameReference\n+import org.jetbrains.jet.lang.psi.JetSimpleNameExpression\n+\n+public class ReplaceWithOperatorAssignIntention : JetSelfTargetingIntention<JetBinaryExpression>(\"replace.with.operator.assign.intention\", javaClass()) {\n+    override fun isApplicableTo(element: JetBinaryExpression): Boolean {\n+        fun checkForNullSafety(element : JetBinaryExpression): Boolean {\n+            val rightExpression = element.getRight()\n+\n+            return element.getLeft() != null &&\n+                    element.getRight() != null &&\n+                    element.getLeft() is JetSimpleNameExpression &&\n+                    element.getOperationToken() == JetTokens.EQ &&\n+                    rightExpression is JetBinaryExpression &&\n+                    rightExpression.getLeft() != null &&\n+                    rightExpression.getRight() != null\n+        }\n+\n+        fun checkExpressionRepeat(variableExpression: JetSimpleNameExpression, expression: JetBinaryExpression): Boolean {\n+            if (variableExpression.getText().equals(expression.getLeft()!!.getText()))\n+                return expression.getOperationToken() == JetTokens.PLUS ||\n+                        expression.getOperationToken() == JetTokens.MINUS ||\n+                        expression.getOperationToken() == JetTokens.MUL ||\n+                        expression.getOperationToken() == JetTokens.DIV ||\n+                        expression.getOperationToken() == JetTokens.PERC\n+            else if (variableExpression.getText().equals(expression.getRight()!!.getText()))\n+                return expression.getOperationToken() == JetTokens.PLUS ||\n+                        expression.getOperationToken() == JetTokens.MUL\n+            else if (expression.getLeft() is JetBinaryExpression)\n+                return checkExpressionRepeat(variableExpression, expression.getLeft() as JetBinaryExpression)\n+            else\n+                return false\n+        }\n+","path":"idea/src/org/jetbrains/jet/plugin/intentions/ReplaceWithOperatorAssignIntention.kt","position":55,"original_position":55,"commit_id":"0f8b22c09a1d87e1278a461e58adf5f8f3ba285c","original_commit_id":"0f8b22c09a1d87e1278a461e58adf5f8f3ba285c","user":{"login":"asedunov","id":2734357,"avatar_url":"https://avatars.githubusercontent.com/u/2734357","gravatar_id":"f45ef344a86e4432c7c7aefca615297c","url":"https://api.github.com/users/asedunov","html_url":"https://github.com/asedunov","followers_url":"https://api.github.com/users/asedunov/followers","following_url":"https://api.github.com/users/asedunov/following{/other_user}","gists_url":"https://api.github.com/users/asedunov/gists{/gist_id}","starred_url":"https://api.github.com/users/asedunov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asedunov/subscriptions","organizations_url":"https://api.github.com/users/asedunov/orgs","repos_url":"https://api.github.com/users/asedunov/repos","events_url":"https://api.github.com/users/asedunov/events{/privacy}","received_events_url":"https://api.github.com/users/asedunov/received_events","type":"User","site_admin":false},"body":"Yes, in this case descriptor should be ClassDescriptor which exposes corresponding type through ```getDefaultType()``` method","created_at":"2014-02-28T10:51:57Z","updated_at":"2014-02-28T10:51:57Z","html_url":"https://github.com/JetBrains/kotlin/pull/386#discussion_r10160465","pull_request_url":"https://api.github.com/repos/JetBrains/kotlin/pulls/386","_links":{"self":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/comments/10160465"},"html":{"href":"https://github.com/JetBrains/kotlin/pull/386#discussion_r10160465"},"pull_request":{"href":"https://api.github.com/repos/JetBrains/kotlin/pulls/386"}}}}