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

Unified Diff: pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart

Issue 3004273002: Dart Kythe indexer refactoring to gather all variable declaration logic into one method (Closed)
Patch Set: Created 3 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
diff --git a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
index c1ddcdb98230141b3be418bbd396e87181e9ff09..a65647cea73746059c81d0d678f0d537687aec79 100644
--- a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
+++ b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
@@ -431,27 +431,9 @@ class KytheDartVisitor extends GeneralizingAstVisitor with OutputUtils {
@override
visitDeclaredIdentifier(DeclaredIdentifier node) {
- // variable
- var variableVName = addNodeAndFacts(schema.VARIABLE_KIND,
- element: node.element,
+ _handleVariableDeclaration(node.element, node.identifier,
subKind: schema.LOCAL_SUBKIND,
- completeFact: schema.DEFINITION);
-
- // anchor
- addAnchorEdgesContainingEdge(
- syntacticEntity: node.identifier,
- edges: [
- schema.DEFINES_BINDING_EDGE,
- ],
- target: variableVName,
- enclosingTarget: _enclosingVName);
-
- // type
- addEdge(
- variableVName,
- schema.TYPED_EDGE,
- _vNameFromType(
- resolutionMap.elementDeclaredByDeclaredIdentifier(node).type));
+ type: resolutionMap.elementDeclaredByDeclaredIdentifier(node).type);
// no children
}
@@ -619,16 +601,8 @@ class KytheDartVisitor extends GeneralizingAstVisitor with OutputUtils {
if (prefixIdentifier != null) {
// variable
- var variableVName = addNodeAndFacts(schema.VARIABLE_KIND,
- element: prefixIdentifier.staticElement,
- completeFact: schema.DEFINITION);
-
- // anchor
- addAnchorEdgesContainingEdge(
- syntacticEntity: prefixIdentifier,
- edges: [schema.DEFINES_BINDING_EDGE],
- target: variableVName,
- enclosingTarget: _enclosingVName);
+ _handleVariableDeclaration(
+ prefixIdentifier.staticElement, prefixIdentifier);
}
// visit children
@@ -865,31 +839,13 @@ class KytheDartVisitor extends GeneralizingAstVisitor with OutputUtils {
@override
visitVariableDeclaration(VariableDeclaration node) {
- // level variable
var isLocal = _enclosingVName != _enclosingClassVName &&
_enclosingVName != _enclosingFileVName;
// variable
- var variableVName = addNodeAndFacts(schema.VARIABLE_KIND,
- element: node.element,
+ _handleVariableDeclaration(node.element, node.name,
subKind: isLocal ? schema.LOCAL_SUBKIND : schema.FIELD_SUBKIND,
- completeFact: schema.DEFINITION);
-
- // anchor
- addAnchorEdgesContainingEdge(
- syntacticEntity: node.name,
- edges: [
- schema.DEFINES_BINDING_EDGE,
- ],
- target: variableVName,
- enclosingTarget: _enclosingVName);
-
- // type
- addEdge(
- variableVName,
- schema.TYPED_EDGE,
- _vNameFromType(
- resolutionMap.elementDeclaredByVariableDeclaration(node).type));
+ type: resolutionMap.elementDeclaredByVariableDeclaration(node).type);
// visit children
_safelyVisit(node.initializer);
@@ -1031,6 +987,28 @@ class KytheDartVisitor extends GeneralizingAstVisitor with OutputUtils {
// no children to visit
}
+ void _handleVariableDeclaration(
+ Element element, SyntacticEntity syntacticEntity,
+ {String subKind, DartType type}) {
+ // variable
+ var variableVName = addNodeAndFacts(schema.VARIABLE_KIND,
+ element: element, subKind: subKind, completeFact: schema.DEFINITION);
+
+ // anchor
+ addAnchorEdgesContainingEdge(
+ syntacticEntity: syntacticEntity,
+ edges: [
+ schema.DEFINES_BINDING_EDGE,
+ ],
+ target: variableVName,
+ enclosingTarget: _enclosingVName);
+
+ // type
+ if (type != null) {
+ addEdge(variableVName, schema.TYPED_EDGE, _vNameFromType(type));
+ }
+ }
+
/// Add a "ref/imports" edge from the passed [uriNode] location to the
/// [referencedElement] [Element]. If the passed element is null, the edge is
/// not written out.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698