github.com/oweisse/u-root@v0.0.0-20181109060735-d005ad25fef1/cmds/elvish/edit/completion/nodeutil.go (about)

     1  package completion
     2  
     3  import (
     4  	"github.com/u-root/u-root/cmds/elvish/parse"
     5  )
     6  
     7  // Utilities for insepcting the AST. Used for completers and stylists.
     8  
     9  func primaryInSimpleCompound(pn *parse.Primary, ev pureEvaler) (*parse.Compound, string) {
    10  	indexing := parse.GetIndexing(pn.Parent())
    11  	if indexing == nil {
    12  		return nil, ""
    13  	}
    14  	compound := parse.GetCompound(indexing.Parent())
    15  	if compound == nil {
    16  		return nil, ""
    17  	}
    18  	head, err := ev.PurelyEvalPartialCompound(compound, indexing)
    19  	if err != nil {
    20  		return nil, ""
    21  	}
    22  	return compound, head
    23  }