| Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartProjectImpl.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartProjectImpl.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartProjectImpl.java
|
| index b4c49d0821a1a65e0e097e30761f587a17818c60..3931083f4a1f660fa18d6fe393cbc51a953fae31 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartProjectImpl.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartProjectImpl.java
|
| @@ -532,6 +532,18 @@ public class DartProjectImpl extends OpenableElementImpl implements DartProject
|
| return project;
|
| }
|
|
|
| + /**
|
| + * Returns the directory name in the packages folder that is linked to the "lib" folder in the
|
| + * project
|
| + */
|
| + public String getSelfLinkedPackageDirName() {
|
| + try {
|
| + return ((DartProjectInfo) getElementInfo()).getLinkedPackageDirName();
|
| + } catch (DartModelException e) {
|
| + return null;
|
| + }
|
| + }
|
| +
|
| @Override
|
| public IResource getUnderlyingResource() throws DartModelException {
|
| if (!exists()) {
|
| @@ -584,6 +596,42 @@ public class DartProjectImpl extends OpenableElementImpl implements DartProject
|
| }
|
| }
|
|
|
| + /**
|
| + * This should be called when the packages folder is created, deleted or changed so that the self
|
| + * link to source can be verified and updated.
|
| + */
|
| + public void recomputePackageInfo() {
|
| + try {
|
| + ((DartProjectInfo) getElementInfo()).setLinkedPackageDirName(null);
|
| + IResource packagesDirectory = project.findMember(DartCore.PACKAGES_DIRECTORY_NAME);
|
| + if (packagesDirectory != null && packagesDirectory.exists()) {
|
| + packagesDirectory.accept(new IResourceProxyVisitor() {
|
| +
|
| + @Override
|
| + public boolean visit(IResourceProxy proxy) throws CoreException {
|
| +
|
| + if (proxy.getType() == IResource.FOLDER) {
|
| + if (proxy.getName().equals(DartCore.PACKAGES_DIRECTORY_NAME)) {
|
| + return true;
|
| + }
|
| + IResource resource = proxy.requestResource();
|
| + if (DartCore.isSelfLinkedResource(resource.getProject(), resource)) {
|
| + ((DartProjectInfo) getElementInfo()).setLinkedPackageDirName(resource.getName());
|
| + return false;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| + }, 0);
|
| + }
|
| +
|
| + } catch (Exception exception) {
|
| + DartCore.logError(
|
| + "Could not traverse resource structure in project " + project.getLocation(),
|
| + exception);
|
| + }
|
| + }
|
| +
|
| @Override
|
| public boolean removeLibraryFile(IFile file) {
|
| boolean foundAndRemoved = false;
|
| @@ -754,6 +802,9 @@ public class DartProjectImpl extends OpenableElementImpl implements DartProject
|
| }
|
| }
|
| projectInfo.setChildren(children.toArray(new DartElementImpl[children.size()]));
|
| + // check for package self link
|
| + recomputePackageInfo();
|
| +
|
| return true;
|
| }
|
| // TODO(brianwilkerson) Remove the code below. It only exists for backward compatibility.
|
|
|