KT-4344 "Overridden method parameters are not annotated" warnings from Java

#KT-4344 Fixed
This commit is contained in:
Nikolay Krasko
2014-02-13 16:15:40 +04:00
parent f14f2c19a8
commit 9a8a8364dd
7 changed files with 106 additions and 40 deletions
@@ -31,7 +31,6 @@ import com.intellij.psi.impl.compiled.ClsFileImpl;
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
import com.intellij.psi.impl.light.LightClass;
import com.intellij.psi.impl.light.LightMethod;
import com.intellij.psi.impl.light.LightModifierList;
import com.intellij.psi.stubs.PsiClassHolderFileStub;
import com.intellij.psi.util.CachedValue;
import com.intellij.psi.util.CachedValuesManager;
@@ -387,7 +386,12 @@ public class KotlinLightClassForExplicitDeclaration extends KotlinWrappingLightC
@Override
public PsiModifierList getModifierList() {
if (modifierList == null) {
modifierList = new KotlinLightModifierList(computeModifiers());
modifierList = new KotlinLightModifierList(this.getManager(), computeModifiers()) {
@Override
public PsiAnnotationOwner getDelegate() {
return KotlinLightClassForExplicitDeclaration.this.getDelegate().getModifierList();
}
};
}
return modifierList;
}
@@ -565,38 +569,4 @@ public class KotlinLightClassForExplicitDeclaration extends KotlinWrappingLightC
return false;
}
private class KotlinLightModifierList extends LightModifierList {
public KotlinLightModifierList(@NotNull String[] modifiers) {
super(KotlinLightClassForExplicitDeclaration.this.getManager(), JetLanguage.INSTANCE, modifiers);
}
private PsiAnnotationOwner getDelegate() {
return KotlinLightClassForExplicitDeclaration.this.getDelegate().getModifierList();
}
@Override
@NotNull
public PsiAnnotation[] getAnnotations() {
return getDelegate().getAnnotations();
}
@Override
@NotNull
public PsiAnnotation[] getApplicableAnnotations() {
return getDelegate().getApplicableAnnotations();
}
@Override
@Nullable
public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) {
return getDelegate().findAnnotation(qualifiedName);
}
@Override
@NotNull
public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
return getDelegate().addAnnotation(qualifiedName);
}
}
}
@@ -0,0 +1,58 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.asJava;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiAnnotationOwner;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.light.LightModifierList;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.plugin.JetLanguage;
public abstract class KotlinLightModifierList extends LightModifierList {
public KotlinLightModifierList(PsiManager psiManager, @NotNull String[] modifiers) {
super(psiManager, JetLanguage.INSTANCE, modifiers);
}
public abstract PsiAnnotationOwner getDelegate();
@Override
@NotNull
public PsiAnnotation[] getAnnotations() {
return getDelegate().getAnnotations();
}
@Override
@NotNull
public PsiAnnotation[] getApplicableAnnotations() {
return getDelegate().getApplicableAnnotations();
}
@Override
@Nullable
public PsiAnnotation findAnnotation(@NotNull @NonNls String qualifiedName) {
return getDelegate().findAnnotation(qualifiedName);
}
@Override
@NotNull
public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
return getDelegate().addAnnotation(qualifiedName);
}
}
@@ -16,7 +16,10 @@
package org.jetbrains.jet.asJava;
import com.intellij.psi.PsiAnnotationOwner;
import com.intellij.psi.PsiModifierList;
import com.intellij.psi.PsiParameter;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.asJava.light.LightParameter;
@@ -34,15 +37,30 @@ public class KotlinLightParameter extends LightParameter implements KotlinLightE
return name != null ? name : "p" + index;
}
private final PsiModifierList modifierList;
private final PsiParameter delegate;
private final int index;
private final KotlinLightMethod method;
public KotlinLightParameter(PsiParameter delegate, int index, KotlinLightMethod method) {
public KotlinLightParameter(final PsiParameter delegate, int index, KotlinLightMethod method) {
super(getName(delegate, index), delegate.getType(), method, JetLanguage.INSTANCE);
this.delegate = delegate;
this.index = index;
this.method = method;
this.modifierList = new KotlinLightModifierList(method.getManager(), ArrayUtil.EMPTY_STRING_ARRAY) {
@Override
public PsiAnnotationOwner getDelegate() {
return delegate.getModifierList();
}
};
}
@NotNull
@Override
public PsiModifierList getModifierList() {
return modifierList;
}
@NotNull