<NME> ElmRecordCompletionTest.kt
<BEF> package org.elm.lang.core.completion

class ElmRecordCompletionTest : ElmCompletionTestBase() {


    fun `test access name field from one letter`() = doSingleCompletion(
            """
type alias Foo = { name : String }
type alias Foo = { name : String }
f : Foo -> String
f foo =
    foo.n{-caret-}
""", """
type alias Foo = { name : String }
f : Foo -> String
f foo =
    foo.name{-caret-}
""")


    fun `test access name field from blank`() = doSingleCompletion(
            """
type alias Foo = { name : String }
f : Foo -> String
f foo =
    foo.{-caret-}
""", """
type alias Foo = { name : String }
f : Foo -> String
f foo =
    foo.name{-caret-}
""")


    fun `test chained field access`() = doSingleCompletion(
            """
type alias Foo = { name : { first: String } }

f : Foo -> String
f foo =
    foo.name.fir{-caret-}
""", """
type alias Foo = { name : { first: String } }

f : Foo -> String
    foo.name.first{-caret-}
""")

}
}

<MSG> Improve record completion in functions with syntax errors. (#245)

In the large majority of cases when trying to complete record fields, the target is a simple value reference, usually to a function parameter. If we resolve that reference, it often resolves to an element for which we can infer the type. In the case of chained field access, we can resolve the base type and walk the `TyRecord` to get the final field ty.

We now bind function parameters as long as there are no syntax errors in the parameters themselves, even if there are errors in the function body.
<DFF> @@ -2,7 +2,6 @@ package org.elm.lang.core.completion
 
 class ElmRecordCompletionTest : ElmCompletionTestBase() {
 
-
     fun `test access name field from one letter`() = doSingleCompletion(
             """
 type alias Foo = { name : String }
@@ -46,4 +45,69 @@ f foo =
     foo.name.first{-caret-}
 """)
 
-}
\ No newline at end of file
+    // partial program tests
+
+    fun `test incomplete case expression`() = doSingleCompletion(
+            """
+type alias Foo = { name : String }
+
+f : Foo -> String
+f r =
+    case r.{-caret-}
+""", """
+type alias Foo = { name : String }
+
+f : Foo -> String
+f r =
+    case r.name{-caret-}
+""")
+
+    fun `test unresolved reference`() = doSingleCompletion(
+            """
+type alias Foo = { name : String }
+
+f : Foo -> String
+f r =
+    foo r.{-caret-}
+""", """
+type alias Foo = { name : String }
+
+f : Foo -> String
+f r =
+    foo r.name{-caret-}
+""")
+
+    fun `test too many arguments`() = doSingleCompletion(
+            """
+type alias Foo = { name : String }
+
+f : Foo -> Int
+f r = 1
+
+g : Foo -> Int
+g r = f 1 r.{-caret-}
+""", """
+type alias Foo = { name : String }
+
+f : Foo -> Int
+f r = 1
+
+g : Foo -> Int
+g r = f 1 r.name{-caret-}
+""")
+
+    fun `test incomplete case expression with chained access`() = doSingleCompletion(
+            """
+type alias Foo = { name : { first: String } }
+
+f : Foo -> String
+f r =
+    case r.name.fir{-caret-}
+""", """
+type alias Foo = { name : { first: String } }
+
+f : Foo -> String
+f r =
+    case r.name.first{-caret-}
+""")
+}

Improve record completion in functions with syntax errors. (#245)