Renamed Matcher -> NavigationStrategy.
Extracted anonymous classes. Renamed methods.
This commit is contained in:
@@ -160,7 +160,7 @@ public class JetSourceNavigationHelper {
|
|||||||
NamespaceDescriptor namespaceDescriptor = bindingContextAndNamespaceDescriptor.second;
|
NamespaceDescriptor namespaceDescriptor = bindingContextAndNamespaceDescriptor.second;
|
||||||
if (receiverType == null) {
|
if (receiverType == null) {
|
||||||
// non-extension property
|
// non-extension property
|
||||||
for (Descr candidate : navigationStrategy.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
for (Descr candidate : navigationStrategy.getCandidateDescriptors(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
||||||
if (candidate.getReceiverParameter() == null) {
|
if (candidate.getReceiverParameter() == null) {
|
||||||
if (navigationStrategy.declarationAndDescriptorMatch(decompiledDeclaration, candidate)) {
|
if (navigationStrategy.declarationAndDescriptorMatch(decompiledDeclaration, candidate)) {
|
||||||
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||||
@@ -171,7 +171,7 @@ public class JetSourceNavigationHelper {
|
|||||||
else {
|
else {
|
||||||
// extension property
|
// extension property
|
||||||
String expectedTypeString = receiverType.getText();
|
String expectedTypeString = receiverType.getText();
|
||||||
for (Descr candidate : navigationStrategy.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
for (Descr candidate : navigationStrategy.getCandidateDescriptors(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
||||||
ReceiverParameterDescriptor receiverParameter = candidate.getReceiverParameter();
|
ReceiverParameterDescriptor receiverParameter = candidate.getReceiverParameter();
|
||||||
if (receiverParameter != null) {
|
if (receiverParameter != null) {
|
||||||
String thisReceiverType = DescriptorRenderer.TEXT.renderType(receiverParameter.getType());
|
String thisReceiverType = DescriptorRenderer.TEXT.renderType(receiverParameter.getType());
|
||||||
@@ -206,7 +206,7 @@ public class JetSourceNavigationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClassDescriptor expectedContainer = isClassObject ? classDescriptor.getClassObjectDescriptor() : classDescriptor;
|
ClassDescriptor expectedContainer = isClassObject ? classDescriptor.getClassObjectDescriptor() : classDescriptor;
|
||||||
for (Descr candidate : navigationStrategy.getCandidatesFromScope(memberScope, entityNameAsName)) {
|
for (Descr candidate : navigationStrategy.getCandidateDescriptors(memberScope, entityNameAsName)) {
|
||||||
if (candidate.getContainingDeclaration() == expectedContainer) {
|
if (candidate.getContainingDeclaration() == expectedContainer) {
|
||||||
JetDeclaration property = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
JetDeclaration property = (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
@@ -232,7 +232,7 @@ public class JetSourceNavigationHelper {
|
|||||||
private interface NavigationStrategy<Decl extends JetDeclaration, Descr extends CallableDescriptor> {
|
private interface NavigationStrategy<Decl extends JetDeclaration, Descr extends CallableDescriptor> {
|
||||||
boolean declarationAndDescriptorMatch(Decl declaration, Descr descriptor);
|
boolean declarationAndDescriptorMatch(Decl declaration, Descr descriptor);
|
||||||
|
|
||||||
Collection<Descr> getCandidatesFromScope(JetScope scope, Name name);
|
Collection<Descr> getCandidateDescriptors(JetScope scope, Name name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FunctionNavigationStrategy implements NavigationStrategy<JetFunction, FunctionDescriptor> {
|
private static class FunctionNavigationStrategy implements NavigationStrategy<JetFunction, FunctionDescriptor> {
|
||||||
@@ -268,7 +268,7 @@ public class JetSourceNavigationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<FunctionDescriptor> getCandidatesFromScope(JetScope scope, Name name) {
|
public Collection<FunctionDescriptor> getCandidateDescriptors(JetScope scope, Name name) {
|
||||||
return scope.getFunctions(name);
|
return scope.getFunctions(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ public class JetSourceNavigationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<VariableDescriptor> getCandidatesFromScope(JetScope scope, Name name) {
|
public Collection<VariableDescriptor> getCandidateDescriptors(JetScope scope, Name name) {
|
||||||
return scope.getProperties(name);
|
return scope.getProperties(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user