Skip to content

Commit 77bd396

Browse files
committed
Check file start not package location
1 parent 14c5964 commit 77bd396

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
116
package a
217

3-
type StructFromAnotherFile struct{}
18+
type StructFromAnotherFile struct {
19+
// OptionalStringField is a string field that is optional.
20+
// +optional
21+
OptionalStringField string `json:"optionalStringField,omitempty"`
22+
}

pkg/analysis/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func getFilesForType(pass *analysis.Pass, ident *ast.Ident) (*token.File, *ast.F
106106
tokenFile := pass.Fset.File(namedType.Obj().Pos())
107107

108108
for _, astFile := range pass.Files {
109-
if astFile.Package == token.Pos(tokenFile.Base()) {
109+
if astFile.FileStart == token.Pos(tokenFile.Base()) {
110110
return tokenFile, astFile
111111
}
112112
}

0 commit comments

Comments
 (0)