JetVariableDeclaration made JetCallableDeclaration and renamed getTypeRef/setTypeRef, getReturnTypeRef/setReturnTypeRef to getTypeReference/setTypeReference
This commit is contained in:
+2
-2
@@ -53,7 +53,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
try {
|
||||
checkForSyntaxErrors(altPropertyDeclaration);
|
||||
checkFieldAnnotation(altPropertyDeclaration, field, isVar);
|
||||
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeRef(),
|
||||
altReturnType = computeReturnType(originalReturnType, altPropertyDeclaration.getTypeReference(),
|
||||
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>());
|
||||
}
|
||||
catch (AlternativeSignatureMismatchException e) {
|
||||
@@ -73,7 +73,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
field.getName().asString(), altProperty.getName());
|
||||
}
|
||||
|
||||
if (altProperty.getTypeRef() == null) {
|
||||
if (altProperty.getTypeReference() == null) {
|
||||
throw new AlternativeSignatureMismatchException("Field annotation for shouldn't have type reference");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
computeValueParameters(valueParameters);
|
||||
|
||||
if (originalReturnType != null) {
|
||||
altReturnType = computeReturnType(originalReturnType, altFunDeclaration.getReturnTypeRef(), originalToAltTypeParameters);
|
||||
altReturnType = computeReturnType(originalReturnType, altFunDeclaration.getTypeReference(), originalToAltTypeParameters);
|
||||
}
|
||||
|
||||
if (hasSuperMethods) {
|
||||
|
||||
@@ -72,12 +72,12 @@ public class PositioningStrategies {
|
||||
PsiElement nameIdentifierOrPlaceholder = null;
|
||||
if (declaration instanceof JetNamedFunction) {
|
||||
JetFunction function = (JetNamedFunction) declaration;
|
||||
returnTypeRef = function.getReturnTypeRef();
|
||||
returnTypeRef = function.getTypeReference();
|
||||
nameIdentifierOrPlaceholder = function.getNameIdentifier();
|
||||
}
|
||||
else if (declaration instanceof JetProperty) {
|
||||
JetProperty property = (JetProperty) declaration;
|
||||
returnTypeRef = property.getTypeRef();
|
||||
returnTypeRef = property.getTypeReference();
|
||||
nameIdentifierOrPlaceholder = property.getNameIdentifier();
|
||||
}
|
||||
else if (declaration instanceof JetPropertyAccessor) {
|
||||
@@ -148,7 +148,7 @@ public class PositioningStrategies {
|
||||
JetNamedFunction function = (JetNamedFunction)element;
|
||||
PsiElement endOfSignatureElement;
|
||||
JetParameterList valueParameterList = function.getValueParameterList();
|
||||
JetElement returnTypeRef = function.getReturnTypeRef();
|
||||
JetElement returnTypeRef = function.getTypeReference();
|
||||
PsiElement nameIdentifier = function.getNameIdentifier();
|
||||
if (returnTypeRef != null) {
|
||||
endOfSignatureElement = returnTypeRef;
|
||||
@@ -167,7 +167,7 @@ public class PositioningStrategies {
|
||||
else if (element instanceof JetProperty) {
|
||||
JetProperty property = (JetProperty) element;
|
||||
PsiElement endOfSignatureElement;
|
||||
JetTypeReference propertyTypeRef = property.getTypeRef();
|
||||
JetTypeReference propertyTypeRef = property.getTypeReference();
|
||||
PsiElement nameIdentifier = property.getNameIdentifier();
|
||||
if (propertyTypeRef != null) {
|
||||
endOfSignatureElement = propertyTypeRef;
|
||||
|
||||
@@ -266,7 +266,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
appendInn(typeParameterList)
|
||||
}
|
||||
appendInn(function.getValueParameterList())
|
||||
appendInn(function.getReturnTypeRef(), prefix = ": ")
|
||||
appendInn(function.getTypeReference(), prefix = ": ")
|
||||
appendInn(function.getTypeConstraintList(), prefix = " ")
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ private object DebugTextBuildingVisitor : JetVisitor<String, Unit>() {
|
||||
appendInn(property.getModifierList(), suffix = " ")
|
||||
append(if (property.isVar()) "var " else "val ")
|
||||
appendInn(property.getNameAsName())
|
||||
appendInn(property.getTypeRef(), prefix = ": ")
|
||||
appendInn(property.getTypeReference(), prefix = ": ")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ public interface JetCallableDeclaration extends JetNamedDeclaration, JetTypePara
|
||||
JetTypeReference getReceiverTypeRef();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference getReturnTypeRef();
|
||||
JetTypeReference getTypeReference();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference setReturnTypeRef(@Nullable JetTypeReference typeRef);
|
||||
JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class JetFunctionLiteralExpression extends JetExpressionImpl {
|
||||
}
|
||||
|
||||
public boolean hasDeclaredReturnType() {
|
||||
return getFunctionLiteral().getReturnTypeRef() != null;
|
||||
return getFunctionLiteral().getTypeReference() != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract public class JetFunctionNotStubbed extends JetTypeParameterListOwnerNot
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaredReturnType() {
|
||||
return getReturnTypeRef() != null;
|
||||
return getTypeReference() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,13 +77,13 @@ abstract public class JetFunctionNotStubbed extends JetTypeParameterListOwnerNot
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference getReturnTypeRef() {
|
||||
public JetTypeReference getTypeReference() {
|
||||
return TypeRefHelpersPackage.getTypeRef(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeReference setReturnTypeRef(@Nullable JetTypeReference typeRef) {
|
||||
public JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef) {
|
||||
return TypeRefHelpersPackage.setTypeRef(this, getValueParameterList(), typeRef);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class JetModifiableBlockHelper {
|
||||
}
|
||||
else if (declaration instanceof JetProperty) {
|
||||
JetProperty property = (JetProperty) declaration;
|
||||
if (property.getTypeRef() != null) {
|
||||
if (property.getTypeReference() != null) {
|
||||
return takePartInDeclarationTypeInference(property);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class JetModifiableBlockHelper {
|
||||
}
|
||||
else if (declaration instanceof JetProperty) {
|
||||
JetProperty property = (JetProperty) declaration;
|
||||
if (property.getTypeRef() == null) {
|
||||
if (property.getTypeReference() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ import org.jetbrains.jet.lang.psi.typeRefHelpers.TypeRefHelpersPackage;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD;
|
||||
|
||||
@@ -34,16 +37,40 @@ public class JetMultiDeclarationEntry extends JetNamedDeclarationNotStubbed impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetTypeReference getTypeRef() {
|
||||
public JetTypeReference getTypeReference() {
|
||||
return TypeRefHelpersPackage.getTypeRef(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference setTypeRef(@Nullable JetTypeReference typeRef) {
|
||||
public JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef) {
|
||||
return TypeRefHelpersPackage.setTypeRef(this, getNameIdentifier(), typeRef);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetParameterList getValueParameterList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeReference getReceiverTypeRef() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetTypeConstraint> getTypeConstraints() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JetTypeParameter> getTypeParameters() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(@NotNull JetVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitMultiDeclarationEntry(this, data);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
||||
|
||||
@Override
|
||||
public boolean hasDeclaredReturnType() {
|
||||
return getReturnTypeRef() != null;
|
||||
return getTypeReference() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,7 +165,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference getReturnTypeRef() {
|
||||
public JetTypeReference getTypeReference() {
|
||||
PsiJetFunctionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
List<JetTypeReference> typeReferences = getStubOrPsiChildrenAsList(JetStubElementTypes.TYPE_REFERENCE);
|
||||
@@ -180,7 +180,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference setReturnTypeRef(@Nullable JetTypeReference typeRef) {
|
||||
public JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef) {
|
||||
return TypeRefHelpersPackage.setTypeRef(this, getValueParameterList(), typeRef);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ import java.util.List;
|
||||
import static org.jetbrains.jet.JetNodeTypes.PROPERTY_DELEGATE;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.*;
|
||||
|
||||
public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStub> implements JetVariableDeclaration,
|
||||
JetCallableDeclaration {
|
||||
public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStub> implements JetVariableDeclaration {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(JetProperty.class);
|
||||
|
||||
@@ -116,21 +115,9 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeReference getReturnTypeRef() {
|
||||
return getTypeRef();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeReference setReturnTypeRef(@Nullable JetTypeReference typeRef) {
|
||||
return setTypeRef(typeRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference getTypeRef() {
|
||||
public JetTypeReference getTypeReference() {
|
||||
PsiJetPropertyStub stub = getStub();
|
||||
if (stub != null) {
|
||||
if (!stub.hasReturnTypeRef()) {
|
||||
@@ -151,7 +138,7 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference setTypeRef(@Nullable JetTypeReference typeRef) {
|
||||
public JetTypeReference setTypeReference(@Nullable JetTypeReference typeRef) {
|
||||
return TypeRefHelpersPackage.setTypeRef(this, getNameIdentifier(), typeRef);
|
||||
}
|
||||
|
||||
@@ -242,7 +229,7 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
}
|
||||
else {
|
||||
if (initializer != null) {
|
||||
PsiElement addAfter = getTypeRef();
|
||||
PsiElement addAfter = getTypeReference();
|
||||
if (addAfter == null) {
|
||||
addAfter = getNameIdentifier();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class JetPsiFactory(private val project: Project) {
|
||||
}
|
||||
|
||||
public fun createType(`type`: String): JetTypeReference {
|
||||
return createProperty("val x : $`type`").getTypeRef()!!
|
||||
return createProperty("val x : $`type`").getTypeReference()!!
|
||||
}
|
||||
|
||||
public fun createStar(): PsiElement {
|
||||
|
||||
@@ -19,15 +19,9 @@ package org.jetbrains.jet.lang.psi;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface JetVariableDeclaration extends JetDeclaration, JetWithExpressionInitializer, JetNamedDeclaration {
|
||||
public interface JetVariableDeclaration extends JetCallableDeclaration, JetWithExpressionInitializer {
|
||||
boolean isVar();
|
||||
|
||||
@Nullable
|
||||
ASTNode getValOrVarNode();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference getTypeRef();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference setTypeRef(@Nullable JetTypeReference typeRef);
|
||||
}
|
||||
|
||||
+1
-4
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs.elements;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.stubs.IndexSink;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.psi.stubs.StubInputStream;
|
||||
@@ -25,7 +23,6 @@ import com.intellij.psi.stubs.StubOutputStream;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetPropertyStub;
|
||||
import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetPropertyStubImpl;
|
||||
@@ -49,7 +46,7 @@ public class JetPropertyElementType extends JetStubElementType<PsiJetPropertyStu
|
||||
parentStub, StringRef.fromString(psi.getName()),
|
||||
psi.isVar(), psi.isTopLevel(), psi.hasDelegate(),
|
||||
psi.hasDelegateExpression(), psi.hasInitializer(),
|
||||
psi.getReceiverTypeRef() != null, psi.getReturnTypeRef() != null,
|
||||
psi.getReceiverTypeRef() != null, psi.getTypeReference() != null,
|
||||
ResolveSessionUtils.safeFqNameForLazyResolve(psi)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ public class BodyResolver {
|
||||
) {
|
||||
JetScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
||||
scope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
|
||||
JetType expectedTypeForInitializer = property.getTypeRef() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
JetType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
CompileTimeConstant<?> compileTimeInitializer = propertyDescriptor.getCompileTimeInitializer();
|
||||
if (compileTimeInitializer == null) {
|
||||
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer, c.getOuterDataFlowInfo(), trace);
|
||||
|
||||
@@ -362,12 +362,12 @@ public class DeclarationsChecker {
|
||||
private void checkDeclaredTypeInPublicMember(JetNamedDeclaration member, CallableMemberDescriptor memberDescriptor) {
|
||||
boolean hasDeferredType;
|
||||
if (member instanceof JetProperty) {
|
||||
hasDeferredType = ((JetProperty) member).getTypeRef() == null && DescriptorResolver.hasBody((JetProperty) member);
|
||||
hasDeferredType = ((JetProperty) member).getTypeReference() == null && DescriptorResolver.hasBody((JetProperty) member);
|
||||
}
|
||||
else {
|
||||
assert member instanceof JetFunction;
|
||||
JetFunction function = (JetFunction) member;
|
||||
hasDeferredType = function.getReturnTypeRef() == null && function.hasBody() && !function.hasBlockBody();
|
||||
hasDeferredType = function.getTypeReference() == null && function.hasBody() && !function.hasBlockBody();
|
||||
}
|
||||
if ((memberDescriptor.getVisibility().isPublicAPI()) && memberDescriptor.getOverriddenDescriptors().size() == 0 && hasDeferredType) {
|
||||
trace.report(PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE.on(member));
|
||||
@@ -425,7 +425,7 @@ public class DeclarationsChecker {
|
||||
(setter != null && setter.hasBody());
|
||||
|
||||
if (propertyDescriptor.getModality() == Modality.ABSTRACT) {
|
||||
if (!property.hasDelegateExpressionOrInitializer() && property.getTypeRef() == null) {
|
||||
if (!property.hasDelegateExpressionOrInitializer() && property.getTypeReference() == null) {
|
||||
trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property));
|
||||
}
|
||||
return;
|
||||
@@ -454,7 +454,7 @@ public class DeclarationsChecker {
|
||||
trace.report(MUST_BE_INITIALIZED_OR_BE_ABSTRACT.on(property));
|
||||
}
|
||||
}
|
||||
if (!error && property.getTypeRef() == null) {
|
||||
if (!error && property.getTypeReference() == null) {
|
||||
trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property));
|
||||
}
|
||||
if (inTrait && property.hasModifier(JetTokens.FINAL_KEYWORD) && backingFieldRequired) {
|
||||
|
||||
@@ -302,7 +302,7 @@ public class DelegatedPropertyResolver {
|
||||
@NotNull final JetScope accessorScope,
|
||||
@NotNull final BindingTrace trace
|
||||
) {
|
||||
final JetType expectedType = property.getTypeRef() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
final JetType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
return new ConstraintSystemCompleter() {
|
||||
@Override
|
||||
public void completeConstraintSystem(
|
||||
|
||||
@@ -331,7 +331,7 @@ public class DescriptorResolver {
|
||||
|
||||
innerScope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
|
||||
JetTypeReference returnTypeRef = function.getReturnTypeRef();
|
||||
JetTypeReference returnTypeRef = function.getTypeReference();
|
||||
JetType returnType;
|
||||
if (returnTypeRef != null) {
|
||||
returnType = typeResolver.resolveType(innerScope, returnTypeRef, trace, true);
|
||||
@@ -1005,7 +1005,7 @@ public class DescriptorResolver {
|
||||
boolean notLocal,
|
||||
@NotNull final BindingTrace trace
|
||||
) {
|
||||
JetTypeReference propertyTypeRef = variable.getTypeRef();
|
||||
JetTypeReference propertyTypeRef = variable.getTypeReference();
|
||||
|
||||
boolean hasDelegate = variable instanceof JetProperty && ((JetProperty) variable).hasDelegateExpression();
|
||||
if (propertyTypeRef == null) {
|
||||
|
||||
+1
-2
@@ -41,7 +41,6 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.getRecordedTypeInfo;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.CallResolverUtil.ResolveArgumentsMode;
|
||||
@@ -211,7 +210,7 @@ public class ArgumentTypeResolver {
|
||||
parameterTypes.add(resolveTypeRefWithDefault(parameter.getTypeReference(), scope, temporaryTrace, DONT_CARE));
|
||||
}
|
||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
JetType returnType = resolveTypeRefWithDefault(functionLiteral.getReturnTypeRef(), scope, temporaryTrace, DONT_CARE);
|
||||
JetType returnType = resolveTypeRefWithDefault(functionLiteral.getTypeReference(), scope, temporaryTrace, DONT_CARE);
|
||||
assert returnType != null;
|
||||
JetType receiverType = resolveTypeRefWithDefault(functionLiteral.getReceiverTypeRef(), scope, temporaryTrace, null);
|
||||
return KotlinBuiltIns.getInstance().getFunctionType(Annotations.EMPTY, receiverType, parameterTypes,
|
||||
|
||||
@@ -48,6 +48,6 @@ public fun shouldBeScriptClassMember(declaration: JetDeclaration): Boolean {
|
||||
// To avoid the necessity to always analyze the whole body of a script even if just its class descriptor is needed
|
||||
// we only add those vals, vars and funs that have explicitly specified return types
|
||||
// (or implicit Unit for function with block body)
|
||||
return declaration is JetCallableDeclaration && declaration.getReturnTypeRef() != null
|
||||
return declaration is JetCallableDeclaration && declaration.getTypeReference() != null
|
||||
|| declaration is JetNamedFunction && declaration.hasBlockBody()
|
||||
}
|
||||
|
||||
+1
-1
@@ -275,7 +275,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
assert bodyExpression != null;
|
||||
|
||||
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
||||
JetTypeReference returnTypeRef = functionLiteral.getReturnTypeRef();
|
||||
JetTypeReference returnTypeRef = functionLiteral.getTypeReference();
|
||||
JetType declaredReturnType = null;
|
||||
if (returnTypeRef != null) {
|
||||
declaredReturnType = components.expressionTypingServices.getTypeResolver().resolveType(context.scope, returnTypeRef, context.trace, true);
|
||||
|
||||
+1
-1
@@ -517,7 +517,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
||||
private static JetType getFunctionExpectedReturnType(@NotNull FunctionDescriptor descriptor, @NotNull JetElement function) {
|
||||
JetType expectedType;
|
||||
if (function instanceof JetFunction) {
|
||||
if (((JetFunction) function).getReturnTypeRef() != null || ((JetFunction) function).hasBlockBody()) {
|
||||
if (((JetFunction) function).getTypeReference() != null || ((JetFunction) function).hasBlockBody()) {
|
||||
expectedType = descriptor.getReturnType();
|
||||
}
|
||||
else {
|
||||
|
||||
+1
-1
@@ -391,7 +391,7 @@ public class ExpressionTypingUtils {
|
||||
|
||||
@NotNull
|
||||
private JetType getExpectedTypeForComponent(ExpressionTypingContext context, JetMultiDeclarationEntry entry) {
|
||||
JetTypeReference entryTypeRef = entry.getTypeRef();
|
||||
JetTypeReference entryTypeRef = entry.getTypeReference();
|
||||
if (entryTypeRef != null) {
|
||||
return expressionTypingServices.getTypeResolver().resolveType(context.scope, entryTypeRef, context.trace, true);
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class RemoveExplicitTypeArguments : JetSelfTargetingIntention<JetTypeArgu
|
||||
// therefore we should resolve outer call with erased type arguments for inner call
|
||||
val parent = callExpression.getParent()
|
||||
val expectedTypeIsExplicitInCode = when (parent) {
|
||||
is JetProperty -> parent.getInitializer() == callExpression && parent.getTypeRef() != null
|
||||
is JetProperty -> parent.getInitializer() == callExpression && parent.getTypeReference() != null
|
||||
is JetDeclarationWithBody -> parent.getBodyExpression() == callExpression
|
||||
is JetReturnExpression -> true
|
||||
else -> false
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public class MoveDeclarationsOutHelper {
|
||||
|
||||
@NotNull
|
||||
private static JetProperty createProperty(@NotNull JetProperty property, @NotNull JetType propertyType, @Nullable String initializer) {
|
||||
JetTypeReference typeRef = property.getTypeRef();
|
||||
JetTypeReference typeRef = property.getTypeReference();
|
||||
String typeString = null;
|
||||
if (typeRef != null) {
|
||||
typeString = typeRef.getText();
|
||||
|
||||
@@ -75,7 +75,7 @@ public class JetDeclarationMover extends AbstractJetUpDownMover {
|
||||
JetTypeReference receiverTypeRef = function.getReceiverTypeRef();
|
||||
if (receiverTypeRef != null) memberSuspects.add(receiverTypeRef);
|
||||
|
||||
JetTypeReference returnTypeRef = function.getReturnTypeRef();
|
||||
JetTypeReference returnTypeRef = function.getTypeReference();
|
||||
if (returnTypeRef != null) memberSuspects.add(returnTypeRef);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class JetDeclarationMover extends AbstractJetUpDownMover {
|
||||
JetTypeReference receiverTypeRef = property.getReceiverTypeRef();
|
||||
if (receiverTypeRef != null) memberSuspects.add(receiverTypeRef);
|
||||
|
||||
JetTypeReference returnTypeRef = property.getTypeRef();
|
||||
JetTypeReference returnTypeRef = property.getTypeReference();
|
||||
if (returnTypeRef != null) memberSuspects.add(returnTypeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public object JetKeywordInsertHandler : InsertHandler<LookupElement> {
|
||||
val element = context.getFile().findElementAt(context.getStartOffset())
|
||||
if (element != null) {
|
||||
val jetFunction = PsiTreeUtil.getParentOfType(element, javaClass<JetFunction>())
|
||||
if (jetFunction != null && (!jetFunction.hasDeclaredReturnType() || JetPsiUtil.isVoidType(jetFunction.getReturnTypeRef()))) {
|
||||
if (jetFunction != null && (!jetFunction.hasDeclaredReturnType() || JetPsiUtil.isVoidType(jetFunction.getTypeReference()))) {
|
||||
// No space for void function
|
||||
return
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ class SmartCompletion(val expression: JetSimpleNameExpression,
|
||||
private fun implicitlyTypedDeclarationFromInitializer(expression: JetExpression): JetDeclaration? {
|
||||
val parent = expression.getParent()
|
||||
when (parent) {
|
||||
is JetVariableDeclaration -> if (expression == parent.getInitializer() && parent.getTypeRef() == null) return parent
|
||||
is JetNamedFunction -> if (expression == parent.getInitializer() && parent.getReturnTypeRef() == null) return parent
|
||||
is JetVariableDeclaration -> if (expression == parent.getInitializer() && parent.getTypeReference() == null) return parent
|
||||
is JetNamedFunction -> if (expression == parent.getInitializer() && parent.getTypeReference() == null) return parent
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public object JetUsageTypeProvider : UsageTypeProviderEx {
|
||||
val property = refExpr.getParentByType(javaClass<JetProperty>())
|
||||
if (property != null) {
|
||||
when {
|
||||
property.getTypeRef().isAncestor(refExpr) ->
|
||||
property.getTypeReference().isAncestor(refExpr) ->
|
||||
return if (property.isLocal()) UsageType.CLASS_LOCAL_VAR_DECLARATION else JetUsageTypes.NON_LOCAL_PROPERTY_TYPE
|
||||
|
||||
property.getReceiverTypeRef().isAncestor(refExpr) ->
|
||||
@@ -72,7 +72,7 @@ public object JetUsageTypeProvider : UsageTypeProviderEx {
|
||||
val function = refExpr.getParentByType(javaClass<JetFunction>())
|
||||
if (function != null) {
|
||||
when {
|
||||
function.getReturnTypeRef().isAncestor(refExpr) ->
|
||||
function.getTypeReference().isAncestor(refExpr) ->
|
||||
return JetUsageTypes.FUNCTION_RETURN_TYPE
|
||||
function.getReceiverTypeRef().isAncestor(refExpr) ->
|
||||
return JetUsageTypes.EXTENSION_RECEIVER_TYPE
|
||||
|
||||
@@ -90,7 +90,7 @@ public class MakeTypeExplicitInLambdaIntention : JetSelfTargetingIntention<JetFu
|
||||
val returnTypeExpr = psiFactory.createType(DescriptorRenderer.SOURCE_CODE.renderType(expectedReturnType))
|
||||
functionLiteral.addAfter(returnTypeExpr, paramList)
|
||||
functionLiteral.addAfter(returnTypeColon, paramList)
|
||||
ShortenReferences.process(functionLiteral.getReturnTypeRef()!!)
|
||||
ShortenReferences.process(functionLiteral.getTypeReference()!!)
|
||||
}
|
||||
|
||||
// Step 3: make the receiver type explicit
|
||||
|
||||
@@ -70,11 +70,11 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
JetType type = getTypeForDeclaration((JetNamedDeclaration) parent);
|
||||
if (parent instanceof JetProperty) {
|
||||
JetProperty property = (JetProperty) parent;
|
||||
if (property.getTypeRef() == null) {
|
||||
if (property.getTypeReference() == null) {
|
||||
addTypeAnnotation(project, editor, property, type);
|
||||
}
|
||||
else {
|
||||
property.setTypeRef(null);
|
||||
property.setTypeReference(null);
|
||||
}
|
||||
}
|
||||
else if (parent instanceof JetParameter) {
|
||||
@@ -88,7 +88,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
else if (parent instanceof JetNamedFunction) {
|
||||
JetNamedFunction function = (JetNamedFunction) parent;
|
||||
assert function.getReturnTypeRef() == null;
|
||||
assert function.getTypeReference() == null;
|
||||
addTypeAnnotation(project, editor, function, type);
|
||||
}
|
||||
else {
|
||||
@@ -113,7 +113,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
JetNamedDeclaration declaration = (JetNamedDeclaration) parent;
|
||||
|
||||
if (declaration instanceof JetProperty && !PsiTreeUtil.isAncestor(((JetProperty) declaration).getInitializer(), element, false)) {
|
||||
if (((JetProperty) declaration).getTypeRef() != null) {
|
||||
if (((JetProperty) declaration).getTypeReference() != null) {
|
||||
setText(JetBundle.message("specify.type.explicitly.remove.action.name"));
|
||||
return true;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
setText(JetBundle.message("specify.type.explicitly.add.action.name"));
|
||||
}
|
||||
}
|
||||
else if (declaration instanceof JetNamedFunction && ((JetNamedFunction) declaration).getReturnTypeRef() == null
|
||||
else if (declaration instanceof JetNamedFunction && ((JetNamedFunction) declaration).getTypeReference() == null
|
||||
&& !((JetNamedFunction) declaration).hasBlockBody()) {
|
||||
setText(JetBundle.message("specify.type.explicitly.add.return.type.action.name"));
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
@NotNull JetProperty property,
|
||||
@NotNull JetType exprType
|
||||
) {
|
||||
if (property.getTypeRef() != null) return;
|
||||
if (property.getTypeReference() != null) return;
|
||||
|
||||
addTypeAnnotationWithTemplate(project, editor, property, exprType);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
addTypeAnnotationWithTemplate(project, editor, function, exprType);
|
||||
}
|
||||
else {
|
||||
function.setReturnTypeRef(anyTypeRef(project));
|
||||
function.setTypeReference(anyTypeRef(project));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,13 +265,13 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
@Nullable
|
||||
private static JetTypeReference getTypeRef(@NotNull JetNamedDeclaration namedDeclaration) {
|
||||
if (namedDeclaration instanceof JetProperty) {
|
||||
return ((JetProperty) namedDeclaration).getTypeRef();
|
||||
return ((JetProperty) namedDeclaration).getTypeReference();
|
||||
}
|
||||
else if (namedDeclaration instanceof JetParameter) {
|
||||
return ((JetParameter) namedDeclaration).getTypeReference();
|
||||
}
|
||||
else if (namedDeclaration instanceof JetFunction) {
|
||||
return ((JetFunction) namedDeclaration).getReturnTypeRef();
|
||||
return ((JetFunction) namedDeclaration).getTypeReference();
|
||||
}
|
||||
assert false : "Wrong namedDeclaration: " + namedDeclaration.getText();
|
||||
return null;
|
||||
@@ -280,13 +280,13 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||
@Nullable
|
||||
private static JetTypeReference setTypeRef(@NotNull JetNamedDeclaration namedDeclaration, @Nullable JetTypeReference typeRef) {
|
||||
if (namedDeclaration instanceof JetProperty) {
|
||||
return ((JetProperty) namedDeclaration).setTypeRef(typeRef);
|
||||
return ((JetProperty) namedDeclaration).setTypeReference(typeRef);
|
||||
}
|
||||
else if (namedDeclaration instanceof JetParameter) {
|
||||
return ((JetParameter) namedDeclaration).setTypeRef(typeRef);
|
||||
}
|
||||
else if (namedDeclaration instanceof JetFunction) {
|
||||
return ((JetFunction) namedDeclaration).setReturnTypeRef(typeRef);
|
||||
return ((JetFunction) namedDeclaration).setTypeReference(typeRef);
|
||||
}
|
||||
assert false : "Wrong namedDeclaration: " + namedDeclaration.getText();
|
||||
return null;
|
||||
|
||||
@@ -34,7 +34,7 @@ fun specifyTypeExplicitly(declaration: JetNamedFunction, `type`: JetType) {
|
||||
if (`type`.isError()) return
|
||||
val typeReference = JetPsiFactory(declaration).createType(DescriptorRenderer.SOURCE_CODE.renderType(`type`))
|
||||
specifyTypeExplicitly(declaration, typeReference)
|
||||
ShortenReferences.process(declaration.getReturnTypeRef()!!)
|
||||
ShortenReferences.process(declaration.getTypeReference()!!)
|
||||
}
|
||||
|
||||
fun specifyTypeExplicitly(declaration: JetNamedFunction, typeReference: JetTypeReference) {
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class ConvertMemberToExtension extends BaseIntentionAction {
|
||||
String name = identifier == null ? "" : identifier.getText();
|
||||
|
||||
JetParameterList valueParameterList = member.getValueParameterList();
|
||||
JetTypeReference returnTypeRef = member.getReturnTypeRef();
|
||||
JetTypeReference returnTypeRef = member.getTypeReference();
|
||||
|
||||
String extensionText = modifiers(member) +
|
||||
memberType(member) + " " +
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DeclarationUtils {
|
||||
|
||||
@Nullable
|
||||
private static JetType getPropertyTypeIfNeeded(@NotNull JetProperty property) {
|
||||
if (property.getTypeRef() != null) return null;
|
||||
if (property.getTypeReference() != null) return null;
|
||||
|
||||
JetType type = AnalyzerFacadeWithCache.getContextForElement(property).get(
|
||||
BindingContext.EXPRESSION_TYPE, property.getInitializer()
|
||||
@@ -74,7 +74,7 @@ public class DeclarationUtils {
|
||||
|
||||
String typeStr = inferredType != null
|
||||
? DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(inferredType)
|
||||
: JetPsiUtil.getNullableText(property.getTypeRef());
|
||||
: JetPsiUtil.getNullableText(property.getTypeReference());
|
||||
|
||||
//noinspection ConstantConditions
|
||||
property = (JetProperty) property.replace(
|
||||
@@ -82,7 +82,7 @@ public class DeclarationUtils {
|
||||
);
|
||||
|
||||
if (inferredType != null) {
|
||||
ShortenReferences.INSTANCE$.process(property.getTypeRef());
|
||||
ShortenReferences.INSTANCE$.process(property.getTypeReference());
|
||||
}
|
||||
|
||||
return newInitializer;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JetDeclarationTreeNode extends AbstractPsiBasedNode<JetDeclaration>
|
||||
|
||||
if (declaration instanceof JetProperty) {
|
||||
JetProperty property = (JetProperty) declaration;
|
||||
JetTypeReference ref = property.getTypeRef();
|
||||
JetTypeReference ref = property.getTypeReference();
|
||||
if (ref != null) {
|
||||
if (settings.SPACE_BEFORE_TYPE_COLON) text += " ";
|
||||
text += ":";
|
||||
@@ -90,7 +90,7 @@ public class JetDeclarationTreeNode extends AbstractPsiBasedNode<JetDeclaration>
|
||||
}
|
||||
if (parameters.size() > 0) text = text.substring(0, text.length() - 2);
|
||||
text += ")";
|
||||
JetTypeReference typeReference = function.getReturnTypeRef();
|
||||
JetTypeReference typeReference = function.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
if (settings.SPACE_BEFORE_TYPE_COLON) text += " ";
|
||||
text += ":";
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends JetIntentionAction<JetFu
|
||||
public ChangeFunctionLiteralReturnTypeFix(@NotNull JetFunctionLiteralExpression functionLiteralExpression, @NotNull JetType type) {
|
||||
super(functionLiteralExpression);
|
||||
renderedType = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(type);
|
||||
functionLiteralReturnTypeRef = functionLiteralExpression.getFunctionLiteral().getReturnTypeRef();
|
||||
functionLiteralReturnTypeRef = functionLiteralExpression.getFunctionLiteral().getTypeReference();
|
||||
|
||||
BindingContext context = ResolvePackage.getBindingContext(functionLiteralExpression.getContainingJetFile());
|
||||
JetType functionLiteralType = context.get(BindingContext.EXPRESSION_TYPE, functionLiteralExpression);
|
||||
@@ -71,7 +71,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends JetIntentionAction<JetFu
|
||||
|
||||
JetProperty correspondingProperty = PsiTreeUtil.getParentOfType(functionLiteralExpression, JetProperty.class);
|
||||
if (correspondingProperty != null && QuickFixUtil.canEvaluateTo(correspondingProperty.getInitializer(), functionLiteralExpression)) {
|
||||
JetTypeReference correspondingPropertyTypeRef = correspondingProperty.getTypeRef();
|
||||
JetTypeReference correspondingPropertyTypeRef = correspondingProperty.getTypeReference();
|
||||
JetType propertyType = context.get(BindingContext.TYPE, correspondingPropertyTypeRef);
|
||||
if (propertyType != null && !JetTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, propertyType)) {
|
||||
appropriateQuickFix = new ChangeVariableTypeFix(correspondingProperty, eventualFunctionLiteralType);
|
||||
@@ -97,7 +97,7 @@ public class ChangeFunctionLiteralReturnTypeFix extends JetIntentionAction<JetFu
|
||||
|
||||
JetFunction parentFunction = PsiTreeUtil.getParentOfType(functionLiteralExpression, JetFunction.class, true);
|
||||
if (parentFunction != null && QuickFixUtil.canFunctionOrGetterReturnExpression(parentFunction, functionLiteralExpression)) {
|
||||
JetTypeReference parentFunctionReturnTypeRef = parentFunction.getReturnTypeRef();
|
||||
JetTypeReference parentFunctionReturnTypeRef = parentFunction.getTypeReference();
|
||||
JetType parentFunctionReturnType = context.get(BindingContext.TYPE, parentFunctionReturnTypeRef);
|
||||
if (parentFunctionReturnType != null && !JetTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, parentFunctionReturnType)) {
|
||||
appropriateQuickFix = new ChangeFunctionReturnTypeFix(parentFunction, eventualFunctionLiteralType);
|
||||
|
||||
@@ -108,10 +108,10 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
}
|
||||
else {
|
||||
if (!(KotlinBuiltIns.getInstance().isUnit(type) && element.hasBlockBody())) {
|
||||
element.setReturnTypeRef(JetPsiFactory(project).createType(renderedType));
|
||||
element.setTypeReference(JetPsiFactory(project).createType(renderedType));
|
||||
}
|
||||
else {
|
||||
element.setReturnTypeRef(null);
|
||||
element.setTypeReference(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
if (resolvedCall == null) return null;
|
||||
JetFunction componentFunction = (JetFunction) DescriptorToSourceUtils
|
||||
.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
JetType expectedType = context.get(BindingContext.TYPE, entry.getTypeRef());
|
||||
JetType expectedType = context.get(BindingContext.TYPE, entry.getTypeReference());
|
||||
if (componentFunction != null && expectedType != null) {
|
||||
return new ChangeFunctionReturnTypeFix(componentFunction, expectedType);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ public class ChangeMemberFunctionSignatureFix extends JetHintAction<JetNamedFunc
|
||||
public void run() {
|
||||
JetNamedFunction patternFunction = psiFactory.createFunction(signatureString);
|
||||
|
||||
JetTypeReference newTypeRef = function.setReturnTypeRef(patternFunction.getReturnTypeRef());
|
||||
JetTypeReference newTypeRef = function.setTypeReference(patternFunction.getTypeReference());
|
||||
if (newTypeRef != null) {
|
||||
ShortenReferences.INSTANCE$.process(newTypeRef);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ChangeVariableTypeFix extends JetIntentionAction<JetVariableDeclara
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
|
||||
element.setTypeRef(null);
|
||||
element.setTypeReference(null);
|
||||
PsiElement nameIdentifier = element.getNameIdentifier();
|
||||
assert nameIdentifier != null : "ChangeVariableTypeFix applied to variable without name";
|
||||
JetPsiFactory psiFactory = JetPsiFactory(file);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class RemovePartsFromPropertyFix extends JetIntentionAction<JetProperty>
|
||||
assert nextSibling != null;
|
||||
newElement.deleteChildRange(nextSibling, initializer);
|
||||
|
||||
if (newElement.getTypeRef() == null && type != null) {
|
||||
if (newElement.getTypeReference() == null && type != null) {
|
||||
typeToAdd = type;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -379,7 +379,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
}
|
||||
|
||||
if (returnTypeExpression != null) {
|
||||
val returnTypeRef = declaration.getReturnTypeRef()
|
||||
val returnTypeRef = declaration.getTypeReference()
|
||||
if (returnTypeRef != null) {
|
||||
val returnType = returnTypeExpression.getTypeFromSelection(
|
||||
returnTypeRef.getText()
|
||||
@@ -388,7 +388,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
if (returnType != null) {
|
||||
// user selected a given type
|
||||
replaceWithLongerName(returnTypeRef, returnType)
|
||||
typeRefsToShorten.add(declaration.getReturnTypeRef()!!)
|
||||
typeRefsToShorten.add(declaration.getTypeReference()!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -420,7 +420,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
private fun setupFunctionBody(func: JetNamedFunction) {
|
||||
val fileTemplate = FileTemplateManager.getInstance()!!.getCodeTemplate(TEMPLATE_FROM_USAGE_FUNCTION_BODY)
|
||||
val properties = Properties()
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, if (isUnit) "Unit" else func.getReturnTypeRef()!!.getText())
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, if (isUnit) "Unit" else func.getTypeReference()!!.getText())
|
||||
receiverClassDescriptor?.let {
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_CLASS_NAME, DescriptorUtils.getFqName(it).asString())
|
||||
properties.setProperty(FileTemplate.ATTRIBUTE_SIMPLE_CLASS_NAME, it.getName().asString())
|
||||
@@ -444,7 +444,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
}
|
||||
|
||||
private fun setupReturnTypeTemplate(builder: TemplateBuilder, declaration: JetCallableDeclaration): TypeExpression? {
|
||||
val returnTypeRef = declaration.getReturnTypeRef() ?: return null
|
||||
val returnTypeRef = declaration.getTypeReference() ?: return null
|
||||
val candidates = typeCandidates[config.callableInfo.returnTypeInfo]!!
|
||||
return when (candidates.size) {
|
||||
0 -> null
|
||||
@@ -476,7 +476,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
typeParameterMap[it.renderedType!!] = it.typeParameterNames!!
|
||||
}
|
||||
|
||||
if (declaration.getReturnTypeRef() != null) {
|
||||
if (declaration.getTypeReference() != null) {
|
||||
typeCandidates[config.callableInfo.returnTypeInfo]!!.forEach {
|
||||
typeParameterMap[it.renderedType!!] = it.typeParameterNames!!
|
||||
}
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ private class TypeParameterListExpression(private val typeParameterNamesFromRece
|
||||
}
|
||||
}
|
||||
}
|
||||
val returnTypeRef = func.getReturnTypeRef()
|
||||
val returnTypeRef = func.getTypeReference()
|
||||
if (returnTypeRef != null) {
|
||||
val typeParameterNamesFromReturnType = parameterTypeToTypeParameterNamesMap[returnTypeRef.getText()]
|
||||
if (typeParameterNamesFromReturnType != null) {
|
||||
|
||||
+2
-2
@@ -97,7 +97,7 @@ fun JetExpression.guessTypes(context: BindingContext): Array<JetType> {
|
||||
}
|
||||
this is JetMultiDeclarationEntry -> {
|
||||
// expression is on the lhs of a multi-declaration
|
||||
val typeRef = getTypeRef()
|
||||
val typeRef = getTypeReference()
|
||||
if (typeRef != null) {
|
||||
// and has a specified type
|
||||
array(context[BindingContext.TYPE, typeRef]!!)
|
||||
@@ -122,7 +122,7 @@ fun JetExpression.guessTypes(context: BindingContext): Array<JetType> {
|
||||
getParent() is JetVariableDeclaration -> {
|
||||
// the expression is the RHS of a variable assignment with a specified type
|
||||
val variable = getParent() as JetVariableDeclaration
|
||||
val typeRef = variable.getTypeRef()
|
||||
val typeRef = variable.getTypeReference()
|
||||
if (typeRef != null) {
|
||||
// and has a specified type
|
||||
array(context[BindingContext.TYPE, typeRef]!!)
|
||||
|
||||
+2
-2
@@ -57,12 +57,12 @@ public class JetFunctionDefinitionUsage extends JetUsageInfo<PsiElement> {
|
||||
}
|
||||
}
|
||||
if (changeInfo.isReturnTypeChanged()) {
|
||||
function.setReturnTypeRef(null);
|
||||
function.setTypeReference(null);
|
||||
String returnTypeText = changeInfo.getNewReturnTypeText();
|
||||
|
||||
//TODO use ChangeFunctionReturnTypeFix.invoke when JetTypeCodeFragment.getType() is ready
|
||||
if (!KotlinBuiltIns.getInstance().getUnitType().toString().equals(returnTypeText)) {
|
||||
function.setReturnTypeRef(JetPsiFactory(function).createType(returnTypeText));
|
||||
function.setTypeReference(JetPsiFactory(function).createType(returnTypeText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ private fun makeCall(
|
||||
block.addBefore(newLine, anchorInBlock)
|
||||
}
|
||||
|
||||
val entries = declarationsToMerge.map { p -> p.getName() + (p.getTypeRef()?.let { ": ${it.getText()}" } ?: "") }
|
||||
val entries = declarationsToMerge.map { p -> p.getName() + (p.getTypeReference()?.let { ": ${it.getText()}" } ?: "") }
|
||||
anchorInBlock?.replace(
|
||||
psiFactory.createDeclaration("${if (isVar) "var" else "val"} (${entries.joinToString()}) = $callText")
|
||||
)
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public class KotlinInplaceVariableIntroducer extends InplaceVariableIntroducer<J
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
|
||||
}
|
||||
else {
|
||||
myProperty.setTypeRef(null);
|
||||
myProperty.setTypeReference(null);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
|
||||
@@ -468,7 +468,7 @@ public class JetPsiUnifier(
|
||||
desc2: CallableDescriptor): Status? {
|
||||
fun needToCompareReturnTypes(): Boolean {
|
||||
if (decl1 !is JetCallableDeclaration) return true
|
||||
return decl1.getReturnTypeRef() != null || (decl2 as JetCallableDeclaration).getReturnTypeRef() != null
|
||||
return decl1.getTypeReference() != null || (decl2 as JetCallableDeclaration).getTypeReference() != null
|
||||
}
|
||||
|
||||
if (desc1 is VariableDescriptor && desc1.isVar() != (desc2 as VariableDescriptor).isVar()) return UNMATCHED
|
||||
|
||||
Reference in New Issue
Block a user