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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisServer.java

Issue 10883074: Update scan, changed and discard to handle "packages" and "pubspec.yaml" (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/Context.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisServer.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisServer.java (revision 11962)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/AnalysisServer.java (working copy)
@@ -139,13 +139,14 @@
}
/**
- * Called when a file or directory has been added or removed or file content has been modified.
+ * Called when file content has been modified or anything in the "packages" directory has changed.
* Use {@link #discard(File)} if the file or directory content should no longer be analyzed.
*
* @param file the file or directory (not <code>null</code>)
*/
public void changed(File file) {
- queueNewTask(new FileChangedTask(this, savedContext, file));
+ file = file.getAbsoluteFile();
+ queueNewTask(new FileChangedTask(this, file));
}
/**
@@ -157,27 +158,21 @@
file = file.getAbsoluteFile();
// If this is a dart file, then discard the library
-
- if (file.isFile() || (!file.exists() && DartCore.isDartLikeFileName(file.getName()))) {
- synchronized (libraryFiles) {
- if (libraryFiles.remove(file)) {
- queueNewTask(new DiscardTask(this, file));
+ // otherwise, discard all libraries in the specified directory tree
+ synchronized (libraryFiles) {
+ if (file.isFile() || (!file.exists() && DartCore.isDartLikeFileName(file.getName()))) {
+ libraryFiles.remove(file);
+ } else {
+ Iterator<File> iter = libraryFiles.iterator();
+ while (iter.hasNext()) {
+ if (equalsOrContains(file, iter.next())) {
+ iter.remove();
+ }
}
}
- return;
}
- // Otherwise, discard all libraries in the specified directory tree
-
- synchronized (libraryFiles) {
- Iterator<File> iter = libraryFiles.iterator();
- while (iter.hasNext()) {
- if (equalsOrContains(file, iter.next())) {
- iter.remove();
- }
- }
- queueNewTask(new DiscardTask(this, file));
- }
+ queueNewTask(new DiscardTask(this, file));
}
/**
@@ -203,6 +198,25 @@
}
/**
+ * TESTING: Answer <code>true</code> if information about the specified library is cached
+ *
+ * @param file the library file (not <code>null</code>)
+ */
+ public boolean isLibraryCached(File file) {
+ return savedContext.getCachedLibrary(file) != null;
+ }
+
+ /**
+ * TESTING: Answer <code>true</code> if specified library has been resolved
+ *
+ * @param file the library file (not <code>null</code>)
+ */
+ public boolean isLibraryResolved(File file) {
+ Library library = savedContext.getCachedLibrary(file);
+ return library != null && library.getLibraryUnit() != null;
+ }
+
+ /**
* Reload the cached information from the previous session. This method must be called before
* {@link #start()} has been called when the server is not yet running.
*
@@ -233,10 +247,12 @@
}
/**
- * Called when all cached information should be discarded and all libraries reanalyzed
+ * Called when all cached information should be discarded and all libraries reanalyzed. No
+ * {@link AnalysisListener#discarded(AnalysisEvent)} events are sent when the information is
+ * discarded.
*/
public void reanalyze() {
- queueNewTask(new EverythingChangedTask(this, savedContext));
+ queueNewTask(new EverythingChangedTask(this));
}
public void removeIdleListener(IdleListener listener) {
@@ -264,7 +280,20 @@
* @param callback for reporting progress and canceling the operation.
*/
public void scan(File file, ScanCallback callback) {
- queueNewTask(new ScanTask(this, savedContext, file, callback));
+ file = file.getAbsoluteFile();
+
+ // If scanning a "packages" directory, then assume that the packages directory has just been
+ // added and create a new application context if one does not already exist
+ if (DartCore.isPackagesDirectory(file)) {
+ File appDir = file.getParentFile();
+ queueNewTask(new DiscardTask(this, appDir));
+ queueNewTask(new ScanTask(this, appDir, callback));
+ }
+
+ // Otherwise scan the file/directory
+ else {
+ queueNewTask(new ScanTask(this, file, callback));
+ }
}
/**
@@ -421,27 +450,6 @@
}
/**
- * TESTING: Answer <code>true</code> if information about the specified library is cached
- *
- * @param file the library file (not <code>null</code>)
- */
- @SuppressWarnings("unused")
- private boolean isLibraryCached(File file) {
- return savedContext.getCachedLibrary(file) != null;
- }
-
- /**
- * TESTING: Answer <code>true</code> if specified library has been resolved
- *
- * @param file the library file (not <code>null</code>)
- */
- @SuppressWarnings("unused")
- private boolean isLibraryResolved(File file) {
- Library library = savedContext.getCachedLibrary(file);
- return library != null && library.getLibraryUnit() != null;
- }
-
- /**
* Reload the cached information from the specified file. This method must be called before
* {@link #start()} has been called when the server is not yet running.
*
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/Context.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698