mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't apply rainbow highlighting to stars in *args and **kwargs
It leads to highlighting conflicts, try next commit without these changes.
This commit is contained in:
@@ -52,10 +52,9 @@ class PyRainbowVisitor : RainbowVisitor() {
|
||||
private fun processNamedParameter(namedParameter: PyNamedParameter) {
|
||||
val context = getNamedParameterContext(namedParameter) ?: return
|
||||
val name = namedParameter.name ?: return
|
||||
val element = namedParameter.nameIdentifier ?: return
|
||||
|
||||
getHighlightedParameterElements(namedParameter).forEach {
|
||||
addInfo(context, it, name, PyHighlighter.PY_PARAMETER)
|
||||
}
|
||||
addInfo(context, element, name, PyHighlighter.PY_PARAMETER)
|
||||
}
|
||||
|
||||
private fun getReferenceContext(referenceExpression: PyReferenceExpression,
|
||||
@@ -112,17 +111,6 @@ class PyRainbowVisitor : RainbowVisitor() {
|
||||
|
||||
private fun updateNameIfGlobal(context: PsiElement, name: String?) = if (context is PyFile && name != null) "global_$name" else name
|
||||
|
||||
private fun getHighlightedParameterElements(namedParameter: PyNamedParameter): List<PsiElement> {
|
||||
val nameIdentifier = namedParameter.nameIdentifier
|
||||
|
||||
return if (namedParameter.isPositionalContainer || namedParameter.isKeywordContainer) {
|
||||
listOfNotNull(namedParameter.firstChild, nameIdentifier)
|
||||
}
|
||||
else {
|
||||
listOfNotNull(nameIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addInfo(context: PsiElement, rainbowElement: PsiElement, name: String, key: TextAttributesKey? = DEFAULT_HIGHLIGHTING_KEY) {
|
||||
addInfo(getInfo(context, rainbowElement, name, key))
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
@@ -37,7 +23,7 @@ public class PyRainbowHighlightingTest extends PyTestCase {
|
||||
}
|
||||
|
||||
public void testPositionalAndKeywordParameters() {
|
||||
doTest("def foo(<rainbow color='ff000003'>*</rainbow><rainbow color='ff000003'>args</rainbow>, <rainbow color='ff000004'>**</rainbow><rainbow color='ff000004'>kwargs</rainbow>):\n" +
|
||||
doTest("def foo(*<rainbow color='ff000003'>args</rainbow>, **<rainbow color='ff000004'>kwargs</rainbow>):\n" +
|
||||
" print <rainbow color='ff000003'>args</rainbow>\n" +
|
||||
" print <rainbow color='ff000004'>kwargs</rainbow>\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user