@@ -61,10 +61,10 @@ func Diagnostics(ctx context.Context, snapshot Snapshot, ph PackageHandle, missi
61
61
warn = true
62
62
}
63
63
64
- isMissingModule := false
64
+ missing := make ( map [ string ] * modfile. Require )
65
65
for _ , imp := range pkg .Imports () {
66
- if _ , ok := missingModules [imp .PkgPath ()]; ok {
67
- isMissingModule = true
66
+ if req , ok := missingModules [imp .PkgPath ()]; ok {
67
+ missing [ imp . PkgPath ()] = req
68
68
continue
69
69
}
70
70
for dep , req := range missingModules {
@@ -77,8 +77,7 @@ func Diagnostics(ctx context.Context, snapshot Snapshot, ph PackageHandle, missi
77
77
// )
78
78
// They both are related to the same module: "golang.org/x/tools"
79
79
if req != nil && strings .HasPrefix (imp .PkgPath (), dep ) {
80
- missingModules [imp .PkgPath ()] = req
81
- isMissingModule = true
80
+ missing [imp .PkgPath ()] = req
82
81
break
83
82
}
84
83
}
@@ -90,8 +89,8 @@ func Diagnostics(ctx context.Context, snapshot Snapshot, ph PackageHandle, missi
90
89
if err := clearReports (snapshot , reports , fh .File ().Identity ().URI ); err != nil {
91
90
return nil , warn , err
92
91
}
93
- if isMissingModule {
94
- if err := missingModulesDiagnostics (ctx , snapshot , reports , missingModules , fh .File ().Identity ().URI ); err != nil {
92
+ if len ( missing ) > 0 {
93
+ if err := missingModulesDiagnostics (ctx , snapshot , reports , missing , fh .File ().Identity ().URI ); err != nil {
95
94
return nil , warn , err
96
95
}
97
96
}
0 commit comments