// GetImportPath resolves the full import path of an identifier based on
// the imports in the current context.
185181
func GetImportPath(name string, ctx *Context) (string, bool) {
	for path := range ctx.Imports.Imported {
		if imported, ok := GetImportedName(path, ctx); ok && imported == name {
			return path, true
		}
	}
	return "", false
}
776836
func vendorlessImportPath(ipath string, currentPackagePath string) (string, bool) {
	split := strings.Split(ipath, "vendor/")
	// no vendor in path
	if len(split) == 1 {
		return ipath, true
	}
	// this import path does not belong to the current package
	if currentPackagePath != "" && !strings.Contains(currentPackagePath, split[0]) {
		return "", false
	}
	// Devendorize for use in import statement.
	if i := strings.LastIndex(ipath, "/vendor/"); i >= 0 {
		return ipath[i+len("/vendor/"):], true
	}
	if strings.HasPrefix(ipath, "vendor/") {
		return ipath[len("vendor/"):], true
	}
	return ipath, true
}
418947
func (l *LargeFile) GetPath() string {
	if l == nil || l.Path == nil {
		return ""
	}
	return *l.Path
}
1216250
func (t *TreeEntry) GetPath() string {
	if t == nil || t.Path == nil {
		return ""
	}
	return *t.Path
}
1242851
func NormalizeImportPath(path string) string {
	chunks := strings.Split(path, "/vendor/")
	return chunks[len(chunks)-1]
}
784492
func GetRequestPath(entity string, project string, id string) string {
	urlPath := ""

	if entity == "projects" {
		urlPath = urlPath + "/" + entity
	} else {
		urlPath = urlPath + "/projects/" + project + "/" + entity
	}

	if id != "" {
		if strings.HasPrefix(id, "?") {
			urlPath = urlPath + id
		} else {
			urlPath = urlPath + "/" + id
		}
	}

	return urlPath
}
74192
func (gr goResource) APILibImportPaths() []string {
	ip := map[string]struct{}{}

	// methods
	for _, gm := range gr.Methods {
		for _, v := range gm.Imports() {
			ip[v] = struct{}{}
		}
	}

	// return sorted array for predictable order
	// we need it for unit test to always return same order
	return commons.MapToSortedStrings(ip)
}
398660
func (pc *processContainer) processPath(path string, info os.FileInfo, err error) error {
	if err != nil {
		utils.Logger.Error("Error scanning app source:", "error", err)
		return nil
	}

	if !info.IsDir() || info.Name() == "tmp" {
		return nil
	}

	// Get the import path of the package.
	pkgImportPath := pc.rootImportPath
	if pc.root != path {
		pkgImportPath = pc.rootImportPath + "/" + filepath.ToSlash(path[len(pc.root)+1:])
	}

	// Parse files within the path.
	var pkgs map[string]*ast.Package
	fset := token.NewFileSet()
	pkgs, err = parser.ParseDir(
		fset,
		path,
		func(f os.FileInfo) bool {
			return !f.IsDir() && !strings.HasPrefix(f.Name(), ".") && strings.HasSuffix(f.Name(), ".go")
		},
		0)

	if err != nil {
		if errList, ok := err.(scanner.ErrorList); ok {
			var pos = errList[0].Pos
			newError := &utils.Error{
				SourceType:  ".go source",
				Title:       "Go Compilation Error",
				Path:        pos.Filename,
				Description: errList[0].Msg,
				Line:        pos.Line,
				Column:      pos.Column,
				SourceLines: utils.MustReadLines(pos.Filename),
			}

			errorLink := pc.paths.Config.StringDefault("error.link", "")
			if errorLink != "" {
				newError.SetLink(errorLink)
			}
			return newError
		}

		// This is exception, err already checked above. Here just a print
		ast.Print(nil, err)
		utils.Logger.Fatal("Failed to parse dir", "error", err)
	}

	// Skip "main" packages.
	delete(pkgs, "main")

	// Ignore packages that end with _test
	// These cannot be included in source code that is not generated specifically as a test
	for i := range pkgs {
		if len(i) > 6 {
			if string(i[len(i)-5:]) == "_test" {
				delete(pkgs, i)
			}
		}
	}

	// If there is no code in this directory, skip it.
	if len(pkgs) == 0 {
		return nil
	}

	// There should be only one package in this directory.
	if len(pkgs) > 1 {
		for i := range pkgs {
			println("Found package ", i)
		}
		utils.Logger.Fatal("Most unexpected! Multiple packages in a single directory:", "packages", pkgs)
	}

	var pkg *ast.Package
	for _, v := range pkgs {
		pkg = v
	}

	if pkg != nil {
		pc.srcInfo = appendSourceInfo(pc.srcInfo, processPackage(fset, pkgImportPath, path, pkg))
	} else {
		utils.Logger.Info("Ignoring package, because it contained no packages", "path", path)
	}
	return nil
}
987313
func GetPathFromVMDiskPath(vmDiskPath string) string {
	datastorePathObj := new(object.DatastorePath)
	isSuccess := datastorePathObj.FromString(vmDiskPath)
	if !isSuccess {
		klog.Errorf("Failed to parse vmDiskPath: %s", vmDiskPath)
		return ""
	}
	return datastorePathObj.Path
}
1328833
func isLocalImport(path string) bool {
	return path == "." || path == ".." || strings.HasPrefix(path, "./") || strings.HasPrefix(path, "../")
}
69802
func (l *ActionListener) GetPath(nodes ...string) string {
	return actionPath(append([]string{l.hostID}, nodes...)...)
}
264347
func (r *RepositoryContent) GetPath() string {
	if r == nil || r.Path == nil {
		return ""
	}
	return *r.Path
}
1223630
func GetImportedName(path string, ctx *Context) (string, bool) {
	importName, imported := ctx.Imports.Imported[path]
	if !imported {
		return "", false
	}

	if _, initonly := ctx.Imports.InitOnly[path]; initonly {
		return "", false
	}

	if alias, ok := ctx.Imports.Aliased[path]; ok {
		importName = alias
	}
	return importName, true
}
45609
func createImport(name, path string) *ast.ImportSpec {
	return &ast.ImportSpec{
		Name: &ast.Ident{Name: name},
		Path: &ast.BasicLit{Kind: 9, Value: path},
	}
}
272039
func (c *Client) GetExportClientsByID(
	ctx context.Context, id int) ([]string, error) {

	ex, err := c.GetExportByID(ctx, id)
	if err != nil {
		return nil, err
	}
	if ex == nil {
		return nil, nil
	}
	if ex.Clients == nil {
		return nil, nil
	}
	return *ex.Clients, nil
}
1044675
func (u Universe) AddImports(packagePath string, importPaths ...string) {
	p := u.Package(packagePath)
	for _, i := range importPaths {
		p.Imports[i] = u.Package(i)
	}
}
1083587
func (p *PagesSource) GetPath() string {
	if p == nil || p.Path == nil {
		return ""
	}
	return *p.Path
}