Converted JetPsiUtil.getElementTextWithContext() to Kotlin extension function.
This commit is contained in:
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
|
|||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
@@ -321,7 +322,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (specifier instanceof JetDelegatorToSuperClass || specifier instanceof JetDelegatorToSuperCall) {
|
if (specifier instanceof JetDelegatorToSuperClass || specifier instanceof JetDelegatorToSuperCall) {
|
||||||
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
assert superType != null :
|
assert superType != null :
|
||||||
String.format("No type recorded for \n---\n%s\n---\n", JetPsiUtil.getElementTextWithContext(specifier));
|
String.format("No type recorded for \n---\n%s\n---\n", PsiUtilPackage.getElementTextWithContext(specifier));
|
||||||
|
|
||||||
ClassifierDescriptor classifierDescriptor = superType.getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifierDescriptor = superType.getConstructor().getDeclarationDescriptor();
|
||||||
if (!(classifierDescriptor instanceof ClassDescriptor)) continue;
|
if (!(classifierDescriptor instanceof ClassDescriptor)) continue;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
|||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
import org.jetbrains.kotlin.resolve.DescriptorFactory;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
@@ -373,7 +374,7 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException("Delegated property not found in its parent: " + JetPsiUtil.getElementTextWithContext(property));
|
throw new IllegalStateException("Delegated property not found in its parent: " + PsiUtilPackage.getElementTextWithContext(property));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,13 @@ import org.jetbrains.kotlin.codegen.SamType;
|
|||||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||||
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
import org.jetbrains.kotlin.codegen.when.WhenByEnumsMapping;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice;
|
import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice;
|
||||||
import org.jetbrains.kotlin.util.slicedMap.Slices;
|
import org.jetbrains.kotlin.util.slicedMap.Slices;
|
||||||
@@ -197,7 +196,7 @@ public class CodegenBinding {
|
|||||||
public static void registerClassNameForScript(@NotNull BindingTrace trace, @NotNull JetScript script, @NotNull Type asmType) {
|
public static void registerClassNameForScript(@NotNull BindingTrace trace, @NotNull JetScript script, @NotNull Type asmType) {
|
||||||
ScriptDescriptor descriptor = trace.getBindingContext().get(SCRIPT, script);
|
ScriptDescriptor descriptor = trace.getBindingContext().get(SCRIPT, script);
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
throw new IllegalStateException("Script descriptor is not found for PSI: " + JetPsiUtil.getElementTextWithContext(script));
|
throw new IllegalStateException("Script descriptor is not found for PSI: " + PsiUtilPackage.getElementTextWithContext(script));
|
||||||
}
|
}
|
||||||
|
|
||||||
String simpleName = asmType.getInternalName().substring(asmType.getInternalName().lastIndexOf('/') + 1);
|
String simpleName = asmType.getInternalName().substring(asmType.getInternalName().lastIndexOf('/') + 1);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.intellij.psi.util.PsiTreeUtil;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.psi.stubs.KotlinFunctionStub;
|
import org.jetbrains.kotlin.psi.stubs.KotlinFunctionStub;
|
||||||
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
|
import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes;
|
||||||
import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage;
|
import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage;
|
||||||
@@ -80,7 +81,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<KotlinFuncti
|
|||||||
@NotNull
|
@NotNull
|
||||||
public PsiElement getFunToken() {
|
public PsiElement getFunToken() {
|
||||||
PsiElement element = findChildByType(JetTokens.FUN_KEYWORD);
|
PsiElement element = findChildByType(JetTokens.FUN_KEYWORD);
|
||||||
assert element != null : "'fun' must be present: " + JetPsiUtil.getElementTextWithContext(this);
|
assert element != null : "'fun' must be present: " + PsiUtilPackage.getElementTextWithContext(this);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -778,33 +778,6 @@ public class JetPsiUtil {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static String getElementTextWithContext(@NotNull PsiElement element) {
|
|
||||||
if (element instanceof PsiFile) {
|
|
||||||
return element.getContainingFile().getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find parent for element among file children
|
|
||||||
PsiElement inFileParent = PsiTreeUtil.findFirstParent(element, new Condition<PsiElement>() {
|
|
||||||
@Override
|
|
||||||
public boolean value(PsiElement parentCandidate) {
|
|
||||||
return parentCandidate != null && parentCandidate.getParent() instanceof PsiFile;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert inFileParent != null : "For non-file element we should always be able to find parent in file children";
|
|
||||||
|
|
||||||
int startContextOffset = inFileParent.getTextRange().getStartOffset();
|
|
||||||
int elementContextOffset = element.getTextRange().getStartOffset();
|
|
||||||
|
|
||||||
int inFileParentOffset = elementContextOffset - startContextOffset;
|
|
||||||
|
|
||||||
return new StringBuilder(inFileParent.getText())
|
|
||||||
.insert(inFileParentOffset, "<caret>")
|
|
||||||
.insert(0, String.format("File name: %s\n", element.getContainingFile().getName()))
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static JetModifierList replaceModifierList(@NotNull JetModifierListOwner owner, @Nullable JetModifierList modifierList) {
|
public static JetModifierList replaceModifierList(@NotNull JetModifierListOwner owner, @Nullable JetModifierList modifierList) {
|
||||||
JetModifierList oldModifierList = owner.getModifierList();
|
JetModifierList oldModifierList = owner.getModifierList();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ object JetQualifiedExpressionImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fun JetQualifiedExpression.getReceiverExpression(): JetExpression {
|
public fun JetQualifiedExpression.getReceiverExpression(): JetExpression {
|
||||||
return getExpression(false) ?: throw AssertionError("No receiver found: ${JetPsiUtil.getElementTextWithContext(this)}")
|
return getExpression(false) ?: throw AssertionError("No receiver found: ${getElementTextWithContext()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun JetQualifiedExpression.getSelectorExpression(): JetExpression? {
|
public fun JetQualifiedExpression.getSelectorExpression(): JetExpression? {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub
|
|||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
|
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.openapi.util.Condition
|
||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import com.intellij.psi.PsiComment
|
import com.intellij.psi.PsiComment
|
||||||
import org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke
|
import org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke
|
||||||
@@ -491,3 +492,23 @@ fun JetNamedDeclaration.getValueParameterList(): JetParameterList? {
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun PsiElement.getElementTextWithContext(): String {
|
||||||
|
if (this is PsiFile) {
|
||||||
|
return getContainingFile().getText()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find parent for element among file children
|
||||||
|
val topLevelElement = PsiTreeUtil.findFirstParent(this, { it.getParent() is PsiFile }) ?:
|
||||||
|
throw AssertionError("For non-file element we should always be able to find parent in file children")
|
||||||
|
|
||||||
|
val startContextOffset = topLevelElement.getTextRange().getStartOffset()
|
||||||
|
val elementContextOffset = getTextRange().getStartOffset()
|
||||||
|
|
||||||
|
val inFileParentOffset = elementContextOffset - startContextOffset
|
||||||
|
|
||||||
|
return StringBuilder(topLevelElement.getText())
|
||||||
|
.insert(inFileParentOffset, "<caret>")
|
||||||
|
.insert(0, "File name: ${getContainingFile().getName()}\n")
|
||||||
|
.toString()
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.lexer.JetTokens;
|
|||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant;
|
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant;
|
||||||
@@ -1109,7 +1110,7 @@ public class DescriptorResolver {
|
|||||||
if (TypesPackage.isFlexible(type) && !TypesPackage.isDynamic(type)) {
|
if (TypesPackage.isFlexible(type) && !TypesPackage.isDynamic(type)) {
|
||||||
assert jetTypeArguments.size() == 2
|
assert jetTypeArguments.size() == 2
|
||||||
: "Flexible type cannot be denoted in Kotlin otherwise than as ft<T1, T2>, but was: "
|
: "Flexible type cannot be denoted in Kotlin otherwise than as ft<T1, T2>, but was: "
|
||||||
+ JetPsiUtil.getElementTextWithContext(typeReference);
|
+ PsiUtilPackage.getElementTextWithContext(typeReference);
|
||||||
// it's really ft<Foo, Bar>
|
// it's really ft<Foo, Bar>
|
||||||
Flexibility flexibility = TypesPackage.flexibility(type);
|
Flexibility flexibility = TypesPackage.flexibility(type);
|
||||||
checkBounds(jetTypeArguments.get(0), flexibility.getLowerBound(), trace);
|
checkBounds(jetTypeArguments.get(0), flexibility.getLowerBound(), trace);
|
||||||
|
|||||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.lazy;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor;
|
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||||
@@ -69,7 +70,7 @@ public class DeclarationScopeProviderImpl implements DeclarationScopeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalStateException("Don't call this method for local declarations: " + jetDeclaration + "\n" +
|
throw new IllegalStateException("Don't call this method for local declarations: " + jetDeclaration + "\n" +
|
||||||
JetPsiUtil.getElementTextWithContext(jetDeclaration));
|
PsiUtilPackage.getElementTextWithContext(jetDeclaration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+4
-3
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.*;
|
|||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
@@ -77,7 +78,7 @@ public class LazyDeclarationResolver {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("Could not find a classifier for %s.\n" +
|
String.format("Could not find a classifier for %s.\n" +
|
||||||
"Found descriptor: %s (%s).\n",
|
"Found descriptor: %s (%s).\n",
|
||||||
JetPsiUtil.getElementTextWithContext(classOrObject),
|
PsiUtilPackage.getElementTextWithContext(classOrObject),
|
||||||
scopeDescriptor != null ? DescriptorRenderer.DEBUG_TEXT.render(scopeDescriptor) : "null",
|
scopeDescriptor != null ? DescriptorRenderer.DEBUG_TEXT.render(scopeDescriptor) : "null",
|
||||||
scopeDescriptor != null ? (scopeDescriptor.getContainingDeclaration().getClass()) : null));
|
scopeDescriptor != null ? (scopeDescriptor.getContainingDeclaration().getClass()) : null));
|
||||||
}
|
}
|
||||||
@@ -202,12 +203,12 @@ public class LazyDeclarationResolver {
|
|||||||
@Override
|
@Override
|
||||||
public DeclarationDescriptor visitJetElement(@NotNull JetElement element, Void data) {
|
public DeclarationDescriptor visitJetElement(@NotNull JetElement element, Void data) {
|
||||||
throw new IllegalArgumentException("Unsupported declaration type: " + element + " " +
|
throw new IllegalArgumentException("Unsupported declaration type: " + element + " " +
|
||||||
JetPsiUtil.getElementTextWithContext(element));
|
PsiUtilPackage.getElementTextWithContext(element));
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new IllegalStateException("No descriptor resolved for " + declaration + ":\n" +
|
throw new IllegalStateException("No descriptor resolved for " + declaration + ":\n" +
|
||||||
JetPsiUtil.getElementTextWithContext(declaration));
|
PsiUtilPackage.getElementTextWithContext(declaration));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.kotlin.idea.JetLanguage;
|
import org.jetbrains.kotlin.idea.JetLanguage;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -123,7 +124,7 @@ public abstract class KotlinWrappingLightClass extends AbstractLightClass implem
|
|||||||
JetDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(field);
|
JetDeclaration declaration = ClsWrapperStubPsiFactory.getOriginalDeclaration(field);
|
||||||
if (declaration instanceof JetEnumEntry) {
|
if (declaration instanceof JetEnumEntry) {
|
||||||
assert field instanceof PsiEnumConstant : "Field delegate should be an enum constant (" + field.getName() + "):\n" +
|
assert field instanceof PsiEnumConstant : "Field delegate should be an enum constant (" + field.getName() + "):\n" +
|
||||||
JetPsiUtil.getElementTextWithContext(declaration);
|
PsiUtilPackage.getElementTextWithContext(declaration);
|
||||||
JetEnumEntry enumEntry = (JetEnumEntry) declaration;
|
JetEnumEntry enumEntry = (JetEnumEntry) declaration;
|
||||||
PsiEnumConstant enumConstant = (PsiEnumConstant) field;
|
PsiEnumConstant enumConstant = (PsiEnumConstant) field;
|
||||||
FqName enumConstantFqName = new FqName(getFqName().asString() + "." + enumEntry.getName());
|
FqName enumConstantFqName = new FqName(getFqName().asString() + "." + enumEntry.getName());
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.di.InjectorForBodyResolve
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||||
@@ -159,7 +160,7 @@ public abstract class ElementResolver protected(
|
|||||||
packageRefAdditionalResolve(resolveSession, trace, resolveElement)
|
packageRefAdditionalResolve(resolveSession, trace, resolveElement)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error("Invalid type of the topmost parent: $resolveElement\n${JetPsiUtil.getElementTextWithContext(resolveElement)}")
|
error("Invalid type of the topmost parent: $resolveElement\n${resolveElement.getElementTextWithContext()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,7 +361,7 @@ public abstract class ElementResolver protected(
|
|||||||
|
|
||||||
val classDescriptor = resolveSession.resolveToDescriptor(klass) as ClassDescriptor
|
val classDescriptor = resolveSession.resolveToDescriptor(klass) as ClassDescriptor
|
||||||
val constructorDescriptor = classDescriptor.getUnsubstitutedPrimaryConstructor()
|
val constructorDescriptor = classDescriptor.getUnsubstitutedPrimaryConstructor()
|
||||||
?: error("Can't get primary constructor for descriptor '$classDescriptor' in from class '${JetPsiUtil.getElementTextWithContext(klass)}'")
|
?: error("Can't get primary constructor for descriptor '$classDescriptor' in from class '${klass.getElementTextWithContext()}'")
|
||||||
|
|
||||||
val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter)
|
val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter)
|
||||||
bodyResolver.resolveConstructorParameterDefaultValuesAndAnnotations(createEmptyContext(resolveSession), trace, klass, constructorDescriptor, scope)
|
bodyResolver.resolveConstructorParameterDefaultValuesAndAnnotations(createEmptyContext(resolveSession), trace, klass, constructorDescriptor, scope)
|
||||||
|
|||||||
+2
-2
@@ -49,11 +49,11 @@ import org.jetbrains.kotlin.idea.stubindex.JetFullClassNameIndex;
|
|||||||
import org.jetbrains.kotlin.idea.stubindex.JetTopLevelClassByPackageIndex;
|
import org.jetbrains.kotlin.idea.stubindex.JetTopLevelClassByPackageIndex;
|
||||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil;
|
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil;
|
||||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
|
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
|
||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||||
@@ -105,7 +105,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, classOrObject);
|
ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, classOrObject);
|
||||||
|
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
LOG.warn("No class descriptor in context for class: " + JetPsiUtil.getElementTextWithContext(classOrObject));
|
LOG.warn("No class descriptor in context for class: " + PsiUtilPackage.getElementTextWithContext(classOrObject));
|
||||||
return new LightClassConstructionContext(bindingContext, session.getModuleDescriptor());
|
return new LightClassConstructionContext(bindingContext, session.getModuleDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.ReadOnly;
|
|||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
import org.jetbrains.kotlin.resolve.BindingContextUtils;
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
|
||||||
@@ -83,7 +84,7 @@ public class ResolveSessionForBodies implements KotlinCodeAnalyzer {
|
|||||||
BindingContext context = resolveElementCache.resolveToElement(declaration, BodyResolveMode.FULL);
|
BindingContext context = resolveElementCache.resolveToElement(declaration, BodyResolveMode.FULL);
|
||||||
return BindingContextUtils.getNotNull(context, BindingContext.DECLARATION_TO_DESCRIPTOR, declaration,
|
return BindingContextUtils.getNotNull(context, BindingContext.DECLARATION_TO_DESCRIPTOR, declaration,
|
||||||
"Descriptor wasn't found for declaration " + declaration.toString() + "\n" +
|
"Descriptor wasn't found for declaration " + declaration.toString() + "\n" +
|
||||||
JetPsiUtil.getElementTextWithContext(declaration));
|
PsiUtilPackage.getElementTextWithContext(declaration));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences.Options
|
|||||||
import org.jetbrains.kotlin.idea.imports.*
|
import org.jetbrains.kotlin.idea.imports.*
|
||||||
import org.jetbrains.kotlin.resolve.*
|
import org.jetbrains.kotlin.resolve.*
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
|
|
||||||
public class ShortenReferences(val options: (JetElement) -> Options = { Options.DEFAULT }) {
|
public class ShortenReferences(val options: (JetElement) -> Options = { Options.DEFAULT }) {
|
||||||
public data class Options(
|
public data class Options(
|
||||||
@@ -402,7 +403,7 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun qualifier(element: JetThisExpression): JetElement =
|
override fun qualifier(element: JetThisExpression): JetElement =
|
||||||
throw AssertionError("Qualifier requested: ${JetPsiUtil.getElementTextWithContext(element)}")
|
throw AssertionError("Qualifier requested: ${element.getElementTextWithContext()}")
|
||||||
|
|
||||||
override fun shortenElement(element: JetThisExpression): JetElement {
|
override fun shortenElement(element: JetThisExpression): JetElement {
|
||||||
return element.replace(simpleThis) as JetElement
|
return element.replace(simpleThis) as JetElement
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.intellij.psi.PsiDirectory
|
|||||||
import com.intellij.openapi.roots.JavaProjectRootsUtil
|
import com.intellij.openapi.roots.JavaProjectRootsUtil
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import com.intellij.refactoring.util.ConflictsUtil
|
import com.intellij.refactoring.util.ConflictsUtil
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getPackage
|
|
||||||
import com.intellij.psi.PsiFileFactory
|
import com.intellij.psi.PsiFileFactory
|
||||||
import org.jetbrains.kotlin.idea.JetFileType
|
import org.jetbrains.kotlin.idea.JetFileType
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
@@ -56,7 +55,6 @@ import com.intellij.openapi.ui.popup.JBPopupAdapter
|
|||||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent
|
import com.intellij.openapi.ui.popup.LightweightWindowEvent
|
||||||
import com.intellij.psi.PsiDocumentManager
|
import com.intellij.psi.PsiDocumentManager
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
|
||||||
import com.intellij.psi.PsiNamedElement
|
import com.intellij.psi.PsiNamedElement
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
@@ -68,10 +66,8 @@ import com.intellij.psi.PsiMethod
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
|
||||||
import com.intellij.psi.PsiPackage
|
import com.intellij.psi.PsiPackage
|
||||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
|
||||||
import com.intellij.refactoring.util.RefactoringUIUtil
|
import com.intellij.refactoring.util.RefactoringUIUtil
|
||||||
import com.intellij.psi.PsiMember
|
import com.intellij.psi.PsiMember
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMemberDescriptor
|
import org.jetbrains.kotlin.idea.caches.resolve.getJavaMemberDescriptor
|
||||||
@@ -98,6 +94,7 @@ import com.intellij.lang.java.JavaLanguage
|
|||||||
import com.intellij.psi.PsiClass
|
import com.intellij.psi.PsiClass
|
||||||
import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils
|
import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils
|
||||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
|
|
||||||
fun <T: Any> PsiElement.getAndRemoveCopyableUserData(key: Key<T>): T? {
|
fun <T: Any> PsiElement.getAndRemoveCopyableUserData(key: Key<T>): T? {
|
||||||
val data = getCopyableUserData(key)
|
val data = getCopyableUserData(key)
|
||||||
@@ -483,7 +480,7 @@ private fun copyTypeParameters<T: PsiTypeParameterListOwner>(
|
|||||||
|
|
||||||
public fun createJavaMethod(function: JetFunction, targetClass: PsiClass): PsiMethod {
|
public fun createJavaMethod(function: JetFunction, targetClass: PsiClass): PsiMethod {
|
||||||
val template = LightClassUtil.getLightClassMethod(function)
|
val template = LightClassUtil.getLightClassMethod(function)
|
||||||
?: throw AssertionError("Can't generate light method: ${JetPsiUtil.getElementTextWithContext(function)}")
|
?: throw AssertionError("Can't generate light method: ${function.getElementTextWithContext()}")
|
||||||
return createJavaMethod(template, targetClass)
|
return createJavaMethod(template, targetClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +525,7 @@ public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMeth
|
|||||||
|
|
||||||
fun createJavaField(property: JetProperty, targetClass: PsiClass): PsiField {
|
fun createJavaField(property: JetProperty, targetClass: PsiClass): PsiField {
|
||||||
val template = LightClassUtil.getLightClassPropertyMethods(property).getGetter()
|
val template = LightClassUtil.getLightClassPropertyMethods(property).getGetter()
|
||||||
?: throw AssertionError("Can't generate light method: ${JetPsiUtil.getElementTextWithContext(property)}")
|
?: throw AssertionError("Can't generate light method: ${property.getElementTextWithContext()}")
|
||||||
|
|
||||||
val factory = PsiElementFactory.SERVICE.getInstance(template.getProject())
|
val factory = PsiElementFactory.SERVICE.getInstance(template.getProject())
|
||||||
val field = targetClass.add(factory.createField(property.getName(), template.getReturnType())) as PsiField
|
val field = targetClass.add(factory.createField(property.getName(), template.getReturnType())) as PsiField
|
||||||
@@ -554,12 +551,12 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember {
|
|||||||
ClassKind.TRAIT -> factory.createInterface(klass.getName())
|
ClassKind.TRAIT -> factory.createInterface(klass.getName())
|
||||||
ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(klass.getName())
|
ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(klass.getName())
|
||||||
ClassKind.ENUM_CLASS -> factory.createEnum(klass.getName())
|
ClassKind.ENUM_CLASS -> factory.createEnum(klass.getName())
|
||||||
else -> throw AssertionError("Unexpected class kind: ${JetPsiUtil.getElementTextWithContext(klass)}")
|
else -> throw AssertionError("Unexpected class kind: ${klass.getElementTextWithContext()}")
|
||||||
}
|
}
|
||||||
val javaClass = targetClass.add(javaClassToAdd) as PsiClass
|
val javaClass = targetClass.add(javaClassToAdd) as PsiClass
|
||||||
|
|
||||||
val template = LightClassUtil.getPsiClass(klass)
|
val template = LightClassUtil.getPsiClass(klass)
|
||||||
?: throw AssertionError("Can't generate light class: ${JetPsiUtil.getElementTextWithContext(klass)}")
|
?: throw AssertionError("Can't generate light class: ${klass.getElementTextWithContext()}")
|
||||||
|
|
||||||
copyModifierListItems(template.getModifierList(), javaClass.getModifierList())
|
copyModifierListItems(template.getModifierList(), javaClass.getModifierList())
|
||||||
if (template.isInterface()) {
|
if (template.isInterface()) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.psi.JetDeclaration
|
|||||||
import org.jetbrains.kotlin.psi.JetElement
|
import org.jetbrains.kotlin.psi.JetElement
|
||||||
import org.jetbrains.kotlin.psi.JetPsiUtil
|
import org.jetbrains.kotlin.psi.JetPsiUtil
|
||||||
import org.jetbrains.kotlin.psi.JetReferenceExpression
|
import org.jetbrains.kotlin.psi.JetReferenceExpression
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRendererBuilder
|
import org.jetbrains.kotlin.renderer.DescriptorRendererBuilder
|
||||||
@@ -122,7 +123,7 @@ public class KotlinQuickDocumentationProvider : AbstractDocumentationProvider()
|
|||||||
val declarationDescriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]
|
val declarationDescriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]
|
||||||
|
|
||||||
if (declarationDescriptor == null) {
|
if (declarationDescriptor == null) {
|
||||||
LOG.info("Failed to find descriptor for declaration " + JetPsiUtil.getElementTextWithContext(declaration))
|
LOG.info("Failed to find descriptor for declaration " + declaration.getElementTextWithContext())
|
||||||
return "No documentation available"
|
return "No documentation available"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction
|
|||||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineAnalyzerExtension
|
import org.jetbrains.kotlin.resolve.inline.InlineAnalyzerExtension
|
||||||
@@ -335,7 +336,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult
|
|||||||
val elementAtForLibraryFile = getElementToCreateTypeMapperForLibraryFile(notPositionedElement)
|
val elementAtForLibraryFile = getElementToCreateTypeMapperForLibraryFile(notPositionedElement)
|
||||||
assert(elementAtForLibraryFile != null) {
|
assert(elementAtForLibraryFile != null) {
|
||||||
"Couldn't find element at breakpoint for library file " + file.getName() +
|
"Couldn't find element at breakpoint for library file " + file.getName() +
|
||||||
(if (notPositionedElement == null) "" else ", notPositionedElement = " + JetPsiUtil.getElementTextWithContext(notPositionedElement))
|
(if (notPositionedElement == null) "" else ", notPositionedElement = " + notPositionedElement.getElementTextWithContext())
|
||||||
}
|
}
|
||||||
return PositionedElement(findPackagePartInternalNameForLibraryFile(elementAtForLibraryFile!!), elementAtForLibraryFile)
|
return PositionedElement(findPackagePartInternalNameForLibraryFile(elementAtForLibraryFile!!), elementAtForLibraryFile)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
|
||||||
import com.intellij.util.indexing.FileBasedIndex
|
import com.intellij.util.indexing.FileBasedIndex
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
|
|
||||||
private val LOG = Logger.getInstance("org.jetbrains.kotlin.idea.debugger")
|
private val LOG = Logger.getInstance("org.jetbrains.kotlin.idea.debugger")
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ private fun render(desc: DeclarationDescriptor) = DescriptorRenderer.FQ_NAMES_IN
|
|||||||
|
|
||||||
private fun reportError(element: JetElement, descriptor: CallableDescriptor?) {
|
private fun reportError(element: JetElement, descriptor: CallableDescriptor?) {
|
||||||
LOG.error("Couldn't calculate class name for element in library scope:\n" +
|
LOG.error("Couldn't calculate class name for element in library scope:\n" +
|
||||||
JetPsiUtil.getElementTextWithContext(element) +
|
element.getElementTextWithContext() +
|
||||||
if (descriptor != null) "\ndescriptor = ${render(descriptor)}" else ""
|
if (descriptor != null) "\ndescriptor = ${render(descriptor)}" else ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.*
|
|||||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||||
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
import org.jetbrains.kotlin.utils.singletonOrEmptyList
|
||||||
import java.awt.GridBagConstraints
|
import java.awt.GridBagConstraints
|
||||||
@@ -166,7 +167,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
var zeroOccurrences = true
|
var zeroOccurrences = true
|
||||||
|
|
||||||
for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) {
|
for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) {
|
||||||
assert(name != null) { "Name is null for " + JetPsiUtil.getElementTextWithContext(declaration) }
|
assert(name != null) { "Name is null for " + declaration.getElementTextWithContext() }
|
||||||
when (psiSearchHelper.isCheapEnoughToSearch(name, useScope, null, null)) {
|
when (psiSearchHelper.isCheapEnoughToSearch(name, useScope, null, null)) {
|
||||||
ZERO_OCCURRENCES -> {} // go on, check other names
|
ZERO_OCCURRENCES -> {} // go on, check other names
|
||||||
FEW_OCCURRENCES -> zeroOccurrences = false
|
FEW_OCCURRENCES -> zeroOccurrences = false
|
||||||
@@ -195,8 +196,8 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
val query = UsagesSearch.search(request)
|
val query = UsagesSearch.search(request)
|
||||||
|
|
||||||
return !query.forEach(Processor {
|
return !query.forEach(Processor {
|
||||||
assert(it != null, { "Found reference is null, was looking for: " + JetPsiUtil.getElementTextWithContext(declaration) +
|
assert(it != null, { "Found reference is null, was looking for: " + declaration.getElementTextWithContext() +
|
||||||
" findAll(): " + query.findAll().map { it?.getElement()?.let{ JetPsiUtil.getElementTextWithContext(it) } } })
|
" findAll(): " + query.findAll().map { it?.getElement()?.let{ it.getElementTextWithContext() } } })
|
||||||
declaration.isAncestor(it.getElement())
|
declaration.isAncestor(it.getElement())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage;
|
|||||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||||
@@ -195,7 +196,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
|||||||
@NotNull JetType exprType
|
@NotNull JetType exprType
|
||||||
) {
|
) {
|
||||||
assert !exprType.isError() : "Unexpected error type, should have been checked before: "
|
assert !exprType.isError() : "Unexpected error type, should have been checked before: "
|
||||||
+ JetPsiUtil.getElementTextWithContext(declaration) + ", type = " + exprType;
|
+ PsiUtilPackage.getElementTextWithContext(declaration) + ", type = " + exprType;
|
||||||
|
|
||||||
Expression expression = createTypeExpressionForTemplate(exprType);
|
Expression expression = createTypeExpressionForTemplate(exprType);
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
|||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage;
|
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage;
|
||||||
@@ -62,7 +63,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
|||||||
if (element instanceof JetFunctionLiteral) {
|
if (element instanceof JetFunctionLiteral) {
|
||||||
JetFunctionLiteralExpression functionLiteralExpression = PsiTreeUtil.getParentOfType(element, JetFunctionLiteralExpression.class);
|
JetFunctionLiteralExpression functionLiteralExpression = PsiTreeUtil.getParentOfType(element, JetFunctionLiteralExpression.class);
|
||||||
assert functionLiteralExpression != null : "FunctionLiteral outside any FunctionLiteralExpression: " +
|
assert functionLiteralExpression != null : "FunctionLiteral outside any FunctionLiteralExpression: " +
|
||||||
JetPsiUtil.getElementTextWithContext(element);
|
PsiUtilPackage.getElementTextWithContext(element);
|
||||||
changeFunctionLiteralReturnTypeFix = new ChangeFunctionLiteralReturnTypeFix(functionLiteralExpression, type);
|
changeFunctionLiteralReturnTypeFix = new ChangeFunctionLiteralReturnTypeFix(functionLiteralExpression, type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
|||||||
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
||||||
import org.jetbrains.kotlin.name.FqName;
|
import org.jetbrains.kotlin.name.FqName;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
@@ -144,7 +145,7 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
|||||||
DeclarationDescriptor descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
|
DeclarationDescriptor descriptor = context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property);
|
||||||
if (!(descriptor instanceof PropertyDescriptor)) {
|
if (!(descriptor instanceof PropertyDescriptor)) {
|
||||||
// Probably can happen in incomplete code.
|
// Probably can happen in incomplete code.
|
||||||
LOG.error("Property descriptor is expected: " + JetPsiUtil.getElementTextWithContext(property));
|
LOG.error("Property descriptor is expected: " + PsiUtilPackage.getElementTextWithContext(property));
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic;
|
|||||||
import org.jetbrains.kotlin.idea.JetBundle;
|
import org.jetbrains.kotlin.idea.JetBundle;
|
||||||
import org.jetbrains.kotlin.psi.JetFile;
|
import org.jetbrains.kotlin.psi.JetFile;
|
||||||
import org.jetbrains.kotlin.psi.JetParameter;
|
import org.jetbrains.kotlin.psi.JetParameter;
|
||||||
import org.jetbrains.kotlin.psi.JetPsiUtil;
|
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
|
||||||
|
|
||||||
public class RemoveValVarFromParameterFix extends JetIntentionAction<JetParameter> {
|
public class RemoveValVarFromParameterFix extends JetIntentionAction<JetParameter> {
|
||||||
private final String varOrVal;
|
private final String varOrVal;
|
||||||
@@ -36,7 +36,7 @@ public class RemoveValVarFromParameterFix extends JetIntentionAction<JetParamete
|
|||||||
public RemoveValVarFromParameterFix(@NotNull JetParameter element) {
|
public RemoveValVarFromParameterFix(@NotNull JetParameter element) {
|
||||||
super(element);
|
super(element);
|
||||||
ASTNode valOrVarNode = element.getValOrVarNode();
|
ASTNode valOrVarNode = element.getValOrVarNode();
|
||||||
assert valOrVarNode != null : "Val or var node not found for " + JetPsiUtil.getElementTextWithContext(element);
|
assert valOrVarNode != null : "Val or var node not found for " + PsiUtilPackage.getElementTextWithContext(element);
|
||||||
varOrVal = valOrVarNode.getText();
|
varOrVal = valOrVarNode.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-5
@@ -53,10 +53,7 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
|||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameters
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
@@ -681,7 +678,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
val templateName = when (func) {
|
val templateName = when (func) {
|
||||||
is JetSecondaryConstructor -> TEMPLATE_FROM_USAGE_SECONDARY_CONSTRUCTOR_BODY
|
is JetSecondaryConstructor -> TEMPLATE_FROM_USAGE_SECONDARY_CONSTRUCTOR_BODY
|
||||||
is JetNamedFunction -> TEMPLATE_FROM_USAGE_FUNCTION_BODY
|
is JetNamedFunction -> TEMPLATE_FROM_USAGE_FUNCTION_BODY
|
||||||
else -> throw AssertionError("Unexpected declaration: " + JetPsiUtil.getElementTextWithContext(func))
|
else -> throw AssertionError("Unexpected declaration: " + func.getElementTextWithContext())
|
||||||
}
|
}
|
||||||
val fileTemplate = FileTemplateManager.getInstance()!!.getCodeTemplate(templateName)
|
val fileTemplate = FileTemplateManager.getInstance()!!.getCodeTemplate(templateName)
|
||||||
val properties = Properties()
|
val properties = Properties()
|
||||||
|
|||||||
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.CreateFromUsageFixBase
|
|||||||
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.*
|
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.*
|
||||||
import org.jetbrains.kotlin.idea.util.application.executeCommand
|
import org.jetbrains.kotlin.idea.util.application.executeCommand
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.HashSet
|
import java.util.HashSet
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ public class CreateCallableFromUsageFix(
|
|||||||
isExtension: Boolean) : this(originalExpression, Collections.singletonList(callableInfo), isExtension) { }
|
isExtension: Boolean) : this(originalExpression, Collections.singletonList(callableInfo), isExtension) { }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
assert (callableInfos.isNotEmpty()) { "No CallableInfos: ${JetPsiUtil.getElementTextWithContext(originalElement)}" }
|
assert (callableInfos.isNotEmpty()) { "No CallableInfos: ${originalElement.getElementTextWithContext()}" }
|
||||||
if (callableInfos.size() > 1) {
|
if (callableInfos.size() > 1) {
|
||||||
val receiverSet = callableInfos.mapTo(HashSet<TypeInfo>()) { it.receiverTypeInfo }
|
val receiverSet = callableInfos.mapTo(HashSet<TypeInfo>()) { it.receiverTypeInfo }
|
||||||
if (receiverSet.size() > 1) throw AssertionError("All functions must have common receiver: $receiverSet")
|
if (receiverSet.size() > 1) throw AssertionError("All functions must have common receiver: $receiverSet")
|
||||||
|
|||||||
+3
-6
@@ -61,10 +61,7 @@ import org.jetbrains.kotlin.idea.util.approximateWithResolvableType
|
|||||||
import org.jetbrains.kotlin.idea.util.isResolvableInScope
|
import org.jetbrains.kotlin.idea.util.isResolvableInScope
|
||||||
import org.jetbrains.kotlin.idea.util.makeNullable
|
import org.jetbrains.kotlin.idea.util.makeNullable
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isInsideOf
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
@@ -840,7 +837,7 @@ fun ExtractionData.performAnalysis(): AnalysisResult {
|
|||||||
|
|
||||||
val enclosingPseudocode = PseudocodeUtil.generatePseudocode(enclosingPseudocodeDeclaration, bindingContext)
|
val enclosingPseudocode = PseudocodeUtil.generatePseudocode(enclosingPseudocodeDeclaration, bindingContext)
|
||||||
val pseudocode = enclosingPseudocode.getPseudocodeByElement(pseudocodeDeclaration)
|
val pseudocode = enclosingPseudocode.getPseudocodeByElement(pseudocodeDeclaration)
|
||||||
?: throw AssertionError("Can't find nested pseudocode for element: ${JetPsiUtil.getElementTextWithContext(pseudocodeDeclaration)}")
|
?: throw AssertionError("Can't find nested pseudocode for element: ${pseudocodeDeclaration.getElementTextWithContext()}")
|
||||||
val localInstructions = getLocalInstructions(pseudocode)
|
val localInstructions = getLocalInstructions(pseudocode)
|
||||||
|
|
||||||
val modifiedVarDescriptorsWithExpressions = localInstructions.getModifiedVarDescriptors(bindingContext)
|
val modifiedVarDescriptorsWithExpressions = localInstructions.getModifiedVarDescriptors(bindingContext)
|
||||||
@@ -949,7 +946,7 @@ private fun JetNamedDeclaration.getGeneratedBody() =
|
|||||||
call?.getFunctionLiteralArguments()?.singleOrNull()?.getFunctionLiteral()?.getBodyExpression()
|
call?.getFunctionLiteralArguments()?.singleOrNull()?.getFunctionLiteral()?.getBodyExpression()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ?: throw AssertionError("Couldn't get block body for this declaration: ${JetPsiUtil.getElementTextWithContext(this)}")
|
} ?: throw AssertionError("Couldn't get block body for this declaration: ${getElementTextWithContext()}")
|
||||||
|
|
||||||
fun ExtractableCodeDescriptor.validate(): ExtractableCodeDescriptorWithConflicts {
|
fun ExtractableCodeDescriptor.validate(): ExtractableCodeDescriptorWithConflicts {
|
||||||
fun getDeclarationMessage(declaration: PsiNamedElement, messageKey: String, capitalize: Boolean = true): String {
|
fun getDeclarationMessage(declaration: PsiNamedElement, messageKey: String, capitalize: Boolean = true): String {
|
||||||
|
|||||||
+2
-1
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.psi.JetExpression
|
|||||||
import org.jetbrains.kotlin.psi.JetParameter
|
import org.jetbrains.kotlin.psi.JetParameter
|
||||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||||
import org.jetbrains.kotlin.psi.JetPsiUtil
|
import org.jetbrains.kotlin.psi.JetPsiUtil
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameterList
|
import org.jetbrains.kotlin.psi.psiUtil.getValueParameterList
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameters
|
import org.jetbrains.kotlin.psi.psiUtil.getValueParameters
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||||
@@ -159,7 +160,7 @@ public class KotlinInplaceParameterIntroducer(
|
|||||||
builder.append(")")
|
builder.append(")")
|
||||||
|
|
||||||
if (addedRange == null) {
|
if (addedRange == null) {
|
||||||
LOG.error("Added parameter not found: ${JetPsiUtil.getElementTextWithContext(callable)}")
|
LOG.error("Added parameter not found: ${callable.getElementTextWithContext()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
val document = previewer!!.getDocument()
|
val document = previewer!!.getDocument()
|
||||||
|
|||||||
+4
-9
@@ -49,12 +49,7 @@ import org.jetbrains.kotlin.idea.util.psi.patternMatching.JetPsiUnifier
|
|||||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange
|
import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange
|
||||||
import org.jetbrains.kotlin.idea.util.supertypes
|
import org.jetbrains.kotlin.idea.util.supertypes
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
|
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameterList
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameters
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils
|
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils
|
||||||
import org.jetbrains.kotlin.types.JetType
|
import org.jetbrains.kotlin.types.JetType
|
||||||
@@ -165,14 +160,14 @@ public open class KotlinIntroduceParameterHandler: KotlinIntroduceHandlerBase()
|
|||||||
is FunctionDescriptor -> descriptor : FunctionDescriptor
|
is FunctionDescriptor -> descriptor : FunctionDescriptor
|
||||||
is ClassDescriptor -> descriptor.getUnsubstitutedPrimaryConstructor()
|
is ClassDescriptor -> descriptor.getUnsubstitutedPrimaryConstructor()
|
||||||
else -> null
|
else -> null
|
||||||
} ?: throw AssertionError("Unexpected element type: ${JetPsiUtil.getElementTextWithContext(targetParent)}")
|
} ?: throw AssertionError("Unexpected element type: ${targetParent.getElementTextWithContext()}")
|
||||||
val parameterType = expressionType.approximateWithResolvableType(JetScopeUtils.getResolutionScope(targetParent, context), false)
|
val parameterType = expressionType.approximateWithResolvableType(JetScopeUtils.getResolutionScope(targetParent, context), false)
|
||||||
|
|
||||||
val body = when (targetParent) {
|
val body = when (targetParent) {
|
||||||
is JetFunction -> targetParent.getBodyExpression()
|
is JetFunction -> targetParent.getBodyExpression()
|
||||||
is JetClass -> targetParent.getBody()
|
is JetClass -> targetParent.getBody()
|
||||||
else -> null
|
else -> null
|
||||||
} ?: throw AssertionError("Body element is not found: ${JetPsiUtil.getElementTextWithContext(targetParent)}")
|
} ?: throw AssertionError("Body element is not found: ${targetParent.getElementTextWithContext()}")
|
||||||
val nameValidator = JetNameValidatorImpl(body, null, JetNameValidatorImpl.Target.PROPERTIES)
|
val nameValidator = JetNameValidatorImpl(body, null, JetNameValidatorImpl.Target.PROPERTIES)
|
||||||
val suggestedNames = linkedSetOf(*JetNameSuggester.suggestNames(parameterType, nameValidator, "p"))
|
val suggestedNames = linkedSetOf(*JetNameSuggester.suggestNames(parameterType, nameValidator, "p"))
|
||||||
|
|
||||||
@@ -228,7 +223,7 @@ public open class KotlinIntroduceParameterHandler: KotlinIntroduceHandlerBase()
|
|||||||
if (parameterList == null) {
|
if (parameterList == null) {
|
||||||
val klass = targetParent as? JetClass
|
val klass = targetParent as? JetClass
|
||||||
val anchor = klass?.getTypeParameterList() ?: klass?.getNameIdentifier()
|
val anchor = klass?.getTypeParameterList() ?: klass?.getNameIdentifier()
|
||||||
assert(anchor != null, "Invalid declaration: ${JetPsiUtil.getElementTextWithContext(targetParent)}")
|
assert(anchor != null, "Invalid declaration: ${targetParent.getElementTextWithContext()}")
|
||||||
|
|
||||||
val constructor = targetParent.addAfter(psiFactory.createPrimaryConstructor(), anchor) as JetPrimaryConstructor
|
val constructor = targetParent.addAfter(psiFactory.createPrimaryConstructor(), anchor) as JetPrimaryConstructor
|
||||||
constructor.getValueParameterList()!!
|
constructor.getValueParameterList()!!
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ public class KotlinInplacePropertyIntroducer(
|
|||||||
property, editor, project, title, JetExpression.EMPTY_ARRAY, null, false, property, false, doNotChangeVar, exprType, false
|
property, editor, project, title, JetExpression.EMPTY_ARRAY, null, false, property, false, doNotChangeVar, exprType, false
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
assert(availableTargets.isNotEmpty(), "No targets available: ${JetPsiUtil.getElementTextWithContext(property)}")
|
assert(availableTargets.isNotEmpty(), "No targets available: ${property.getElementTextWithContext()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
private var extractionResult = extractionResult
|
private var extractionResult = extractionResult
|
||||||
|
|||||||
+2
-1
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiErrorElement
|
|||||||
import org.jetbrains.kotlin.psi.JetPsiUtil
|
import org.jetbrains.kotlin.psi.JetPsiUtil
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import org.jetbrains.kotlin.idea.decompiler.JetClsFile
|
import org.jetbrains.kotlin.idea.decompiler.JetClsFile
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext
|
||||||
|
|
||||||
public abstract class AbstractDecompiledTextTest() : JetLightCodeInsightFixtureTestCase() {
|
public abstract class AbstractDecompiledTextTest() : JetLightCodeInsightFixtureTestCase() {
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ public abstract class AbstractDecompiledTextTest() : JetLightCodeInsightFixtureT
|
|||||||
private fun checkThatFileWasParsedCorrectly(clsFile: PsiFile) {
|
private fun checkThatFileWasParsedCorrectly(clsFile: PsiFile) {
|
||||||
clsFile.accept(object : PsiRecursiveElementVisitor() {
|
clsFile.accept(object : PsiRecursiveElementVisitor() {
|
||||||
override fun visitErrorElement(element: PsiErrorElement) {
|
override fun visitErrorElement(element: PsiErrorElement) {
|
||||||
fail("Decompiled file should not contain error elements!\n${JetPsiUtil.getElementTextWithContext(element)}")
|
fail("Decompiled file should not contain error elements!\n${element.getElementTextWithContext()}")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user