Imports #
"cmd/internal/obj"
"cmd/internal/src"
"encoding/json"
"fmt"
"internal/buildcfg"
"io"
"log"
"net/url"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
"unicode"
"cmd/internal/obj"
"cmd/internal/src"
"encoding/json"
"fmt"
"internal/buildcfg"
"io"
"log"
"net/url"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
"unicode"
var Format = None
const Json0
const None logFormat = iota
SeverityInformation defined: * Reports an information.
const SeverityInformation DiagnosticSeverity = 3
var dest string
var loggedOpts []*LoggedOpt
var mu = sync.Mutex{...}
DiagnosticSeverity defines constants
type DiagnosticSeverity uint
DiagnosticTag defines constants
type DiagnosticTag uint
type DocumentURI string
type logFormat uint8
Diagnostic defined: * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects * are only valid in the scope of a resource.
type Diagnostic struct {
Range Range `json:"range"`
Severity DiagnosticSeverity `json:"severity,omitempty"`
Code string `json:"code,omitempty"`
Source string `json:"source,omitempty"`
Message string `json:"message"`
Tags []DiagnosticTag `json:"tags,omitempty"`
RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation,omitempty"`
}
DiagnosticRelatedInformation defined: * Represents a related message and source code location for a diagnostic. This should be * used to point to code locations that cause or related to a diagnostics, e.g when duplicating * a symbol in a scope.
type DiagnosticRelatedInformation struct {
Location Location `json:"location"`
Message string `json:"message"`
}
A Location represents a location inside a resource, such as a line inside a text file.
type Location struct {
URI DocumentURI `json:"uri"`
Range Range `json:"range"`
}
A LoggedOpt is what the compiler produces and accumulates, to be converted to JSON for human or IDE consumption.
type LoggedOpt struct {
pos src.XPos
lastPos src.XPos
compilerPass string
functionName string
what string
target []interface{}
}
type Position struct {
Line uint `json:"line"`
Character uint `json:"character"`
}
A Range in a text document expressed as (zero-based) start and end positions. A range is comparable to a selection in an editor. Therefore the end position is exclusive. If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line.
type Range struct {
Start Position `json:"start"`
End Position `json:"end"`
}
type VersionHeader struct {
Version int `json:"version"`
Package string `json:"package"`
Goos string `json:"goos"`
Goarch string `json:"goarch"`
GcVersion string `json:"gc_version"`
File string `json:"file,omitempty"`
}
byPos sorts diagnostics by source position.
type byPos struct {
ctxt *obj.Link
a []*LoggedOpt
}
Enabled returns whether optimization logging is enabled.
func Enabled() bool
FlushLoggedOpts flushes all the accumulated optimization log entries.
func FlushLoggedOpts(ctxt *obj.Link, slashPkgPath string)
func (x byPos) Len() int
func (x byPos) Less(i int, j int) bool
LogJsonOption parses and validates the version,directory value attached to the -json compiler flag.
func LogJsonOption(flagValue string)
LogOpt logs information about a (usually missed) optimization performed by the compiler. Pos is the source position (including inlining), what is the message, pass is which pass created the message, funcName is the name of the function.
func LogOpt(pos src.XPos, what string, pass string, funcName string, args ...interface{})
LogOptRange is the same as LogOpt, but includes the ability to express a range of positions, not just a point.
func LogOptRange(pos src.XPos, lastPos src.XPos, what string, pass string, funcName string, args ...interface{})
NewLoggedOpt allocates a new LoggedOpt, to later be passed to either NewLoggedOpt or LogOpt as "args". Pos is the source position (including inlining), what is the message, pass is which pass created the message, funcName is the name of the function A typical use for this to accumulate an explanation for a missed optimization, for example, why did something escape?
func NewLoggedOpt(pos src.XPos, lastPos src.XPos, what string, pass string, funcName string, args ...interface{}) *LoggedOpt
func (x byPos) Swap(i int, j int)
appendInlinedPos extracts inlining information from posTmp and append it to diagnostic.
func appendInlinedPos(posTmp []src.Pos, lastTmp []src.Pos, diagnostic *Diagnostic)
checkLogPath does superficial early checking of the string specifying the directory to which optimizer logging is directed, and if it passes the test, stores the string in LO_dir.
func checkLogPath(destination string) string
func fixSlash(f string) string
isWindowsDriveURIPath returns true if the file URI is of the format used by Windows URIs. The url.Parse package does not specially handle Windows paths (see golang/go#6027), so we check if the URI path has a drive prefix (e.g. "/C:"). (copied from tools/internal/span/uri.go) this is less comprehensive that the processing in filepath.IsAbs on Windows.
func isWindowsDriveURIPath(uri string) bool
newLocation returns the Location for the compiler source location p.
func newLocation(p src.Pos, last src.Pos) Location
newRange returns a single-position Range for the compiler source location p.
func newRange(p src.Pos, last src.Pos) Range
parseLogFlag checks the flag passed to -json for version,destination format and returns the two parts.
func parseLogFlag(flag string, value string) (version int, directory string)
func parseLogPath(destination string) (string, string)
parsePos expands a src.XPos into a slice of src.Pos, with the outermost first. It returns the slice, and the outermost.
func parsePos(ctxt *obj.Link, pos src.XPos, posTmp []src.Pos) ([]src.Pos, src.Pos)
Return filename, replacing a first occurrence of $GOROOT with the actual value of the GOROOT (because LSP does not speak "$GOROOT").
func uprootedPath(filename string) string
func uriIfy(f string) DocumentURI
func writerForLSP(subdirpath string, file string) io.WriteCloser
Generated with Arrow