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