func GetFileAnnotation(
	ctx context.Context,
	parserAccessorHandler ParserAccessorHandler,
	errorWithPos protoparse.ErrorWithPos,
) (bufanalysis.FileAnnotation, error) {
	var fileInfo bufmoduleref.FileInfo
	var startLine int
	var startColumn int
	var endLine int
	var endColumn int
	typeString := "COMPILE"
	message := "Compile error."
	// this should never happen
	// maybe we should error
	if errorWithPos.Unwrap() != nil {
		message = errorWithPos.Unwrap().Error()
	}
	sourcePos := protoparse.SourcePos{}
	if errorWithSourcePos, ok := errorWithPos.(protoparse.ErrorWithSourcePos); ok {
		if pos := errorWithSourcePos.Pos; pos != nil {
			sourcePos = *pos
		}
	}
	if sourcePos.Filename != "" {
		path, err := normalpath.NormalizeAndValidate(sourcePos.Filename)
		if err != nil {
			return nil, err
		}
		fileInfo, err = bufmoduleref.NewFileInfo(
			path,
			parserAccessorHandler.ExternalPath(path),
			parserAccessorHandler.IsImport(path),
			nil,
			"",
		)
		if err != nil {
			return nil, err
		}
	}
	if sourcePos.Line > 0 {
		startLine = sourcePos.Line
		endLine = sourcePos.Line
	}
	if sourcePos.Col > 0 {
		startColumn = sourcePos.Col
		endColumn = sourcePos.Col
	}
	return bufanalysis.NewFileAnnotation(
		fileInfo,
		startLine,
		startColumn,
		endLine,
		endColumn,
		typeString,
		message,
	), nil
}
// GetFileAnnotation gets the FileAnnotation for the ErrorWithPos error.
GetFileAnnotation gets the FileAnnotation for the ErrorWithPos error.
// GetFileAnnotation gets the FileAnnotation for the ErrorWithPos error .
func GetFileAnnotation(
	ctx context.Context,
	parserAccessorHandler ParserAccessorHandler,
	errorWithPos protoparse.ErrorWithPos,
) (bufanalysis.FileAnnotation, error) {
	var fileInfo bufmoduleref.FileInfo
	var startLine int
	var startColumn int
	var endLine int
	var endColumn int
	typeString := "COMPILE"
	message := "Compile error."
	if errorWithPos.Unwrap() != nil {
		message = errorWithPos.Unwrap().Error()
	}
	sourcePos := protoparse.SourcePos{}
	if errorWithSourcePos, ok := errorWithPos.(protoparse.ErrorWithSourcePos); ok {
		if pos := errorWithSourcePos.Pos; pos != nil {
			sourcePos = *pos
		}
	}
	if sourcePos.Filename != "" {
		path, err := normalpath.NormalizeAndValidate(sourcePos.Filename)
		if err != nil {
			return nil, err
		}
		fileInfo, err = bufmoduleref.NewFileInfo(
			path,
			parserAccessorHandler.ExternalPath(path),
			parserAccessorHandler.IsImport(path),
			nil,
			"",
		)
		if err != nil {
			return nil, err
		}
	}
	if sourcePos.Line > 0 {
		startLine = sourcePos.Line
		endLine = sourcePos.Line
	}
	if sourcePos.Col > 0 {
		startColumn = sourcePos.Col
		endColumn = sourcePos.Col
	}
	return bufanalysis.NewFileAnnotation(
		fileInfo,
		startLine,
		startColumn,
		endLine,
		endColumn,
		typeString,
		message,
	), nil
}
func GetFileAnnotation ( ctx context . Context , parserAccessorHandler ParserAccessorHandler , errorWithPos protoparse . ErrorWithPos , ) ( bufanalysis . FileAnnotation , error ) { var fileInfo bufmoduleref . FileInfo var startLine int var startColumn int var endLine int var endColumn int typeString := " " message := " " if errorWithPos . Unwrap ( ) != nil { message = errorWithPos . Unwrap ( ) . Error ( ) } sourcePos := protoparse . SourcePos { } if errorWithSourcePos , ok := errorWithPos . ( protoparse . ErrorWithSourcePos ) ; ok { if pos := errorWithSourcePos . Pos ; pos != nil { sourcePos = * pos } } if sourcePos . Filename != " " { path , err := normalpath . NormalizeAndValidate ( sourcePos . Filename ) if err != nil { return nil , err } fileInfo , err = bufmoduleref . NewFileInfo ( path , parserAccessorHandler . ExternalPath ( path ) , parserAccessorHandler . IsImport ( path ) , nil , " " , ) if err != nil { return nil , err } } if sourcePos . Line > 0 { startLine = sourcePos . Line endLine = sourcePos . Line } if sourcePos . Col > 0 { startColumn = sourcePos . Col endColumn = sourcePos . Col } return bufanalysis . NewFileAnnotation ( fileInfo , startLine , startColumn , endLine , endColumn , typeString , message , ) , nil }
GetFileAnnotation gets the FileAnnotation for the ErrorWithPos error.
GetFileAnnotation gets the FileAnnotation for the ErrorWithPos error .
// this should never happen // maybe we should error