Refactoring: method rename resolveToExpression -> resolveToElement
This commit is contained in:
@@ -113,16 +113,16 @@ public class ResolveSessionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull BindingContext resolveToExpression(
|
public static @NotNull BindingContext resolveToElement(
|
||||||
@NotNull ResolveSession resolveSession,
|
@NotNull ResolveSession resolveSession,
|
||||||
@NotNull JetElement expression
|
@NotNull JetElement jetElement
|
||||||
) {
|
) {
|
||||||
DelegatingBindingTrace trace = new DelegatingBindingTrace(
|
DelegatingBindingTrace trace = new DelegatingBindingTrace(
|
||||||
resolveSession.getBindingContext(), "trace to resolve expression", expression);
|
resolveSession.getBindingContext(), "trace to resolve jetElement", jetElement);
|
||||||
JetFile file = (JetFile) expression.getContainingFile();
|
JetFile file = (JetFile) jetElement.getContainingFile();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
PsiElement topmostCandidateForAdditionalResolve = JetPsiUtil.getTopmostParentOfTypes(expression,
|
PsiElement topmostCandidateForAdditionalResolve = JetPsiUtil.getTopmostParentOfTypes(jetElement,
|
||||||
JetNamedFunction.class, JetClassInitializer.class,
|
JetNamedFunction.class, JetClassInitializer.class,
|
||||||
JetProperty.class, JetDelegationSpecifierList.class,
|
JetProperty.class, JetDelegationSpecifierList.class,
|
||||||
JetImportDirective.class);
|
JetImportDirective.class);
|
||||||
@@ -155,8 +155,8 @@ public class ResolveSessionUtils {
|
|||||||
return trace.getBindingContext();
|
return trace.getBindingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expression instanceof JetExpression) {
|
if (jetElement instanceof JetExpression) {
|
||||||
JetExpression jetExpression = (JetExpression) expression;
|
JetExpression jetExpression = (JetExpression) jetElement;
|
||||||
// Setup resolution scope explicitly
|
// Setup resolution scope explicitly
|
||||||
if (trace.getBindingContext().get(BindingContext.RESOLUTION_SCOPE, jetExpression) == null) {
|
if (trace.getBindingContext().get(BindingContext.RESOLUTION_SCOPE, jetExpression) == null) {
|
||||||
JetScope scope = getExpressionMemberScope(resolveSession, jetExpression);
|
JetScope scope = getExpressionMemberScope(resolveSession, jetExpression);
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
@NotNull ResolveSession resolveSession,
|
@NotNull ResolveSession resolveSession,
|
||||||
@NotNull GlobalSearchScope scope
|
@NotNull GlobalSearchScope scope
|
||||||
) {
|
) {
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, expression);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, expression);
|
||||||
JetScope jetScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
JetScope jetScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||||
|
|
||||||
if (jetScope == null) {
|
if (jetScope == null) {
|
||||||
@@ -221,7 +221,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, expression);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, expression);
|
||||||
JetScope jetScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
JetScope jetScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||||
|
|
||||||
if (jetScope == null) {
|
if (jetScope == null) {
|
||||||
@@ -302,7 +302,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
) {
|
) {
|
||||||
Collection<DeclarationDescriptor> resultDescriptors = new ArrayList<DeclarationDescriptor>();
|
Collection<DeclarationDescriptor> resultDescriptors = new ArrayList<DeclarationDescriptor>();
|
||||||
|
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, expression);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, expression);
|
||||||
JetExpression receiverExpression = expression.getReceiverExpression();
|
JetExpression receiverExpression = expression.getReceiverExpression();
|
||||||
|
|
||||||
if (receiverExpression != null) {
|
if (receiverExpression != null) {
|
||||||
|
|||||||
+17
-1
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.codeInsight.surroundWith;
|
package org.jetbrains.jet.plugin.codeInsight.surroundWith;
|
||||||
|
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
@@ -31,7 +47,7 @@ public class KotlinSurrounderUtils {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static JetType getExpressionType(JetExpression expression) {
|
public static JetType getExpressionType(JetExpression expression) {
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) expression.getContainingFile());
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) expression.getContainingFile());
|
||||||
BindingContext expressionBindingContext = ResolveSessionUtils.resolveToExpression(resolveSession, expression);
|
BindingContext expressionBindingContext = ResolveSessionUtils.resolveToElement(resolveSession, expression);
|
||||||
return expressionBindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
return expressionBindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -40,7 +40,8 @@ import org.jetbrains.jet.renderer.DescriptorRenderer;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.psi.JetPsiFactory.*;
|
import static org.jetbrains.jet.lang.psi.JetPsiFactory.createExpression;
|
||||||
|
import static org.jetbrains.jet.lang.psi.JetPsiFactory.createNewLine;
|
||||||
|
|
||||||
public class MoveDeclarationsOutHelper {
|
public class MoveDeclarationsOutHelper {
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ public class MoveDeclarationsOutHelper {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private static JetType getPropertyType(@NotNull JetProperty property) {
|
private static JetType getPropertyType(@NotNull JetProperty property) {
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) property.getContainingFile());
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) property.getContainingFile());
|
||||||
BindingContext expressionBindingContext = ResolveSessionUtils.resolveToExpression(resolveSession, property);
|
BindingContext expressionBindingContext = ResolveSessionUtils.resolveToElement(resolveSession, property);
|
||||||
|
|
||||||
VariableDescriptor propertyDescriptor = expressionBindingContext.get(BindingContext.VARIABLE, property);
|
VariableDescriptor propertyDescriptor = expressionBindingContext.get(BindingContext.VARIABLE, property);
|
||||||
assert propertyDescriptor != null : "Couldn't resolve property to property descriptor " + property.getText();
|
assert propertyDescriptor != null : "Couldn't resolve property to property descriptor " + property.getText();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class CompletionSession {
|
|||||||
this.jetReference = jetReference;
|
this.jetReference = jetReference;
|
||||||
|
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) position.getContainingFile());
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) position.getContainingFile());
|
||||||
BindingContext expressionBindingContext = ResolveSessionUtils.resolveToExpression(resolveSession, jetReference.getExpression());
|
BindingContext expressionBindingContext = ResolveSessionUtils.resolveToElement(resolveSession, jetReference.getExpression());
|
||||||
JetScope scope = expressionBindingContext.get(BindingContext.RESOLUTION_SCOPE, jetReference.getExpression());
|
JetScope scope = expressionBindingContext.get(BindingContext.RESOLUTION_SCOPE, jetReference.getExpression());
|
||||||
|
|
||||||
inDescriptor = scope != null ? scope.getContainingDeclaration() : null;
|
inDescriptor = scope != null ? scope.getContainingDeclaration() : null;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class JetPackagesContributor extends CompletionContributor {
|
|||||||
|
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile(
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile(
|
||||||
(JetFile) simpleNameReference.getExpression().getContainingFile());
|
(JetFile) simpleNameReference.getExpression().getContainingFile());
|
||||||
BindingContext bindingContext = ResolveSessionUtils.resolveToExpression(
|
BindingContext bindingContext = ResolveSessionUtils.resolveToElement(
|
||||||
resolveSession, simpleNameReference.getExpression());
|
resolveSession, simpleNameReference.getExpression());
|
||||||
|
|
||||||
for (LookupElement variant : DescriptorLookupConverter.collectLookupElements(
|
for (LookupElement variant : DescriptorLookupConverter.collectLookupElements(
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class JetImportOptimizer implements ImportOptimizer {
|
|||||||
@Override
|
@Override
|
||||||
public void visitForExpression(JetForExpression expression) {
|
public void visitForExpression(JetForExpression expression) {
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) expression.getContainingFile());
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) expression.getContainingFile());
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, expression);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, expression);
|
||||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL, expression.getLoopRange());
|
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL, expression.getLoopRange());
|
||||||
addResolvedCallFqName(resolvedCall);
|
addResolvedCallFqName(resolvedCall);
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ public class JetImportOptimizer implements ImportOptimizer {
|
|||||||
@Override
|
@Override
|
||||||
public void visitMultiDeclaration(JetMultiDeclaration declaration) {
|
public void visitMultiDeclaration(JetMultiDeclaration declaration) {
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) declaration.getContainingFile());
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) declaration.getContainingFile());
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, declaration);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, declaration);
|
||||||
List<JetMultiDeclarationEntry> entries = declaration.getEntries();
|
List<JetMultiDeclarationEntry> entries = declaration.getEntries();
|
||||||
for (JetMultiDeclarationEntry entry : entries) {
|
for (JetMultiDeclarationEntry entry : entries) {
|
||||||
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
|
ResolvedCall<FunctionDescriptor> resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry);
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
|
|
||||||
if ((element instanceof JetNamedFunction && ((JetNamedFunction) element).isLocal()) ||
|
if ((element instanceof JetNamedFunction && ((JetNamedFunction) element).isLocal()) ||
|
||||||
element instanceof JetProperty && ((JetProperty) element).isLocal()) {
|
element instanceof JetProperty && ((JetProperty) element).isLocal()) {
|
||||||
bindingContext = ResolveSessionUtils.resolveToExpression(sessionForFile, (JetElement) element);
|
bindingContext = ResolveSessionUtils.resolveToElement(sessionForFile, (JetElement) element);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+2
-2
@@ -239,7 +239,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
PsiElement owner = context.getParameterOwner();
|
PsiElement owner = context.getParameterOwner();
|
||||||
BindingContext bindingContext = ResolveSessionUtils.resolveToExpression(resolveSession, (JetElement) owner);
|
BindingContext bindingContext = ResolveSessionUtils.resolveToElement(resolveSession, (JetElement) owner);
|
||||||
|
|
||||||
for (int i = 0; i < valueParameters.size(); ++i) {
|
for (int i = 0; i < valueParameters.size(); ++i) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
@@ -384,7 +384,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith
|
|||||||
|
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile(
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile(
|
||||||
(JetFile) callNameExpression.getContainingFile());
|
(JetFile) callNameExpression.getContainingFile());
|
||||||
BindingContext bindingContext = ResolveSessionUtils.resolveToExpression(resolveSession, callNameExpression);
|
BindingContext bindingContext = ResolveSessionUtils.resolveToElement(resolveSession, callNameExpression);
|
||||||
|
|
||||||
JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, callNameExpression);
|
JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, callNameExpression);
|
||||||
DeclarationDescriptor placeDescriptor = null;
|
DeclarationDescriptor placeDescriptor = null;
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ public final class WholeProjectAnalyzerFacade {
|
|||||||
|
|
||||||
public static BindingContext getContextForExpression(@NotNull JetExpression jetExpression) {
|
public static BindingContext getContextForExpression(@NotNull JetExpression jetExpression) {
|
||||||
ResolveSession resolveSession = getLazyResolveSessionForFile((JetFile) jetExpression.getContainingFile());
|
ResolveSession resolveSession = getLazyResolveSessionForFile((JetFile) jetExpression.getContainingFile());
|
||||||
return ResolveSessionUtils.resolveToExpression(resolveSession, jetExpression);
|
return ResolveSessionUtils.resolveToElement(resolveSession, jetExpression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResolveSession resolveSession = AnalyzerFacadeWithCache.getLazyResolveSession((JetFile) initializer.getContainingFile());
|
ResolveSession resolveSession = AnalyzerFacadeWithCache.getLazyResolveSession((JetFile) initializer.getContainingFile());
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, initializer);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, initializer);
|
||||||
SimpleFunctionDescriptor fun = context.get(BindingContext.FUNCTION, functionLiteralExpression.getFunctionLiteral());
|
SimpleFunctionDescriptor fun = context.get(BindingContext.FUNCTION, functionLiteralExpression.getFunctionLiteral());
|
||||||
if (fun == null || ErrorUtils.containsErrorType(fun)) {
|
if (fun == null || ErrorUtils.containsErrorType(fun)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -284,7 +284,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
@NotNull ResolveSession resolveSession
|
@NotNull ResolveSession resolveSession
|
||||||
) {
|
) {
|
||||||
JetFunctionLiteral functionLiteral = functionLiteralExpression.getFunctionLiteral();
|
JetFunctionLiteral functionLiteral = functionLiteralExpression.getFunctionLiteral();
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, functionLiteralExpression);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, functionLiteralExpression);
|
||||||
for (Diagnostic diagnostic : context.getDiagnostics()) {
|
for (Diagnostic diagnostic : context.getDiagnostics()) {
|
||||||
AbstractDiagnosticFactory factory = diagnostic.getFactory();
|
AbstractDiagnosticFactory factory = diagnostic.getFactory();
|
||||||
PsiElement element = diagnostic.getPsiElement();
|
PsiElement element = diagnostic.getPsiElement();
|
||||||
@@ -328,7 +328,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
|
|
||||||
JetExpression callee = callExpression.getCalleeExpression();
|
JetExpression callee = callExpression.getCalleeExpression();
|
||||||
ResolveSession resolveSession = AnalyzerFacadeWithCache.getLazyResolveSession((JetFile) initializer.getContainingFile());
|
ResolveSession resolveSession = AnalyzerFacadeWithCache.getLazyResolveSession((JetFile) initializer.getContainingFile());
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, initializer);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, initializer);
|
||||||
ResolvedCall<? extends CallableDescriptor> call = context.get(BindingContext.RESOLVED_CALL, callee);
|
ResolvedCall<? extends CallableDescriptor> call = context.get(BindingContext.RESOLVED_CALL, callee);
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -353,7 +353,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
@NotNull ResolveSession resolveSession
|
@NotNull ResolveSession resolveSession
|
||||||
) {
|
) {
|
||||||
JetExpression callee = callExpression.getCalleeExpression();
|
JetExpression callee = callExpression.getCalleeExpression();
|
||||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, callExpression);
|
BindingContext context = ResolveSessionUtils.resolveToElement(resolveSession, callExpression);
|
||||||
for (Diagnostic diagnostic : context.getDiagnostics()) {
|
for (Diagnostic diagnostic : context.getDiagnostics()) {
|
||||||
if (diagnostic.getFactory() == Errors.TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER && diagnostic.getPsiElement() == callee) {
|
if (diagnostic.getFactory() == Errors.TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER && diagnostic.getPsiElement() == callee) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class JetSimpleNameReference extends JetPsiReference {
|
|||||||
@Override
|
@Override
|
||||||
public Object[] getVariants() {
|
public Object[] getVariants() {
|
||||||
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) getExpression().getContainingFile());
|
ResolveSession resolveSession = WholeProjectAnalyzerFacade.getLazyResolveSessionForFile((JetFile) getExpression().getContainingFile());
|
||||||
BindingContext bindingContext = ResolveSessionUtils.resolveToExpression(resolveSession, getExpression());
|
BindingContext bindingContext = ResolveSessionUtils.resolveToElement(resolveSession, getExpression());
|
||||||
|
|
||||||
return DescriptorLookupConverter.collectLookupElements(
|
return DescriptorLookupConverter.collectLookupElements(
|
||||||
resolveSession, bindingContext, TipsManager.getReferenceVariants(myExpression, bindingContext));
|
resolveSession, bindingContext, TipsManager.getReferenceVariants(myExpression, bindingContext));
|
||||||
|
|||||||
Reference in New Issue
Block a user