Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/DartCore.java |
=================================================================== |
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/DartCore.java (revision 37568) |
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/DartCore.java (working copy) |
@@ -17,7 +17,7 @@ |
import com.google.dart.engine.error.ErrorCode; |
import com.google.dart.engine.index.Index; |
import com.google.dart.engine.index.IndexFactory; |
-import com.google.dart.engine.index.MemoryIndexStore; |
+import com.google.dart.engine.index.IndexStore; |
import com.google.dart.engine.sdk.DirectoryBasedDartSdk; |
import com.google.dart.engine.utilities.instrumentation.Instrumentation; |
import com.google.dart.engine.utilities.instrumentation.InstrumentationBuilder; |
@@ -52,6 +52,7 @@ |
import com.google.dart.tools.core.utilities.performance.PerformanceManager; |
import com.google.dart.tools.core.utilities.yaml.PubYamlUtils; |
+import org.apache.commons.lang3.StringUtils; |
import org.eclipse.core.resources.IContainer; |
import org.eclipse.core.resources.IFile; |
import org.eclipse.core.resources.IFolder; |
@@ -85,6 +86,7 @@ |
import java.io.FileReader; |
import java.io.FileWriter; |
import java.io.IOException; |
+import java.io.PrintStream; |
import java.io.PrintWriter; |
import java.io.StringWriter; |
import java.lang.management.ManagementFactory; |
@@ -173,6 +175,11 @@ |
public static final String EXTENSION_JS = "js"; |
/** |
+ * Preference for enabling Angular analysis. |
+ */ |
+ public static final String ENABLE_ANGULAR_ANALYSIS_PREFERENCE = "enableAngularAnalysis"; |
+ |
+ /** |
* Preference for the automatically running pub. |
*/ |
public static final String PUB_AUTO_RUN_PREFERENCE = "pubAutoRun"; |
@@ -286,6 +293,12 @@ |
public static final String BUILD_DART_FILE_NAME = "build.dart"; |
/** |
+ * Used by the {@link DartDebugUserAgentManager} to indicate whether the |
+ * allow remote connection dialog is open. |
+ */ |
+ public static boolean allowConnectionDialogOpen = false; |
+ |
+ /** |
* The shared message console instance. |
*/ |
private static final MessageConsole CONSOLE = new MessageConsoleImpl(); |
@@ -343,6 +356,11 @@ |
private static final Object analysisServerLock = new Object(); |
/** |
+ * The socket and process manager used by {@link #analysisServer}. |
+ */ |
+ private static StdioServerSocket analysisServerSocket; |
+ |
+ /** |
* Add the given listener for dart ignore changes to the Dart Model. Has no effect if an identical |
* listener is already registered. |
* |
@@ -463,8 +481,8 @@ |
if (analysisServer == null) { |
// TODO(scheglov) remove local analysis server |
// analysisServer = new com.google.dart.server.internal.local.LocalAnalysisServerImpl(); |
- File sdkDirectory = DirectoryBasedDartSdk.getDefaultSdkDirectory(); |
- if (sdkDirectory == null) { |
+ DartSdkManager sdkManager = DartSdkManager.getManager(); |
+ if (!sdkManager.hasSdk()) { |
DartCore.logError("Add the dart sdk (com.google.dart.sdk) as a JVM argument"); |
System.exit(1); |
} |
@@ -473,14 +491,28 @@ |
DartCore.logError("Add the dart svnRoot (com.google.dart.svnRoot) as a JVM argument"); |
System.exit(1); |
} |
- String runtimePath = sdkDirectory.getAbsolutePath() + "/bin/dart"; |
+ String runtimePath = sdkManager.getSdk().getVmExecutable().getAbsolutePath(); |
String analysisServerPath = svnRoot + "/pkg/analysis_server/bin/server.dart"; |
try { |
- StdioServerSocket socket = new StdioServerSocket(runtimePath, analysisServerPath); |
- socket.start(); |
+ // prepare debug stream |
+ PrintStream debugStream; |
+ { |
+ String logPath = DartCoreDebug.ANALYSIS_SERVER_LOG_FILE; |
+ if (StringUtils.isBlank(logPath)) { |
+ debugStream = null; |
+ } else if ("console".equals(logPath)) { |
+ debugStream = System.out; |
+ } else { |
+ debugStream = new PrintStream(logPath); |
+ } |
+ } |
+ // start server |
+ analysisServerSocket = new StdioServerSocket(runtimePath, analysisServerPath, debugStream); |
+ analysisServerSocket.start(); |
analysisServer = new com.google.dart.server.internal.remote.RemoteAnalysisServerImpl( |
- socket.getRequestSink(), |
- socket.getResponseStream()); |
+ analysisServerSocket.getRequestSink(), |
+ analysisServerSocket.getResponseStream(), |
+ analysisServerSocket.getErrorStream()); |
analysisServerDataImpl.setServer(analysisServer); |
analysisServer.addAnalysisServerListener(analysisServerListener); |
} catch (Throwable e) { |
@@ -720,7 +752,10 @@ |
// start index |
final Index index; |
{ |
- MemoryIndexStore indexStore = IndexFactory.newMemoryIndexStore(); |
+ File stateDir = getPlugin().getStateLocation().toFile(); |
+ File indexDir = new File(stateDir, "index"); |
+ indexDir.mkdirs(); |
+ IndexStore indexStore = IndexFactory.newFileIndexStore(indexDir); |
index = IndexFactory.newIndex(indexStore); |
Thread thread = new Thread() { |
@Override |
@@ -1622,6 +1657,10 @@ |
return projectScope.getNode(PLUGIN_ID); |
} |
+ public boolean isAngularAnalysisEnabled() { |
+ return DartCore.getPlugin().getPrefs().getBoolean(ENABLE_ANGULAR_ANALYSIS_PREFERENCE, true); |
+ } |
+ |
public boolean isAutoRunPubEnabled() { |
return DartCore.getPlugin().getPrefs().getBoolean(PUB_AUTO_RUN_PREFERENCE, true); |
} |
@@ -1737,6 +1776,7 @@ |
synchronized (analysisServerLock) { |
if (analysisServer != null) { |
analysisServer.shutdown(); |
+ analysisServerSocket.stop(); |
} |
} |