Skip to content

Commit 01165df

Browse files
bwilkersonCommit Queue
authored andcommitted
Migrate the diagnostic pages
Change-Id: I8f3255bf07154ddc32c89535579dbbaa64351414 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394821 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent fc7f12d commit 01165df

File tree

7 files changed

+133
-95
lines changed

7 files changed

+133
-95
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ lib/src/services/search/element_visitors.dart
9191
lib/src/services/search/hierarchy.dart
9292
lib/src/services/search/search_engine.dart
9393
lib/src/services/search/search_engine_internal.dart
94-
lib/src/status/ast_writer.dart
95-
lib/src/status/diagnostics.dart
96-
lib/src/status/element_writer.dart
97-
lib/src/status/tree_writer.dart
9894
lib/src/utilities/extensions/ast.dart
9995
lib/src/utilities/extensions/completion_request.dart
10096
lib/src/utilities/extensions/element.dart

pkg/analysis_server/lib/src/status/ast_writer.dart

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,35 @@ class AstWriter extends UnifyingAstVisitor<void> with TreeWriter {
3434

3535
properties['name'] = _getName(node);
3636
if (node is ArgumentListImpl) {
37-
properties['static parameter types'] = node.correspondingStaticParameters;
37+
properties['corresponding static parameters'] =
38+
node.correspondingStaticParameters2;
3839
} else if (node is Annotation) {
39-
properties['element'] = node.element;
40+
properties['element'] = node.element2;
4041
properties['element annotation'] = node.elementAnnotation;
4142
} else if (node is BinaryExpression) {
42-
properties['static element'] = node.staticElement;
43+
properties['element'] = node.element;
4344
properties['static type'] = node.staticType;
4445
} else if (node is ClassDeclaration) {
45-
properties['declaredElement'] = node.declaredElement;
46+
properties['declared fragment'] = node.declaredFragment;
4647
properties['abstract keyword'] = node.abstractKeyword;
4748
} else if (node is ClassTypeAlias) {
48-
properties['declaredElement'] = node.declaredElement;
49+
properties['declared fragment'] = node.declaredFragment;
4950
properties['abstract keyword'] = node.abstractKeyword;
5051
} else if (node is CompilationUnit) {
51-
properties['declaredElement'] = node.declaredElement;
52+
properties['declared fragment'] = node.declaredFragment;
5253
} else if (node is Configuration) {
5354
properties['uriSource'] = node.resolvedUri;
5455
} else if (node is ConstructorName) {
55-
properties['static element'] = node.staticElement;
56+
properties['element'] = node.element;
5657
} else if (node is DeclaredIdentifier) {
57-
properties['element'] = node.declaredElement;
58+
properties['element'] = node.declaredElement2;
5859
properties['keyword'] = node.keyword;
5960
} else if (node is ExportDirective) {
60-
properties['element'] = node.element;
61+
properties['library export'] = node.libraryExport;
6162
} else if (node is FieldDeclaration) {
6263
properties['static keyword'] = node.staticKeyword;
6364
} else if (node is FormalParameter) {
64-
properties['declaredElement'] = node.declaredElement;
65+
properties['declared fragment'] = node.declaredFragment;
6566
if (node.isRequiredPositional) {
6667
properties['kind'] = 'required-positional';
6768
} else if (node.isRequiredNamed) {
@@ -74,26 +75,26 @@ class AstWriter extends UnifyingAstVisitor<void> with TreeWriter {
7475
properties['kind'] = 'unknown kind';
7576
}
7677
} else if (node is FunctionDeclaration) {
77-
properties['declaredElement'] = node.declaredElement;
78+
properties['declared fragment'] = node.declaredFragment;
7879
properties['external keyword'] = node.externalKeyword;
7980
properties['property keyword'] = node.propertyKeyword;
8081
} else if (node is FunctionExpressionInvocation) {
81-
properties['static element'] = node.staticElement;
82+
properties['element'] = node.element;
8283
properties['static invoke type'] = node.staticInvokeType;
8384
properties['static type'] = node.staticType;
8485
} else if (node is GenericFunctionType) {
8586
properties['type'] = node.type;
8687
} else if (node is ImportDirective) {
87-
properties['element'] = node.element;
88+
properties['library import'] = node.libraryImport;
8889
} else if (node is IndexExpression) {
89-
properties['static element'] = node.staticElement;
90+
properties['element'] = node.element;
9091
properties['static type'] = node.staticType;
9192
} else if (node is InstanceCreationExpression) {
9293
properties['static type'] = node.staticType;
9394
} else if (node is LibraryDirective) {
94-
properties['element'] = node.element;
95+
properties['element'] = node.element2;
9596
} else if (node is MethodDeclaration) {
96-
properties['declaredElement'] = node.declaredElement;
97+
properties['declared fragment'] = node.declaredFragment;
9798
properties['external keyword'] = node.externalKeyword;
9899
properties['modifier keyword'] = node.modifierKeyword;
99100
properties['operator keyword'] = node.operatorKeyword;
@@ -102,37 +103,35 @@ class AstWriter extends UnifyingAstVisitor<void> with TreeWriter {
102103
properties['static invoke type'] = node.staticInvokeType;
103104
properties['static type'] = node.staticType;
104105
} else if (node is PartDirective) {
105-
properties['element'] = node.element;
106-
} else if (node is PartOfDirective) {
107-
properties['element'] = node.element;
106+
properties['fragment include'] = node.fragmentInclude;
108107
} else if (node is PostfixExpression) {
109-
properties['static element'] = node.staticElement;
108+
properties['element'] = node.element;
110109
properties['static type'] = node.staticType;
111110
} else if (node is PrefixExpression) {
112-
properties['static element'] = node.staticElement;
111+
properties['element'] = node.element;
113112
properties['static type'] = node.staticType;
114113
} else if (node is RedirectingConstructorInvocation) {
115-
properties['static element'] = node.staticElement;
114+
properties['element'] = node.element;
116115
} else if (node is SimpleIdentifier) {
117-
properties['static element'] = node.staticElement;
116+
properties['element'] = node.element;
118117
properties['static type'] = node.staticType;
119118
} else if (node is SimpleStringLiteral) {
120119
properties['value'] = node.value;
121120
} else if (node is SuperConstructorInvocation) {
122-
properties['static element'] = node.staticElement;
121+
properties['element'] = node.element;
123122
} else if (node is TypeAnnotation) {
124123
properties['type'] = node.type;
125124
} else if (node is VariableDeclarationList) {
126125
properties['keyword'] = node.keyword;
127126
} else if (node is Declaration) {
128-
properties['declaredElement'] = node.declaredElement;
127+
properties['declared fragment'] = node.declaredFragment;
129128
} else if (node is Expression) {
130129
properties['static type'] = node.staticType;
131130
} else if (node is FunctionBody) {
132-
properties['isAsynchronous'] = node.isAsynchronous;
133-
properties['isGenerator'] = node.isGenerator;
131+
properties['is asynchronous'] = node.isAsynchronous;
132+
properties['is generator'] = node.isGenerator;
134133
} else if (node is Identifier) {
135-
properties['static element'] = node.staticElement;
134+
properties['element'] = node.element;
136135
properties['static type'] = node.staticType;
137136
}
138137

pkg/analysis_server/lib/src/status/diagnostics.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import 'package:analysis_server/src/status/pages.dart';
2424
import 'package:analysis_server/src/utilities/profiling.dart';
2525
import 'package:analyzer/dart/analysis/context_root.dart';
2626
import 'package:analyzer/dart/analysis/results.dart';
27-
import 'package:analyzer/dart/element/element.dart';
2827
import 'package:analyzer/src/context/source.dart';
2928
import 'package:analyzer/src/dart/analysis/analysis_options_map.dart';
3029
import 'package:analyzer/src/dart/analysis/driver.dart';
@@ -1306,13 +1305,17 @@ class ElementModelPage extends DiagnosticPageWithNav {
13061305
return;
13071306
}
13081307
var result = await driver.getResolvedUnit(filePath);
1309-
CompilationUnitElement? compilationUnitElement;
1310-
if (result is ResolvedUnitResult) {
1311-
compilationUnitElement = result.unit.declaredElement;
1308+
if (result is! ResolvedUnitResult) {
1309+
p(
1310+
'The file <code>${escape(filePath)}</code> could not be resolved.',
1311+
raw: true,
1312+
);
1313+
return;
13121314
}
1313-
if (compilationUnitElement != null) {
1315+
var libraryFragment = result.unit.declaredFragment;
1316+
if (libraryFragment != null) {
13141317
var writer = ElementWriter(buf);
1315-
compilationUnitElement.accept(writer);
1318+
writer.write(libraryFragment.element);
13161319
} else {
13171320
p(
13181321
'An element model could not be produced for the file '

0 commit comments

Comments
 (0)