We are renaming Lumi to Pulumi Fabric. This change simply renames the pulumi/lumi repo to pulumi/pulumi-fabric, without the CLI tools and other changes that will follow soon afterwards.
46 lines
941 B
Go
46 lines
941 B
Go
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
package lumidl
|
|
|
|
import (
|
|
"go/token"
|
|
"path/filepath"
|
|
|
|
"golang.org/x/tools/go/loader"
|
|
|
|
"github.com/pulumi/pulumi-fabric/pkg/diag"
|
|
"github.com/pulumi/pulumi-fabric/pkg/util/contract"
|
|
)
|
|
|
|
type goPos interface {
|
|
Pos() token.Pos
|
|
}
|
|
|
|
// goDiag produces a diagnostics object out of a Go type artifact.
|
|
func goDiag(prog *loader.Program, elem goPos, relto string) diag.Diagable {
|
|
pos := prog.Fset.Position(elem.Pos())
|
|
file := pos.Filename
|
|
if relto != "" {
|
|
var err error
|
|
file, err = filepath.Rel(relto, file)
|
|
contract.Assertf(err == nil, "error: %v", err)
|
|
}
|
|
return &goDiagable{
|
|
doc: diag.NewDocument(file),
|
|
loc: &diag.Location{
|
|
Start: diag.Pos{
|
|
Line: pos.Line,
|
|
Column: pos.Column,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
type goDiagable struct {
|
|
doc *diag.Document
|
|
loc *diag.Location
|
|
}
|
|
|
|
func (d *goDiagable) Where() (*diag.Document, *diag.Location) {
|
|
return d.doc, d.loc
|
|
}
|