Skip to content

Commit

Permalink
Extracted method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Gerashchenko authored and Evgeny Gerashchenko committed Feb 13, 2013
1 parent 18d6e86 commit 105d2d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Expand Up @@ -25,6 +25,7 @@
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory1;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.name.Name;
Expand Down Expand Up @@ -455,10 +456,7 @@ private List<ValueParameterDescriptor> resolveValueParameters(
}

if (!(functionDescriptor instanceof ConstructorDescriptor)) {
ASTNode valOrVarNode = valueParameter.getValOrVarNode();
if (valOrVarNode != null) {
trace.report(VAL_OR_VAR_ON_FUN_PARAMETER.on(valOrVarNode.getPsi(), ((JetKeywordToken) valOrVarNode.getElementType())));
}
checkParameterHasNoValOrVar(trace, valueParameter, VAL_OR_VAR_ON_FUN_PARAMETER);
}

ValueParameterDescriptor valueParameterDescriptor =
Expand Down Expand Up @@ -1382,4 +1380,15 @@ public static boolean checkHasOuterClassInstance(
}
return true;
}

public static void checkParameterHasNoValOrVar(
@NotNull BindingTrace trace,
@NotNull JetParameter parameter,
@NotNull DiagnosticFactory1<PsiElement, JetKeywordToken> diagnosticFactory
) {
ASTNode valOrVarNode = parameter.getValOrVarNode();
if (valOrVarNode != null) {
trace.report(diagnosticFactory.on(valOrVarNode.getPsi(), ((JetKeywordToken) valOrVarNode.getElementType())));
}
}
}
Expand Up @@ -17,7 +17,6 @@
package org.jetbrains.jet.lang.types.expressions;

import com.google.common.collect.Lists;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.Pair;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
Expand All @@ -32,10 +31,11 @@
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
Expand All @@ -45,8 +45,6 @@
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetKeywordToken;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.util.slicedmap.WritableSlice;

import java.util.ArrayList;
Expand Down Expand Up @@ -314,10 +312,7 @@ private static VariableDescriptor createLoopParameterDescriptor(
JetType expectedParameterType,
ExpressionTypingContext context
) {
ASTNode valOrVarNode = loopParameter.getValOrVarNode();
if (valOrVarNode != null) {
context.trace.report(VAL_OR_VAR_ON_LOOP_PARAMETER.on(valOrVarNode.getPsi(), ((JetKeywordToken) valOrVarNode.getElementType())));
}
DescriptorResolver.checkParameterHasNoValOrVar(context.trace, loopParameter, VAL_OR_VAR_ON_LOOP_PARAMETER);

JetTypeReference typeReference = loopParameter.getTypeReference();
VariableDescriptor variableDescriptor;
Expand Down Expand Up @@ -432,10 +427,7 @@ public JetTypeInfo visitTryExpression(JetTryExpression expression, ExpressionTyp
JetParameter catchParameter = catchClause.getCatchParameter();
JetExpression catchBody = catchClause.getCatchBody();
if (catchParameter != null) {
ASTNode valOrVarNode = catchParameter.getValOrVarNode();
if (valOrVarNode != null) {
context.trace.report(VAL_OR_VAR_ON_CATCH_PARAMETER.on(valOrVarNode.getPsi(), ((JetKeywordToken) valOrVarNode.getElementType())));
}
DescriptorResolver.checkParameterHasNoValOrVar(context.trace, catchParameter, VAL_OR_VAR_ON_CATCH_PARAMETER);

VariableDescriptor variableDescriptor = context.expressionTypingServices.getDescriptorResolver().resolveLocalVariableDescriptor(
context.scope.getContainingDeclaration(), context.scope, catchParameter, context.trace);
Expand Down

0 comments on commit 105d2d7

Please sign in to comment.