Rename: analyzeWithDeclarations --> analyzeWithContent()
This commit is contained in:
+1
-1
@@ -162,7 +162,7 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
|
||||
|
||||
override fun analyze(element: KtElement) = bindingContext
|
||||
|
||||
override fun analyzeWithDeclarations(element: KtClassOrObject) = bindingContext
|
||||
override fun analyzeWithContent(element: KtClassOrObject) = bindingContext
|
||||
|
||||
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
val filesForFacade = findFilesForFacade(facadeFqName, scope)
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ abstract class LightClassGenerationSupport {
|
||||
|
||||
abstract fun analyze(element: KtElement): BindingContext
|
||||
|
||||
abstract fun analyzeWithDeclarations(element: KtClassOrObject): BindingContext
|
||||
abstract fun analyzeWithContent(element: KtClassOrObject): BindingContext
|
||||
|
||||
abstract fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass>
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class KtLightPsiReferenceList (
|
||||
override val kotlinOrigin by lazyPub {
|
||||
val superTypeList = this@KtLightPsiReferenceList.kotlinOrigin ?: return@lazyPub null
|
||||
val fqNameToFind = clsDelegate.qualifiedName ?: return@lazyPub null
|
||||
val context = LightClassGenerationSupport.getInstance(project).analyzeWithDeclarations(superTypeList.parent as KtClassOrObject)
|
||||
val context = LightClassGenerationSupport.getInstance(project).analyzeWithContent(superTypeList.parent as KtClassOrObject)
|
||||
superTypeList.entries.firstOrNull {
|
||||
val referencedType = context[BindingContext.TYPE, it.typeReference]
|
||||
referencedType?.constructor?.declarationDescriptor?.fqNameUnsafe?.asString() == fqNameToFind
|
||||
|
||||
@@ -78,18 +78,18 @@ fun KtFile.resolveImportReference(fqName: FqName): Collection<DeclarationDescrip
|
||||
}
|
||||
|
||||
|
||||
// This and next function are used for 'normal' element analysis
|
||||
// This and next functions are used for 'normal' element analysis
|
||||
// This analysis *should* provide all information extractable from this KtElement except:
|
||||
// - it does not analyze bodies of functions
|
||||
// - it does not analyze content of classes
|
||||
// - it does not analyze initializers / accessors for member / top-level properties
|
||||
// - for declarations, it does not analyze their bodies
|
||||
// - for classes, it does not analyze their content
|
||||
// - for member / top-level properties, it does not analyze initializers / accessors
|
||||
// This information includes related descriptors, resolved calls (but not inside body, see above!)
|
||||
// and many other binding context slices.
|
||||
// Normally, the function is used on local declarations or statements / expressions
|
||||
// Any usage on non-local declaration is a bit suspicious,
|
||||
// consider replacing it with resolveToDescriptorIfAny and
|
||||
// remember that body / content is not analyzed;
|
||||
// if it's necessary, use analyzeWithContent() / analyzeWithDeclarations().
|
||||
// if it's necessary, use analyzeWithContent()
|
||||
//
|
||||
// If you need diagnostics in result context, use BodyResolveMode.PARTIAL_WITH_DIAGNOSTICS.
|
||||
// BodyResolveMode.FULL analyzes all statements on the level of KtElement and above.
|
||||
@@ -114,13 +114,13 @@ fun KtDeclaration.analyzeWithContent(): BindingContext =
|
||||
|
||||
// This function is used to make full analysis of declaration container.
|
||||
// All its declarations, including their content (see above), are analyzed.
|
||||
inline fun <reified T> T.analyzeWithDeclarations(): BindingContext where T : KtDeclarationContainer, T : KtElement =
|
||||
inline fun <reified T> T.analyzeWithContent(): BindingContext where T : KtDeclarationContainer, T : KtElement =
|
||||
getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
|
||||
|
||||
// NB: for statements / expressions, usually should be replaced with analyze(),
|
||||
// for declarations, analyzeWithContent() will do what you want.
|
||||
@Deprecated(
|
||||
"Use either analyzeWithContent() or analyzeWithDeclarations() instead, or use just analyze()",
|
||||
"Use analyzeWithContent() instead, or use just analyze()",
|
||||
ReplaceWith("analyze()")
|
||||
)
|
||||
fun KtElement.analyzeFully(): BindingContext = getResolutionFacade().analyzeFullyAndGetResult(listOf(this)).bindingContext
|
||||
|
||||
+1
-1
@@ -237,7 +237,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
|
||||
override fun analyze(element: KtElement) = element.analyze(BodyResolveMode.PARTIAL)
|
||||
|
||||
override fun analyzeWithDeclarations(element: KtClassOrObject) = element.analyzeWithDeclarations()
|
||||
override fun analyzeWithContent(element: KtClassOrObject) = element.analyzeWithContent()
|
||||
|
||||
override fun getFacadeNames(packageFqName: FqName, scope: GlobalSearchScope): Collection<String> {
|
||||
val facadeFilesInPackage = runReadAction {
|
||||
|
||||
@@ -40,7 +40,7 @@ class DebugInfoAnnotator : Annotator {
|
||||
|
||||
if (element is KtFile && element !is KtCodeFragment) {
|
||||
try {
|
||||
val bindingContext = element.analyzeWithDeclarations()
|
||||
val bindingContext = element.analyzeWithContent()
|
||||
DebugInfoUtil.markDebugAnnotations(element, bindingContext, object : DebugInfoUtil.DebugInfoReporter() {
|
||||
override fun reportElementWithErrorType(expression: KtReferenceExpression) {
|
||||
holder.createErrorAnnotation(expression, "[DEBUG] Resolved to error element").textAttributes =
|
||||
|
||||
+3
-5
@@ -19,10 +19,8 @@ package org.jetbrains.kotlin.idea.highlighter
|
||||
import com.intellij.lang.annotation.AnnotationHolder
|
||||
import com.intellij.lang.annotation.Annotator
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.asJava.getJvmSignatureDiagnostics
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getModuleInfo
|
||||
import org.jetbrains.kotlin.asJava.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.*
|
||||
import org.jetbrains.kotlin.idea.project.TargetPlatformDetector
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
@@ -39,7 +37,7 @@ class DuplicateJvmSignatureAnnotator : Annotator {
|
||||
|
||||
val otherDiagnostics = when (element) {
|
||||
is KtDeclaration -> element.analyzeWithContent()
|
||||
is KtFile -> element.analyzeWithDeclarations()
|
||||
is KtFile -> element.analyzeWithContent()
|
||||
else -> throw AssertionError("DuplicateJvmSignatureAnnotator: should not get here! Element: ${element.text}")
|
||||
}.diagnostics
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.util.ExceptionUtil
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*
|
||||
@@ -154,7 +154,7 @@ private fun KtFile.findContextElement(): KtElement? {
|
||||
private var PsiElement.DEBUG_SMART_CAST: PsiElement? by CopyablePsiUserDataProperty(Key.create("DEBUG_SMART_CAST"))
|
||||
|
||||
private fun KtCodeFragment.markSmartCasts() {
|
||||
val bindingContext = runInReadActionWithWriteActionPriorityWithPCE { analyzeWithDeclarations() }
|
||||
val bindingContext = runInReadActionWithWriteActionPriorityWithPCE { analyzeWithContent() }
|
||||
val factory = KtPsiFactory(project)
|
||||
|
||||
getContentElement()?.forEachDescendantOfType<KtExpression> { expression ->
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import com.intellij.psi.PsiFile
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
|
||||
@@ -22,7 +22,7 @@ object DirectiveBasedActionUtils {
|
||||
|
||||
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ERROR:").sorted()
|
||||
|
||||
val actualErrors = file.analyzeWithDeclarations().diagnostics
|
||||
val actualErrors = file.analyzeWithContent().diagnostics
|
||||
.filter { it.getSeverity() == Severity.ERROR }
|
||||
.map { DefaultErrorMessages.render(it).replace("\n", "<br>") }
|
||||
.sorted()
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.intellij.util.Consumer
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.LibraryModificationTracker
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider
|
||||
import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
@@ -73,7 +73,7 @@ fun Module.configureAs(kind: ModuleKind) {
|
||||
}
|
||||
|
||||
fun KtFile.dumpTextWithErrors(): String {
|
||||
val diagnostics = analyzeWithDeclarations().diagnostics
|
||||
val diagnostics = analyzeWithContent().diagnostics
|
||||
val errors = diagnostics.filter { it.severity == Severity.ERROR }
|
||||
if (errors.isEmpty()) return text
|
||||
val header = errors.map { "// ERROR: " + DefaultErrorMessages.render(it).replace('\n', ' ') }.joinToString("\n", postfix = "\n")
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.core.CollectingNameValidator
|
||||
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
|
||||
@@ -98,7 +98,7 @@ class KotlinGenerateEqualsAndHashcodeAction : KotlinGenerateMemberActionBase<Kot
|
||||
override fun prepareMembersInfo(klass: KtClassOrObject, project: Project, editor: Editor?): Info? {
|
||||
if (klass !is KtClass) throw AssertionError("Not a class: ${klass.getElementTextWithContext()}")
|
||||
|
||||
val context = klass.analyzeWithDeclarations()
|
||||
val context = klass.analyzeWithContent()
|
||||
val classDescriptor = context.get(BindingContext.CLASS, klass) ?: return null
|
||||
|
||||
val equalsDescriptor = classDescriptor.findDeclaredEquals(false)
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.core.CollectingNameValidator
|
||||
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
|
||||
@@ -104,7 +104,7 @@ class KotlinGenerateSecondaryConstructorAction : KotlinGenerateMemberActionBase<
|
||||
}
|
||||
|
||||
override fun prepareMembersInfo(klass: KtClassOrObject, project: Project, editor: Editor?): Info? {
|
||||
val context = klass.analyzeWithDeclarations()
|
||||
val context = klass.analyzeWithContent()
|
||||
val classDescriptor = context.get(BindingContext.CLASS, klass) ?: return null
|
||||
val superConstructors = chooseSuperConstructors(klass, classDescriptor).map { it.descriptor as ConstructorDescriptor }
|
||||
val propertiesToInitialize = choosePropertiesToInitialize(klass, context).map { it.descriptor as PropertyDescriptor }
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
|
||||
import org.jetbrains.kotlin.idea.core.insertMembersAfter
|
||||
@@ -132,7 +132,7 @@ class KotlinGenerateToStringAction : KotlinGenerateMemberActionBase<KotlinGenera
|
||||
override fun prepareMembersInfo(klass: KtClassOrObject, project: Project, editor: Editor?): Info? {
|
||||
if (klass !is KtClass) throw AssertionError("Not a class: ${klass.getElementTextWithContext()}")
|
||||
|
||||
val context = klass.analyzeWithDeclarations()
|
||||
val context = klass.analyzeWithContent()
|
||||
val classDescriptor = context.get(BindingContext.CLASS, klass) ?: return null
|
||||
|
||||
classDescriptor.findDeclaredToString(false)?.let {
|
||||
|
||||
@@ -32,7 +32,7 @@ class CopyAsDiagnosticTestAction : AnAction() {
|
||||
val psiFile = e.getData(CommonDataKeys.PSI_FILE)
|
||||
assert(editor != null && psiFile != null)
|
||||
|
||||
val bindingContext = (psiFile as KtFile).analyzeWithDeclarations()
|
||||
val bindingContext = (psiFile as KtFile).analyzeWithContent()
|
||||
|
||||
val diagnostics = CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(
|
||||
bindingContext, psiFile, false, null, null, false
|
||||
|
||||
@@ -44,7 +44,7 @@ class PlainTextPasteImportResolver(val dataForConversion: DataForConversion, val
|
||||
private val importList = file.importList!!
|
||||
private val psiElementFactory = PsiElementFactory.SERVICE.getInstance(project)
|
||||
|
||||
private val bindingContext by lazy { targetFile.analyzeWithDeclarations() }
|
||||
private val bindingContext by lazy { targetFile.analyzeWithContent() }
|
||||
private val resolutionFacade = targetFile.getResolutionFacade()
|
||||
|
||||
private val shortNameCache = PsiShortNamesCache.getInstance(project)
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.addRemoveModifier.addModifier
|
||||
@@ -50,7 +50,7 @@ class AddVarianceModifierInspection : AbstractKotlinInspection() {
|
||||
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
|
||||
return classOrObjectVisitor { klass ->
|
||||
val context = klass.analyzeWithDeclarations()
|
||||
val context = klass.analyzeWithContent()
|
||||
for (typeParameter in klass.typeParameters) {
|
||||
if (typeParameter.variance != Variance.INVARIANT) continue
|
||||
val parameterDescriptor =
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.intentions
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
||||
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -59,7 +59,7 @@ class ConvertSecondaryConstructorToPrimaryIntention : SelfTargetingRangeIntentio
|
||||
val klass = element.containingClassOrObject ?: return null
|
||||
if (klass.hasPrimaryConstructor()) return null
|
||||
|
||||
val context = klass.analyzeWithDeclarations()
|
||||
val context = klass.analyzeWithContent()
|
||||
val classDescriptor = context[BindingContext.CLASS, klass] ?: return null
|
||||
val elementDescriptor = context[BindingContext.CONSTRUCTOR, element] ?: return null
|
||||
|
||||
@@ -154,7 +154,7 @@ class ConvertSecondaryConstructorToPrimaryIntention : SelfTargetingRangeIntentio
|
||||
|
||||
override fun applyTo(element: KtSecondaryConstructor, editor: Editor?) {
|
||||
val klass = element.containingClassOrObject as? KtClass ?: return
|
||||
val context = klass.analyzeWithDeclarations()
|
||||
val context = klass.analyzeWithContent()
|
||||
val factory = KtPsiFactory(klass)
|
||||
val constructorCommentSaver = CommentSaver(element)
|
||||
val constructorInClass = klass.createPrimaryConstructorIfAbsent()
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
|
||||
@@ -61,7 +61,7 @@ class MapPlatformClassToKotlinFix(
|
||||
override fun getFamilyName() = "Change to Kotlin class"
|
||||
|
||||
public override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val bindingContext = file.analyzeWithDeclarations()
|
||||
val bindingContext = file.analyzeWithContent()
|
||||
|
||||
val imports = ArrayList<KtImportDirective>()
|
||||
val usages = ArrayList<KtUserType>()
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
|
||||
import org.jetbrains.kotlin.idea.util.approximateWithResolvableType
|
||||
@@ -51,7 +51,7 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() {
|
||||
override fun doCreateActions(diagnostic: Diagnostic): List<IntentionAction> {
|
||||
val actions = LinkedList<IntentionAction>()
|
||||
|
||||
val context = (diagnostic.psiFile as KtFile).analyzeWithDeclarations()
|
||||
val context = (diagnostic.psiFile as KtFile).analyzeWithContent()
|
||||
|
||||
val diagnosticElement = diagnostic.psiElement
|
||||
if (diagnosticElement !is KtExpression) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideMemberChooserObject
|
||||
import org.jetbrains.kotlin.idea.core.overrideImplement.generateMember
|
||||
@@ -44,7 +44,7 @@ class SpecifyOverrideExplicitlyFix(
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
|
||||
val element = element ?: return
|
||||
val context = element.analyzeWithDeclarations()
|
||||
val context = element.analyzeWithContent()
|
||||
val delegatedDescriptor = context.diagnostics.forElement(element).mapNotNull {
|
||||
if (it.factory == Errors.DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE)
|
||||
Errors.DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE.cast(it).a
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
||||
import org.jetbrains.kotlin.checkers.AbstractPsiCheckerTest
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
|
||||
import org.jetbrains.kotlin.idea.completion.test.AbstractJvmBasicCompletionTest
|
||||
import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils
|
||||
@@ -127,7 +127,7 @@ private fun JavaCodeInsightTestFixture.configureByCodeFragment(filePath: String)
|
||||
if (typeStr != null) {
|
||||
file.putCopyableUserData(KtCodeFragment.RUNTIME_TYPE_EVALUATOR, {
|
||||
val codeFragment = KtPsiFactory(project).createBlockCodeFragment("val xxx: $typeStr", PsiTreeUtil.getParentOfType(elementAt, KtElement::class.java))
|
||||
val context = codeFragment.analyzeWithDeclarations()
|
||||
val context = codeFragment.analyzeWithContent()
|
||||
val typeReference: KtTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().firstChild, KtTypeReference::class.java)!!
|
||||
context[BindingContext.TYPE, typeReference]
|
||||
})
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithDeclarations
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||
import org.jetbrains.kotlin.idea.test.KotlinJdkAndLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
@@ -45,7 +45,7 @@ class NoErrorsInStdlibTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
val psiFile = psiManager.findFile(file)
|
||||
if (psiFile is KtFile) {
|
||||
hasAtLeastOneFile = true
|
||||
val bindingContext = psiFile.analyzeWithDeclarations()
|
||||
val bindingContext = psiFile.analyzeWithContent()
|
||||
val errors = bindingContext.diagnostics.all().filter { it.severity == Severity.ERROR }
|
||||
|
||||
if (errors.isNotEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user