bblfsh / sdk

Babelfish driver SDK
GNU General Public License v3.0
23 stars 27 forks source link

Provide a shortcut function to get Name in Semantic mode #366

Open vmarkovtsev opened 5 years ago

vmarkovtsev commented 5 years ago

Having obtained function names in #365 I need to get the actual strings. My current take is

nodeName, err := tools.FilterNode(node, "//uast:Function/../../Name")
if err != nil {
    return nil, err
}
println(string(nodeName.(nodes.Object)["Name"].(nodes.String)))

I have to hardcode "Name" and do two type assertions. Is it possible to add a wrapper?