KT-4592 Parameter info shows signatures of inaccessible methods
#KT-4592 Fixed
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
|
||||
public class JetVisibilityChecker {
|
||||
/**
|
||||
* @param locationOwner owner of the call site
|
||||
* @param subject the descriptor whose visibility is being checked
|
||||
* @return <code>true</code> iff subject is visible locationOwner
|
||||
*/
|
||||
public static boolean isVisible(@NotNull DeclarationDescriptor locationOwner, @NotNull DeclarationDescriptor subject) {
|
||||
// TODO : stub implementation
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade;
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
||||
import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper;
|
||||
import org.jetbrains.kotlin.idea.core.CorePackage;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
@@ -45,7 +46,6 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.kotlin.resolve.JetVisibilityChecker;
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
@@ -373,7 +373,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
||||
return null;
|
||||
}
|
||||
|
||||
JetSimpleNameExpression callNameExpression = getCallSimpleNameExpression(argumentList);
|
||||
final JetSimpleNameExpression callNameExpression = getCallSimpleNameExpression(argumentList);
|
||||
if (callNameExpression == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -384,7 +384,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
||||
}
|
||||
|
||||
ResolutionFacade resolutionFacade = ResolvePackage.getResolutionFacade(callNameExpression.getContainingJetFile());
|
||||
BindingContext bindingContext = resolutionFacade.analyze(callNameExpression, BodyResolveMode.FULL);
|
||||
final BindingContext bindingContext = resolutionFacade.analyze(callNameExpression, BodyResolveMode.FULL);
|
||||
ModuleDescriptor moduleDescriptor = resolutionFacade.findModuleDescriptor(callNameExpression);
|
||||
|
||||
JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, callNameExpression);
|
||||
@@ -398,7 +398,9 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
||||
Function1<DeclarationDescriptor, Boolean> visibilityFilter = new Function1<DeclarationDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(DeclarationDescriptor descriptor) {
|
||||
return placeDescriptor == null || JetVisibilityChecker.isVisible(placeDescriptor, descriptor);
|
||||
if (placeDescriptor == null) return true;
|
||||
if (!(descriptor instanceof DeclarationDescriptorWithVisibility)) return true;
|
||||
return CorePackage.isVisible((DeclarationDescriptorWithVisibility) descriptor, placeDescriptor, bindingContext, callNameExpression);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class C {
|
||||
fun foo(){}
|
||||
protected fun foo(p: Int){}
|
||||
}
|
||||
|
||||
fun f(c: C) {
|
||||
c.foo(<caret>1)
|
||||
}
|
||||
/*
|
||||
Text: (<no parameters>), Disabled: true, Strikeout: false, Green: true
|
||||
*/
|
||||
+6
@@ -77,6 +77,12 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NotAccessible.kt")
|
||||
public void testNotAccessible() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NotGreen.kt")
|
||||
public void testNotGreen() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NotGreen.kt");
|
||||
|
||||
Reference in New Issue
Block a user