Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1097)

Unified Diff: pkg/analysis_server/lib/src/domain_execution.dart

Issue 2937323003: Remove ability to disable new analysis driver (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/domain_execution.dart
diff --git a/pkg/analysis_server/lib/src/domain_execution.dart b/pkg/analysis_server/lib/src/domain_execution.dart
index 3a9161c67087e44c280a43e98e85d02eaf341095..801979efd0aafd59b3be32033bf7221c596d08eb 100644
--- a/pkg/analysis_server/lib/src/domain_execution.dart
+++ b/pkg/analysis_server/lib/src/domain_execution.dart
@@ -12,7 +12,6 @@ import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/constants.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
-import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
/**
@@ -98,21 +97,11 @@ class ExecutionDomainHandler implements RequestHandler {
'There is no execution context with an id of $contextId');
}
- SourceFactory sourceFactory;
- AnalysisDriver driver;
- if (server.options.enableNewAnalysisDriver) {
- driver = server.getAnalysisDriver(path);
- if (driver == null) {
- return new Response.invalidExecutionContext(request, contextId);
- }
- sourceFactory = driver.sourceFactory;
- } else {
- AnalysisContext context = server.getContainingContext(path);
- if (context == null) {
- return new Response.invalidExecutionContext(request, contextId);
- }
- sourceFactory = context.sourceFactory;
+ AnalysisDriver driver = server.getAnalysisDriver(path);
+ if (driver == null) {
+ return new Response.invalidExecutionContext(request, contextId);
}
+ SourceFactory sourceFactory = driver.sourceFactory;
String file = params.file;
String uri = params.uri;
@@ -129,13 +118,7 @@ class ExecutionDomainHandler implements RequestHandler {
request, 'file', 'Must not refer to a directory');
}
- Source source;
- if (server.options.enableNewAnalysisDriver) {
- source = driver.fsState.getFileForPath(file).source;
- } else {
- ContextSourcePair contextSource = server.getContextSourcePair(file);
- source = contextSource.source;
- }
+ Source source = driver.fsState.getFileForPath(file).source;
if (source.uriKind != UriKind.FILE_URI) {
uri = source.uri.toString();
} else {
@@ -158,112 +141,7 @@ class ExecutionDomainHandler implements RequestHandler {
* Implement the 'execution.setSubscriptions' request.
*/
Response setSubscriptions(Request request) {
- if (server.options.enableNewAnalysisDriver) {
- // Under the analysis driver, setSubscriptions() becomes a no-op.
- return new ExecutionSetSubscriptionsResult().toResponse(request.id);
- } else {
- List<ExecutionService> subscriptions =
- new ExecutionSetSubscriptionsParams.fromRequest(request)
- .subscriptions;
- if (subscriptions.contains(ExecutionService.LAUNCH_DATA)) {
- if (onFileAnalyzed == null) {
- onFileAnalyzed = server.onFileAnalyzed.listen(_fileAnalyzed);
- _reportCurrentFileStatus();
- }
- } else {
- if (onFileAnalyzed != null) {
- onFileAnalyzed.cancel();
- onFileAnalyzed = null;
- }
- }
- return new ExecutionSetSubscriptionsResult().toResponse(request.id);
- }
- }
-
- void _fileAnalyzed(ChangeNotice notice) {
- ServerPerformanceStatistics.executionNotifications.makeCurrentWhile(() {
- Source source = notice.source;
- String filePath = source.fullName;
- // check files
- bool isDartFile = notice.resolvedDartUnit != null;
- if (!isDartFile) {
- return;
- }
- // prepare context
- AnalysisContext context = server.getContainingContext(filePath);
- if (context == null) {
- return;
- }
- // analyze the file
- if (isDartFile) {
- ExecutableKind kind = ExecutableKind.NOT_EXECUTABLE;
- if (context.isClientLibrary(source)) {
- kind = ExecutableKind.CLIENT;
- if (context.isServerLibrary(source)) {
- kind = ExecutableKind.EITHER;
- }
- } else if (context.isServerLibrary(source)) {
- kind = ExecutableKind.SERVER;
- }
- server.sendNotification(
- new ExecutionLaunchDataParams(filePath, kind: kind)
- .toNotification());
- }
- });
- }
-
- /**
- * Return `true` if the given [filePath] represents a file that is in an
- * analysis root.
- */
- bool _isInAnalysisRoot(String filePath) =>
- server.contextManager.isInAnalysisRoot(filePath);
-
- void _reportCurrentFileStatus() {
- for (AnalysisContext context in server.analysisContexts) {
- List<Source> librarySources = context.librarySources;
- List<Source> clientSources = context.launchableClientLibrarySources;
- List<Source> serverSources = context.launchableServerLibrarySources;
- for (Source source in clientSources) {
- if (serverSources.remove(source)) {
- _sendKindNotification(source.fullName, ExecutableKind.EITHER);
- } else {
- _sendKindNotification(source.fullName, ExecutableKind.CLIENT);
- }
- librarySources.remove(source);
- }
- for (Source source in serverSources) {
- _sendKindNotification(source.fullName, ExecutableKind.SERVER);
- librarySources.remove(source);
- }
- for (Source source in librarySources) {
- _sendKindNotification(source.fullName, ExecutableKind.NOT_EXECUTABLE);
- }
- for (Source source in context.htmlSources) {
- String filePath = source.fullName;
- if (_isInAnalysisRoot(filePath)) {
- List<Source> libraries =
- context.getLibrariesReferencedFromHtml(source);
- server.sendNotification(new ExecutionLaunchDataParams(filePath,
- referencedFiles: _getFullNames(libraries))
- .toNotification());
- }
- }
- }
- }
-
- /**
- * Send a notification indicating the [kind] of the file with the given
- * [filePath], but only if the file is in an analysis root.
- */
- void _sendKindNotification(String filePath, ExecutableKind kind) {
- if (_isInAnalysisRoot(filePath)) {
- server.sendNotification(
- new ExecutionLaunchDataParams(filePath, kind: kind).toNotification());
- }
- }
-
- static List<String> _getFullNames(List<Source> sources) {
- return sources.map((Source source) => source.fullName).toList();
+ // Under the analysis driver, setSubscriptions() becomes a no-op.
+ return new ExecutionSetSubscriptionsResult().toResponse(request.id);
}
}
« no previous file with comments | « pkg/analysis_server/lib/src/domain_diagnostic.dart ('k') | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698