Preserving annotations in incremental compilation.
This commit is contained in:
@@ -20,6 +20,8 @@ import com.intellij.psi.PsiElement;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||||
|
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||||
|
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPropertyDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||||
@@ -112,24 +114,33 @@ public abstract class AnnotationCodegen {
|
|||||||
modifierList = ((JetModifierListOwner) psiElement).getModifierList();
|
modifierList = ((JetModifierListOwner) psiElement).getModifierList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modifierList == null) {
|
|
||||||
generateAdditionalAnnotations(annotated, returnType, Collections.<String>emptySet());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<String>();
|
Set<String> annotationDescriptorsAlreadyPresent = new HashSet<String>();
|
||||||
|
|
||||||
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
|
if (modifierList == null) {
|
||||||
for (JetAnnotationEntry annotationEntry : annotationEntries) {
|
if (annotated instanceof DeserializedCallableMemberDescriptor ||
|
||||||
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression());
|
annotated instanceof PropertyAccessorDescriptor &&
|
||||||
if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
|
((PropertyAccessorDescriptor) annotated).getCorrespondingProperty() instanceof DeserializedPropertyDescriptor) {
|
||||||
|
for (AnnotationDescriptor annotation : annotated.getAnnotations()) {
|
||||||
|
String descriptor = genAnnotation(annotation);
|
||||||
|
if (descriptor != null) {
|
||||||
|
annotationDescriptorsAlreadyPresent.add(descriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
|
||||||
|
for (JetAnnotationEntry annotationEntry : annotationEntries) {
|
||||||
|
ResolvedCall<?> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, annotationEntry.getCalleeExpression());
|
||||||
|
if (resolvedCall == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
|
||||||
|
|
||||||
AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry);
|
AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry);
|
||||||
if (annotationDescriptor == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
|
if (annotationDescriptor == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
|
||||||
|
|
||||||
String descriptor = genAnnotation(annotationDescriptor);
|
String descriptor = genAnnotation(annotationDescriptor);
|
||||||
if (descriptor != null) {
|
if (descriptor != null) {
|
||||||
annotationDescriptorsAlreadyPresent.add(descriptor);
|
annotationDescriptorsAlreadyPresent.add(descriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("jps-plugin/testData/incremental"), Pattern.compile("^([^\\.]+)$"), false);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("jps-plugin/testData/incremental"), Pattern.compile("^([^\\.]+)$"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotations")
|
||||||
|
public void testAnnotations() throws Exception {
|
||||||
|
doTest("jps-plugin/testData/incremental/annotations/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("classInlineFunctionChanged")
|
@TestMetadata("classInlineFunctionChanged")
|
||||||
public void testClassInlineFunctionChanged() throws Exception {
|
public void testClassInlineFunctionChanged() throws Exception {
|
||||||
doTest("jps-plugin/testData/incremental/classInlineFunctionChanged/");
|
doTest("jps-plugin/testData/incremental/classInlineFunctionChanged/");
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
annotation class Anno
|
||||||
|
|
||||||
|
[Anno] fun f() {
|
||||||
|
}
|
||||||
|
|
||||||
|
[Anno] val v1 = ""
|
||||||
|
|
||||||
|
var v2: String
|
||||||
|
get() = ""
|
||||||
|
[Anno] set(value) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Cleaning output files:
|
||||||
|
out/production/module/test/TestPackage-other-*.class
|
||||||
|
out/production/module/test/TestPackage.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/other.kt
|
||||||
|
End of files
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun dummyFunction() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
fun dummyFunction() {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user