1// Copyright 2019 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package protoreflect 6 7// SourceLocations is a list of source locations. 8type SourceLocations interface { 9 // Len reports the number of source locations in the proto file. 10 Len() int 11 // Get returns the ith SourceLocation. It panics if out of bounds. 12 Get(int) SourceLocation 13 14 doNotImplement 15 16 // TODO: Add ByPath and ByDescriptor helper methods. 17} 18 19// SourceLocation describes a source location and 20// corresponds with the google.protobuf.SourceCodeInfo.Location message. 21type SourceLocation struct { 22 // Path is the path to the declaration from the root file descriptor. 23 // The contents of this slice must not be mutated. 24 Path SourcePath 25 26 // StartLine and StartColumn are the zero-indexed starting location 27 // in the source file for the declaration. 28 StartLine, StartColumn int 29 // EndLine and EndColumn are the zero-indexed ending location 30 // in the source file for the declaration. 31 // In the descriptor.proto, the end line may be omitted if it is identical 32 // to the start line. Here, it is always populated. 33 EndLine, EndColumn int 34 35 // LeadingDetachedComments are the leading detached comments 36 // for the declaration. The contents of this slice must not be mutated. 37 LeadingDetachedComments []string 38 // LeadingComments is the leading attached comment for the declaration. 39 LeadingComments string 40 // TrailingComments is the trailing attached comment for the declaration. 41 TrailingComments string 42} 43 44// SourcePath identifies part of a file descriptor for a source location. 45// The SourcePath is a sequence of either field numbers or indexes into 46// a repeated field that form a path starting from the root file descriptor. 47// 48// See google.protobuf.SourceCodeInfo.Location.path. 49type SourcePath []int32 50 51// TODO: Add SourcePath.String method to pretty-print the path. For example: 52// ".message_type[6].nested_type[15].field[3]" 53