resolve methods renamed
This commit is contained in:
@@ -250,7 +250,7 @@ public class ExpressionCodegen extends JetVisitor {
|
||||
|
||||
@Override
|
||||
public void visitReferenceExpression(JetReferenceExpression expression) {
|
||||
final DeclarationDescriptor descriptor = bindingContext.resolve(expression);
|
||||
final DeclarationDescriptor descriptor = bindingContext.resolveReferenceExpression(expression);
|
||||
if (descriptor instanceof ValueParameterDescriptor) {
|
||||
final int index = ((ValueParameterDescriptor) descriptor).getIndex();
|
||||
v.visitVarInsn(Opcodes.ALOAD, index); // TODO +1 for non-static methods
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.jet.lang;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.jet.lang.resolve.ClassDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.types.BindingTrace;
|
||||
import org.jetbrains.jet.lang.types.JetStandardLibrary;
|
||||
@@ -17,6 +18,10 @@ public class JetSemanticServices {
|
||||
this.typeInferrer = new JetTypeInferrer(BindingTrace.DUMMY, this);
|
||||
}
|
||||
|
||||
public JetSemanticServices(Project project) {
|
||||
this(new JetStandardLibrary(project));
|
||||
}
|
||||
|
||||
public JetStandardLibrary getStandardLibrary() {
|
||||
return standardLibrary;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,11 @@ import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalyzer;
|
||||
import org.jetbrains.jet.lang.types.Type;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -12,10 +16,21 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
public class JetPsiChecker implements Annotator {
|
||||
|
||||
@Override
|
||||
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) {
|
||||
if (element instanceof JetFile) {
|
||||
JetFile file = (JetFile) element;
|
||||
// JetScope jetScope = FileContentsResolver.INSTANCE.resolveFileContents(JetStandardClasses.STANDARD_CLASSES, file);
|
||||
JetSemanticServices semanticServices = new JetSemanticServices(element.getProject());
|
||||
final BindingContext bindingContext = new TopDownAnalyzer(semanticServices).process(semanticServices.getStandardLibrary().getLibraryScope(), file.getRootNamespace().getDeclarations());
|
||||
file.getRootNamespace().accept(new JetVisitor() {
|
||||
@Override
|
||||
public void visitClass(JetClass klass) {
|
||||
for (JetDelegationSpecifier specifier : klass.getDelegationSpecifiers()) {
|
||||
JetTypeReference typeReference = specifier.getTypeReference();
|
||||
Type type = bindingContext.resolveTypeReference(typeReference);
|
||||
holder.createInfoAnnotation(typeReference, type.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ public interface BindingContext {
|
||||
FunctionDescriptor getFunctionDescriptor(JetFunction declaration);
|
||||
PropertyDescriptor getPropertyDescriptor(JetProperty declaration);
|
||||
|
||||
Type getType(JetTypeReference typeReference);
|
||||
Type getExpressionType(JetExpression expression);
|
||||
DeclarationDescriptor resolve(JetReferenceExpression referenceExpression);
|
||||
|
||||
JetScope getTopLevelScope();
|
||||
|
||||
DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression);
|
||||
Type resolveTypeReference(JetTypeReference typeReference);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TopDownAnalyzer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType(JetTypeReference typeReference) {
|
||||
public Type resolveTypeReference(JetTypeReference typeReference) {
|
||||
return types.get(typeReference);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TopDownAnalyzer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeclarationDescriptor resolve(JetReferenceExpression referenceExpression) {
|
||||
public DeclarationDescriptor resolveReferenceExpression(JetReferenceExpression referenceExpression) {
|
||||
return resolutionResults.get(referenceExpression);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
val foo
|
||||
val foo = 1
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class JetResolveTest extends LightDaemonAnalyzerTestCase {
|
||||
assertEquals(library.getIntType(), expressionType);
|
||||
|
||||
{
|
||||
DeclarationDescriptor resolve = bindingContext.resolve((JetReferenceExpression) fooDecl.getBodyExpression());
|
||||
DeclarationDescriptor resolve = bindingContext.resolveReferenceExpression((JetReferenceExpression) fooDecl.getBodyExpression());
|
||||
assertSame(bindingContext.getFunctionDescriptor(fooDecl).getUnsubstitutedValueParameters().get(0), resolve);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class JetResolveTest extends LightDaemonAnalyzerTestCase {
|
||||
JetFunction fooBDecl = (JetFunction) classADecl.getDeclarations().get(2);
|
||||
JetCallExpression fooBBody = (JetCallExpression) fooBDecl.getBodyExpression();
|
||||
JetReferenceExpression refToFoo = (JetReferenceExpression) fooBBody.getCalleeExpression();
|
||||
FunctionDescriptor mustBeFoo = (FunctionDescriptor) bindingContext.resolve(refToFoo);
|
||||
FunctionDescriptor mustBeFoo = (FunctionDescriptor) bindingContext.resolveReferenceExpression(refToFoo);
|
||||
assertSame(bindingContext.getFunctionDescriptor(fooDecl), FunctionDescriptorUtil.getOriginal(mustBeFoo));
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class JetResolveTest extends LightDaemonAnalyzerTestCase {
|
||||
JetCallExpression fooIntBody = (JetCallExpression) fooIntDecl.getBodyExpression();
|
||||
JetDotQualifiedExpression qualifiedPlus = (JetDotQualifiedExpression) fooIntBody.getCalleeExpression();
|
||||
JetReferenceExpression refToPlus = (JetReferenceExpression) qualifiedPlus.getSelectorExpression();
|
||||
FunctionDescriptor mustBePlus = (FunctionDescriptor) bindingContext.resolve(refToPlus);
|
||||
FunctionDescriptor mustBePlus = (FunctionDescriptor) bindingContext.resolveReferenceExpression(refToPlus);
|
||||
FunctionGroup plusGroup = library.getInt().getMemberScope(Collections.<TypeProjection>emptyList()).getFunctionGroup("plus");
|
||||
Collection<FunctionDescriptor> pluses = plusGroup.getPossiblyApplicableFunctions(Collections.<Type>emptyList(), Collections.singletonList(library.getIntType()));
|
||||
FunctionDescriptor intPlus = null;
|
||||
@@ -97,7 +97,7 @@ public class JetResolveTest extends LightDaemonAnalyzerTestCase {
|
||||
assertSame(a, mustBeA);
|
||||
|
||||
JetTypeReference propertyTypeRef = aDecl.getPropertyTypeRef();
|
||||
Type type = bindingContext.getType(propertyTypeRef);
|
||||
Type type = bindingContext.resolveTypeReference(propertyTypeRef);
|
||||
assertEquals(library.getIntType(), type);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user