2020-03-10 08:14:56 -06:00
|
|
|
// Copyright 2020 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package analysisinternal exposes internal-only fields from go/analysis.
|
|
|
|
package analysisinternal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"go/token"
|
|
|
|
"go/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TypeErrorEndPos(fset *token.FileSet, src []byte, start token.Pos) token.Pos {
|
|
|
|
// Get the end position for the type error.
|
|
|
|
offset, end := fset.PositionFor(start, false).Offset, start
|
|
|
|
if offset >= len(src) {
|
|
|
|
return end
|
|
|
|
}
|
2020-03-05 07:51:57 -07:00
|
|
|
if width := bytes.IndexAny(src[offset:], " \n,():;[]+-*"); width > 0 {
|
2020-03-10 08:14:56 -06:00
|
|
|
end = start + token.Pos(width)
|
|
|
|
}
|
|
|
|
return end
|
|
|
|
}
|
|
|
|
|
|
|
|
var GetTypeErrors = func(p interface{}) []types.Error { return nil }
|
|
|
|
var SetTypeErrors = func(p interface{}, errors []types.Error) {}
|
2020-03-05 07:51:57 -07:00
|
|
|
|
|
|
|
type TypeErrorPass string
|
|
|
|
|
|
|
|
const (
|
2020-03-16 12:46:49 -06:00
|
|
|
NoResultValues TypeErrorPass = "noresultvalues"
|
2020-03-05 07:51:57 -07:00
|
|
|
UndeclaredName TypeErrorPass = "undeclaredname"
|
|
|
|
)
|