本文整理汇总了Golang中code/google/com/p/go/tools/importer.Importer.PathEnclosingInterval方法的典型用法代码示例。如果您正苦于以下问题:Golang Importer.PathEnclosingInterval方法的具体用法?Golang Importer.PathEnclosingInterval怎么用?Golang Importer.PathEnclosingInterval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/go/tools/importer.Importer
的用法示例。
在下文中一共展示了Importer.PathEnclosingInterval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ParseQueryPos
// ParseQueryPos parses the source query position pos.
// If needExact, it must identify a single AST subtree.
//
func ParseQueryPos(imp *importer.Importer, pos string, needExact bool) (*QueryPos, error) {
start, end, err := parseQueryPos(imp.Fset, pos)
if err != nil {
return nil, err
}
info, path, exact := imp.PathEnclosingInterval(start, end)
if path == nil {
return nil, fmt.Errorf("no syntax here")
}
if needExact && !exact {
return nil, fmt.Errorf("ambiguous selection within %s", importer.NodeDescription(path[0]))
}
return &QueryPos{start, end, info, path}, nil
}
示例2: ParseQueryPos
// ParseQueryPos parses the source query position pos.
// If needExact, it must identify a single AST subtree;
// this is appropriate for queries that allow fairly arbitrary syntax,
// e.g. "describe".
//
func ParseQueryPos(imp *importer.Importer, posFlag string, needExact bool) (*QueryPos, error) {
filename, startOffset, endOffset, err := parsePosFlag(posFlag)
if err != nil {
return nil, err
}
start, end, err := findQueryPos(imp.Fset, filename, startOffset, endOffset)
if err != nil {
return nil, err
}
info, path, exact := imp.PathEnclosingInterval(start, end)
if path == nil {
return nil, fmt.Errorf("no syntax here")
}
if needExact && !exact {
return nil, fmt.Errorf("ambiguous selection within %s", astutil.NodeDescription(path[0]))
}
return &QueryPos{imp.Fset, start, end, path, exact, info}, nil
}