Don't report package facade classes as output of sources without top-level members.
This commit is contained in:
@@ -87,7 +87,8 @@ public class PackageCodegen {
|
|||||||
JetFile sourceFile = getRepresentativePackageFile(files);
|
JetFile sourceFile = getRepresentativePackageFile(files);
|
||||||
|
|
||||||
String className = AsmUtil.internalNameByFqNameWithoutInnerClasses(getPackageClassFqName(fqName));
|
String className = AsmUtil.internalNameByFqNameWithoutInnerClasses(getPackageClassFqName(fqName));
|
||||||
ClassBuilder v = PackageCodegen.this.state.getFactory().newVisitor(Type.getObjectType(className), files);
|
ClassBuilder v = PackageCodegen.this.state.getFactory()
|
||||||
|
.newVisitor(Type.getObjectType(className), getPackageFilesWithCallables(files));
|
||||||
v.defineClass(sourceFile, V1_6,
|
v.defineClass(sourceFile, V1_6,
|
||||||
ACC_PUBLIC | ACC_FINAL,
|
ACC_PUBLIC | ACC_FINAL,
|
||||||
className,
|
className,
|
||||||
@@ -111,18 +112,7 @@ public class PackageCodegen {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<JetFile> packageFilesWithCallables = ContainerUtil.filter(packageFiles, new Condition<JetFile>() {
|
List<JetFile> packageFilesWithCallables = getPackageFilesWithCallables(packageFiles);
|
||||||
@Override
|
|
||||||
public boolean value(JetFile packageFile) {
|
|
||||||
for (JetDeclaration declaration : packageFile.getDeclarations()) {
|
|
||||||
if (declaration instanceof JetProperty || declaration instanceof JetNamedFunction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return packageFilesWithCallables.size() == 1 ? packageFilesWithCallables.get(0) : null;
|
return packageFilesWithCallables.size() == 1 ? packageFilesWithCallables.get(0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,6 +349,21 @@ public class PackageCodegen {
|
|||||||
MemberCodegen.genClassOrObject(context, classOrObject, state, null);
|
MemberCodegen.genClassOrObject(context, classOrObject, state, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static List<JetFile> getPackageFilesWithCallables(@NotNull Collection<JetFile> packageFiles) {
|
||||||
|
return ContainerUtil.filter(packageFiles, new Condition<JetFile>() {
|
||||||
|
@Override
|
||||||
|
public boolean value(JetFile packageFile) {
|
||||||
|
for (JetDeclaration declaration : packageFile.getDeclarations()) {
|
||||||
|
if (declaration instanceof JetProperty || declaration instanceof JetNamedFunction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void done() {
|
public void done() {
|
||||||
v.done();
|
v.done();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -38,6 +38,8 @@ import org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils
|
|||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
|
import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
|
||||||
import org.jetbrains.jet.storage.NotNullLazyValue
|
import org.jetbrains.jet.storage.NotNullLazyValue
|
||||||
|
import org.jetbrains.jet.lang.psi.JetNamedFunction
|
||||||
|
import org.jetbrains.jet.lang.psi.JetProperty
|
||||||
|
|
||||||
public class IncrementalPackageFragmentProvider(
|
public class IncrementalPackageFragmentProvider(
|
||||||
sourceFiles: Collection<JetFile>,
|
sourceFiles: Collection<JetFile>,
|
||||||
@@ -70,7 +72,9 @@ public class IncrementalPackageFragmentProvider(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (source in sourceFiles) {
|
for (source in sourceFiles) {
|
||||||
createPackageFragment(source.getPackageFqName())
|
if (source.getDeclarations().any { it is JetProperty || it is JetNamedFunction }) {
|
||||||
|
createPackageFragment(source.getPackageFqName())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class KotlinJpsBuildTest extends AbstractKotlinJpsBuildTestCase {
|
|||||||
|
|
||||||
checkPackageDeletedFromOutputWhen(Operation.CHANGE, "kotlinProject", "src/main.kt", "foo.FooPackage");
|
checkPackageDeletedFromOutputWhen(Operation.CHANGE, "kotlinProject", "src/main.kt", "foo.FooPackage");
|
||||||
checkPackageDeletedFromOutputWhen(Operation.CHANGE, "kotlinProject", "src/boo.kt", "boo.BooPackage");
|
checkPackageDeletedFromOutputWhen(Operation.CHANGE, "kotlinProject", "src/boo.kt", "boo.BooPackage");
|
||||||
checkClassesDeletedFromOutputWhen(Operation.CHANGE, "kotlinProject", "src/Bar.kt", "foo.Bar", "foo.FooPackage");
|
checkClassesDeletedFromOutputWhen(Operation.CHANGE, "kotlinProject", "src/Bar.kt", "foo.Bar");
|
||||||
|
|
||||||
checkPackageDeletedFromOutputWhen(Operation.DELETE, "kotlinProject", "src/main.kt", "foo.FooPackage");
|
checkPackageDeletedFromOutputWhen(Operation.DELETE, "kotlinProject", "src/main.kt", "foo.FooPackage");
|
||||||
assertFilesNotExistInOutput(module, "foo/FooPackage.class");
|
assertFilesNotExistInOutput(module, "foo/FooPackage.class");
|
||||||
|
|||||||
Reference in New Issue
Block a user