Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/sdk/DirectoryBasedDartSdk.java |
=================================================================== |
--- editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/sdk/DirectoryBasedDartSdk.java (revision 40542) |
+++ editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/sdk/DirectoryBasedDartSdk.java (working copy) |
@@ -103,6 +103,12 @@ |
private LibraryMap libraryMap; |
/** |
+ * The default SDK, or {@code null} if the default SDK either has not yet been created or cannot |
+ * be created for some reason. |
+ */ |
+ private static DirectoryBasedDartSdk DEFAULT_SDK; |
+ |
+ /** |
* The name of the directory within the SDK directory that contains executables. |
*/ |
private static final String BIN_DIRECTORY_NAME = "bin"; //$NON-NLS-1$ |
@@ -212,11 +218,14 @@ |
* @return the default Dart SDK |
*/ |
public static DirectoryBasedDartSdk getDefaultSdk() { |
- File sdkDirectory = getDefaultSdkDirectory(); |
- if (sdkDirectory == null) { |
- return null; |
+ if (DEFAULT_SDK == null) { |
+ File sdkDirectory = getDefaultSdkDirectory(); |
+ if (sdkDirectory == null) { |
+ return null; |
+ } |
+ DEFAULT_SDK = new DirectoryBasedDartSdk(sdkDirectory); |
} |
- return new DirectoryBasedDartSdk(sdkDirectory); |
+ return DEFAULT_SDK; |
} |
/** |