createAnalysisDriver method
AnalysisDriverGeneric
createAnalysisDriver(
- ContextRoot contextRoot
)
Implementation
@override
AnalysisDriverGeneric createAnalysisDriver(plugin.ContextRoot contextRoot) {
final rootPath = contextRoot.root;
final locator = ContextLocator(
resourceProvider: resourceProvider,
).locateRoots(
includedPaths: [rootPath],
excludedPaths: contextRoot.exclude,
optionsFile: contextRoot.optionsFile,
);
if (locator.isEmpty) {
final error = _sendStateErrorNotification('Unexpected empty context');
throw error;
}
final builder = ContextBuilder(resourceProvider: resourceProvider);
final context = builder.createContext(contextRoot: locator.first)
as DriverBasedAnalysisContext;
final dartDriver = context.driver;
final options = _loadAnalysisOptions(contextRoot.optionsFile, optionKey);
runZonedGuarded(
() {
dartDriver.results.listen((analysisResult) {
if (analysisResult is ErrorsResult && analysisResult.errors.isEmpty) {
dartDriver.getResult(analysisResult.path);
} else if (analysisResult is ResolvedUnitResult) {
analyzeCommand.runCommand(
AnalyzeCommandContext(
options,
rules,
dartDriver,
analysisResult,
channel,
optionKey,
),
);
}
});
},
(e, stackTrace) {
channel.sendNotification(
plugin.PluginErrorParams(false, e.toString(), stackTrace.toString())
.toNotification(),
);
},
);
return dartDriver;
}