pulumi/pkg/diag/diag.go

35 lines
1,008 B
Go
Raw Normal View History

// Copyright 2016 Marapongo, Inc. All rights reserved.
package diag
// ID is a unique diagnostics identifier.
type ID int
// Diag is an instance of an error or warning generated by the compiler.
type Diag struct {
ID ID // a unique identifier for this diagnostic.
Message string // a human-friendly message for this diagnostic.
File string // the document in which this diagnostic occurred.
Filepos *PosRange // the document position at which this diagnostic occurred.
}
// WithFile adds a file to an existing diagnostic, retaining its ID and message.
func (diag *Diag) WithFile(file string) *Diag {
return &Diag{
ID: diag.ID,
Message: diag.Message,
File: file,
Filepos: &EmptyPosRange,
}
}
// WithFilepos adds a file and position to an existing diagnostic, retaining its ID and message.
func (diag *Diag) WithFilepos(file string, filepos *PosRange) *Diag {
return &Diag{
ID: diag.ID,
Message: diag.Message,
File: file,
Filepos: filepos,
}
}