Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b33c7891
Unverified
Commit
b33c7891
authored
Apr 22, 2021
by
Greg Spencer
Committed by
GitHub
Apr 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the sample analyzer to analyze dart:ui and make the analyzer null safe (#80742)
parent
a84ac2ec
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
215 additions
and
71 deletions
+215
-71
analyze_sample_code.dart
dev/bots/analyze_sample_code.dart
+141
-57
ui.dart
dev/bots/test/analyze-sample-code-test-dart-ui/ui.dart
+33
-0
analyze_sample_code_test.dart
dev/bots/test/analyze_sample_code_test.dart
+38
-13
snippets.dart
dev/snippets/lib/snippets.dart
+3
-1
No files found.
dev/bots/analyze_sample_code.dart
View file @
b33c7891
This diff is collapsed.
Click to expand it.
dev/bots/test/analyze-sample-code-test-dart-ui/ui.dart
0 → 100644
View file @
b33c7891
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.12
// This is a dummy dart:ui package for the sample code analyzer tests to use.
library
dart
.
ui
;
/// Annotation used by Flutter's Dart compiler to indicate that an
/// [Object.toString] override should not be replaced with a supercall.
///
/// {@tool sample}
/// A sample if using keepToString to prevent replacement by a supercall.
///
/// ```dart
/// class MyStringBuffer {
/// StringBuffer _buffer = StringBuffer();
///
/// @keepToString
/// @override
/// String toString() {
/// return _buffer.toString();
/// }
/// }
/// ```
/// {@end-tool}
const
_KeepToString
keepToString
=
_KeepToString
();
class
_KeepToString
{
const
_KeepToString
();
}
\ No newline at end of file
dev/bots/test/analyze_sample_code_test.dart
View file @
b33c7891
...
@@ -7,35 +7,42 @@ import 'dart:io';
...
@@ -7,35 +7,42 @@ import 'dart:io';
import
'common.dart'
;
import
'common.dart'
;
void
main
(
)
{
void
main
(
)
{
test
(
'analyze_sample_code'
,
()
{
// These tests don't run on Windows because the sample analyzer doesn't
// support Windows as a platform, since it is only run on Linux in the
// continuous integration tests.
if
(
Platform
.
isWindows
)
{
return
;
}
test
(
'analyze_sample_code smoke test'
,
()
{
final
ProcessResult
process
=
Process
.
runSync
(
final
ProcessResult
process
=
Process
.
runSync
(
'../../bin/cache/dart-sdk/bin/dart'
,
'../../bin/cache/dart-sdk/bin/dart'
,
<
String
>[
'analyze_sample_code.dart'
,
'test/analyze-sample-code-test-input'
],
<
String
>[
'analyze_sample_code.dart'
,
'
--no-include-dart-ui'
,
'
test/analyze-sample-code-test-input'
],
);
);
final
List
<
String
>
stdoutLines
=
process
.
stdout
.
toString
().
split
(
'
\n
'
);
final
List
<
String
>
stdoutLines
=
process
.
stdout
.
toString
().
split
(
'
\n
'
);
final
List
<
String
>
stderrLines
=
process
.
stderr
.
toString
().
split
(
'
\n
'
)
final
List
<
String
>
stderrLines
=
process
.
stderr
.
toString
().
split
(
'
\n
'
)
..
removeWhere
((
String
line
)
=>
line
.
startsWith
(
'Analyzer output:'
)
||
line
.
startsWith
(
'Building flutter tool...'
));
..
removeWhere
((
String
line
)
=>
line
.
startsWith
(
'Analyzer output:'
)
||
line
.
startsWith
(
'Building flutter tool...'
));
expect
(
process
.
exitCode
,
isNot
(
equals
(
0
)));
expect
(
process
.
exitCode
,
isNot
(
equals
(
0
)));
expect
(
stderrLines
,
<
String
>[
expect
(
stderrLines
,
<
String
>[
'In sample starting at known_broken_documentation.dart:117:bool? _visible = true;'
,
'In sample starting at
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:117:bool? _visible = true;'
,
'>>> info: Use late for private members with non-nullable type (use_late_for_private_fields_and_variables)'
,
'>>> info: Use late for private members with non-nullable type (use_late_for_private_fields_and_variables)'
,
'In sample starting at known_broken_documentation.dart:117: child: Text(title),'
,
'In sample starting at
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:117: child: Text(title),'
,
'>>> error: The final variable
\'
title
\'
can
\'
t be read because it is potentially unassigned at this point (read_potentially_unassigned_final)'
,
'>>> error: The final variable
\'
title
\'
can
\'
t be read because it is potentially unassigned at this point (read_potentially_unassigned_final)'
,
'known_broken_documentation.dart:30:9: new Opacity('
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:30:9: new Opacity('
,
'>>> info: Unnecessary new keyword (unnecessary_new)'
,
'>>> info: Unnecessary new keyword (unnecessary_new)'
,
'known_broken_documentation.dart:62:9: new Opacity('
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:62:9: new Opacity('
,
'>>> info: Unnecessary new keyword (unnecessary_new)'
,
'>>> info: Unnecessary new keyword (unnecessary_new)'
,
'known_broken_documentation.dart:95:9: const text0 = Text(
\'
Poor wandering ones!
\'
);'
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:95:9: const text0 = Text(
\'
Poor wandering ones!
\'
);'
,
'>>> info: Specify type annotations (always_specify_types)'
,
'>>> info: Specify type annotations (always_specify_types)'
,
'known_broken_documentation.dart:103:9: const text1 = _Text(
\'
Poor wandering ones!
\'
);'
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:103:9: const text1 = _Text(
\'
Poor wandering ones!
\'
);'
,
'>>> info: Specify type annotations (always_specify_types)'
,
'>>> info: Specify type annotations (always_specify_types)'
,
'known_broken_documentation.dart:111:9: final String? bar =
\'
Hello
\'
;'
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:111:9: final String? bar =
\'
Hello
\'
;'
,
'>>> info: Prefer const over final for declarations (prefer_const_declarations)'
,
'>>> info: Prefer const over final for declarations (prefer_const_declarations)'
,
'known_broken_documentation.dart:111:23: final String? bar =
\'
Hello
\'
;'
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:111:23: final String? bar =
\'
Hello
\'
;'
,
'>>> info: Use a non-nullable type for a final variable initialized with a non-nullable value (unnecessary_nullable_for_final_variable_declarations)'
,
'>>> info: Use a non-nullable type for a final variable initialized with a non-nullable value (unnecessary_nullable_for_final_variable_declarations)'
,
'known_broken_documentation.dart:112:9: final int foo = null;'
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:112:9: final int foo = null;'
,
'>>> info: Prefer const over final for declarations (prefer_const_declarations)'
,
'>>> info: Prefer const over final for declarations (prefer_const_declarations)'
,
'known_broken_documentation.dart:112:25: final int foo = null;'
,
'
dev/bots/test/analyze-sample-code-test-input/
known_broken_documentation.dart:112:25: final int foo = null;'
,
'>>> error: A value of type
\'
Null
\'
can
\'
t be assigned to a variable of type
\'
int
\'
(invalid_assignment)'
,
'>>> error: A value of type
\'
Null
\'
can
\'
t be assigned to a variable of type
\'
int
\'
(invalid_assignment)'
,
''
,
''
,
'Found 2 sample code errors.'
,
'Found 2 sample code errors.'
,
...
@@ -46,5 +53,23 @@ void main() {
...
@@ -46,5 +53,23 @@ void main() {
'Starting analysis of code samples.'
,
'Starting analysis of code samples.'
,
''
,
''
,
]);
]);
},
skip:
Platform
.
isWindows
);
});
test
(
'Analyzes dart:ui code'
,
()
{
final
ProcessResult
process
=
Process
.
runSync
(
'../../bin/cache/dart-sdk/bin/dart'
,
<
String
>[
'analyze_sample_code.dart'
,
'--dart-ui-location'
,
'test/analyze-sample-code-test-dart-ui'
,
'test/analyze-sample-code-test-input'
,
],
);
final
List
<
String
>
stdoutLines
=
process
.
stdout
.
toString
().
split
(
'
\n
'
);
expect
(
process
.
exitCode
,
isNot
(
equals
(
0
)));
expect
(
stdoutLines
,
equals
(<
String
>[
// There is one sample code section in the test's dummy dart:ui code.
'Found 8 snippet code blocks, 1 sample code sections, and 2 dartpad sections.'
,
''
,
]));
});
}
}
dev/snippets/lib/snippets.dart
View file @
b33c7891
...
@@ -179,7 +179,9 @@ class SnippetGenerator {
...
@@ -179,7 +179,9 @@ class SnippetGenerator {
description
.
add
(
line
);
description
.
add
(
line
);
}
else
{
}
else
{
assert
(
language
!=
null
);
assert
(
language
!=
null
);
components
.
last
.
contents
.
add
(
line
);
if
(
components
.
isNotEmpty
)
{
components
.
last
.
contents
.
add
(
line
);
}
}
}
}
}
return
<
_ComponentTuple
>[
return
<
_ComponentTuple
>[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment