| 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 library context.directory.manager; | 5 library context.directory.manager; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/resource.dart'; | 10 import 'package:analysis_server/src/resource.dart'; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // TODO(paulberry): handle removing pubspec.yaml | 127 // TODO(paulberry): handle removing pubspec.yaml |
| 128 Source source = info.sources[event.path]; | 128 Source source = info.sources[event.path]; |
| 129 if (source != null) { | 129 if (source != null) { |
| 130 ChangeSet changeSet = new ChangeSet(); | 130 ChangeSet changeSet = new ChangeSet(); |
| 131 changeSet.removedSource(source); | 131 changeSet.removedSource(source); |
| 132 applyChangesToContext(folder, changeSet); | 132 applyChangesToContext(folder, changeSet); |
| 133 info.sources.remove(event.path); | 133 info.sources.remove(event.path); |
| 134 } | 134 } |
| 135 break; | 135 break; |
| 136 case ChangeType.MODIFY: | 136 case ChangeType.MODIFY: |
| 137 // TODO(paulberry): handle modification events | 137 Source source = info.sources[event.path]; |
| 138 if (source != null) { |
| 139 ChangeSet changeSet = new ChangeSet(); |
| 140 // TODO(paulberry): technically we should skip calling changedSource() |
| 141 // for files that currently have their contents overridden. However, |
| 142 // it's hard to figure out which files have their contents overridden |
| 143 // (this info isn't exposed through the AnalysisContext interface), |
| 144 // and besides, if we go ahead and call changedSource() we get the |
| 145 // behavior we want (the context continues consulting the overridden |
| 146 // file contents). |
| 147 changeSet.changedSource(source); |
| 148 applyChangesToContext(folder, changeSet); |
| 149 } |
| 138 break; | 150 break; |
| 139 } | 151 } |
| 140 } | 152 } |
| 141 | 153 |
| 142 /** | 154 /** |
| 143 * Determine if the path from [folder] to [path] contains a 'packages' | 155 * Determine if the path from [folder] to [path] contains a 'packages' |
| 144 * directory. | 156 * directory. |
| 145 */ | 157 */ |
| 146 bool _isInPackagesDir(String path, Folder folder) { | 158 bool _isInPackagesDir(String path, Folder folder) { |
| 147 String relativePath = resourceProvider.pathContext.relative(path, from: fold
er.path); | 159 String relativePath = resourceProvider.pathContext.relative(path, from: fold
er.path); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 * some of those files have been modified). [changeSet] is the set of | 206 * some of those files have been modified). [changeSet] is the set of |
| 195 * changes that need to be applied to the context. | 207 * changes that need to be applied to the context. |
| 196 */ | 208 */ |
| 197 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); | 209 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); |
| 198 | 210 |
| 199 /** | 211 /** |
| 200 * Remove the context associated with the given [folder]. | 212 * Remove the context associated with the given [folder]. |
| 201 */ | 213 */ |
| 202 void removeContext(Folder folder); | 214 void removeContext(Folder folder); |
| 203 } | 215 } |
| OLD | NEW |