Don't report package facade classes as output of sources without top-level members.

This commit is contained in:
Evgeny Gerashchenko
2014-05-22 12:32:56 +04:00
parent e89b59a745
commit b9f01a6397
3 changed files with 24 additions and 15 deletions
@@ -87,7 +87,8 @@ public class PackageCodegen {
JetFile sourceFile = getRepresentativePackageFile(files);
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,
ACC_PUBLIC | ACC_FINAL,
className,
@@ -111,18 +112,7 @@ public class PackageCodegen {
return null;
}
List<JetFile> packageFilesWithCallables = 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;
}
});
List<JetFile> packageFilesWithCallables = getPackageFilesWithCallables(packageFiles);
return packageFilesWithCallables.size() == 1 ? packageFilesWithCallables.get(0) : null;
}
@@ -359,6 +349,21 @@ public class PackageCodegen {
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() {
v.done();
}
@@ -38,6 +38,8 @@ import org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils
import java.util.Collections
import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
import org.jetbrains.jet.storage.NotNullLazyValue
import org.jetbrains.jet.lang.psi.JetNamedFunction
import org.jetbrains.jet.lang.psi.JetProperty
public class IncrementalPackageFragmentProvider(
sourceFiles: Collection<JetFile>,
@@ -70,7 +72,9 @@ public class IncrementalPackageFragmentProvider(
}
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/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");
assertFilesNotExistInOutput(module, "foo/FooPackage.class");