From dea1e6650fd46a168e4ae73e7b98b201cf244422 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 16 Sep 2013 16:14:05 +0400 Subject: [PATCH] Minor, remove unused methods from ErrorUtils Inline methods, annotate with NotNull --- .../jetbrains/jet/lang/types/ErrorUtils.java | 70 +++++++------------ 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java index 373410127bf..e1915513038 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -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.PropertyDescriptorImpl; 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.name.LabelName; 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.lang.KotlinBuiltIns; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; public class ErrorUtils { @@ -75,10 +77,9 @@ public class ErrorUtils { public static class ErrorScope implements JetScope { - private final String debugMessage; - private ErrorScope(String debugMessage) { + private ErrorScope(@NotNull String debugMessage) { this.debugMessage = debugMessage; } @@ -134,7 +135,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getDeclarationsByLabel(LabelName labelName) { + public Collection getDeclarationsByLabel(@NotNull LabelName labelName) { return Collections.emptyList(); } @@ -164,7 +165,7 @@ public class ErrorUtils { private static class ThrowingScope implements JetScope { private final String debugMessage; - private ThrowingScope(String message) { + private ThrowingScope(@NotNull String message) { debugMessage = message; } @@ -267,27 +268,31 @@ public class ErrorUtils { } } - private static final Set ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor(0, Collections.emptyList())); + private static final Set ERROR_CONSTRUCTOR_GROUP = Collections.singleton(createErrorConstructor()); private static final ConstructorDescriptor ERROR_CONSTRUCTOR = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.emptyList(), true); static { ERROR_CLASS.initializeErrorClass(); } + @NotNull public static Set getErrorConstructorGroup() { return ERROR_CONSTRUCTOR_GROUP; } + @NotNull public static ConstructorDescriptor getErrorConstructor() { return ERROR_CONSTRUCTOR; } - public static JetScope createErrorScope(String debugMessage) { + @NotNull + public static JetScope createErrorScope(@NotNull String debugMessage) { return createErrorScope(debugMessage, false); } - public static JetScope createErrorScope(String debugMessage, boolean throwExceptions) { + @NotNull + public static JetScope createErrorScope(@NotNull String debugMessage, boolean throwExceptions) { if (throwExceptions) { return new ThrowingScope(debugMessage); } @@ -308,7 +313,8 @@ public class ErrorUtils { CallableMemberDescriptor.Kind.DECLARATION); private static final Set 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); function.initialize( null, @@ -323,7 +329,8 @@ public class ErrorUtils { return function; } - public static ConstructorDescriptor createErrorConstructor(int typeParameterCount, List positionedValueParameterTypes) { + @NotNull + private static ConstructorDescriptor createErrorConstructor() { ConstructorDescriptorImpl r = new ConstructorDescriptorImpl(ERROR_CLASS, Collections.emptyList(), false); r.initialize( Collections.emptyList(), // TODO @@ -334,37 +341,18 @@ public class ErrorUtils { return r; } - private static final JetType ERROR_PARAMETER_TYPE = createErrorType(""); - private static List getValueParameters(FunctionDescriptor functionDescriptor, List argumentTypes) { - List result = new ArrayList(); - for (int i = 0, argumentTypesSize = argumentTypes.size(); i < argumentTypesSize; i++) { - result.add(new ValueParameterDescriptorImpl( - functionDescriptor, - i, - Collections.emptyList(), - Name.special(""), - ERROR_PARAMETER_TYPE, - false, - null)); - } - return result; + @NotNull + public static JetType createErrorType(@NotNull String debugMessage) { + return createErrorTypeWithCustomDebugName(createErrorScope(debugMessage), "[ERROR : " + debugMessage + "]"); } @NotNull - public static JetType createErrorType(String debugMessage) { - 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) { + public static JetType createErrorTypeWithCustomDebugName(@NotNull String 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 = new ErrorTypeConstructor(ERROR_CLASS, Collections.emptyList(), false, debugName, Collections.emptyList(), @@ -372,10 +360,6 @@ public class ErrorUtils { return new ErrorTypeImpl(constructor, memberScope); } - public static JetType createWrongVarianceErrorType(TypeProjection value) { - return createErrorType(value + " is not allowed here", value.getType().getMemberScope()); - } - @NotNull public static ClassDescriptor getErrorClass() { return ERROR_CLASS; @@ -411,11 +395,10 @@ public class ErrorUtils { } private static class ErrorTypeImpl implements JetType { - private final TypeConstructor constructor; - private final JetScope memberScope; - private ErrorTypeImpl(TypeConstructor constructor, JetScope memberScope) { + + private ErrorTypeImpl(@NotNull TypeConstructor constructor, @NotNull JetScope memberScope) { this.constructor = constructor; this.memberScope = memberScope; } @@ -459,6 +442,7 @@ public class ErrorUtils { } } + @NotNull public static ModuleDescriptor getErrorModule() { return ERROR_MODULE; }