Got rid of MemberNavigationStrategy.
This commit is contained in:
@@ -152,8 +152,7 @@ public class JetSourceNavigationHelper {
|
||||
@Nullable
|
||||
private static <Decl extends JetNamedDeclaration, Descr extends CallableDescriptor> JetNamedDeclaration
|
||||
getSourcePropertyOrFunction(
|
||||
@NotNull final Decl decompiledDeclaration,
|
||||
@NotNull final MemberNavigationStrategy<Decl, Descr> navigationStrategy
|
||||
@NotNull final Decl decompiledDeclaration
|
||||
) {
|
||||
String memberNameAsString = decompiledDeclaration.getName();
|
||||
assert memberNameAsString != null;
|
||||
@@ -185,14 +184,14 @@ public class JetSourceNavigationHelper {
|
||||
}
|
||||
|
||||
if (!forceResolve) {
|
||||
candidates = filterByReceiverPresenceAndParametersCount(decompiledDeclaration, navigationStrategy, candidates);
|
||||
candidates = filterByReceiverPresenceAndParametersCount(decompiledDeclaration, candidates);
|
||||
|
||||
if (candidates.size() <= 1) {
|
||||
return candidates.isEmpty() ? null : candidates.iterator().next();
|
||||
}
|
||||
|
||||
if (!haveRenamesInImports(getContainingFiles(candidates))) {
|
||||
candidates = filterByReceiverAndParameterTypes(decompiledDeclaration, navigationStrategy, candidates);
|
||||
candidates = filterByReceiverAndParameterTypes(decompiledDeclaration, candidates);
|
||||
|
||||
if (candidates.size() <= 1) {
|
||||
return candidates.isEmpty() ? null : candidates.iterator().next();
|
||||
@@ -217,8 +216,8 @@ public class JetSourceNavigationHelper {
|
||||
for (Decl candidate : candidates) {
|
||||
//noinspection unchecked
|
||||
Descr candidateDescriptor = (Descr) resolveSession.resolveToDescriptor(candidate);
|
||||
if (receiversMatch(navigationStrategy, decompiledDeclaration, candidateDescriptor)
|
||||
&& valueParametersTypesMatch(navigationStrategy, decompiledDeclaration, candidateDescriptor)
|
||||
if (receiversMatch(decompiledDeclaration, candidateDescriptor)
|
||||
&& valueParametersTypesMatch(decompiledDeclaration, candidateDescriptor)
|
||||
&& typeParametersMatch((JetTypeParameterListOwner) decompiledDeclaration, candidateDescriptor.getTypeParameters())) {
|
||||
return candidate;
|
||||
}
|
||||
@@ -288,13 +287,12 @@ public class JetSourceNavigationHelper {
|
||||
@NotNull
|
||||
private static <Decl extends JetNamedDeclaration, Descr extends CallableDescriptor> List<Decl> filterByReceiverPresenceAndParametersCount(
|
||||
final @NotNull Decl decompiledDeclaration,
|
||||
final @NotNull MemberNavigationStrategy<Decl, Descr> navigationStrategy,
|
||||
@NotNull Collection<Decl> candidates
|
||||
) {
|
||||
return ContainerUtil.filter(candidates, new Condition<Decl>() {
|
||||
@Override
|
||||
public boolean value(Decl candidate) {
|
||||
return sameReceiverPresenceAndParametersCount(navigationStrategy, candidate, decompiledDeclaration);
|
||||
return sameReceiverPresenceAndParametersCount(candidate, decompiledDeclaration);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -302,25 +300,24 @@ public class JetSourceNavigationHelper {
|
||||
@NotNull
|
||||
private static <Decl extends JetNamedDeclaration, Descr extends CallableDescriptor> List<Decl> filterByReceiverAndParameterTypes(
|
||||
final @NotNull Decl decompiledDeclaration,
|
||||
final @NotNull MemberNavigationStrategy<Decl, Descr> navigationStrategy,
|
||||
@NotNull Collection<Decl> candidates
|
||||
) {
|
||||
return ContainerUtil.filter(candidates, new Condition<Decl>() {
|
||||
@Override
|
||||
public boolean value(Decl candidate) {
|
||||
return receiverAndParametersShortTypesMatch(navigationStrategy, candidate, decompiledDeclaration);
|
||||
return receiverAndParametersShortTypesMatch(candidate, decompiledDeclaration);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetNamedDeclaration getSourceProperty(final @NotNull JetProperty decompiledProperty) {
|
||||
return getSourcePropertyOrFunction(decompiledProperty, new MemberNavigationStrategy.PropertyStrategy());
|
||||
return getSourcePropertyOrFunction(decompiledProperty);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetNamedDeclaration getSourceFunction(final @NotNull JetNamedFunction decompiledFunction) {
|
||||
return getSourcePropertyOrFunction(decompiledFunction, new MemberNavigationStrategy.FunctionStrategy());
|
||||
return getSourcePropertyOrFunction(decompiledFunction);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
@@ -103,7 +103,6 @@ public class MemberMatching {
|
||||
}
|
||||
|
||||
static <Decl extends JetNamedDeclaration> boolean sameReceiverPresenceAndParametersCount(
|
||||
@NotNull MemberNavigationStrategy<Decl, ?> navigationStrategy,
|
||||
@NotNull Decl a,
|
||||
@NotNull Decl b
|
||||
) {
|
||||
@@ -113,7 +112,6 @@ public class MemberMatching {
|
||||
}
|
||||
|
||||
static <Decl extends JetNamedDeclaration> boolean receiverAndParametersShortTypesMatch(
|
||||
@NotNull MemberNavigationStrategy<Decl, ?> navigationStrategy,
|
||||
@NotNull Decl a,
|
||||
@NotNull Decl b
|
||||
) {
|
||||
@@ -149,7 +147,6 @@ public class MemberMatching {
|
||||
|
||||
/* DECLARATION AND DESCRIPTOR STRICT MATCHING */
|
||||
static <Decl extends JetNamedDeclaration> boolean receiversMatch(
|
||||
@NotNull MemberNavigationStrategy<Decl, ?> navigationStrategy,
|
||||
@NotNull Decl declaration,
|
||||
@NotNull CallableDescriptor descriptor
|
||||
) {
|
||||
@@ -165,7 +162,6 @@ public class MemberMatching {
|
||||
}
|
||||
|
||||
static <Decl extends JetNamedDeclaration, Descr extends CallableDescriptor> boolean valueParametersTypesMatch(
|
||||
@NotNull MemberNavigationStrategy<Decl, Descr> navigationStrategy,
|
||||
@NotNull Decl declaration,
|
||||
@NotNull Descr descriptor
|
||||
) {
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.plugin.libraries;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
|
||||
interface MemberNavigationStrategy<Decl extends JetNamedDeclaration, Descr extends CallableDescriptor> {
|
||||
class FunctionStrategy implements MemberNavigationStrategy<JetNamedFunction, FunctionDescriptor> {
|
||||
}
|
||||
|
||||
class PropertyStrategy implements MemberNavigationStrategy<JetProperty, VariableDescriptor> {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user