我有一个使用 scala-meta 的真正初学者问题
我想根据字段的名称向案例类字段的子集添加注释。要注释的类和字段定义如下:
val classMapping = Map[String,String](
("com.example.employees","""OntologyContext("http://schema.org")"""),
("Employee.scala","""OntologyType("person")""")
)
val fieldMapping = Map[String,String](
("hello","""OntologyRef("name")"""),
("job","""OntologyRef("title")"""),("id","""Obfuscated""")
)
前:
package com.example.employees
import java.time.LocalDate
case class Employee(
hello: String,
job:String,
id:String,
employmentDate: Date)
后:
package com.example.employees
import java.time.LocalDate
@OntologyContext(“http://schema.org”)
@OntologyType(“person”)
case class Employee(
@OntologyRef(“name”) hello: String,
@OntologyRef(“title”) job: String,
@Obfuscated() id:String,
employmentDate: Date
)
我的问题与树转换中所需的准引号的语法有关:
- 选择指定的字段;和
- 插入注释
您能否参考任何可以为我指明正确方向的示例?