StackOverlowes fixed with FQNames remembered in trace
This commit is contained in:
@@ -8,6 +8,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -103,4 +104,38 @@ public class JetPsiUtil {
|
||||
return unquoteIdentifier(quoted);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFQName(JetNamespace jetNamespace) {
|
||||
JetNamespace parent = PsiTreeUtil.getParentOfType(jetNamespace, JetNamespace.class);
|
||||
if (parent != null) {
|
||||
String parentFQName = getFQName(parent);
|
||||
if (parentFQName.length() > 0) {
|
||||
return parentFQName + "." + getFQName(jetNamespace.getHeader());
|
||||
}
|
||||
}
|
||||
return getFQName(jetNamespace.getHeader()); // TODO: Must include module root namespace
|
||||
}
|
||||
|
||||
private static String getFQName(JetNamespaceHeader header) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (Iterator<JetSimpleNameExpression> iterator = header.getParentNamespaceNames().iterator(); iterator.hasNext(); ) {
|
||||
JetSimpleNameExpression nameExpression = iterator.next();
|
||||
builder.append(nameExpression.getReferencedName());
|
||||
builder.append(".");
|
||||
}
|
||||
// PsiElement nameIdentifier = header.getNameIdentifier();
|
||||
builder.append(header.getName());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String getFQName(JetClass jetClass) {
|
||||
JetNamedDeclaration parent = PsiTreeUtil.getParentOfType(jetClass, JetNamespace.class, JetClass.class);
|
||||
if (parent instanceof JetNamespace) {
|
||||
return getFQName(((JetNamespace) parent)) + "." + jetClass.getName();
|
||||
}
|
||||
if (parent instanceof JetClass) {
|
||||
return getFQName(((JetClass) parent)) + "." + jetClass.getName();
|
||||
}
|
||||
return jetClass.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.jetbrains.jet.util.slicedmap.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.jetbrains.jet.util.slicedmap.RewritePolicy.DO_NOTHING;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
@@ -26,12 +28,12 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<JetExpression, CompileTimeConstant<?>> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
|
||||
WritableSlice<JetTypeReference, JetType> TYPE = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, JetType> EXPRESSION_TYPE = new BasicWritableSlice<JetExpression, JetType>(RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetExpression, JetType> EXPRESSION_TYPE = new BasicWritableSlice<JetExpression, JetType>(DO_NOTHING);
|
||||
|
||||
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>> RESOLVED_CALL = new BasicWritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>>(RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
|
||||
WritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>> RESOLVED_CALL = new BasicWritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>>(DO_NOTHING);
|
||||
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>> AMBIGUOUS_REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>>(RewritePolicy.DO_NOTHING);
|
||||
WritableSlice<JetReferenceExpression, Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>> AMBIGUOUS_REFERENCE_TARGET = new BasicWritableSlice<JetReferenceExpression, Collection<? extends ResolvedCallImpl<? extends DeclarationDescriptor>>>(DO_NOTHING);
|
||||
|
||||
WritableSlice<JetExpression, FunctionDescriptor> LOOP_RANGE_ITERATOR = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, CallableDescriptor> LOOP_RANGE_HAS_NEXT = Slices.createSimpleSlice();
|
||||
@@ -61,7 +63,7 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<Box<DeferredType>, Boolean> DEFERRED_TYPE = Slices.createCollectiveSetSlice();
|
||||
|
||||
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new Slices.SetSlice<PropertyDescriptor>(RewritePolicy.DO_NOTHING) {
|
||||
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new Slices.SetSlice<PropertyDescriptor>(DO_NOTHING) {
|
||||
@Override
|
||||
public Boolean computeValue(SlicedMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) {
|
||||
backingFieldRequired = valueNotFound ? false : backingFieldRequired;
|
||||
@@ -92,7 +94,7 @@ public interface BindingContext {
|
||||
};
|
||||
WritableSlice<PropertyDescriptor, Boolean> IS_INITIALIZED = Slices.createSimpleSetSlice();
|
||||
|
||||
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new Slices.SetSlice<JetFunctionLiteralExpression>(RewritePolicy.DO_NOTHING) {
|
||||
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new Slices.SetSlice<JetFunctionLiteralExpression>(DO_NOTHING) {
|
||||
@Override
|
||||
public Boolean computeValue(SlicedMap map, JetFunctionLiteralExpression expression, Boolean isBlock, boolean valueNotFound) {
|
||||
isBlock = valueNotFound ? false : isBlock;
|
||||
@@ -136,6 +138,9 @@ public interface BindingContext {
|
||||
WritableSlice<JetReferenceExpression, PsiElement> LABEL_TARGET = Slices.<JetReferenceExpression, PsiElement>sliceBuilder().build();
|
||||
WritableSlice<JetParameter, PropertyDescriptor> VALUE_PARAMETER_AS_PROPERTY = Slices.<JetParameter, PropertyDescriptor>sliceBuilder().build();
|
||||
|
||||
WritableSlice<String, ClassDescriptor> FQNAME_TO_CLASS_DESCRIPTOR = new BasicWritableSlice<String, ClassDescriptor>(DO_NOTHING);
|
||||
WritableSlice<String, NamespaceDescriptor> FQNAME_TO_NAMESPACE_DESCRIPTOR = new BasicWritableSlice<String, NamespaceDescriptor>(DO_NOTHING);
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
@Deprecated // This field is needed only for the side effects of its initializer
|
||||
Void _static_initializer = BasicWritableSlice.initSliceDebugNames(BindingContext.class);
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.*;
|
||||
@@ -91,6 +90,7 @@ public class TypeHierarchyResolver {
|
||||
@Override
|
||||
public void visitClass(JetClass klass) {
|
||||
MutableClassDescriptor mutableClassDescriptor = new MutableClassDescriptor(context.getTrace(), owner, outerScope, getClassKind(klass));
|
||||
context.getTrace().record(FQNAME_TO_CLASS_DESCRIPTOR, JetPsiUtil.getFQName(klass), mutableClassDescriptor);
|
||||
|
||||
if (klass.hasModifier(JetTokens.ENUM_KEYWORD)) {
|
||||
MutableClassDescriptor classObjectDescriptor = new MutableClassDescriptor(context.getTrace(), mutableClassDescriptor, outerScope, ClassKind.OBJECT);
|
||||
@@ -217,6 +217,7 @@ public class TypeHierarchyResolver {
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO: annotations
|
||||
name
|
||||
);
|
||||
context.getTrace().record(FQNAME_TO_NAMESPACE_DESCRIPTOR, DescriptorUtils.getFQName(namespaceDescriptor), namespaceDescriptor);
|
||||
WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope");
|
||||
scope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
namespaceDescriptor.initialize(scope);
|
||||
|
||||
Reference in New Issue
Block a user