Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ linter:
- avoid_bool_literals_in_conditional_expressions
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
- avoid_classes_with_only_static_members
# - avoid_classes_with_only_static_members # we do this commonly
- avoid_double_and_int_checks
- avoid_dynamic_calls
- avoid_empty_else
Expand Down
6 changes: 1 addition & 5 deletions lib/ui/isolate_name_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ part of dart.ui;
/// communication or multiple-message communication is necessary, it is
/// recommended to establish a separate communication channel in that first
/// message (e.g. by passing a dedicated [SendPort]).
class IsolateNameServer {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
IsolateNameServer._();

abstract final class IsolateNameServer {
/// Looks up the [SendPort] associated with a given name.
///
/// Returns null if the name does not exist. To register the name in the first
Expand Down
6 changes: 1 addition & 5 deletions lib/ui/natives.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ part of dart.ui;
// ignore_for_file: avoid_classes_with_only_static_members

/// Helper functions for Dart Plugin Registrants.
class DartPluginRegistrant {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
DartPluginRegistrant._();

abstract final class DartPluginRegistrant {
static bool _wasInitialized = false;

/// Makes sure the that the Dart Plugin Registrant has been called for this
Expand Down
6 changes: 1 addition & 5 deletions lib/ui/plugins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ class CallbackHandle {
///
/// * [IsolateNameServer], which provides utilities for dealing with
/// [Isolate]s.
class PluginUtilities {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
PluginUtilities._();

abstract final class PluginUtilities {
static final Map<Function, CallbackHandle?> _forwardCache =
<Function, CallbackHandle?>{};
static final Map<CallbackHandle, Function?> _backwardCache =
Expand Down
6 changes: 1 addition & 5 deletions lib/web_ui/lib/src/engine/html/path/path_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ class SPathVerb {
static const int kClose = 5; // 0 points
}

abstract class SPath {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
SPath._();

abstract final class SPath {
static const int kMoveVerb = SPathVerb.kMove;
static const int kLineVerb = SPathVerb.kLine;
static const int kQuadVerb = SPathVerb.kQuad;
Expand Down
12 changes: 2 additions & 10 deletions lib/web_ui/lib/src/engine/html/shaders/vertex_shaders.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import '../../browser_detection.dart';
import 'shader_builder.dart';

/// Provides common shaders used for gradients and drawVertices APIs.
abstract class VertexShaders {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
VertexShaders._();

abstract final class VertexShaders {
static final Uint16List vertexIndicesForRect =
Uint16List.fromList(<int>[0, 1, 2, 2, 3, 0]);

Expand Down Expand Up @@ -73,11 +69,7 @@ abstract class VertexShaders {
}
}

abstract class FragmentShaders {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
FragmentShaders._();

abstract final class FragmentShaders {
static String writeTextureFragmentShader(
bool isWebGl2, ui.TileMode? tileModeX, ui.TileMode? tileModeY) {
final ShaderBuilder builder = ShaderBuilder.fragment(webGLVersion);
Expand Down
6 changes: 1 addition & 5 deletions lib/web_ui/lib/src/engine/text/word_breaker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ class _FindBreakDirection {
}

/// [WordBreaker] exposes static methods to identify word boundaries.
abstract class WordBreaker {
// This class is not meant to be instantiated or extended; this constructor
// prevents instantiation and extension.
WordBreaker._();

abstract final class WordBreaker {
/// It starts from [index] and tries to find the next word boundary in [text].
static int nextBreakIndex(String text, int index) =>
_findBreakIndex(_FindBreakDirection.forward, text, index);
Expand Down
12 changes: 2 additions & 10 deletions lib/web_ui/lib/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ class CallbackHandle {
}

// TODO(dit): see https://github.com/flutter/flutter/issues/33615.
class PluginUtilities {
// This class is only a namespace, and should not be instantiated or
// extended directly.
factory PluginUtilities._() => throw UnsupportedError('Namespace');

abstract final class PluginUtilities {
static CallbackHandle? getCallbackHandle(Function callback) {
throw UnimplementedError();
}
Expand All @@ -187,11 +183,7 @@ class PluginUtilities {
}
}

class IsolateNameServer {
// This class is only a namespace, and should not be instantiated or
// extended directly.
factory IsolateNameServer._() => throw UnsupportedError('Namespace');

abstract final class IsolateNameServer {
static dynamic lookupPortByName(String name) {
throw UnimplementedError();
}
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies:
path: ../../third_party/web_test_fonts

dev_dependencies:
analyzer: 5.2.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is being removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency is unused.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the IDE? Which analyzer does it use when I open the lib/web_ui folder? For some reason, I always assumed the IDE used the analyzer dependency version, but I'm not 100% sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses the analyzer of the dart SDK configured in the IDE. This dependency is used for ‘package:analyzer/…’ imports of which there don’t seem to be any within web_ui.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying!

archive: 3.1.2
args: any
async: any
Expand Down
6 changes: 1 addition & 5 deletions tools/api_check/lib/apicheck.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:pub_semver/pub_semver.dart';

/// Returns all indexed fields in [className].
///
Expand Down Expand Up @@ -163,10 +162,7 @@ List<String> _getBlockStartingWith({
/// Apply a visitor to all compilation units in the dart:ui library.
void visitUIUnits(String flutterRoot, AstVisitor<void> visitor) {
final String uiRoot = '$flutterRoot/lib/ui';
final FeatureSet analyzerFeatures = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version.parse('2.17.0'),
flags: <String>['non-nullable'],
);
final FeatureSet analyzerFeatures = FeatureSet.latestLanguageVersion();
final ParseStringResult uiResult = parseFile(path: '$uiRoot/ui.dart', featureSet: analyzerFeatures);
for (final PartDirective part in uiResult.unit.directives.whereType<PartDirective>()) {
final String partPath = part.uri.stringValue!;
Expand Down
3 changes: 2 additions & 1 deletion web_sdk/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ dependencies:
path: 1.8.2

dev_dependencies:
analyzer: 4.3.1
analyzer: 5.7.1
test: 1.22.1
pub_semver: 2.1.3
52 changes: 28 additions & 24 deletions web_sdk/test/api_conform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:pub_semver/pub_semver.dart';

// Ignore members defined on Object.
const Set<String> _kObjectMembers = <String>{
Expand All @@ -19,7 +20,10 @@ const Set<String> _kObjectMembers = <String>{
};

CompilationUnit _parseAndCheckDart(String path) {
final FeatureSet analyzerFeatures = FeatureSet.latestLanguageVersion();
final FeatureSet analyzerFeatures = FeatureSet.fromEnableFlags2(
flags: <String>['class-modifiers', 'sealed-class', 'records', 'patterns'],
sdkLanguageVersion: Version.parse('3.0.0-0'),
);
if (!analyzerFeatures.isEnabled(Feature.non_nullable)) {
throw Exception('non-nullable feature is disabled.');
}
Expand Down Expand Up @@ -120,20 +124,20 @@ void main() {
uiConstructor.parameters.parameters[i];
final FormalParameter webParam =
webConstructor.parameters.parameters[i];
if (webParam.identifier!.name != uiParam.identifier!.name) {
if (webParam.name!.lexeme != uiParam.name!.lexeme) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$name parameter $i'
' ${uiParam.identifier!.name} has a different name in lib/web_ui/ui.dart.');
' ${uiParam.name!.lexeme} has a different name in lib/web_ui/ui.dart.');
}
if (uiParam.isPositional != webParam.isPositional) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$name parameter $i'
'${uiParam.identifier!.name} is positional, but not in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme} is positional, but not in lib/web_ui/ui.dart.');
}
if (uiParam.isNamed != webParam.isNamed) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$name parameter $i'
'${uiParam.identifier!.name} is named, but not in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme} is named, but not in lib/web_ui/ui.dart.');
}
}
}
Expand Down Expand Up @@ -170,20 +174,20 @@ void main() {
i++) {
final FormalParameter uiParam = uiMethod.parameters!.parameters[i];
final FormalParameter webParam = webMethod.parameters!.parameters[i];
if (webParam.identifier!.name != uiParam.identifier!.name) {
if (webParam.name!.lexeme != uiParam.name!.lexeme) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i'
' ${uiParam.identifier!.name} has a different name in lib/web_ui/ui.dart.');
' ${uiParam.name!.lexeme} has a different name in lib/web_ui/ui.dart.');
}
if (uiParam.isPositional != webParam.isPositional) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i'
'${uiParam.identifier!.name} is positional, but not in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme} is positional, but not in lib/web_ui/ui.dart.');
}
if (uiParam.isNamed != webParam.isNamed) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i'
'${uiParam.identifier!.name} is named, but not in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme} is named, but not in lib/web_ui/ui.dart.');
}
// check nullability
if (uiParam is SimpleFormalParameter &&
Expand All @@ -193,7 +197,7 @@ void main() {
if (isUiNullable != isWebNullable) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i '
'${uiParam.identifier} has a different nullability than in lib/web_ui/ui.dart.');
'${uiParam.name} has a different nullability than in lib/web_ui/ui.dart.');
}
}
}
Expand Down Expand Up @@ -247,36 +251,36 @@ void main() {
final SimpleFormalParameter webParam =
(webTypeDef.type as GenericFunctionType).parameters.parameters[i]
as SimpleFormalParameter;
if (webParam.identifier == null) {
if (webParam.name == null) {
failed = true;
print('Warning: lib/web_ui/ui.dart $typeDefName parameter $i should have name.');
}
if (uiParam.identifier == null) {
if (uiParam.name == null) {
failed = true;
print('Warning: lib/ui/ui.dart $typeDefName parameter $i should have name.');
}
if (webParam.identifier?.name != uiParam.identifier?.name) {
if (webParam.name?.lexeme != uiParam.name?.lexeme) {
failed = true;
print('Warning: lib/ui/ui.dart $typeDefName parameter $i '
'${uiParam.identifier!.name} has a different name in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme} has a different name in lib/web_ui/ui.dart.');
}
if (uiParam.isPositional != webParam.isPositional) {
failed = true;
print('Warning: lib/ui/ui.dart $typeDefName parameter $i '
'${uiParam.identifier!.name} is positional, but not in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme} is positional, but not in lib/web_ui/ui.dart.');
}
if (uiParam.isNamed != webParam.isNamed) {
failed = true;
print('Warning: lib/ui/ui.dart $typeDefName parameter $i '
'${uiParam.identifier!.name} is named, but not in lib/web_ui/ui.dart.');
'${uiParam.name!.lexeme}} is named, but not in lib/web_ui/ui.dart.');
}

final bool isUiNullable = uiParam.type?.question != null;
final bool isWebNullable = webParam.type?.question != null;
if (isUiNullable != isWebNullable) {
failed = true;
print('Warning: lib/ui/ui.dart $typeDefName parameter $i '
'${uiParam.identifier} has a different nullability than in lib/web_ui/ui.dart.');
'${uiParam.name} has a different nullability than in lib/web_ui/ui.dart.');
}
}

Expand Down Expand Up @@ -315,10 +319,10 @@ void _collectPublicClasses(CompilationUnit unit,
continue;
}
final ClassDeclaration classDeclaration = member;
if (classDeclaration.name.name.startsWith('_')) {
if (classDeclaration.name.lexeme.startsWith('_')) {
continue;
}
destination[classDeclaration.name.name] = classDeclaration;
destination[classDeclaration.name.lexeme] = classDeclaration;
}
}
}
Expand All @@ -329,7 +333,7 @@ void _collectPublicConstructors(ClassDeclaration classDeclaration,
if (member is! ConstructorDeclaration) {
continue;
}
final String? methodName = member.name?.name;
final String? methodName = member.name?.lexeme;
if (methodName == null) {
destination['Unnamed Constructor'] = member;
continue;
Expand All @@ -347,10 +351,10 @@ void _collectPublicMethods(ClassDeclaration classDeclaration,
if (member is! MethodDeclaration) {
continue;
}
if (member.name.name.startsWith('_')) {
if (member.name.lexeme.startsWith('_')) {
continue;
}
destination[member.name.name] = member;
destination[member.name.lexeme] = member;
}
}

Expand All @@ -369,10 +373,10 @@ void _collectPublicTypeDefs(CompilationUnit unit,
continue;
}
final GenericTypeAlias typeDeclaration = member;
if (typeDeclaration.name.name.startsWith('_')) {
if (typeDeclaration.name.lexeme.startsWith('_')) {
continue;
}
destination[typeDeclaration.name.name] = typeDeclaration;
destination[typeDeclaration.name.lexeme] = typeDeclaration;
}
}
}
2 changes: 1 addition & 1 deletion web_sdk/web_test_utils/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environment:
sdk: '>=3.0.0-0 <4.0.0'

dependencies:
collection: 1.15.0
collection: 1.17.0
crypto: 3.0.1
image: 3.0.1
js: 0.6.4
Expand Down