Skip to content

Commit 9709e9e

Browse files
smarteranatoliykmetyuk
authored andcommitted
Rewrite dotty.tools.dottydoc.staticsite.Yaml in Java
To work properly, `TypeReference` relies on using runtime reflection to get the generic arguments it was instantiated with, this does not work currently with Dotty, because we're not emitting a generic signature for the parent, see scala#6349.
1 parent ded615a commit 9709e9e

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dotty.tools.dottydoc.staticsite;
2+
3+
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.fasterxml.jackson.core.type.TypeReference;
6+
7+
import java.util.HashMap;
8+
import java.io.ByteArrayInputStream;
9+
10+
public class Yaml {
11+
12+
public static HashMap<String, Object> apply(String input)
13+
throws java.io.UnsupportedEncodingException, java.io.IOException {
14+
ByteArrayInputStream is = new ByteArrayInputStream(input.getBytes("UTF-8"));
15+
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
16+
17+
TypeReference<HashMap<String, Object>> typeRef =
18+
new TypeReference<HashMap<String, Object>>() {};
19+
20+
return mapper.readValue(is, typeRef);
21+
}
22+
}

doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)