Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: pkg/analyzer/lib/src/generated/html.dart

Issue 844593003: Remove Angular support from the analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11
12 import 'ast.dart'; 12 import 'ast.dart';
13 import 'element.dart'; 13 import 'element.dart';
14 import 'engine.dart' show AnalysisEngine, AngularHtmlUnitResolver, 14 import 'engine.dart' show AnalysisEngine;
15 ExpressionVisitor;
16 import 'error.dart' show AnalysisErrorListener; 15 import 'error.dart' show AnalysisErrorListener;
17 import 'java_core.dart'; 16 import 'java_core.dart';
18 import 'java_engine.dart'; 17 import 'java_engine.dart';
19 import 'parser.dart' show Parser; 18 import 'parser.dart' show Parser;
20 import 'scanner.dart' as sc show Scanner, SubSequenceReader, Token; 19 import 'scanner.dart' as sc show Scanner, SubSequenceReader, Token;
21 import 'source.dart'; 20 import 'source.dart';
22 21
23 /** 22 /**
24 * The abstract class `AbstractScanner` implements a scanner for HTML code. Subc lasses are 23 * The abstract class `AbstractScanner` implements a scanner for HTML code. Subc lasses are
25 * required to implement the interface used to access the characters being scann ed. 24 * required to implement the interface used to access the characters being scann ed.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 _emitWithOffsetAndLength(TokenType.TAG, start, -1); 338 _emitWithOffsetAndLength(TokenType.TAG, start, -1);
340 } else { 339 } else {
341 // a non-char token 340 // a non-char token
342 _emitWithOffsetAndLength(TokenType.TEXT, start, 0); 341 _emitWithOffsetAndLength(TokenType.TEXT, start, 0);
343 c = advance(); 342 c = advance();
344 } 343 }
345 } 344 }
346 } 345 }
347 } 346 }
348 347
349 class ExpressionVisitor_HtmlUnitUtils_getExpression extends ExpressionVisitor {
350 final int offset;
351
352 Expression result;
353
354 ExpressionVisitor_HtmlUnitUtils_getExpression(this.offset);
355
356 @override
357 void visitExpression(Expression expression) {
358 Expression at = HtmlUnitUtils._getExpressionAt(expression, offset);
359 if (at != null) {
360 result = at;
361 throw new HtmlUnitUtils_FoundExpressionError();
362 }
363 }
364 }
365
366 /** 348 /**
367 * Instances of the class `HtmlParser` are used to parse tokens into a AST struc ture comprised 349 * Instances of the class `HtmlParser` are used to parse tokens into a AST struc ture comprised
368 * of [XmlNode]s. 350 * of [XmlNode]s.
369 */ 351 */
370 class HtmlParser extends XmlParser { 352 class HtmlParser extends XmlParser {
371 static String _APPLICATION_DART_IN_DOUBLE_QUOTES = "\"application/dart\""; 353 static String _APPLICATION_DART_IN_DOUBLE_QUOTES = "\"application/dart\"";
372 354
373 static String _APPLICATION_DART_IN_SINGLE_QUOTES = "'application/dart'"; 355 static String _APPLICATION_DART_IN_SINGLE_QUOTES = "'application/dart'";
374 356
375 static String _SCRIPT = "script"; 357 static String _SCRIPT = "script";
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 640
659 @override 641 @override
660 void visitChildren(XmlVisitor visitor) { 642 void visitChildren(XmlVisitor visitor) {
661 for (XmlTagNode node in _tagNodes) { 643 for (XmlTagNode node in _tagNodes) {
662 node.accept(visitor); 644 node.accept(visitor);
663 } 645 }
664 } 646 }
665 } 647 }
666 648
667 /** 649 /**
668 * Utilities locating [Expression]s and [Element]s in [HtmlUnit].
669 */
670 class HtmlUnitUtils {
671 /**
672 * Returns the [XmlAttributeNode] that is part of the given [HtmlUnit] and enc loses
673 * the given offset.
674 */
675 static XmlAttributeNode getAttributeNode(HtmlUnit htmlUnit, int offset) {
676 if (htmlUnit == null) {
677 return null;
678 }
679 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode visitor =
680 new RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(offset);
681 try {
682 htmlUnit.accept(visitor);
683 } on HtmlUnitUtils_FoundAttributeNodeError catch (e) {
684 return visitor.result;
685 }
686 return null;
687 }
688
689 /**
690 * Returns the best [Element] of the given [Expression].
691 */
692 static Element getElement(Expression expression) {
693 if (expression == null) {
694 return null;
695 }
696 return ElementLocator.locate(expression);
697 }
698
699 /**
700 * Returns the [Element] of the [Expression] in the given [HtmlUnit], enclosin g
701 * the given offset.
702 */
703 static Element getElementAtOffset(HtmlUnit htmlUnit, int offset) {
704 Expression expression = getExpression(htmlUnit, offset);
705 return getElement(expression);
706 }
707
708 /**
709 * Returns the [Element] to open when requested at the given [Expression].
710 */
711 static Element getElementToOpen(HtmlUnit htmlUnit, Expression expression) {
712 Element element = getElement(expression);
713 {
714 AngularElement angularElement =
715 AngularHtmlUnitResolver.getAngularElement(element);
716 if (angularElement != null) {
717 return angularElement;
718 }
719 }
720 return element;
721 }
722
723 /**
724 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and encloses the
725 * given offset.
726 */
727 static XmlTagNode getEnclosingTagNode(HtmlUnit htmlUnit, int offset) {
728 if (htmlUnit == null) {
729 return null;
730 }
731 RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode visitor =
732 new RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(offset);
733 try {
734 htmlUnit.accept(visitor);
735 } on HtmlUnitUtils_FoundTagNodeError catch (e) {
736 return visitor.result;
737 }
738 return null;
739 }
740
741 /**
742 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses the
743 * given offset.
744 */
745 static Expression getExpression(HtmlUnit htmlUnit, int offset) {
746 if (htmlUnit == null) {
747 return null;
748 }
749 ExpressionVisitor_HtmlUnitUtils_getExpression visitor =
750 new ExpressionVisitor_HtmlUnitUtils_getExpression(offset);
751 try {
752 // TODO(scheglov) this code is very Angular specific
753 htmlUnit.accept(visitor);
754 } on HtmlUnitUtils_FoundExpressionError catch (e) {
755 return visitor.result;
756 }
757 return null;
758 }
759
760 /**
761 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and its open or
762 * closing tag name encloses the given offset.
763 */
764 static XmlTagNode getTagNode(HtmlUnit htmlUnit, int offset) {
765 XmlTagNode node = getEnclosingTagNode(htmlUnit, offset);
766 // do we have an enclosing tag at all?
767 if (node == null) {
768 return null;
769 }
770 // is "offset" in the open tag?
771 Token openTag = node.tagToken;
772 if (openTag.offset <= offset && offset <= openTag.end) {
773 return node;
774 }
775 // is "offset" in the open tag?
776 Token closeTag = node.closingTag;
777 if (closeTag != null &&
778 closeTag.offset <= offset &&
779 offset <= closeTag.end) {
780 return node;
781 }
782 // not on a tag name
783 return null;
784 }
785
786 /**
787 * Returns the [Expression] that is part of the given root [AstNode] and enclo ses the
788 * given offset.
789 */
790 static Expression _getExpressionAt(AstNode root, int offset) {
791 if (root.offset <= offset && offset <= root.end) {
792 AstNode dartNode = new NodeLocator.con1(offset).searchWithin(root);
793 if (dartNode is Expression) {
794 return dartNode;
795 }
796 }
797 return null;
798 }
799 }
800
801 class HtmlUnitUtils_FoundAttributeNodeError extends Error {
802 }
803
804 class HtmlUnitUtils_FoundExpressionError extends Error {
805 }
806
807 class HtmlUnitUtils_FoundTagNodeError extends Error {
808 }
809
810 /**
811 * Implementation of [XmlExpression] for an [Expression] embedded without any wr apping
812 * characters.
813 */
814 class RawXmlExpression extends XmlExpression {
815 final Expression expression;
816
817 RawXmlExpression(this.expression);
818
819 @override
820 int get end => expression.end;
821
822 @override
823 int get length => expression.length;
824
825 @override
826 int get offset => expression.offset;
827
828 @override
829 XmlExpression_Reference getReference(int offset) {
830 AstNode node = new NodeLocator.con1(offset).searchWithin(expression);
831 if (node != null) {
832 Element element = ElementLocator.locate(node);
833 return new XmlExpression_Reference(element, node.offset, node.length);
834 }
835 return null;
836 }
837 }
838
839 /**
840 * Instances of the class `RecursiveXmlVisitor` implement an XML visitor that wi ll recursively 650 * Instances of the class `RecursiveXmlVisitor` implement an XML visitor that wi ll recursively
841 * visit all of the nodes in an XML structure. For example, using an instance of this class to visit 651 * visit all of the nodes in an XML structure. For example, using an instance of this class to visit
842 * a [XmlTagNode] will also cause all of the contained [XmlAttributeNode]s and 652 * a [XmlTagNode] will also cause all of the contained [XmlAttributeNode]s and
843 * [XmlTagNode]s to be visited. 653 * [XmlTagNode]s to be visited.
844 * 654 *
845 * Subclasses that override a visit method must either invoke the overridden vis it method or must 655 * Subclasses that override a visit method must either invoke the overridden vis it method or must
846 * explicitly ask the visited node to visit its children. Failure to do so will cause the children 656 * explicitly ask the visited node to visit its children. Failure to do so will cause the children
847 * of the visited node to not be visited. 657 * of the visited node to not be visited.
848 */ 658 */
849 class RecursiveXmlVisitor<R> implements XmlVisitor<R> { 659 class RecursiveXmlVisitor<R> implements XmlVisitor<R> {
(...skipping 15 matching lines...) Expand all
865 return null; 675 return null;
866 } 676 }
867 677
868 @override 678 @override
869 R visitXmlTagNode(XmlTagNode node) { 679 R visitXmlTagNode(XmlTagNode node) {
870 node.visitChildren(this); 680 node.visitChildren(this);
871 return null; 681 return null;
872 } 682 }
873 } 683 }
874 684
875 class RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode extends
876 RecursiveXmlVisitor<Object> {
877 final int offset;
878
879 XmlAttributeNode result;
880
881 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(this.offset);
882
883 @override
884 Object visitXmlAttributeNode(XmlAttributeNode node) {
885 Token nameToken = node.nameToken;
886 if (nameToken.offset <= offset && offset <= nameToken.end) {
887 result = node;
888 throw new HtmlUnitUtils_FoundAttributeNodeError();
889 }
890 return super.visitXmlAttributeNode(node);
891 }
892 }
893
894 class RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode extends
895 RecursiveXmlVisitor<Object> {
896 final int offset;
897
898 XmlTagNode result;
899
900 RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(this.offset);
901
902 @override
903 Object visitXmlTagNode(XmlTagNode node) {
904 if (node.offset <= offset && offset < node.end) {
905 result = node;
906 super.visitXmlTagNode(node);
907 throw new HtmlUnitUtils_FoundTagNodeError();
908 }
909 return null;
910 }
911 }
912
913 /** 685 /**
914 * Instances of the class `SimpleXmlVisitor` implement an AST visitor that will do nothing 686 * Instances of the class `SimpleXmlVisitor` implement an AST visitor that will do nothing
915 * when visiting an AST node. It is intended to be a superclass for classes that use the visitor 687 * when visiting an AST node. It is intended to be a superclass for classes that use the visitor
916 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel y visit a whole 688 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel y visit a whole
917 * structure) and that only need to visit a small number of node types. 689 * structure) and that only need to visit a small number of node types.
918 */ 690 */
919 class SimpleXmlVisitor<R> implements XmlVisitor<R> { 691 class SimpleXmlVisitor<R> implements XmlVisitor<R> {
920 @override 692 @override
921 R visitHtmlScriptTagNode(HtmlScriptTagNode node) => null; 693 R visitHtmlScriptTagNode(HtmlScriptTagNode node) => null;
922 694
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 */ 1918 */
2147 abstract class XmlVisitor<R> { 1919 abstract class XmlVisitor<R> {
2148 R visitHtmlScriptTagNode(HtmlScriptTagNode node); 1920 R visitHtmlScriptTagNode(HtmlScriptTagNode node);
2149 1921
2150 R visitHtmlUnit(HtmlUnit htmlUnit); 1922 R visitHtmlUnit(HtmlUnit htmlUnit);
2151 1923
2152 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode); 1924 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode);
2153 1925
2154 R visitXmlTagNode(XmlTagNode xmlTagNode); 1926 R visitXmlTagNode(XmlTagNode xmlTagNode);
2155 } 1927 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698