mark last parenthesis instead of value argument list
This commit is contained in:
@@ -352,7 +352,7 @@ public interface Errors {
|
||||
|
||||
AmbiguousDescriptorDiagnosticFactory OVERLOAD_RESOLUTION_AMBIGUITY = new AmbiguousDescriptorDiagnosticFactory();
|
||||
AmbiguousDescriptorDiagnosticFactory NONE_APPLICABLE = new AmbiguousDescriptorDiagnosticFactory();
|
||||
DiagnosticFactory1<PsiElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetElement, ValueParameterDescriptor> NO_VALUE_FOR_PARAMETER = DiagnosticFactory1.create(ERROR, VALUE_ARGUMENTS);
|
||||
DiagnosticFactory1<JetReferenceExpression, JetType> MISSING_RECEIVER = DiagnosticFactory1.create(ERROR);
|
||||
SimpleDiagnosticFactory<JetReferenceExpression> NO_RECEIVER_ADMITTED = SimpleDiagnosticFactory.create(ERROR);
|
||||
|
||||
|
||||
@@ -322,4 +322,19 @@ public class PositioningStrategies {
|
||||
return super.mark(element);
|
||||
}
|
||||
};
|
||||
|
||||
public static PositioningStrategy<JetElement> VALUE_ARGUMENTS = new PositioningStrategy<JetElement>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<TextRange> mark(@NotNull JetElement element) {
|
||||
if (element instanceof JetValueArgumentList) {
|
||||
PsiElement rightParenthesis = ((JetValueArgumentList) element).getRightParenthesis();
|
||||
if (rightParenthesis != null) {
|
||||
return markElement(rightParenthesis);
|
||||
}
|
||||
|
||||
}
|
||||
return super.mark(element);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -17,8 +17,11 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,4 +46,10 @@ public class JetValueArgumentList extends JetElementImpl {
|
||||
public List<JetValueArgument> getArguments() {
|
||||
return findChildrenByType(JetNodeTypes.VALUE_ARGUMENT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getRightParenthesis() {
|
||||
return findChildByType(JetTokens.RPAR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
|
||||
|
||||
@Override
|
||||
public void noValueForParameter(@NotNull BindingTrace trace, @NotNull ValueParameterDescriptor valueParameter) {
|
||||
PsiElement reportOn;
|
||||
JetElement reportOn;
|
||||
JetValueArgumentList valueArgumentList = call.getValueArgumentList();
|
||||
if (valueArgumentList != null) {
|
||||
reportOn = valueArgumentList;
|
||||
|
||||
@@ -22,7 +22,7 @@ fun fooT2<T>() : (t : T) -> T {
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
args.foo()()
|
||||
args.foo1()<!NO_VALUE_FOR_PARAMETER!>()<!>
|
||||
args.foo1()(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
<!UNRESOLVED_REFERENCE!>a<!>.foo1()()
|
||||
<!UNRESOLVED_REFERENCE!>a<!>.foo1()(<!UNRESOLVED_REFERENCE!>a<!>)
|
||||
|
||||
@@ -71,7 +71,7 @@ fun main1() {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
{(x : Int) -> 1}<!NO_VALUE_FOR_PARAMETER!>()<!>;
|
||||
{(x : Int) -> 1}(<!NO_VALUE_FOR_PARAMETER!>)<!>;
|
||||
<!MISSING_RECEIVER!>{Int.() -> 1}<!>()
|
||||
<!TYPE_MISMATCH!>"sd"<!>.{Int.() -> 1}()
|
||||
val i : Int? = null
|
||||
|
||||
@@ -14,10 +14,10 @@ fun test() {
|
||||
foo(1, "", <!TOO_MANY_ARGUMENTS!>""<!>)
|
||||
|
||||
bar(z = "")
|
||||
bar<!NO_VALUE_FOR_PARAMETER!>()<!>
|
||||
bar<!NO_VALUE_FOR_PARAMETER!>("")<!>
|
||||
bar(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
bar(""<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
bar(1, 1, "")
|
||||
bar(1, 1, "")
|
||||
bar(1, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>z<!> = "")
|
||||
bar<!NO_VALUE_FOR_PARAMETER!>(1, <!NAMED_PARAMETER_NOT_FOUND, MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>zz<!> = "", <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!><!UNRESOLVED_REFERENCE!>zz<!>.foo<!>)<!>
|
||||
}
|
||||
bar(1, <!NAMED_PARAMETER_NOT_FOUND, MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>zz<!> = "", <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!><!UNRESOLVED_REFERENCE!>zz<!>.foo<!><!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
@@ -16,6 +16,6 @@ class C : T {
|
||||
super.foo() // OK
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>.bar() // Error
|
||||
super.buzz() // OK, resolved to a member
|
||||
super.buzz1<!NO_VALUE_FOR_PARAMETER!>()<!> // Resolved to a member, but error: no parameter passed where required
|
||||
super.buzz1(<!NO_VALUE_FOR_PARAMETER!>)<!> // Resolved to a member, but error: no parameter passed where required
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,17 @@ fun <T : Any> T?.sure() : T = this!!
|
||||
fun testArrays(val ci: List<Int?>, val cii: List<Int?>?) {
|
||||
val c1: Array<Int?> = cii.sure().toArray(<!FUNCTION_CALL_EXPECTED!><!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>Array<!><Int?><!>)
|
||||
|
||||
val c2: Array<Int?> = ci.toArray(Array<Int?><!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>()<!>)
|
||||
val c2: Array<Int?> = ci.toArray(Array<Int?>(<!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>)<!>)
|
||||
|
||||
val c3 = Array<Int?><!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>()<!>
|
||||
val c3 = Array<Int?>(<!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
|
||||
val c4 = ci.toArray<Int?>(Array<Int?><!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>()<!>)
|
||||
val c4 = ci.toArray<Int?>(Array<Int?>(<!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>)<!>)
|
||||
|
||||
val c5 = ci.toArray(Array<Int?><!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>()<!>)
|
||||
val c5 = ci.toArray(Array<Int?>(<!NO_VALUE_FOR_PARAMETER, NO_VALUE_FOR_PARAMETER!>)<!>)
|
||||
|
||||
c1 : Array<Int?>
|
||||
c2 : Array<Int?>
|
||||
c3 : Array<Int?>
|
||||
c4 : Array<Int?>
|
||||
c5 : Array<Int?>
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ fun <K, V> testMutableMapEntry(<warning>map</warning>: MutableMap<K, V>, <warnin
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
<error>testMutableMapEntry</error><error>(hashMap(1 to 'a'), 'b')</error>
|
||||
<error>testMutableMapEntry</error>(hashMap(1 to 'a'), 'b'<error>)</error>
|
||||
}
|
||||
|
||||
//extract from library
|
||||
|
||||
Reference in New Issue
Block a user