Open bitsydarel opened 3 years ago
/cc @bkonyi
@devoncarew
Hi @devoncarew Any news on this ?
This is applicable to both dart analyze
and dart fix
.
@mit-mit ?
// @bwilkerson
It's pretty easy to add the new flag to dart analyze
and pass it onto the analysis server wrapper here:
https://github.com/dart-lang/sdk/blob/main/pkg/dartdev/lib/src/analysis_server.dart#L28
@@ -30,12 +30,14 @@ class AnalysisServer {
this.packagesFile,
this.sdkPath,
this.analysisRoots, {
+ this.optionsFile,
this.cacheDirectoryPath,
required this.commandName,
required this.argResults,
});
final String? cacheDirectoryPath;
+ final File? optionsFile;
})
That then invokes an analysis driver here: https://github.com/dart-lang/sdk/blob/main/pkg/dartdev/lib/src/analysis_server.dart#L85
I tried adding an --options
here, but that doesn't work:
mit-macbookpro5:pkg1 mit$ ~/dev/dartsdk/sdk/xcodebuild/DebugX64/dart-sdk/bin/dart analyze --options=fuz/analysis_options.yaml .
Analyzing ....
Unhandled exception:
FormatException: Could not find an option named "options".
#0 Parser._validate (package:args/src/parser.dart:309:21)
#1 Parser._handleLongOption (package:args/src/parser.dart:298:7)
#2 Parser._parseLongOption (package:args/src/parser.dart:262:12)
#3 Parser.parse (package:args/src/parser.dart:86:11)
#4 ArgParser.parse (package:args/src/arg_parser.dart:334:42)
#5 Driver.start (package:analysis_server/src/server/driver.dart:144:26)
#6 main (file:///Users/mit/dev/dartsdk/sdk/pkg/analysis_server/bin/server.dart:10:11)
#7 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Is there a way of passing the options file path to package:analysis_server/src/server/driver.dart
?
Not currently, no.
The analysis server was originally designed to be a long-running process and for the set of packages being analyzed to vary over time. In that mode such an option doesn't make sense.
But it's now being used by command-line tools like dart analyze
and dart fix
, and in that environment the option makes more sense.
If we want / need to add such an option to dart analyze
, then we'll need to add it to the server as well.
This tracker is for issues related to:
Analyzer
Dart SDK version: 2.12.0 (stable) (Thu Feb 25 19:50:53 2021 +0100) on "macos_x64" MacOSX
dart analyze does not support the command --options to specify the location of the analysis_options.yaml file which is needed to run analysis of project with code style located outside of the project directory.