Minor, remove unused methods from ErrorUtils

Inline methods, annotate with NotNull
This commit is contained in:
Alexander Udalov
2013-09-16 16:14:05 +04:00
parent b7f1e61be9
commit dea1e6650f
@@ -25,7 +25,6 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
import org.jetbrains.jet.lang.resolve.ImportPath; import org.jetbrains.jet.lang.resolve.ImportPath;
import org.jetbrains.jet.lang.resolve.name.LabelName; import org.jetbrains.jet.lang.resolve.name.LabelName;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
@@ -34,7 +33,10 @@ import org.jetbrains.jet.lang.types.error.ErrorClassDescriptor;
import org.jetbrains.jet.lang.types.error.ErrorSimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.types.error.ErrorSimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.util.*; import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class ErrorUtils { public class ErrorUtils {
@@ -75,10 +77,9 @@ public class ErrorUtils {
public static class ErrorScope implements JetScope { public static class ErrorScope implements JetScope {
private final String debugMessage; private final String debugMessage;
private ErrorScope(String debugMessage) { private ErrorScope(@NotNull String debugMessage) {
this.debugMessage = debugMessage; this.debugMessage = debugMessage;
} }
@@ -134,7 +135,7 @@ public class ErrorUtils {
@NotNull @NotNull
@Override @Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(LabelName labelName) { public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName) {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -164,7 +165,7 @@ public class ErrorUtils {
private static class ThrowingScope implements JetScope { private static class ThrowingScope implements JetScope {
private final String debugMessage; private final String debugMessage;
private ThrowingScope(String message) { private ThrowingScope(@NotNull String message) {
debugMessage = message; debugMessage = message;
} }
@@ -267,27 +268,31 @@ public class ErrorUtils {
} }
} }
private static final Set<ConstructorDescriptor> ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor(0, Collections.<JetType>emptyList())); private static final Set<ConstructorDescriptor> ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor());
private static final ConstructorDescriptor ERROR_CONSTRUCTOR = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), true); private static final ConstructorDescriptor ERROR_CONSTRUCTOR = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), true);
static { static {
ERROR_CLASS.initializeErrorClass(); ERROR_CLASS.initializeErrorClass();
} }
@NotNull @NotNull
public static Set<ConstructorDescriptor> getErrorConstructorGroup() { public static Set<ConstructorDescriptor> getErrorConstructorGroup() {
return ERROR_CONSTRUCTOR_GROUP; return ERROR_CONSTRUCTOR_GROUP;
} }
@NotNull
public static ConstructorDescriptor getErrorConstructor() { public static ConstructorDescriptor getErrorConstructor() {
return ERROR_CONSTRUCTOR; return ERROR_CONSTRUCTOR;
} }
public static JetScope createErrorScope(String debugMessage) { @NotNull
public static JetScope createErrorScope(@NotNull String debugMessage) {
return createErrorScope(debugMessage, false); return createErrorScope(debugMessage, false);
} }
public static JetScope createErrorScope(String debugMessage, boolean throwExceptions) { @NotNull
public static JetScope createErrorScope(@NotNull String debugMessage, boolean throwExceptions) {
if (throwExceptions) { if (throwExceptions) {
return new ThrowingScope(debugMessage); return new ThrowingScope(debugMessage);
} }
@@ -308,7 +313,8 @@ public class ErrorUtils {
CallableMemberDescriptor.Kind.DECLARATION); CallableMemberDescriptor.Kind.DECLARATION);
private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY); private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY);
private static SimpleFunctionDescriptor createErrorFunction(ErrorScope ownerScope) { @NotNull
private static SimpleFunctionDescriptor createErrorFunction(@NotNull ErrorScope ownerScope) {
ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ownerScope); ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ownerScope);
function.initialize( function.initialize(
null, null,
@@ -323,7 +329,8 @@ public class ErrorUtils {
return function; return function;
} }
public static ConstructorDescriptor createErrorConstructor(int typeParameterCount, List<JetType> positionedValueParameterTypes) { @NotNull
private static ConstructorDescriptor createErrorConstructor() {
ConstructorDescriptorImpl r = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false); ConstructorDescriptorImpl r = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false);
r.initialize( r.initialize(
Collections.<TypeParameterDescriptor>emptyList(), // TODO Collections.<TypeParameterDescriptor>emptyList(), // TODO
@@ -334,37 +341,18 @@ public class ErrorUtils {
return r; return r;
} }
private static final JetType ERROR_PARAMETER_TYPE = createErrorType("<ERROR VALUE_PARAMETER TYPE>"); @NotNull
private static List<ValueParameterDescriptor> getValueParameters(FunctionDescriptor functionDescriptor, List<JetType> argumentTypes) { public static JetType createErrorType(@NotNull String debugMessage) {
List<ValueParameterDescriptor> result = new ArrayList<ValueParameterDescriptor>(); return createErrorTypeWithCustomDebugName(createErrorScope(debugMessage), "[ERROR : " + debugMessage + "]");
for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) {
result.add(new ValueParameterDescriptorImpl(
functionDescriptor,
i,
Collections.<AnnotationDescriptor>emptyList(),
Name.special("<ERROR VALUE_PARAMETER>"),
ERROR_PARAMETER_TYPE,
false,
null));
}
return result;
} }
@NotNull @NotNull
public static JetType createErrorType(String debugMessage) { public static JetType createErrorTypeWithCustomDebugName(@NotNull String debugName) {
return createErrorType(debugMessage, createErrorScope(debugMessage));
}
private static JetType createErrorType(String debugMessage, JetScope memberScope) {
return createErrorTypeWithCustomDebugName(memberScope, "[ERROR : " + debugMessage + "]");
}
@NotNull
public static JetType createErrorTypeWithCustomDebugName(String debugName) {
return createErrorTypeWithCustomDebugName(createErrorScope(debugName), debugName); return createErrorTypeWithCustomDebugName(createErrorScope(debugName), debugName);
} }
private static JetType createErrorTypeWithCustomDebugName(JetScope memberScope, String debugName) { @NotNull
private static JetType createErrorTypeWithCustomDebugName(@NotNull JetScope memberScope, @NotNull String debugName) {
TypeConstructorImpl constructor = TypeConstructorImpl constructor =
new ErrorTypeConstructor(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false, debugName, new ErrorTypeConstructor(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), false, debugName,
Collections.<TypeParameterDescriptorImpl>emptyList(), Collections.<TypeParameterDescriptorImpl>emptyList(),
@@ -372,10 +360,6 @@ public class ErrorUtils {
return new ErrorTypeImpl(constructor, memberScope); return new ErrorTypeImpl(constructor, memberScope);
} }
public static JetType createWrongVarianceErrorType(TypeProjection value) {
return createErrorType(value + " is not allowed here", value.getType().getMemberScope());
}
@NotNull @NotNull
public static ClassDescriptor getErrorClass() { public static ClassDescriptor getErrorClass() {
return ERROR_CLASS; return ERROR_CLASS;
@@ -411,11 +395,10 @@ public class ErrorUtils {
} }
private static class ErrorTypeImpl implements JetType { private static class ErrorTypeImpl implements JetType {
private final TypeConstructor constructor; private final TypeConstructor constructor;
private final JetScope memberScope; private final JetScope memberScope;
private ErrorTypeImpl(TypeConstructor constructor, JetScope memberScope) {
private ErrorTypeImpl(@NotNull TypeConstructor constructor, @NotNull JetScope memberScope) {
this.constructor = constructor; this.constructor = constructor;
this.memberScope = memberScope; this.memberScope = memberScope;
} }
@@ -459,6 +442,7 @@ public class ErrorUtils {
} }
} }
@NotNull
public static ModuleDescriptor getErrorModule() { public static ModuleDescriptor getErrorModule() {
return ERROR_MODULE; return ERROR_MODULE;
} }