Rename Namer -> DescriptorNamer & Move it to the top level
This commit is contained in:
committed by
Alexander Udalov
parent
c0707628e8
commit
962092cfae
+3
-3
@@ -40,7 +40,7 @@ public class ClassSerializationUtil {
|
||||
@NotNull
|
||||
@Override
|
||||
public DescriptorSerializer getSerializerFor(@NotNull ClassDescriptor classDescriptor) {
|
||||
return new DescriptorSerializer(NameTable.Namer.DEFAULT);
|
||||
return new DescriptorSerializer(DescriptorNamer.DEFAULT);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ClassSerializationUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ClassId getClassId(@NotNull ClassDescriptor classDescriptor, @NotNull NameTable.Namer namer) {
|
||||
public static ClassId getClassId(@NotNull ClassDescriptor classDescriptor, @NotNull DescriptorNamer namer) {
|
||||
DeclarationDescriptor containingDeclaration = classDescriptor.getContainingDeclaration();
|
||||
if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) containingDeclaration;
|
||||
@@ -97,7 +97,7 @@ public class ClassSerializationUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FqName getPackageFqName(@NotNull NamespaceDescriptor namespaceDescriptor, @NotNull NameTable.Namer namer) {
|
||||
public static FqName getPackageFqName(@NotNull NamespaceDescriptor namespaceDescriptor, @NotNull DescriptorNamer namer) {
|
||||
if (DescriptorUtils.isRootNamespace(namespaceDescriptor)) return FqName.ROOT;
|
||||
|
||||
NamespaceDescriptor parent = (NamespaceDescriptor) namespaceDescriptor.getContainingDeclaration();
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.descriptors.serialization;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public interface DescriptorNamer {
|
||||
DescriptorNamer DEFAULT = new DescriptorNamer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getClassName(@NotNull ClassDescriptor classDescriptor) {
|
||||
return classDescriptor.getName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getPackageName(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
return namespaceDescriptor.getName();
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
Name getClassName(@NotNull ClassDescriptor classDescriptor);
|
||||
|
||||
@NotNull
|
||||
Name getPackageName(@NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
}
|
||||
+2
-2
@@ -46,11 +46,11 @@ public class DescriptorSerializer {
|
||||
private final Interner<TypeParameterDescriptor> typeParameters;
|
||||
private final Predicate<ClassDescriptor> isSpecial;
|
||||
|
||||
public DescriptorSerializer(@NotNull NameTable.Namer namer) {
|
||||
public DescriptorSerializer(@NotNull DescriptorNamer namer) {
|
||||
this(namer, Predicates.<ClassDescriptor>alwaysFalse());
|
||||
}
|
||||
|
||||
public DescriptorSerializer(@NotNull NameTable.Namer namer, @NotNull Predicate<ClassDescriptor> isSpecial) {
|
||||
public DescriptorSerializer(@NotNull DescriptorNamer namer, @NotNull Predicate<ClassDescriptor> isSpecial) {
|
||||
this(new NameTable(namer), new Interner<TypeParameterDescriptor>(), isSpecial);
|
||||
}
|
||||
|
||||
|
||||
+2
-24
@@ -51,34 +51,12 @@ public class NameTable {
|
||||
}
|
||||
};
|
||||
|
||||
public interface Namer {
|
||||
Namer DEFAULT = new NameTable.Namer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getClassName(@NotNull ClassDescriptor classDescriptor) {
|
||||
return classDescriptor.getName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getPackageName(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
return namespaceDescriptor.getName();
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
Name getClassName(@NotNull ClassDescriptor classDescriptor);
|
||||
|
||||
@NotNull
|
||||
Name getPackageName(@NotNull NamespaceDescriptor namespaceDescriptor);
|
||||
}
|
||||
|
||||
private final Namer namer;
|
||||
private final DescriptorNamer namer;
|
||||
|
||||
private final Interner<String> simpleNames = new Interner<String>();
|
||||
private final Interner<QualifiedName.Builder> qualifiedNames = new Interner<QualifiedName.Builder>(QUALIFIED_NAME_BUILDER_HASHING);
|
||||
|
||||
public NameTable(@NotNull Namer namer) {
|
||||
public NameTable(@NotNull DescriptorNamer namer) {
|
||||
this.namer = namer;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package org.jetbrains.jet.lang.types.lang;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.descriptors.serialization.ClassId;
|
||||
import org.jetbrains.jet.descriptors.serialization.ClassSerializationUtil;
|
||||
import org.jetbrains.jet.descriptors.serialization.NameTable;
|
||||
import org.jetbrains.jet.descriptors.serialization.DescriptorNamer;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassKind;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
@@ -20,7 +20,7 @@ public class BuiltInsSerializationUtil {
|
||||
public static final String CLASS_NAMES_FILE_NAME = ".kotlin_class_names";
|
||||
public static final Name CLASS_OBJECT_NAME = Name.identifier("object");
|
||||
|
||||
public static final NameTable.Namer BUILTINS_NAMER = new NameTable.Namer() {
|
||||
public static final DescriptorNamer BUILTINS_NAMER = new DescriptorNamer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getClassName(@NotNull ClassDescriptor classDescriptor) {
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ import static org.jetbrains.jet.descriptors.serialization.descriptors.Annotation
|
||||
public abstract class AbstractDescriptorSerializationTest extends KotlinTestWithEnvironment {
|
||||
|
||||
public static final Name TEST_PACKAGE_NAME = Name.identifier("test");
|
||||
public static final NameTable.Namer JAVA_NAMER = new NameTable.Namer() {
|
||||
public static final DescriptorNamer JAVA_NAMER = new DescriptorNamer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getClassName(@NotNull ClassDescriptor classDescriptor) {
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ import static org.jetbrains.jet.descriptors.serialization.ClassSerializationUtil
|
||||
public class BuiltinsDeserializationTest extends KotlinTestWithEnvironment {
|
||||
|
||||
private static final Name CLASS_OBJECT_NAME = Name.special("<class object>");
|
||||
private static final NameTable.Namer NAMER = new NameTable.Namer() {
|
||||
private static final DescriptorNamer NAMER = new DescriptorNamer() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getClassName(@NotNull ClassDescriptor classDescriptor) {
|
||||
|
||||
Reference in New Issue
Block a user