From 5b3ab97b4e414bcb6065b54ee58a3f34af217ef2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 12 Jan 2018 17:56:46 +0100 Subject: [PATCH] Highlight 'var' primary constructor parameters as mutable #KT-11467 Fixed --- .../PropertiesHighlightingVisitor.kt | 18 +++++------------- idea/testData/highlighter/Variables.kt | 6 +++++- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PropertiesHighlightingVisitor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PropertiesHighlightingVisitor.kt index 808935f0c33..6a5a40b1011 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PropertiesHighlightingVisitor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PropertiesHighlightingVisitor.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.idea.highlighter @@ -63,6 +52,9 @@ internal class PropertiesHighlightingVisitor(holder: AnnotationHolder, bindingCo val nameIdentifier = parameter.nameIdentifier ?: return val propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter) if (propertyDescriptor != null) { + if (propertyDescriptor.isVar) { + highlightName(nameIdentifier, MUTABLE_VARIABLE) + } highlightProperty(nameIdentifier, propertyDescriptor) } diff --git a/idea/testData/highlighter/Variables.kt b/idea/testData/highlighter/Variables.kt index f8e56d76ca8..500e54837ae 100644 --- a/idea/testData/highlighter/Variables.kt +++ b/idea/testData/highlighter/Variables.kt @@ -10,7 +10,11 @@ val y : sq + field + x } -class Foo(val a : Int, b : String) { +class Foo( + val a : Int, + b : String, + var c : String +) { init { b }