本文整理汇总了Golang中github.com/serulian/compiler/graphs/scopegraph/proto.ScopeInfo.GetNamedReference方法的典型用法代码示例。如果您正苦于以下问题:Golang ScopeInfo.GetNamedReference方法的具体用法?Golang ScopeInfo.GetNamedReference怎么用?Golang ScopeInfo.GetNamedReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/serulian/compiler/graphs/scopegraph/proto.ScopeInfo
的用法示例。
在下文中一共展示了ScopeInfo.GetNamedReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getNamedScopeForScope
// getNamedScopeForScope returns namedScopeInfo for the given name, if it references a node by name.
func (sb *scopeBuilder) getNamedScopeForScope(scope *proto.ScopeInfo) (namedScopeInfo, bool) {
if scope.GetNamedReference() == nil {
return namedScopeInfo{}, false
}
namedReference := scope.GetNamedReference()
nodeId := compilergraph.GraphNodeId(namedReference.GetReferencedNode())
if namedReference.GetIsSRGNode() {
referencedNode := sb.sg.srg.GetNamedScope(nodeId)
return namedScopeInfo{referencedNode, nil, sb}, true
} else {
referencedNode := sb.sg.tdg.GetTypeOrMember(nodeId)
return namedScopeInfo{srg.SRGNamedScope{}, referencedNode, sb}, true
}
}
示例2: GetReferencedName
// GetReferencedName returns the ReferencedName struct for the given scope, if it refers to a named scope.
func (sg *ScopeGraph) GetReferencedName(scope proto.ScopeInfo) (ReferencedName, bool) {
if scope.GetNamedReference() == nil {
return ReferencedName{}, false
}
namedReference := scope.GetNamedReference()
nodeId := compilergraph.GraphNodeId(namedReference.GetReferencedNode())
if namedReference.GetIsSRGNode() {
referencedNode := sg.srg.GetNamedScope(nodeId)
return ReferencedName{referencedNode, nil, sg}, true
} else {
referencedNode := sg.tdg.GetTypeOrMember(nodeId)
return ReferencedName{srg.SRGNamedScope{}, referencedNode, sg}, true
}
}