| Index: pkg/analyzer/lib/src/generated/html.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/html.dart b/pkg/analyzer/lib/src/generated/html.dart
|
| index 2d511c131690d5434b72e0ee0039ccf5d848bf52..85708aaeb6b687a58e3542e07e0fc3690a125046 100644
|
| --- a/pkg/analyzer/lib/src/generated/html.dart
|
| +++ b/pkg/analyzer/lib/src/generated/html.dart
|
| @@ -166,29 +166,6 @@ class RawXmlExpression extends XmlExpression {
|
| }
|
|
|
| /**
|
| - * Instances of `HtmlParseResult` hold the result of parsing an HTML file.
|
| - *
|
| - * @coverage dart.engine.html
|
| - */
|
| -class HtmlParseResult extends HtmlScanResult {
|
| - /**
|
| - * The unit containing the parsed information (not `null`).
|
| - */
|
| - HtmlUnit _unit;
|
| -
|
| - HtmlParseResult(int modificationTime, Token token, List<int> lineStarts, HtmlUnit unit) : super(modificationTime, token, lineStarts) {
|
| - this._unit = unit;
|
| - }
|
| -
|
| - /**
|
| - * Answer the unit generated by parsing the source
|
| - *
|
| - * @return the unit (not `null`)
|
| - */
|
| - HtmlUnit get htmlUnit => _unit;
|
| -}
|
| -
|
| -/**
|
| * Instances of the class `RecursiveXmlVisitor` implement an XML visitor that will recursively
|
| * visit all of the nodes in an XML structure. For example, using an instance of this class to visit
|
| * a [XmlTagNode] will also cause all of the contained [XmlAttributeNode]s and
|
| @@ -976,30 +953,6 @@ abstract class AbstractScanner {
|
| }
|
|
|
| /**
|
| - * Instances of `HtmlScanResult` hold the result of scanning an HTML file.
|
| - *
|
| - * @coverage dart.engine.html
|
| - */
|
| -class HtmlScanResult {
|
| - /**
|
| - * The time at which the contents of the source were last set.
|
| - */
|
| - final int modificationTime;
|
| -
|
| - /**
|
| - * The first token in the token stream (not `null`).
|
| - */
|
| - final Token token;
|
| -
|
| - /**
|
| - * The line start information that was produced.
|
| - */
|
| - final List<int> lineStarts;
|
| -
|
| - HtmlScanResult(this.modificationTime, this.token, this.lineStarts);
|
| -}
|
| -
|
| -/**
|
| * Instances of the class `StringScanner` implement a scanner that reads from a string. The
|
| * scanning logic is in the superclass.
|
| *
|
| @@ -1366,65 +1319,6 @@ class XmlExpression_Reference {
|
| }
|
|
|
| /**
|
| - * Instances of `HtmlScanner` receive and scan HTML content from a [Source].<br/>
|
| - * For example, the following code scans HTML source and returns the result:
|
| - *
|
| - * <pre>
|
| - * HtmlScanner scanner = new HtmlScanner(source);
|
| - * source.getContents(scanner);
|
| - * return scanner.getResult();
|
| - * </pre>
|
| - *
|
| - * @coverage dart.engine.html
|
| - */
|
| -class HtmlScanner implements Source_ContentReceiver {
|
| - List<String> _SCRIPT_TAG = <String> ["script"];
|
| -
|
| - /**
|
| - * The source being scanned (not `null`)
|
| - */
|
| - Source _source;
|
| -
|
| - /**
|
| - * The time at which the contents of the source were last set.
|
| - */
|
| - int _modificationTime = 0;
|
| -
|
| - /**
|
| - * The scanner used to scan the source
|
| - */
|
| - AbstractScanner _scanner;
|
| -
|
| - /**
|
| - * The first token in the token stream.
|
| - */
|
| - Token _token;
|
| -
|
| - /**
|
| - * Construct a new instance to scan the specified source.
|
| - *
|
| - * @param source the source to be scanned (not `null`)
|
| - */
|
| - HtmlScanner(Source source) {
|
| - this._source = source;
|
| - }
|
| -
|
| - void accept(String contents, int modificationTime) {
|
| - this._modificationTime = modificationTime;
|
| - _scanner = new StringScanner(_source, contents);
|
| - _scanner.passThroughElements = _SCRIPT_TAG;
|
| - _token = _scanner.tokenize();
|
| - }
|
| -
|
| - /**
|
| - * Answer the result of scanning the source
|
| - *
|
| - * @return the result (not `null`)
|
| - */
|
| - HtmlScanResult get result => new HtmlScanResult(_modificationTime, _token, _scanner.lineStarts);
|
| -}
|
| -
|
| -/**
|
| * Instances of the class `XmlParser` are used to parse tokens into a AST structure comprised
|
| * of [XmlNode]s.
|
| *
|
| @@ -1491,22 +1385,20 @@ class XmlParser {
|
| List<XmlTagNode> parseTopTagNodes(Token firstToken) {
|
| _currentToken = firstToken;
|
| List<XmlTagNode> tagNodes = new List<XmlTagNode>();
|
| - while (true) {
|
| - while (true) {
|
| - if (_currentToken.type == TokenType.LT) {
|
| - tagNodes.add(parseTagNode());
|
| - } else if (_currentToken.type == TokenType.DECLARATION || _currentToken.type == TokenType.DIRECTIVE || _currentToken.type == TokenType.COMMENT) {
|
| - // ignored tokens
|
| - _currentToken = _currentToken.next;
|
| - } else if (_currentToken.type == TokenType.EOF) {
|
| - return tagNodes;
|
| - } else {
|
| - reportUnexpectedToken();
|
| - _currentToken = _currentToken.next;
|
| - }
|
| - break;
|
| + TokenType type = _currentToken.type;
|
| + while (type != TokenType.EOF) {
|
| + if (identical(type, TokenType.LT)) {
|
| + tagNodes.add(parseTagNode());
|
| + } else if (identical(type, TokenType.DECLARATION) || identical(type, TokenType.DIRECTIVE) || identical(type, TokenType.COMMENT)) {
|
| + // ignored tokens
|
| + _currentToken = _currentToken.next;
|
| + } else {
|
| + reportUnexpectedToken();
|
| + _currentToken = _currentToken.next;
|
| }
|
| + type = _currentToken.type;
|
| }
|
| + return tagNodes;
|
| }
|
|
|
| /**
|
| @@ -1572,19 +1464,16 @@ class XmlParser {
|
| return XmlTagNode.NO_ATTRIBUTES;
|
| }
|
| List<XmlAttributeNode> attributes = new List<XmlAttributeNode>();
|
| - while (true) {
|
| - while (true) {
|
| - if (_currentToken.type == TokenType.GT || _currentToken.type == TokenType.SLASH_GT || _currentToken.type == TokenType.EOF) {
|
| - return attributes;
|
| - } else if (_currentToken.type == TokenType.TAG) {
|
| - attributes.add(parseAttribute());
|
| - } else {
|
| - reportUnexpectedToken();
|
| - _currentToken = _currentToken.next;
|
| - }
|
| - break;
|
| + while (type != TokenType.GT && type != TokenType.SLASH_GT && type != TokenType.EOF) {
|
| + if (identical(type, TokenType.TAG)) {
|
| + attributes.add(parseAttribute());
|
| + } else {
|
| + reportUnexpectedToken();
|
| + _currentToken = _currentToken.next;
|
| }
|
| + type = _currentToken.type;
|
| }
|
| + return attributes;
|
| }
|
|
|
| /**
|
| @@ -1599,22 +1488,19 @@ class XmlParser {
|
| return XmlTagNode.NO_TAG_NODES;
|
| }
|
| List<XmlTagNode> nodes = new List<XmlTagNode>();
|
| - while (true) {
|
| - while (true) {
|
| - if (_currentToken.type == TokenType.LT) {
|
| - nodes.add(parseTagNode());
|
| - } else if (_currentToken.type == TokenType.LT_SLASH || _currentToken.type == TokenType.EOF) {
|
| - return nodes;
|
| - } else if (_currentToken.type == TokenType.COMMENT) {
|
| - // ignored token
|
| - _currentToken = _currentToken.next;
|
| - } else {
|
| - reportUnexpectedToken();
|
| - _currentToken = _currentToken.next;
|
| - }
|
| - break;
|
| + while (type != TokenType.LT_SLASH && type != TokenType.EOF) {
|
| + if (identical(type, TokenType.LT)) {
|
| + nodes.add(parseTagNode());
|
| + } else if (identical(type, TokenType.COMMENT)) {
|
| + // ignored token
|
| + _currentToken = _currentToken.next;
|
| + } else {
|
| + reportUnexpectedToken();
|
| + _currentToken = _currentToken.next;
|
| }
|
| + type = _currentToken.type;
|
| }
|
| + return nodes;
|
| }
|
|
|
| /**
|
| @@ -1997,30 +1883,16 @@ class HtmlParser extends XmlParser {
|
| }
|
|
|
| /**
|
| - * Parse the tokens specified by the given scan result.
|
| - *
|
| - * @param scanResult the result of scanning an HTML source (not `null`)
|
| - * @return the parse result (not `null`)
|
| - */
|
| - HtmlParseResult parse(HtmlScanResult scanResult) {
|
| - List<int> lineStarts = scanResult.lineStarts;
|
| - _lineInfo = new LineInfo(lineStarts);
|
| - Token firstToken = scanResult.token;
|
| - List<XmlTagNode> tagNodes = parseTopTagNodes(firstToken);
|
| - HtmlUnit unit = new HtmlUnit(firstToken, tagNodes, currentToken);
|
| - return new HtmlParseResult(scanResult.modificationTime, firstToken, scanResult.lineStarts, unit);
|
| - }
|
| -
|
| - /**
|
| - * Scan then parse the specified source.
|
| + * Parse the given tokens.
|
| *
|
| - * @param source the source to be scanned and parsed (not `null`)
|
| + * @param token the first token in the stream of tokens to be parsed
|
| + * @param lineInfo the line information created by the scanner
|
| * @return the parse result (not `null`)
|
| */
|
| - HtmlParseResult parse2(Source source) {
|
| - HtmlScanner scanner = new HtmlScanner(source);
|
| - source.getContents(scanner);
|
| - return parse(scanner.result);
|
| + HtmlUnit parse(Token token, LineInfo lineInfo) {
|
| + this._lineInfo = lineInfo;
|
| + List<XmlTagNode> tagNodes = parseTopTagNodes(token);
|
| + return new HtmlUnit(token, tagNodes, currentToken);
|
| }
|
|
|
| XmlAttributeNode createAttributeNode(Token name, Token equals, Token value) => new XmlAttributeNode(name, equals, value);
|
|
|