Skip to content

Commit

Permalink
Rewrite dotty.tools.dottydoc.staticsite.Yaml in Java
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
smarter committed Apr 22, 2019
1 parent 99c4e4b commit 6a42c8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
22 changes: 22 additions & 0 deletions doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package dotty.tools.dottydoc.staticsite;

import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;

import java.util.HashMap;
import java.io.ByteArrayInputStream;

public class Yaml {

public static HashMap<String, Object> apply(String input)
throws java.io.UnsupportedEncodingException, java.io.IOException {
ByteArrayInputStream is = new ByteArrayInputStream(input.getBytes("UTF-8"));
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());

TypeReference<HashMap<String, Object>> typeRef =
new TypeReference<HashMap<String, Object>>() {};

return mapper.readValue(is, typeRef);
}
}
23 changes: 0 additions & 23 deletions doc-tool/src/dotty/tools/dottydoc/staticsite/Yaml.scala

This file was deleted.

0 comments on commit 6a42c8d

Please sign in to comment.