error descriptions in error objects
This commit is contained in:
@@ -6,6 +6,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
|||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.types.error.NamedFunctionDescriptorErrorImpl;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -17,11 +18,13 @@ public class ErrorUtils {
|
|||||||
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor("<ERROR MODULE>");
|
private static final ModuleDescriptor ERROR_MODULE = new ModuleDescriptor("<ERROR MODULE>");
|
||||||
|
|
||||||
|
|
||||||
private static final JetScope ERROR_SCOPE = new ErrorScope();
|
|
||||||
|
|
||||||
public static class ErrorScope implements JetScope {
|
public static class ErrorScope implements JetScope {
|
||||||
|
|
||||||
private ErrorScope() {}
|
private final String debugMessage;
|
||||||
|
|
||||||
|
private ErrorScope(String debugMessage) {
|
||||||
|
this.debugMessage = debugMessage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
public ClassifierDescriptor getClassifier(@NotNull String name) {
|
||||||
@@ -68,7 +71,7 @@ public class ErrorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
public Set<FunctionDescriptor> getFunctions(@NotNull String name) {
|
||||||
return ERROR_FUNCTION_GROUP;
|
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -116,17 +119,16 @@ public class ErrorUtils {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Set<FunctionDescriptor> ERROR_FUNCTION_GROUP = Collections.singleton(createErrorFunction(0, Collections.<JetType>emptyList()));
|
|
||||||
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(0, Collections.<JetType>emptyList()));
|
||||||
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.initialize(
|
ERROR_CLASS.initialize(
|
||||||
true, Collections.<TypeParameterDescriptor>emptyList(), Collections.<JetType>emptyList(), getErrorScope(), ERROR_CONSTRUCTOR_GROUP, ERROR_CONSTRUCTOR);
|
true, Collections.<TypeParameterDescriptor>emptyList(), Collections.<JetType>emptyList(), createErrorScope("ERROR_CLASS"), ERROR_CONSTRUCTOR_GROUP, ERROR_CONSTRUCTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JetScope getErrorScope() {
|
public static JetScope createErrorScope(String debugMessage) {
|
||||||
return ERROR_SCOPE;
|
return new ErrorScope(debugMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final JetType ERROR_PROPERTY_TYPE = createErrorType("<ERROR PROPERTY TYPE>");
|
private static final JetType ERROR_PROPERTY_TYPE = createErrorType("<ERROR PROPERTY TYPE>");
|
||||||
@@ -143,21 +145,9 @@ public class ErrorUtils {
|
|||||||
ERROR_PROPERTY_TYPE);
|
ERROR_PROPERTY_TYPE);
|
||||||
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 FunctionDescriptor createErrorFunction(List<TypeParameterDescriptor> typeParameters, List<JetType> positionedValueArgumentTypes) {
|
private static NamedFunctionDescriptor createErrorFunction(ErrorScope ownerScope) {
|
||||||
FunctionDescriptorImpl functionDescriptor = new NamedFunctionDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), "<ERROR FUNCTION>");
|
NamedFunctionDescriptorErrorImpl function = new NamedFunctionDescriptorErrorImpl(ownerScope);
|
||||||
return functionDescriptor.initialize(
|
function.initialize(
|
||||||
null,
|
|
||||||
ReceiverDescriptor.NO_RECEIVER,
|
|
||||||
typeParameters,
|
|
||||||
getValueParameters(functionDescriptor, positionedValueArgumentTypes),
|
|
||||||
createErrorType("<ERROR FUNCTION RETURN>"),
|
|
||||||
Modality.OPEN,
|
|
||||||
Visibility.INTERNAL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FunctionDescriptor createErrorFunction(int typeParameterCount, List<JetType> positionedValueParameterTypes) {
|
|
||||||
return new NamedFunctionDescriptorImpl(ERROR_CLASS, Collections.<AnnotationDescriptor>emptyList(), "<ERROR FUNCTION>").initialize(
|
|
||||||
null,
|
null,
|
||||||
ReceiverDescriptor.NO_RECEIVER,
|
ReceiverDescriptor.NO_RECEIVER,
|
||||||
Collections.<TypeParameterDescriptor>emptyList(), // TODO
|
Collections.<TypeParameterDescriptor>emptyList(), // TODO
|
||||||
@@ -166,6 +156,7 @@ public class ErrorUtils {
|
|||||||
Modality.OPEN,
|
Modality.OPEN,
|
||||||
Visibility.INTERNAL
|
Visibility.INTERNAL
|
||||||
);
|
);
|
||||||
|
return function;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConstructorDescriptor createErrorConstructor(int typeParameterCount, List<JetType> positionedValueParameterTypes) {
|
public static ConstructorDescriptor createErrorConstructor(int typeParameterCount, List<JetType> positionedValueParameterTypes) {
|
||||||
@@ -199,7 +190,7 @@ public class ErrorUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetType createErrorType(String debugMessage) {
|
public static JetType createErrorType(String debugMessage) {
|
||||||
return createErrorType(debugMessage, ERROR_SCOPE);
|
return createErrorType(debugMessage, createErrorScope(debugMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JetType createErrorType(String debugMessage, JetScope memberScope) {
|
private static JetType createErrorType(String debugMessage, JetScope memberScope) {
|
||||||
@@ -208,7 +199,7 @@ public class ErrorUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetType createErrorTypeWithCustomDebugName(String debugName) {
|
public static JetType createErrorTypeWithCustomDebugName(String debugName) {
|
||||||
return createErrorTypeWithCustomDebugName(ERROR_SCOPE, debugName);
|
return createErrorTypeWithCustomDebugName(createErrorScope(debugName), debugName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JetType createErrorTypeWithCustomDebugName(JetScope memberScope, String debugName) {
|
private static JetType createErrorTypeWithCustomDebugName(JetScope memberScope, String debugName) {
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package org.jetbrains.jet.lang.types.error;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptorImpl;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Stepan Koltsov
|
||||||
|
*/
|
||||||
|
public class NamedFunctionDescriptorErrorImpl extends NamedFunctionDescriptorImpl {
|
||||||
|
// used for diagnostic only
|
||||||
|
@NotNull
|
||||||
|
private final ErrorUtils.ErrorScope ownerScope;
|
||||||
|
|
||||||
|
public NamedFunctionDescriptorErrorImpl(ErrorUtils.ErrorScope ownerScope) {
|
||||||
|
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), "<ERROR FUNCTION>");
|
||||||
|
this.ownerScope = ownerScope;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user