@@ -175,6 +175,8 @@ type Server struct {
175
175
resolveAddressContractNames AddressContractNamesResolver
176
176
// resolveStringImport is the optional function that is used to resolve string imports
177
177
resolveStringImport StringImportResolver
178
+ // resolveIdentifierImport is the optional function that is used to resolve identifier imports
179
+ resolveIdentifierImport func (location common.IdentifierLocation ) (string , error )
178
180
// codeLensProviders are the functions that are used to provide code lenses for a checker
179
181
codeLensProviders []CodeLensProvider
180
182
// diagnosticProviders are the functions that are used to provide diagnostics for a checker
@@ -242,6 +244,15 @@ func WithStringImportResolver(resolver StringImportResolver) Option {
242
244
}
243
245
}
244
246
247
+ // WithIdentifierImportResolver returns a server option that sets the given function
248
+ // as the function that is used to resolve identifier imports
249
+ func WithIdentifierImportResolver (resolver func (location common.IdentifierLocation ) (string , error )) Option {
250
+ return func (s * Server ) error {
251
+ s .resolveIdentifierImport = resolver
252
+ return nil
253
+ }
254
+ }
255
+
245
256
// WithCodeLensProvider returns a server option that adds the given function
246
257
// as a function that is used to generate code lenses
247
258
func WithCodeLensProvider (provider CodeLensProvider ) Option {
@@ -2048,6 +2059,12 @@ func (s *Server) resolveImport(location common.Location) (program *ast.Program,
2048
2059
}
2049
2060
code , err = s .resolveAddressImport (loc )
2050
2061
2062
+ case common.IdentifierLocation :
2063
+ if s .resolveIdentifierImport == nil {
2064
+ return nil , nil
2065
+ }
2066
+ code , err = s .resolveIdentifierImport (loc )
2067
+
2051
2068
default :
2052
2069
return nil , nil
2053
2070
}
0 commit comments