KT-738 No kotlin type completion in extend class scope

This commit is contained in:
Nikolay Krasko
2011-12-02 17:45:14 +04:00
parent 47050a11d1
commit 65fb8d40b7
8 changed files with 112 additions and 3 deletions
@@ -9,6 +9,8 @@ import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
/**
* Stores a number of semantic services. Should be created once for each kotlin project.
*
* @author abreslav
*/
public class JetSemanticServices {
@@ -10,6 +10,9 @@ import java.util.Collections;
import java.util.List;
/**
* Type reference element.
* Underlying token is {@link org.jetbrains.jet.JetNodeTypes#TYPE_REFERENCE}
*
* @author max
*/
public class JetTypeReference extends JetElement {
@@ -36,6 +39,15 @@ public class JetTypeReference extends JetElement {
return findChildByClass(JetTypeElement.class);
}
/**
* Will return not null for type references with internal user type.
* There could be other JetTypeReferences, see parsing of in {@link org.jetbrains.jet.lang.parsing.JetParsing}
*/
@Nullable
public JetUserType getUserType() {
return findChildByClass(JetUserType.class);
}
public List<JetAnnotationEntry> getAnnotations() {
List<JetAnnotationEntry> answer = null;
for (JetAnnotation annotation : getAttributeAnnotations()) {
@@ -41,11 +41,15 @@ public interface BindingContext {
WritableSlice<JetExpression, ResolvedCall<FunctionDescriptor>> INDEXED_LVALUE_SET = Slices.createSimpleSlice();
WritableSlice<JetExpression, JetType> AUTOCAST = Slices.createSimpleSlice();
/** A scope where type of expression has been resolved */
WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = Slices.createSimpleSlice();
WritableSlice<JetExpression, Boolean> VARIABLE_REASSIGNMENT = Slices.createSimpleSetSlice();
WritableSlice<ValueParameterDescriptor, Boolean> AUTO_CREATED_IT = Slices.createSimpleSetSlice();
WritableSlice<JetExpression, DeclarationDescriptor> VARIABLE_ASSIGNMENT = Slices.createSimpleSlice();
/** Was type of current expression has been already resolved */
WritableSlice<JetExpression, Boolean> PROCESSED = Slices.createSimpleSetSlice();
WritableSlice<JetElement, Boolean> STATEMENT = Slices.createRemovableSetSlice();
WritableSlice<CallableMemberDescriptor, Boolean> DELEGATED = Slices.createRemovableSetSlice();
@@ -49,11 +49,20 @@ public class TypeResolver {
JetTypeElement typeElement = typeReference.getTypeElement();
JetType type = resolveTypeElement(scope, annotations, typeElement, false);
trace.record(BindingContext.TYPE, typeReference, type);
final JetUserType jetUserType = typeReference.getUserType();
if (jetUserType != null) {
final JetSimpleNameExpression referenceExpression = jetUserType.getReferenceExpression();
trace.record(BindingContext.RESOLUTION_SCOPE, referenceExpression, scope);
}
return type;
}
@NotNull
private JetType resolveTypeElement(final JetScope scope, final List<AnnotationDescriptor> annotations, JetTypeElement typeElement, final boolean nullable) {
private JetType resolveTypeElement(final JetScope scope, final List<AnnotationDescriptor> annotations,
JetTypeElement typeElement, final boolean nullable) {
final JetType[] result = new JetType[1];
if (typeElement != null) {
typeElement.accept(new JetVisitorVoid() {
@@ -70,6 +79,7 @@ public class TypeResolver {
resolveTypeProjections(scope, ErrorUtils.createErrorType("No type").getConstructor(), type.getTypeArguments());
return;
}
if (classifierDescriptor instanceof TypeParameterDescriptor) {
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) classifierDescriptor;