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

Unified Diff: pkg/analysis_server/lib/src/services/index/index_contributor.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/search/search_engine_internal.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/index/index_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/index/index_contributor.dart b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
index 98d28f20b4db34978ac8ce2f09773aac5f792187..3159baf8b56344ad2623cd676a97d17d13830471 100644
--- a/pkg/analysis_server/lib/src/services/index/index_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/index/index_contributor.dart
@@ -39,7 +39,6 @@ void indexDartUnit(IndexStore store, AnalysisContext context,
}
// do index
unit.accept(new _IndexContributor(store));
- unit.accept(new _AngularDartIndexContributor(store));
store.doneIndex();
}
@@ -64,259 +63,11 @@ void indexHtmlUnit(IndexStore store, AnalysisContext context, ht.HtmlUnit unit)
return;
}
// do index
- unit.accept(new _AngularHtmlIndexContributor(store));
store.doneIndex();
}
/**
- * Visits resolved [CompilationUnit] and adds Angular specific relationships
- * into [IndexStore].
- */
-class _AngularDartIndexContributor extends GeneralizingAstVisitor<Object> {
- final IndexStore _store;
-
- _AngularDartIndexContributor(this._store);
-
- @override
- Object visitClassDeclaration(ClassDeclaration node) {
- ClassElement classElement = node.element;
- if (classElement != null) {
- List<ToolkitObjectElement> toolkitObjects = classElement.toolkitObjects;
- for (ToolkitObjectElement object in toolkitObjects) {
- if (object is AngularComponentElement) {
- _indexComponent(object);
- }
- if (object is AngularDecoratorElement) {
- AngularDecoratorElement directive = object;
- _indexDirective(directive);
- }
- }
- }
- // stop visiting
- return null;
- }
-
- @override
- Object visitCompilationUnitMember(CompilationUnitMember node) => null;
-
- void _indexComponent(AngularComponentElement component) {
- _indexProperties(component.properties);
- }
-
- void _indexDirective(AngularDecoratorElement directive) {
- _indexProperties(directive.properties);
- }
-
- /**
- * Index [FieldElement] references from [AngularPropertyElement]s.
- */
- void _indexProperties(List<AngularPropertyElement> properties) {
- for (AngularPropertyElement property in properties) {
- FieldElement field = property.field;
- if (field != null) {
- int offset = property.fieldNameOffset;
- if (offset == -1) {
- continue;
- }
- int length = field.name.length;
- Location location = new Location(property, offset, length);
- // getter reference
- if (property.propertyKind.callsGetter()) {
- PropertyAccessorElement getter = field.getter;
- if (getter != null) {
- _store.recordRelationship(
- getter,
- IndexConstants.IS_REFERENCED_BY,
- location);
- }
- }
- // setter reference
- if (property.propertyKind.callsSetter()) {
- PropertyAccessorElement setter = field.setter;
- if (setter != null) {
- _store.recordRelationship(
- setter,
- IndexConstants.IS_REFERENCED_BY,
- location);
- }
- }
- }
- }
- }
-}
-
-
-/**
- * Visits resolved [HtmlUnit] and adds relationships into [IndexStore].
- */
-class _AngularHtmlIndexContributor extends _ExpressionVisitor {
- /**
- * The [IndexStore] to record relations into.
- */
- final IndexStore _store;
-
- /**
- * The index contributor used to index Dart [Expression]s.
- */
- _IndexContributor _indexContributor;
-
- HtmlElement _htmlUnitElement;
-
- /**
- * Initialize a newly created Angular HTML index contributor.
- *
- * [store] - the [IndexStore] to record relations into.
- */
- _AngularHtmlIndexContributor(this._store) {
- _indexContributor =
- new _AngularHtmlIndexContributor_forEmbeddedDart(_store, this);
- }
-
- @override
- void visitExpression(Expression expression) {
- // Formatter
- if (expression is SimpleIdentifier) {
- Element element = expression.bestElement;
- if (element is AngularElement) {
- _store.recordRelationship(
- element,
- IndexConstants.ANGULAR_REFERENCE,
- _createLocationForIdentifier(expression));
- return;
- }
- }
- // index as a normal Dart expression
- expression.accept(_indexContributor);
- }
-
- @override
- Object visitHtmlUnit(ht.HtmlUnit node) {
- _htmlUnitElement = node.element;
- CompilationUnitElement dartUnitElement =
- _htmlUnitElement.angularCompilationUnit;
- _indexContributor.enterScope(dartUnitElement);
- return super.visitHtmlUnit(node);
- }
-
- @override
- Object visitXmlAttributeNode(ht.XmlAttributeNode node) {
- Element element = node.element;
- if (element != null) {
- ht.Token nameToken = node.nameToken;
- Location location = _createLocationForToken(nameToken);
- _store.recordRelationship(
- element,
- IndexConstants.ANGULAR_REFERENCE,
- location);
- }
- return super.visitXmlAttributeNode(node);
- }
-
- @override
- Object visitXmlTagNode(ht.XmlTagNode node) {
- Element element = node.element;
- if (element != null) {
- // tag
- {
- ht.Token tagToken = node.tagToken;
- Location location = _createLocationForToken(tagToken);
- _store.recordRelationship(
- element,
- IndexConstants.ANGULAR_REFERENCE,
- location);
- }
- // maybe add closing tag range
- ht.Token closingTag = node.closingTag;
- if (closingTag != null) {
- Location location = _createLocationForToken(closingTag);
- _store.recordRelationship(
- element,
- IndexConstants.ANGULAR_CLOSING_TAG_REFERENCE,
- location);
- }
- }
- return super.visitXmlTagNode(node);
- }
-
- Location _createLocationForIdentifier(SimpleIdentifier identifier) =>
- new Location(_htmlUnitElement, identifier.offset, identifier.length);
-
- Location _createLocationForToken(ht.Token token) =>
- new Location(_htmlUnitElement, token.offset, token.length);
-}
-
-
-class _AngularHtmlIndexContributor_forEmbeddedDart extends _IndexContributor {
- final _AngularHtmlIndexContributor angularContributor;
-
- _AngularHtmlIndexContributor_forEmbeddedDart(IndexStore store,
- this.angularContributor)
- : super(store);
-
- @override
- Element peekElement() => angularContributor._htmlUnitElement;
-
- @override
- void recordRelationship(Element element, Relationship relationship,
- Location location) {
- AngularElement angularElement =
- AngularHtmlUnitResolver.getAngularElement(element);
- if (angularElement != null) {
- element = angularElement;
- relationship = IndexConstants.ANGULAR_REFERENCE;
- }
- super.recordRelationship(element, relationship, location);
- }
-}
-
-
-/**
- * Recursively visits an [HtmlUnit] and every embedded [Expression].
- */
-abstract class _ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> {
- /**
- * Visits the given [Expression]s embedded into tag or attribute.
- *
- * [expression] - the [Expression] to visit, not `null`
- */
- void visitExpression(Expression expression);
-
- @override
- Object visitXmlAttributeNode(ht.XmlAttributeNode node) {
- _visitExpressions(node.expressions);
- return super.visitXmlAttributeNode(node);
- }
-
- @override
- Object visitXmlTagNode(ht.XmlTagNode node) {
- _visitExpressions(node.expressions);
- return super.visitXmlTagNode(node);
- }
-
- /**
- * Visits [Expression]s of the given [XmlExpression]s.
- */
- void _visitExpressions(List<ht.XmlExpression> expressions) {
- for (ht.XmlExpression xmlExpression in expressions) {
- if (xmlExpression is AngularXmlExpression) {
- AngularXmlExpression angularXmlExpression = xmlExpression;
- List<Expression> dartExpressions =
- angularXmlExpression.expression.expressions;
- for (Expression dartExpression in dartExpressions) {
- visitExpression(dartExpression);
- }
- }
- if (xmlExpression is ht.RawXmlExpression) {
- ht.RawXmlExpression rawXmlExpression = xmlExpression;
- visitExpression(rawXmlExpression.expression);
- }
- }
- }
-}
-
-
-/**
* Visits a resolved AST and adds relationships into [IndexStore].
*/
class _IndexContributor extends GeneralizingAstVisitor<Object> {
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/search/search_engine_internal.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698