anchor.diff:      // If still at the beginning of the file, add before the first declaration.
       int offset;
       bool insertEmptyLineAfter = false;
  -    if (unit.declarations.isNotEmpty) {
  -      offset = unit.declarations.first.offset;
  +    if (resolvedUnit.unit.declarations.isNotEmpty) {
  +      offset = resolvedUnit.unit.declarations.first.offset;
         insertEmptyLineAfter = true;
       } else {
  -      offset = unit.end;
  +      offset = resolvedUnit.unit.end;
       }
       addInsertion(offset, (EditBuilder builder) {
         for (int i = 0; i < importList.length; i++) {
  
positive.code:     }
      int timeStamp = state == ResultState.VALID ? 0 : -1;
  
      CompilationUnit unit = result.unit;
      CompilationUnitElement declaredUnit = unit.declaredElement;
      CompilationUnitElement libraryUnit =
          declaredUnit.library.definingCompilationUnit;
  
  
negative.code:       });
      }
  
      return DartFileEditBuilderImpl(this, result, timeStamp, libraryEditBuilder);
    }
  }
  
  