Add "deprecated" to the standard library.

If the editor supports it, we should have a declaration in the standard library.
I suggest a separte dart:annotation library. It may grow in the future.
Alternatively it can be put in dart:core.

R=bak@google.com

Review URL: https://codereview.chromium.org//27523002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29166 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
lrn@google.com 2013-10-24 11:47:01 +00:00
parent 849ed804f4
commit 36332f6188
9 changed files with 115 additions and 67 deletions

View file

@ -4,8 +4,10 @@
/**
* Constants for use in metadata annotations such as
* `@deprecated`, `@override`, and `@proxy`.
*
* `@proxy`.
*
* See also `@deprecated` and `@override` in the `dart:core` library.
*
* Annotations provide semantic information
* that tools can use to provide a better user experience.
* For example, an IDE might not autocomplete
@ -21,29 +23,6 @@
*/
library meta;
/**
* An annotation used to mark a class, field, getter, setter, method, top-level
* variable, or top-level function as one that should no longer be used. Tools
* can use this annotation to provide a warning on references to the marked
* element.
*/
const deprecated = const _Deprecated();
class _Deprecated {
const _Deprecated();
}
/**
* An annotation used to mark an instance member (method, field, getter or
* setter) as overriding an inherited class member. Tools can use this
* annotation to provide a warning if there is no overridden member.
*/
const override = const _Override();
class _Override {
const _Override();
}
/**
* An annotation used to mark a class that should be considered to implement
* every possible getter, setter and method. Tools can use this annotation to
@ -57,4 +36,4 @@ const proxy = const _Proxy();
class _Proxy {
const _Proxy();
}
}

View file

@ -18,35 +18,6 @@ abstract class EfficientLength {
int get length;
}
// This is a hack to make @deprecated work in dart:io. Don't remove or use this,
// unless coordinated with either me or the core library team. Thanks!
// TODO(ajohnsen): Remove at the 11th of August 2013.
// TODO(ajohnsen): Remove hide in:
// tools/dom/templates/html/dart2js/html_dart2js.darttemplate
// tools/dom/templates/html/dart2js/svg_dart2js.darttemplate
// tools/dom/templates/html/dart2js/web_audio_dart2js.darttemplate
// tools/dom/templates/html/dart2js/web_gl_dart2js.darttemplate
// tools/dom/templates/html/dart2js/web_sql_dart2js.darttemplate
// tools/dom/templates/html/dartium/html_dartium.darttemplate
// tools/dom/templates/html/dartium/svg_dartium.darttemplate
// tools/dom/templates/html/dartium/web_audio_dartium.darttemplate
// tools/dom/templates/html/dartium/web_gl_dartium.darttemplate
// tools/dom/templates/html/dartium/web_sql_dartium.darttemplate
// sdk/lib/core/regexp.dart
// TODO(floitsch): also used in dart:async until end of September for
// deprecation of runZonedExperimental.
// TODO(floitsch): also used in dart:json and dart:utf until middle of October
// for deprecation of json and utf libraries.
// TODO(floitsch): and dart:async until middle of October for deprecation of
// getAttachedStackTrace.
// TODO(floitsch): and dart:async until end of October for deprecation of
// runAsync.
// We use a random string constant to avoid it clashing with other constants.
// This is, because we have a test that verifies that no metadata is included
// in the output, when no mirrors need them.
const deprecated = "qB2n4PYM";
/**
* An [Iterable] for classes that have efficient [length] and [elementAt].
*

View file

@ -95,7 +95,7 @@ const Map<String, LibraryInfo> LIBRARIES = const {
"mirrors": const LibraryInfo(
"mirrors/mirrors.dart",
maturity: Maturity.UNSTABLE,
maturity: Maturity.UNSTABLE,
dart2jsPatchPath: "_internal/lib/mirrors_patch.dart"),
"nativewrappers": const LibraryInfo(

View file

@ -0,0 +1,104 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of dart.core;
/**
* The annotation "@Deprecated('expires when')" marks a feature as deprecated.
*
* The annotation "@deprecated" is a shorthand for deprecating until
* to an unspecified "next release".
*
* The intent of the "@Deprecated" annotation is to inform users of a feature
* that they should change their code, even if it is currently still working
* correctly.
*
* A deprecated feature is scheduled to be removed at a later time, possibly
* specified as the "expires" field of the annotation.
* This means that a deprecated feature should not be used, or code using it
* will break at some point in the future. If there is code using the feature,
* that code should be rewritten to not use the deprecated feature.
*
* A deprecated feature should document how the same effect can be achieved,
* so the programmer knows how to rewrite the code.
*
* The "@Deprecated" annotation applies to libraries, top-level declarations
* (variables, getters, setters, functions, classes and typedefs),
* class-level declarations (variables, getters, setters, methods, operators or
* constructors, whether static or not), named optional arguments and
* trailing optional positional parameters.
*
* Deprecation is transitive:
*
* - If a library is deprecated, so is every member of it.
* - If a class is deprecated, so is every member of it.
* - If a variable is deprecated, so are its implicit getter and setter.
*
*
* A tool that processes Dart source code may report when:
*
* - the code imports a deprecated library.
* - the code exports a deprecated library, or any deprecated member of
*  a non-deprecated library.
* - the code refers statically to a deprecated declaration.
* - the code dynamically uses a member of an object with a statically known
* type, where the member is deprecated on the static type of the object.
* - the code dynamically calls a method with an argument where the
* corresponding optional parameter is deprecated on the object's static type.
*
*
* If the deprecated use is inside a library, class or method which is itself
* deprecated, the tool should not bother the user about it.
* A deprecated feature is expected to use other deprecated features.
*/
class Deprecated {
/**
* A description of when the deprecated feature is expected to be retired.
*/
final String expires;
/**
* Create a deprecation annotation which specifies the expiration of the
* annotated feature.
*
* The [expires] argument should be readable by programmers, and should state
* when an annotated feature is expected to be removed.
* This can be specified, for example, as a date, as a release number, or
* as relative to some other change (like "when bug 4418 is fixed").
*/
const Deprecated(String expires) : this.expires = expires;
String toString() => "Deprecated feature. Will be removed $expires";
}
class _Override {
const _Override();
}
/**
* Marks a feature as [Deprecated] until the next release.
*/
const deprecated = const Deprecated("next release");
/*
* The annotation "@override" marks an instance member as overriding a
* superclass member with the same name.
*
* The annotation applies to instance methods, getters and setters, and to
* instance fields, where it means that the implicit getter and setter of the
* field is marked as overriding, but the field itself is not.
*
* A tool may report if no declaration of an annotated member is inherited by
* the class from either a superclass or an interface.
*
* The intent of the "override" notation is to catch situations where a
* superclass renames a member, and an independent subclass which used to
* override the member, could silently continue working using the
* superclass implementation.
*
* The "@override" annotation is intentionally not used in the core libraries.
* It is intended for the editor, or similar tools, to support user written
* code.
*/
const override = const _Override();

View file

@ -158,6 +158,7 @@ import "dart:_collection-dev" as _collection_dev;
import "dart:convert" show UTF8, Encoding;
import "dart:math" show Random; // Used by List.shuffle.
part "annotations.dart";
part "bool.dart";
part "comparable.dart";
part "date_time.dart";

View file

@ -6,6 +6,7 @@
'sources': [
'core.dart',
# The above file needs to be first as it lists the parts below.
'annotations.dart',
'bool.dart',
'comparable.dart',
'date_time.dart',

View file

@ -26154,13 +26154,13 @@ class Url extends NativeFieldWrapperClass2 {
if ((blob_OR_source_OR_stream is Blob || blob_OR_source_OR_stream == null)) {
return _createObjectURL_1(blob_OR_source_OR_stream);
}
if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) {
if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) {
return _createObjectURL_2(blob_OR_source_OR_stream);
}
if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) {
if ((blob_OR_source_OR_stream is MediaSource || blob_OR_source_OR_stream == null)) {
return _createObjectURL_3(blob_OR_source_OR_stream);
}
if ((blob_OR_source_OR_stream is MediaStream || blob_OR_source_OR_stream == null)) {
if ((blob_OR_source_OR_stream is _WebKitMediaSource || blob_OR_source_OR_stream == null)) {
return _createObjectURL_4(blob_OR_source_OR_stream);
}
throw new ArgumentError("Incorrect number or type of arguments");

View file

@ -14,7 +14,3 @@ part 'css_class_set.dart';
part 'device.dart';
part 'filtered_element_list.dart';
part 'lists.dart';
// For annotating deprecated APIs.
// TODO: remove once @deprecated is added to dart core.
const deprecated = 0;

View file

@ -19,7 +19,3 @@ part 'conversions.dart';
part 'device.dart';
part 'filtered_element_list.dart';
part 'lists.dart';
// For annotating deprecated APIs.
// TODO: remove once @deprecated is added to dart core.
const deprecated = 0;