Skip to content

Commit 83b47a8

Browse files
srawlinsCommit Queue
authored andcommitted
DAS: rename constants to use lowerCamelCase
Change-Id: If3f23ffc275171c67d0dc9cab3ee4abb7c5bc117 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461181 Reviewed-by: Keerti Parthasarathy <keertip@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
1 parent 6cd11ed commit 83b47a8

32 files changed

+94
-104
lines changed

pkg/analysis_server/integration_test/support/integration_tests.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ abstract class AbstractAnalysisServerIntegrationTest extends IntegrationTest
110110
with MockPackagesMixin, ConfigurationFilesMixin {
111111
/// Amount of time to give the server to respond to a shutdown request before
112112
/// forcibly terminating it.
113-
static const Duration SHUTDOWN_TIMEOUT = Duration(seconds: 60);
113+
static const Duration shutdownTimeout = Duration(seconds: 60);
114114

115115
/// Connection to the analysis server.
116116
@override
@@ -287,7 +287,7 @@ abstract class AbstractAnalysisServerIntegrationTest extends IntegrationTest
287287
// doesn't exit, then forcibly terminate it.
288288
sendServerShutdown();
289289
return server.exitCode.timeout(
290-
SHUTDOWN_TIMEOUT,
290+
shutdownTimeout,
291291
onTimeout: () {
292292
// The integer value of the exit code isn't used, but we have to return
293293
// an integer to keep the typing correct.

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,12 @@ abstract class AnalysisServer {
572572
bool registerExperimentalHandlers = false,
573573
}) async {
574574
switch (dtd?.state) {
575-
case DtdConnectionState.Connecting || DtdConnectionState.Connected:
575+
case DtdConnectionState.connecting || DtdConnectionState.connected:
576576
return lsp.error(
577577
lsp.ServerErrorCodes.stateError,
578578
'Server is already connected to DTD',
579579
);
580-
case DtdConnectionState.Disconnected || DtdConnectionState.Error || null:
580+
case DtdConnectionState.disconnected || DtdConnectionState.error || null:
581581
var connectResult = await DtdServices.connect(
582582
this,
583583
dtdUri,

pkg/analysis_server/lib/src/plugin/plugin_isolate.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ class PluginIsolate {
239239
class PluginSession {
240240
/// The maximum number of milliseconds that server should wait for a response
241241
/// from a plugin before deciding that the plugin is hung.
242-
static const Duration MAXIMUM_RESPONSE_TIME = Duration(minutes: 2);
242+
static const Duration _maximumResponseTime = Duration(minutes: 2);
243243

244244
/// The length of time to wait after sending a 'plugin.shutdown' request
245245
/// before a failure to terminate will cause the isolate to be killed.
246-
static const Duration WAIT_FOR_SHUTDOWN_DURATION = Duration(seconds: 10);
246+
static const Duration _waitForShutdownDuration = Duration(seconds: 10);
247247

248248
/// The information about the plugin being executed.
249249
final PluginIsolate _isolate;
@@ -349,7 +349,7 @@ class PluginSession {
349349
// identify non-responsive plugins and kill them.
350350
var cutOffTime =
351351
DateTime.now().millisecondsSinceEpoch -
352-
MAXIMUM_RESPONSE_TIME.inMilliseconds;
352+
_maximumResponseTime.inMilliseconds;
353353
for (var requestData in pendingRequests.values) {
354354
if (requestData.requestTime < cutOffTime) {
355355
return true;
@@ -476,7 +476,7 @@ class PluginSession {
476476
throw StateError('Cannot stop a plugin that is not running.');
477477
}
478478
sendRequest(PluginShutdownParams());
479-
Future.delayed(WAIT_FOR_SHUTDOWN_DURATION, () {
479+
Future.delayed(_waitForShutdownDuration, () {
480480
if (channel != null) {
481481
channel?.kill();
482482
channel = null;

pkg/analysis_server/lib/src/server/http_server.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class AbstractHttpHandler {
2727
/// - serves diagnostic information as html pages
2828
class HttpAnalysisServer {
2929
/// Number of lines of print output to capture.
30-
static const int MAX_PRINT_BUFFER_LENGTH = 1000;
30+
static const int _maxPrintBufferLength = 1000;
3131

3232
/// An object that can handle either a WebSocket connection or a connection
3333
/// to the client over stdio.
@@ -62,11 +62,8 @@ class HttpAnalysisServer {
6262
/// Record that the given line was printed out by the analysis server.
6363
void recordPrint(String line) {
6464
_printBuffer.add(line);
65-
if (_printBuffer.length > MAX_PRINT_BUFFER_LENGTH) {
66-
_printBuffer.removeRange(
67-
0,
68-
_printBuffer.length - MAX_PRINT_BUFFER_LENGTH,
69-
);
65+
if (_printBuffer.length > _maxPrintBufferLength) {
66+
_printBuffer.removeRange(0, _printBuffer.length - _maxPrintBufferLength);
7067
}
7168
}
7269

pkg/analysis_server/lib/src/services/completion/dart/utilities.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart'
2020
show Element, ElementKind;
2121

2222
/// The name of the type `dynamic`;
23-
const DYNAMIC = 'dynamic';
23+
const _dynamicName = 'dynamic';
2424

2525
/// Sort by relevance first, highest to lowest, and then by the completion
2626
/// alphabetically.
@@ -249,7 +249,7 @@ String? nameForType(SimpleIdentifier identifier, TypeAnnotation? declaredType) {
249249
DartType type;
250250
var element = identifier.element;
251251
if (element == null) {
252-
return DYNAMIC;
252+
return _dynamicName;
253253
} else if (element is FunctionTypedElement) {
254254
if (element is PropertyAccessorElement && element is SetterElement) {
255255
return null;
@@ -273,7 +273,7 @@ String? nameForType(SimpleIdentifier identifier, TypeAnnotation? declaredType) {
273273
if (declaredType is NamedType) {
274274
return declaredType.qualifiedName;
275275
}
276-
return DYNAMIC;
276+
return _dynamicName;
277277
}
278278
return type.getDisplayString();
279279
}

pkg/analysis_server/lib/src/services/correction/fix/pubspec/fix_kind.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
88
abstract final class PubspecFixKind {
99
static const addName = FixKind(
1010
'pubspec.fix.add.name',
11-
PubspecFixKindPriority.DEFAULT,
11+
PubspecFixKindPriority._default,
1212
"Add 'name' key",
1313
);
1414
static const addDependency = FixKind(
1515
'pubspec.fix.add.dependency',
16-
PubspecFixKindPriority.DEFAULT,
16+
PubspecFixKindPriority._default,
1717
'Update pubspec with the missing dependencies',
1818
);
1919
}
2020

2121
abstract final class PubspecFixKindPriority {
22-
static const int DEFAULT = 50;
22+
static const int _default = 50;
2323
}

pkg/analysis_server/lib/src/services/dart_tooling_daemon/dtd_services.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ import 'package:json_rpc_2/json_rpc_2.dart';
2121
/// The state of the connection to DTD.
2222
enum DtdConnectionState {
2323
/// A connection is being made or initialization is in progress.
24-
Connecting,
24+
connecting,
2525

2626
/// The connection is available to use.
27-
Connected,
27+
connected,
2828

2929
/// The connection is closing or closed.
30-
Disconnected,
30+
disconnected,
3131

3232
/// A fatal error occurred setting up the connection to DTD.
33-
Error,
33+
error,
3434
}
3535

3636
/// A connection to DTD that exposes some analysis services (such as a subset
@@ -49,7 +49,7 @@ class DtdServices {
4949
/// A raw connection to the Dart Tooling Daemon.
5050
DartToolingDaemon? _dtd;
5151

52-
DtdConnectionState _state = DtdConnectionState.Connecting;
52+
DtdConnectionState _state = DtdConnectionState.connecting;
5353

5454
/// Whether to register experimental LSP handlers over DTD.
5555
final bool registerExperimentalHandlers;
@@ -110,7 +110,7 @@ class DtdServices {
110110
}
111111

112112
/// Closes the connection to DTD and cleans up.
113-
void _close([DtdConnectionState state = DtdConnectionState.Disconnected]) {
113+
void _close([DtdConnectionState state = DtdConnectionState.disconnected]) {
114114
_state = state;
115115

116116
// This code may have been closed because the connection closed, or it might
@@ -206,7 +206,7 @@ class DtdServices {
206206
['Failed to connect to/initialize DTD:', error, ?stack].join('\n'),
207207
);
208208

209-
_close(DtdConnectionState.Error);
209+
_close(DtdConnectionState.error);
210210
}
211211

212212
/// Registers any request handlers provided by the server handler [handler]

pkg/analysis_server/lib/src/services/refactoring/legacy/extract_local.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import 'package:analyzer/src/generated/java_core.dart';
2727
import 'package:analyzer/src/utilities/dot_shorthands.dart';
2828
import 'package:analyzer_plugin/utilities/range_factory.dart';
2929

30-
const String _TOKEN_SEPARATOR = '\uFFFF';
30+
const String _tokenSeparator = '\uFFFF';
3131

3232
/// [ExtractLocalRefactoring] implementation.
3333
class ExtractLocalRefactoringImpl extends RefactoringImpl
@@ -440,8 +440,8 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
440440
// done
441441
return tokenString;
442442
})
443-
.join(_TOKEN_SEPARATOR);
444-
return result + _TOKEN_SEPARATOR;
443+
.join(_tokenSeparator);
444+
return result + _tokenSeparator;
445445
}
446446

447447
/// Return the [AstNode] to defined the variable before.

pkg/analysis_server/lib/src/services/refactoring/legacy/naming_conventions.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ RefactoringStatus _validateIdentifier(
179179
// invalid characters
180180
for (var i = 0; i < length; i++) {
181181
var currentChar = identifier.codeUnitAt(i);
182-
if (!currentChar.isLetterOrDigitOrUnderscore &&
183-
currentChar != CHAR_DOLLAR) {
182+
if (!currentChar.isLetterOrDigitOrUnderscore && currentChar != charDollar) {
184183
var charStr = String.fromCharCode(currentChar);
185184
var message = "$desc must not contain '$charStr'.";
186185
return RefactoringStatus.fatal(message);
@@ -189,8 +188,8 @@ RefactoringStatus _validateIdentifier(
189188
// first character
190189
var currentChar = identifier.codeUnitAt(0);
191190
if (!currentChar.isLetter &&
192-
currentChar != CHAR_UNDERSCORE &&
193-
currentChar != CHAR_DOLLAR) {
191+
currentChar != charUnderscore &&
192+
currentChar != charDollar) {
194193
var message = '$desc must begin with $beginDesc.';
195194
return RefactoringStatus.fatal(message);
196195
}
@@ -216,11 +215,11 @@ RefactoringStatus _validateLowerCamelCase(
216215
return status;
217216
}
218217
// is private, OK
219-
if (identifier.codeUnitAt(0) == CHAR_UNDERSCORE) {
218+
if (identifier.codeUnitAt(0) == charUnderscore) {
220219
return RefactoringStatus();
221220
}
222221
// leading $, OK
223-
if (identifier.codeUnitAt(0) == CHAR_DOLLAR) {
222+
if (identifier.codeUnitAt(0) == charDollar) {
224223
return RefactoringStatus();
225224
}
226225
// does not start with lower case
@@ -245,11 +244,11 @@ RefactoringStatus _validateUpperCamelCase(String identifier, String desc) {
245244
return status;
246245
}
247246
// is private, OK
248-
if (identifier.codeUnitAt(0) == CHAR_UNDERSCORE) {
247+
if (identifier.codeUnitAt(0) == charUnderscore) {
249248
return RefactoringStatus();
250249
}
251250
// leading $, OK
252-
if (identifier.codeUnitAt(0) == CHAR_DOLLAR) {
251+
if (identifier.codeUnitAt(0) == charDollar) {
253252
return RefactoringStatus();
254253
}
255254
// does not start with upper case

pkg/analysis_server/lib/src/services/refactoring/legacy/refactoring_manager.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool test_simulateRefactoringReset_afterInitialConditions = false;
4040
/// Once new set of parameters is received, the previous [Refactoring] instance
4141
/// is invalidated and a new one is created and initialized.
4242
class RefactoringManager {
43-
static const List<RefactoringProblem> EMPTY_PROBLEM_LIST =
43+
static const List<RefactoringProblem> _emptyProblemList =
4444
<RefactoringProblem>[];
4545

4646
final LegacyAnalysisServer server;
@@ -104,9 +104,9 @@ class RefactoringManager {
104104
// prepare for processing the request
105105
this.request = request;
106106
var result = this.result = EditGetRefactoringResult(
107-
EMPTY_PROBLEM_LIST,
108-
EMPTY_PROBLEM_LIST,
109-
EMPTY_PROBLEM_LIST,
107+
_emptyProblemList,
108+
_emptyProblemList,
109+
_emptyProblemList,
110110
);
111111

112112
// process the request

0 commit comments

Comments
 (0)