| 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'; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 { | 252 { |
| 253 AngularElement angularElement = AngularHtmlUnitResolver.getAngularElement(
element); | 253 AngularElement angularElement = AngularHtmlUnitResolver.getAngularElement(
element); |
| 254 if (angularElement != null) { | 254 if (angularElement != null) { |
| 255 return angularElement; | 255 return angularElement; |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 return element; | 258 return element; |
| 259 } | 259 } |
| 260 | 260 |
| 261 /** | 261 /** |
| 262 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and encloses
the |
| 263 * given offset. |
| 264 */ |
| 265 static XmlTagNode getEnclosingTagNode(HtmlUnit htmlUnit, int offset) { |
| 266 if (htmlUnit == null) { |
| 267 return null; |
| 268 } |
| 269 List<XmlTagNode> result = [null]; |
| 270 try { |
| 271 htmlUnit.accept(new RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(
offset, result)); |
| 272 } on HtmlUnitUtils_FoundTagNodeError catch (e) { |
| 273 return result[0]; |
| 274 } |
| 275 return null; |
| 276 } |
| 277 |
| 278 /** |
| 262 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses
the | 279 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses
the |
| 263 * given offset. | 280 * given offset. |
| 264 */ | 281 */ |
| 265 static Expression getExpression(HtmlUnit htmlUnit, int offset) { | 282 static Expression getExpression(HtmlUnit htmlUnit, int offset) { |
| 266 if (htmlUnit == null) { | 283 if (htmlUnit == null) { |
| 267 return null; | 284 return null; |
| 268 } | 285 } |
| 269 List<Expression> result = [null]; | 286 List<Expression> result = [null]; |
| 270 try { | 287 try { |
| 271 // TODO(scheglov) this code is very Angular specific | 288 // TODO(scheglov) this code is very Angular specific |
| 272 htmlUnit.accept(new ExpressionVisitor_HtmlUnitUtils_getExpression(offset,
result)); | 289 htmlUnit.accept(new ExpressionVisitor_HtmlUnitUtils_getExpression(offset,
result)); |
| 273 } on HtmlUnitUtils_FoundExpressionError catch (e) { | 290 } on HtmlUnitUtils_FoundExpressionError catch (e) { |
| 274 return result[0]; | 291 return result[0]; |
| 275 } | 292 } |
| 276 return null; | 293 return null; |
| 277 } | 294 } |
| 278 | 295 |
| 279 /** | 296 /** |
| 280 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and encloses
the | 297 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and its open
or |
| 281 * given offset. | 298 * closing tag name encloses the given offset. |
| 282 */ | 299 */ |
| 283 static XmlTagNode getTagNode(HtmlUnit htmlUnit, int offset) { | 300 static XmlTagNode getTagNode(HtmlUnit htmlUnit, int offset) { |
| 284 if (htmlUnit == null) { | 301 XmlTagNode node = getEnclosingTagNode(htmlUnit, offset); |
| 302 // do we have an enclosing tag at all? |
| 303 if (node == null) { |
| 285 return null; | 304 return null; |
| 286 } | 305 } |
| 287 List<XmlTagNode> result = [null]; | 306 // is "offset" in the open tag? |
| 288 try { | 307 Token openTag = node.tagToken; |
| 289 htmlUnit.accept(new RecursiveXmlVisitor_HtmlUnitUtils_getTagNode(offset, r
esult)); | 308 if (openTag.offset <= offset && offset <= openTag.end) { |
| 290 } on HtmlUnitUtils_FoundTagNodeError catch (e) { | 309 return node; |
| 291 return result[0]; | |
| 292 } | 310 } |
| 311 // is "offset" in the open tag? |
| 312 Token closeTag = node.closingTag; |
| 313 if (closeTag != null && closeTag.offset <= offset && offset <= closeTag.end)
{ |
| 314 return node; |
| 315 } |
| 316 // not on a tag name |
| 293 return null; | 317 return null; |
| 294 } | 318 } |
| 295 | 319 |
| 296 /** | 320 /** |
| 297 * Returns the [Expression] that is part of the given root [AstNode] and enclo
ses the | 321 * Returns the [Expression] that is part of the given root [AstNode] and enclo
ses the |
| 298 * given offset. | 322 * given offset. |
| 299 */ | 323 */ |
| 300 static Expression _getExpressionAt(AstNode root, int offset) { | 324 static Expression _getExpressionAt(AstNode root, int offset) { |
| 301 if (root.offset <= offset && offset < root.end) { | 325 if (root.offset <= offset && offset <= root.end) { |
| 302 AstNode dartNode = new NodeLocator.con1(offset).searchWithin(root); | 326 AstNode dartNode = new NodeLocator.con1(offset).searchWithin(root); |
| 303 if (dartNode is Expression) { | 327 if (dartNode is Expression) { |
| 304 return dartNode; | 328 return dartNode; |
| 305 } | 329 } |
| 306 } | 330 } |
| 307 return null; | 331 return null; |
| 308 } | 332 } |
| 309 } | 333 } |
| 310 | 334 |
| 311 class HtmlUnitUtils_FoundAttributeNodeError extends Error { | 335 class HtmlUnitUtils_FoundAttributeNodeError extends Error { |
| 312 } | 336 } |
| 313 | 337 |
| 314 class HtmlUnitUtils_FoundExpressionError extends Error { | 338 class HtmlUnitUtils_FoundExpressionError extends Error { |
| 315 } | 339 } |
| 316 | 340 |
| 317 class HtmlUnitUtils_FoundTagNodeError extends Error { | 341 class HtmlUnitUtils_FoundTagNodeError extends Error { |
| 318 } | 342 } |
| 319 | 343 |
| 320 class RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode extends RecursiveXmlVis
itor<Object> { | 344 class RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode extends RecursiveXmlVis
itor<Object> { |
| 321 int offset = 0; | 345 int offset = 0; |
| 322 | 346 |
| 323 List<XmlAttributeNode> result; | 347 List<XmlAttributeNode> result; |
| 324 | 348 |
| 325 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(this.offset, this.result) :
super(); | 349 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(this.offset, this.result) :
super(); |
| 326 | 350 |
| 327 @override | 351 @override |
| 328 Object visitXmlAttributeNode(XmlAttributeNode node) { | 352 Object visitXmlAttributeNode(XmlAttributeNode node) { |
| 329 Token nameToken = node.nameToken; | 353 Token nameToken = node.nameToken; |
| 330 if (nameToken.offset <= offset && offset < nameToken.end) { | 354 if (nameToken.offset <= offset && offset <= nameToken.end) { |
| 331 result[0] = node; | 355 result[0] = node; |
| 332 throw new HtmlUnitUtils_FoundAttributeNodeError(); | 356 throw new HtmlUnitUtils_FoundAttributeNodeError(); |
| 333 } | 357 } |
| 334 return super.visitXmlAttributeNode(node); | 358 return super.visitXmlAttributeNode(node); |
| 335 } | 359 } |
| 336 } | 360 } |
| 337 | 361 |
| 362 class RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode extends RecursiveXml
Visitor<Object> { |
| 363 int offset = 0; |
| 364 |
| 365 List<XmlTagNode> result; |
| 366 |
| 367 RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(this.offset, this.result
) : super(); |
| 368 |
| 369 @override |
| 370 Object visitXmlTagNode(XmlTagNode node) { |
| 371 if (node.offset <= offset && offset < node.end) { |
| 372 result[0] = node; |
| 373 super.visitXmlTagNode(node); |
| 374 throw new HtmlUnitUtils_FoundTagNodeError(); |
| 375 } |
| 376 return null; |
| 377 } |
| 378 } |
| 379 |
| 338 class ExpressionVisitor_HtmlUnitUtils_getExpression extends ExpressionVisitor { | 380 class ExpressionVisitor_HtmlUnitUtils_getExpression extends ExpressionVisitor { |
| 339 int offset = 0; | 381 int offset = 0; |
| 340 | 382 |
| 341 List<Expression> result; | 383 List<Expression> result; |
| 342 | 384 |
| 343 ExpressionVisitor_HtmlUnitUtils_getExpression(this.offset, this.result) : supe
r(); | 385 ExpressionVisitor_HtmlUnitUtils_getExpression(this.offset, this.result) : supe
r(); |
| 344 | 386 |
| 345 @override | 387 @override |
| 346 void visitExpression(Expression expression) { | 388 void visitExpression(Expression expression) { |
| 347 Expression at = HtmlUnitUtils._getExpressionAt(expression, offset); | 389 Expression at = HtmlUnitUtils._getExpressionAt(expression, offset); |
| 348 if (at != null) { | 390 if (at != null) { |
| 349 result[0] = at; | 391 result[0] = at; |
| 350 throw new HtmlUnitUtils_FoundExpressionError(); | 392 throw new HtmlUnitUtils_FoundExpressionError(); |
| 351 } | 393 } |
| 352 } | 394 } |
| 353 } | 395 } |
| 354 | 396 |
| 355 class RecursiveXmlVisitor_HtmlUnitUtils_getTagNode extends RecursiveXmlVisitor<O
bject> { | |
| 356 int offset = 0; | |
| 357 | |
| 358 List<XmlTagNode> result; | |
| 359 | |
| 360 RecursiveXmlVisitor_HtmlUnitUtils_getTagNode(this.offset, this.result) : super
(); | |
| 361 | |
| 362 @override | |
| 363 Object visitXmlTagNode(XmlTagNode node) { | |
| 364 super.visitXmlTagNode(node); | |
| 365 Token tagToken = node.tagToken; | |
| 366 if (tagToken.offset <= offset && offset < tagToken.end) { | |
| 367 result[0] = node; | |
| 368 throw new HtmlUnitUtils_FoundTagNodeError(); | |
| 369 } | |
| 370 return null; | |
| 371 } | |
| 372 } | |
| 373 | |
| 374 /** | 397 /** |
| 375 * Instances of the class `HtmlScriptTagNode` represent a script tag within an H
TML file that | 398 * Instances of the class `HtmlScriptTagNode` represent a script tag within an H
TML file that |
| 376 * references a Dart script. | 399 * references a Dart script. |
| 377 */ | 400 */ |
| 378 class HtmlScriptTagNode extends XmlTagNode { | 401 class HtmlScriptTagNode extends XmlTagNode { |
| 379 /** | 402 /** |
| 380 * The AST structure representing the Dart code within this tag. | 403 * The AST structure representing the Dart code within this tag. |
| 381 */ | 404 */ |
| 382 CompilationUnit _script; | 405 CompilationUnit _script; |
| 383 | 406 |
| (...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 super.element = element; | 2030 super.element = element; |
| 2008 } | 2031 } |
| 2009 | 2032 |
| 2010 @override | 2033 @override |
| 2011 void visitChildren(XmlVisitor visitor) { | 2034 void visitChildren(XmlVisitor visitor) { |
| 2012 for (XmlTagNode node in _tagNodes) { | 2035 for (XmlTagNode node in _tagNodes) { |
| 2013 node.accept(visitor); | 2036 node.accept(visitor); |
| 2014 } | 2037 } |
| 2015 } | 2038 } |
| 2016 } | 2039 } |
| OLD | NEW |