Sort out root namespace names

This commit is contained in:
Andrey Breslav
2012-05-25 18:58:05 +04:00
parent ff7be5b7c3
commit 7ce4d427f0
3 changed files with 5 additions and 4 deletions
@@ -79,10 +79,10 @@ public class JetNamespaceHeader extends JetReferenceExpression {
return nameIdentifier == null ? "" : nameIdentifier.getText(); return nameIdentifier == null ? "" : nameIdentifier.getText();
} }
@Nullable @NotNull
public Name getNameAsName() { public Name getNameAsName() {
PsiElement nameIdentifier = getNameIdentifier(); PsiElement nameIdentifier = getNameIdentifier();
return nameIdentifier == null ? null : Name.identifier(nameIdentifier.getText()); return nameIdentifier == null ? JetPsiUtil.ROOT_NAMESPACE_NAME : Name.identifier(nameIdentifier.getText());
} }
public boolean isRoot() { public boolean isRoot() {
@@ -40,6 +40,7 @@ import java.util.Set;
public class JetPsiUtil { public class JetPsiUtil {
public static final Name NO_NAME_PROVIDED = Name.special("<no name provided>"); public static final Name NO_NAME_PROVIDED = Name.special("<no name provided>");
public static final Name ROOT_NAMESPACE_NAME = Name.special("<root namespace>");
private JetPsiUtil() { private JetPsiUtil() {
} }
@@ -17,7 +17,7 @@
package org.jetbrains.jet.lang.resolve; package org.jetbrains.jet.lang.resolve;
import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetElement;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.NamespaceType; import org.jetbrains.jet.lang.types.NamespaceType;
@@ -27,6 +27,6 @@ import org.jetbrains.jet.lang.types.NamespaceType;
public class JetModuleUtil { public class JetModuleUtil {
public static NamespaceType getRootNamespaceType(JetElement expression) { public static NamespaceType getRootNamespaceType(JetElement expression) {
// TODO: this is a stub: at least the modules' root namespaces must be indexed here // TODO: this is a stub: at least the modules' root namespaces must be indexed here
return new NamespaceType(Name.special("<namespace_root>"), JetScope.EMPTY); return new NamespaceType(JetPsiUtil.ROOT_NAMESPACE_NAME, JetScope.EMPTY);
} }
} }