Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: pkg/analyzer/test/src/summary/summary_common.dart

Issue 1689283002: Serialize parameters visible ranges. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Changes for review comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/summary_common.dart
diff --git a/pkg/analyzer/test/src/summary/summary_common.dart b/pkg/analyzer/test/src/summary/summary_common.dart
index a70821ea3f053e513b452cb6383beeac5b6478a9..867365488c56931607e529c575421215c377f735 100644
--- a/pkg/analyzer/test/src/summary/summary_common.dart
+++ b/pkg/analyzer/test/src/summary/summary_common.dart
@@ -5729,6 +5729,56 @@ class C {
expect(f.inferredReturnTypeSlot, 0);
}
+ test_parameter_visibleRange_abstractMethod() {
+ UnlinkedExecutable m = findExecutable('m',
+ executables:
+ serializeClassText('abstract class C { m(p); }').executables,
+ failIfAbsent: true);
+ _assertParameterZeroVisibleRange(m.parameters[0]);
+ }
+
+ test_parameter_visibleRange_function_blockBody() {
+ String text = r'''
+f(x) { // 1
+ f2(y) { // 2
+ } // 3
+} // 4
+''';
+ UnlinkedExecutable f = serializeExecutableText(text);
+ UnlinkedExecutable f2 = f.localFunctions[0];
+ _assertParameterVisible(text, f.parameters[0], '{ // 1', '} // 4');
+ _assertParameterVisible(text, f2.parameters[0], '{ // 2', '} // 3');
+ }
+
+ test_parameter_visibleRange_function_emptyBody() {
+ UnlinkedExecutable f = serializeExecutableText('external f(x);');
+ _assertParameterZeroVisibleRange(f.parameters[0]);
+ }
+
+ test_parameter_visibleRange_function_expressionBody() {
+ String text = r'''
+f(x) => 42;
+''';
+ UnlinkedExecutable f = serializeExecutableText(text);
+ _assertParameterVisible(text, f.parameters[0], '=>', ';');
+ }
+
+ test_parameter_visibleRange_inFunctionTypedParameter() {
+ String text = 'f(g(p)) {}';
+ UnlinkedExecutable f = serializeExecutableText(text);
+ UnlinkedParam g = f.parameters[0];
+ UnlinkedParam p = g.parameters[0];
+ expect(g.name, 'g');
+ expect(p.name, 'p');
+ _assertParameterVisible(text, g, '{', '}');
+ _assertParameterZeroVisibleRange(p);
+ }
+
+ test_parameter_visibleRange_typedef() {
+ UnlinkedTypedef type = serializeTypedefText('typedef F(x);');
+ _assertParameterZeroVisibleRange(type.parameters[0]);
+ }
+
test_part_declaration() {
addNamedSource('/a.dart', 'part of my.lib;');
String text = 'library my.lib; part "a.dart"; // <-part';
@@ -6524,6 +6574,20 @@ var v;''';
expect(f.visibleLength, expectedVisibleLength);
}
+ void _assertParameterVisible(
+ String code, UnlinkedParam p, String visibleBegin, String visibleEnd) {
+ int expectedVisibleOffset = code.indexOf(visibleBegin);
+ int expectedVisibleLength =
+ code.indexOf(visibleEnd) - expectedVisibleOffset + 1;
+ expect(p.visibleOffset, expectedVisibleOffset);
+ expect(p.visibleLength, expectedVisibleLength);
+ }
+
+ void _assertParameterZeroVisibleRange(UnlinkedParam p) {
+ expect(p.visibleOffset, isZero);
+ expect(p.visibleLength, isZero);
+ }
+
void _assertUnlinkedConst(UnlinkedConst constExpr,
{bool isInvalid: false,
List<UnlinkedConstOperation> operators: const <UnlinkedConstOperation>[],
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698