Refactor: inline AnalyzerFacadeWithCache#getContextForElement
This commit is contained in:
@@ -21,7 +21,6 @@ import org.jetbrains.jet.lang.psi.JetForExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetMultiDeclaration
|
import org.jetbrains.jet.lang.psi.JetMultiDeclaration
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetImportDirective
|
import org.jetbrains.jet.lang.psi.JetImportDirective
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypeAndBranch
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypeAndBranch
|
||||||
import org.jetbrains.jet.lang.psi.JetCallableReferenceExpression
|
import org.jetbrains.jet.lang.psi.JetCallableReferenceExpression
|
||||||
@@ -61,8 +60,8 @@ import org.jetbrains.jet.lang.descriptors.ClassKind
|
|||||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor
|
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor
|
||||||
import com.intellij.psi.PsiPackage
|
import com.intellij.psi.PsiPackage
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
|
||||||
import org.jetbrains.jet.plugin.findUsages.UsageTypeEnum.*
|
import org.jetbrains.jet.plugin.findUsages.UsageTypeEnum.*
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public object UsageTypeUtils {
|
public object UsageTypeUtils {
|
||||||
public fun getUsageType(element: PsiElement?): UsageTypeEnum? {
|
public fun getUsageType(element: PsiElement?): UsageTypeEnum? {
|
||||||
@@ -74,7 +73,7 @@ public object UsageTypeUtils {
|
|||||||
val refExpr = element?.getParentByType(javaClass<JetReferenceExpression>())
|
val refExpr = element?.getParentByType(javaClass<JetReferenceExpression>())
|
||||||
if (refExpr == null) return null
|
if (refExpr == null) return null
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(refExpr)
|
val context = refExpr.analyze()
|
||||||
|
|
||||||
fun getCommonUsageType(): UsageTypeEnum? {
|
fun getCommonUsageType(): UsageTypeEnum? {
|
||||||
return when {
|
return when {
|
||||||
|
|||||||
+3
-3
@@ -27,10 +27,10 @@ import org.jetbrains.jet.lexer.JetTokens
|
|||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import org.jetbrains.jet.lang.psi.JetElement
|
import org.jetbrains.jet.lang.psi.JetElement
|
||||||
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>("operator.to.function", javaClass()) {
|
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>("operator.to.function", javaClass()) {
|
||||||
class object {
|
class object {
|
||||||
@@ -57,7 +57,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isApplicableCall(element: JetCallExpression): Boolean {
|
private fun isApplicableCall(element: JetCallExpression): Boolean {
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element)
|
val bindingContext = element.analyze()
|
||||||
val resolvedCall = element.getResolvedCall(bindingContext)
|
val resolvedCall = element.getResolvedCall(bindingContext)
|
||||||
val descriptor = resolvedCall?.getResultingDescriptor()
|
val descriptor = resolvedCall?.getResultingDescriptor()
|
||||||
if (descriptor is FunctionDescriptor && descriptor.getName().asString() == "invoke") {
|
if (descriptor is FunctionDescriptor && descriptor.getName().asString() == "invoke") {
|
||||||
@@ -115,7 +115,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpressi
|
|||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val functionCandidate = element.getResolvedCall(context)
|
val functionCandidate = element.getResolvedCall(context)
|
||||||
val functionName = functionCandidate?.getCandidateDescriptor()?.getName().toString()
|
val functionName = functionCandidate?.getCandidateDescriptor()?.getName().toString()
|
||||||
val elemType = context[BindingContext.EXPRESSION_TYPE, left]
|
val elemType = context[BindingContext.EXPRESSION_TYPE, left]
|
||||||
|
|||||||
+2
-2
@@ -18,7 +18,6 @@ package org.jetbrains.jet.plugin.intentions
|
|||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall
|
import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils
|
import org.jetbrains.jet.lang.types.TypeUtils
|
||||||
@@ -36,6 +35,7 @@ import org.jetbrains.jet.lang.psi.psiUtil.getTextWithLocation
|
|||||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
||||||
import org.jetbrains.jet.plugin.util.approximateFlexibleTypes
|
import org.jetbrains.jet.plugin.util.approximateFlexibleTypes
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.findModuleDescriptor
|
import org.jetbrains.jet.plugin.caches.resolve.findModuleDescriptor
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class RemoveExplicitTypeArguments : JetSelfTargetingIntention<JetTypeArgumentList>(
|
public class RemoveExplicitTypeArguments : JetSelfTargetingIntention<JetTypeArgumentList>(
|
||||||
"remove.explicit.type.arguments", javaClass()) {
|
"remove.explicit.type.arguments", javaClass()) {
|
||||||
@@ -44,7 +44,7 @@ public class RemoveExplicitTypeArguments : JetSelfTargetingIntention<JetTypeArgu
|
|||||||
val callExpression = element.getParent()
|
val callExpression = element.getParent()
|
||||||
if (callExpression !is JetCallExpression) return false
|
if (callExpression !is JetCallExpression) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(callExpression)
|
val context = callExpression.analyze()
|
||||||
if (callExpression.getTypeArguments().isEmpty()) return false
|
if (callExpression.getTypeArguments().isEmpty()) return false
|
||||||
|
|
||||||
val injector = InjectorForMacros(callExpression.getProject(), callExpression.findModuleDescriptor())
|
val injector = InjectorForMacros(callExpression.getProject(), callExpression.findModuleDescriptor())
|
||||||
|
|||||||
@@ -1,33 +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.project;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetElement;
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
|
||||||
|
|
||||||
public final class AnalyzerFacadeWithCache {
|
|
||||||
|
|
||||||
private AnalyzerFacadeWithCache() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static BindingContext getContextForElement(@NotNull JetElement jetElement) {
|
|
||||||
return ResolvePackage.analyze(jetElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -22,11 +22,11 @@ import com.intellij.psi.PsiElement
|
|||||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory
|
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory
|
||||||
import org.jetbrains.jet.lang.psi.*
|
import org.jetbrains.jet.lang.psi.*
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||||
import com.intellij.codeInspection.SuppressIntentionAction
|
import com.intellij.codeInspection.SuppressIntentionAction
|
||||||
import org.jetbrains.jet.plugin.util.JetPsiPrecedences
|
import org.jetbrains.jet.plugin.util.JetPsiPrecedences
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class KotlinSuppressIntentionAction(
|
public class KotlinSuppressIntentionAction(
|
||||||
private val suppressAt: JetExpression,
|
private val suppressAt: JetExpression,
|
||||||
@@ -132,7 +132,7 @@ public class KotlinSuppressIntentionAction(
|
|||||||
private fun suppressAnnotationText(id: String) = "[suppress($id)]"
|
private fun suppressAnnotationText(id: String) = "[suppress($id)]"
|
||||||
|
|
||||||
private fun findSuppressAnnotation(annotated: JetAnnotated): JetAnnotationEntry? {
|
private fun findSuppressAnnotation(annotated: JetAnnotated): JetAnnotationEntry? {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(annotated)
|
val context = annotated.analyze()
|
||||||
for (entry in annotated.getAnnotationEntries()) {
|
for (entry in annotated.getAnnotationEntries()) {
|
||||||
val annotationDescriptor = context.get(BindingContext.ANNOTATION, entry)
|
val annotationDescriptor = context.get(BindingContext.ANNOTATION, entry)
|
||||||
if (annotationDescriptor != null && KotlinBuiltIns.getInstance().isSuppressAnnotation(annotationDescriptor)) {
|
if (annotationDescriptor != null && KotlinBuiltIns.getInstance().isSuppressAnnotation(annotationDescriptor)) {
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ import com.intellij.util.IncorrectOperationException
|
|||||||
import com.intellij.psi.PsiReference
|
import com.intellij.psi.PsiReference
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression
|
||||||
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
|
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
|
||||||
import org.jetbrains.jet.lang.psi.JetElement
|
import org.jetbrains.jet.lang.psi.JetElement
|
||||||
import org.jetbrains.jet.utils.keysToMap
|
import org.jetbrains.jet.utils.keysToMap
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public trait JetReference : PsiPolyVariantReference {
|
public trait JetReference : PsiPolyVariantReference {
|
||||||
public fun resolveToDescriptors(): Collection<DeclarationDescriptor>
|
public fun resolveToDescriptors(): Collection<DeclarationDescriptor>
|
||||||
@@ -72,18 +72,15 @@ public abstract class AbstractJetReference<T : JetElement>(element: T)
|
|||||||
override fun isSoft(): Boolean = false
|
override fun isSoft(): Boolean = false
|
||||||
|
|
||||||
private fun resolveToPsiElements(): Collection<PsiElement> {
|
private fun resolveToPsiElements(): Collection<PsiElement> {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
return resolveToPsiElements(expression.analyze(), getTargetDescriptors(expression.analyze()))
|
||||||
return resolveToPsiElements(context, getTargetDescriptors(context))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolveToDescriptors(): Collection<DeclarationDescriptor> {
|
override fun resolveToDescriptors(): Collection<DeclarationDescriptor> {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
return getTargetDescriptors(expression.analyze())
|
||||||
return getTargetDescriptors(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resolveMap(): Map<DeclarationDescriptor, Collection<PsiElement>> {
|
override fun resolveMap(): Map<DeclarationDescriptor, Collection<PsiElement>> {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
return getTargetDescriptors(expression.analyze()) keysToMap { DescriptorToDeclarationUtil.resolveToPsiElements(expression.getProject(), it) }
|
||||||
return getTargetDescriptors(context) keysToMap { DescriptorToDeclarationUtil.resolveToPsiElements(expression.getProject(), it) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveToPsiElements(context: BindingContext, targetDescriptors: Collection<DeclarationDescriptor>): Collection<PsiElement> {
|
private fun resolveToPsiElements(context: BindingContext, targetDescriptors: Collection<DeclarationDescriptor>): Collection<PsiElement> {
|
||||||
|
|||||||
+3
-3
@@ -31,12 +31,12 @@ import org.jetbrains.jet.plugin.refactoring.fqName.getKotlinFqName
|
|||||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.jet.lexer.JetToken
|
import org.jetbrains.jet.lexer.JetToken
|
||||||
import org.jetbrains.jet.plugin.intentions.OperatorToFunctionIntention
|
import org.jetbrains.jet.plugin.intentions.OperatorToFunctionIntention
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import com.intellij.util.IncorrectOperationException
|
import com.intellij.util.IncorrectOperationException
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypeAndBranch
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypeAndBranch
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name
|
import org.jetbrains.jet.lang.resolve.name.Name
|
||||||
import org.jetbrains.jet.lang.resolve.dataClassUtils.isComponentLike
|
import org.jetbrains.jet.lang.resolve.dataClassUtils.isComponentLike
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class JetSimpleNameReference(
|
public class JetSimpleNameReference(
|
||||||
jetSimpleNameExpression: JetSimpleNameExpression
|
jetSimpleNameExpression: JetSimpleNameExpression
|
||||||
@@ -78,13 +78,13 @@ public class JetSimpleNameReference(
|
|||||||
val opExpression =
|
val opExpression =
|
||||||
PsiTreeUtil.getParentOfType<JetExpression>(expression, javaClass<JetUnaryExpression>(), javaClass<JetBinaryExpression>())
|
PsiTreeUtil.getParentOfType<JetExpression>(expression, javaClass<JetUnaryExpression>(), javaClass<JetBinaryExpression>())
|
||||||
if (elementType is JetToken && OperatorConventions.getNameForOperationSymbol(elementType) != null && opExpression != null) {
|
if (elementType is JetToken && OperatorConventions.getNameForOperationSymbol(elementType) != null && opExpression != null) {
|
||||||
val oldDescriptor = AnalyzerFacadeWithCache.getContextForElement(expression)[BindingContext.REFERENCE_TARGET, expression]
|
val oldDescriptor = expression.analyze()[BindingContext.REFERENCE_TARGET, expression]
|
||||||
val newExpression = OperatorToFunctionIntention.convert(opExpression)
|
val newExpression = OperatorToFunctionIntention.convert(opExpression)
|
||||||
newExpression.accept(
|
newExpression.accept(
|
||||||
object: JetTreeVisitorVoid() {
|
object: JetTreeVisitorVoid() {
|
||||||
override fun visitCallExpression(expression: JetCallExpression) {
|
override fun visitCallExpression(expression: JetCallExpression) {
|
||||||
val callee = expression.getCalleeExpression() as? JetSimpleNameExpression
|
val callee = expression.getCalleeExpression() as? JetSimpleNameExpression
|
||||||
if (callee != null && AnalyzerFacadeWithCache.getContextForElement(callee)[BindingContext.REFERENCE_TARGET, callee] == oldDescriptor) {
|
if (callee != null && callee.analyze()[BindingContext.REFERENCE_TARGET, callee] == oldDescriptor) {
|
||||||
nameElement = callee.getReferencedNameElement()
|
nameElement = callee.getReferencedNameElement()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+2
-2
@@ -33,13 +33,13 @@ import org.jetbrains.jet.asJava.LightClassUtil.PropertyAccessorsPsiMethods
|
|||||||
import org.jetbrains.jet.lang.psi.psiUtil.*
|
import org.jetbrains.jet.lang.psi.psiUtil.*
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name
|
import org.jetbrains.jet.lang.resolve.name.Name
|
||||||
import org.jetbrains.jet.lexer.JetSingleValueToken
|
import org.jetbrains.jet.lexer.JetSingleValueToken
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.jet.lexer.JetTokens
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
import org.jetbrains.jet.plugin.references.*
|
import org.jetbrains.jet.plugin.references.*
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||||
import com.intellij.util.containers.ContainerUtil
|
import com.intellij.util.containers.ContainerUtil
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
val isTargetUsage = (PsiReference::matchesTarget).searchFilter
|
val isTargetUsage = (PsiReference::matchesTarget).searchFilter
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ public fun PsiNamedElement.getSpecialNamesToSearch(): List<String> {
|
|||||||
this is JetParameter -> {
|
this is JetParameter -> {
|
||||||
if (!hasValOrVarNode()) return Collections.emptyList<String>()
|
if (!hasValOrVarNode()) return Collections.emptyList<String>()
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(this)
|
val context = this.analyze()
|
||||||
val paramDescriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? ValueParameterDescriptor
|
val paramDescriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, this] as? ValueParameterDescriptor
|
||||||
context[BindingContext.DATA_CLASS_COMPONENT_FUNCTION, paramDescriptor]?.let {
|
context[BindingContext.DATA_CLASS_COMPONENT_FUNCTION, paramDescriptor]?.let {
|
||||||
listOf(it.getName().asString(), JetTokens.LPAR.getValue())
|
listOf(it.getName().asString(), JetTokens.LPAR.getValue())
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.jetbrains.jet.lang.descriptors.*
|
|||||||
import org.jetbrains.jet.lang.psi.*
|
import org.jetbrains.jet.lang.psi.*
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.*
|
import org.jetbrains.jet.lang.psi.psiUtil.*
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import com.intellij.psi.PsiReference
|
import com.intellij.psi.PsiReference
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||||
import org.jetbrains.jet.codegen.PropertyCodegen
|
import org.jetbrains.jet.codegen.PropertyCodegen
|
||||||
@@ -31,12 +30,13 @@ import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.jet.plugin.references.*
|
import org.jetbrains.jet.plugin.references.*
|
||||||
import org.jetbrains.jet.plugin.findUsages.UsageTypeUtils
|
import org.jetbrains.jet.plugin.findUsages.UsageTypeUtils
|
||||||
import org.jetbrains.jet.plugin.findUsages.UsageTypeEnum
|
import org.jetbrains.jet.plugin.findUsages.UsageTypeEnum
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
val JetDeclaration.descriptor: DeclarationDescriptor?
|
val JetDeclaration.descriptor: DeclarationDescriptor?
|
||||||
get() = AnalyzerFacadeWithCache.getContextForElement(this).get(BindingContext.DECLARATION_TO_DESCRIPTOR, this)
|
get() = this.analyze().get(BindingContext.DECLARATION_TO_DESCRIPTOR, this)
|
||||||
|
|
||||||
val JetParameter.propertyDescriptor: PropertyDescriptor?
|
val JetParameter.propertyDescriptor: PropertyDescriptor?
|
||||||
get() = AnalyzerFacadeWithCache.getContextForElement(this).get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, this)
|
get() = this.analyze().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, this)
|
||||||
|
|
||||||
fun PsiReference.checkUsageVsOriginalDescriptor(
|
fun PsiReference.checkUsageVsOriginalDescriptor(
|
||||||
target: JetDeclaration,
|
target: JetDeclaration,
|
||||||
@@ -82,7 +82,7 @@ fun PsiReference.isConstructorUsage(jetClassOrObject: JetClassOrObject): Boolean
|
|||||||
fun checkKotlinUsage(): Boolean {
|
fun checkKotlinUsage(): Boolean {
|
||||||
if (this !is JetElement) return false
|
if (this !is JetElement) return false
|
||||||
|
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(this)
|
val bindingContext = this.analyze()
|
||||||
|
|
||||||
val descriptor = getCallDescriptor(bindingContext)
|
val descriptor = getCallDescriptor(bindingContext)
|
||||||
if (descriptor !is ConstructorDescriptor) return false
|
if (descriptor !is ConstructorDescriptor) return false
|
||||||
|
|||||||
+2
-7
@@ -16,21 +16,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.structureView
|
package org.jetbrains.jet.plugin.structureView
|
||||||
|
|
||||||
import com.intellij.ide.util.treeView.smartTree.TreeElement
|
|
||||||
import com.intellij.ide.util.InheritedMembersNodeProvider
|
import com.intellij.ide.util.InheritedMembersNodeProvider
|
||||||
import com.intellij.ide.util.treeView.smartTree.TreeElement
|
import com.intellij.ide.util.treeView.smartTree.TreeElement
|
||||||
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
|
||||||
import com.intellij.psi.NavigatablePsiElement
|
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor
|
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor
|
||||||
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
|
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
||||||
import com.intellij.psi.NavigatablePsiElement
|
import com.intellij.psi.NavigatablePsiElement
|
||||||
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeElement>() {
|
public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<TreeElement>() {
|
||||||
override fun provideNodes(node: TreeElement): Collection<TreeElement> {
|
override fun provideNodes(node: TreeElement): Collection<TreeElement> {
|
||||||
@@ -42,7 +37,7 @@ public class KotlinInheritedMembersNodeProvider: InheritedMembersNodeProvider<Tr
|
|||||||
[suppress("USELESS_CAST")] // KT-3996 Workaround
|
[suppress("USELESS_CAST")] // KT-3996 Workaround
|
||||||
val project = (element as NavigatablePsiElement).getProject()
|
val project = (element as NavigatablePsiElement).getProject()
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val descriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, element]
|
val descriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, element]
|
||||||
|
|
||||||
if (descriptor !is ClassifierDescriptor) return listOf()
|
if (descriptor !is ClassifierDescriptor) return listOf()
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.psi.JetDeclaration;
|
|||||||
import org.jetbrains.jet.lang.psi.JetPackageDirective;
|
import org.jetbrains.jet.lang.psi.JetPackageDirective;
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
|
|
||||||
public class JetQuickDocumentationProvider extends AbstractDocumentationProvider {
|
public class JetQuickDocumentationProvider extends AbstractDocumentationProvider {
|
||||||
@@ -67,7 +67,7 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
|
|||||||
if (quickNavigation) {
|
if (quickNavigation) {
|
||||||
JetReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(originalElement, JetReferenceExpression.class, false);
|
JetReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(originalElement, JetReferenceExpression.class, false);
|
||||||
if (referenceExpression != null) {
|
if (referenceExpression != null) {
|
||||||
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(referenceExpression);
|
BindingContext context = ResolvePackage.analyze(referenceExpression);
|
||||||
DeclarationDescriptor declarationDescriptor = context.get(BindingContext.REFERENCE_TARGET, referenceExpression);
|
DeclarationDescriptor declarationDescriptor = context.get(BindingContext.REFERENCE_TARGET, referenceExpression);
|
||||||
if (declarationDescriptor != null) {
|
if (declarationDescriptor != null) {
|
||||||
return mixKotlinToJava(declarationDescriptor, element, originalElement);
|
return mixKotlinToJava(declarationDescriptor, element, originalElement);
|
||||||
@@ -82,7 +82,7 @@ public class JetQuickDocumentationProvider extends AbstractDocumentationProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String renderKotlinDeclaration(JetDeclaration declaration, boolean quickNavigation) {
|
private static String renderKotlinDeclaration(JetDeclaration declaration, boolean quickNavigation) {
|
||||||
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(declaration);
|
BindingContext context = ResolvePackage.analyze(declaration);
|
||||||
DeclarationDescriptor declarationDescriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
DeclarationDescriptor declarationDescriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||||
|
|
||||||
assert declarationDescriptor != null;
|
assert declarationDescriptor != null;
|
||||||
|
|||||||
+2
-2
@@ -26,8 +26,8 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.plugin.JetBundle;
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
|
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
|
|
||||||
public class KotlinSurrounderUtils {
|
public class KotlinSurrounderUtils {
|
||||||
public static String SURROUND_WITH = JetBundle.message("surround.with");
|
public static String SURROUND_WITH = JetBundle.message("surround.with");
|
||||||
@@ -46,7 +46,7 @@ public class KotlinSurrounderUtils {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static JetType getExpressionType(JetExpression expression) {
|
public static JetType getExpressionType(JetExpression expression) {
|
||||||
BindingContext expressionBindingContext = AnalyzerFacadeWithCache.getContextForElement(expression);
|
BindingContext expressionBindingContext = ResolvePackage.analyze(expression);
|
||||||
return expressionBindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
return expressionBindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -29,9 +29,9 @@ import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
|||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
|
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -116,7 +116,7 @@ public class MoveDeclarationsOutHelper {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static JetType getPropertyType(@NotNull JetProperty property) {
|
private static JetType getPropertyType(@NotNull JetProperty property) {
|
||||||
BindingContext expressionBindingContext = AnalyzerFacadeWithCache.getContextForElement(property);
|
BindingContext expressionBindingContext = ResolvePackage.analyze(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();
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.intellij.debugger.actions.MethodSmartStepTarget
|
|||||||
import com.intellij.util.containers.OrderedSet
|
import com.intellij.util.containers.OrderedSet
|
||||||
import com.intellij.util.Range
|
import com.intellij.util.Range
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.asJava.LightClassUtil
|
import org.jetbrains.jet.asJava.LightClassUtil
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
@@ -40,6 +39,7 @@ import com.intellij.psi.PsiDocumentManager
|
|||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.jet.plugin.util.application.runReadAction
|
import org.jetbrains.jet.plugin.util.application.runReadAction
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
|||||||
if (doc == null) return Collections.emptyList()
|
if (doc == null) return Collections.emptyList()
|
||||||
|
|
||||||
val lines = Range<Int>(doc.getLineNumber(elementTextRange.getStartOffset()), doc.getLineNumber(elementTextRange.getEndOffset()))
|
val lines = Range<Int>(doc.getLineNumber(elementTextRange.getStartOffset()), doc.getLineNumber(elementTextRange.getEndOffset()))
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element)
|
val bindingContext = element.analyze()
|
||||||
val result = OrderedSet<SmartStepTarget>()
|
val result = OrderedSet<SmartStepTarget>()
|
||||||
|
|
||||||
// TODO support class initializers, local functions, delegated properties with specified type, setter for properties
|
// TODO support class initializers, local functions, delegated properties with specified type, setter for properties
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -164,7 +164,7 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
|
|||||||
elementText = ((JetFile) element).getName();
|
elementText = ((JetFile) element).getName();
|
||||||
}
|
}
|
||||||
else if (element instanceof JetNamedDeclaration) {
|
else if (element instanceof JetNamedDeclaration) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement((JetElement) element);
|
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||||
|
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||||
if (descriptor == null) return null;
|
if (descriptor == null) return null;
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ import com.intellij.psi.PsiReference;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.asJava.KotlinLightMethod;
|
import org.jetbrains.jet.asJava.KotlinLightMethod;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -84,7 +84,7 @@ public class KotlinCalleeMethodsTreeStructure extends KotlinCallTreeStructure {
|
|||||||
final Map<PsiReference, PsiElement> referencesToCalleeElements = new HashMap<PsiReference, PsiElement>();
|
final Map<PsiReference, PsiElement> referencesToCalleeElements = new HashMap<PsiReference, PsiElement>();
|
||||||
for (JetElement element : elementsToAnalyze) {
|
for (JetElement element : elementsToAnalyze) {
|
||||||
element.accept(
|
element.accept(
|
||||||
new CalleeReferenceVisitorBase(AnalyzerFacadeWithCache.getContextForElement(element), false) {
|
new CalleeReferenceVisitorBase(ResolvePackage.analyze(element), false) {
|
||||||
@Override
|
@Override
|
||||||
protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) {
|
protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) {
|
||||||
referencesToCalleeElements.put(reference.getReference(), declaration);
|
referencesToCalleeElements.put(reference.getReference(), declaration);
|
||||||
|
|||||||
+2
-2
@@ -37,8 +37,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.asJava.LightClassUtil;
|
import org.jetbrains.jet.asJava.LightClassUtil;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.hierarchy.HierarchyUtils;
|
import org.jetbrains.jet.plugin.hierarchy.HierarchyUtils;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.references.JetReference;
|
import org.jetbrains.jet.plugin.references.JetReference;
|
||||||
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchPackage;
|
import org.jetbrains.jet.plugin.search.usagesSearch.UsagesSearchPackage;
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure {
|
|||||||
|
|
||||||
JetElement codeBlockForLocalDeclaration = getEnclosingElementForLocalDeclaration(element);
|
JetElement codeBlockForLocalDeclaration = getEnclosingElementForLocalDeclaration(element);
|
||||||
if (codeBlockForLocalDeclaration != null) {
|
if (codeBlockForLocalDeclaration != null) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement((JetElement) element);
|
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||||
|
|
||||||
final Map<PsiReference, PsiElement> referencesToElements = new HashMap<PsiReference, PsiElement>();
|
final Map<PsiReference, PsiElement> referencesToElements = new HashMap<PsiReference, PsiElement>();
|
||||||
codeBlockForLocalDeclaration.accept(new CalleeReferenceVisitorBase(bindingContext, true) {
|
codeBlockForLocalDeclaration.accept(new CalleeReferenceVisitorBase(bindingContext, true) {
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import com.intellij.codeInsight.daemon.GutterIconNavigationHandler
|
|||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import com.intellij.util.Function
|
import com.intellij.util.Function
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
object SuperDeclarationMarkerTooltip: Function<JetDeclaration, String> {
|
object SuperDeclarationMarkerTooltip: Function<JetDeclaration, String> {
|
||||||
override fun `fun`(jetDeclaration: JetDeclaration?): String? {
|
override fun `fun`(jetDeclaration: JetDeclaration?): String? {
|
||||||
@@ -112,7 +112,7 @@ public data class ResolveWithParentsResult(
|
|||||||
val overriddenDescriptors: Collection<CallableMemberDescriptor>)
|
val overriddenDescriptors: Collection<CallableMemberDescriptor>)
|
||||||
|
|
||||||
public fun resolveDeclarationWithParents(element: JetDeclaration): ResolveWithParentsResult {
|
public fun resolveDeclarationWithParents(element: JetDeclaration): ResolveWithParentsResult {
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element)
|
val bindingContext = element.analyze()
|
||||||
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||||
|
|
||||||
if (descriptor !is CallableMemberDescriptor) return ResolveWithParentsResult(null, listOf())
|
if (descriptor !is CallableMemberDescriptor) return ResolveWithParentsResult(null, listOf())
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.jet.plugin.intentions
|
|||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import org.jetbrains.jet.lang.psi.JetPrefixExpression
|
import org.jetbrains.jet.lang.psi.JetPrefixExpression
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||||
@@ -32,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
|||||||
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetThrowExpression
|
import org.jetbrains.jet.lang.psi.JetThrowExpression
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.replaced
|
import org.jetbrains.jet.lang.psi.psiUtil.replaced
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class ConvertAssertToIfWithThrowIntention : JetSelfTargetingIntention<JetCallExpression>(
|
public class ConvertAssertToIfWithThrowIntention : JetSelfTargetingIntention<JetCallExpression>(
|
||||||
"convert.assert.to.if.with.throw", javaClass()) {
|
"convert.assert.to.if.with.throw", javaClass()) {
|
||||||
@@ -45,7 +45,7 @@ public class ConvertAssertToIfWithThrowIntention : JetSelfTargetingIntention<Jet
|
|||||||
if (argumentSize !in 1..2) return false
|
if (argumentSize !in 1..2) return false
|
||||||
if (element.getFunctionLiteralArguments().size == 1 && argumentSize == 1) return false
|
if (element.getFunctionLiteralArguments().size == 1 && argumentSize == 1) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val resolvedCall = element.getResolvedCall(context)
|
val resolvedCall = element.getResolvedCall(context)
|
||||||
if (resolvedCall == null) return false
|
if (resolvedCall == null) return false
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.jet.plugin.intentions
|
|||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import org.jetbrains.jet.lang.psi.JetPrefixExpression
|
import org.jetbrains.jet.lang.psi.JetPrefixExpression
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||||
@@ -30,6 +29,7 @@ import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetExpression
|
import org.jetbrains.jet.lang.psi.JetExpression
|
||||||
import org.jetbrains.jet.plugin.intentions.branchedTransformations.isNullExpression
|
import org.jetbrains.jet.plugin.intentions.branchedTransformations.isNullExpression
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class ConvertIfWithThrowToAssertIntention :
|
public class ConvertIfWithThrowToAssertIntention :
|
||||||
JetSelfTargetingIntention<JetIfExpression>("convert.if.with.throw.to.assert", javaClass()) {
|
JetSelfTargetingIntention<JetIfExpression>("convert.if.with.throw.to.assert", javaClass()) {
|
||||||
@@ -48,7 +48,7 @@ public class ConvertIfWithThrowToAssertIntention :
|
|||||||
val paramAmount = thrownExpr.getValueArguments().size
|
val paramAmount = thrownExpr.getValueArguments().size
|
||||||
if (paramAmount > 1) return false
|
if (paramAmount > 1) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(thrownExpr)
|
val context = thenExpr.analyze()
|
||||||
val resolvedCall = thrownExpr.getResolvedCall(context)
|
val resolvedCall = thrownExpr.getResolvedCall(context)
|
||||||
if (resolvedCall == null) return false
|
if (resolvedCall == null) return false
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -7,11 +7,11 @@ import org.jetbrains.jet.lang.psi.JetStringTemplateEntry
|
|||||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetStringTemplateEntryWithExpression
|
import org.jetbrains.jet.lang.psi.JetStringTemplateEntryWithExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression
|
import org.jetbrains.jet.lang.psi.JetExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||||
import org.jetbrains.jet.lang.psi.JetIfExpression
|
import org.jetbrains.jet.lang.psi.JetIfExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class ConvertToConcatenatedStringIntention : JetSelfTargetingIntention<JetStringTemplateExpression>("convert.to.concatenated.string.intention", javaClass()) {
|
public class ConvertToConcatenatedStringIntention : JetSelfTargetingIntention<JetStringTemplateExpression>("convert.to.concatenated.string.intention", javaClass()) {
|
||||||
override fun isApplicableTo(element: JetStringTemplateExpression): Boolean {
|
override fun isApplicableTo(element: JetStringTemplateExpression): Boolean {
|
||||||
@@ -62,7 +62,7 @@ public class ConvertToConcatenatedStringIntention : JetSelfTargetingIntention<Je
|
|||||||
private fun String.quote(quote: String) = quote + this + quote
|
private fun String.quote(quote: String) = quote + this + quote
|
||||||
|
|
||||||
private fun JetExpression.isStringExpression(): Boolean {
|
private fun JetExpression.isStringExpression(): Boolean {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(this)
|
val context = this.analyze()
|
||||||
val elementType = BindingContextUtils.getRecordedTypeInfo(this, context)?.getType()
|
val elementType = BindingContextUtils.getRecordedTypeInfo(this, context)?.getType()
|
||||||
|
|
||||||
return KotlinBuiltIns.getInstance().isString(elementType)
|
return KotlinBuiltIns.getInstance().isString(elementType)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.jet.plugin.intentions
|
|||||||
|
|
||||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression
|
import org.jetbrains.jet.lang.psi.JetExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
@@ -33,13 +32,14 @@ import org.jetbrains.jet.lang.psi.JetPsiUtil
|
|||||||
import com.intellij.openapi.util.text.StringUtil
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
import com.intellij.psi.util.PsiUtilCore
|
import com.intellij.psi.util.PsiUtilCore
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
|
|
||||||
public class ConvertToStringTemplateIntention : JetSelfTargetingIntention<JetBinaryExpression>("convert.to.string.template", javaClass()) {
|
public class ConvertToStringTemplateIntention : JetSelfTargetingIntention<JetBinaryExpression>("convert.to.string.template", javaClass()) {
|
||||||
override fun isApplicableTo(element: JetBinaryExpression): Boolean {
|
override fun isApplicableTo(element: JetBinaryExpression): Boolean {
|
||||||
if (element.getOperationToken() != JetTokens.PLUS) return false
|
if (element.getOperationToken() != JetTokens.PLUS) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val elementType = BindingContextUtils.getRecordedTypeInfo(element, context)?.getType()
|
val elementType = BindingContextUtils.getRecordedTypeInfo(element, context)?.getType()
|
||||||
if (!(KotlinBuiltIns.getInstance().isString(elementType))) return false
|
if (!(KotlinBuiltIns.getInstance().isString(elementType))) return false
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ public class ConvertToStringTemplateIntention : JetSelfTargetingIntention<JetBin
|
|||||||
val expressionText = expression?.getText() ?: ""
|
val expressionText = expression?.getText() ?: ""
|
||||||
return when (expression) {
|
return when (expression) {
|
||||||
is JetConstantExpression -> {
|
is JetConstantExpression -> {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
val context = expression.analyze()
|
||||||
val trace = DelegatingBindingTrace(context, "Trace for evaluating constant")
|
val trace = DelegatingBindingTrace(context, "Trace for evaluating constant")
|
||||||
val constant = ConstantExpressionEvaluator.evaluate(expression, trace, null)
|
val constant = ConstantExpressionEvaluator.evaluate(expression, trace, null)
|
||||||
if (constant is IntegerValueTypeConstant) {
|
if (constant is IntegerValueTypeConstant) {
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ package org.jetbrains.jet.plugin.intentions
|
|||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils
|
import org.jetbrains.jet.lang.types.ErrorUtils
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.jet.lang.psi.JetTypeArgumentList
|
import org.jetbrains.jet.lang.psi.JetTypeArgumentList
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class InsertExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpression>(
|
public class InsertExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpression>(
|
||||||
"insert.explicit.type.arguments", javaClass()) {
|
"insert.explicit.type.arguments", javaClass()) {
|
||||||
@@ -40,7 +40,7 @@ public class InsertExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpr
|
|||||||
val textRange = element.getCalleeExpression()?.getTextRange()
|
val textRange = element.getCalleeExpression()?.getTextRange()
|
||||||
if (textRange == null || !textRange.contains(editor.getCaretModel().getOffset())) return false
|
if (textRange == null || !textRange.contains(editor.getCaretModel().getOffset())) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val resolvedCall = element.getResolvedCall(context)
|
val resolvedCall = element.getResolvedCall(context)
|
||||||
if (resolvedCall == null) return false
|
if (resolvedCall == null) return false
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public class InsertExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpr
|
|||||||
|
|
||||||
class object {
|
class object {
|
||||||
fun createTypeArguments(element: JetCallExpression): JetTypeArgumentList? {
|
fun createTypeArguments(element: JetCallExpression): JetTypeArgumentList? {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val resolvedCall = element.getResolvedCall(context)
|
val resolvedCall = element.getResolvedCall(context)
|
||||||
if (resolvedCall == null) return null
|
if (resolvedCall == null) return null
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ package org.jetbrains.jet.plugin.intentions
|
|||||||
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils
|
import org.jetbrains.jet.lang.types.ErrorUtils
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFunctionLiteralExpression>(
|
public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFunctionLiteralExpression>(
|
||||||
"make.type.explicit.in.lambda", javaClass()) {
|
"make.type.explicit.in.lambda", javaClass()) {
|
||||||
@@ -42,7 +42,7 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
|
|||||||
caretLocation != closeBraceOffset) return false
|
caretLocation != closeBraceOffset) return false
|
||||||
else if (arrow == null && caretLocation != openBraceOffset + 1 && caretLocation != closeBraceOffset) return false
|
else if (arrow == null && caretLocation != openBraceOffset + 1 && caretLocation != closeBraceOffset) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val func = context[BindingContext.FUNCTION, element.getFunctionLiteral()]
|
val func = context[BindingContext.FUNCTION, element.getFunctionLiteral()]
|
||||||
if (func == null || ErrorUtils.containsErrorType(func)) return false
|
if (func == null || ErrorUtils.containsErrorType(func)) return false
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
|
|||||||
|
|
||||||
override fun applyTo(element: JetFunctionLiteralExpression, editor: Editor) {
|
override fun applyTo(element: JetFunctionLiteralExpression, editor: Editor) {
|
||||||
val functionLiteral = element.getFunctionLiteral()
|
val functionLiteral = element.getFunctionLiteral()
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
val context = element.analyze()
|
||||||
val func = context[BindingContext.FUNCTION, functionLiteral]!!
|
val func = context[BindingContext.FUNCTION, functionLiteral]!!
|
||||||
|
|
||||||
// Step 1: make the parameters types explicit
|
// Step 1: make the parameters types explicit
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import org.jetbrains.jet.lang.psi.*;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.plugin.JetBundle;
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
||||||
@@ -81,6 +81,6 @@ public class ReconstructTypeInCastOrIsAction extends PsiElementBaseIntentionActi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static JetType getReconstructedType(JetTypeReference typeRef) {
|
private static JetType getReconstructedType(JetTypeReference typeRef) {
|
||||||
return AnalyzerFacadeWithCache.getContextForElement(typeRef).get(BindingContext.TYPE, typeRef);
|
return ResolvePackage.analyze(typeRef).get(BindingContext.TYPE, typeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -26,9 +26,7 @@ import com.intellij.usageView.UsageInfo
|
|||||||
import org.jetbrains.jet.lang.psi.*
|
import org.jetbrains.jet.lang.psi.*
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
|
||||||
import org.jetbrains.jet.plugin.references.JetReference
|
import org.jetbrains.jet.plugin.references.JetReference
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||||
|
|||||||
+2
-2
@@ -27,12 +27,12 @@ import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
||||||
import org.jetbrains.jet.plugin.references.JetReference
|
import org.jetbrains.jet.plugin.references.JetReference
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBaseIntentionAction() {
|
public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBaseIntentionAction() {
|
||||||
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
||||||
@@ -74,7 +74,7 @@ public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBa
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(simpleNameExpression)
|
val bindingContext = simpleNameExpression.analyze()
|
||||||
val reference = simpleNameExpression.getReference() as JetReference?
|
val reference = simpleNameExpression.getReference() as JetReference?
|
||||||
val simpleNameTarget = reference?.resolveToDescriptors()?.firstOrNull() as? ValueParameterDescriptor?
|
val simpleNameTarget = reference?.resolveToDescriptors()?.firstOrNull() as? ValueParameterDescriptor?
|
||||||
if (simpleNameTarget == null || bindingContext.get(BindingContext.AUTO_CREATED_IT, simpleNameTarget) != true) {
|
if (simpleNameTarget == null || bindingContext.get(BindingContext.AUTO_CREATED_IT, simpleNameTarget) != true) {
|
||||||
|
|||||||
+2
-2
@@ -23,11 +23,11 @@ import org.jetbrains.jet.plugin.caches.resolve.analyzeFully
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
import org.jetbrains.jet.lang.psi.JetValueArgument
|
import org.jetbrains.jet.lang.psi.JetValueArgument
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils
|
import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import com.intellij.codeInsight.hint.HintManager
|
import com.intellij.codeInsight.hint.HintManager
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntention<JetCallExpression>("replace.with.infix.function.call.intention", javaClass()) {
|
public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntention<JetCallExpression>("replace.with.infix.function.call.intention", javaClass()) {
|
||||||
override fun isApplicableTo(element: JetCallExpression): Boolean {
|
override fun isApplicableTo(element: JetCallExpression): Boolean {
|
||||||
@@ -88,7 +88,7 @@ public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntent
|
|||||||
val operatorText = element.getCalleeExpression()!!.getText()
|
val operatorText = element.getCalleeExpression()!!.getText()
|
||||||
val valueArguments = element.getValueArgumentList()?.getArguments() ?: listOf<JetValueArgument>()
|
val valueArguments = element.getValueArgumentList()?.getArguments() ?: listOf<JetValueArgument>()
|
||||||
val functionLiteralArguments = element.getFunctionLiteralArguments()
|
val functionLiteralArguments = element.getFunctionLiteralArguments()
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(parent)
|
val bindingContext = parent.analyze()
|
||||||
val receiverType = bindingContext[BindingContext.EXPRESSION_TYPE, receiver]
|
val receiverType = bindingContext[BindingContext.EXPRESSION_TYPE, receiver]
|
||||||
if (receiverType == null) {
|
if (receiverType == null) {
|
||||||
if (bindingContext[BindingContext.QUALIFIER, receiver] != null) {
|
if (bindingContext[BindingContext.QUALIFIER, receiver] != null) {
|
||||||
|
|||||||
@@ -21,13 +21,11 @@ import com.intellij.openapi.editor.Editor
|
|||||||
import org.jetbrains.jet.lexer.JetTokens
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.JetPsiUnifier
|
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.UnificationResult
|
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.matches
|
import org.jetbrains.jet.plugin.util.psi.patternMatching.matches
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class ReplaceWithOperatorAssignIntention : JetSelfTargetingIntention<JetBinaryExpression>("replace.with.operator.assign.intention", javaClass()) {
|
public class ReplaceWithOperatorAssignIntention : JetSelfTargetingIntention<JetBinaryExpression>("replace.with.operator.assign.intention", javaClass()) {
|
||||||
|
|
||||||
@@ -44,7 +42,7 @@ public class ReplaceWithOperatorAssignIntention : JetSelfTargetingIntention<JetB
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkExpressionRepeat(variableExpression: JetSimpleNameExpression, expression: JetBinaryExpression): Boolean {
|
fun checkExpressionRepeat(variableExpression: JetSimpleNameExpression, expression: JetBinaryExpression): Boolean {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
val context = expression.analyze()
|
||||||
val descriptor = context[BindingContext.REFERENCE_TARGET, expression.getOperationReference()]?.getContainingDeclaration()
|
val descriptor = context[BindingContext.REFERENCE_TARGET, expression.getOperationReference()]?.getContainingDeclaration()
|
||||||
val isPrimitiveOperation = descriptor is ClassDescriptor && KotlinBuiltIns.getInstance().isPrimitiveType(descriptor.getDefaultType())
|
val isPrimitiveOperation = descriptor is ClassDescriptor && KotlinBuiltIns.getInstance().isPrimitiveType(descriptor.getDefaultType())
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -24,11 +24,11 @@ import org.jetbrains.jet.lang.psi.JetParenthesizedExpression
|
|||||||
import org.jetbrains.jet.lexer.JetTokens
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils
|
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils
|
||||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
|
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import com.intellij.psi.tree.IElementType
|
import com.intellij.psi.tree.IElementType
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.copied
|
import org.jetbrains.jet.lang.psi.psiUtil.copied
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.replaced
|
import org.jetbrains.jet.lang.psi.psiUtil.replaced
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class SimplifyBooleanWithConstantsIntention : JetSelfTargetingIntention<JetBinaryExpression>(
|
public class SimplifyBooleanWithConstantsIntention : JetSelfTargetingIntention<JetBinaryExpression>(
|
||||||
"simplify.boolean.with.constants", javaClass()) {
|
"simplify.boolean.with.constants", javaClass()) {
|
||||||
@@ -128,7 +128,7 @@ public class SimplifyBooleanWithConstantsIntention : JetSelfTargetingIntention<J
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun JetExpression.canBeReducedToBooleanConstant(constant: Boolean?): Boolean {
|
private fun JetExpression.canBeReducedToBooleanConstant(constant: Boolean?): Boolean {
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(this)
|
val bindingContext = this.analyze()
|
||||||
val trace = DelegatingBindingTrace(bindingContext, "trace for constant check")
|
val trace = DelegatingBindingTrace(bindingContext, "trace for constant check")
|
||||||
return CompileTimeConstantUtils.canBeReducedToBooleanConstant(this, trace, constant)
|
return CompileTimeConstantUtils.canBeReducedToBooleanConstant(this, trace, constant)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,6 @@ import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
||||||
import org.jetbrains.jet.plugin.intentions.JetSelfTargetingIntention
|
import org.jetbrains.jet.plugin.intentions.JetSelfTargetingIntention
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.jet.lang.psi.ValueArgument
|
import org.jetbrains.jet.lang.psi.ValueArgument
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
@@ -33,6 +32,7 @@ import org.jetbrains.jet.plugin.util.MaybeError
|
|||||||
import org.jetbrains.jet.plugin.util.MaybeValue
|
import org.jetbrains.jet.plugin.util.MaybeValue
|
||||||
import com.intellij.codeInsight.hint.HintManager
|
import com.intellij.codeInsight.hint.HintManager
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
// Internal because you shouldn't construct this manually. You can end up with an inconsistant CallDescription.
|
// Internal because you shouldn't construct this manually. You can end up with an inconsistant CallDescription.
|
||||||
public class CallDescription internal (
|
public class CallDescription internal (
|
||||||
@@ -89,7 +89,7 @@ public class CallDescription internal (
|
|||||||
public fun JetQualifiedExpression.toCallDescription(): CallDescription? {
|
public fun JetQualifiedExpression.toCallDescription(): CallDescription? {
|
||||||
val callExpression = getSelectorExpression() as? JetCallExpression ?: return null
|
val callExpression = getSelectorExpression() as? JetCallExpression ?: return null
|
||||||
|
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(callExpression)
|
val bindingContext = callExpression.analyze()
|
||||||
// This should work. Nothing that returns a CallableDescriptor returns null and (out T is T)
|
// This should work. Nothing that returns a CallableDescriptor returns null and (out T is T)
|
||||||
val resolvedCall = callExpression.getResolvedCall(bindingContext) ?:
|
val resolvedCall = callExpression.getResolvedCall(bindingContext) ?:
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.intellij.openapi.editor.Editor
|
|||||||
import org.jetbrains.jet.plugin.refactoring.introduce.introduceVariable.KotlinIntroduceVariableHandler
|
import org.jetbrains.jet.plugin.refactoring.introduce.introduceVariable.KotlinIntroduceVariableHandler
|
||||||
import org.jetbrains.jet.lang.psi.JetSafeQualifiedExpression
|
import org.jetbrains.jet.lang.psi.JetSafeQualifiedExpression
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.jet.plugin.refactoring.inline.KotlinInlineValHandler
|
import org.jetbrains.jet.plugin.refactoring.inline.KotlinInlineValHandler
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
@@ -44,6 +43,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.jet.lang.psi.JetElement
|
import org.jetbrains.jet.lang.psi.JetElement
|
||||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.isUsedAsStatement
|
import org.jetbrains.jet.lang.resolve.bindingContextUtil.isUsedAsStatement
|
||||||
import org.jetbrains.jet.lang.psi.JetProperty
|
import org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
val NULL_PTR_EXCEPTION = "NullPointerException"
|
val NULL_PTR_EXCEPTION = "NullPointerException"
|
||||||
val NULL_PTR_EXCEPTION_FQ = "java.lang.NullPointerException"
|
val NULL_PTR_EXCEPTION_FQ = "java.lang.NullPointerException"
|
||||||
@@ -73,7 +73,7 @@ fun JetExpression.extractExpressionIfSingle(): JetExpression? {
|
|||||||
return innerExpression
|
return innerExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
fun JetExpression.isStatement(): Boolean = isUsedAsStatement(AnalyzerFacadeWithCache.getContextForElement(this))
|
fun JetExpression.isStatement(): Boolean = isUsedAsStatement(this.analyze())
|
||||||
|
|
||||||
fun JetBinaryExpression.getNonNullExpression(): JetExpression? = when {
|
fun JetBinaryExpression.getNonNullExpression(): JetExpression? = when {
|
||||||
this.getLeft()?.isNullExpression() == false ->
|
this.getLeft()?.isNullExpression() == false ->
|
||||||
@@ -94,7 +94,7 @@ fun JetThrowExpression.throwsNullPointerExceptionWithNoArguments(): Boolean {
|
|||||||
val thrownExpression = this.getThrownExpression()
|
val thrownExpression = this.getThrownExpression()
|
||||||
if (thrownExpression !is JetCallExpression) return false
|
if (thrownExpression !is JetCallExpression) return false
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(this)
|
val context = this.analyze()
|
||||||
val descriptor = context.get(BindingContext.REFERENCE_TARGET, thrownExpression.getCalleeExpression() as JetSimpleNameExpression)
|
val descriptor = context.get(BindingContext.REFERENCE_TARGET, thrownExpression.getCalleeExpression() as JetSimpleNameExpression)
|
||||||
val declDescriptor = descriptor?.getContainingDeclaration()
|
val declDescriptor = descriptor?.getContainingDeclaration()
|
||||||
if (declDescriptor == null) return false
|
if (declDescriptor == null) return false
|
||||||
@@ -169,7 +169,7 @@ fun JetPostfixExpression.inlineBaseExpressionIfApplicableWithPrompt(editor: Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun JetExpression.isStableVariable(): Boolean {
|
fun JetExpression.isStableVariable(): Boolean {
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(this)
|
val context = this.analyze()
|
||||||
val descriptor = BindingContextUtils.extractVariableDescriptorIfAny(context, this, false)
|
val descriptor = BindingContextUtils.extractVariableDescriptorIfAny(context, this, false)
|
||||||
return descriptor is VariableDescriptor && DataFlowValueFactory.isStableVariable(descriptor)
|
return descriptor is VariableDescriptor && DataFlowValueFactory.isStableVariable(descriptor)
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -25,10 +25,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
|||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import com.intellij.util.containers.ContainerUtil
|
import com.intellij.util.containers.ContainerUtil
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.JetPsiUnifier
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.toRange
|
import org.jetbrains.jet.plugin.util.psi.patternMatching.toRange
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.UnificationResult
|
|
||||||
import org.jetbrains.jet.plugin.util.psi.patternMatching.matches
|
import org.jetbrains.jet.plugin.util.psi.patternMatching.matches
|
||||||
|
|
||||||
public val TRANSFORM_WITHOUT_CHECK: String = "Expression must be checked before applying transformation"
|
public val TRANSFORM_WITHOUT_CHECK: String = "Expression must be checked before applying transformation"
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ public class DeclarationUtils {
|
|||||||
private static JetType getPropertyTypeIfNeeded(@NotNull JetProperty property) {
|
private static JetType getPropertyTypeIfNeeded(@NotNull JetProperty property) {
|
||||||
if (property.getTypeReference() != null) return null;
|
if (property.getTypeReference() != null) return null;
|
||||||
|
|
||||||
JetType type = AnalyzerFacadeWithCache.getContextForElement(property).get(
|
JetType type = ResolvePackage.analyze(property).get(
|
||||||
BindingContext.EXPRESSION_TYPE, property.getInitializer()
|
BindingContext.EXPRESSION_TYPE, property.getInitializer()
|
||||||
);
|
);
|
||||||
return type == null || type.isError() ? null : type;
|
return type == null || type.isError() ? null : type;
|
||||||
|
|||||||
+2
-2
@@ -32,8 +32,8 @@ import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler;
|
import org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -60,7 +60,7 @@ class AnonymousTemplateEditingListener extends TemplateEditingAdapter {
|
|||||||
PsiElement name = psiFile.findElementAt(variableRange.getStartOffset());
|
PsiElement name = psiFile.findElementAt(variableRange.getStartOffset());
|
||||||
if (name != null && name.getParent() instanceof JetReferenceExpression) {
|
if (name != null && name.getParent() instanceof JetReferenceExpression) {
|
||||||
JetReferenceExpression ref = (JetReferenceExpression) name.getParent();
|
JetReferenceExpression ref = (JetReferenceExpression) name.getParent();
|
||||||
DeclarationDescriptor descriptor = AnalyzerFacadeWithCache.getContextForElement(ref).get(BindingContext.REFERENCE_TARGET, ref);
|
DeclarationDescriptor descriptor = ResolvePackage.analyze(ref).get(BindingContext.REFERENCE_TARGET, ref);
|
||||||
if (descriptor instanceof ClassDescriptor) {
|
if (descriptor instanceof ClassDescriptor) {
|
||||||
classRef = ref;
|
classRef = ref;
|
||||||
classDescriptor = (ClassDescriptor) descriptor;
|
classDescriptor = (ClassDescriptor) descriptor;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.scopes.DescriptorKindFilter;
|
import org.jetbrains.jet.lang.resolve.scopes.DescriptorKindFilter;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.plugin.JetBundle;
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@@ -91,7 +91,7 @@ public class JetAnonymousSuperMacro extends Macro {
|
|||||||
JetExpression expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(context.getStartOffset()), JetExpression.class);
|
JetExpression expression = PsiTreeUtil.getParentOfType(psiFile.findElementAt(context.getStartOffset()), JetExpression.class);
|
||||||
if (expression == null) return null;
|
if (expression == null) return null;
|
||||||
|
|
||||||
BindingContext bc = AnalyzerFacadeWithCache.getContextForElement(expression);
|
BindingContext bc = ResolvePackage.analyze(expression);
|
||||||
JetScope scope = bc.get(BindingContext.RESOLUTION_SCOPE, expression);
|
JetScope scope = bc.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||||
if (scope == null) return null;
|
if (scope == null) return null;
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -2,7 +2,6 @@ package org.jetbrains.jet.plugin.quickfix.createFromUsage.createClass
|
|||||||
|
|
||||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
import com.intellij.codeInsight.intention.IntentionAction
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.TypeInfo
|
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.TypeInfo
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.types.Variance
|
import org.jetbrains.jet.lang.types.Variance
|
||||||
@@ -14,12 +13,11 @@ import org.jetbrains.jet.lang.psi.JetAnnotationEntry
|
|||||||
import org.jetbrains.jet.lang.psi.JetUserType
|
import org.jetbrains.jet.lang.psi.JetUserType
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall
|
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall
|
||||||
import org.jetbrains.jet.lang.psi.JetDelegatorToThisCall
|
|
||||||
import org.jetbrains.jet.lang.psi.JetCallElement
|
import org.jetbrains.jet.lang.psi.JetCallElement
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||||
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
|
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public object CreateClassFromCallWithConstructorCalleeActionFactory : JetSingleIntentionActionFactory() {
|
public object CreateClassFromCallWithConstructorCalleeActionFactory : JetSingleIntentionActionFactory() {
|
||||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
@@ -42,7 +40,7 @@ public object CreateClassFromCallWithConstructorCalleeActionFactory : JetSingleI
|
|||||||
val typeRef = callee.getTypeReference() ?: return null
|
val typeRef = callee.getTypeReference() ?: return null
|
||||||
val userType = typeRef.getTypeElement() as? JetUserType ?: return null
|
val userType = typeRef.getTypeElement() as? JetUserType ?: return null
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(userType)
|
val context = userType.analyze()
|
||||||
|
|
||||||
val qualifier = userType.getQualifier()?.getReferenceExpression()
|
val qualifier = userType.getQualifier()?.getReferenceExpression()
|
||||||
val qualifierDescriptor = qualifier?.let { context[BindingContext.REFERENCE_TARGET, it] }
|
val qualifierDescriptor = qualifier?.let { context[BindingContext.REFERENCE_TARGET, it] }
|
||||||
|
|||||||
+2
-2
@@ -12,8 +12,8 @@ import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.TypeInf
|
|||||||
import org.jetbrains.jet.lang.types.Variance
|
import org.jetbrains.jet.lang.types.Variance
|
||||||
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperClass
|
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperClass
|
||||||
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
|
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
|
import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public object CreateClassFromTypeReferenceActionFactory: JetIntentionActionsFactory() {
|
public object CreateClassFromTypeReferenceActionFactory: JetIntentionActionsFactory() {
|
||||||
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
||||||
@@ -28,7 +28,7 @@ public object CreateClassFromTypeReferenceActionFactory: JetIntentionActionsFact
|
|||||||
|
|
||||||
val traitExpected = typeRefParent is JetDelegatorToSuperClass
|
val traitExpected = typeRefParent is JetDelegatorToSuperClass
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(userType)
|
val context = userType.analyze()
|
||||||
|
|
||||||
val file = userType.getContainingFile() as? JetFile ?: return Collections.emptyList()
|
val file = userType.getContainingFile() as? JetFile ?: return Collections.emptyList()
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -9,7 +9,6 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
|||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
import org.jetbrains.jet.lexer.JetTokens
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getCall
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.Qualifier
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.Qualifier
|
||||||
@@ -26,6 +25,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext
|
|||||||
import org.jetbrains.jet.lang.psi.JetTypeReference
|
import org.jetbrains.jet.lang.psi.JetTypeReference
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import org.jetbrains.jet.lang.psi.JetAnnotationEntry
|
import org.jetbrains.jet.lang.psi.JetAnnotationEntry
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionFactory() {
|
object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionFactory() {
|
||||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
@@ -33,22 +33,22 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionF
|
|||||||
if (PsiTreeUtil.getParentOfType(diagElement, javaClass<JetTypeReference>(), javaClass<JetAnnotationEntry>()) != null) return null
|
if (PsiTreeUtil.getParentOfType(diagElement, javaClass<JetTypeReference>(), javaClass<JetAnnotationEntry>()) != null) return null
|
||||||
|
|
||||||
val callExpr = when (diagnostic.getFactory()) {
|
val callExpr = when (diagnostic.getFactory()) {
|
||||||
in Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS, Errors.EXPRESSION_EXPECTED_PACKAGE_FOUND -> {
|
in Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS, Errors.EXPRESSION_EXPECTED_PACKAGE_FOUND -> {
|
||||||
val parent = diagElement.getParent()
|
val parent = diagElement.getParent()
|
||||||
if (parent is JetCallExpression && parent.getCalleeExpression() == diagElement) parent else diagElement
|
if (parent is JetCallExpression && parent.getCalleeExpression() == diagElement) parent else diagElement
|
||||||
}
|
}
|
||||||
|
|
||||||
Errors.NO_VALUE_FOR_PARAMETER,
|
Errors.NO_VALUE_FOR_PARAMETER,
|
||||||
Errors.TOO_MANY_ARGUMENTS -> diagElement.getParentByType(javaClass<JetCallExpression>())
|
Errors.TOO_MANY_ARGUMENTS -> diagElement.getParentByType(javaClass<JetCallExpression>())
|
||||||
|
|
||||||
else -> throw AssertionError("Unexpected diagnostic: ${diagnostic.getFactory()}")
|
else -> throw AssertionError("Unexpected diagnostic: ${diagnostic.getFactory()}")
|
||||||
} as? JetExpression ?: return null
|
} as? JetExpression ?: return null
|
||||||
|
|
||||||
val calleeExpr = when (callExpr) {
|
val calleeExpr = when (callExpr) {
|
||||||
is JetCallExpression -> callExpr.getCalleeExpression()
|
is JetCallExpression -> callExpr.getCalleeExpression()
|
||||||
is JetSimpleNameExpression -> callExpr
|
is JetSimpleNameExpression -> callExpr
|
||||||
else -> null
|
else -> null
|
||||||
} as? JetSimpleNameExpression ?: return null
|
} as? JetSimpleNameExpression ?: return null
|
||||||
|
|
||||||
if (calleeExpr.getReferencedNameElementType() != JetTokens.IDENTIFIER) return null
|
if (calleeExpr.getReferencedNameElementType() != JetTokens.IDENTIFIER) return null
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionF
|
|||||||
val fullCallExpr =
|
val fullCallExpr =
|
||||||
if (callParent is JetQualifiedExpression && callParent.getSelectorExpression() == callExpr) callParent else callExpr
|
if (callParent is JetQualifiedExpression && callParent.getSelectorExpression() == callExpr) callParent else callExpr
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(callExpr)
|
val context = calleeExpr.analyze()
|
||||||
val receiver = callExpr.getCall(context)?.getExplicitReceiver()
|
val receiver = callExpr.getCall(context)?.getExplicitReceiver()
|
||||||
|
|
||||||
val receiverType = when (receiver) {
|
val receiverType = when (receiver) {
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,6 @@ import org.jetbrains.jet.lang.types.Variance
|
|||||||
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.ParameterInfo
|
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.ParameterInfo
|
||||||
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.FunctionInfo
|
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.FunctionInfo
|
||||||
import org.jetbrains.jet.lang.psi.JetProperty
|
import org.jetbrains.jet.lang.psi.JetProperty
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||||
@@ -17,11 +16,12 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
|||||||
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.CallableInfo
|
import org.jetbrains.jet.plugin.quickfix.createFromUsage.callableBuilder.CallableInfo
|
||||||
import com.intellij.util.SmartList
|
import com.intellij.util.SmartList
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor
|
import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
object CreatePropertyDelegateAccessorsActionFactory : JetSingleIntentionActionFactory() {
|
object CreatePropertyDelegateAccessorsActionFactory : JetSingleIntentionActionFactory() {
|
||||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
val expression = diagnostic.getPsiElement() as? JetExpression ?: return null
|
val expression = diagnostic.getPsiElement() as? JetExpression ?: return null
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
val context = expression.analyze()
|
||||||
[suppress("UNCHECKED_CAST")]
|
[suppress("UNCHECKED_CAST")]
|
||||||
|
|
||||||
fun isApplicableForAccessor(accessor: PropertyAccessorDescriptor?): Boolean =
|
fun isApplicableForAccessor(accessor: PropertyAccessorDescriptor?): Boolean =
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ import org.jetbrains.jet.lang.psi.JetOperationExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
||||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
import org.jetbrains.jet.lang.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils
|
import org.jetbrains.jet.lang.types.ErrorUtils
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
object CreateSetFunctionActionFactory : JetSingleIntentionActionFactory() {
|
object CreateSetFunctionActionFactory : JetSingleIntentionActionFactory() {
|
||||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||||
@@ -38,7 +38,7 @@ object CreateSetFunctionActionFactory : JetSingleIntentionActionFactory() {
|
|||||||
is JetUnaryExpression -> {
|
is JetUnaryExpression -> {
|
||||||
if (assignmentExpr.getOperationToken() !in OperatorConventions.INCREMENT_OPERATIONS) return null
|
if (assignmentExpr.getOperationToken() !in OperatorConventions.INCREMENT_OPERATIONS) return null
|
||||||
|
|
||||||
val context = AnalyzerFacadeWithCache.getContextForElement(assignmentExpr)
|
val context = assignmentExpr.analyze()
|
||||||
val rhsType = assignmentExpr.getResolvedCall(context)?.getResultingDescriptor()?.getReturnType()
|
val rhsType = assignmentExpr.getResolvedCall(context)?.getResultingDescriptor()?.getReturnType()
|
||||||
TypeInfo(if (rhsType == null || ErrorUtils.containsErrorType(rhsType)) builtIns.getAnyType() else rhsType, Variance.IN_VARIANCE)
|
TypeInfo(if (rhsType == null || ErrorUtils.containsErrorType(rhsType)) builtIns.getAnyType() else rhsType, Variance.IN_VARIANCE)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
|||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.lexer.JetLexer;
|
import org.jetbrains.jet.lexer.JetLexer;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -67,7 +67,7 @@ public class JetNameSuggester {
|
|||||||
public static @NotNull String[] suggestNames(@NotNull JetExpression expression, @NotNull JetNameValidator validator, @Nullable String defaultName) {
|
public static @NotNull String[] suggestNames(@NotNull JetExpression expression, @NotNull JetNameValidator validator, @Nullable String defaultName) {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(expression);
|
BindingContext bindingContext = ResolvePackage.analyze(expression);
|
||||||
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
if (jetType != null) {
|
if (jetType != null) {
|
||||||
addNamesForType(result, jetType, validator);
|
addNamesForType(result, jetType, validator);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.psi.JetVisitorVoid;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -72,7 +72,7 @@ public class JetNameValidatorImpl extends JetNameValidator {
|
|||||||
private boolean checkElement(String name, PsiElement sibling, final Set<JetScope> visitedScopes) {
|
private boolean checkElement(String name, PsiElement sibling, final Set<JetScope> visitedScopes) {
|
||||||
if (!(sibling instanceof JetElement)) return true;
|
if (!(sibling instanceof JetElement)) return true;
|
||||||
|
|
||||||
final BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement((JetElement) sibling);
|
final BindingContext bindingContext = ResolvePackage.analyze((JetElement) sibling);
|
||||||
final Name identifier = Name.identifier(name);
|
final Name identifier = Name.identifier(name);
|
||||||
|
|
||||||
final Ref<Boolean> result = new Ref<Boolean>(true);
|
final Ref<Boolean> result = new Ref<Boolean>(true);
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
|||||||
import org.jetbrains.jet.lexer.JetModifierKeywordToken;
|
import org.jetbrains.jet.lexer.JetModifierKeywordToken;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.jetbrains.jet.plugin.JetBundle;
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
|
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil;
|
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.jet.plugin.util.string.StringPackage;
|
import org.jetbrains.jet.plugin.util.string.StringPackage;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
@@ -127,7 +127,7 @@ public class JetRefactoringUtil {
|
|||||||
@Nullable Collection<PsiElement> ignore,
|
@Nullable Collection<PsiElement> ignore,
|
||||||
@NotNull String actionStringKey
|
@NotNull String actionStringKey
|
||||||
) {
|
) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(declaration);
|
BindingContext bindingContext = ResolvePackage.analyze(declaration);
|
||||||
|
|
||||||
CallableDescriptor declarationDescriptor =
|
CallableDescriptor declarationDescriptor =
|
||||||
(CallableDescriptor)bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
(CallableDescriptor)bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration);
|
||||||
@@ -262,7 +262,7 @@ public class JetRefactoringUtil {
|
|||||||
PsiElement originalDeclaration = AsJavaPackage.getUnwrapped(method);
|
PsiElement originalDeclaration = AsJavaPackage.getUnwrapped(method);
|
||||||
if (originalDeclaration instanceof JetDeclaration) {
|
if (originalDeclaration instanceof JetDeclaration) {
|
||||||
JetDeclaration jetDeclaration = (JetDeclaration) originalDeclaration;
|
JetDeclaration jetDeclaration = (JetDeclaration) originalDeclaration;
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(jetDeclaration);
|
BindingContext bindingContext = ResolvePackage.analyze(jetDeclaration);
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetDeclaration);
|
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetDeclaration);
|
||||||
|
|
||||||
if (descriptor != null) return formatFunctionDescriptor(descriptor);
|
if (descriptor != null) return formatFunctionDescriptor(descriptor);
|
||||||
@@ -272,7 +272,7 @@ public class JetRefactoringUtil {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String formatClass(@NotNull JetClassOrObject classOrObject) {
|
public static String formatClass(@NotNull JetClassOrObject classOrObject) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(classOrObject);
|
BindingContext bindingContext = ResolvePackage.analyze(classOrObject);
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
|
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
|
||||||
|
|
||||||
if (descriptor instanceof ClassDescriptor) return formatClassDescriptor(descriptor);
|
if (descriptor instanceof ClassDescriptor) return formatClassDescriptor(descriptor);
|
||||||
@@ -425,7 +425,7 @@ public class JetRefactoringUtil {
|
|||||||
}
|
}
|
||||||
if (addExpression) {
|
if (addExpression) {
|
||||||
JetExpression expression = (JetExpression)element;
|
JetExpression expression = (JetExpression)element;
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(expression);
|
BindingContext bindingContext = ResolvePackage.analyze(expression);
|
||||||
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||||
if (expressionType == null || !KotlinBuiltIns.getInstance().isUnit(expressionType)) {
|
if (expressionType == null || !KotlinBuiltIns.getInstance().isUnit(expressionType)) {
|
||||||
expressions.add(expression);
|
expressions.add(expression);
|
||||||
|
|||||||
+7
-4
@@ -32,10 +32,13 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.TestOnly;
|
import org.jetbrains.annotations.TestOnly;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle;
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -74,7 +77,7 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler {
|
|||||||
JetElement jetElement = PsiTreeUtil.getParentOfType(element, JetElement.class);
|
JetElement jetElement = PsiTreeUtil.getParentOfType(element, JetElement.class);
|
||||||
if (jetElement == null) return null;
|
if (jetElement == null) return null;
|
||||||
|
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(jetElement);
|
BindingContext bindingContext = ResolvePackage.analyze(jetElement);
|
||||||
DeclarationDescriptor descriptor =
|
DeclarationDescriptor descriptor =
|
||||||
bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) receiverExpr);
|
bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) receiverExpr);
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler {
|
|||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@Nullable Editor editor
|
@Nullable Editor editor
|
||||||
) {
|
) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(element);
|
BindingContext bindingContext = ResolvePackage.analyze(element);
|
||||||
FunctionDescriptor functionDescriptor = findDescriptor(element, project, editor, bindingContext);
|
FunctionDescriptor functionDescriptor = findDescriptor(element, project, editor, bindingContext);
|
||||||
if (functionDescriptor == null) {
|
if (functionDescriptor == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-2
@@ -41,7 +41,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.refactoring.changeSignature.usages.JetFunctionCallUsage;
|
import org.jetbrains.jet.plugin.refactoring.changeSignature.usages.JetFunctionCallUsage;
|
||||||
import org.jetbrains.jet.plugin.refactoring.changeSignature.usages.JetFunctionDefinitionUsage;
|
import org.jetbrains.jet.plugin.refactoring.changeSignature.usages.JetFunctionDefinitionUsage;
|
||||||
import org.jetbrains.jet.plugin.refactoring.changeSignature.usages.JetParameterUsage;
|
import org.jetbrains.jet.plugin.refactoring.changeSignature.usages.JetParameterUsage;
|
||||||
@@ -129,7 +129,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
|||||||
JetChangeInfo changeInfo = (JetChangeInfo) info;
|
JetChangeInfo changeInfo = (JetChangeInfo) info;
|
||||||
PsiElement function = info.getMethod();
|
PsiElement function = info.getMethod();
|
||||||
PsiElement element = function != null ? function : changeInfo.getContext();
|
PsiElement element = function != null ? function : changeInfo.getContext();
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement((JetElement) element);
|
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||||
FunctionDescriptor oldDescriptor = changeInfo.getOldDescriptor();
|
FunctionDescriptor oldDescriptor = changeInfo.getOldDescriptor();
|
||||||
JetScope parametersScope = null;
|
JetScope parametersScope = null;
|
||||||
DeclarationDescriptor containingDeclaration = oldDescriptor != null ? oldDescriptor.getContainingDeclaration() : null;
|
DeclarationDescriptor containingDeclaration = oldDescriptor != null ? oldDescriptor.getContainingDeclaration() : null;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.intellij.refactoring.changeSignature.ParameterInfo;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
@@ -30,7 +29,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
|||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -91,7 +90,7 @@ public class JetParameterInfo implements ParameterInfo {
|
|||||||
String inheritedParamName = inheritedParam.getName();
|
String inheritedParamName = inheritedParam.getName();
|
||||||
|
|
||||||
if (oldParam.getName().equals(inheritedParamName)) {
|
if (oldParam.getName().equals(inheritedParamName)) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(inheritedJetFunction);
|
BindingContext bindingContext = ResolvePackage.analyze(inheritedJetFunction);
|
||||||
JetScope parametersScope = JetChangeSignatureUsageProcessor.getFunctionBodyScope(inheritedJetFunction, bindingContext);
|
JetScope parametersScope = JetChangeSignatureUsageProcessor.getFunctionBodyScope(inheritedJetFunction, bindingContext);
|
||||||
|
|
||||||
if (parametersScope != null && parametersScope.getLocalVariable(Name.identifier(name)) == null)
|
if (parametersScope != null && parametersScope.getLocalVariable(Name.identifier(name)) == null)
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,6 @@ import org.jetbrains.jet.utils.DFS
|
|||||||
import org.jetbrains.jet.utils.DFS.*
|
import org.jetbrains.jet.utils.DFS.*
|
||||||
import com.intellij.refactoring.util.RefactoringUIUtil
|
import com.intellij.refactoring.util.RefactoringUIUtil
|
||||||
import com.intellij.util.containers.MultiMap
|
import com.intellij.util.containers.MultiMap
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors
|
import org.jetbrains.jet.lang.diagnostics.Errors
|
||||||
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.Status
|
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.Status
|
||||||
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.ErrorMessage
|
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.ErrorMessage
|
||||||
@@ -67,6 +66,7 @@ import org.jetbrains.jet.plugin.refactoring.extractFunction.OutputValueBoxer.AsL
|
|||||||
import org.jetbrains.jet.plugin.refactoring.getContextForContainingDeclarationBody
|
import org.jetbrains.jet.plugin.refactoring.getContextForContainingDeclarationBody
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.findModuleDescriptor
|
import org.jetbrains.jet.plugin.caches.resolve.findModuleDescriptor
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
private val DEFAULT_FUNCTION_NAME = "myFun"
|
private val DEFAULT_FUNCTION_NAME = "myFun"
|
||||||
private val DEFAULT_RETURN_TYPE = KotlinBuiltIns.getInstance().getUnitType()
|
private val DEFAULT_RETURN_TYPE = KotlinBuiltIns.getInstance().getUnitType()
|
||||||
@@ -776,7 +776,7 @@ fun ExtractableCodeDescriptor.validate(): ExtractableCodeDescriptorWithConflicts
|
|||||||
val result = generateDeclaration(ExtractionGeneratorOptions(inTempFile = true))
|
val result = generateDeclaration(ExtractionGeneratorOptions(inTempFile = true))
|
||||||
|
|
||||||
val valueParameterList = (result.declaration as? JetNamedFunction)?.getValueParameterList()
|
val valueParameterList = (result.declaration as? JetNamedFunction)?.getValueParameterList()
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(result.declaration.getGeneratedBlockBody())
|
val bindingContext = result.declaration.getGeneratedBlockBody().analyze()
|
||||||
|
|
||||||
for ((originalOffset, resolveResult) in extractionData.refOffsetToDeclaration) {
|
for ((originalOffset, resolveResult) in extractionData.refOffsetToDeclaration) {
|
||||||
if (resolveResult.declaration.isInsideOf(extractionData.originalElements)) continue
|
if (resolveResult.declaration.isInsideOf(extractionData.originalElements)) continue
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ import org.jetbrains.jet.plugin.JetLanguage;
|
|||||||
import org.jetbrains.jet.plugin.caches.resolve.ResolutionFacade;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolutionFacade;
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -231,7 +230,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(initializer);
|
BindingContext context = ResolvePackage.analyze(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;
|
||||||
@@ -343,7 +342,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static String getTypeArgumentsStringForCall(@NotNull JetExpression initializer) {
|
private static String getTypeArgumentsStringForCall(@NotNull JetExpression initializer) {
|
||||||
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(initializer);
|
BindingContext context = ResolvePackage.analyze(initializer);
|
||||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCall(initializer, context);
|
ResolvedCall<?> call = CallUtilPackage.getResolvedCall(initializer, context);
|
||||||
if (call == null) return null;
|
if (call == null) return null;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext
|
|||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||||
import com.intellij.psi.PsiNamedElement
|
import com.intellij.psi.PsiNamedElement
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer
|
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||||
import com.intellij.openapi.util.text.StringUtil
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
@@ -299,7 +298,7 @@ public fun chooseContainerElement<T>(
|
|||||||
|
|
||||||
private fun JetElement.renderDeclaration(): String? {
|
private fun JetElement.renderDeclaration(): String? {
|
||||||
val name = renderName()
|
val name = renderName()
|
||||||
val descriptor = AnalyzerFacadeWithCache.getContextForElement(this)[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
|
val descriptor = this.analyze()[BindingContext.DECLARATION_TO_DESCRIPTOR, this]
|
||||||
val params = (descriptor as? FunctionDescriptor)?.let { descriptor ->
|
val params = (descriptor as? FunctionDescriptor)?.let { descriptor ->
|
||||||
descriptor.getValueParameters()
|
descriptor.getValueParameters()
|
||||||
.map { DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it.getType()) }
|
.map { DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it.getType()) }
|
||||||
|
|||||||
-4
@@ -21,12 +21,8 @@ import com.intellij.usageView.UsageInfo
|
|||||||
import com.intellij.psi.PsiClass
|
import com.intellij.psi.PsiClass
|
||||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getQualifiedElementSelector
|
import org.jetbrains.jet.lang.psi.psiUtil.getQualifiedElementSelector
|
||||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||||
import java.util.Collections
|
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
|
|||||||
+2
-2
@@ -33,7 +33,6 @@ import com.intellij.usageView.UsageInfo
|
|||||||
import com.intellij.refactoring.listeners.RefactoringElementListener
|
import com.intellij.refactoring.listeners.RefactoringElementListener
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.jetbrains.jet.lexer.JetTokens
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
||||||
import com.intellij.openapi.ui.Messages
|
import com.intellij.openapi.ui.Messages
|
||||||
@@ -42,6 +41,7 @@ import org.jetbrains.jet.asJava.namedUnwrappedElement
|
|||||||
import org.jetbrains.jet.lang.resolve.OverrideResolver
|
import org.jetbrains.jet.lang.resolve.OverrideResolver
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.jet.plugin.util.application.runReadAction
|
import org.jetbrains.jet.plugin.util.application.runReadAction
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
|
public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
|
||||||
override fun canProcessElement(element: PsiElement): Boolean = element.namedUnwrappedElement is JetProperty
|
override fun canProcessElement(element: PsiElement): Boolean = element.namedUnwrappedElement is JetProperty
|
||||||
@@ -170,7 +170,7 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
|
|||||||
|
|
||||||
private fun findDeepestOverriddenProperty(jetProperty: JetProperty): JetProperty? {
|
private fun findDeepestOverriddenProperty(jetProperty: JetProperty): JetProperty? {
|
||||||
if (jetProperty.getModifierList()?.hasModifier(JetTokens.OVERRIDE_KEYWORD) == true) {
|
if (jetProperty.getModifierList()?.hasModifier(JetTokens.OVERRIDE_KEYWORD) == true) {
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(jetProperty)
|
val bindingContext = jetProperty.analyze()
|
||||||
val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, jetProperty]
|
val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, jetProperty]
|
||||||
|
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
|
|||||||
+2
-6
@@ -16,25 +16,21 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.plugin.refactoring.safeDelete
|
package org.jetbrains.jet.plugin.refactoring.safeDelete
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import com.intellij.psi.PsiMethod
|
import com.intellij.psi.PsiMethod
|
||||||
import com.intellij.psi.PsiParameter
|
import com.intellij.psi.PsiParameter
|
||||||
import com.intellij.psi.PsiReference
|
import com.intellij.psi.PsiReference
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
|
||||||
import com.intellij.refactoring.safeDelete.JavaSafeDeleteDelegate
|
import com.intellij.refactoring.safeDelete.JavaSafeDeleteDelegate
|
||||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo
|
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo
|
||||||
import com.intellij.usageView.UsageInfo
|
import com.intellij.usageView.UsageInfo
|
||||||
import org.jetbrains.jet.asJava.unwrapped
|
import org.jetbrains.jet.asJava.unwrapped
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.jet.lang.psi.*
|
import org.jetbrains.jet.lang.psi.*
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.plugin.references.JetReference
|
import org.jetbrains.jet.plugin.references.JetReference
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.parameterIndex
|
import org.jetbrains.jet.lang.psi.psiUtil.parameterIndex
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate {
|
public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate {
|
||||||
override fun createUsageInfoForParameter(
|
override fun createUsageInfoForParameter(
|
||||||
@@ -50,7 +46,7 @@ public class KotlinJavaSafeDeleteDelegate : JavaSafeDeleteDelegate {
|
|||||||
val calleeExpression = callExpression.getCalleeExpression()
|
val calleeExpression = callExpression.getCalleeExpression()
|
||||||
if (!(calleeExpression is JetReferenceExpression && calleeExpression.isAncestor(element))) return
|
if (!(calleeExpression is JetReferenceExpression && calleeExpression.isAncestor(element))) return
|
||||||
|
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element)
|
val bindingContext = element.analyze()
|
||||||
|
|
||||||
val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, calleeExpression)
|
val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, calleeExpression)
|
||||||
if (descriptor == null) return
|
if (descriptor == null) return
|
||||||
|
|||||||
+6
-3
@@ -36,10 +36,13 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.plugin.JetBundle;
|
import org.jetbrains.jet.plugin.JetBundle;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil;
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil;
|
||||||
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
@@ -90,7 +93,7 @@ class KotlinOverridingDialog extends DialogWrapper {
|
|||||||
private static String formatElement(PsiElement element) {
|
private static String formatElement(PsiElement element) {
|
||||||
element = JetPsiUtil.ascendIfPropertyAccessor(element);
|
element = JetPsiUtil.ascendIfPropertyAccessor(element);
|
||||||
if (element instanceof JetNamedFunction || element instanceof JetProperty) {
|
if (element instanceof JetNamedFunction || element instanceof JetProperty) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement((JetElement) element);
|
BindingContext bindingContext = ResolvePackage.analyze((JetElement) element);
|
||||||
|
|
||||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||||
if (declarationDescriptor instanceof CallableMemberDescriptor) {
|
if (declarationDescriptor instanceof CallableMemberDescriptor) {
|
||||||
|
|||||||
+2
-2
@@ -39,12 +39,12 @@ import org.jetbrains.jet.lang.psi.*
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.lexer.JetTokens
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
import org.jetbrains.jet.plugin.JetBundle
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringUtil
|
||||||
import org.jetbrains.jet.plugin.references.JetReference
|
import org.jetbrains.jet.plugin.references.JetReference
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||||
import org.jetbrains.jet.lang.psi.psiUtil.deleteElementAndCleanParent
|
import org.jetbrains.jet.lang.psi.psiUtil.deleteElementAndCleanParent
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||||
override fun handlesElement(element: PsiElement): Boolean = element.canDeleteElement()
|
override fun handlesElement(element: PsiElement): Boolean = element.canDeleteElement()
|
||||||
@@ -208,7 +208,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
|||||||
val modifierList = jetClass.getModifierList()
|
val modifierList = jetClass.getModifierList()
|
||||||
if (modifierList != null && modifierList.hasModifier(JetTokens.ABSTRACT_KEYWORD)) return null
|
if (modifierList != null && modifierList.hasModifier(JetTokens.ABSTRACT_KEYWORD)) return null
|
||||||
|
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(element as JetElement)
|
val bindingContext = (element as JetElement).analyze()
|
||||||
|
|
||||||
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element)
|
||||||
if (declarationDescriptor !is CallableMemberDescriptor) return null
|
if (declarationDescriptor !is CallableMemberDescriptor) return null
|
||||||
|
|||||||
+2
-3
@@ -17,10 +17,9 @@
|
|||||||
package org.jetbrains.jet.plugin.refactoring.safeDelete
|
package org.jetbrains.jet.plugin.refactoring.safeDelete
|
||||||
|
|
||||||
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo
|
import com.intellij.refactoring.safeDelete.usageInfo.SafeDeleteReferenceSimpleDeleteUsageInfo
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.jet.lang.psi.*
|
import org.jetbrains.jet.lang.psi.*
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public class SafeDeleteImportDirectiveUsageInfo(
|
public class SafeDeleteImportDirectiveUsageInfo(
|
||||||
importDirective: JetImportDirective, declaration: JetDeclaration
|
importDirective: JetImportDirective, declaration: JetDeclaration
|
||||||
@@ -39,7 +38,7 @@ fun JetImportDirective.isSafeToDelete(declaration: JetDeclaration): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (importReference != null) {
|
if (importReference != null) {
|
||||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(importReference)
|
val bindingContext = importReference.analyze()
|
||||||
val referenceDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, importReference)
|
val referenceDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, importReference)
|
||||||
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
|
val declarationDescriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
|
||||||
return referenceDescriptor == declarationDescriptor
|
return referenceDescriptor == declarationDescriptor
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
|||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.plugin.MainFunctionDetector;
|
import org.jetbrains.jet.plugin.MainFunctionDetector;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.stubindex.JetTopLevelFunctionsFqnNameIndex;
|
import org.jetbrains.jet.plugin.stubindex.JetTopLevelFunctionsFqnNameIndex;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -271,7 +271,7 @@ public class JetRunConfiguration extends ModuleBasedConfiguration<RunConfigurati
|
|||||||
Collection<JetNamedFunction> mainFunctions = JetTopLevelFunctionsFqnNameIndex.getInstance().get(
|
Collection<JetNamedFunction> mainFunctions = JetTopLevelFunctionsFqnNameIndex.getInstance().get(
|
||||||
mainFunFqName, module.getProject(), module.getModuleRuntimeScope(true));
|
mainFunFqName, module.getProject(), module.getModuleRuntimeScope(true));
|
||||||
for (JetNamedFunction function : mainFunctions) {
|
for (JetNamedFunction function : mainFunctions) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(function);
|
BindingContext bindingContext = ResolvePackage.analyze(function);
|
||||||
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(bindingContext);
|
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(bindingContext);
|
||||||
if (mainFunctionDetector.isMain(function)) {
|
if (mainFunctionDetector.isMain(function)) {
|
||||||
return function;
|
return function;
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
package org.jetbrains.jet.completion
|
package org.jetbrains.jet.completion
|
||||||
|
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
|
||||||
import org.jetbrains.jet.lang.psi.JetFile
|
import org.jetbrains.jet.lang.psi.JetFile
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression
|
import org.jetbrains.jet.lang.psi.JetExpression
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import org.jetbrains.jet.plugin.completion.renderDataFlowValue
|
import org.jetbrains.jet.plugin.completion.renderDataFlowValue
|
||||||
@@ -30,6 +28,7 @@ import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
|
|||||||
import com.intellij.testFramework.LightProjectDescriptor
|
import com.intellij.testFramework.LightProjectDescriptor
|
||||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getDataFlowInfo
|
||||||
|
import org.jetbrains.jet.plugin.caches.resolve.analyze
|
||||||
|
|
||||||
public abstract class AbstractDataFlowValueRenderingTest: JetLightCodeInsightFixtureTestCase() {
|
public abstract class AbstractDataFlowValueRenderingTest: JetLightCodeInsightFixtureTestCase() {
|
||||||
override fun getTestDataPath() : String {
|
override fun getTestDataPath() : String {
|
||||||
@@ -47,7 +46,7 @@ public abstract class AbstractDataFlowValueRenderingTest: JetLightCodeInsightFix
|
|||||||
val jetFile = fixture.getFile() as JetFile
|
val jetFile = fixture.getFile() as JetFile
|
||||||
val element = jetFile.findElementAt(fixture.getCaretOffset())
|
val element = jetFile.findElementAt(fixture.getCaretOffset())
|
||||||
val expression = PsiTreeUtil.getParentOfType(element, javaClass<JetExpression>())!!
|
val expression = PsiTreeUtil.getParentOfType(element, javaClass<JetExpression>())!!
|
||||||
val info = AnalyzerFacadeWithCache.getContextForElement(expression).getDataFlowInfo(expression)
|
val info = expression.analyze().getDataFlowInfo(expression)
|
||||||
|
|
||||||
val allValues = (info.getCompleteTypeInfo().keySet() + info.getCompleteNullabilityInfo().keySet()).toSet()
|
val allValues = (info.getCompleteTypeInfo().keySet() + info.getCompleteNullabilityInfo().keySet()).toSet()
|
||||||
val actual = allValues.map { renderDataFlowValue(it) }.filterNotNull().sort().makeString("\n")
|
val actual = allValues.map { renderDataFlowValue(it) }.filterNotNull().sort().makeString("\n")
|
||||||
|
|||||||
+1
-2
@@ -33,7 +33,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
|||||||
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase;
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -112,7 +111,7 @@ public abstract class AbstractInsertImportOnPasteTest extends JetLightCodeInsigh
|
|||||||
DebugInfoUtil.markDebugAnnotations(file, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
|
DebugInfoUtil.markDebugAnnotations(file, bindingContext, new DebugInfoUtil.DebugInfoReporter() {
|
||||||
@Override
|
@Override
|
||||||
public void preProcessReference(@NotNull JetReferenceExpression expression) {
|
public void preProcessReference(@NotNull JetReferenceExpression expression) {
|
||||||
AnalyzerFacadeWithCache.getContextForElement(expression);
|
ResolvePackage.analyze(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-3
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.resolve.dataClassUtils.DataClassUtilsPackage;
|
|||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.plugin.KotlinCodeInsightTestCase;
|
import org.jetbrains.jet.plugin.KotlinCodeInsightTestCase;
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache;
|
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||||
import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle;
|
import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -235,7 +235,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(method);
|
BindingContext context = ResolvePackage.analyze(method);
|
||||||
|
|
||||||
ChangeSignaturePackage
|
ChangeSignaturePackage
|
||||||
.runChangeSignature(getProject(), changeInfo.getOldDescriptor(), empty, context, method, "test");
|
.runChangeSignature(getProject(), changeInfo.getOldDescriptor(), empty, context, method, "test");
|
||||||
@@ -298,7 +298,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
|||||||
JetElement element = (JetElement) new JetChangeSignatureHandler().findTargetMember(file, editor);
|
JetElement element = (JetElement) new JetChangeSignatureHandler().findTargetMember(file, editor);
|
||||||
assertNotNull("Target element is null", element);
|
assertNotNull("Target element is null", element);
|
||||||
|
|
||||||
BindingContext bindingContext = AnalyzerFacadeWithCache.getContextForElement(element);
|
BindingContext bindingContext = ResolvePackage.analyze(element);
|
||||||
PsiElement context = file.findElementAt(editor.getCaretModel().getOffset());
|
PsiElement context = file.findElementAt(editor.getCaretModel().getOffset());
|
||||||
assertNotNull(context);
|
assertNotNull(context);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user