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

Unified Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 1427513003: Compute documentation offsets for library, import, and export directive elements (issue 24756) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/task/dart.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/context/context_test.dart
diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
index c8832031da83cc550c6c7f9b9bedfe84735f7de7..62b499015ed77f9d18a7a005dc18ba80aac36394 100644
--- a/pkg/analyzer/test/src/context/context_test.dart
+++ b/pkg/analyzer/test/src/context/context_test.dart
@@ -397,7 +397,7 @@ import 'libB.dart';''';
});
}
- void test_computeDocumentationComment_block() {
+ void test_computeDocumentationComment_class_block() {
String comment = "/** Comment */";
Source source = addSource(
"/test.dart",
@@ -411,7 +411,7 @@ class A {}""");
expect(context.computeDocumentationComment(classElement), comment);
}
- void test_computeDocumentationComment_none() {
+ void test_computeDocumentationComment_class_none() {
Source source = addSource("/test.dart", "class A {}");
LibraryElement libraryElement = context.computeLibraryElement(source);
expect(libraryElement, isNotNull);
@@ -420,11 +420,7 @@ class A {}""");
expect(context.computeDocumentationComment(classElement), isNull);
}
- void test_computeDocumentationComment_null() {
- expect(context.computeDocumentationComment(null), isNull);
- }
-
- void test_computeDocumentationComment_singleLine_multiple_EOL_n() {
+ void test_computeDocumentationComment_class_singleLine_multiple_EOL_n() {
String comment = "/// line 1\n/// line 2\n/// line 3\n";
Source source = addSource("/test.dart", "${comment}class A {}");
LibraryElement libraryElement = context.computeLibraryElement(source);
@@ -435,7 +431,7 @@ class A {}""");
expect(actual, "/// line 1\n/// line 2\n/// line 3");
}
- void test_computeDocumentationComment_singleLine_multiple_EOL_rn() {
+ void test_computeDocumentationComment_class_singleLine_multiple_EOL_rn() {
String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n";
Source source = addSource("/test.dart", "${comment}class A {}");
LibraryElement libraryElement = context.computeLibraryElement(source);
@@ -446,6 +442,51 @@ class A {}""");
expect(actual, "/// line 1\n/// line 2\n/// line 3");
}
+ void test_computeDocumentationComment_exportDirective_block() {
+ String comment = '/** Comment */';
+ Source source = addSource(
+ "/test.dart",
+ '''
+$comment
+export 'dart:async';
+''');
+ LibraryElement libraryElement = context.computeLibraryElement(source);
+ expect(libraryElement, isNotNull);
+ ExportElement exportElement = libraryElement.exports[0];
+ expect(context.computeDocumentationComment(exportElement), comment);
+ }
+
+ void test_computeDocumentationComment_importDirective_block() {
+ String comment = '/** Comment */';
+ Source source = addSource(
+ "/test.dart",
+ '''
+$comment
+import 'dart:async';
+''');
+ LibraryElement libraryElement = context.computeLibraryElement(source);
+ expect(libraryElement, isNotNull);
+ ImportElement importElement = libraryElement.imports[0];
+ expect(context.computeDocumentationComment(importElement), comment);
+ }
+
+ void test_computeDocumentationComment_libraryDirective_block() {
+ String comment = '/** Comment */';
+ Source source = addSource(
+ "/test.dart",
+ '''
+$comment
+library lib;
+''');
+ LibraryElement libraryElement = context.computeLibraryElement(source);
+ expect(libraryElement, isNotNull);
+ expect(context.computeDocumentationComment(libraryElement), comment);
+ }
+
+ void test_computeDocumentationComment_null() {
+ expect(context.computeDocumentationComment(null), isNull);
+ }
+
void test_computeErrors_dart_none() {
Source source = addSource("/lib.dart", "library lib;");
List<AnalysisError> errors = context.computeErrors(source);
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698