forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
22 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.