diff --git a/src/main/kotlin/platform/bukkit/BukkitModule.kt b/src/main/kotlin/platform/bukkit/BukkitModule.kt index 1a73b9488..e2c427e4c 100644 --- a/src/main/kotlin/platform/bukkit/BukkitModule.kt +++ b/src/main/kotlin/platform/bukkit/BukkitModule.kt @@ -92,7 +92,7 @@ class BukkitModule>(facet: MinecraftFacet, type: T chosenClass: PsiClass, chosenName: String, data: GenerationData?, - ): PsiMethod? { + ): PsiMethod { val bukkitData = data as BukkitGenerationData val method = generateBukkitStyleEventListenerMethod( @@ -101,7 +101,7 @@ class BukkitModule>(facet: MinecraftFacet, type: T project, BukkitConstants.HANDLER_ANNOTATION, bukkitData.isIgnoreCanceled, - ) ?: return null + ) if (bukkitData.eventPriority != "NORMAL") { val list = method.modifierList @@ -217,8 +217,8 @@ class BukkitModule>(facet: MinecraftFacet, type: T project: Project, annotationName: String, setIgnoreCancelled: Boolean, - ): PsiMethod? { - val newMethod = createVoidMethodWithParameterType(project, chosenName, chosenClass) ?: return null + ): PsiMethod { + val newMethod = createVoidMethodWithParameterType(project, chosenName, chosenClass) val modifierList = newMethod.modifierList val annotation = modifierList.addAnnotation(annotationName) diff --git a/src/main/kotlin/platform/forge/ForgeModule.kt b/src/main/kotlin/platform/forge/ForgeModule.kt index 02ebdce1b..35fb4b996 100644 --- a/src/main/kotlin/platform/forge/ForgeModule.kt +++ b/src/main/kotlin/platform/forge/ForgeModule.kt @@ -163,10 +163,10 @@ class ForgeModule internal constructor(facet: MinecraftFacet) : AbstractModule(f chosenClass: PsiClass, chosenName: String, data: GenerationData?, - ): PsiMethod? { + ): PsiMethod { val isFmlEvent = chosenClass.extendsOrImplements(ForgeConstants.FML_EVENT) - val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) ?: return null + val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) val modifierList = method.modifierList if (isFmlEvent) { diff --git a/src/main/kotlin/platform/mcp/inspections/EntityConstructorInspection.kt b/src/main/kotlin/platform/mcp/inspections/EntityConstructorInspection.kt deleted file mode 100644 index d465cf5c0..000000000 --- a/src/main/kotlin/platform/mcp/inspections/EntityConstructorInspection.kt +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Minecraft Development for IntelliJ - * - * https://mcdev.io/ - * - * Copyright (C) 2023 minecraft-dev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation, version 3.0 only. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.demonwav.mcdev.platform.mcp.inspections - -import com.demonwav.mcdev.facet.MinecraftFacet -import com.demonwav.mcdev.platform.mcp.McpModuleType -import com.demonwav.mcdev.platform.mcp.util.McpConstants -import com.demonwav.mcdev.platform.mixin.util.isMixin -import com.demonwav.mcdev.util.SemanticVersion -import com.demonwav.mcdev.util.extendsOrImplements -import com.intellij.openapi.module.ModuleUtilCore -import com.intellij.psi.PsiClass -import com.intellij.psi.PsiClassType -import com.intellij.psi.PsiTypeParameter -import com.siyeh.ig.BaseInspection -import com.siyeh.ig.BaseInspectionVisitor -import org.jetbrains.annotations.Nls - -class EntityConstructorInspection : BaseInspection() { - @Nls - override fun getDisplayName(): String { - return "MCP Entity class missing World constructor" - } - - override fun buildErrorString(vararg infos: Any): String { - return "All entities must have a constructor that takes one " + McpConstants.WORLD + " parameter." - } - - override fun buildVisitor(): BaseInspectionVisitor { - return object : BaseInspectionVisitor() { - override fun visitClass(aClass: PsiClass) { - if (aClass is PsiTypeParameter) { - return - } - - if (!aClass.extendsOrImplements(McpConstants.ENTITY)) { - return - } - - if (aClass.extendsOrImplements(McpConstants.ENTITY_FX)) { - return - } - - val module = ModuleUtilCore.findModuleForPsiElement(aClass) ?: return - val mcpModule = MinecraftFacet.getInstance(module, McpModuleType) ?: return - val mcVersion = mcpModule.getSettings().minecraftVersion - if (mcVersion == null || SemanticVersion.parse(mcVersion) > McpModuleType.MC_1_12_2) { - return - } - - if (aClass.isMixin) { - return - } - - val constructors = aClass.constructors - for (constructor in constructors) { - if (constructor.parameterList.parameters.size != 1) { - continue - } - - val parameter = constructor.parameterList.parameters[0] - val typeElement = parameter.typeElement ?: continue - - val type = typeElement.type as? PsiClassType ?: continue - - val resolve = type.resolve() ?: continue - - if (resolve.qualifiedName == null) { - continue - } - - if (resolve.qualifiedName == McpConstants.WORLD) { - return - } - } - - registerClassError(aClass) - } - } - } -} diff --git a/src/main/kotlin/platform/mcp/inspections/StackEmptyInspection.kt b/src/main/kotlin/platform/mcp/inspections/StackEmptyInspection.kt index 4b3cb7470..22693193d 100644 --- a/src/main/kotlin/platform/mcp/inspections/StackEmptyInspection.kt +++ b/src/main/kotlin/platform/mcp/inspections/StackEmptyInspection.kt @@ -32,7 +32,6 @@ import com.intellij.openapi.project.Project import com.intellij.psi.JavaPsiFacade import com.intellij.psi.JavaTokenType import com.intellij.psi.PsiBinaryExpression -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiExpression import com.intellij.psi.PsiField import com.intellij.psi.PsiReferenceExpression @@ -118,7 +117,7 @@ class StackEmptyInspection : BaseInspection() { } private fun isExpressionStack(expression: PsiExpression?): Boolean { - return (expression?.type as? PsiClassType)?.resolve()?.fullQualifiedName == STACK_FQ_NAME + return expression?.type?.equalsToText(STACK_FQ_NAME) == true } private fun isExpressionEmptyConstant(expression: PsiExpression?): Boolean { diff --git a/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt b/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt index d43efe728..7854d0967 100644 --- a/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt +++ b/src/main/kotlin/platform/mixin/config/inspection/ConfigValueInspection.kt @@ -40,7 +40,6 @@ import com.intellij.psi.CommonClassNames.JAVA_LANG_INTEGER import com.intellij.psi.CommonClassNames.JAVA_LANG_LONG import com.intellij.psi.CommonClassNames.JAVA_LANG_SHORT import com.intellij.psi.CommonClassNames.JAVA_LANG_STRING -import com.intellij.psi.CommonClassNames.JAVA_LANG_STRING_SHORT import com.intellij.psi.PsiArrayType import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElementVisitor @@ -97,18 +96,15 @@ class ConfigValueInspection : MixinConfigInspection() { return true // Idk, it's fine I guess } - if (type.className == JAVA_LANG_STRING_SHORT && type.resolve()?.qualifiedName == JAVA_LANG_STRING) { + if (type.equalsToText(JAVA_LANG_STRING)) { return value is JsonStringLiteral } - if (type.className == "Boolean" && type.resolve()?.qualifiedName == CommonClassNames.JAVA_LANG_BOOLEAN) { + if (type.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN)) { return value is JsonBooleanLiteral || value is JsonNullLiteral } - if ( - shortNumberNames.contains(type.className) && - qualifiedNumberNames.contains(type.resolve()?.qualifiedName) - ) { + if (qualifiedNumberNames.any(type::equalsToText)) { return value is JsonNumberLiteral || value is JsonNullLiteral } @@ -116,8 +112,7 @@ class ConfigValueInspection : MixinConfigInspection() { return value is JsonObject } - private val shortNumberNames = setOf("Byte", "Character", "Double", "Float", "Integer", "Long", "Short") - private val qualifiedNumberNames = setOf( + private val qualifiedNumberNames = listOf( JAVA_LANG_BYTE, JAVA_LANG_CHARACTER, JAVA_LANG_DOUBLE, diff --git a/src/main/kotlin/platform/mixin/folding/MixinObjectCastFoldingBuilder.kt b/src/main/kotlin/platform/mixin/folding/MixinObjectCastFoldingBuilder.kt index 5478e1dd3..ecf35c3b2 100644 --- a/src/main/kotlin/platform/mixin/folding/MixinObjectCastFoldingBuilder.kt +++ b/src/main/kotlin/platform/mixin/folding/MixinObjectCastFoldingBuilder.kt @@ -28,7 +28,6 @@ import com.intellij.openapi.editor.Document import com.intellij.openapi.util.TextRange import com.intellij.psi.CommonClassNames import com.intellij.psi.JavaRecursiveElementWalkingVisitor -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElement import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiTypeCastExpression @@ -74,7 +73,7 @@ class MixinObjectCastFoldingBuilder : CustomFoldingBuilder() { } val innerCast = expression.operand as? PsiTypeCastExpression ?: return - if ((innerCast.type as? PsiClassType)?.resolve()?.qualifiedName == CommonClassNames.JAVA_LANG_OBJECT) { + if (innerCast.type?.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) == true) { // Fold the two casts val start = (expression as? CompositeElement)?.findChildByRole(ChildRole.LPARENTH) ?: return diff --git a/src/main/kotlin/platform/mixin/handlers/InvokerHandler.kt b/src/main/kotlin/platform/mixin/handlers/InvokerHandler.kt index ff9f2ba87..f9c7f7b6d 100644 --- a/src/main/kotlin/platform/mixin/handlers/InvokerHandler.kt +++ b/src/main/kotlin/platform/mixin/handlers/InvokerHandler.kt @@ -30,9 +30,7 @@ import com.demonwav.mcdev.util.constantStringValue import com.demonwav.mcdev.util.decapitalize import com.demonwav.mcdev.util.descriptor import com.demonwav.mcdev.util.findAnnotation -import com.demonwav.mcdev.util.fullQualifiedName import com.intellij.psi.PsiAnnotation -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiMember import com.intellij.psi.PsiMethod import com.intellij.psi.SmartPsiElementPointer @@ -55,7 +53,7 @@ class InvokerHandler : MixinMemberAnnotationHandler { val name = getInvokerTargetName(annotation, member) ?: return emptyList() val constructor = name == "" if (constructor && - (member.returnType as? PsiClassType)?.resolve()?.fullQualifiedName?.replace('.', '/') != targetClass.name + member.returnType?.equalsToText(targetClass.name.replace('/', '.').replace('$', '.')) != true ) { return emptyList() } diff --git a/src/main/kotlin/platform/mixin/inspection/MixinCancellableInspection.kt b/src/main/kotlin/platform/mixin/inspection/MixinCancellableInspection.kt index 85ef79174..955320d51 100644 --- a/src/main/kotlin/platform/mixin/inspection/MixinCancellableInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/MixinCancellableInspection.kt @@ -23,7 +23,6 @@ package com.demonwav.mcdev.platform.mixin.inspection import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.INJECT import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Classes.CALLBACK_INFO import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Classes.CALLBACK_INFO_RETURNABLE -import com.demonwav.mcdev.util.fullQualifiedName import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ProblemsHolder @@ -58,8 +57,7 @@ class MixinCancellableInspection : MixinInspection() { val isCancellable = cancellableAttribute.value == true val ciParam = method.parameterList.parameters.firstOrNull { - val className = (it.type as? PsiClassType)?.fullQualifiedName ?: return@firstOrNull false - className == CALLBACK_INFO || className == CALLBACK_INFO_RETURNABLE + it.type.equalsToText(CALLBACK_INFO) || it.type.equalsToText(CALLBACK_INFO_RETURNABLE) } ?: return val ciType = (ciParam.type as? PsiClassType)?.resolve() ?: return diff --git a/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt b/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt index 9d96a33dc..d620b84bf 100644 --- a/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/injector/InjectCouldBeOverwriteInspection.kt @@ -360,11 +360,8 @@ class InjectCouldBeOverwriteInspection : MixinInspection() { } companion object { - private fun isCallbackInfoParam(param: PsiParameter): Boolean { - val type = (param.type as? PsiClassType)?.resolve() ?: return false - val qName = type.qualifiedName ?: return false - return qName == MixinConstants.Classes.CALLBACK_INFO || - qName == MixinConstants.Classes.CALLBACK_INFO_RETURNABLE - } + private fun isCallbackInfoParam(param: PsiParameter) = + param.type.equalsToText(MixinConstants.Classes.CALLBACK_INFO) || + param.type.equalsToText(MixinConstants.Classes.CALLBACK_INFO_RETURNABLE) } } diff --git a/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt b/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt index 1b93da3c2..29ede21c2 100644 --- a/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt @@ -32,7 +32,6 @@ import com.demonwav.mcdev.platform.mixin.util.isAssignable import com.demonwav.mcdev.platform.mixin.util.isConstructor import com.demonwav.mcdev.platform.mixin.util.isMixinExtrasSugar import com.demonwav.mcdev.util.Parameter -import com.demonwav.mcdev.util.fullQualifiedName import com.demonwav.mcdev.util.synchronize import com.intellij.codeInsight.intention.FileModifier.SafeFieldForPreview import com.intellij.codeInsight.intention.QuickFixFactory @@ -43,7 +42,6 @@ import com.intellij.codeInspection.ProblemsHolder import com.intellij.openapi.project.Project import com.intellij.psi.JavaElementVisitor import com.intellij.psi.JavaPsiFacade -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiMethod import com.intellij.psi.PsiModifier @@ -307,9 +305,8 @@ class InvalidInjectorMethodSignatureInspection : MixinInspection() { val parameters = descriptor.psiElement as PsiParameterList // We want to preserve captured locals val locals = parameters.parameters.dropWhile { - val fqname = (it.type as? PsiClassType)?.fullQualifiedName ?: return@dropWhile true - return@dropWhile fqname != MixinConstants.Classes.CALLBACK_INFO && - fqname != MixinConstants.Classes.CALLBACK_INFO_RETURNABLE + !it.type.equalsToText(MixinConstants.Classes.CALLBACK_INFO) && + !it.type.equalsToText(MixinConstants.Classes.CALLBACK_INFO_RETURNABLE) }.drop(1) // the first element in the list is the CallbackInfo but we don't want it .takeWhile { !it.isMixinExtrasSugar } diff --git a/src/main/kotlin/platform/mixin/inspection/mixinextras/WrongOperationParametersInspection.kt b/src/main/kotlin/platform/mixin/inspection/mixinextras/WrongOperationParametersInspection.kt index 2ebca3ca7..75f8dcf00 100644 --- a/src/main/kotlin/platform/mixin/inspection/mixinextras/WrongOperationParametersInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/mixinextras/WrongOperationParametersInspection.kt @@ -32,7 +32,6 @@ import com.intellij.psi.JavaElementVisitor import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiCallExpression import com.intellij.psi.PsiClass -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElement import com.intellij.psi.PsiExpressionList import com.intellij.psi.PsiField @@ -68,7 +67,7 @@ class WrongOperationParametersInspection : MixinInspection() { val (operationIndex, operationParam) = containingMethod.parameterList.parameters.asSequence() .withIndex() .firstOrNull { (_, param) -> - (param.type as? PsiClassType)?.resolve()?.qualifiedName == MixinConstants.MixinExtras.OPERATION + param.type.equalsToText(MixinConstants.MixinExtras.OPERATION) } ?: return val (expectedParamTypes, paramNames) = containingMethod.parameterList.parameters.asSequence() .take(operationIndex) diff --git a/src/main/kotlin/platform/sponge/SpongeModule.kt b/src/main/kotlin/platform/sponge/SpongeModule.kt index 8bd09dc7e..50a58b8bd 100644 --- a/src/main/kotlin/platform/sponge/SpongeModule.kt +++ b/src/main/kotlin/platform/sponge/SpongeModule.kt @@ -61,8 +61,8 @@ class SpongeModule(facet: MinecraftFacet) : AbstractModule(facet) { chosenClass: PsiClass, chosenName: String, data: GenerationData?, - ): PsiMethod? { - val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) ?: return null + ): PsiMethod { + val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) val modifierList = method.modifierList val listenerAnnotation = modifierList.addAnnotation("org.spongepowered.api.event.Listener") diff --git a/src/main/kotlin/platform/sponge/inspection/SpongeLoggingInspection.kt b/src/main/kotlin/platform/sponge/inspection/SpongeLoggingInspection.kt index f18c3bfd0..6158618d0 100644 --- a/src/main/kotlin/platform/sponge/inspection/SpongeLoggingInspection.kt +++ b/src/main/kotlin/platform/sponge/inspection/SpongeLoggingInspection.kt @@ -22,14 +22,12 @@ package com.demonwav.mcdev.platform.sponge.inspection import com.demonwav.mcdev.platform.sponge.SpongeModuleType import com.demonwav.mcdev.util.Constants -import com.demonwav.mcdev.util.fullQualifiedName import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool import com.intellij.codeInspection.InspectionManager import com.intellij.codeInspection.ProblemDescriptor import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ProblemsHolder import com.intellij.psi.JavaElementVisitor -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiField import com.intellij.psi.PsiFile @@ -60,9 +58,8 @@ class SpongeLoggingInspection : AbstractBaseJavaLocalInspectionTool() { override fun visitField(field: PsiField) { val element = field.typeElement ?: return - val name = (field.type as? PsiClassType)?.fullQualifiedName ?: return - if (name != Constants.JAVA_UTIL_LOGGER) { + if (!field.type.equalsToText(Constants.JAVA_UTIL_LOGGER)) { return } diff --git a/src/main/kotlin/platform/sponge/inspection/SpongeWrongGetterTypeInspection.kt b/src/main/kotlin/platform/sponge/inspection/SpongeWrongGetterTypeInspection.kt index b3dc3cf3a..b577f2596 100644 --- a/src/main/kotlin/platform/sponge/inspection/SpongeWrongGetterTypeInspection.kt +++ b/src/main/kotlin/platform/sponge/inspection/SpongeWrongGetterTypeInspection.kt @@ -23,7 +23,6 @@ package com.demonwav.mcdev.platform.sponge.inspection import com.demonwav.mcdev.platform.sponge.util.SpongeConstants import com.demonwav.mcdev.platform.sponge.util.isValidSpongeListener import com.demonwav.mcdev.platform.sponge.util.resolveSpongeGetterTarget -import com.demonwav.mcdev.util.isJavaOptional import com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool import com.intellij.codeInspection.InspectionManager import com.intellij.codeInspection.IntentionAndQuickFixAction @@ -36,6 +35,7 @@ import com.intellij.lang.jvm.actions.expectedParameter import com.intellij.lang.jvm.actions.updateMethodParametersRequest import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project +import com.intellij.psi.CommonClassNames import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClassType import com.intellij.psi.PsiFile @@ -126,7 +126,7 @@ class SpongeWrongGetterTypeInspection : AbstractBaseUastLocalInspectionTool() { private fun isOptional(type: PsiType): Boolean { val typeClass = type as? PsiClassType ?: return false - return typeClass.isJavaOptional() && typeClass.hasParameters() + return typeClass.equalsToText(CommonClassNames.JAVA_UTIL_OPTIONAL) && typeClass.hasParameters() } private fun getFirstGenericType(typeElement: PsiType): PsiType? = diff --git a/src/main/kotlin/platform/velocity/VelocityModule.kt b/src/main/kotlin/platform/velocity/VelocityModule.kt index 33c51bf40..d84e52037 100644 --- a/src/main/kotlin/platform/velocity/VelocityModule.kt +++ b/src/main/kotlin/platform/velocity/VelocityModule.kt @@ -51,8 +51,8 @@ class VelocityModule(facet: MinecraftFacet) : AbstractModule(facet) { chosenClass: PsiClass, chosenName: String, data: GenerationData?, - ): PsiMethod? { - val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) ?: return null + ): PsiMethod { + val method = createVoidMethodWithParameterType(project, chosenName, chosenClass) val modifierList = method.modifierList val subscribeAnnotation = modifierList.addAnnotation(SUBSCRIBE_ANNOTATION) diff --git a/src/main/kotlin/util/class-utils.kt b/src/main/kotlin/util/class-utils.kt index 18b5fd39f..da15fbe9f 100644 --- a/src/main/kotlin/util/class-utils.kt +++ b/src/main/kotlin/util/class-utils.kt @@ -23,7 +23,6 @@ package com.demonwav.mcdev.util import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodFix import com.intellij.navigation.AnonymousElementProvider import com.intellij.openapi.project.Project -import com.intellij.psi.CommonClassNames import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass import com.intellij.psi.PsiClassType @@ -305,10 +304,6 @@ private fun areReallyOnlyParametersErasureEqual( return true } -fun PsiClass.isJavaOptional(): Boolean = this.qualifiedName == CommonClassNames.JAVA_UTIL_OPTIONAL - -fun PsiClassType.isJavaOptional(): Boolean = this.fullQualifiedName == CommonClassNames.JAVA_UTIL_OPTIONAL - class ClassNameResolutionFailedException : Exception { constructor() : super() constructor(message: String) : super(message) diff --git a/src/main/kotlin/util/code-gen.kt b/src/main/kotlin/util/code-gen.kt index a55ccc195..8575640f6 100644 --- a/src/main/kotlin/util/code-gen.kt +++ b/src/main/kotlin/util/code-gen.kt @@ -26,21 +26,19 @@ import com.intellij.openapi.util.text.StringUtil import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiAnnotation import com.intellij.psi.PsiClass -import com.intellij.psi.PsiClassType import com.intellij.psi.PsiMember import com.intellij.psi.PsiMethod import com.intellij.psi.PsiTypes -import com.intellij.psi.search.GlobalSearchScope -fun createVoidMethodWithParameterType(project: Project, name: String, paramType: PsiClass): PsiMethod? { - val newMethod = JavaPsiFacade.getElementFactory(project).createMethod(name, PsiTypes.voidType()) +fun createVoidMethodWithParameterType(project: Project, name: String, paramType: PsiClass): PsiMethod { + val elementFactory = JavaPsiFacade.getElementFactory(project) + val newMethod = elementFactory.createMethod(name, PsiTypes.voidType()) val list = newMethod.parameterList - val qName = paramType.qualifiedName ?: return null - val parameter = JavaPsiFacade.getElementFactory(project) + val parameter = elementFactory .createParameter( "event", - PsiClassType.getTypeByName(qName, project, GlobalSearchScope.allScope(project)), + elementFactory.createType(paramType) ) list.add(parameter) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 42c3c7d41..6a2e8fef5 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -651,13 +651,6 @@ -