KtLightModifierList* is created only for light classes build for sources

This is a hacky solution to avoid calling lightMemberOrigin.originalElement inside
Moreover it needs to resolve descriptor for sources inside computeAnnotations and it is used only for kotlin sources so this will have to do for now
This commit is contained in:
Pavel V. Talanov
2016-03-30 15:33:02 +03:00
parent e19cc04c63
commit 484167e9d9
3 changed files with 21 additions and 8 deletions
@@ -68,7 +68,11 @@ sealed class KtLightFieldImpl(
@Throws(IncorrectOperationException::class)
override fun setName(@NonNls name: String) = throw IncorrectOperationException("Not supported")
private val _modifierList by lazy { clsDelegate.modifierList?.let { KtLightModifierList(it, this) } }
private val _modifierList by lazy {
if (lightMemberOrigin is LightMemberOriginForDeclaration)
clsDelegate.modifierList?.let { KtLightModifierList(it, this) }
else clsDelegate.modifierList
}
override fun getModifierList() = _modifierList
@@ -111,7 +111,11 @@ sealed class KtLightMethodImpl(
throw IncorrectOperationException(JavaCoreBundle.message("psi.error.attempt.to.edit.class.file"))
}
private val _modifierList by lazy { KtLightModifierList(clsDelegate.modifierList, this) }
private val _modifierList by lazy {
if (lightMethodOrigin is LightMemberOriginForDeclaration)
KtLightModifierList(clsDelegate.modifierList, this)
else clsDelegate.modifierList
}
override fun getModifierList() = _modifierList
@@ -50,12 +50,17 @@ public class KtLightParameter extends LightParameter implements KtLightDeclarati
this.index = index;
this.method = method;
this.modifierList = new KtLightModifierListWithExplicitModifiers(this, ArrayUtil.EMPTY_STRING_ARRAY) {
@Override
public PsiAnnotationOwner getDelegate() {
return delegate.getModifierList();
}
};
if (method.getLightMethodOrigin() instanceof LightMemberOriginForDeclaration) {
this.modifierList = new KtLightModifierListWithExplicitModifiers(this, ArrayUtil.EMPTY_STRING_ARRAY) {
@Override
public PsiAnnotationOwner getDelegate() {
return delegate.getModifierList();
}
};
}
else {
this.modifierList = super.getModifierList();
}
}
@NotNull