Prevent NullPointerException by initializing VariableType.type to an empty
string.
Fix ClassCastException in variable detection

Calling AstNode.getString may fail with a ClassCastException
if the underlying node is not a string context, which occurs
for example when typing:
"function func("
In that case, the node is an ErrorNode, and getString fails.

Replace getString() with toSource() which never fails and produces
the same result otherwise.