Remove the annoying misconcetion in the naming.
This commit is contained in:
@@ -230,12 +230,12 @@ public abstract class CodegenContext {
|
|||||||
if(accessor != null)
|
if(accessor != null)
|
||||||
return accessor;
|
return accessor;
|
||||||
|
|
||||||
if(descriptor instanceof NamedFunctionDescriptor) {
|
if(descriptor instanceof SimpleFunctionDescriptor) {
|
||||||
NamedFunctionDescriptorImpl myAccessor = new NamedFunctionDescriptorImpl(contextType,
|
SimpleFunctionDescriptorImpl myAccessor = new SimpleFunctionDescriptorImpl(contextType,
|
||||||
Collections.<AnnotationDescriptor>emptyList(),
|
Collections.<AnnotationDescriptor>emptyList(),
|
||||||
descriptor.getName() + "$bridge$" + accessors.size(),
|
descriptor.getName() + "$bridge$" + accessors.size(),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
FunctionDescriptor fd = (NamedFunctionDescriptor) descriptor;
|
FunctionDescriptor fd = (SimpleFunctionDescriptor) descriptor;
|
||||||
myAccessor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
myAccessor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||||
fd.getExpectedThisObject(),
|
fd.getExpectedThisObject(),
|
||||||
fd.getTypeParameters(),
|
fd.getTypeParameters(),
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ public class CodegenUtil {
|
|||||||
return (ClassDescriptor) outerDescriptor;
|
return (ClassDescriptor) outerDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NamedFunctionDescriptor createInvoke(FunctionDescriptor fd) {
|
public static SimpleFunctionDescriptor createInvoke(FunctionDescriptor fd) {
|
||||||
int arity = fd.getValueParameters().size();
|
int arity = fd.getValueParameters().size();
|
||||||
NamedFunctionDescriptorImpl invokeDescriptor = new NamedFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl(
|
||||||
fd.getExpectedThisObject().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity),
|
fd.getExpectedThisObject().exists() ? JetStandardClasses.getReceiverFunction(arity) : JetStandardClasses.getFunction(arity),
|
||||||
Collections.<AnnotationDescriptor>emptyList(),
|
Collections.<AnnotationDescriptor>emptyList(),
|
||||||
"invoke",
|
"invoke",
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiMethod;
|
import com.intellij.psi.PsiMethod;
|
||||||
import com.intellij.psi.tree.IElementType;
|
import com.intellij.psi.tree.IElementType;
|
||||||
@@ -31,8 +30,6 @@ import org.jetbrains.jet.lang.psi.*;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.*;
|
import org.jetbrains.jet.lang.resolve.calls.*;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||||
@@ -1328,8 +1325,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
assert !superCall;
|
assert !superCall;
|
||||||
callableMethod = ClosureCodegen.asCallableMethod((FunctionDescriptor) fd);
|
callableMethod = ClosureCodegen.asCallableMethod((FunctionDescriptor) fd);
|
||||||
}
|
}
|
||||||
else if (fd instanceof ExpressionAsFunctionDescriptor || (fd instanceof NamedFunctionDescriptor && fd.getContainingDeclaration() instanceof FunctionDescriptor)) {
|
else if (fd instanceof ExpressionAsFunctionDescriptor || (fd instanceof SimpleFunctionDescriptor && fd.getContainingDeclaration() instanceof FunctionDescriptor)) {
|
||||||
NamedFunctionDescriptor invoke = CodegenUtil.createInvoke((FunctionDescriptor) fd);
|
SimpleFunctionDescriptor invoke = CodegenUtil.createInvoke((FunctionDescriptor) fd);
|
||||||
callableMethod = ClosureCodegen.asCallableMethod(invoke);
|
callableMethod = ClosureCodegen.asCallableMethod(invoke);
|
||||||
}
|
}
|
||||||
else if (fd instanceof FunctionDescriptor) {
|
else if (fd instanceof FunctionDescriptor) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class FunctionCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void gen(JetNamedFunction f) {
|
public void gen(JetNamedFunction f) {
|
||||||
final NamedFunctionDescriptor functionDescriptor = state.getBindingContext().get(BindingContext.FUNCTION, f);
|
final SimpleFunctionDescriptor functionDescriptor = state.getBindingContext().get(BindingContext.FUNCTION, f);
|
||||||
assert functionDescriptor != null;
|
assert functionDescriptor != null;
|
||||||
JvmMethodSignature method = typeMapper.mapToCallableMethod(functionDescriptor, false, owner.getContextKind()).getSignature();
|
JvmMethodSignature method = typeMapper.mapToCallableMethod(functionDescriptor, false, owner.getContextKind()).getSignature();
|
||||||
generateMethod(f, method, true, null, functionDescriptor);
|
generateMethod(f, method, true, null, functionDescriptor);
|
||||||
@@ -120,7 +120,7 @@ public class FunctionCodegen {
|
|||||||
if (needJetAnnotations) {
|
if (needJetAnnotations) {
|
||||||
if (functionDescriptor instanceof PropertyAccessorDescriptor) {
|
if (functionDescriptor instanceof PropertyAccessorDescriptor) {
|
||||||
PropertyCodegen.generateJetPropertyAnnotation(mv, propertyTypeSignature, jvmSignature.getKotlinTypeParameter());
|
PropertyCodegen.generateJetPropertyAnnotation(mv, propertyTypeSignature, jvmSignature.getKotlinTypeParameter());
|
||||||
} else if (functionDescriptor instanceof NamedFunctionDescriptor) {
|
} else if (functionDescriptor instanceof SimpleFunctionDescriptor) {
|
||||||
if (propertyTypeSignature != null) {
|
if (propertyTypeSignature != null) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
import org.objectweb.asm.AnnotationVisitor;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import org.objectweb.asm.MethodVisitor;
|
||||||
@@ -533,7 +532,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
HashSet<FunctionDescriptor> overridden = new HashSet<FunctionDescriptor>();
|
||||||
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
for (JetDeclaration declaration : myClass.getDeclarations()) {
|
||||||
if (declaration instanceof JetNamedFunction) {
|
if (declaration instanceof JetNamedFunction) {
|
||||||
NamedFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration);
|
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration);
|
||||||
assert functionDescriptor != null;
|
assert functionDescriptor != null;
|
||||||
overridden.addAll(functionDescriptor.getOverriddenDescriptors());
|
overridden.addAll(functionDescriptor.getOverriddenDescriptors());
|
||||||
}
|
}
|
||||||
@@ -653,7 +652,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
for (Pair<CallableMemberDescriptor, CallableMemberDescriptor> needDelegates : getTraitImplementations(descriptor)) {
|
for (Pair<CallableMemberDescriptor, CallableMemberDescriptor> needDelegates : getTraitImplementations(descriptor)) {
|
||||||
CallableMemberDescriptor callableDescriptor = needDelegates.first;
|
CallableMemberDescriptor callableDescriptor = needDelegates.first;
|
||||||
if (needDelegates.second instanceof NamedFunctionDescriptor) {
|
if (needDelegates.second instanceof SimpleFunctionDescriptor) {
|
||||||
generateDelegationToTraitImpl(codegen, (FunctionDescriptor) needDelegates.second);
|
generateDelegationToTraitImpl(codegen, (FunctionDescriptor) needDelegates.second);
|
||||||
} else if (needDelegates.second instanceof PropertyDescriptor) {
|
} else if (needDelegates.second instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor property = (PropertyDescriptor) needDelegates.second;
|
PropertyDescriptor property = (PropertyDescriptor) needDelegates.second;
|
||||||
@@ -924,8 +923,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (declaration instanceof PropertyDescriptor) {
|
if (declaration instanceof PropertyDescriptor) {
|
||||||
propertyCodegen.genDelegate((PropertyDescriptor) declaration, (PropertyDescriptor) overriddenDescriptor, field);
|
propertyCodegen.genDelegate((PropertyDescriptor) declaration, (PropertyDescriptor) overriddenDescriptor, field);
|
||||||
}
|
}
|
||||||
else if (declaration instanceof NamedFunctionDescriptor) {
|
else if (declaration instanceof SimpleFunctionDescriptor) {
|
||||||
functionCodegen.genDelegate((NamedFunctionDescriptor) declaration, overriddenDescriptor, field);
|
functionCodegen.genDelegate((SimpleFunctionDescriptor) declaration, overriddenDescriptor, field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -854,7 +854,7 @@ public class JetTypeMapper {
|
|||||||
if(descriptor instanceof PropertyDescriptor) {
|
if(descriptor instanceof PropertyDescriptor) {
|
||||||
return StackValue.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType()));
|
return StackValue.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType()));
|
||||||
}
|
}
|
||||||
else if (descriptor instanceof NamedFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||||
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
PsiElement psiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor);
|
||||||
return Type.getObjectType(classNameForAnonymousClass((JetElement) psiElement));
|
return Type.getObjectType(classNameForAnonymousClass((JetElement) psiElement));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,8 +182,8 @@ public class IntrinsicMethods {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
for (DeclarationDescriptor stringMember : stringMembers) {
|
for (DeclarationDescriptor stringMember : stringMembers) {
|
||||||
if (stringMember instanceof NamedFunctionDescriptor) {
|
if (stringMember instanceof SimpleFunctionDescriptor) {
|
||||||
final NamedFunctionDescriptor stringMethod = (NamedFunctionDescriptor) stringMember;
|
final SimpleFunctionDescriptor stringMethod = (SimpleFunctionDescriptor) stringMember;
|
||||||
final PsiMethod[] methods = stringPsiClass != null?
|
final PsiMethod[] methods = stringPsiClass != null?
|
||||||
stringPsiClass.findMethodsByName(stringMember.getName(), false) : new PsiMethod[]{};
|
stringPsiClass.findMethodsByName(stringMember.getName(), false) : new PsiMethod[]{};
|
||||||
for (PsiMethod method : methods) {
|
for (PsiMethod method : methods) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.jetbrains.jet.codegen.CallableMethod;
|
|||||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||||
import org.jetbrains.jet.codegen.OwnerKind;
|
import org.jetbrains.jet.codegen.OwnerKind;
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
@@ -34,9 +34,9 @@ import java.util.List;
|
|||||||
* @author alex.tkachman
|
* @author alex.tkachman
|
||||||
*/
|
*/
|
||||||
public class PsiMethodCall implements IntrinsicMethod {
|
public class PsiMethodCall implements IntrinsicMethod {
|
||||||
private final NamedFunctionDescriptor myMethod;
|
private final SimpleFunctionDescriptor myMethod;
|
||||||
|
|
||||||
public PsiMethodCall(NamedFunctionDescriptor method) {
|
public PsiMethodCall(SimpleFunctionDescriptor method) {
|
||||||
myMethod = method;
|
myMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -1258,19 +1258,19 @@ public class JavaDescriptorResolver {
|
|||||||
|
|
||||||
final Set<FunctionDescriptor> functions = new HashSet<FunctionDescriptor>();
|
final Set<FunctionDescriptor> functions = new HashSet<FunctionDescriptor>();
|
||||||
|
|
||||||
Set<NamedFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
Set<SimpleFunctionDescriptor> functionsFromCurrent = Sets.newHashSet();
|
||||||
for (PsiMethodWrapper method : namedMembers.methods) {
|
for (PsiMethodWrapper method : namedMembers.methods) {
|
||||||
FunctionDescriptorImpl function = resolveMethodToFunctionDescriptor(owner, psiClass,
|
FunctionDescriptorImpl function = resolveMethodToFunctionDescriptor(owner, psiClass,
|
||||||
method);
|
method);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
functionsFromCurrent.add((NamedFunctionDescriptor) function);
|
functionsFromCurrent.add((SimpleFunctionDescriptor) function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owner instanceof ClassDescriptor) {
|
if (owner instanceof ClassDescriptor) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
|
||||||
|
|
||||||
Set<NamedFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(scopeData, methodName);
|
Set<SimpleFunctionDescriptor> functionsFromSupertypes = getFunctionsFromSupertypes(scopeData, methodName);
|
||||||
|
|
||||||
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor, new OverrideResolver.DescriptorSink() {
|
OverrideResolver.generateOverridesInFunctionGroup(methodName, functionsFromSupertypes, functionsFromCurrent, classDescriptor, new OverrideResolver.DescriptorSink() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1291,11 +1291,11 @@ public class JavaDescriptorResolver {
|
|||||||
namedMembers.functionDescriptors = functions;
|
namedMembers.functionDescriptors = functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<NamedFunctionDescriptor> getFunctionsFromSupertypes(ResolverScopeData scopeData, String methodName) {
|
private Set<SimpleFunctionDescriptor> getFunctionsFromSupertypes(ResolverScopeData scopeData, String methodName) {
|
||||||
Set<NamedFunctionDescriptor> r = new HashSet<NamedFunctionDescriptor>();
|
Set<SimpleFunctionDescriptor> r = new HashSet<SimpleFunctionDescriptor>();
|
||||||
for (JetType supertype : getSupertypes(scopeData)) {
|
for (JetType supertype : getSupertypes(scopeData)) {
|
||||||
for (FunctionDescriptor function : supertype.getMemberScope().getFunctions(methodName)) {
|
for (FunctionDescriptor function : supertype.getMemberScope().getFunctions(methodName)) {
|
||||||
r.add((NamedFunctionDescriptor) function);
|
r.add((SimpleFunctionDescriptor) function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
@@ -1429,7 +1429,7 @@ public class JavaDescriptorResolver {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedFunctionDescriptorImpl functionDescriptorImpl = new NamedFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
|
||||||
owner,
|
owner,
|
||||||
resolveAnnotations(method.getPsiMethod()),
|
resolveAnnotations(method.getPsiMethod()),
|
||||||
method.getName(),
|
method.getName(),
|
||||||
|
|||||||
+3
-4
@@ -22,7 +22,6 @@ import org.jetbrains.jet.lang.psi.JetParameter;
|
|||||||
import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter;
|
import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||||
@@ -39,7 +38,7 @@ import java.util.Set;
|
|||||||
public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
||||||
private final Set<CallableMemberDescriptor> callableMembers = Sets.newHashSet();
|
private final Set<CallableMemberDescriptor> callableMembers = Sets.newHashSet();
|
||||||
private final Set<PropertyDescriptor> properties = Sets.newHashSet();
|
private final Set<PropertyDescriptor> properties = Sets.newHashSet();
|
||||||
private final Set<NamedFunctionDescriptor> functions = Sets.newHashSet();
|
private final Set<SimpleFunctionDescriptor> functions = Sets.newHashSet();
|
||||||
|
|
||||||
private final WritableScope scopeForMemberResolution;
|
private final WritableScope scopeForMemberResolution;
|
||||||
// This scope contains type parameters but does not contain inner classes
|
// This scope contains type parameters but does not contain inner classes
|
||||||
@@ -119,7 +118,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
super.addFunctionDescriptor(functionDescriptor);
|
super.addFunctionDescriptor(functionDescriptor);
|
||||||
functions.add(functionDescriptor);
|
functions.add(functionDescriptor);
|
||||||
callableMembers.add(functionDescriptor);
|
callableMembers.add(functionDescriptor);
|
||||||
@@ -127,7 +126,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<NamedFunctionDescriptor> getFunctions() {
|
public Set<SimpleFunctionDescriptor> getFunctions() {
|
||||||
return functions;
|
return functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -252,7 +252,7 @@ public class MutableClassDescriptorLite extends MutableDeclarationDescriptor imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
getScopeForMemberLookupAsWritableScope().addFunctionDescriptor(functionDescriptor);
|
getScopeForMemberLookupAsWritableScope().addFunctionDescriptor(functionDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public class NamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
memberScope.addFunctionDescriptor(functionDescriptor);
|
memberScope.addFunctionDescriptor(functionDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public interface NamespaceLike extends DeclarationDescriptor {
|
|||||||
|
|
||||||
void addObjectDescriptor(@NotNull MutableClassDescriptorLite objectDescriptor);
|
void addObjectDescriptor(@NotNull MutableClassDescriptorLite objectDescriptor);
|
||||||
|
|
||||||
void addFunctionDescriptor(@NotNull NamedFunctionDescriptor functionDescriptor);
|
void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor);
|
||||||
|
|
||||||
void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor);
|
void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor);
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -19,17 +19,17 @@ package org.jetbrains.jet.lang.descriptors;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ... and also a closure
|
* Simple functions are the ones with 'fun' keyword and function literals
|
||||||
*
|
*
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
public interface NamedFunctionDescriptor extends FunctionDescriptor {
|
public interface SimpleFunctionDescriptor extends FunctionDescriptor {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
NamedFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, Kind kind, boolean copyOverrides);
|
SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, Kind kind, boolean copyOverrides);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
NamedFunctionDescriptor getOriginal();
|
SimpleFunctionDescriptor getOriginal();
|
||||||
}
|
}
|
||||||
+10
-10
@@ -29,9 +29,9 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
public class NamedFunctionDescriptorImpl extends FunctionDescriptorImpl implements NamedFunctionDescriptor {
|
public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl implements SimpleFunctionDescriptor {
|
||||||
|
|
||||||
public NamedFunctionDescriptorImpl(
|
public SimpleFunctionDescriptorImpl(
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull List<AnnotationDescriptor> annotations,
|
@NotNull List<AnnotationDescriptor> annotations,
|
||||||
@NotNull String name,
|
@NotNull String name,
|
||||||
@@ -39,9 +39,9 @@ public class NamedFunctionDescriptorImpl extends FunctionDescriptorImpl implemen
|
|||||||
super(containingDeclaration, annotations, name, kind);
|
super(containingDeclaration, annotations, name, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamedFunctionDescriptorImpl(
|
private SimpleFunctionDescriptorImpl(
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull NamedFunctionDescriptor original,
|
@NotNull SimpleFunctionDescriptor original,
|
||||||
@NotNull List<AnnotationDescriptor> annotations,
|
@NotNull List<AnnotationDescriptor> annotations,
|
||||||
@NotNull String name,
|
@NotNull String name,
|
||||||
Kind kind) {
|
Kind kind) {
|
||||||
@@ -55,14 +55,14 @@ public class NamedFunctionDescriptorImpl extends FunctionDescriptorImpl implemen
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public NamedFunctionDescriptor getOriginal() {
|
public SimpleFunctionDescriptor getOriginal() {
|
||||||
return (NamedFunctionDescriptor) super.getOriginal();
|
return (SimpleFunctionDescriptor) super.getOriginal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
||||||
if (preserveOriginal) {
|
if (preserveOriginal) {
|
||||||
return new NamedFunctionDescriptorImpl(
|
return new SimpleFunctionDescriptorImpl(
|
||||||
newOwner,
|
newOwner,
|
||||||
getOriginal(),
|
getOriginal(),
|
||||||
// TODO : safeSubstitute
|
// TODO : safeSubstitute
|
||||||
@@ -70,7 +70,7 @@ public class NamedFunctionDescriptorImpl extends FunctionDescriptorImpl implemen
|
|||||||
getName(),
|
getName(),
|
||||||
kind);
|
kind);
|
||||||
} else {
|
} else {
|
||||||
return new NamedFunctionDescriptorImpl(
|
return new SimpleFunctionDescriptorImpl(
|
||||||
newOwner,
|
newOwner,
|
||||||
// TODO : safeSubstitute
|
// TODO : safeSubstitute
|
||||||
getAnnotations(),
|
getAnnotations(),
|
||||||
@@ -81,7 +81,7 @@ public class NamedFunctionDescriptorImpl extends FunctionDescriptorImpl implemen
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public NamedFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, Kind kind, boolean copyOverrides) {
|
public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, Kind kind, boolean copyOverrides) {
|
||||||
return (NamedFunctionDescriptor) doSubstitute(TypeSubstitutor.EMPTY, newOwner, DescriptorUtils.convertModality(modality, makeNonAbstract), false, copyOverrides, kind);
|
return (SimpleFunctionDescriptor) doSubstitute(TypeSubstitutor.EMPTY, newOwner, DescriptorUtils.convertModality(modality, makeNonAbstract), false, copyOverrides, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,11 +146,11 @@ public interface Errors {
|
|||||||
return super.on(elementToBlame, nodeToMark, s, classDescriptor, modifierListOwner).add(DiagnosticParameters.CLASS, modifierListOwner);
|
return super.on(elementToBlame, nodeToMark, s, classDescriptor, modifierListOwner).add(DiagnosticParameters.CLASS, modifierListOwner);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
PsiElementOnlyDiagnosticFactory1<JetFunction, NamedFunctionDescriptor> ABSTRACT_FUNCTION_WITH_BODY = PsiElementOnlyDiagnosticFactory1.create(ERROR, "A function {0} with body cannot be abstract");
|
PsiElementOnlyDiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> ABSTRACT_FUNCTION_WITH_BODY = PsiElementOnlyDiagnosticFactory1.create(ERROR, "A function {0} with body cannot be abstract");
|
||||||
PsiElementOnlyDiagnosticFactory1<JetFunction, NamedFunctionDescriptor> NON_ABSTRACT_FUNCTION_WITH_NO_BODY = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Method {0} without a body must be abstract");
|
PsiElementOnlyDiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> NON_ABSTRACT_FUNCTION_WITH_NO_BODY = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Method {0} without a body must be abstract");
|
||||||
PsiElementOnlyDiagnosticFactory1<JetModifierListOwner, NamedFunctionDescriptor> NON_MEMBER_ABSTRACT_FUNCTION = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Function {0} is not a class or trait member and cannot be abstract");
|
PsiElementOnlyDiagnosticFactory1<JetModifierListOwner, SimpleFunctionDescriptor> NON_MEMBER_ABSTRACT_FUNCTION = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Function {0} is not a class or trait member and cannot be abstract");
|
||||||
|
|
||||||
PsiElementOnlyDiagnosticFactory1<JetFunction, NamedFunctionDescriptor> NON_MEMBER_FUNCTION_NO_BODY = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Function {0} must have a body");
|
PsiElementOnlyDiagnosticFactory1<JetFunction, SimpleFunctionDescriptor> NON_MEMBER_FUNCTION_NO_BODY = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Function {0} must have a body");
|
||||||
|
|
||||||
DiagnosticWithParameterFactory<JetNamedDeclaration, JetClass> NON_FINAL_MEMBER_IN_FINAL_CLASS = DiagnosticWithParameterFactory.create(ERROR, "Non final member in a final class", DiagnosticParameters.CLASS);
|
DiagnosticWithParameterFactory<JetNamedDeclaration, JetClass> NON_FINAL_MEMBER_IN_FINAL_CLASS = DiagnosticWithParameterFactory.create(ERROR, "Non final member in a final class", DiagnosticParameters.CLASS);
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class AnalyzingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
scope.addFunctionDescriptor(functionDescriptor);
|
scope.addFunctionDescriptor(functionDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public interface BindingContext {
|
|||||||
WritableSlice<PsiElement, NamespaceDescriptor> NAMESPACE = Slices.<PsiElement, NamespaceDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<PsiElement, NamespaceDescriptor> NAMESPACE = Slices.<PsiElement, NamespaceDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
WritableSlice<PsiElement, ClassDescriptor> CLASS = Slices.<PsiElement, ClassDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<PsiElement, ClassDescriptor> CLASS = Slices.<PsiElement, ClassDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
WritableSlice<JetTypeParameter, TypeParameterDescriptor> TYPE_PARAMETER = Slices.<JetTypeParameter, TypeParameterDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<JetTypeParameter, TypeParameterDescriptor> TYPE_PARAMETER = Slices.<JetTypeParameter, TypeParameterDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
WritableSlice<PsiElement, NamedFunctionDescriptor> FUNCTION = Slices.<PsiElement, NamedFunctionDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<PsiElement, SimpleFunctionDescriptor> FUNCTION = Slices.<PsiElement, SimpleFunctionDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
WritableSlice<PsiElement, ConstructorDescriptor> CONSTRUCTOR = Slices.<PsiElement, ConstructorDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<PsiElement, ConstructorDescriptor> CONSTRUCTOR = Slices.<PsiElement, ConstructorDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
WritableSlice<PsiElement, VariableDescriptor> VARIABLE = Slices.<PsiElement, VariableDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<PsiElement, VariableDescriptor> VARIABLE = Slices.<PsiElement, VariableDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
WritableSlice<JetParameter, VariableDescriptor> VALUE_PARAMETER = Slices.<JetParameter, VariableDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
WritableSlice<JetParameter, VariableDescriptor> VALUE_PARAMETER = Slices.<JetParameter, VariableDescriptor>sliceBuilder().setOpposite((WritableSlice) DESCRIPTOR_TO_DECLARATION).build();
|
||||||
|
|||||||
@@ -482,9 +482,9 @@ public class BodyResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void resolveFunctionBodies() {
|
private void resolveFunctionBodies() {
|
||||||
for (Map.Entry<JetNamedFunction, NamedFunctionDescriptor> entry : this.context.getFunctions().entrySet()) {
|
for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : this.context.getFunctions().entrySet()) {
|
||||||
JetNamedFunction declaration = entry.getKey();
|
JetNamedFunction declaration = entry.getKey();
|
||||||
NamedFunctionDescriptor descriptor = entry.getValue();
|
SimpleFunctionDescriptor descriptor = entry.getValue();
|
||||||
|
|
||||||
computeDeferredType(descriptor.getReturnType());
|
computeDeferredType(descriptor.getReturnType());
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
|
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
@@ -51,9 +51,9 @@ public class ControlFlowAnalyzer {
|
|||||||
if (!context.completeAnalysisNeeded(objectDeclaration)) continue;
|
if (!context.completeAnalysisNeeded(objectDeclaration)) continue;
|
||||||
checkClassOrObject(objectDeclaration);
|
checkClassOrObject(objectDeclaration);
|
||||||
}
|
}
|
||||||
for (Map.Entry<JetNamedFunction, NamedFunctionDescriptor> entry : context.getFunctions().entrySet()) {
|
for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : context.getFunctions().entrySet()) {
|
||||||
JetNamedFunction function = entry.getKey();
|
JetNamedFunction function = entry.getKey();
|
||||||
NamedFunctionDescriptor functionDescriptor = entry.getValue();
|
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
||||||
if (!context.completeAnalysisNeeded(function)) continue;
|
if (!context.completeAnalysisNeeded(function)) continue;
|
||||||
final JetType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
final JetType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
|
||||||
? NO_EXPECTED_TYPE
|
? NO_EXPECTED_TYPE
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class DeclarationResolver {
|
|||||||
declaration.accept(new JetVisitorVoid() {
|
declaration.accept(new JetVisitorVoid() {
|
||||||
@Override
|
@Override
|
||||||
public void visitNamedFunction(JetNamedFunction function) {
|
public void visitNamedFunction(JetNamedFunction function) {
|
||||||
NamedFunctionDescriptor functionDescriptor = context.getDescriptorResolver().resolveFunctionDescriptor(namespaceLike, scopeForFunctions, function);
|
SimpleFunctionDescriptor functionDescriptor = context.getDescriptorResolver().resolveFunctionDescriptor(namespaceLike, scopeForFunctions, function);
|
||||||
namespaceLike.addFunctionDescriptor(functionDescriptor);
|
namespaceLike.addFunctionDescriptor(functionDescriptor);
|
||||||
context.getFunctions().put(function, functionDescriptor);
|
context.getFunctions().put(function, functionDescriptor);
|
||||||
context.getDeclaringScopes().put(function, scopeForFunctions);
|
context.getDeclaringScopes().put(function, scopeForFunctions);
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ public class DeclarationsChecker {
|
|||||||
checkObject(objectDeclaration, objectDescriptor);
|
checkObject(objectDeclaration, objectDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<JetNamedFunction, NamedFunctionDescriptor> functions = context.getFunctions();
|
Map<JetNamedFunction, SimpleFunctionDescriptor> functions = context.getFunctions();
|
||||||
for (Map.Entry<JetNamedFunction, NamedFunctionDescriptor> entry : functions.entrySet()) {
|
for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : functions.entrySet()) {
|
||||||
JetNamedFunction function = entry.getKey();
|
JetNamedFunction function = entry.getKey();
|
||||||
NamedFunctionDescriptor functionDescriptor = entry.getValue();
|
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
|
||||||
|
|
||||||
if (!context.completeAnalysisNeeded(function)) continue;
|
if (!context.completeAnalysisNeeded(function)) continue;
|
||||||
checkFunction(function, functionDescriptor);
|
checkFunction(function, functionDescriptor);
|
||||||
@@ -246,7 +246,7 @@ public class DeclarationsChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkFunction(JetNamedFunction function, NamedFunctionDescriptor functionDescriptor) {
|
protected void checkFunction(JetNamedFunction function, SimpleFunctionDescriptor functionDescriptor) {
|
||||||
DeclarationDescriptor containingDescriptor = functionDescriptor.getContainingDeclaration();
|
DeclarationDescriptor containingDescriptor = functionDescriptor.getContainingDeclaration();
|
||||||
PsiElement nameIdentifier = function.getNameIdentifier();
|
PsiElement nameIdentifier = function.getNameIdentifier();
|
||||||
JetModifierList modifierList = function.getModifierList();
|
JetModifierList modifierList = function.getModifierList();
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ public class DelegationResolver {
|
|||||||
context.getTrace().record(DELEGATED, copy);
|
context.getTrace().record(DELEGATED, copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (declarationDescriptor instanceof NamedFunctionDescriptor) {
|
else if (declarationDescriptor instanceof SimpleFunctionDescriptor) {
|
||||||
NamedFunctionDescriptor functionDescriptor = (NamedFunctionDescriptor) declarationDescriptor;
|
SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) declarationDescriptor;
|
||||||
if (functionDescriptor.getModality().isOverridable()) {
|
if (functionDescriptor.getModality().isOverridable()) {
|
||||||
NamedFunctionDescriptor copy = functionDescriptor.copy(classDescriptor, true, CallableMemberDescriptor.Kind.DELEGATION, true);
|
SimpleFunctionDescriptor copy = functionDescriptor.copy(classDescriptor, true, CallableMemberDescriptor.Kind.DELEGATION, true);
|
||||||
classDescriptor.addFunctionDescriptor(copy);
|
classDescriptor.addFunctionDescriptor(copy);
|
||||||
context.getTrace().record(DELEGATED, copy);
|
context.getTrace().record(DELEGATED, copy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ public class DescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public NamedFunctionDescriptor resolveFunctionDescriptor(DeclarationDescriptor containingDescriptor, final JetScope scope, final JetNamedFunction function) {
|
public SimpleFunctionDescriptor resolveFunctionDescriptor(DeclarationDescriptor containingDescriptor, final JetScope scope, final JetNamedFunction function) {
|
||||||
final NamedFunctionDescriptorImpl functionDescriptor = new NamedFunctionDescriptorImpl(
|
final SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl(
|
||||||
containingDescriptor,
|
containingDescriptor,
|
||||||
annotationResolver.resolveAnnotations(scope, function.getModifierList()),
|
annotationResolver.resolveAnnotations(scope, function.getModifierList()),
|
||||||
JetPsiUtil.safeName(function.getName()),
|
JetPsiUtil.safeName(function.getName()),
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class DescriptorUtils {
|
|||||||
return descriptor.getName();
|
return descriptor.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTopLevelFunction(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
public static boolean isTopLevelFunction(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
return functionDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor;
|
return functionDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class OverloadResolver {
|
|||||||
|
|
||||||
MultiMap<Key, CallableMemberDescriptor> functionsByName = MultiMap.create();
|
MultiMap<Key, CallableMemberDescriptor> functionsByName = MultiMap.create();
|
||||||
|
|
||||||
for (NamedFunctionDescriptor function : context.getFunctions().values()) {
|
for (SimpleFunctionDescriptor function : context.getFunctions().values()) {
|
||||||
DeclarationDescriptor containingDeclaration = function.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = function.getContainingDeclaration();
|
||||||
if (containingDeclaration instanceof NamespaceDescriptor) {
|
if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||||
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) containingDeclaration;
|
NamespaceDescriptor namespaceDescriptor = (NamespaceDescriptor) containingDeclaration;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve;
|
|||||||
|
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@ public class OverloadUtil {
|
|||||||
private static int braceCount(CallableDescriptor a) {
|
private static int braceCount(CallableDescriptor a) {
|
||||||
if (a instanceof PropertyDescriptor) {
|
if (a instanceof PropertyDescriptor) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (a instanceof NamedFunctionDescriptor) {
|
} else if (a instanceof SimpleFunctionDescriptor) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (a instanceof ConstructorDescriptor) {
|
} else if (a instanceof ConstructorDescriptor) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public class OverrideResolver {
|
|||||||
public void addToScope(@NotNull CallableMemberDescriptor fakeOverride) {
|
public void addToScope(@NotNull CallableMemberDescriptor fakeOverride) {
|
||||||
if (fakeOverride instanceof PropertyDescriptor) {
|
if (fakeOverride instanceof PropertyDescriptor) {
|
||||||
classDescriptor.getScopeForMemberLookupAsWritableScope().addPropertyDescriptor((PropertyDescriptor) fakeOverride);
|
classDescriptor.getScopeForMemberLookupAsWritableScope().addPropertyDescriptor((PropertyDescriptor) fakeOverride);
|
||||||
} else if (fakeOverride instanceof NamedFunctionDescriptor) {
|
} else if (fakeOverride instanceof SimpleFunctionDescriptor) {
|
||||||
classDescriptor.getScopeForMemberLookupAsWritableScope().addFunctionDescriptor((NamedFunctionDescriptor) fakeOverride);
|
classDescriptor.getScopeForMemberLookupAsWritableScope().addFunctionDescriptor((SimpleFunctionDescriptor) fakeOverride);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException(fakeOverride.getClass().getName());
|
throw new IllegalStateException(fakeOverride.getClass().getName());
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ public class OverrideResolver {
|
|||||||
JetScope scope) {
|
JetScope scope) {
|
||||||
List<CallableMemberDescriptor> r = Lists.newArrayList();
|
List<CallableMemberDescriptor> r = Lists.newArrayList();
|
||||||
for (DeclarationDescriptor decl : scope.getAllDescriptors()) {
|
for (DeclarationDescriptor decl : scope.getAllDescriptors()) {
|
||||||
if (decl instanceof PropertyDescriptor || decl instanceof NamedFunctionDescriptor) {
|
if (decl instanceof PropertyDescriptor || decl instanceof SimpleFunctionDescriptor) {
|
||||||
r.add((CallableMemberDescriptor) decl);
|
r.add((CallableMemberDescriptor) decl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import java.util.Set;
|
|||||||
protected final Map<JetFile, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
|
protected final Map<JetFile, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
|
||||||
|
|
||||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||||
private final Map<JetNamedFunction, NamedFunctionDescriptor> functions = Maps.newLinkedHashMap();
|
private final Map<JetNamedFunction, SimpleFunctionDescriptor> functions = Maps.newLinkedHashMap();
|
||||||
private final Map<JetSecondaryConstructor, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
private final Map<JetSecondaryConstructor, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||||
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||||
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
||||||
@@ -154,7 +154,7 @@ import java.util.Set;
|
|||||||
return declaringScopes;
|
return declaringScopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<JetNamedFunction, NamedFunctionDescriptor> getFunctions() {
|
public Map<JetNamedFunction, SimpleFunctionDescriptor> getFunctions() {
|
||||||
return functions;
|
return functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ public class TopDownAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFunctionDescriptor(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,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.ErrorNamedFunctionDescriptorImpl;
|
import org.jetbrains.jet.lang.types.error.ErrorSimpleFunctionDescriptorImpl;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -162,8 +162,8 @@ public class ErrorUtils {
|
|||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
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 NamedFunctionDescriptor createErrorFunction(ErrorScope ownerScope) {
|
private static SimpleFunctionDescriptor createErrorFunction(ErrorScope ownerScope) {
|
||||||
ErrorNamedFunctionDescriptorImpl function = new ErrorNamedFunctionDescriptorImpl(ownerScope);
|
ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ownerScope);
|
||||||
function.initialize(
|
function.initialize(
|
||||||
null,
|
null,
|
||||||
ReceiverDescriptor.NO_RECEIVER,
|
ReceiverDescriptor.NO_RECEIVER,
|
||||||
|
|||||||
+5
-8
@@ -17,11 +17,8 @@
|
|||||||
package org.jetbrains.jet.lang.types.error;
|
package org.jetbrains.jet.lang.types.error;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptorImpl;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptorImpl;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||||
|
|
||||||
@@ -30,12 +27,12 @@ import java.util.Collections;
|
|||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
*/
|
*/
|
||||||
public class ErrorNamedFunctionDescriptorImpl extends NamedFunctionDescriptorImpl {
|
public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorImpl {
|
||||||
// used for diagnostic only
|
// used for diagnostic only
|
||||||
@NotNull
|
@NotNull
|
||||||
private final ErrorUtils.ErrorScope ownerScope;
|
private final ErrorUtils.ErrorScope ownerScope;
|
||||||
|
|
||||||
public ErrorNamedFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) {
|
public ErrorSimpleFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) {
|
||||||
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), "<ERROR FUNCTION>", Kind.DECLARATION);
|
super(ErrorUtils.getErrorClass(), Collections.<AnnotationDescriptor>emptyList(), "<ERROR FUNCTION>", Kind.DECLARATION);
|
||||||
this.ownerScope = ownerScope;
|
this.ownerScope = ownerScope;
|
||||||
}
|
}
|
||||||
@@ -47,7 +44,7 @@ public class ErrorNamedFunctionDescriptorImpl extends NamedFunctionDescriptorImp
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public NamedFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, Kind kind, boolean copyOverrides) {
|
public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, boolean makeNonAbstract, Kind kind, boolean copyOverrides) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -84,7 +84,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
JetType expectedType = context.expectedType;
|
JetType expectedType = context.expectedType;
|
||||||
boolean functionTypeExpected = expectedType != TypeUtils.NO_EXPECTED_TYPE && JetStandardClasses.isFunctionType(expectedType);
|
boolean functionTypeExpected = expectedType != TypeUtils.NO_EXPECTED_TYPE && JetStandardClasses.isFunctionType(expectedType);
|
||||||
|
|
||||||
NamedFunctionDescriptorImpl functionDescriptor = createFunctionDescriptor(expression, context, functionTypeExpected);
|
SimpleFunctionDescriptorImpl functionDescriptor = createFunctionDescriptor(expression, context, functionTypeExpected);
|
||||||
|
|
||||||
List<JetType> parameterTypes = Lists.newArrayList();
|
List<JetType> parameterTypes = Lists.newArrayList();
|
||||||
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
||||||
@@ -124,10 +124,10 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return DataFlowUtils.checkType(JetStandardClasses.getFunctionType(Collections.<AnnotationDescriptor>emptyList(), receiver, parameterTypes, safeReturnType), expression, context);
|
return DataFlowUtils.checkType(JetStandardClasses.getFunctionType(Collections.<AnnotationDescriptor>emptyList(), receiver, parameterTypes, safeReturnType), expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NamedFunctionDescriptorImpl createFunctionDescriptor(JetFunctionLiteralExpression expression, ExpressionTypingContext context, boolean functionTypeExpected) {
|
private SimpleFunctionDescriptorImpl createFunctionDescriptor(JetFunctionLiteralExpression expression, ExpressionTypingContext context, boolean functionTypeExpected) {
|
||||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||||
JetTypeReference receiverTypeRef = functionLiteral.getReceiverTypeRef();
|
JetTypeReference receiverTypeRef = functionLiteral.getReceiverTypeRef();
|
||||||
NamedFunctionDescriptorImpl functionDescriptor = new NamedFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl(
|
||||||
context.scope.getContainingDeclaration(), Collections.<AnnotationDescriptor>emptyList(), "<anonymous>", CallableMemberDescriptor.Kind.DECLARATION);
|
context.scope.getContainingDeclaration(), Collections.<AnnotationDescriptor>emptyList(), "<anonymous>", CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
|
|
||||||
List<ValueParameterDescriptor> valueParameterDescriptors = createValueParameterDescriptors(context, functionLiteral, functionDescriptor, functionTypeExpected);
|
List<ValueParameterDescriptor> valueParameterDescriptors = createValueParameterDescriptors(context, functionLiteral, functionDescriptor, functionTypeExpected);
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||||
import org.jetbrains.jet.lang.psi.*;
|
import org.jetbrains.jet.lang.psi.*;
|
||||||
@@ -479,7 +479,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (element != null) {
|
else if (element != null) {
|
||||||
NamedFunctionDescriptor functionDescriptor = context.trace.get(FUNCTION, element);
|
SimpleFunctionDescriptor functionDescriptor = context.trace.get(FUNCTION, element);
|
||||||
if (functionDescriptor != null) {
|
if (functionDescriptor != null) {
|
||||||
expectedType = DescriptorUtils.getFunctionExpectedReturnType(functionDescriptor, element);
|
expectedType = DescriptorUtils.getFunctionExpectedReturnType(functionDescriptor, element);
|
||||||
if (functionDescriptor != containingFunctionDescriptor) {
|
if (functionDescriptor != containingFunctionDescriptor) {
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetType visitNamedFunction(JetNamedFunction function, ExpressionTypingContext context) {
|
public JetType visitNamedFunction(JetNamedFunction function, ExpressionTypingContext context) {
|
||||||
NamedFunctionDescriptor functionDescriptor = context.getDescriptorResolver().resolveFunctionDescriptor(scope.getContainingDeclaration(), scope, function);
|
SimpleFunctionDescriptor functionDescriptor = context.getDescriptorResolver().resolveFunctionDescriptor(scope.getContainingDeclaration(), scope, function);
|
||||||
scope.addFunctionDescriptor(functionDescriptor);
|
scope.addFunctionDescriptor(functionDescriptor);
|
||||||
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
||||||
context.getServices().checkFunctionReturnType(functionInnerScope, function, functionDescriptor, context.dataFlowInfo);
|
context.getServices().checkFunctionReturnType(functionInnerScope, function, functionDescriptor, context.dataFlowInfo);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
|||||||
|
|
||||||
List<JetDeclaration> declarations = aClass.getDeclarations();
|
List<JetDeclaration> declarations = aClass.getDeclarations();
|
||||||
JetNamedFunction function = (JetNamedFunction) declarations.get(0);
|
JetNamedFunction function = (JetNamedFunction) declarations.get(0);
|
||||||
NamedFunctionDescriptor functionDescriptor = descriptorResolver.resolveFunctionDescriptor(classDescriptor, scope, function);
|
SimpleFunctionDescriptor functionDescriptor = descriptorResolver.resolveFunctionDescriptor(classDescriptor, scope, function);
|
||||||
|
|
||||||
assertEquals(expectedFunctionModality, functionDescriptor.getModality());
|
assertEquals(expectedFunctionModality, functionDescriptor.getModality());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
if (element instanceof JetNamedFunction) {
|
if (element instanceof JetNamedFunction) {
|
||||||
JetNamedFunction jetFunction = (JetNamedFunction) element;
|
JetNamedFunction jetFunction = (JetNamedFunction) element;
|
||||||
|
|
||||||
final NamedFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, jetFunction);
|
final SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, jetFunction);
|
||||||
if (functionDescriptor == null) return null;
|
if (functionDescriptor == null) return null;
|
||||||
final Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenDescriptors();
|
final Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenDescriptors();
|
||||||
Icon icon = isMember(functionDescriptor) ? (overriddenFunctions.isEmpty() ? PlatformIcons.METHOD_ICON : OVERRIDING_FUNCTION) : PlatformIcons.FUNCTION_ICON;
|
Icon icon = isMember(functionDescriptor) ? (overriddenFunctions.isEmpty() ? PlatformIcons.METHOD_ICON : OVERRIDING_FUNCTION) : PlatformIcons.FUNCTION_ICON;
|
||||||
@@ -198,7 +198,7 @@ public class JetLineMarkerProvider implements LineMarkerProvider {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMember(@NotNull NamedFunctionDescriptor functionDescriptor) {
|
private boolean isMember(@NotNull SimpleFunctionDescriptor functionDescriptor) {
|
||||||
return functionDescriptor.getContainingDeclaration().getOriginal() instanceof ClassifierDescriptor;
|
return functionDescriptor.getContainingDeclaration().getOriginal() instanceof ClassifierDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.NonNls;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.asJava.JavaElementFinder;
|
import org.jetbrains.jet.asJava.JavaElementFinder;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
@@ -135,7 +135,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Collection<NamedFunctionDescriptor> getTopLevelFunctionDescriptorsByName(final @NotNull String name,
|
public Collection<SimpleFunctionDescriptor> getTopLevelFunctionDescriptorsByName(final @NotNull String name,
|
||||||
final @NotNull GlobalSearchScope scope) {
|
final @NotNull GlobalSearchScope scope) {
|
||||||
|
|
||||||
// TODO: Add jet function in jar-dependencies (those functions are missing in BindingContext and stubs)
|
// TODO: Add jet function in jar-dependencies (those functions are missing in BindingContext and stubs)
|
||||||
@@ -144,10 +144,10 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
|
|
||||||
final BindingContext context = getResolutionContext(scope);
|
final BindingContext context = getResolutionContext(scope);
|
||||||
|
|
||||||
final HashSet<NamedFunctionDescriptor> result = new HashSet<NamedFunctionDescriptor>();
|
final HashSet<SimpleFunctionDescriptor> result = new HashSet<SimpleFunctionDescriptor>();
|
||||||
|
|
||||||
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
|
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
|
||||||
final NamedFunctionDescriptor functionDescriptor = context.get(BindingContext.FUNCTION, jetNamedFunction);
|
final SimpleFunctionDescriptor functionDescriptor = context.get(BindingContext.FUNCTION, jetNamedFunction);
|
||||||
if (functionDescriptor != null) {
|
if (functionDescriptor != null) {
|
||||||
result.add(functionDescriptor);
|
result.add(functionDescriptor);
|
||||||
}
|
}
|
||||||
@@ -181,17 +181,17 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
|||||||
return extensionFunctionNames;
|
return extensionFunctionNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<NamedFunctionDescriptor> getAllJetExtensionFunctionsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
|
public Collection<SimpleFunctionDescriptor> getAllJetExtensionFunctionsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
|
||||||
// TODO: Add jet extension functions in jar-dependencies (those functions are missing in BindingContext and stubs)
|
// TODO: Add jet extension functions in jar-dependencies (those functions are missing in BindingContext and stubs)
|
||||||
|
|
||||||
final Collection<JetNamedFunction> jetNamedFunctions = JetShortFunctionNameIndex.getInstance().get(name, project, scope);
|
final Collection<JetNamedFunction> jetNamedFunctions = JetShortFunctionNameIndex.getInstance().get(name, project, scope);
|
||||||
|
|
||||||
final BindingContext context = getResolutionContext(scope);
|
final BindingContext context = getResolutionContext(scope);
|
||||||
|
|
||||||
final HashSet<NamedFunctionDescriptor> result = new HashSet<NamedFunctionDescriptor>();
|
final HashSet<SimpleFunctionDescriptor> result = new HashSet<SimpleFunctionDescriptor>();
|
||||||
|
|
||||||
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
|
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
|
||||||
final NamedFunctionDescriptor functionDescriptor = context.get(BindingContext.FUNCTION, jetNamedFunction);
|
final SimpleFunctionDescriptor functionDescriptor = context.get(BindingContext.FUNCTION, jetNamedFunction);
|
||||||
if (functionDescriptor != null) {
|
if (functionDescriptor != null) {
|
||||||
if (functionDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
if (functionDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||||
if (functionDescriptor.getExpectedThisObject() != ReceiverDescriptor.NO_RECEIVER) {
|
if (functionDescriptor.getExpectedThisObject() != ReceiverDescriptor.NO_RECEIVER) {
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
|||||||
for (DescriptorClassMember selectedElement : selectedElements) {
|
for (DescriptorClassMember selectedElement : selectedElements) {
|
||||||
final DeclarationDescriptor descriptor = selectedElement.getDescriptor();
|
final DeclarationDescriptor descriptor = selectedElement.getDescriptor();
|
||||||
JetFile containingFile = (JetFile) classOrObject.getContainingFile();
|
JetFile containingFile = (JetFile) classOrObject.getContainingFile();
|
||||||
if (descriptor instanceof NamedFunctionDescriptor) {
|
if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||||
JetElement target = overrideFunction(project, containingFile, (NamedFunctionDescriptor) descriptor);
|
JetElement target = overrideFunction(project, containingFile, (SimpleFunctionDescriptor) descriptor);
|
||||||
body.addBefore(target, body.getRBrace());
|
body.addBefore(target, body.getRBrace());
|
||||||
}
|
}
|
||||||
else if (descriptor instanceof PropertyDescriptor) {
|
else if (descriptor instanceof PropertyDescriptor) {
|
||||||
@@ -104,7 +104,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
|||||||
return JetPsiFactory.createProperty(project, bodyBuilder.toString());
|
return JetPsiFactory.createProperty(project, bodyBuilder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JetElement overrideFunction(Project project, JetFile file, NamedFunctionDescriptor descriptor) {
|
private static JetElement overrideFunction(Project project, JetFile file, SimpleFunctionDescriptor descriptor) {
|
||||||
StringBuilder bodyBuilder = new StringBuilder("override fun ");
|
StringBuilder bodyBuilder = new StringBuilder("override fun ");
|
||||||
bodyBuilder.append(descriptor.getName());
|
bodyBuilder.append(descriptor.getName());
|
||||||
bodyBuilder.append("(");
|
bodyBuilder.append("(");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.intellij.psi.PsiElement;
|
|||||||
import com.intellij.psi.util.PsiTreeUtil;
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamedFunctionDescriptor;
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
import org.jetbrains.jet.lang.psi.JetImportDirective;
|
||||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression;
|
import org.jetbrains.jet.lang.psi.JetQualifiedExpression;
|
||||||
@@ -122,10 +122,10 @@ public class JetFunctionInsertHandler implements InsertHandler<LookupElement> {
|
|||||||
|
|
||||||
if (context.getFile() instanceof JetFile && item.getObject() instanceof JetLookupObject) {
|
if (context.getFile() instanceof JetFile && item.getObject() instanceof JetLookupObject) {
|
||||||
final DeclarationDescriptor descriptor = ((JetLookupObject) item.getObject()).getDescriptor();
|
final DeclarationDescriptor descriptor = ((JetLookupObject) item.getObject()).getDescriptor();
|
||||||
if (descriptor instanceof NamedFunctionDescriptor) {
|
if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||||
|
|
||||||
final JetFile file = (JetFile) context.getFile();
|
final JetFile file = (JetFile) context.getFile();
|
||||||
NamedFunctionDescriptor functionDescriptor = (NamedFunctionDescriptor) descriptor;
|
SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) descriptor;
|
||||||
final String fqn = DescriptorUtils.getFQName(functionDescriptor);
|
final String fqn = DescriptorUtils.getFQName(functionDescriptor);
|
||||||
|
|
||||||
if (DescriptorUtils.isTopLevelFunction(functionDescriptor)) {
|
if (DescriptorUtils.isTopLevelFunction(functionDescriptor)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user