afcfbbeba8
(Part of https://github.com/dart-lang/sdk/issues/63288) This change migrates the packages owned by the developer experience team to use the new constructor declaration syntax, described in https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations. This change was performed in an automated fashion, by (a) bumping the packages' SDK constraints to `3.13.0-0`, (b) enabling the lints `unnecessary_type_name_in_constructor` and `unnecessary_const_in_enum_constructor`, (c) fixing the resulting lint failures using `dart fix`, and then (d) reformatting the affected files. To ease code review, I've reverted unrelated formatting changes. Since this change requires bumping SDK constaints to `3.13.0-0`, it was only performed on packages that are *not* published on pub. (Packages that *are* published on pub should remain on lower language versions until at least after the stable version of 3.13 is released, so that we don't block users on the stable channel from receiving updates to those packages.) Change-Id: Ibb4daebafd239da58251e838ea6a3f336a6a6964 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505046 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
194 lines
5.5 KiB
Dart
194 lines
5.5 KiB
Dart
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
/// Code generation for the file "AnalysisServer.java".
|
|
library;
|
|
|
|
import 'package:analyzer_utilities/tools.dart';
|
|
|
|
import 'api.dart';
|
|
import 'codegen_java.dart';
|
|
|
|
final GeneratedFile target = javaGeneratedFile(
|
|
'analysis_server/tool/spec/generated/java/AnalysisServer.java',
|
|
(Api api) => CodegenAnalysisServer(api),
|
|
);
|
|
|
|
class CodegenAnalysisServer extends CodegenJavaVisitor {
|
|
new(super.api);
|
|
|
|
@override
|
|
void visitApi() {
|
|
outputHeader(javaStyle: true);
|
|
writeln('package com.google.dart.server.generated;');
|
|
writeln();
|
|
writeln('import com.google.dart.server.*;');
|
|
writeln('import org.dartlang.analysis.server.protocol.*;');
|
|
writeln();
|
|
writeln('import java.util.List;');
|
|
writeln('import java.util.Map;');
|
|
writeln();
|
|
writeln('''/**
|
|
* The interface {@code AnalysisServer} defines the behavior of objects that interface to an
|
|
* analysis server.
|
|
*
|
|
* @coverage dart.server
|
|
*/''');
|
|
makeClass('public interface AnalysisServer', () {
|
|
//
|
|
// addAnalysisServerListener(..)
|
|
//
|
|
publicMethod('addAnalysisServerListener', () {
|
|
writeln('''/**
|
|
* Add the given listener to the list of listeners that will receive notification when new
|
|
* analysis results become available.
|
|
*
|
|
* @param listener the listener to be added
|
|
*/''');
|
|
writeln(
|
|
'public void addAnalysisServerListener(AnalysisServerListener listener);',
|
|
);
|
|
});
|
|
|
|
//
|
|
// removeAnalysisServerListener(..)
|
|
//
|
|
publicMethod('removeAnalysisServerListener', () {
|
|
writeln('''/**
|
|
* Remove the given listener from the list of listeners that will receive notification when new
|
|
* analysis results become available.
|
|
*
|
|
* @param listener the listener to be removed
|
|
*/''');
|
|
writeln(
|
|
'public void removeAnalysisServerListener(AnalysisServerListener listener);',
|
|
);
|
|
});
|
|
|
|
//
|
|
// addRequestListener(..)
|
|
//
|
|
publicMethod('addRequestListener', () {
|
|
writeln('''/**
|
|
* Add the given listener to the list of listeners that will receive notification when
|
|
* requests are made by an analysis server client.
|
|
*
|
|
* @param listener the listener to be added
|
|
*/''');
|
|
writeln('public void addRequestListener(RequestListener listener);');
|
|
});
|
|
|
|
//
|
|
// removeRequestListener(..)
|
|
//
|
|
publicMethod('removeRequestListener', () {
|
|
writeln('''/**
|
|
* Remove the given listener from the list of listeners that will receive notification when
|
|
* requests are made by an analysis server client.
|
|
*
|
|
* @param listener the listener to be removed
|
|
*/''');
|
|
writeln('public void removeRequestListener(RequestListener listener);');
|
|
});
|
|
|
|
//
|
|
// addResponseListener(..)
|
|
//
|
|
publicMethod('addResponseListener', () {
|
|
writeln('''/**
|
|
* Add the given listener to the list of listeners that will receive notification when
|
|
* responses are received by an analysis server client.
|
|
*
|
|
* @param listener the listener to be added
|
|
*/''');
|
|
writeln('public void addResponseListener(ResponseListener listener);');
|
|
});
|
|
|
|
//
|
|
// removeResponseListener(..)
|
|
//
|
|
publicMethod('removeResponseListener', () {
|
|
writeln('''/**
|
|
* Remove the given listener from the list of listeners that will receive notification when
|
|
* responses are received by an analysis server client.
|
|
*
|
|
* @param listener the listener to be removed
|
|
*/''');
|
|
writeln(
|
|
'public void removeResponseListener(ResponseListener listener);',
|
|
);
|
|
});
|
|
|
|
//
|
|
// addStatusListener(..)
|
|
//
|
|
publicMethod('addStatusListener', () {
|
|
writeln('''/**
|
|
* Add the given listener to the list of listeners that will receive notification when the server
|
|
* is not active
|
|
*
|
|
* @param listener the listener to be added
|
|
*/''');
|
|
writeln(
|
|
'public void addStatusListener(AnalysisServerStatusListener listener);',
|
|
);
|
|
});
|
|
|
|
//
|
|
// isSocketOpen()
|
|
//
|
|
publicMethod('isSocketOpen', () {
|
|
writeln('''/**
|
|
* Return {@code true} if the socket is open.
|
|
*/''');
|
|
writeln('public boolean isSocketOpen();');
|
|
});
|
|
|
|
//
|
|
// start(..)
|
|
//
|
|
publicMethod('start', () {
|
|
writeln('''/**
|
|
* Start the analysis server.
|
|
*/''');
|
|
writeln('public void start() throws Exception;');
|
|
});
|
|
super.visitApi();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void visitRequest(Request request) {
|
|
var methodName = '${request.domainName}_${request.method}';
|
|
publicMethod(methodName, () {
|
|
docComment(
|
|
toHtmlVisitor.collectHtml(() {
|
|
toHtmlVisitor.write('{@code ${request.longMethod}}');
|
|
toHtmlVisitor.translateHtml(request.html);
|
|
toHtmlVisitor.javadocParams(request.params);
|
|
if (request.deprecated) {
|
|
toHtmlVisitor.p(() => toHtmlVisitor.write('@deprecated'));
|
|
}
|
|
}),
|
|
);
|
|
write('public void $methodName(');
|
|
var arguments = <String>[];
|
|
|
|
var params = request.params;
|
|
if (params != null) {
|
|
for (var field in params.fields) {
|
|
arguments.add('${javaType(field.type)} ${javaName(field.name)}');
|
|
}
|
|
}
|
|
|
|
if (request.result != null) {
|
|
arguments.add('${consumerName(request)} consumer');
|
|
}
|
|
|
|
write(arguments.join(', '));
|
|
writeln(');');
|
|
});
|
|
}
|
|
}
|