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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/pub/PubBuildParticipant.java

Issue 11735003: show package version information in Files View (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 12 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: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/pub/PubBuildParticipant.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/pub/PubBuildParticipant.java (revision 16570)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/pub/PubBuildParticipant.java (working copy)
@@ -20,14 +20,19 @@
import com.google.dart.tools.core.builder.BuildVisitor;
import com.google.dart.tools.core.builder.CleanEvent;
import com.google.dart.tools.core.internal.builder.DartBuilder;
+import com.google.dart.tools.core.utilities.yaml.PubYamlUtils;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import java.io.File;
+import java.util.Map;
+
/**
* This build participant has a higher priority and should be called by {@link DartBuilder} before
* the dart project is analyzed or build.dart is run. It will run pub install on any pubspec file
@@ -56,6 +61,9 @@
if (resource.getName().equals(DartCore.PUBSPEC_FILE_NAME)) {
runPub(resource.getParent(), monitor);
}
+ if (resource.getName().equals(DartCore.PUBSPEC_LOCK_FILE_NAME)) {
+ processLockFileContents(resource, resource.getProject(), monitor);
+ }
}
}
@@ -68,16 +76,50 @@
if (proxy.getName().equals(DartCore.PUBSPEC_FILE_NAME)) {
runPub(proxy.requestResource().getParent(), monitor);
}
+ if (proxy.getName().equals(DartCore.PUBSPEC_LOCK_FILE_NAME)) {
+ processLockFileContents(
+ proxy.requestResource(),
+ proxy.requestResource().getProject(),
+ monitor);
+ }
}
return true;
}
/**
+ * Process the lockfile to extract the version information, and save the information in the
+ * resource property DartCore.PUB_PACKAGE_VERSION
+ *
+ * @param lockFile the pubspec.lock file
+ * @param project containing the pubspec.lock file
+ * @param monitor the progress monitor
+ */
+ protected void processLockFileContents(IResource lockFile, IProject project,
+ IProgressMonitor monitor) {
+
+ Map<String, String> versionMap = PubYamlUtils.getPackageVersionMap(lockFile);
+ if (versionMap != null && !versionMap.isEmpty()) {
+ for (String key : versionMap.keySet()) {
+ IResource folder = lockFile.getParent().findMember(
+ DartCore.PACKAGES_DIRECTORY_NAME + File.separator + key);
devoncarew 2013/01/02 17:28:20 Instead of File.separator I think we want "/". I b
keertip 2013/01/02 17:43:16 Done.
+ if (folder != null) {
+ try {
+ folder.setPersistentProperty(DartCore.PUB_PACKAGE_VERSION, versionMap.get(key));
+ } catch (CoreException e) {
+ DartCore.logError(e);
+ }
+ }
+ }
+ PubManager.getInstance().notifyListeners(lockFile.getParent());
+ }
+ }
+
+ /**
* Execute the pub operation. This is overridden when testing this class to record the intent to
* run pub but prevent actually running pub.
*
- * @param container the workng directory in which pub should be run (not <code>null</code>)
+ * @param container the working directory in which pub should be run (not <code>null</code>)
* @param monitor the progress monitor (not <code>null</code>)
*/
protected void runPub(IContainer container, final IProgressMonitor monitor) {

Powered by Google App Engine
This is Rietveld 408576698