Report correct build targets for outputs + tests on output removal

This commit is contained in:
Andrey Breslav
2013-10-21 17:54:02 +04:00
parent c84e582397
commit 2a43d2adee
10 changed files with 104 additions and 21 deletions
@@ -18,7 +18,7 @@ package org.jetbrains.jet.codegen;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.PsiFile;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
@@ -269,11 +269,11 @@ public class CodegenUtil {
return ((ImplementationBodyCodegen) classBodyCodegen.getParentCodegen());
}
static int getPathHashCode(@NotNull PsiFile file) {
static int getPathHashCode(@NotNull VirtualFile file) {
// Conversion to system-dependent name seems to be unnecessary, but it's hard to check now:
// it was introduced when fixing KT-2839, which appeared again (KT-3639).
// If you try to remove it, run tests on Windows.
return FileUtil.toSystemDependentName(file.getVirtualFile().getPath()).hashCode();
return FileUtil.toSystemDependentName(file.getPath()).hashCode();
}
@Nullable
@@ -186,7 +186,7 @@ public class NamespaceCodegen extends MemberCodegen {
if (!generateSrcClass) return null;
Type packageFragmentType = getNamespacePartType(getPackageClassFqName(name), file);
Type packageFragmentType = getNamespacePartType(getPackageClassFqName(name), file.getVirtualFile());
ClassBuilder builder = state.getFactory().forPackageFragment(packageFragmentType, file);
new NamespacePartCodegen(builder, file, packageFragmentType, packageFragmentContext, state).generate();
@@ -247,7 +247,7 @@ public class NamespaceCodegen extends MemberCodegen {
}
@NotNull
private static Type getNamespacePartType(@NotNull FqName facadeFqName, @NotNull PsiFile file) {
public static Type getNamespacePartType(@NotNull FqName facadeFqName, @NotNull VirtualFile file) {
String fileName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(file.getName()));
// path hashCode to prevent same name / different path collision
@@ -267,6 +267,6 @@ public class NamespaceCodegen extends MemberCodegen {
@NotNull
public static String getNamespacePartInternalName(@NotNull JetFile file) {
FqName packageFqName = JetPsiUtil.getFQName(file);
return getNamespacePartType(getPackageClassFqName(packageFqName), file).getInternalName();
return getNamespacePartType(getPackageClassFqName(packageFqName), file.getVirtualFile()).getInternalName();
}
}
@@ -16,6 +16,7 @@
package org.jetbrains.jet.codegen;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.MethodVisitor;
@@ -134,11 +135,12 @@ public class SamWrapperCodegen extends ParentCodegenAwareImpl {
private String getWrapperName(@NotNull JetFile containingFile) {
NamespaceDescriptor namespace = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, containingFile);
assert namespace != null : "couldn't find namespace for file: " + containingFile.getVirtualFile();
VirtualFile virtualFile = containingFile.getVirtualFile();
assert namespace != null : "couldn't find namespace for file: " + virtualFile;
FqName fqName = DescriptorUtils.getFQName(namespace).toSafe();
String packageInternalName = JvmClassName.byFqNameWithoutInnerClasses(
PackageClassUtils.getPackageClassFqName(fqName)).getInternalName();
return packageInternalName + "$sam$" + samInterface.getName().asString() + "$" +
Integer.toHexString(CodegenUtil.getPathHashCode(containingFile) * 31 + DescriptorUtils.getFQName(samInterface).hashCode());
Integer.toHexString(CodegenUtil.getPathHashCode(virtualFile) * 31 + DescriptorUtils.getFQName(samInterface).hashCode());
}
}