Permalink
Browse files

Get complete type working for the most part.

Paramters with type args will still need some love.
  • Loading branch information...
1 parent a6cadac commit 0fa7942035207409381671b9bc6bf7d4cbe6d0af Matt Farmer committed Mar 5, 2012
Showing with 17 additions and 18 deletions.
  1. +17 −18 Support/ensime.rb
View
@@ -265,7 +265,7 @@ def completions(file, word, line)
puts "Sorry, import completion isn't implemented yet"
elsif (prev_char_index > white_space_count) &&
(prev_char == '.' || prev_char == ' ')
- # puts "complete type"
+
complete_type(file,wd,line)
else
# puts "scope"
@@ -352,29 +352,28 @@ def complete_type(file,word,line)
@socket.print(msg)
swankmsg = get_response(@socket)
parsed = @parser.parse_string(swankmsg)
- # e_sn parsed[0][1][1][3][.inspect
- noImplicits = parsed[0][1][1][3].select do |arr|
- arr[3] == nil #check if it is implicit
- end
- curries = noImplicits.collect do |arr|
- [arr[1][0][1][1],
- arr[1][0][1][9]]
+
+ noImplicits = parsed[0][1][1][3][0][1].select do |arr|
+ arr[1][1] != nil #check if it is implicit
+ # Still not quite sure why this check was put here, but I'm
+ # leaving it in place for now. -MF
end
- # e_sn curries.inspect
+
stopPoint = 0
- str = curries.collect do |arr|
+ str = noImplicits.collect do |singleParameterInformation|
stopPoint = stopPoint +1
- if arr[1] == nil # no type params
- "(${#{stopPoint.to_s}:#{arr[0]}})"
+ parameterName = singleParameterInformation[0]
+ parameterType = singleParameterInformation[1][1]
+ parameterTypeArgs = singleParameterInformation[1][9]
+
+ if parameterTypeArgs.nil?
+ "${#{stopPoint.to_s}:#{parameterName}:#{parameterType}}"
else
- preExpand = arr[0] + "[" + arr[1].collect{ |typ| typ[1] }.join(", ") + "]"
- expanded = ScalaParser::Expander.new(stopPoint).expand(preExpand)
- rslt = "(${#{stopPoint.to_s}:" + expanded.string + "})"
- stopPoint = expanded.point
- rslt
+ # TODO: Fix handling with type args
+ "${#{stopPoint.to_s}:#{parameterName}:#{parameterType}}"
end
end
- str.to_s
+ "(" + str.join(", ") + ")"
}
end
end

0 comments on commit 0fa7942

Please sign in to comment.