For namespaces with multiple files keep 'Compiled from' information empty
This commit is contained in:
@@ -62,7 +62,7 @@ public class NamespaceCodegen extends MemberCodegen {
|
|||||||
name = fqName;
|
name = fqName;
|
||||||
this.files = namespaceFiles;
|
this.files = namespaceFiles;
|
||||||
|
|
||||||
final PsiFile sourceFile = namespaceFiles.iterator().next().getContainingFile();
|
final PsiFile sourceFile = namespaceFiles.size() == 1 ? namespaceFiles.iterator().next().getContainingFile() : null;
|
||||||
|
|
||||||
v.addOptionalDeclaration(new ClassBuilderOnDemand.ClassBuilderCallback() {
|
v.addOptionalDeclaration(new ClassBuilderOnDemand.ClassBuilderCallback() {
|
||||||
@Override
|
@Override
|
||||||
@@ -75,8 +75,10 @@ public class NamespaceCodegen extends MemberCodegen {
|
|||||||
"java/lang/Object",
|
"java/lang/Object",
|
||||||
new String[0]
|
new String[0]
|
||||||
);
|
);
|
||||||
// TODO figure something out for a namespace that spans multiple files
|
//We don't generate any source information for namespace with multiple files
|
||||||
v.visitSource(sourceFile.getName(), null);
|
if (sourceFile != null) {
|
||||||
|
v.visitSource(sourceFile.getName(), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
fun box() = {
|
||||||
|
1
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package foo;
|
||||||
|
|
||||||
|
fun box2() = {
|
||||||
|
1
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
class SingleClass {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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.codegen;
|
||||||
|
|
||||||
|
import org.jetbrains.asm4.ClassReader;
|
||||||
|
import org.jetbrains.asm4.ClassVisitor;
|
||||||
|
import org.jetbrains.asm4.Opcodes;
|
||||||
|
import org.jetbrains.jet.ConfigurationKind;
|
||||||
|
|
||||||
|
public class SourceInfoGenTest extends CodegenTestCase {
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSingleFileNamespace() {
|
||||||
|
String producer = "sourceInfo/foo1.kt";
|
||||||
|
loadFiles(producer);
|
||||||
|
assertEquals(producer, getProducerInfo("foo/FooPackage.class"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMultiFileNamespace() {
|
||||||
|
loadFiles("sourceInfo/foo1.kt", "sourceInfo/foo2.kt");
|
||||||
|
assertEquals(null, getProducerInfo("foo/FooPackage.class"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSingleClass() {
|
||||||
|
String producer = "sourceInfo/singleClass.kt";
|
||||||
|
loadFiles(producer);
|
||||||
|
assertEquals(producer, getProducerInfo("SingleClass.class"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getProducerInfo(String name) {
|
||||||
|
ClassReader classReader = new ClassReader(generateClassesInFile().asBytes(name));
|
||||||
|
|
||||||
|
final String [] producer = new String [1];
|
||||||
|
classReader.accept(new ClassVisitor(Opcodes.ASM4) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visitSource(String source, String debug) {
|
||||||
|
producer[0] = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 0);
|
||||||
|
return producer[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user