Check that target of a new constructor is a ClassDeclaration.

For an exception #10 from the list.

Cannot reproduce though.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1757393002 .
This commit is contained in:
Konstantin Shcheglov 2016-03-03 13:19:40 -08:00
parent 1cc5dab2f2
commit 6510065262

View file

@ -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);
{