| 1 | // Copyright 2018 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package commonscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/ |
| 16 | |
| 17 | // Location interface to represent a location within Source. |
| 18 | type Locationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/Location# interface { |
| 19 | Linescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/Location#Line.() int // 1-based line number within source. |
| 20 | Columnscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/Location#Column.() int // 0-based column number within source. |
| 21 | } |
| 22 | |
| 23 | // SourceLocation helper type to manually construct a location. |
| 24 | type SourceLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation# struct { |
| 25 | linescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#line. int |
| 26 | columnscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#column. int |
| 27 | } |
| 28 | |
| 29 | var ( |
| 30 | // Location implements the SourceLocation interface. |
| 31 | _ Locationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/Location# = &SourceLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#{} |
| 32 | // NoLocation is a particular illegal location. |
| 33 | NoLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/NoLocation. = &SourceLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#{-1, -1} |
| 34 | ) |
| 35 | |
| 36 | // NewLocation creates a new location. |
| 37 | func NewLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/NewLocation().(line, column int) Locationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/Location# { |
| 38 | return &SourceLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#{ |
| 39 | linescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#line.: line, |
| 40 | columnscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#column.: column} |
| 41 | } |
| 42 | |
| 43 | // Line returns the 1-based line of the location. |
| 44 | func (l *SourceLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#) Linescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#Line().() int { |
| 45 | return l.linescip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#line. |
| 46 | } |
| 47 | |
| 48 | // Column returns the 0-based column number of the location. |
| 49 | func (l *SourceLocationscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#) Columnscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#Column().() int { |
| 50 | return l.columnscip-go gomod github.com/google/cel-go . `github.com/google/cel-go/common`/SourceLocation#column. |
| 51 | } |