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

Unified Diff: pkg/analysis_server/test/computer/element_test.dart

Issue 559353003: Semantic highlighting for LABEL elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/analysis_server/test/analysis_notification_highlights_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/computer/element_test.dart
diff --git a/pkg/analysis_server/test/computer/element_test.dart b/pkg/analysis_server/test/computer/element_test.dart
index 2b26ffd65e85039e53e15d1bdeeabfdd6d068792..5539c22eb3134aa68ba4e04c9fb8e20da477ef43 100644
--- a/pkg/analysis_server/test/computer/element_test.dart
+++ b/pkg/analysis_server/test/computer/element_test.dart
@@ -5,14 +5,15 @@
library test.computer.element;
import 'package:analysis_server/src/protocol.dart';
-import '../abstract_context.dart';
-import '../reflective_tests.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart' as engine;
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.dart' as engine;
import 'package:unittest/unittest.dart';
+import '../abstract_context.dart';
+import '../reflective_tests.dart';
+
main() {
@@ -46,6 +47,9 @@ class ElementKindTest {
new ElementKind.fromEngine(engine.ElementKind.GETTER),
ElementKind.GETTER);
expect(
+ new ElementKind.fromEngine(engine.ElementKind.LABEL),
+ ElementKind.LABEL);
+ expect(
new ElementKind.fromEngine(engine.ElementKind.LIBRARY),
ElementKind.LIBRARY);
expect(
@@ -83,9 +87,7 @@ class ElementKindTest {
new ElementKind(ElementKind.CONSTRUCTOR.name),
ElementKind.CONSTRUCTOR);
expect(new ElementKind(ElementKind.FIELD.name), ElementKind.FIELD);
- expect(
- new ElementKind(ElementKind.FUNCTION.name),
- ElementKind.FUNCTION);
+ expect(new ElementKind(ElementKind.FUNCTION.name), ElementKind.FUNCTION);
expect(
new ElementKind(ElementKind.FUNCTION_TYPE_ALIAS.name),
ElementKind.FUNCTION_TYPE_ALIAS);
@@ -95,9 +97,7 @@ class ElementKindTest {
new ElementKind(ElementKind.LOCAL_VARIABLE.name),
ElementKind.LOCAL_VARIABLE);
expect(new ElementKind(ElementKind.METHOD.name), ElementKind.METHOD);
- expect(
- new ElementKind(ElementKind.PARAMETER.name),
- ElementKind.PARAMETER);
+ expect(new ElementKind(ElementKind.PARAMETER.name), ElementKind.PARAMETER);
expect(new ElementKind(ElementKind.SETTER.name), ElementKind.SETTER);
expect(
new ElementKind(ElementKind.TOP_LEVEL_VARIABLE.name),
@@ -119,7 +119,8 @@ class ElementKindTest {
void test_toString() {
expect(ElementKind.CLASS.toString(), 'ElementKind.CLASS');
- expect(ElementKind.COMPILATION_UNIT.toString(),
+ expect(
+ ElementKind.COMPILATION_UNIT.toString(),
'ElementKind.COMPILATION_UNIT');
}
}
@@ -229,6 +230,33 @@ class A {
expect(element.flags, 0);
}
+ void test_fromElement_LABEL() {
+ Source source = addSource('/test.dart', '''
+main() {
+myLabel:
+ while (true) {
+ break myLabel;
+ }
+}''');
+ CompilationUnit unit = resolveLibraryUnit(source);
+ engine.LabelElement engineElement = findElementInUnit(unit, 'myLabel');
+ // create notification Element
+ Element element = new Element.fromEngine(engineElement);
+ expect(element.kind, ElementKind.LABEL);
+ expect(element.name, 'myLabel');
+ {
+ Location location = element.location;
+ expect(location.file, '/test.dart');
+ expect(location.offset, 9);
+ expect(location.length, 'myLabel'.length);
+ expect(location.startLine, 2);
+ expect(location.startColumn, 1);
+ }
+ expect(element.parameters, isNull);
+ expect(element.returnType, isNull);
+ expect(element.flags, 0);
+ }
+
void test_fromElement_METHOD() {
Source source = addSource('/test.dart', '''
class A {
« no previous file with comments | « pkg/analysis_server/test/analysis_notification_highlights_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698