@@ -32,6 +32,7 @@ class LinterRust
32
32
@subscriptions .add atom .config .observe ' linter-rust.cargoCommand' ,
33
33
(cargoCommand ) =>
34
34
@cargoCommand = cargoCommand
35
+ @useWorkspaceManifest = cargoCommand .endsWith (' all' )
35
36
36
37
@subscriptions .add atom .config .observe ' linter-rust.rustcBuildTest' ,
37
38
(rustcBuildTest ) =>
@@ -75,6 +76,8 @@ class LinterRust
75
76
cmdPath = if cmd[0 ]? then path .dirname cmd[0 ] else __dirname
76
77
args = cmd .slice 1
77
78
env .PATH = cmdPath + path .delimiter + env .PATH
79
+ cargoManifestFile = @ locateCargo curDir
80
+ cargoManifestDir = path .dirname cargoManifestFile
78
81
79
82
# we set flags only for intermediate json support
80
83
if errorMode == errorModes .FLAGS_JSON_CARGO
@@ -116,7 +119,8 @@ class LinterRust
116
119
# correct file paths
117
120
messages .forEach (message) ->
118
121
if ! (path .isAbsolute message .location .file )
119
- message .location .file = path .join curDir, message .location .file
122
+ message .location .file = path .join curDir, message .location .file if fs .existsSync path .join curDir, message .location .file
123
+ message .location .file = path .join cargoManifestDir, message .location .file if fs .existsSync path .join cargoManifestDir, message .location .file
120
124
messages
121
125
else
122
126
# whoops, we're in trouble -- let's output as much as we can
@@ -199,8 +203,29 @@ class LinterRust
199
203
locateCargo : (curDir ) =>
200
204
root_dir = if / ^ win/ .test process .platform then / ^ . :\\ $ / else / ^ \/ $ /
201
205
directory = path .resolve curDir
206
+ manifest_name = @cargoManifestFilename
207
+
202
208
loop
203
- return path .join directory, @cargoManifestFilename if fs .existsSync path .join directory, @cargoManifestFilename
209
+ if fs .existsSync path .join directory, manifest_name
210
+ crate_level_manifest = path .join directory , manifest_name
211
+
212
+ if @useWorkspaceManifest
213
+ execOpts =
214
+ env : JSON .parse JSON .stringify process .env
215
+ cwd : curDir
216
+ stream : ' both'
217
+
218
+ atom_linter .exec (' cargo' , [' locate-project' , ' --workspace' , ' --manifest-path=' + crate_level_manifest], execOpts)
219
+ .then (result) =>
220
+ {stdout , stderr , exitCode } = result
221
+ json = JSON .parse stdout
222
+ return json .root
223
+ .catch (error) ->
224
+ return crate_level_manifest
225
+ else
226
+ return crate_level_manifest
227
+
228
+ return path .join directory , manifest_name if fs .existsSync path .join directory, manifest_name
204
229
break if root_dir .test directory
205
230
directory = path .resolve path .join (directory, ' ..' )
206
231
return false
0 commit comments