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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1577413002: Patch together getters/setters in different parts. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index df4e7acf804d283a6cbc263380fea2b4e94e1ace..3d511451a1a3b0c989925e36781a01c556354741 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -1488,9 +1488,7 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
for (Directive directive in directivesToResolve) {
directive.element = libraryElement;
}
- if (sourcedCompilationUnits.isNotEmpty) {
- _patchTopLevelAccessors(libraryElement);
- }
+ BuildLibraryElementUtils.patchTopLevelAccessors(libraryElement);
if (libraryDirective != null) {
_setDoc(libraryElement, libraryDirective);
}
@@ -1503,25 +1501,6 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
}
/**
- * Add all of the non-synthetic [getters] and [setters] defined in the given
- * [unit] that have no corresponding accessor to one of the given collections.
- */
- void _collectAccessors(Map<String, PropertyAccessorElement> getters,
- List<PropertyAccessorElement> setters, CompilationUnitElement unit) {
- for (PropertyAccessorElement accessor in unit.accessors) {
- if (accessor.isGetter) {
- if (!accessor.isSynthetic && accessor.correspondingSetter == null) {
- getters[accessor.displayName] = accessor;
- }
- } else {
- if (!accessor.isSynthetic && accessor.correspondingGetter == null) {
- setters.add(accessor);
- }
- }
- }
- }
-
- /**
* Return the top-level [FunctionElement] entry point, or `null` if the given
* [element] does not define an entry point.
*/
@@ -1553,33 +1532,6 @@ class BuildLibraryElementTask extends SourceBasedAnalysisTask {
}
/**
- * Look through all of the compilation units defined for the given [library],
- * looking for getters and setters that are defined in different compilation
- * units but that have the same names. If any are found, make sure that they
- * have the same variable element.
- */
- void _patchTopLevelAccessors(LibraryElementImpl library) {
- HashMap<String, PropertyAccessorElement> getters =
- new HashMap<String, PropertyAccessorElement>();
- List<PropertyAccessorElement> setters = <PropertyAccessorElement>[];
- _collectAccessors(getters, setters, library.definingCompilationUnit);
- for (CompilationUnitElement unit in library.parts) {
- _collectAccessors(getters, setters, unit);
- }
- for (PropertyAccessorElement setter in setters) {
- PropertyAccessorElement getter = getters[setter.displayName];
- if (getter != null) {
- TopLevelVariableElementImpl variable = getter.variable;
- TopLevelVariableElementImpl setterVariable = setter.variable;
- CompilationUnitElementImpl setterUnit = setterVariable.enclosingElement;
- setterUnit.replaceTopLevelVariable(setterVariable, variable);
- variable.setter = setter;
- (setter as PropertyAccessorElementImpl).variable = variable;
- }
- }
- }
-
- /**
* If the given [node] has a documentation comment, remember its content
* and range into the given [element].
*/

Powered by Google App Engine
This is Rietveld 408576698