mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
translate events from VFS to jps server
This commit is contained in:
@@ -82,8 +82,10 @@ public class JpsServerManager implements ApplicationComponent{
|
||||
ApplicationManager.getApplication().executeOnPooledThread(runnable);
|
||||
}
|
||||
});
|
||||
private final ProjectManager myProjectManager;
|
||||
|
||||
public JpsServerManager(ProjectManager projectManager) {
|
||||
public JpsServerManager(final ProjectManager projectManager) {
|
||||
myProjectManager = projectManager;
|
||||
final String systemPath = PathManager.getSystemPath();
|
||||
File system = new File(systemPath);
|
||||
try {
|
||||
@@ -108,6 +110,40 @@ public class JpsServerManager implements ApplicationComponent{
|
||||
return ApplicationManager.getApplication().getComponent(JpsServerManager.class);
|
||||
}
|
||||
|
||||
public void notifyFilesChanged(Collection<String> paths) {
|
||||
sendNotification(paths, false);
|
||||
}
|
||||
|
||||
public void notifyFilesDeleted(Collection<String> paths) {
|
||||
sendNotification(paths, true);
|
||||
}
|
||||
|
||||
private void sendNotification(Collection<String> paths, final boolean isDeleted) {
|
||||
final Client client = myClient;
|
||||
if (client != null && client.isConnected()) {
|
||||
final Project[] openProjects = myProjectManager.getOpenProjects();
|
||||
if (openProjects.length > 0) {
|
||||
final Collection<String> changed, deleted;
|
||||
if (isDeleted) {
|
||||
changed = Collections.emptyList();
|
||||
deleted = paths;
|
||||
}
|
||||
else {
|
||||
changed = paths;
|
||||
deleted = Collections.emptyList();
|
||||
}
|
||||
for (Project project : openProjects) {
|
||||
try {
|
||||
client.sendFSEvent(project.getLocation(), changed, deleted);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Future submitCompilationTask(final String projectId, final List<String> modules, final boolean rebuild, final JpsServerResponseHandler handler) {
|
||||
final Ref<RequestFuture> futureRef = new Ref<RequestFuture>(null);
|
||||
@@ -309,8 +345,6 @@ public class JpsServerManager implements ApplicationComponent{
|
||||
// commandLine.add((launcherUsed? "-J" : "") + "-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + CharsetToolkit.getDefaultSystemCharset().name());
|
||||
//}
|
||||
|
||||
|
||||
|
||||
private Process launchServer(int port) throws ExecutionException {
|
||||
final Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
|
||||
final GeneralCommandLine cmdLine = new GeneralCommandLine();
|
||||
@@ -331,7 +365,7 @@ public class JpsServerManager implements ApplicationComponent{
|
||||
|
||||
// debugging
|
||||
cmdLine.addParameter("-XX:+HeapDumpOnOutOfMemoryError");
|
||||
//cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5008");
|
||||
cmdLine.addParameter("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5008");
|
||||
|
||||
// javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
|
||||
final String lang = System.getProperty("user.language");
|
||||
|
||||
+21
@@ -18,6 +18,7 @@ package com.intellij.compiler.impl;
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerIOUtil;
|
||||
import com.intellij.compiler.JpsServerManager;
|
||||
import com.intellij.compiler.make.MakeUtil;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -1298,9 +1299,13 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
|
||||
final Set<String> pathsToMark = new HashSet<String>();
|
||||
|
||||
processRecursively(eventFile, true, new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
final String filePath = file.getPath();
|
||||
pathsToMark.add(filePath);
|
||||
try {
|
||||
final OutputFileInfo outputInfo = loadOutputInfo(file);
|
||||
if (outputInfo != null) {
|
||||
@@ -1360,6 +1365,10 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!pathsToMark.isEmpty()) {
|
||||
JpsServerManager.getInstance().notifyFilesDeleted(pathsToMark);
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeFileMovement(final VirtualFileMoveEvent event) {
|
||||
@@ -1367,10 +1376,14 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
private void markDirtyIfSource(final VirtualFile file) {
|
||||
final Set<String> pathsToMark = new HashSet<String>();
|
||||
processRecursively(file, false, new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
final SourceFileInfo srcInfo = file.isValid()? loadSourceInfo(file) : null;
|
||||
if (srcInfo != null) {
|
||||
|
||||
pathsToMark.add(file.getPath());
|
||||
|
||||
for (int projectId : srcInfo.getProjectIds().toArray()) {
|
||||
addSourceForRecompilation(projectId, file, srcInfo);
|
||||
}
|
||||
@@ -1380,9 +1393,13 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!pathsToMark.isEmpty()) {
|
||||
JpsServerManager.getInstance().notifyFilesChanged(pathsToMark);
|
||||
}
|
||||
}
|
||||
|
||||
private void processNewFile(final VirtualFile file) {
|
||||
final Set<String> pathsToMark = new HashSet<String>();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
// need read action to ensure that the project was not disposed during the iteration over the project list
|
||||
public void run() {
|
||||
@@ -1396,6 +1413,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
final TranslatingCompiler[] translators = CompilerManager.getInstance(project).getCompilers(TranslatingCompiler.class);
|
||||
processRecursively(file, false, new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
pathsToMark.add(file.getPath());
|
||||
if (isCompilable(file)) {
|
||||
loadInfoAndAddSourceForRecompilation(projectId, file);
|
||||
}
|
||||
@@ -1423,6 +1441,9 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!pathsToMark.isEmpty()) {
|
||||
JpsServerManager.getInstance().notifyFilesChanged(pathsToMark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package com.intellij.compiler.options;
|
||||
|
||||
import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.CompilerWorkspaceConfiguration;
|
||||
import com.intellij.compiler.MalformedPatternException;
|
||||
import com.intellij.compiler.*;
|
||||
import com.intellij.compiler.impl.TranslatingCompilerFilesMonitor;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
@@ -98,6 +95,9 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
|
||||
// this will schedule for compilation all files that might become compilable after resource patterns' changing
|
||||
TranslatingCompilerFilesMonitor.getInstance().scanSourcesForCompilableFiles(myProject);
|
||||
if (!workspaceConfiguration.USE_COMPILE_SERVER) {
|
||||
JpsServerManager.getInstance().shutdownServer();
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyResourcePatterns(String extensionString, final CompilerConfigurationImpl configuration)
|
||||
|
||||
@@ -69,6 +69,14 @@ public class ProtoUtil {
|
||||
return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.RELOAD_PROJECT_COMMAND).setReloadProjectCommand(builder.build()).build();
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createFSEvent(String projectPath, Collection<String> changedPaths, Collection<String> deletedPaths) {
|
||||
final JpsRemoteProto.Message.Request.FSEvent.Builder builder = JpsRemoteProto.Message.Request.FSEvent.newBuilder();
|
||||
builder.setProjectId(projectPath);
|
||||
builder.addAllChangedPaths(changedPaths);
|
||||
builder.addAllDeletedPaths(deletedPaths);
|
||||
return JpsRemoteProto.Message.Request.newBuilder().setRequestType(JpsRemoteProto.Message.Request.Type.FS_EVENT).setFsEvent(builder.build()).build();
|
||||
}
|
||||
|
||||
public static JpsRemoteProto.Message.Request createSetupRequest(final Map<String, String> pathVars, List<GlobalLibrary> sdkAndLibs) {
|
||||
final JpsRemoteProto.Message.Request.SetupCommand.Builder cmdBuilder = JpsRemoteProto.Message.Request.SetupCommand.newBuilder();
|
||||
|
||||
|
||||
@@ -112,6 +112,12 @@ public class Client {
|
||||
return sendRequest(ProtoUtil.createReloadProjectRequest(projectPaths), null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RequestFuture sendFSEvent(String projectPath, Collection<String> changedPaths, Collection<String> deletedPaths) throws Exception {
|
||||
checkConnected();
|
||||
return sendRequest(ProtoUtil.createFSEvent(projectPath, changedPaths, deletedPaths), null);
|
||||
}
|
||||
|
||||
private void checkConnected() throws Exception {
|
||||
if (myState.get() != State.CONNECTED) {
|
||||
throw new Exception("Client not connected");
|
||||
|
||||
@@ -25,9 +25,9 @@ public class FSState {
|
||||
|
||||
public boolean markInitialScanPerformed(Module module, boolean forTests) {
|
||||
final Set<Module> map = forTests ? myInitialTestsScanPerformed : myInitialProductionScanPerformed;
|
||||
return map.add(module);
|
||||
// todo: temp comment
|
||||
//return map.add(module);
|
||||
return true;
|
||||
//return true;
|
||||
}
|
||||
|
||||
public void beforeNextRoundStart() {
|
||||
|
||||
Reference in New Issue
Block a user