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

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 1757393002: Check that target of a new constructor is a ClassDeclaration. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index a33d280fe75cd346087c593f82cef1cadc3ab2d0..3fdd5f9a3db8a3b7a43e2afc1012365455acbf5e 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -700,10 +700,14 @@ class FixProcessor {
return;
}
ClassElement targetElement = constructorElement.enclosingElement;
- String targetFile = targetElement.source.fullName;
- ClassDeclaration targetClass = getParsedClassElementNode(targetElement);
+ // prepare location for a new constructor
+ AstNode targetTypeNode = getParsedClassElementNode(targetElement);
+ if (targetTypeNode is! ClassDeclaration) {
+ return;
+ }
_ConstructorLocation targetLocation =
- _prepareNewConstructorLocation(targetClass);
+ _prepareNewConstructorLocation(targetTypeNode);
+ String targetFile = targetElement.source.fullName;
// build method source
SourceBuilder sb = new SourceBuilder(targetFile, targetLocation.offset);
{
@@ -753,11 +757,15 @@ class FixProcessor {
if (targetType is! InterfaceType) {
return;
}
+ // prepare location for a new constructor
ClassElement targetElement = targetType.element as ClassElement;
- String targetFile = targetElement.source.fullName;
- ClassDeclaration targetClass = getParsedClassElementNode(targetElement);
+ AstNode targetTypeNode = getParsedClassElementNode(targetElement);
+ if (targetTypeNode is! ClassDeclaration) {
+ return;
+ }
_ConstructorLocation targetLocation =
- _prepareNewConstructorLocation(targetClass);
+ _prepareNewConstructorLocation(targetTypeNode);
+ String targetFile = targetElement.source.fullName;
// build method source
SourceBuilder sb = new SourceBuilder(targetFile, targetLocation.offset);
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698