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

Unified Diff: editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java

Issue 16359011: Share DartSdk instance in Java-based CLI Dart Analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | tests/co19/co19-analyzer.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java
diff --git a/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java b/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java
index 9e3b17296dc2950543dc75529d625c691ea4c728..2339df50dafb0cfca99cf1ec7a13f5e67a395d6e 100644
--- a/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java
+++ b/editor/tools/plugins/com.google.dart.command.analyze/src/com/google/dart/command/analyze/AnalyzerImpl.java
@@ -34,6 +34,7 @@ import com.google.dart.engine.source.UriKind;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -42,6 +43,7 @@ import java.util.Set;
* Scans, parses, and analyzes a library.
*/
class AnalyzerImpl {
+ private static final HashMap<File, DartSdk> sdkMap = new HashMap<File, DartSdk>();
private static ErrorSeverity getMaxErrorSeverity(List<AnalysisError> errors) {
ErrorSeverity status = ErrorSeverity.NONE;
@@ -55,14 +57,24 @@ class AnalyzerImpl {
return status;
}
+ /**
+ * @return the new or cached instance of the {@link DartSdk} with the given directory.
+ */
+ private static DartSdk getSdk(File sdkDirectory) {
+ DartSdk sdk = sdkMap.get(sdkDirectory);
+ if (sdk == null) {
+ sdk = new DirectoryBasedDartSdk(sdkDirectory);
+ sdkMap.put(sdkDirectory, sdk);
+ }
+ return sdk;
+ }
+
private AnalyzerOptions options;
private DartSdk sdk;
public AnalyzerImpl(AnalyzerOptions options) {
this.options = options;
-
- // This sdk is shared between multiple runs of the analyzer.
- sdk = new DirectoryBasedDartSdk(options.getDartSdkPath());
+ this.sdk = getSdk(options.getDartSdkPath());
Brian Wilkerson 2013/06/04 16:45:11 I don't understand the need for this change. As fa
scheglov 2013/06/04 16:54:10 When we run with --batch, we use single process to
}
/**
« no previous file with comments | « no previous file | tests/co19/co19-analyzer.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698