Remove support for script tags.
BUG= R=ahe@google.com Review URL: https://codereview.chromium.org//20994004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25606 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -169,11 +169,6 @@ class CloningVisitor implements Visitor<Node> {
|
||||
visitReturn(Return node) => new Return(
|
||||
node.beginToken, node.endToken, visit(node.expression));
|
||||
|
||||
visitScriptTag(ScriptTag node) => new ScriptTag(
|
||||
visit(node.tag), visit(node.argument),
|
||||
visit(node.prefixIdentifier), visit(node.prefix),
|
||||
node.beginToken, node.endToken);
|
||||
|
||||
visitSend(Send node) => new Send(
|
||||
visit(node.receiver), visit(node.selector), visit(node.argumentsNode));
|
||||
|
||||
|
||||
@@ -795,8 +795,8 @@ class LibraryElementX extends ElementX implements LibraryElement {
|
||||
bool hasLibraryName() => libraryTag != null;
|
||||
|
||||
/**
|
||||
* Returns the library name (as defined by the #library tag) or for script
|
||||
* (which have no #library tag) the script file name. The latter case is used
|
||||
* Returns the library name (as defined by the library tag) or for script
|
||||
* (which have no library tag) the script file name. The latter case is used
|
||||
* to private 'library name' for scripts to use for instance in dartdoc.
|
||||
*/
|
||||
String getLibraryOrScriptName() {
|
||||
|
||||
@@ -531,8 +531,8 @@ class Dart2JsLibraryMirror extends Dart2JsContainerMirror
|
||||
LibraryMirror library() => this;
|
||||
|
||||
/**
|
||||
* Returns the library name (for libraries with a #library tag) or the script
|
||||
* file name (for scripts without a #library tag). The latter case is used to
|
||||
* Returns the library name (for libraries with a library tag) or the script
|
||||
* file name (for scripts without a library tag). The latter case is used to
|
||||
* provide a 'library name' for scripts, to use for instance in dartdoc.
|
||||
*/
|
||||
String get simpleName {
|
||||
|
||||
@@ -287,12 +287,6 @@ class Listener {
|
||||
Token beginToken, Token endToken) {
|
||||
}
|
||||
|
||||
void beginScriptTag(Token token) {
|
||||
}
|
||||
|
||||
void endScriptTag(bool hasPrefix, Token beginToken, Token endToken) {
|
||||
}
|
||||
|
||||
void beginSend(Token token) {
|
||||
}
|
||||
|
||||
@@ -729,26 +723,6 @@ class ElementListener extends Listener {
|
||||
compilationUnitElement.setPartOf(tag, listener);
|
||||
}
|
||||
|
||||
void endScriptTag(bool hasPrefix, Token beginToken, Token endToken) {
|
||||
LiteralString prefix = null;
|
||||
Identifier argumentName = null;
|
||||
if (hasPrefix) {
|
||||
prefix = popLiteralString();
|
||||
argumentName = popNode();
|
||||
}
|
||||
LiteralString firstArgument = popLiteralString();
|
||||
Identifier tag = popNode();
|
||||
ScriptTag scriptTag = new ScriptTag(tag, firstArgument, argumentName,
|
||||
prefix, beginToken, endToken);
|
||||
if (const SourceString('import') == tag.source ||
|
||||
const SourceString('source') == tag.source ||
|
||||
const SourceString('library') == tag.source) {
|
||||
addScriptTag(scriptTag);
|
||||
} else {
|
||||
recoverableError('unknown tag: ${tag.source.slowToString()}', node: tag);
|
||||
}
|
||||
}
|
||||
|
||||
void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
|
||||
if (periodBeforeName != null) {
|
||||
popNode(); // Discard name.
|
||||
@@ -1041,12 +1015,6 @@ class ElementListener extends Listener {
|
||||
metadata = metadata.prepend(annotation);
|
||||
}
|
||||
|
||||
// TODO(ahe): Remove this method.
|
||||
void addScriptTag(ScriptTag tag) {
|
||||
listener.onDeprecatedFeature(tag, '# tags');
|
||||
addLibraryTag(tag.toLibraryTag());
|
||||
}
|
||||
|
||||
void addLibraryTag(LibraryTag tag) {
|
||||
if (!allowLibraryTags()) {
|
||||
recoverableError('library tags not allowed here', node: tag);
|
||||
|
||||
@@ -52,8 +52,6 @@ class Parser {
|
||||
return parseClass(token);
|
||||
} else if (identical(value, 'typedef')) {
|
||||
return parseTypedef(token);
|
||||
} else if (identical(value, '#')) {
|
||||
return parseScriptTags(token);
|
||||
} else if (identical(value, 'library')) {
|
||||
return parseLibraryName(token);
|
||||
} else if (identical(value, 'import')) {
|
||||
@@ -747,24 +745,6 @@ class Parser {
|
||||
return token;
|
||||
}
|
||||
|
||||
Token parseScriptTags(Token token) {
|
||||
Token begin = token;
|
||||
listener.beginScriptTag(token);
|
||||
token = parseIdentifier(token.next);
|
||||
token = expect('(', token);
|
||||
token = parseLiteralStringOrRecoverExpression(token);
|
||||
bool hasPrefix = false;
|
||||
if (optional(',', token)) {
|
||||
hasPrefix = true;
|
||||
token = parseIdentifier(token.next);
|
||||
token = expect(':', token);
|
||||
token = parseLiteralStringOrRecoverExpression(token);
|
||||
}
|
||||
token = expect(')', token);
|
||||
listener.endScriptTag(hasPrefix, begin, token);
|
||||
return expectSemicolon(token);
|
||||
}
|
||||
|
||||
Token parseLiteralStringOrRecoverExpression(Token token) {
|
||||
if (identical(token.kind, STRING_TOKEN)) {
|
||||
return parseLiteralString(token);
|
||||
|
||||
@@ -5027,10 +5027,6 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
|
||||
inTryStatement = oldInTryStatement;
|
||||
}
|
||||
|
||||
visitScriptTag(ScriptTag node) {
|
||||
compiler.unimplemented('SsaBuilder.visitScriptTag', node: node);
|
||||
}
|
||||
|
||||
visitCatchBlock(CatchBlock node) {
|
||||
visit(node.block);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ abstract class Visitor<R> {
|
||||
R visitPrefix(Prefix node) => visitNodeList(node);
|
||||
R visitRethrow(Rethrow node) => visitStatement(node);
|
||||
R visitReturn(Return node) => visitStatement(node);
|
||||
R visitScriptTag(ScriptTag node) => visitNode(node);
|
||||
R visitSend(Send node) => visitExpression(node);
|
||||
R visitSendSet(SendSet node) => visitSend(node);
|
||||
R visitStatement(Statement node) => visitNode(node);
|
||||
@@ -181,7 +180,6 @@ abstract class Node extends TreeElementMixin implements Spannable {
|
||||
PartOf asPartOf() => null;
|
||||
Rethrow asRethrow() => null;
|
||||
Return asReturn() => null;
|
||||
ScriptTag asScriptTag() => null;
|
||||
Send asSend() => null;
|
||||
SendSet asSendSet() => null;
|
||||
Statement asStatement() => null;
|
||||
@@ -1695,59 +1693,6 @@ class LabeledStatement extends Statement {
|
||||
Node getBody() => statement;
|
||||
}
|
||||
|
||||
class ScriptTag extends Node {
|
||||
final Identifier tag;
|
||||
final StringNode argument;
|
||||
final Identifier prefixIdentifier;
|
||||
final StringNode prefix;
|
||||
|
||||
final Token beginToken;
|
||||
final Token endToken;
|
||||
|
||||
ScriptTag(this.tag, this.argument, this.prefixIdentifier, this.prefix,
|
||||
this.beginToken, this.endToken);
|
||||
|
||||
bool isImport() => tag.source == const SourceString("import");
|
||||
bool isSource() => tag.source == const SourceString("source");
|
||||
bool isLibrary() => tag.source == const SourceString("library");
|
||||
|
||||
ScriptTag asScriptTag() => this;
|
||||
|
||||
accept(Visitor visitor) => visitor.visitScriptTag(this);
|
||||
|
||||
visitChildren(Visitor visitor) {
|
||||
tag.accept(visitor);
|
||||
argument.accept(visitor);
|
||||
if (prefixIdentifier != null) prefixIdentifier.accept(visitor);
|
||||
if (prefix != null) prefix.accept(visitor);
|
||||
}
|
||||
|
||||
Token getBeginToken() => beginToken;
|
||||
|
||||
Token getEndToken() => endToken;
|
||||
|
||||
LibraryTag toLibraryTag() {
|
||||
if (isImport()) {
|
||||
Identifier prefixNode;
|
||||
if (prefix != null) {
|
||||
SourceString source = prefix.dartString.source;
|
||||
Token prefixToken = prefix.getBeginToken();
|
||||
Token token = new StringToken.fromSource(IDENTIFIER_INFO, source,
|
||||
prefixToken.charOffset);
|
||||
token.next = prefixToken.next;
|
||||
prefixNode = new Identifier(token);
|
||||
}
|
||||
return new Import(tag.token, argument, prefixNode, null, null);
|
||||
} else if (isLibrary()) {
|
||||
return new LibraryName(tag.token, argument, null);
|
||||
} else if (isSource()) {
|
||||
return new Part(tag.token, argument, null);
|
||||
} else {
|
||||
throw 'Unknown script tag ${tag.token.slowToString()}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class LibraryTag extends Node {
|
||||
final Link<MetadataAnnotation> metadata;
|
||||
|
||||
|
||||
@@ -314,10 +314,6 @@ class PrettyPrinter implements Visitor {
|
||||
closeNode();
|
||||
}
|
||||
|
||||
visitScriptTag(ScriptTag node) {
|
||||
visitNodeWithChildren(node, "ScriptTag");
|
||||
}
|
||||
|
||||
visitChildNode(Node node, String fieldName) {
|
||||
if (node == null) return;
|
||||
addCurrentIndent();
|
||||
|
||||
@@ -477,20 +477,6 @@ class Unparser implements Visitor {
|
||||
sb.write('import "$uri"$suffix;');
|
||||
}
|
||||
|
||||
visitScriptTag(ScriptTag node) {
|
||||
add(node.beginToken.value);
|
||||
visit(node.tag);
|
||||
sb.write('(');
|
||||
visit(node.argument);
|
||||
if (node.prefixIdentifier != null) {
|
||||
visit(node.prefixIdentifier);
|
||||
sb.write(':');
|
||||
visit(node.prefix);
|
||||
}
|
||||
sb.write(')');
|
||||
add(node.endToken.value);
|
||||
}
|
||||
|
||||
visitTryStatement(TryStatement node) {
|
||||
addToken(node.tryKeyword);
|
||||
visit(node.tryBlock);
|
||||
|
||||
@@ -2165,10 +2165,6 @@ class TypeInferrerVisitor extends ResolvedVisitor<ConcreteType> {
|
||||
inferrer.fail(node, 'not yet implemented');
|
||||
}
|
||||
|
||||
ConcreteType visitScriptTag(ScriptTag node) {
|
||||
inferrer.fail(node, 'not yet implemented');
|
||||
}
|
||||
|
||||
ConcreteType visitCatchBlock(CatchBlock node) {
|
||||
inferrer.fail(node, 'not yet implemented');
|
||||
}
|
||||
|
||||
@@ -54,11 +54,10 @@ main() {
|
||||
// "message" is the expected message as a [String]. This is a
|
||||
// short-term solution and should eventually changed to include
|
||||
// a symbolic reference to a MessageKind.
|
||||
"0<#library('test');>::${deprecatedMessage('# tags')}\n"
|
||||
"19<part 'part.dart';>::${deprecatedMessage('missing part-of tag')}\n"
|
||||
"15<part 'part.dart';>::${deprecatedMessage('missing part-of tag')}\n"
|
||||
"0<>:/part.dart:info: Note: This file has no part-of tag, but it is being"
|
||||
" used as a part.\n"
|
||||
"57<()>::${deprecatedMessage('getter parameters')}\n",
|
||||
"53<()>::${deprecatedMessage('getter parameters')}\n",
|
||||
messages.toString());
|
||||
}
|
||||
|
||||
@@ -70,7 +69,7 @@ deprecatedMessage(feature) {
|
||||
|
||||
const Map<String, String> TEST_SOURCE =
|
||||
const <String, String>{ '': """
|
||||
#library('test');
|
||||
library test;
|
||||
|
||||
part 'part.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user