From 25dfd0fa80fe2cb122ae2c2889b800194a99e0ff Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 24 Feb 2017 11:01:00 -0800 Subject: [PATCH] Deprecate execution.setSubscriptions. BUG= R=brianwilkerson@google.com, scheglov@google.com Review-Url: https://codereview.chromium.org/2713513007 . --- pkg/analysis_server/doc/api.html | 20 +++-- .../plugin/protocol/generated_protocol.dart | 16 ++-- .../lib/src/domain_execution.dart | 27 ++++--- .../test/domain_execution_test.dart | 76 ------------------- .../test/integration/coverage.md | 2 +- .../execution/set_subscriptions_test.dart | 15 ---- .../integration/integration_test_methods.dart | 6 +- .../spec/generated/java/AnalysisServer.java | 4 +- .../java/types/HoverInformation.java | 8 +- .../generated/java/types/RenameFeedback.java | 8 +- pkg/analysis_server/tool/spec/spec_input.html | 20 +++-- 11 files changed, 64 insertions(+), 138 deletions(-) diff --git a/pkg/analysis_server/doc/api.html b/pkg/analysis_server/doc/api.html index 9fc9d4596c6..328bf553720 100644 --- a/pkg/analysis_server/doc/api.html +++ b/pkg/analysis_server/doc/api.html @@ -143,9 +143,9 @@ a:focus, a:hover { To ease interoperability with Lisp-based clients (which may not be able to easily distinguish between empty lists, empty maps, and null), client-to-server communication is allowed to replace - any instance of “{}” or “[]” with null. The + any instance of "{}" or "[]" with null. The server will always properly represent empty lists as - “[]” and empty maps as “{}”. + "[]" and empty maps as "{}".

Communication Structure

@@ -2059,7 +2059,7 @@ a:focus, a:hover { structure of the data is dependent on the kind of refactoring being performed. The data that is expected is documented in the section titled Refactorings, labeled as - “Options”. This field can be omitted if the refactoring + "Options". This field can be omitted if the refactoring does not require any options or if the values of those options are not known.

@@ -2093,7 +2093,7 @@ a:focus, a:hover { of the data is dependent on the kind of refactoring being created. The data that is returned is documented in the section titled Refactorings, labeled as - “Feedback”. + "Feedback".

change (optional SourceChange)
@@ -2346,6 +2346,10 @@ a:focus, a:hover { "id": String "error": optional RequestError } +

+ Deprecated: the analysis server no longer fires + LAUNCH_DATA events. +

Subscribe for services. All previous subscriptions are replaced by the given set of services. @@ -3307,8 +3311,8 @@ a:focus, a:hover {

A human-readable description of the kind of element being - referenced (such as “class” or “function type - alias”). This data is omitted if there is no referenced + referenced (such as "class" or "function type + alias"). This data is omitted if there is no referenced element.

isDeprecated (optional bool)
@@ -4502,8 +4506,8 @@ a:focus, a:hover {

The human-readable description of the kind of element being - renamed (such as “class” or “function type - alias”). + renamed (such as "class" or "function type + alias").

oldName (String)
diff --git a/pkg/analysis_server/lib/plugin/protocol/generated_protocol.dart b/pkg/analysis_server/lib/plugin/protocol/generated_protocol.dart index 59b76b03c14..f3c299d7035 100644 --- a/pkg/analysis_server/lib/plugin/protocol/generated_protocol.dart +++ b/pkg/analysis_server/lib/plugin/protocol/generated_protocol.dart @@ -6227,7 +6227,7 @@ class EditGetRefactoringParams implements HasToJson { * Data used to provide values provided by the user. The structure of the * data is dependent on the kind of refactoring being performed. The data * that is expected is documented in the section titled Refactorings, labeled - * as “Options”. This field can be omitted if the refactoring does not + * as "Options". This field can be omitted if the refactoring does not * require any options or if the values of those options are not known. */ RefactoringOptions get options => _options; @@ -6236,7 +6236,7 @@ class EditGetRefactoringParams implements HasToJson { * Data used to provide values provided by the user. The structure of the * data is dependent on the kind of refactoring being performed. The data * that is expected is documented in the section titled Refactorings, labeled - * as “Options”. This field can be omitted if the refactoring does not + * as "Options". This field can be omitted if the refactoring does not * require any options or if the values of those options are not known. */ void set options(RefactoringOptions value) { @@ -6432,7 +6432,7 @@ class EditGetRefactoringResult implements HasToJson { * Data used to provide feedback to the user. The structure of the data is * dependent on the kind of refactoring being created. The data that is * returned is documented in the section titled Refactorings, labeled as - * “Feedback”. + * "Feedback". */ RefactoringFeedback get feedback => _feedback; @@ -6440,7 +6440,7 @@ class EditGetRefactoringResult implements HasToJson { * Data used to provide feedback to the user. The structure of the data is * dependent on the kind of refactoring being created. The data that is * returned is documented in the section titled Refactorings, labeled as - * “Feedback”. + * "Feedback". */ void set feedback(RefactoringFeedback value) { this._feedback = value; @@ -11571,14 +11571,14 @@ class HoverInformation implements HasToJson { /** * A human-readable description of the kind of element being referenced (such - * as “class” or “function type alias”). This data is omitted if there is no + * as "class" or "function type alias"). This data is omitted if there is no * referenced element. */ String get elementKind => _elementKind; /** * A human-readable description of the kind of element being referenced (such - * as “class” or “function type alias”). This data is omitted if there is no + * as "class" or "function type alias"). This data is omitted if there is no * referenced element. */ void set elementKind(String value) { @@ -16976,13 +16976,13 @@ class RenameFeedback extends RefactoringFeedback { /** * The human-readable description of the kind of element being renamed (such - * as “class” or “function type alias”). + * as "class" or "function type alias"). */ String get elementKindName => _elementKindName; /** * The human-readable description of the kind of element being renamed (such - * as “class” or “function type alias”). + * as "class" or "function type alias"). */ void set elementKindName(String value) { assert(value != null); diff --git a/pkg/analysis_server/lib/src/domain_execution.dart b/pkg/analysis_server/lib/src/domain_execution.dart index 29449c5b3fa..dfdd2bd9c44 100644 --- a/pkg/analysis_server/lib/src/domain_execution.dart +++ b/pkg/analysis_server/lib/src/domain_execution.dart @@ -159,20 +159,25 @@ class ExecutionDomainHandler implements RequestHandler { * Implement the 'execution.setSubscriptions' request. */ Response setSubscriptions(Request request) { - List subscriptions = - new ExecutionSetSubscriptionsParams.fromRequest(request).subscriptions; - if (subscriptions.contains(ExecutionService.LAUNCH_DATA)) { - if (onFileAnalyzed == null) { - onFileAnalyzed = server.onFileAnalyzed.listen(_fileAnalyzed); - _reportCurrentFileStatus(); - } + if (server.options.enableNewAnalysisDriver) { + // Under the analysis driver, setSubscriptions() becomes a no-op. + return new ExecutionSetSubscriptionsResult().toResponse(request.id); } else { - if (onFileAnalyzed != null) { - onFileAnalyzed.cancel(); - onFileAnalyzed = null; + List 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); } - return new ExecutionSetSubscriptionsResult().toResponse(request.id); } void _fileAnalyzed(ChangeNotice notice) { diff --git a/pkg/analysis_server/test/domain_execution_test.dart b/pkg/analysis_server/test/domain_execution_test.dart index 3ed91bd0d1b..8e134778f1e 100644 --- a/pkg/analysis_server/test/domain_execution_test.dart +++ b/pkg/analysis_server/test/domain_execution_test.dart @@ -4,12 +4,9 @@ library test.domain.execution; -import 'dart:async'; - import 'package:analysis_server/plugin/protocol/protocol.dart'; import 'package:analysis_server/src/analysis_server.dart'; import 'package:analysis_server/src/constants.dart'; -import 'package:analysis_server/src/context_manager.dart'; import 'package:analysis_server/src/domain_execution.dart'; import 'package:analysis_server/src/plugin/server_plugin.dart'; import 'package:analyzer/file_system/file_system.dart'; @@ -22,11 +19,9 @@ import 'package:analyzer/src/generated/source_io.dart'; import 'package:plugin/manager.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; -import 'package:typed_mock/typed_mock.dart'; import 'analysis_abstract.dart'; import 'mocks.dart'; -import 'operation/operation_queue_test.dart'; main() { defineReflectiveSuite(() { @@ -199,77 +194,6 @@ main() { expect(handler.onFileAnalyzed, isNull); }); }); - - test('onAnalysisComplete - success - setting and clearing', () { - Source source1 = new TestSource('/a.dart'); - Source source2 = new TestSource('/b.dart'); - Source source3 = new TestSource('/c.dart'); - Source source4 = new TestSource('/d.dart'); - Source source5 = new TestSource('/e.html'); - Source source6 = new TestSource('/f.html'); - Source source7 = new TestSource('/g.html'); - - AnalysisContext context = new AnalysisContextMock(); - when(context.launchableClientLibrarySources) - .thenReturn([source1, source2]); - when(context.launchableServerLibrarySources) - .thenReturn([source2, source3]); - when(context.librarySources).thenReturn([source4]); - when(context.htmlSources).thenReturn([source5]); - when(context.getLibrariesReferencedFromHtml(anyObject)) - .thenReturn([source6, source7]); - - ContextManager manager = new ServerContextManagerMock(); - when(manager.isInAnalysisRoot(anyString)).thenReturn(true); - - AnalysisServer server = new AnalysisServerMock(); - when(server.analysisContexts).thenReturn([context]); - when(server.contextManager).thenReturn(manager); - - StreamController controller = new StreamController.broadcast(sync: true); - when(server.onFileAnalyzed).thenReturn(controller.stream); - - List unsentNotifications = [ - source1.fullName, - source2.fullName, - source3.fullName, - source4.fullName, - source5.fullName - ]; - when(server.sendNotification(anyObject)) - .thenInvoke((Notification notification) { - ExecutionLaunchDataParams params = - new ExecutionLaunchDataParams.fromNotification(notification); - - String fileName = params.file; - expect(unsentNotifications.remove(fileName), isTrue); - - if (fileName == source1.fullName) { - expect(params.kind, ExecutableKind.CLIENT); - } else if (fileName == source2.fullName) { - expect(params.kind, ExecutableKind.EITHER); - } else if (fileName == source3.fullName) { - expect(params.kind, ExecutableKind.SERVER); - } else if (fileName == source4.fullName) { - expect(params.kind, ExecutableKind.NOT_EXECUTABLE); - } else if (fileName == source5.fullName) { - var referencedFiles = params.referencedFiles; - expect(referencedFiles, isNotNull); - expect(referencedFiles.length, equals(2)); - expect(referencedFiles[0], equals(source6.fullName)); - expect(referencedFiles[1], equals(source7.fullName)); - } - }); - - ExecutionDomainHandler handler = new ExecutionDomainHandler(server); - Request request = - new ExecutionSetSubscriptionsParams([ExecutionService.LAUNCH_DATA]) - .toRequest('0'); - handler.handleRequest(request); - -// controller.add(null); - expect(unsentNotifications, isEmpty); - }); }); } diff --git a/pkg/analysis_server/test/integration/coverage.md b/pkg/analysis_server/test/integration/coverage.md index 9f394ba8751..cea5f7ec3e7 100644 --- a/pkg/analysis_server/test/integration/coverage.md +++ b/pkg/analysis_server/test/integration/coverage.md @@ -39,7 +39,7 @@ TODO(devoncarew): We should track analysis server notifications here as well. - [x] execution.createContext - [x] execution.deleteContext - [x] execution.mapUri -- [x] execution.setSubscriptions (failing - see #28806) +- [x] execution.setSubscriptions ## search domain - [ ] search.findElementReferences diff --git a/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart b/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart index 4afbaa62747..fe7d3945e63 100644 --- a/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart +++ b/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analysis_server/plugin/protocol/protocol.dart'; -import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; import '../integration_tests.dart'; @@ -16,23 +15,9 @@ main() { @reflectiveTest class SetSubscriptionsTest extends AbstractAnalysisServerIntegrationTest { - @failingTest test_subscribe() async { - // Bad state: Should not be used with the new analysis driver (#28806) - writeFile(sourcePath('.packages'), 'foo:lib/'); standardAnalysisSetup(); await sendExecutionSetSubscriptions([ExecutionService.LAUNCH_DATA]); - - String contextId = - (await sendExecutionCreateContext(sourceDirectory.path)).id; - expect(contextId, isNotNull); - - String pathname = sourcePath('lib/main.dart'); - writeFile(pathname, 'void main() {}'); - - ExecutionLaunchDataParams data = await onExecutionLaunchData.first; - expect(data.kind, ExecutableKind.SERVER); - expect(data.file, pathname); } @override diff --git a/pkg/analysis_server/test/integration/integration_test_methods.dart b/pkg/analysis_server/test/integration/integration_test_methods.dart index ea537a93c45..e9ab15b446d 100644 --- a/pkg/analysis_server/test/integration/integration_test_methods.dart +++ b/pkg/analysis_server/test/integration/integration_test_methods.dart @@ -1345,7 +1345,7 @@ abstract class IntegrationTestMixin { * Data used to provide values provided by the user. The structure of the * data is dependent on the kind of refactoring being performed. The data * that is expected is documented in the section titled Refactorings, - * labeled as “Options”. This field can be omitted if the refactoring does + * labeled as "Options". This field can be omitted if the refactoring does * not require any options or if the values of those options are not known. * * Returns @@ -1373,7 +1373,7 @@ abstract class IntegrationTestMixin { * Data used to provide feedback to the user. The structure of the data is * dependent on the kind of refactoring being created. The data that is * returned is documented in the section titled Refactorings, labeled as - * “Feedback”. + * "Feedback". * * change (optional SourceChange) * @@ -1560,6 +1560,8 @@ abstract class IntegrationTestMixin { } /** + * Deprecated: the analysis server no longer fires LAUNCH_DATA events. + * * Subscribe for services. All previous subscriptions are replaced by the * given set of services. * diff --git a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java index 99e5ac09d34..67bce36ba9d 100644 --- a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java +++ b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java @@ -378,7 +378,7 @@ public interface AnalysisServer { * validated and no change be generated. * @param options Data used to provide values provided by the user. The structure of the data is * dependent on the kind of refactoring being performed. The data that is expected is - * documented in the section titled Refactorings, labeled as “Options”. This field can be + * documented in the section titled Refactorings, labeled as "Options". This field can be * omitted if the refactoring does not require any options or if the values of those * options are not known. */ @@ -467,6 +467,8 @@ public interface AnalysisServer { /** * {@code execution.setSubscriptions} * + * Deprecated: the analysis server no longer fires LAUNCH_DATA events. + * * Subscribe for services. All previous subscriptions are replaced by the given set of services. * * It is an error if any of the elements in the list are not valid services. If there is an error, diff --git a/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java b/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java index d1dd58d24db..b9ca9819825 100644 --- a/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java +++ b/pkg/analysis_server/tool/spec/generated/java/types/HoverInformation.java @@ -89,8 +89,8 @@ public class HoverInformation { private final String elementDescription; /** - * A human-readable description of the kind of element being referenced (such as “class” or - * “function type alias”). This data is omitted if there is no referenced element. + * A human-readable description of the kind of element being referenced (such as "class" or + * "function type alias"). This data is omitted if there is no referenced element. */ private final String elementKind; @@ -228,8 +228,8 @@ public class HoverInformation { } /** - * A human-readable description of the kind of element being referenced (such as “class” or - * “function type alias”). This data is omitted if there is no referenced element. + * A human-readable description of the kind of element being referenced (such as "class" or + * "function type alias"). This data is omitted if there is no referenced element. */ public String getElementKind() { return elementKind; diff --git a/pkg/analysis_server/tool/spec/generated/java/types/RenameFeedback.java b/pkg/analysis_server/tool/spec/generated/java/types/RenameFeedback.java index 35dacffe8f2..c10021ff74e 100644 --- a/pkg/analysis_server/tool/spec/generated/java/types/RenameFeedback.java +++ b/pkg/analysis_server/tool/spec/generated/java/types/RenameFeedback.java @@ -52,8 +52,8 @@ public class RenameFeedback extends RefactoringFeedback { private final int length; /** - * The human-readable description of the kind of element being renamed (such as “class” or - * “function type alias”). + * The human-readable description of the kind of element being renamed (such as "class" or + * "function type alias"). */ private final String elementKindName; @@ -106,8 +106,8 @@ public class RenameFeedback extends RefactoringFeedback { } /** - * The human-readable description of the kind of element being renamed (such as “class” or - * “function type alias”). + * The human-readable description of the kind of element being renamed (such as "class" or + * "function type alias"). */ public String getElementKindName() { return elementKindName; diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html index 1f15359f95e..41eaf794992 100644 --- a/pkg/analysis_server/tool/spec/spec_input.html +++ b/pkg/analysis_server/tool/spec/spec_input.html @@ -41,9 +41,9 @@ To ease interoperability with Lisp-based clients (which may not be able to easily distinguish between empty lists, empty maps, and null), client-to-server communication is allowed to replace - any instance of “{}” or “[]” with null. The + any instance of "{}" or "[]" with null. The server will always properly represent empty lists as - “[]” and empty maps as “{}”. + "[]" and empty maps as "{}".

Communication Structure

@@ -1730,7 +1730,7 @@ refactoring being performed. The data that is expected is documented in the section titled Refactorings, labeled as - “Options”. This field can be omitted if the refactoring + "Options". This field can be omitted if the refactoring does not require any options or if the values of those options are not known.

@@ -1771,7 +1771,7 @@ being created. The data that is returned is documented in the section titled Refactorings, labeled as - “Feedback”. + "Feedback".

@@ -1981,6 +1981,10 @@ +

+ Deprecated: the analysis server no longer fires + LAUNCH_DATA events. +

Subscribe for services. All previous subscriptions are replaced by the given set of services. @@ -3124,8 +3128,8 @@ String

A human-readable description of the kind of element being - referenced (such as “class” or “function type - alias”). This data is omitted if there is no referenced + referenced (such as "class" or "function type + alias"). This data is omitted if there is no referenced element.

@@ -4553,8 +4557,8 @@ String

The human-readable description of the kind of element being - renamed (such as “class” or “function type - alias”). + renamed (such as "class" or "function type + alias").