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 a90342c400bfe5ca9fe534ad0f3543d00ce8f788..7ddbdba08cbf21218f5920d69e8851c6b20eae82 100644 |
--- a/pkg/analyzer/test/src/summary/summary_common.dart |
+++ b/pkg/analyzer/test/src/summary/summary_common.dart |
@@ -1076,6 +1076,13 @@ class E {} |
expect(cls.hasNoSupertype, isFalse); |
} |
+ test_class_codeRange() { |
+ UnlinkedClass cls = serializeClassText(' class C {}'); |
+ expect(cls.hasCodeRange, true); |
Paul Berry
2016/03/04 16:36:07
When would `hasCodeRange` be false? We need tests
scheglov
2016/03/04 17:15:19
In production - never.
It tests - for every manual
|
+ expect(cls.codeOffset, 1); |
+ expect(cls.codeLength, 10); |
+ } |
+ |
test_class_concrete() { |
UnlinkedClass cls = serializeClassText('class C {}'); |
expect(cls.isAbstract, false); |
@@ -4010,6 +4017,9 @@ typedef F(); |
expect(e.values, hasLength(1)); |
expect(e.values[0].name, 'v1'); |
expect(e.values[0].nameOffset, text.indexOf('v1')); |
+ expect(e.hasCodeRange, true); |
+ expect(e.codeOffset, 0); |
+ expect(e.codeLength, 13); |
expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
ReferenceKind.classOrEnum); |
@@ -4410,6 +4420,9 @@ get g { // 1 |
expect(executable.isExternal, isFalse); |
expect(executable.visibleOffset, 0); |
expect(executable.visibleLength, 0); |
+ expect(executable.hasCodeRange, true); |
+ expect(executable.codeOffset, 10); |
+ expect(executable.codeLength, 6); |
} |
test_executable_member_function_explicit_return() { |
@@ -4433,6 +4446,9 @@ get g { // 1 |
expect(executable.kind, UnlinkedExecutableKind.getter); |
expect(executable.returnType, isNotNull); |
expect(executable.isExternal, isFalse); |
+ expect(executable.hasCodeRange, true); |
+ expect(executable.codeOffset, 10); |
+ expect(executable.codeLength, 15); |
expect(findVariable('f', variables: cls.fields), isNull); |
expect(findExecutable('f=', executables: cls.executables), isNull); |
} |
@@ -4451,6 +4467,9 @@ get g { // 1 |
expect(executable.kind, UnlinkedExecutableKind.setter); |
expect(executable.returnType, isNotNull); |
expect(executable.isExternal, isFalse); |
+ expect(executable.hasCodeRange, true); |
+ expect(executable.codeOffset, 10); |
+ expect(executable.codeLength, 20); |
expect(findVariable('f', variables: cls.fields), isNull); |
expect(findExecutable('f', executables: cls.executables), isNull); |
} |
@@ -4572,6 +4591,14 @@ get g { // 1 |
expect(executable.name, '<='); |
} |
+ test_executable_param_codeRange() { |
+ UnlinkedExecutable executable = serializeExecutableText('f(int x) {}'); |
+ UnlinkedParam parameter = executable.parameters[0]; |
+ expect(parameter.hasCodeRange, true); |
+ expect(parameter.codeOffset, 2); |
+ expect(parameter.codeLength, 5); |
+ } |
+ |
test_executable_param_function_typed() { |
if (!checkAstDerivedData) { |
// TODO(paulberry): this test fails when building the summary from the |
@@ -6794,6 +6821,15 @@ bool f() => true; |
checkDynamicTypeRef(serializeTypeText('dynamic')); |
} |
+ test_type_param_codeRange() { |
+ UnlinkedClass cls = |
+ serializeClassText('class A {} class C<T extends A> {}'); |
+ var e = cls.typeParameters[0]; |
+ expect(e.hasCodeRange, true); |
+ expect(e.codeOffset, 19); |
+ expect(e.codeLength, 11); |
+ } |
+ |
test_type_param_not_shadowed_by_constructor() { |
UnlinkedClass cls = |
serializeClassText('class C<D> { D x; C.D(); } class D {}'); |
@@ -7052,6 +7088,13 @@ b.C c4;'''); |
checkUnresolvedTypeRef(typeRef, null, 'Foo'); |
} |
+ test_typedef_codeRange() { |
+ UnlinkedTypedef type = serializeTypedefText('typedef F();'); |
+ expect(type.hasCodeRange, true); |
+ expect(type.codeOffset, 0); |
+ expect(type.codeLength, 12); |
+ } |
+ |
test_typedef_documented() { |
String text = ''' |
// Extra comment so doc comment offset != 0 |
@@ -7136,6 +7179,14 @@ typedef F();'''; |
expect(type.typeParameters[1].name, 'U'); |
} |
+ test_unit_codeRange() { |
+ serializeLibraryText(' int a = 1; '); |
+ UnlinkedUnit unit = unlinkedUnits[0]; |
+ expect(unit.hasCodeRange, true); |
+ expect(unit.codeOffset, 0); |
+ expect(unit.codeLength, 14); |
+ } |
+ |
test_unresolved_reference_in_multiple_parts() { |
addNamedSource('/a.dart', 'part of foo; int x; Unresolved y;'); |
serializeLibraryText('library foo; part "a.dart"; Unresolved z;', |
@@ -7177,6 +7228,23 @@ typedef F();'''; |
expect(unlinkedUnits[0].publicNamespace.names[1].numTypeParameters, 0); |
} |
+ test_variable_codeRange() { |
+ serializeLibraryText(' int a = 1, b = 22;'); |
+ List<UnlinkedVariable> variables = unlinkedUnits[0].variables; |
+ { |
+ UnlinkedVariable variable = variables[0]; |
+ expect(variable.hasCodeRange, true); |
+ expect(variable.codeOffset, 1); |
+ expect(variable.codeLength, 18); |
+ } |
+ { |
+ UnlinkedVariable variable = variables[1]; |
+ expect(variable.hasCodeRange, true); |
+ expect(variable.codeOffset, 1); |
+ expect(variable.codeLength, 18); |
+ } |
+ } |
+ |
test_variable_const() { |
UnlinkedVariable variable = |
serializeVariableText('const int i = 0;', variableName: 'i'); |