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

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/DartCore.java

Issue 439933005: first incremental cut at editor without packages directories (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, the Dart project authors. 2 * Copyright (c) 2012, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 * @return <code>true</code> if the given resource should be analyzed 853 * @return <code>true</code> if the given resource should be analyzed
854 */ 854 */
855 public static boolean isAnalyzed(IResource resource) { 855 public static boolean isAnalyzed(IResource resource) {
856 return getProjectManager().getIgnoreManager().isAnalyzed(resource); 856 return getProjectManager().getIgnoreManager().isAnalyzed(resource);
857 } 857 }
858 858
859 /** 859 /**
860 * Return true if directory contains a "packages" directory and a "pubspec.yam l" file 860 * Return true if directory contains a "packages" directory and a "pubspec.yam l" file
861 */ 861 */
862 public static boolean isApplicationDirectory(File directory) { 862 public static boolean isApplicationDirectory(File directory) {
863 return containsPubspecFile(directory) && containsPackagesDirectory(directory ); 863 return containsPubspecFile(directory)
864 && (DartCoreDebug.NO_PUB_PACKAGES || containsPackagesDirectory(directory ));
864 } 865 }
865 866
866 /** 867 /**
867 * Return true if directory contains a "packages" directory and a "pubspec.yam l" file 868 * Return true if directory contains a "packages" directory and a "pubspec.yam l" file
868 */ 869 */
869 public static boolean isApplicationDirectory(IContainer container) { 870 public static boolean isApplicationDirectory(IContainer container) {
870 if (container.getLocation() == null) { 871 if (container.getLocation() == null) {
871 return false; 872 return false;
872 } 873 }
873 874
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 PubFolder pubFolder = DartCore.getProjectManager().getPubFolder(resource); 1047 PubFolder pubFolder = DartCore.getProjectManager().getPubFolder(resource);
1047 if (pubFolder == null) { 1048 if (pubFolder == null) {
1048 return false; 1049 return false;
1049 } 1050 }
1050 IPath pubPath = pubFolder.getResource().getFullPath(); 1051 IPath pubPath = pubFolder.getResource().getFullPath();
1051 // check if resource is in "packages" 1052 // check if resource is in "packages"
1052 IPath resourcePath = resource.getFullPath(); 1053 IPath resourcePath = resource.getFullPath();
1053 String[] segments = resourcePath.segments(); 1054 String[] segments = resourcePath.segments();
1054 for (int i = 1; i < segments.length - 1; i++) { 1055 for (int i = 1; i < segments.length - 1; i++) {
1055 String segment = segments[i]; 1056 String segment = segments[i];
1056 if (segment.equals("packages")) { 1057 if (segment.equals(PACKAGES_DIRECTORY_NAME)) {
1057 return !resourcePath.uptoSegment(i).equals(pubPath); 1058 return !resourcePath.uptoSegment(i).equals(pubPath);
1058 } 1059 }
1059 } 1060 }
1060 // not in "packages" 1061 // not in "packages"
1061 return false; 1062 return false;
1062 } 1063 }
1063 1064
1064 /** 1065 /**
1065 * @return {@code true} if the given resource is located in the "packages" sub -folder that 1066 * @return {@code true} if the given resource is located in the "packages" sub -folder that
1066 * corresponds to the enclosing package. 1067 * corresponds to the enclosing package.
1067 */ 1068 */
1068 public static boolean isInSelfLinkedPackageFolder(IResource resource) { 1069 public static boolean isInSelfLinkedPackageFolder(IResource resource) {
1069 if (resource == null) { 1070 if (resource == null) {
1070 return false; 1071 return false;
1071 } 1072 }
1072 try { 1073 try {
1073 // prepare "pub" folder 1074 // prepare "pub" folder
1074 PubFolder pubFolder = DartCore.getProjectManager().getPubFolder(resource); 1075 PubFolder pubFolder = DartCore.getProjectManager().getPubFolder(resource);
1075 if (pubFolder == null) { 1076 if (pubFolder == null) {
1076 return false; 1077 return false;
1077 } 1078 }
1078 // the name of the enclosing package 1079 // the name of the enclosing package
1079 String packageName = pubFolder.getPubspec().getName(); 1080 String packageName = pubFolder.getPubspec().getName();
1080 // check if resource is in "packages" and references the enclosing package 1081 // check if resource is in "packages" and references the enclosing package
1081 String[] segments = resource.getFullPath().segments(); 1082 String[] segments = resource.getFullPath().segments();
1082 for (int i = 0; i < segments.length - 1; i++) { 1083 for (int i = 0; i < segments.length - 1; i++) {
1083 String segment = segments[i]; 1084 String segment = segments[i];
1084 if (segment.equals("packages") && segments[i + 1].equals(packageName)) { 1085 if (segment.equals(PACKAGES_DIRECTORY_NAME) && segments[i + 1].equals(pa ckageName)) {
1085 return true; 1086 return true;
1086 } 1087 }
1087 } 1088 }
1088 } catch (Throwable e) { 1089 } catch (Throwable e) {
1089 // pubFolder.getPubspec() may fail 1090 // pubFolder.getPubspec() may fail
1090 return false; 1091 return false;
1091 } 1092 }
1092 // not a self-reference 1093 // not a self-reference
1093 return false; 1094 return false;
1094 } 1095 }
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 String metricsInfo = writer.toString(); 1752 String metricsInfo = writer.toString();
1752 if (metricsInfo.length() > 0) { 1753 if (metricsInfo.length() > 0) {
1753 getLog().log(new Status(Status.INFO, PLUGIN_ID, metricsInfo, null)); 1754 getLog().log(new Status(Status.INFO, PLUGIN_ID, metricsInfo, null));
1754 } 1755 }
1755 } 1756 }
1756 } finally { 1757 } finally {
1757 super.stop(context); 1758 super.stop(context);
1758 } 1759 }
1759 } 1760 }
1760 } 1761 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698