Extract SpecialNames utility class
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getClassObjectName;
|
||||
import static org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName;
|
||||
|
||||
public class JavaEnumClassObjectDescriptor extends MutableClassDescriptorLite {
|
||||
private ConstructorDescriptor constructor;
|
||||
|
||||
+2
-2
@@ -50,8 +50,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getClassObjectName;
|
||||
import static org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule.INCLUDE_KOTLIN_SOURCES;
|
||||
import static org.jetbrains.jet.lang.resolve.name.SpecialNames.getClassObjectName;
|
||||
|
||||
public final class JavaClassResolver {
|
||||
@NotNull
|
||||
@@ -401,7 +401,7 @@ public final class JavaClassResolver {
|
||||
if (JvmAbi.CLASS_OBJECT_CLASS_NAME.equals(segment.asString())) {
|
||||
assert !correctedSegments.isEmpty();
|
||||
Name previous = correctedSegments.get(correctedSegments.size() - 1);
|
||||
correctedSegments.add(DescriptorUtils.getClassObjectName(previous));
|
||||
correctedSegments.add(getClassObjectName(previous));
|
||||
}
|
||||
else {
|
||||
correctedSegments.add(segment);
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.name.SpecialNames;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.FilteringScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -40,8 +41,6 @@ import java.util.*;
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
public class DescriptorUtils {
|
||||
public static final Name ROOT_NAMESPACE_NAME = Name.special("<root namespace>");
|
||||
|
||||
private DescriptorUtils() {
|
||||
}
|
||||
|
||||
@@ -306,11 +305,6 @@ public class DescriptorUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Name getClassObjectName(@NotNull Name className) {
|
||||
return Name.special("<class-object-for-" + className.asString() + ">");
|
||||
}
|
||||
|
||||
public static boolean isEnumClassObject(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.CLASS_OBJECT) {
|
||||
DeclarationDescriptor containing = descriptor.getContainingDeclaration();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.lang.resolve.name;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpecialNames {
|
||||
public static final Name NO_NAME_PROVIDED = Name.special("<no name provided>");
|
||||
public static final Name ROOT_NAMESPACE = Name.special("<root namespace>");
|
||||
|
||||
private SpecialNames() {}
|
||||
|
||||
@NotNull
|
||||
public static Name getClassObjectName(@NotNull Name className) {
|
||||
return Name.special("<class-object-for-" + className.asString() + ">");
|
||||
}
|
||||
}
|
||||
@@ -28,14 +28,15 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.NamespaceDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.name.SpecialNames;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -163,7 +164,7 @@ public class KotlinBuiltIns {
|
||||
|
||||
private static void loadBuiltIns(@NotNull ModuleDescriptorImpl module) throws IOException {
|
||||
NamespaceDescriptorImpl rootNamespace =
|
||||
new NamespaceDescriptorImpl(module, Collections.<AnnotationDescriptor>emptyList(), DescriptorUtils.ROOT_NAMESPACE_NAME);
|
||||
new NamespaceDescriptorImpl(module, Collections.<AnnotationDescriptor>emptyList(), SpecialNames.ROOT_NAMESPACE);
|
||||
rootNamespace.initialize(
|
||||
new WritableScopeImpl(JetScope.EMPTY, rootNamespace, RedeclarationHandler.DO_NOTHING, "members of root namespace"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user