| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.html; | 8 library engine.html; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| 11 import 'java_core.dart'; | 11 import 'java_core.dart'; |
| 12 import 'java_engine.dart'; | 12 import 'java_engine.dart'; |
| 13 import 'source.dart'; | 13 import 'source.dart'; |
| 14 import 'error.dart' show AnalysisErrorListener; | 14 import 'error.dart' show AnalysisErrorListener; |
| 15 import 'scanner.dart' as sc show Scanner, SubSequenceReader, Token; | 15 import 'scanner.dart' as sc show Scanner, SubSequenceReader, Token; |
| 16 import 'parser.dart' show Parser; | 16 import 'parser.dart' show Parser; |
| 17 import 'ast.dart'; | 17 import 'ast.dart'; |
| 18 import 'element.dart'; | 18 import 'element.dart'; |
| 19 import 'engine.dart' show AnalysisEngine; | 19 import 'engine.dart' show AnalysisEngine, AngularHtmlUnitResolver; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Instances of the class `Token` represent a token that was scanned from the in
put. Each | 22 * Instances of the class `Token` represent a token that was scanned from the in
put. Each |
| 23 * token knows which token follows it, acting as the head of a linked list of to
kens. | 23 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 24 * | 24 * |
| 25 * @coverage dart.engine.html | 25 * @coverage dart.engine.html |
| 26 */ | 26 */ |
| 27 class Token { | 27 class Token { |
| 28 /** | 28 /** |
| 29 * The offset from the beginning of the file to the first character in the tok
en. | 29 * The offset from the beginning of the file to the first character in the tok
en. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 static Element getElement2(HtmlUnit htmlUnit, int offset) { | 270 static Element getElement2(HtmlUnit htmlUnit, int offset) { |
| 271 Expression expression = getExpression(htmlUnit, offset); | 271 Expression expression = getExpression(htmlUnit, offset); |
| 272 return getElement(expression); | 272 return getElement(expression); |
| 273 } | 273 } |
| 274 | 274 |
| 275 /** | 275 /** |
| 276 * Returns the [Element] to open when requested at the given [Expression]. | 276 * Returns the [Element] to open when requested at the given [Expression]. |
| 277 */ | 277 */ |
| 278 static Element getElementToOpen(HtmlUnit htmlUnit, Expression expression) { | 278 static Element getElementToOpen(HtmlUnit htmlUnit, Expression expression) { |
| 279 Element element = getElement(expression); | 279 Element element = getElement(expression); |
| 280 // special cases for Angular | 280 { |
| 281 if (isAngular(htmlUnit)) { | 281 AngularElement angularElement = AngularHtmlUnitResolver.getAngularElement(
element); |
| 282 // replace artificial controller variable Element with controller ClassEle
ment | 282 if (angularElement != null) { |
| 283 if (element is VariableElement) { | 283 return angularElement; |
| 284 VariableElement variable = element as VariableElement; | |
| 285 Type2 type = variable.type; | |
| 286 if (variable.nameOffset == 0 && type is InterfaceType) { | |
| 287 element = type.element; | |
| 288 } | |
| 289 } | 284 } |
| 290 } | 285 } |
| 291 // done | |
| 292 return element; | 286 return element; |
| 293 } | 287 } |
| 294 | 288 |
| 295 /** | 289 /** |
| 296 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses
the | 290 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses
the |
| 297 * given offset. | 291 * given offset. |
| 298 */ | 292 */ |
| 299 static Expression getExpression(HtmlUnit htmlUnit, int offset) { | 293 static Expression getExpression(HtmlUnit htmlUnit, int offset) { |
| 300 if (htmlUnit == null) { | 294 if (htmlUnit == null) { |
| 301 return null; | 295 return null; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 320 List<XmlTagNode> result = [null]; | 314 List<XmlTagNode> result = [null]; |
| 321 try { | 315 try { |
| 322 htmlUnit.accept(new RecursiveXmlVisitor_HtmlUnitUtils_getTagNode(offset, r
esult)); | 316 htmlUnit.accept(new RecursiveXmlVisitor_HtmlUnitUtils_getTagNode(offset, r
esult)); |
| 323 } on HtmlUnitUtils_FoundTagNodeError catch (e) { | 317 } on HtmlUnitUtils_FoundTagNodeError catch (e) { |
| 324 return result[0]; | 318 return result[0]; |
| 325 } | 319 } |
| 326 return null; | 320 return null; |
| 327 } | 321 } |
| 328 | 322 |
| 329 /** | 323 /** |
| 330 * Returns `true` if the given [HtmlUnit] has Angular annotation. | |
| 331 */ | |
| 332 static bool isAngular(HtmlUnit htmlUnit) => false; // AngularHtmlUnitResolver.
hasAngularAnnotation(htmlUnit); | |
| 333 | |
| 334 /** | |
| 335 * Returns the [Expression] that is part of the given root [ASTNode] and enclo
ses the | 324 * Returns the [Expression] that is part of the given root [ASTNode] and enclo
ses the |
| 336 * given offset. | 325 * given offset. |
| 337 */ | 326 */ |
| 338 static Expression getExpressionAt(ASTNode root, int offset) { | 327 static Expression getExpressionAt(ASTNode root, int offset) { |
| 339 if (root.offset <= offset && offset < root.end) { | 328 if (root.offset <= offset && offset < root.end) { |
| 340 ASTNode dartNode = new NodeLocator.con1(offset).searchWithin(root); | 329 ASTNode dartNode = new NodeLocator.con1(offset).searchWithin(root); |
| 341 if (dartNode is Expression) { | 330 if (dartNode is Expression) { |
| 342 return dartNode; | 331 return dartNode; |
| 343 } | 332 } |
| 344 } | 333 } |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 } else { | 856 } else { |
| 868 // handle a declaration | 857 // handle a declaration |
| 869 while (c >= 0) { | 858 while (c >= 0) { |
| 870 if (c == 0x3E) { | 859 if (c == 0x3E) { |
| 871 c = advance(); | 860 c = advance(); |
| 872 break; | 861 break; |
| 873 } | 862 } |
| 874 c = recordStartOfLineAndAdvance(c); | 863 c = recordStartOfLineAndAdvance(c); |
| 875 } | 864 } |
| 876 emit3(TokenType.DECLARATION, start, -1); | 865 emit3(TokenType.DECLARATION, start, -1); |
| 877 if (!_tail.lexeme.endsWith(">")) { | 866 if (!StringUtilities.endsWithChar(_tail.lexeme, 0x3E)) { |
| 878 } | 867 } |
| 879 } | 868 } |
| 880 } else if (c == 0x3F) { | 869 } else if (c == 0x3F) { |
| 881 // handle a directive | 870 // handle a directive |
| 882 while (c >= 0) { | 871 while (c >= 0) { |
| 883 if (c == 0x3F) { | 872 if (c == 0x3F) { |
| 884 c = advance(); | 873 c = advance(); |
| 885 if (c == 0x3E) { | 874 if (c == 0x3E) { |
| 886 c = advance(); | 875 c = advance(); |
| 887 break; | 876 break; |
| (...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 } | 2208 } |
| 2220 super.element = element; | 2209 super.element = element; |
| 2221 } | 2210 } |
| 2222 | 2211 |
| 2223 void visitChildren(XmlVisitor visitor) { | 2212 void visitChildren(XmlVisitor visitor) { |
| 2224 for (XmlTagNode node in _tagNodes) { | 2213 for (XmlTagNode node in _tagNodes) { |
| 2225 node.accept(visitor); | 2214 node.accept(visitor); |
| 2226 } | 2215 } |
| 2227 } | 2216 } |
| 2228 } | 2217 } |
| OLD | NEW |