@@ -104,7 +104,7 @@ func (c *Compiler) AddFile(f *ast.File) (*File, error) {
104
104
c .addErrorf (f .Pos (), "file %s already exists" , filename )
105
105
return file , c .errors .Err ()
106
106
}
107
- path , err := filepath . Abs (filename )
107
+ path , err := absolutePath (filename )
108
108
if err != nil {
109
109
return nil , fmt .Errorf ("failed to get absolute path of %s: %w" , filename , err )
110
110
}
@@ -188,7 +188,7 @@ func (c *Compiler) addErrorf(pos token.Pos, format string, args ...any) {
188
188
189
189
// getFileByPos returns the file by position
190
190
func (c * Compiler ) getFileByPos (pos token.Pos ) * File {
191
- path , err := filepath . Abs (c .fset .Position (pos ).Filename )
191
+ path , err := absolutePath (c .fset .Position (pos ).Filename )
192
192
if err != nil {
193
193
c .addErrorf (pos , "failed to get absolute path of %s: %v" , c .fset .Position (pos ).Filename , err )
194
194
return nil
@@ -203,12 +203,13 @@ func (c *Compiler) lookupFile(fullPath, relativePath string) *File {
203
203
}
204
204
if ! filepath .IsAbs (relativePath ) {
205
205
var err error
206
- relativePath , err = filepath . Abs (filepath .Join (filepath .Dir (fullPath ), relativePath ))
206
+ relativePath , err = absolutePath (filepath .Join (filepath .Dir (fullPath ), relativePath ))
207
207
if err != nil {
208
208
c .addErrorf (token .NoPos , "failed to get absolute path of %s: %v" , relativePath , err )
209
209
return nil
210
210
}
211
211
}
212
+ relativePath = filepath .ToSlash (relativePath )
212
213
return c .files [relativePath ]
213
214
}
214
215
@@ -803,10 +804,10 @@ func (c *Compiler) validateAnnotations(node Node, annotations grammar.Annotation
803
804
if ! c .options .Strict {
804
805
continue
805
806
}
806
- s , score := stringutil .FindBestMatchFunc (slices .All (annotations ), name , stringutil .DefaultSimilarityThreshold , func (i int , a grammar.Options [grammar.Annotation ]) string {
807
+ s := stringutil .FindBestMatchFunc (slices .All (annotations ), name , stringutil .DefaultSimilarityThreshold , func (i int , a grammar.Options [grammar.Annotation ]) string {
807
808
return a .Value ().Name
808
809
})
809
- if score > 0 {
810
+ if s != "" {
810
811
c .addErrorf (annotation .Pos ().pos , "unknown annotation %s, did you mean %s?" , name , s )
811
812
} else {
812
813
c .addErrorf (annotation .Pos ().pos , "unknown annotation %s" , name )
@@ -830,7 +831,7 @@ func (c *Compiler) validateAnnotations(node Node, annotations grammar.Annotation
830
831
if ! c .options .Strict && name != "next" {
831
832
continue
832
833
}
833
- s , score := stringutil .FindBestMatchFunc (slices .All (ga .Parameters ), p , stringutil .DefaultSimilarityThreshold , func (i int , a grammar.Options [grammar.AnnotationParameter ]) string {
834
+ s := stringutil .FindBestMatchFunc (slices .All (ga .Parameters ), p , stringutil .DefaultSimilarityThreshold , func (i int , a grammar.Options [grammar.AnnotationParameter ]) string {
834
835
name := a .Value ().Name
835
836
if strings .HasPrefix (name , ".+_" ) {
836
837
if index := strings .Index (p , "_" ); index > 0 {
@@ -843,7 +844,7 @@ func (c *Compiler) validateAnnotations(node Node, annotations grammar.Annotation
843
844
}
844
845
return name
845
846
})
846
- if score > 0 {
847
+ if s != "" {
847
848
c .addErrorf (annotation .NamePos (p ).pos , "annotation %s: unknown parameter %s, did you mean %s?" , name , p , s )
848
849
} else {
849
850
c .addErrorf (annotation .NamePos (p ).pos , "annotation %s: unknown parameter %s" , name , p )
@@ -886,6 +887,15 @@ func (c *Compiler) validateAnnotations(node Node, annotations grammar.Annotation
886
887
c .addErrorf (annotation .NamePos (p ).pos , "annotation %s: parameter %s: %s" , name , p , pv .Value ().Message )
887
888
}
888
889
}
890
+ // Validate available expression
891
+ if name == "next" && p == "available" {
892
+ if pos , err := validateAvailable (c , annotation , v ); err != nil {
893
+ if ! pos .IsValid () {
894
+ pos = annotation .NamePos (name ).pos
895
+ }
896
+ c .addError (pos , err .Error ())
897
+ }
898
+ }
889
899
}
890
900
for _ , gp := range ga .Parameters {
891
901
if ! gp .Value ().Required {
0 commit comments