IDEA-170804 Idea does't support @Newify annotation

This commit is contained in:
alexey.afanasiev
2017-05-26 17:36:43 +03:00
parent a64f4c768b
commit 8344c463ee
@@ -39,13 +39,13 @@ class NewifyMemberContributor : NonCodeMembersContributor() {
for (annotation in listNewifyAnnotations(place)) {
val newifiedClasses = GrAnnotationUtil.getClassArrayValue(annotation, "value", true)
qualifier ?: newifiedClasses.flatMap { it.constructors.asList() }.forEach {
ResolveUtil.processElement(processor, NewifiedConstructor(it, "by @Newify", it.name, true, arrayOf(PsiModifier.STATIC)), state)
ResolveUtil.processElement(processor, NewifiedConstructor(it, "by @Newify", it.name, true), state)
}
val createNewMethods = GrAnnotationUtil.inferBooleanAttributeNotNull(annotation, "auto")
val type = (qualifier as? GrReferenceExpression)?.resolve() as? PsiClass
if (type != null && createNewMethods) {
type.constructors.forEach {
ResolveUtil.processElement(processor, NewifiedConstructor(it, "by @Newify", "new", false, arrayOf(PsiModifier.STATIC)), state)
ResolveUtil.processElement(processor, NewifiedConstructor(it, "by @Newify", "new", false), state)
}
}
}
@@ -67,13 +67,16 @@ class NewifyMemberContributor : NonCodeMembersContributor() {
return (elem as? GrReferenceExpression)?.qualifierExpression
}
class NewifiedConstructor(val myPrototype: PsiMethod, val myOriginInfo: String, val newName: String, val asConstructor: Boolean, val modifiers:Array<String>)
class NewifiedConstructor(val myPrototype: PsiMethod,
val myOriginInfo: String,
val newName: String,
val asConstructor: Boolean)
: LightMethod(myPrototype.manager, myPrototype, myPrototype.containingClass!!), OriginInfoAwareElement, PsiMirrorElement {
override fun getPrototype(): PsiElement {
return myPrototype
}
val myModifierList: LightModifierList = LightModifierList(myPrototype.manager, JavaLanguage.INSTANCE, *modifiers)
val myModifierList: LightModifierList = LightModifierList(myPrototype.manager, JavaLanguage.INSTANCE, PsiModifier.STATIC)
override fun getName(): String {