[Elixir] Improve Elixir Client about primitive type spec (#6623)

Fix following dialyzer warnings in the sample:

```
:0: Unknown type 'Elixir.Float':t/0
:0: Unknown type 'Elixir.Integer':t/0
```
This commit is contained in:
niku
2017-10-06 10:16:27 +09:00
committed by wing328
parent 2644adb7a3
commit 86803c0c24
4 changed files with 26 additions and 9 deletions

View File

@@ -590,9 +590,26 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
buildTypespec(param.items, sb);
sb.append("}");
} else if (param.isPrimitiveType) {
// <type>.t
sb.append(param.dataType);
sb.append(".t");
// <type>() OR <type>.t
// Primitive types in Elixir
// https://hexdocs.pm/elixir/1.5.2/typespecs.html#types-and-their-syntax
//
// NOTE: List, Tuple and Map are declared as primitive in a variable `languageSpecificPrimitives`.
HashMap map = new HashMap<String, String>();
map.put("Integer", "integer()");
map.put("Float", "float()");
map.put("Boolean", "boolean()");
map.put("String", "String.t");
map.put("List", "list()");
map.put("Atom", "atom()");
map.put("Map", "map()");
map.put("Tuple", "tuple()");
map.put("PID", "pid()");
map.put("DateTime", "DateTime.t");
String dataType = (String) map.get(param.dataType);
sb.append(dataType);
} else if (param.isFile) {
sb.append("String.t");
} else {