descriptor name cannot be empty string
* add assertion * fix tests * #KT-1748 Fixed
This commit is contained in:
+5
-1
@@ -29,7 +29,11 @@ import java.util.List;
|
||||
public abstract class AbstractNamespaceDescriptorImpl extends DeclarationDescriptorImpl implements NamespaceDescriptor {
|
||||
private NamespaceType namespaceType;
|
||||
|
||||
public AbstractNamespaceDescriptorImpl(@NotNull NamespaceDescriptorParent containingDeclaration, List<AnnotationDescriptor> annotations, String name) {
|
||||
public AbstractNamespaceDescriptorImpl(
|
||||
@NotNull NamespaceDescriptorParent containingDeclaration,
|
||||
List<AnnotationDescriptor> annotations,
|
||||
@NotNull String name) {
|
||||
|
||||
super(containingDeclaration, annotations, name);
|
||||
|
||||
boolean rootAccordingToContainer = containingDeclaration instanceof ModuleDescriptor;
|
||||
|
||||
+5
@@ -34,6 +34,11 @@ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements
|
||||
|
||||
public DeclarationDescriptorImpl(@Nullable DeclarationDescriptor containingDeclaration, @NotNull List<AnnotationDescriptor> annotations, @NotNull String name) {
|
||||
super(annotations);
|
||||
|
||||
if (name.length() == 0) {
|
||||
throw new IllegalArgumentException("descriptor name cannot be empty string");
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
this.containingDeclaration = containingDeclaration;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,14 @@ public class JetNamespaceHeader extends JetReferenceExpression {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
PsiElement nameIdentifier = getNameIdentifier();
|
||||
return nameIdentifier == null ? "" : nameIdentifier.getText();
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return getName().length() == 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptorParent;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
@@ -85,12 +86,20 @@ public class NamespaceFactoryImpl implements NamespaceFactory {
|
||||
currentOwner = namespaceDescriptor;
|
||||
}
|
||||
|
||||
String name = JetPsiUtil.safeName(namespaceHeader.getName());
|
||||
NamespaceDescriptorImpl namespaceDescriptor = createNamespaceDescriptorIfNeeded(file, currentOwner, name, false,
|
||||
namespaceHeader.getLastPartExpression());
|
||||
NamespaceDescriptorImpl namespaceDescriptor;
|
||||
String name;
|
||||
if (namespaceHeader.isRoot()) {
|
||||
// again to register file in trace
|
||||
namespaceDescriptor = createNamespaceDescriptorIfNeeded(file, moduleDescriptor, "<root>", true, null);
|
||||
}
|
||||
else {
|
||||
name = namespaceHeader.getName();
|
||||
namespaceDescriptor = createNamespaceDescriptorIfNeeded(file, currentOwner, name, namespaceHeader.isRoot(),
|
||||
namespaceHeader.getLastPartExpression());
|
||||
|
||||
trace.record(BindingContext.NAMESPACE_IS_SRC, namespaceDescriptor, true);
|
||||
trace.record(RESOLUTION_SCOPE, namespaceHeader, outerScope);
|
||||
trace.record(BindingContext.NAMESPACE_IS_SRC, namespaceDescriptor, true);
|
||||
trace.record(RESOLUTION_SCOPE, namespaceHeader, outerScope);
|
||||
}
|
||||
|
||||
return namespaceDescriptor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user