From 487719aff5b965418d63a4e950a1e5a95c6f8db5 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 29 Jan 2018 17:38:05 +0300 Subject: [PATCH] IDEA-184991 Parameter info popup doesn't highlight current item updated fix for IDEA-180584, to account for this use case --- .../api/impls/MethodParameterInfoHandler.java | 12 ++++++----- .../UpdateParameterInfoContext.java | 17 ++------------- .../hint/ParameterInfoController.java | 9 +++++--- .../MockUpdateParameterInfoContext.java | 21 ++++++------------- 4 files changed, 21 insertions(+), 38 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java index edf78ed8fb9a..f7f8f3d6dcbe 100644 --- a/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/hint/api/impls/MethodParameterInfoHandler.java @@ -343,11 +343,13 @@ public class MethodParameterInfoHandler implements ParameterInfoHandlerWithTabAc context.setHighlightedParameter(completeMatch); } - Object highlightedCandidate = candidates.length == 1 ? candidates[0] : context.getHighlightedParameter(); - if (highlightedCandidate != null) { - PsiMethod method = (PsiMethod)(highlightedCandidate instanceof CandidateInfo - ? ((CandidateInfo)highlightedCandidate).getElement() : highlightedCandidate); - if (!method.isVarArgs() && index >= method.getParameterList().getParametersCount()) context.setCurrentParameter(-1); + if (context.isSingleParameterInfo()) { + Object highlightedCandidate = candidates.length == 1 ? candidates[0] : context.getHighlightedParameter(); + if (highlightedCandidate != null) { + PsiMethod method = (PsiMethod)(highlightedCandidate instanceof CandidateInfo + ? ((CandidateInfo)highlightedCandidate).getElement() : highlightedCandidate); + if (!method.isVarArgs() && index >= method.getParameterList().getParametersCount()) context.setCurrentParameter(-1); + } } } diff --git a/platform/lang-api/src/com/intellij/lang/parameterInfo/UpdateParameterInfoContext.java b/platform/lang-api/src/com/intellij/lang/parameterInfo/UpdateParameterInfoContext.java index 87770dafcc19..44c694cf9fe3 100644 --- a/platform/lang-api/src/com/intellij/lang/parameterInfo/UpdateParameterInfoContext.java +++ b/platform/lang-api/src/com/intellij/lang/parameterInfo/UpdateParameterInfoContext.java @@ -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-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 file. package com.intellij.lang.parameterInfo; @@ -38,6 +24,7 @@ public interface UpdateParameterInfoContext extends ParameterInfoContext { boolean isPreservedOnHintHidden(); void setPreservedOnHintHidden(boolean value); boolean isInnermostContext(); + boolean isSingleParameterInfo(); UserDataHolderEx getCustomContext(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java index 36130fc8110d..4cecd6133739 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoController.java @@ -1,6 +1,4 @@ -/* - * 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 file. - */ +// 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 file. package com.intellij.codeInsight.hint; @@ -667,6 +665,11 @@ public class ParameterInfoController extends UserDataHolderBase implements Visib return true; } + @Override + public boolean isSingleParameterInfo() { + return mySingleParameterInfo; + } + @Override public UserDataHolderEx getCustomContext() { return ParameterInfoController.this; diff --git a/platform/testFramework/src/com/intellij/testFramework/utils/parameterInfo/MockUpdateParameterInfoContext.java b/platform/testFramework/src/com/intellij/testFramework/utils/parameterInfo/MockUpdateParameterInfoContext.java index 70a4ce61c9ef..76a8a1779503 100644 --- a/platform/testFramework/src/com/intellij/testFramework/utils/parameterInfo/MockUpdateParameterInfoContext.java +++ b/platform/testFramework/src/com/intellij/testFramework/utils/parameterInfo/MockUpdateParameterInfoContext.java @@ -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-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 file. package com.intellij.testFramework.utils.parameterInfo; import com.intellij.lang.parameterInfo.UpdateParameterInfoContext; @@ -105,6 +91,11 @@ public class MockUpdateParameterInfoContext implements UpdateParameterInfoContex return false; } + @Override + public boolean isSingleParameterInfo() { + return false; + } + @Override public UserDataHolderEx getCustomContext() { throw new UnsupportedOperationException();