mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
Generated
+2
-2
@@ -1,11 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Netty">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/netty-3.3.1.Final.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/netty-3.4.0.Final.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/netty-3.3.1.Final-sources.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/src/netty-3.4.0.Final-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
Generated
+11
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="miglayout-swing">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/community/lib/miglayout-swing.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/community/lib/src/miglayout-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
@@ -1,5 +1,5 @@
|
||||
<component>
|
||||
<version codename="Community Edition" major="11" minor="1" eap="true" update-channel="IDEA11dot1EAP"/>
|
||||
<version codename="Community Edition" major="11" minor="2" eap="true" update-channel="IDEA11dot1EAP"/>
|
||||
|
||||
<build number="__BUILD_NUMBER__" date="__BUILD_DATE__"/>
|
||||
<install-over minbuild="0" maxbuild="0" version="10.5"/>
|
||||
|
||||
@@ -76,10 +76,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
@@ -91,26 +88,21 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
private static final String COMPILE_SERVER_SYSTEM_ROOT = "compile-server";
|
||||
private static final String LOGGER_CONFIG = "log.xml";
|
||||
private static final String DEFAULT_LOGGER_CONFIG = "defaultLogConfig.xml";
|
||||
private volatile ServerWrapper myProcessHandler;
|
||||
private volatile OSProcessHandler myProcessHandler;
|
||||
private final File mySystemDirectory;
|
||||
@Nullable
|
||||
private volatile CompileServerClient myClient;
|
||||
private final SequentialTaskExecutor myTaskExecutor = new SequentialTaskExecutor(new AsyncTaskExecutor() {
|
||||
@Override
|
||||
public void submit(Runnable runnable) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(runnable);
|
||||
}
|
||||
});
|
||||
private final ProjectManager myProjectManager;
|
||||
private static final int MAKE_TRIGGER_DELAY = 5 * 1000 /*5 seconds*/;
|
||||
private final Map<RequestFuture, Project> myAutomakeFutures = new HashMap<RequestFuture, Project>();
|
||||
private final CompileServerClasspathManager myClasspathManager = new CompileServerClasspathManager();
|
||||
private final AsyncTaskExecutor myAsyncExec = new AsyncTaskExecutor() {
|
||||
private final Executor myPooledThreadExecutor = new Executor() {
|
||||
@Override
|
||||
public void submit(Runnable runnable) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(runnable);
|
||||
public void execute(Runnable command) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(command);
|
||||
}
|
||||
};
|
||||
private final SequentialTaskExecutor myTaskExecutor = new SequentialTaskExecutor(myPooledThreadExecutor);
|
||||
|
||||
public CompileServerManager(final ProjectManager projectManager) {
|
||||
myProjectManager = projectManager;
|
||||
@@ -335,7 +327,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
public RequestFuture submitCompilationTask(final Project project, final boolean isRebuild, final boolean isMake,
|
||||
final Collection<String> modules, final Collection<String> artifacts,
|
||||
final Collection<String> paths,
|
||||
final Map<String, String> _userData, final JpsServerResponseHandler handler) {
|
||||
final Map<String, String> userData, final JpsServerResponseHandler handler) {
|
||||
final String projectId = getProjectPath(project);
|
||||
final Ref<RequestFuture> futureRef = new Ref<RequestFuture>(null);
|
||||
final RunnableFuture future = myTaskExecutor.submit(new Runnable() {
|
||||
@@ -344,16 +336,9 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
try {
|
||||
final CompileServerClient client = ensureServerRunningAndClientConnected(true);
|
||||
if (client != null) {
|
||||
final Map<String, String> userData = new LinkedHashMap<String, String>();
|
||||
if (!isRebuild) { //todo pass user data on rebuild as well?
|
||||
userData.putAll(_userData);
|
||||
}
|
||||
if (Registry.is("compiler.server.use.external.javac.process")) {
|
||||
userData.put(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION, "true");
|
||||
}
|
||||
final RequestFuture requestFuture = isRebuild ?
|
||||
client.sendRebuildRequest(projectId, handler, userData) :
|
||||
client.sendCompileRequest(isMake, projectId, modules, artifacts, paths, userData, handler);
|
||||
client.sendRebuildRequest(projectId, handler, userData) :
|
||||
client.sendCompileRequest(isMake, projectId, modules, artifacts, paths, userData, handler);
|
||||
futureRef.set(requestFuture);
|
||||
}
|
||||
else {
|
||||
@@ -397,9 +382,9 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
// executed in one thread at a time
|
||||
@Nullable
|
||||
private CompileServerClient ensureServerRunningAndClientConnected(boolean forceRestart) throws Throwable {
|
||||
final ServerWrapper ph = myProcessHandler;
|
||||
final OSProcessHandler ph = myProcessHandler;
|
||||
final CompileServerClient cl = myClient;
|
||||
final boolean processNotRunning = ph == null || ph.isDead();
|
||||
final boolean processNotRunning = ph == null || ph.isProcessTerminated() || ph.isProcessTerminating();
|
||||
final boolean clientNotConnected = cl == null || !cl.isConnected();
|
||||
|
||||
if (processNotRunning || clientNotConnected) {
|
||||
@@ -412,105 +397,89 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
return null;
|
||||
}
|
||||
|
||||
final File workDirectory = new File(mySystemDirectory, COMPILE_SERVER_SYSTEM_ROOT);
|
||||
workDirectory.mkdirs();
|
||||
ensureLogConfigExists(workDirectory);
|
||||
|
||||
final int port = NetUtils.findAvailableSocketPort();
|
||||
final long serverPingInterval = Registry.intValue("compiler.server.ping.interval", -1) * 1000L;
|
||||
ServerWrapper wrapper = Registry.is("compiler.server.in.process") ? launchServerThread(workDirectory, port) : launchServerProcess(port, serverPingInterval, workDirectory);
|
||||
final long serverPingInterval = Registry.intValue("compiler.server.ping.interval", -1) * 1000L;
|
||||
final Process process = launchServer(port, serverPingInterval);
|
||||
|
||||
CompileServerClient client = new CompileServerClient(serverPingInterval, myAsyncExec);
|
||||
final OSProcessHandler processHandler = new OSProcessHandler(process, null) {
|
||||
@Override
|
||||
protected boolean shouldDestroyProcessRecursively() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
final StringBuilder serverStartMessage = new StringBuilder();
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
processHandler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
// re-translate server's output to idea.log
|
||||
final String text = event.getText();
|
||||
if (!StringUtil.isEmpty(text)) {
|
||||
LOG.info("COMPILE_SERVER [" +outputType.toString() +"]: "+ text.trim());
|
||||
}
|
||||
}
|
||||
});
|
||||
processHandler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void processTerminated(ProcessEvent event) {
|
||||
try {
|
||||
processHandler.removeProcessListener(this);
|
||||
}
|
||||
finally {
|
||||
semaphore.up();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
if (outputType == ProcessOutputTypes.STDERR) {
|
||||
try {
|
||||
final String text = event.getText();
|
||||
if (text != null) {
|
||||
if (text.contains(Server.SERVER_SUCCESS_START_MESSAGE) || text.contains(Server.SERVER_ERROR_START_MESSAGE)) {
|
||||
processHandler.removeProcessListener(this);
|
||||
}
|
||||
if (serverStartMessage.length() > 0) {
|
||||
serverStartMessage.append("\n");
|
||||
}
|
||||
serverStartMessage.append(text);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
semaphore.up();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
processHandler.startNotify();
|
||||
semaphore.waitFor();
|
||||
|
||||
final String startupMsg = serverStartMessage.toString();
|
||||
if (!startupMsg.contains(Server.SERVER_SUCCESS_START_MESSAGE)) {
|
||||
throw new Exception("Server startup failed: " + startupMsg);
|
||||
}
|
||||
|
||||
CompileServerClient client = new CompileServerClient(serverPingInterval, myPooledThreadExecutor);
|
||||
boolean connected = false;
|
||||
try {
|
||||
connected = client.connect(NetUtils.getLocalHostString(), port);
|
||||
if (connected) {
|
||||
final RequestFuture setupFuture = sendSetupRequest(client);
|
||||
setupFuture.waitFor();
|
||||
myProcessHandler = wrapper;
|
||||
myProcessHandler = processHandler;
|
||||
myClient = client;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (!connected) {
|
||||
shutdownServer(cl, wrapper);
|
||||
shutdownServer(cl, processHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return myClient;
|
||||
}
|
||||
|
||||
private static ServerWrapper launchServerThread(final File workDirectory, final int port) {
|
||||
final Server server = new Server(workDirectory, Registry.is("compiler.server.use.memory.temp.cache"));
|
||||
//todo hostname
|
||||
server.start(port);
|
||||
return new ServerWrapper(null, server);
|
||||
}
|
||||
|
||||
private ServerWrapper launchServerProcess(int port, long serverPingInterval, File workDirectory) throws Exception {
|
||||
final Process process = launchServer(port, serverPingInterval, workDirectory);
|
||||
|
||||
final OSProcessHandler processHandler = new OSProcessHandler(process, null) {
|
||||
@Override
|
||||
protected boolean shouldDestroyProcessRecursively() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
final StringBuilder serverStartMessage = new StringBuilder();
|
||||
final Semaphore semaphore = new Semaphore();
|
||||
semaphore.down();
|
||||
processHandler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
// re-translate server's output to idea.log
|
||||
final String text = event.getText();
|
||||
if (!StringUtil.isEmpty(text)) {
|
||||
LOG.info("COMPILE_SERVER [" +outputType.toString() +"]: "+ text.trim());
|
||||
}
|
||||
}
|
||||
});
|
||||
processHandler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void processTerminated(ProcessEvent event) {
|
||||
try {
|
||||
processHandler.removeProcessListener(this);
|
||||
}
|
||||
finally {
|
||||
semaphore.up();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
if (outputType == ProcessOutputTypes.STDERR) {
|
||||
try {
|
||||
final String text = event.getText();
|
||||
if (text != null) {
|
||||
if (text.contains(Server.SERVER_SUCCESS_START_MESSAGE) || text.contains(Server.SERVER_ERROR_START_MESSAGE)) {
|
||||
processHandler.removeProcessListener(this);
|
||||
}
|
||||
if (serverStartMessage.length() > 0) {
|
||||
serverStartMessage.append("\n");
|
||||
}
|
||||
serverStartMessage.append(text);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
semaphore.up();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
processHandler.startNotify();
|
||||
semaphore.waitFor();
|
||||
|
||||
final String startupMsg = serverStartMessage.toString();
|
||||
if (!startupMsg.contains(Server.SERVER_SUCCESS_START_MESSAGE)) {
|
||||
throw new Exception("Server startup failed: " + startupMsg);
|
||||
}
|
||||
return new ServerWrapper(processHandler, null);
|
||||
}
|
||||
|
||||
private static RequestFuture sendSetupRequest(final @NotNull CompileServerClient client) throws Exception {
|
||||
final Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
@@ -593,7 +562,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
// commandLine.add((launcherUsed? "-J" : "") + "-D" + CharsetToolkit.FILE_ENCODING_PROPERTY + "=" + CharsetToolkit.getDefaultSystemCharset().name());
|
||||
//}
|
||||
|
||||
private Process launchServer(final int port, long pingInterval, File workDirectory) throws ExecutionException {
|
||||
private Process launchServer(final int port, long pingInterval) throws ExecutionException {
|
||||
// validate tools.jar presence
|
||||
final JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
|
||||
if (systemCompiler == null) {
|
||||
@@ -642,6 +611,9 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (Registry.is("compiler.server.use.memory.temp.cache")) {
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION + "=true");
|
||||
}
|
||||
if (Registry.is("compiler.server.use.external.javac.process")) {
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.USE_EXTERNAL_JAVAC_OPTION + "=true");
|
||||
}
|
||||
cmdLine.addParameter("-D"+ GlobalOptions.HOSTNAME_OPTION + "=" + NetUtils.getLocalHostString());
|
||||
|
||||
// javac's VM should use the same default locale that IDEA uses in order for javac to print messages in 'correct' language
|
||||
@@ -672,6 +644,10 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
cmdLine.addParameter(org.jetbrains.jps.server.Server.class.getName());
|
||||
cmdLine.addParameter(Integer.toString(port));
|
||||
|
||||
final File workDirectory = new File(mySystemDirectory, COMPILE_SERVER_SYSTEM_ROOT);
|
||||
workDirectory.mkdirs();
|
||||
ensureLogConfigExists(workDirectory);
|
||||
|
||||
cmdLine.addParameter(FileUtil.toSystemIndependentName(workDirectory.getPath()));
|
||||
|
||||
cmdLine.setWorkDirectory(workDirectory);
|
||||
@@ -711,7 +687,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
shutdownServer(myClient, myProcessHandler);
|
||||
}
|
||||
|
||||
private static void shutdownServer(final CompileServerClient client, final ServerWrapper processHandler) {
|
||||
private static void shutdownServer(final CompileServerClient client, final OSProcessHandler processHandler) {
|
||||
try {
|
||||
if (client != null && client.isConnected()) {
|
||||
final Future future = client.sendShutdownRequest();
|
||||
@@ -884,28 +860,4 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ServerWrapper {
|
||||
final @Nullable OSProcessHandler myHandler;
|
||||
final @Nullable Server myServer;
|
||||
|
||||
ServerWrapper(OSProcessHandler handler, Server server) {
|
||||
myHandler = handler;
|
||||
myServer = server;
|
||||
}
|
||||
|
||||
public void destroyProcess() {
|
||||
if (myHandler != null) {
|
||||
myHandler.destroyProcess();
|
||||
} else if (myServer != null) {
|
||||
myServer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDead() {
|
||||
return myHandler != null && (myHandler.isProcessTerminated() || myHandler.isProcessTerminating()) ||
|
||||
myServer != null && myServer.isStopped();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -284,9 +284,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
ContainerUtil.addIfNotNull(request, requestsToRemove);
|
||||
}
|
||||
|
||||
final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
|
||||
fileSystem.removeWatchedRoots(requestsToRemove);
|
||||
final Set<LocalFileSystem.WatchRequest> newRequests = fileSystem.addRootsToWatch(toAdd, true);
|
||||
Set<LocalFileSystem.WatchRequest> newRequests = LocalFileSystem.getInstance().replaceWatchedRoots(requestsToRemove, toAdd, true);
|
||||
for (LocalFileSystem.WatchRequest request : newRequests) {
|
||||
myWatchedOutputs.put(request.getRootPath(), request);
|
||||
}
|
||||
|
||||
+2
-1
@@ -31,13 +31,14 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class BuildArtifactsBeforeRunTask extends BeforeRunTask {
|
||||
public class BuildArtifactsBeforeRunTask extends BeforeRunTask<BuildArtifactsBeforeRunTask> {
|
||||
@NonNls public static final String NAME_ATTRIBUTE = "name";
|
||||
@NonNls public static final String ARTIFACT_ELEMENT = "artifact";
|
||||
private List<ArtifactPointer> myArtifactPointers = new ArrayList<ArtifactPointer>();
|
||||
private final Project myProject;
|
||||
|
||||
public BuildArtifactsBeforeRunTask(Project project) {
|
||||
super(BuildArtifactsBeforeRunTaskProvider.ID);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
|
||||
+67
-26
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.run;
|
||||
|
||||
import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.BeforeRunTaskProvider;
|
||||
import com.intellij.execution.RunManagerEx;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
@@ -33,6 +34,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.packaging.artifacts.*;
|
||||
import com.intellij.packaging.impl.artifacts.PlainArtifactType;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactAwareCompiler;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactCompileScope;
|
||||
import com.intellij.packaging.impl.compiler.ArtifactsCompiler;
|
||||
@@ -63,8 +65,8 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
public void artifactRemoved(@NotNull Artifact artifact) {
|
||||
final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
|
||||
for (RunConfiguration configuration : runManager.getAllConfigurations()) {
|
||||
final BuildArtifactsBeforeRunTask task = runManager.getBeforeRunTask(configuration, ID);
|
||||
if (task != null) {
|
||||
final List<BuildArtifactsBeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration, ID);
|
||||
for (BuildArtifactsBeforeRunTask task : tasks) {
|
||||
final String artifactName = artifact.getName();
|
||||
final List<ArtifactPointer> pointersList = task.getArtifactPointers();
|
||||
final ArtifactPointer[] pointers = pointersList.toArray(new ArtifactPointer[pointersList.size()]);
|
||||
@@ -83,18 +85,40 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
return ID;
|
||||
}
|
||||
|
||||
public String getDescription(RunConfiguration runConfiguration, BuildArtifactsBeforeRunTask task) {
|
||||
final List<ArtifactPointer> pointers = task.getArtifactPointers();
|
||||
if (!task.isEnabled() || pointers.isEmpty()) {
|
||||
return "Build Artifacts";
|
||||
}
|
||||
if (pointers.size() == 1) {
|
||||
return "Build '" + pointers.get(0).getArtifactName() + "' artifact";
|
||||
}
|
||||
return "Build " + pointers.size() + " artifacts";
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return PlainArtifactType.ARTIFACT_ICON;
|
||||
}
|
||||
|
||||
public boolean hasConfigurationButton() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return CompilerBundle.message("build.artifacts.before.run.description.empty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTaskIcon(BuildArtifactsBeforeRunTask task) {
|
||||
List<ArtifactPointer> pointers = task.getArtifactPointers();
|
||||
if (pointers == null || pointers.isEmpty())
|
||||
return getIcon();
|
||||
Artifact artifact = pointers.get(0).getArtifact();
|
||||
if (artifact == null)
|
||||
return getIcon();
|
||||
return artifact.getArtifactType().getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(BuildArtifactsBeforeRunTask task) {
|
||||
final List<ArtifactPointer> pointers = task.getArtifactPointers();
|
||||
if (!task.isEnabled() || pointers.isEmpty()) {
|
||||
return CompilerBundle.message("build.artifacts.before.run.description.empty");
|
||||
}
|
||||
if (pointers.size() == 1) {
|
||||
return CompilerBundle.message("build.artifacts.before.run.description.single", pointers.get(0).getArtifactName());
|
||||
}
|
||||
return CompilerBundle.message("build.artifacts.before.run.description.multiple", pointers.size());
|
||||
}
|
||||
|
||||
public boolean isConfigurable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -115,7 +139,7 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
chooser.setPreferredSize(new Dimension(400, 300));
|
||||
|
||||
DialogBuilder builder = new DialogBuilder(myProject);
|
||||
builder.setTitle("Select Artifacts");
|
||||
builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title"));
|
||||
builder.setDimensionServiceKey("#BuildArtifactsBeforeRunChooser");
|
||||
builder.addOkAction();
|
||||
builder.addCancelAction();
|
||||
@@ -128,6 +152,15 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecuteTask(RunConfiguration configuration, BuildArtifactsBeforeRunTask task) {
|
||||
for (ArtifactPointer pointer: task.getArtifactPointers()) {
|
||||
if (pointer.getArtifact() != null)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean executeTask(DataContext context, RunConfiguration configuration, final BuildArtifactsBeforeRunTask task) {
|
||||
final Ref<Boolean> result = Ref.create(false);
|
||||
final Semaphore finished = new Semaphore();
|
||||
@@ -170,27 +203,35 @@ public class BuildArtifactsBeforeRunTaskProvider extends BeforeRunTaskProvider<B
|
||||
final DataContext dataContext = DataManager.getInstance().getDataContext(runConfigurationEditorComponent);
|
||||
final ConfigurationSettingsEditorWrapper editor = ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.getData(dataContext);
|
||||
if (editor != null) {
|
||||
final BuildArtifactsBeforeRunTask task = (BuildArtifactsBeforeRunTask)editor.getStepsBeforeLaunch().get(ID);
|
||||
if (enable) {
|
||||
task.addArtifact(artifact);
|
||||
task.setEnabled(true);
|
||||
List<BeforeRunTask> tasks = editor.getStepsBeforeLaunch();
|
||||
List<BuildArtifactsBeforeRunTask> myTasks = new ArrayList<BuildArtifactsBeforeRunTask>();
|
||||
for (BeforeRunTask task : tasks) {
|
||||
if (task instanceof BuildArtifactsBeforeRunTask) {
|
||||
myTasks.add((BuildArtifactsBeforeRunTask)task);
|
||||
}
|
||||
}
|
||||
else {
|
||||
task.removeArtifact(artifact);
|
||||
if (task.getArtifactPointers().isEmpty()) {
|
||||
task.setEnabled(false);
|
||||
for (BuildArtifactsBeforeRunTask task : myTasks) {
|
||||
if (enable) {
|
||||
task.addArtifact(artifact);
|
||||
task.setEnabled(true);
|
||||
}
|
||||
else {
|
||||
task.removeArtifact(artifact);
|
||||
if (task.getArtifactPointers().isEmpty()) {
|
||||
task.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.updateBeforeRunTaskPanel(ID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBuildArtifactBeforeRun(@NotNull Project project, @NotNull RunConfiguration configuration, @NotNull Artifact artifact) {
|
||||
RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
|
||||
final BuildArtifactsBeforeRunTask buildArtifactsTask = runManager.getBeforeRunTask(configuration, ID);
|
||||
if (buildArtifactsTask != null) {
|
||||
buildArtifactsTask.setEnabled(true);
|
||||
buildArtifactsTask.addArtifact(artifact);
|
||||
final List<BuildArtifactsBeforeRunTask> buildArtifactsTasks = runManager.getBeforeRunTasks(configuration, ID);
|
||||
for (BuildArtifactsBeforeRunTask task : buildArtifactsTasks) {
|
||||
task.setEnabled(true);
|
||||
task.addArtifact(artifact);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,15 @@ import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author spleaner
|
||||
*/
|
||||
@@ -47,6 +50,9 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
private static final Key<RunConfiguration> RUN_CONFIGURATION = Key.create("RUN_CONFIGURATION");
|
||||
|
||||
@NonNls protected static final String MAKE_PROJECT_ON_RUN_KEY = "makeProjectOnRun";
|
||||
|
||||
private static final Icon ICON = IconLoader.getIcon("/actions/compile.png");
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
public CompileStepBeforeRun(@NotNull final Project project) {
|
||||
@@ -57,10 +63,26 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
return ID;
|
||||
}
|
||||
|
||||
public String getDescription(final RunConfiguration runConfiguration, MakeBeforeRunTask task) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return ExecutionBundle.message("before.launch.compile.step");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(MakeBeforeRunTask task) {
|
||||
return ExecutionBundle.message("before.launch.compile.step");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTaskIcon(MakeBeforeRunTask task) {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
public MakeBeforeRunTask createTask(RunConfiguration runConfiguration) {
|
||||
return !(runConfiguration instanceof RemoteConfiguration) && runConfiguration instanceof RunProfileWithCompileBeforeLaunchOption
|
||||
? new MakeBeforeRunTask()
|
||||
@@ -71,6 +93,11 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecuteTask(RunConfiguration configuration, MakeBeforeRunTask task) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean executeTask(DataContext context, final RunConfiguration configuration, MakeBeforeRunTask task) {
|
||||
if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) {
|
||||
return true;
|
||||
@@ -134,7 +161,7 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
return result[0];
|
||||
}
|
||||
|
||||
public boolean hasConfigurationButton() {
|
||||
public boolean isConfigurable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -148,8 +175,9 @@ public class CompileStepBeforeRun extends BeforeRunTaskProvider<CompileStepBefor
|
||||
return compileScope.getUserData(RUN_CONFIGURATION);
|
||||
}
|
||||
|
||||
public static class MakeBeforeRunTask extends BeforeRunTask {
|
||||
public static class MakeBeforeRunTask extends BeforeRunTask<MakeBeforeRunTask> {
|
||||
private MakeBeforeRunTask() {
|
||||
super(ID);
|
||||
setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection.inferNullity;
|
||||
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.SequentialModalProgressTask;
|
||||
import com.intellij.util.SequentialTask;
|
||||
|
||||
class AnnotateTask implements SequentialTask {
|
||||
private final Project myProject;
|
||||
private final NullityInferrer myInferrer;
|
||||
private final SequentialModalProgressTask myTask;
|
||||
private int myCount = 0;
|
||||
private final int myTotal;
|
||||
private final NullableNotNullManager myNotNullManager;
|
||||
|
||||
public AnnotateTask(Project project, NullityInferrer inferrer, SequentialModalProgressTask progressTask) {
|
||||
myProject = project;
|
||||
myNotNullManager = NullableNotNullManager.getInstance(myProject);
|
||||
myInferrer = inferrer;
|
||||
myTask = progressTask;
|
||||
myTotal = myInferrer.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return myCount > myTotal - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean iteration() {
|
||||
final ProgressIndicator indicator = myTask.getIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.setFraction(((double)myCount) / myTotal);
|
||||
}
|
||||
|
||||
myInferrer.apply(myCount++, myProject, myNotNullManager);
|
||||
|
||||
return isDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -49,6 +49,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SequentialModalProgressTask;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -196,7 +197,12 @@ public class InferNullityAnnotationsAction extends BaseAnalysisAction {
|
||||
new WriteCommandAction(project, INFER_NULLITY_ANNOTATIONS) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
inferrer.apply(project);
|
||||
if (!inferrer.nothingFoundMessage(project)) {
|
||||
final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, INFER_NULLITY_ANNOTATIONS, false);
|
||||
progressTask.setMinIterationTime(200);
|
||||
progressTask.setTask(new AnnotateTask(project, inferrer, progressTask));
|
||||
ProgressManager.getInstance().run(progressTask);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@@ -31,14 +31,15 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class NullityInferrer {
|
||||
private static final int MAX_PASSES = 10;
|
||||
private int numAnnotationsAdded = 0;
|
||||
private final HashSet<SmartPsiElementPointer<? extends PsiModifierListOwner>> myNotNullSet = new HashSet<SmartPsiElementPointer<? extends PsiModifierListOwner>>();
|
||||
private final HashSet<SmartPsiElementPointer<? extends PsiModifierListOwner>> myNullableSet = new HashSet<SmartPsiElementPointer<? extends PsiModifierListOwner>>();
|
||||
private final List<SmartPsiElementPointer<? extends PsiModifierListOwner>> myNotNullSet = new ArrayList<SmartPsiElementPointer<? extends PsiModifierListOwner>>();
|
||||
private final List<SmartPsiElementPointer<? extends PsiModifierListOwner>> myNullableSet = new ArrayList<SmartPsiElementPointer<? extends PsiModifierListOwner>>();
|
||||
private final boolean myAnnotateLocalVariables;
|
||||
private final SmartPointerManager myPointerManager;
|
||||
|
||||
@@ -139,29 +140,60 @@ public class NullityInferrer {
|
||||
public void apply(final Project project) {
|
||||
final NullableNotNullManager manager = NullableNotNullManager.getInstance(project);
|
||||
for (SmartPsiElementPointer<? extends PsiModifierListOwner> pointer : myNullableSet) {
|
||||
final PsiModifierListOwner element = pointer.getElement();
|
||||
if (element != null) {
|
||||
if (shouldIgnore(element)) continue;
|
||||
new AddAnnotationFix(manager.getDefaultNullable(), element, manager.getDefaultNotNull()).invoke(project, null, element.getContainingFile());
|
||||
}
|
||||
annotateNullable(project, manager, pointer);
|
||||
}
|
||||
|
||||
for (SmartPsiElementPointer<? extends PsiModifierListOwner> pointer : myNotNullSet) {
|
||||
final PsiModifierListOwner element = pointer.getElement();
|
||||
if (element != null) {
|
||||
if (shouldIgnore(element)) continue;
|
||||
if (element instanceof PsiField && ((PsiField)element).hasInitializer() && element.hasModifierProperty(PsiModifier.FINAL)) continue;
|
||||
new AddAnnotationFix(manager.getDefaultNotNull(), element, manager.getDefaultNullable()).invoke(project, null,
|
||||
element.getContainingFile());
|
||||
}
|
||||
annotateNotNull(project, manager, pointer);
|
||||
}
|
||||
|
||||
nothingFoundMessage(project);
|
||||
}
|
||||
|
||||
public boolean nothingFoundMessage(final Project project) {
|
||||
if (myNullableSet.isEmpty() && myNotNullSet.isEmpty()) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
Messages.showInfoMessage(project, "No places found to infer @Nullable/@NotNull", "Infer Nullity Results");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void annotateNotNull(Project project,
|
||||
NullableNotNullManager manager,
|
||||
SmartPsiElementPointer<? extends PsiModifierListOwner> pointer) {
|
||||
final PsiModifierListOwner element = pointer.getElement();
|
||||
if (element != null) {
|
||||
if (shouldIgnore(element)) return;
|
||||
if (element instanceof PsiField && ((PsiField)element).hasInitializer() && element.hasModifierProperty(PsiModifier.FINAL)) return;
|
||||
new AddAnnotationFix(manager.getDefaultNotNull(), element, manager.getDefaultNullable()).invoke(project, null,
|
||||
element.getContainingFile());
|
||||
}
|
||||
}
|
||||
|
||||
private void annotateNullable(Project project,
|
||||
NullableNotNullManager manager,
|
||||
SmartPsiElementPointer<? extends PsiModifierListOwner> pointer) {
|
||||
final PsiModifierListOwner element = pointer.getElement();
|
||||
if (element != null) {
|
||||
if (shouldIgnore(element)) return;
|
||||
new AddAnnotationFix(manager.getDefaultNullable(), element, manager.getDefaultNotNull()).invoke(project, null, element.getContainingFile());
|
||||
}
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return myNotNullSet.size() + myNullableSet.size();
|
||||
}
|
||||
|
||||
public void apply(int i, Project project, NullableNotNullManager manager) {
|
||||
if (i < myNullableSet.size()) {
|
||||
annotateNullable(project, manager, myNullableSet.get(i));
|
||||
} else {
|
||||
i -= myNullableSet.size();
|
||||
annotateNotNull(project, manager, myNotNullSet.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,9 +300,9 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
|
||||
public void export(final RefEntity refEntity, final Element element) {
|
||||
if (refEntity instanceof RefElement) {
|
||||
final PsiElement psiElement = ((RefElement)refEntity).getElement();
|
||||
if (psiElement != null) {
|
||||
final PsiFile psiFile = psiElement.getContainingFile();
|
||||
final SmartPsiElementPointer pointer = ((RefElement)refEntity).getPointer();
|
||||
if (pointer != null) {
|
||||
final PsiFile psiFile = pointer.getContainingFile();
|
||||
if (psiFile instanceof PsiJavaFile) {
|
||||
appendPackageElement(element, ((PsiJavaFile)psiFile).getPackageName());
|
||||
}
|
||||
|
||||
+2
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -98,12 +98,7 @@ public class CompilerProjectExtensionImpl extends CompilerProjectExtension {
|
||||
public void setCompilerOutputUrl(String compilerOutputUrl) {
|
||||
VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(compilerOutputUrl, myProject, null);
|
||||
setCompilerOutputPointer(pointer);
|
||||
final LocalFileSystem.WatchRequest watchRequest =
|
||||
LocalFileSystem.getInstance().addRootToWatch(ProjectRootManagerImpl.extractLocalPath(compilerOutputUrl), true);
|
||||
if (myCompilerOutputWatchRequest != null) {
|
||||
LocalFileSystem.getInstance().removeWatchedRoot(myCompilerOutputWatchRequest);
|
||||
}
|
||||
myCompilerOutputWatchRequest = watchRequest;
|
||||
myCompilerOutputWatchRequest = LocalFileSystem.getInstance().replaceWatchedRoot(myCompilerOutputWatchRequest, compilerOutputUrl, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -45,7 +46,7 @@ public class ClassLiteralGetter {
|
||||
PsiElement position = parameters.getPosition();
|
||||
if (classParameter instanceof PsiWildcardType) {
|
||||
final PsiWildcardType wildcardType = (PsiWildcardType)classParameter;
|
||||
classParameter = wildcardType.getBound();
|
||||
classParameter = wildcardType.isSuper() ? wildcardType.getSuperBound() : wildcardType.getExtendsBound();
|
||||
addInheritors = wildcardType.isExtends() && classParameter instanceof PsiClassType;
|
||||
} else if (!matcher.getPrefix().isEmpty()) {
|
||||
addInheritors = true;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -66,6 +67,11 @@ public class PsiWildcardType extends PsiType {
|
||||
|
||||
public static PsiWildcardType changeBound(@NotNull PsiWildcardType type, @NotNull PsiType newBound) {
|
||||
LOG.assertTrue(type.getBound() != null);
|
||||
if (type.myIsExtending) {
|
||||
if (newBound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
|
||||
return createUnbounded(type.myManager);
|
||||
}
|
||||
}
|
||||
return new PsiWildcardType(type.myManager, type.myIsExtending, newBound);
|
||||
}
|
||||
|
||||
|
||||
@@ -659,7 +659,7 @@ public class TypeConversionUtil {
|
||||
return left.equals(right) || isAssignable(((PsiCapturedWildcardType)left).getLowerBound(), right, false);
|
||||
}
|
||||
if (right instanceof PsiCapturedWildcardType) {
|
||||
return isAssignable(left, ((PsiCapturedWildcardType)right).getUpperBound(), false);
|
||||
return isAssignable(left, ((PsiCapturedWildcardType)right).getUpperBound(), allowUncheckedConversion);
|
||||
}
|
||||
|
||||
if (left instanceof PsiWildcardType) {
|
||||
|
||||
+14
-2
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
public static void bar() {
|
||||
@@ -24,4 +24,16 @@ public class Test {
|
||||
public static Class<? extends Iterator> foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Example {
|
||||
static List<? extends AbstractTreeNode> treeNodes = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (AbstractTreeNode<String> treeNode : treeNodes) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
class AbstractTreeNode<T> {}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class D<T> {
|
||||
void foo(D<?> x){
|
||||
bar<error descr="'bar(D<? extends java.lang.Object>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
|
||||
bar<error descr="'bar(D<?>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
|
||||
}
|
||||
<T> void bar(D<? extends T> x, D<? super T> y){}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
public class A {
|
||||
void foo(Object o) {
|
||||
if (o instanceof String){}
|
||||
}
|
||||
}
|
||||
|
||||
class AImpl extends A {
|
||||
void foo(Object o) {
|
||||
if (o instanceof String){}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
void bar(Object o) {
|
||||
if (o instanceof String){}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
class s {
|
||||
String s = "xx.yy";
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
xx.yy=zzzz
|
||||
aaa.bbb=zzz
|
||||
cccc=c
|
||||
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
public class FindTest {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(" done");
|
||||
//done
|
||||
System.out.println("done");
|
||||
System.out.println(" done");
|
||||
System.out.println(" done2");
|
||||
//done!
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package tests;
|
||||
public class FindTests {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(" done");
|
||||
//done
|
||||
System.out.println("done");
|
||||
System.out.println(" done");
|
||||
System.out.println(" done2");
|
||||
//done!
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// TargetWord
|
||||
@@ -0,0 +1 @@
|
||||
// TargetWord
|
||||
@@ -0,0 +1,428 @@
|
||||
package com.intellij.find;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
import com.intellij.find.impl.FindInProjectUtil;
|
||||
import com.intellij.find.replaceInProject.ReplaceInProjectManager;
|
||||
import com.intellij.lang.properties.IProperty;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.fixtures.TempDirTestFixture;
|
||||
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.Usage;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.WaitFor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author: MYakovlev
|
||||
* Date: Oct 17, 2002
|
||||
* Time: 7:53:31 PM
|
||||
*/
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
protected VirtualFile[] mySourceDirs;
|
||||
|
||||
public void testFindString() throws Exception{
|
||||
FindManager findManager = FindManager.getInstance(myProject);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("done");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
|
||||
String text = "public static class MyClass{\n/*done*/\npublic static void main(){}}";
|
||||
FindResult findResult = findManager.findString(text, 0, findModel);
|
||||
assertTrue(findResult.isStringFound());
|
||||
|
||||
findModel = new FindModel();
|
||||
findModel.setStringToFind("done");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(true);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
|
||||
findResult = findManager.findString(text, 40, findModel);
|
||||
assertFalse(findResult.isStringFound());
|
||||
|
||||
findModel = new FindModel();
|
||||
findModel.setStringToFind("done");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(true);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setForward(false);
|
||||
|
||||
findResult = findManager.findString(text, 40, findModel);
|
||||
assertTrue(findResult.isStringFound());
|
||||
|
||||
findModel = new FindModel();
|
||||
findModel.setStringToFind("done");
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
|
||||
findResult = findManager.findString(text, 0, findModel);
|
||||
assertTrue(findResult.isStringFound());
|
||||
|
||||
findModel = new FindModel();
|
||||
findModel.setStringToFind("don");
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
|
||||
final FindResult[] findResultArr = new FindResult[1];
|
||||
findInNewThread(findModel, findManager, text, 0, findResultArr);
|
||||
new WaitFor(30 *1000){
|
||||
@Override
|
||||
protected boolean condition() {
|
||||
return findResultArr[0] != null;
|
||||
}
|
||||
}.assertCompleted();
|
||||
|
||||
assertFalse(findResultArr[0].isStringFound());
|
||||
}
|
||||
|
||||
private static Thread findInNewThread(final FindModel model,
|
||||
final FindManager findManager,
|
||||
final CharSequence text,
|
||||
final int offset,
|
||||
final FindResult[] op_result){
|
||||
op_result[0] = null;
|
||||
Thread findThread = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
op_result[0] = findManager.findString(text, offset, model);
|
||||
}
|
||||
};
|
||||
findThread.start();
|
||||
return findThread;
|
||||
}
|
||||
|
||||
public void testFindUsages() throws Exception{
|
||||
initProject("findManager", "src", "src1");
|
||||
final String projectDir = (PathManagerEx.getTestDataPath() + "/find/findManager").replace('/', File.separatorChar);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("done");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setDirectoryName(projectDir + File.separatorChar + "src1");
|
||||
findModel.setWithSubdirectories(true);
|
||||
checkFindUsages(12, findModel);
|
||||
|
||||
//findModel = new FindModel();
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
findModel.setProjectScope(false);
|
||||
findModel.setDirectoryName(projectDir + File.separatorChar + "src1");
|
||||
findModel.setWithSubdirectories(true);
|
||||
checkFindUsages(6, findModel);
|
||||
|
||||
findModel.setWholeWordsOnly(true);
|
||||
checkFindUsages(5, findModel);
|
||||
// findModel.setForward(false);
|
||||
// findModel.setCaseSensitive();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void checkFindUsages(int expectedResults, FindModel findModel) throws Exception{
|
||||
Collection<UsageInfo> usages = findUsages(findModel);
|
||||
assertEquals(expectedResults, usages.size());
|
||||
}
|
||||
|
||||
private List<UsageInfo> findUsages(final FindModel findModel) {
|
||||
PsiDirectory psiDirectory = FindInProjectUtil.getPsiDirectory(findModel, myProject);
|
||||
return FindInProjectUtil.findUsages(findModel, psiDirectory, myProject);
|
||||
}
|
||||
|
||||
public void testFindWholeWordsInProperties() throws Exception {
|
||||
initProject("findInPath", "src");
|
||||
|
||||
searchProperty("xx.yy");
|
||||
searchProperty(".yy");
|
||||
searchProperty("xx.");
|
||||
}
|
||||
|
||||
private void searchProperty(String query) {
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind(query);
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setDirectoryName(mySourceDirs[0].getPath());
|
||||
findModel.setWithSubdirectories(true);
|
||||
|
||||
List<UsageInfo> usages = findUsages(findModel);
|
||||
assertEquals(2, usages.size());
|
||||
if (!(usages.get(0).getElement().getContainingFile() instanceof PsiJavaFile)) {
|
||||
Collections.swap(usages, 0, 1);
|
||||
}
|
||||
PsiElement element = usages.get(0).getElement();
|
||||
//assertTrue(element instanceof PsiJavaFile);
|
||||
PsiElement refElement = element.findElementAt(usages.get(0).getRangeInElement().getStartOffset()).getParent();
|
||||
assertTrue(refElement instanceof PsiLiteralExpression);
|
||||
assertEquals("xx.yy", ((PsiLiteralExpression)refElement).getValue());
|
||||
|
||||
VirtualFile file = mySourceDirs[0].findFileByRelativePath("x/dd.properties");
|
||||
PropertiesFile propertiesFile = (PropertiesFile)PsiManager.getInstance(myProject).findFile(file);
|
||||
element = usages.get(1).getElement();
|
||||
//assertTrue(element instanceof PropertiesFile);
|
||||
refElement = element.findElementAt(usages.get(1).getRangeInElement().getStartOffset()).getParent();
|
||||
assertTrue(refElement instanceof IProperty);
|
||||
assertSame(propertiesFile.findPropertyByKey("xx.yy"), refElement);
|
||||
}
|
||||
|
||||
public void testFindInClassHierarchy() throws Exception {
|
||||
initProject("findInClassHierarchy", "src");
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("instanceof");
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
final PsiClass baseClass = facade.findClass("A", GlobalSearchScope.allScope(getProject()));
|
||||
final PsiClass implClass = facade.findClass("AImpl", GlobalSearchScope.allScope(getProject()));
|
||||
findModel.setCustomScope(new LocalSearchScope(new PsiElement[]{baseClass, implClass}));
|
||||
|
||||
List<UsageInfo> usages = findUsages(findModel);
|
||||
assertEquals(2, usages.size());
|
||||
}
|
||||
|
||||
public void testReplaceRegexp() throws Throwable {
|
||||
FindManager findManager = FindManager.getInstance(myProject);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("bug(?=here)");
|
||||
findModel.setStringToReplace("x$0y");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setRegularExpressions(true);
|
||||
findModel.setPromptOnReplace(false);
|
||||
|
||||
findManager.setFindNextModel(null);
|
||||
findManager.getFindInFileModel().copyFrom(findModel);
|
||||
|
||||
String text = "bughere\n" + "bughere";
|
||||
configureByText(FileTypes.PLAIN_TEXT, text);
|
||||
boolean succ = FindUtil.replace(getProject(), getEditor(), 0, findModel);
|
||||
assertTrue(succ);
|
||||
|
||||
assertEquals("xbugyhere\n" + "xbugyhere", getEditor().getDocument().getText());
|
||||
}
|
||||
public void testReplaceRegexp1() throws Throwable {
|
||||
FindManager findManager = FindManager.getInstance(myProject);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("bug(?=here)");
|
||||
findModel.setStringToReplace("$0");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setRegularExpressions(true);
|
||||
findModel.setPromptOnReplace(false);
|
||||
|
||||
findManager.setFindNextModel(null);
|
||||
findManager.getFindInFileModel().copyFrom(findModel);
|
||||
|
||||
String text = "bughere\n" + "bughere";
|
||||
configureByText(FileTypes.PLAIN_TEXT, text);
|
||||
boolean succ = FindUtil.replace(getProject(), getEditor(), 0, findModel);
|
||||
assertTrue(succ);
|
||||
|
||||
assertEquals(text, getEditor().getDocument().getText());
|
||||
}
|
||||
|
||||
public void testReplaceRegexpWithNewLine() throws Throwable {
|
||||
FindManager findManager = FindManager.getInstance(myProject);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("xxx");
|
||||
findModel.setStringToReplace("xxx\\n");
|
||||
findModel.setWholeWordsOnly(false);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setRegularExpressions(true);
|
||||
findModel.setPromptOnReplace(false);
|
||||
|
||||
findManager.setFindNextModel(null);
|
||||
findManager.getFindInFileModel().copyFrom(findModel);
|
||||
|
||||
String text = "xxx";
|
||||
configureByText(FileTypes.PLAIN_TEXT, text);
|
||||
boolean succ = FindUtil.replace(getProject(), getEditor(), 0, findModel);
|
||||
assertTrue(succ);
|
||||
|
||||
assertEquals(text+"\n", getEditor().getDocument().getText());
|
||||
}
|
||||
|
||||
private void initProject(String folderName, final String... sourceDirs) throws Exception{
|
||||
final String testDir = JavaTestUtil.getJavaTestDataPath() + "/find/" + folderName;
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable(){
|
||||
@Override
|
||||
public void run(){
|
||||
try{
|
||||
mySourceDirs = new VirtualFile[sourceDirs.length];
|
||||
for (int i = 0; i < sourceDirs.length; i++){
|
||||
String sourceDir = sourceDirs[i];
|
||||
mySourceDirs[i] = LocalFileSystem.getInstance().refreshAndFindFileByPath(new File(testDir + File.separatorChar + sourceDir).getCanonicalPath().replace(File.separatorChar, '/'));
|
||||
}
|
||||
VirtualFile projectDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(new File(testDir).getCanonicalPath().replace(File.separatorChar, '/'));
|
||||
|
||||
final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule);
|
||||
final ModifiableRootModel rootModel = rootManager.getModifiableModel();
|
||||
rootModel.clear();
|
||||
// configure source and output path
|
||||
final ContentEntry contentEntry = rootModel.addContentEntry(projectDir);
|
||||
for (VirtualFile sourceDir : mySourceDirs) {
|
||||
contentEntry.addSourceFolder(sourceDir, false);
|
||||
}
|
||||
|
||||
Sdk jdk = JavaSdkImpl.getMockJdk17();
|
||||
rootModel.setSdk(jdk);
|
||||
|
||||
rootModel.commit();
|
||||
}
|
||||
catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testReplaceAll() throws Throwable {
|
||||
FindManager findManager = FindManager.getInstance(myProject);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
String toFind = "xxx";
|
||||
String toReplace = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
findModel.setStringToFind(toFind);
|
||||
findModel.setStringToReplace(toReplace);
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(false);
|
||||
findModel.setProjectScope(true);
|
||||
findModel.setRegularExpressions(false);
|
||||
findModel.setPromptOnReplace(false);
|
||||
|
||||
findManager.setFindNextModel(null);
|
||||
findManager.getFindInFileModel().copyFrom(findModel);
|
||||
|
||||
String text = StringUtil.repeat(toFind + "\n",6);
|
||||
configureByText(FileTypes.PLAIN_TEXT, text);
|
||||
|
||||
List<Usage> usages = FindUtil.findAll(getProject(), myEditor, findModel);
|
||||
for (Usage usage : usages) {
|
||||
ReplaceInProjectManager.getInstance(getProject()).doReplace(usage, findModel, Collections.<Usage>emptySet());
|
||||
}
|
||||
String newText = StringUtil.repeat(toReplace + "\n",6);
|
||||
assertEquals(newText, getEditor().getDocument().getText());
|
||||
}
|
||||
|
||||
public void testFindInFileUnderLibraryUnderProject() throws Exception {
|
||||
initProject("libUnderProject", "src");
|
||||
PsiTestUtil.addLibrary(myModule, "lib", JavaTestUtil.getJavaTestDataPath() + "/find/libUnderProject/lib", new String[]{""}, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
|
||||
FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("TargetWord");
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
|
||||
findModel.setWholeWordsOnly(false);
|
||||
assertSize(2, findUsages(findModel));
|
||||
|
||||
/* todo
|
||||
findModel.setWholeWordsOnly(true);
|
||||
assertSize(2, findUsages(findModel));
|
||||
*/
|
||||
}
|
||||
|
||||
public void testLocalScopeSearchPerformance() throws Exception {
|
||||
final int count = 3000;
|
||||
TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
|
||||
fixture.setUp();
|
||||
|
||||
try {
|
||||
String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
fixture.createFile("a" + i + ".txt", sampleText);
|
||||
}
|
||||
PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile(""));
|
||||
|
||||
VirtualFile file = fixture.createFile("target.txt", sampleText);
|
||||
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
|
||||
final FindModel findModel = new FindModel();
|
||||
findModel.setStringToFind("TargetWord");
|
||||
findModel.setWholeWordsOnly(true);
|
||||
findModel.setFromCursor(false);
|
||||
findModel.setGlobal(true);
|
||||
findModel.setMultipleFiles(true);
|
||||
|
||||
ThrowableRunnable test = new ThrowableRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
assertSize(count, findUsages(findModel));
|
||||
}
|
||||
};
|
||||
|
||||
findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
|
||||
PlatformTestUtil.startPerformanceTest("slow", 500, test).attempts(1).cpuBound().usesAllCPUCores().assertTiming();
|
||||
|
||||
findModel.setCustomScope(new LocalSearchScope(psiFile));
|
||||
PlatformTestUtil.startPerformanceTest("slow", 500, test).attempts(1).cpuBound().usesAllCPUCores().assertTiming();
|
||||
}
|
||||
finally {
|
||||
fixture.tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class ResolveClassTest extends ResolveTestCase {
|
||||
PsiReference ref = configure();
|
||||
long start = System.currentTimeMillis();
|
||||
assertNull(ref.resolve());
|
||||
PlatformTestUtil.assertTiming("exponent?", 20000, System.currentTimeMillis() - start);
|
||||
PlatformTestUtil.assertTiming("exponent?", 200, System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
public void testStaticImportNetwork() throws Exception {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.jetbrains.jps.api;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 2/28/12
|
||||
*/
|
||||
public interface AsyncTaskExecutor {
|
||||
AsyncTaskExecutor DEFAULT = new AsyncTaskExecutor() {
|
||||
@Override
|
||||
public void submit(Runnable runnable) {
|
||||
new Thread(runnable).start();
|
||||
}
|
||||
};
|
||||
|
||||
void submit(Runnable runnable);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.api;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
@@ -11,7 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* Date: 9/24/11
|
||||
*/
|
||||
public class SequentialTaskExecutor {
|
||||
private final AsyncTaskExecutor myExecutor;
|
||||
private final Executor myExecutor;
|
||||
private final Queue<FutureTask> myTaskQueue = new LinkedBlockingQueue<FutureTask>();
|
||||
private final AtomicBoolean myInProgress = new AtomicBoolean(false);
|
||||
private final Runnable USER_TASK_RUNNER = new Runnable() {
|
||||
@@ -31,7 +32,7 @@ public class SequentialTaskExecutor {
|
||||
}
|
||||
};
|
||||
|
||||
public SequentialTaskExecutor(AsyncTaskExecutor executor) {
|
||||
public SequentialTaskExecutor(Executor executor) {
|
||||
myExecutor = executor;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public class SequentialTaskExecutor {
|
||||
|
||||
private void processQueue() {
|
||||
if (!myInProgress.getAndSet(true)) {
|
||||
myExecutor.submit(USER_TASK_RUNNER);
|
||||
myExecutor.execute(USER_TASK_RUNNER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,4 @@ import java.util.concurrent.Executors;
|
||||
*/
|
||||
public class SharedThreadPool {
|
||||
public static final ExecutorService INSTANCE = Executors.newCachedThreadPool();
|
||||
public static final AsyncTaskExecutor ASYNC_EXEC = new AsyncTaskExecutor() {
|
||||
@Override
|
||||
public void submit(Runnable runnable) {
|
||||
INSTANCE.submit(runnable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.api.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -20,7 +24,7 @@ public class CompileServerClient extends SimpleProtobufClient<JpsServerResponseH
|
||||
private volatile ScheduledFuture<?> myPingFuture;
|
||||
private final long myServerPingInterval;
|
||||
|
||||
public CompileServerClient(long serverPingInterval, final AsyncTaskExecutor asyncExec) {
|
||||
public CompileServerClient(long serverPingInterval, final Executor asyncExec) {
|
||||
super(JpsRemoteProto.Message.getDefaultInstance(), asyncExec, new UUIDGetter() {
|
||||
@NotNull
|
||||
public UUID getSessionUUID(@NotNull MessageEvent e) {
|
||||
|
||||
@@ -6,12 +6,12 @@ import org.jboss.netty.channel.ChannelStateEvent;
|
||||
import org.jboss.netty.channel.MessageEvent;
|
||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.api.AsyncTaskExecutor;
|
||||
import org.jetbrains.jps.api.RequestFuture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -22,9 +22,9 @@ final class ProtobufClientMessageHandler<T extends ProtobufResponseHandler> exte
|
||||
@NotNull
|
||||
private final UUIDGetter myUuidGetter;
|
||||
private final SimpleProtobufClient myClient;
|
||||
private final AsyncTaskExecutor myAsyncExec;
|
||||
private final Executor myAsyncExec;
|
||||
|
||||
public ProtobufClientMessageHandler(@NotNull UUIDGetter uuidGetter, SimpleProtobufClient client, AsyncTaskExecutor asyncExec) {
|
||||
public ProtobufClientMessageHandler(@NotNull UUIDGetter uuidGetter, SimpleProtobufClient client, Executor asyncExec) {
|
||||
myUuidGetter = uuidGetter;
|
||||
myClient = client;
|
||||
myAsyncExec = asyncExec;
|
||||
@@ -92,7 +92,7 @@ final class ProtobufClientMessageHandler<T extends ProtobufResponseHandler> exte
|
||||
}
|
||||
finally {
|
||||
// make sure the client is in disconnected state
|
||||
myAsyncExec.submit(new Runnable() {
|
||||
myAsyncExec.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myClient.disconnect();
|
||||
|
||||
@@ -10,13 +10,11 @@ import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder;
|
||||
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
||||
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.api.AsyncTaskExecutor;
|
||||
import org.jetbrains.jps.api.RequestFuture;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
@@ -25,7 +23,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
*/
|
||||
public class SimpleProtobufClient<T extends ProtobufResponseHandler> {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.client.SimpleProtobufClient");
|
||||
private final ExecutorService ourExecutor = Executors.newCachedThreadPool();
|
||||
|
||||
private static enum State {
|
||||
DISCONNECTED, CONNECTING, CONNECTED, DISCONNECTING
|
||||
@@ -37,9 +34,9 @@ public class SimpleProtobufClient<T extends ProtobufResponseHandler> {
|
||||
protected volatile ChannelFuture myConnectFuture;
|
||||
private final ProtobufClientMessageHandler<T> myMessageHandler;
|
||||
|
||||
public SimpleProtobufClient(final MessageLite msgDefaultInstance, final AsyncTaskExecutor asyncExec, final UUIDGetter uuidGetter) {
|
||||
public SimpleProtobufClient(final MessageLite msgDefaultInstance, final Executor asyncExec, final UUIDGetter uuidGetter) {
|
||||
myMessageHandler = new ProtobufClientMessageHandler<T>(uuidGetter, this, asyncExec);
|
||||
myChannelFactory = new NioClientSocketChannelFactory(ourExecutor, ourExecutor, 1);
|
||||
myChannelFactory = new NioClientSocketChannelFactory(asyncExec, asyncExec, 1);
|
||||
myPipelineFactory = new ChannelPipelineFactory() {
|
||||
public ChannelPipeline getPipeline() throws Exception {
|
||||
return Channels.pipeline(
|
||||
@@ -117,13 +114,8 @@ public class SimpleProtobufClient<T extends ProtobufResponseHandler> {
|
||||
catch (Throwable e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
try {
|
||||
final ChannelFuture closeFuture = future.getChannel().close();
|
||||
closeFuture.awaitUninterruptibly();
|
||||
}
|
||||
finally {
|
||||
myChannelFactory.releaseExternalResources();
|
||||
}
|
||||
final ChannelFuture closeFuture = future.getChannel().close();
|
||||
closeFuture.awaitUninterruptibly();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -7,13 +7,13 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.io.MappingFailedException;
|
||||
import com.intellij.util.io.PersistentEnumerator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.*;
|
||||
import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.api.GlobalOptions;
|
||||
import org.jetbrains.jps.api.RequestFuture;
|
||||
import org.jetbrains.jps.api.SharedThreadPool;
|
||||
import org.jetbrains.jps.incremental.java.ExternalJavacDescriptor;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
@@ -164,7 +164,7 @@ public class IncProjectBuilder {
|
||||
return context;
|
||||
}
|
||||
|
||||
private static void flushContext(@Nullable CompileContext context) {
|
||||
private static void flushContext(CompileContext context) {
|
||||
if (context != null) {
|
||||
context.getTimestampStorage().force();
|
||||
context.getDataManager().flush(false);
|
||||
@@ -181,16 +181,14 @@ public class IncProjectBuilder {
|
||||
}
|
||||
ExternalJavacDescriptor.KEY.set(context, null);
|
||||
}
|
||||
if (context == null || context.getBuilderParameter(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION) == null) {
|
||||
cleanupJavacNameTable();
|
||||
}
|
||||
cleanupJavacNameTable();
|
||||
}
|
||||
|
||||
private static boolean ourClenupFailed = false;
|
||||
|
||||
private static void cleanupJavacNameTable() {
|
||||
try {
|
||||
if (!ourClenupFailed) {
|
||||
if (JavaBuilder.USE_EMBEDDED_JAVAC && !ourClenupFailed) {
|
||||
final Field freelistField = Class.forName("com.sun.tools.javac.util.Name$Table").getDeclaredField("freelist");
|
||||
freelistField.setAccessible(true);
|
||||
freelistField.set(null, com.sun.tools.javac.util.List.nil());
|
||||
|
||||
@@ -56,6 +56,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
private static final String FORMS_BUILDER_NAME = "forms";
|
||||
private static final String JAVA_EXTENSION = ".java";
|
||||
private static final String FORM_EXTENSION = ".form";
|
||||
public static final boolean USE_EMBEDDED_JAVAC = System.getProperty(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION) == null;
|
||||
|
||||
public static final FileFilter JAVA_SOURCES_FILTER = new FileFilter() {
|
||||
public boolean accept(File file) {
|
||||
@@ -385,7 +386,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final ClassProcessingConsumer classesConsumer = new ClassProcessingConsumer(context, outputSink);
|
||||
try {
|
||||
final boolean rc;
|
||||
if (context.getBuilderParameter(GlobalOptions.USE_EXTERNAL_JAVAC_OPTION) == null) {
|
||||
if (USE_EMBEDDED_JAVAC) {
|
||||
rc = JavacMain.compile(
|
||||
options, files, classpath, platformCp, sourcePath, outs, diagnosticSink, classesConsumer, context.getCancelStatus()
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.*;
|
||||
public class JavacServerClient extends SimpleProtobufClient<JavacServerResponseHandler>{
|
||||
|
||||
public JavacServerClient() {
|
||||
super(JavacRemoteProto.Message.getDefaultInstance(), SharedThreadPool.ASYNC_EXEC, new UUIDGetter() {
|
||||
super(JavacRemoteProto.Message.getDefaultInstance(), SharedThreadPool.INSTANCE, new UUIDGetter() {
|
||||
@NotNull
|
||||
public UUID getSessionUUID(@NotNull MessageEvent e) {
|
||||
final JavacRemoteProto.Message message = (JavacRemoteProto.Message)e.getMessage();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.server;
|
||||
|
||||
//import com.intellij.openapi.diagnostic.Logger;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import org.apache.log4j.Level;
|
||||
@@ -17,17 +18,13 @@ import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
||||
import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.api.AsyncTaskExecutor;
|
||||
import org.jetbrains.jps.api.GlobalOptions;
|
||||
import org.jetbrains.jps.api.JpsRemoteProto;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -70,21 +67,21 @@ public class Server {
|
||||
private final ScheduledExecutorService myScheduler;
|
||||
private final ServerMessageHandler myMessageHandler;
|
||||
|
||||
public Server(File systemDir, boolean cachesInMemory) {
|
||||
public Server(File systemDir) {
|
||||
Utils.setSystemRoot(systemDir);
|
||||
final ExecutorService threadPool = Executors.newCachedThreadPool();
|
||||
myScheduler = ConcurrencyUtil.newSingleScheduledThreadExecutor("Client activity checker", Thread.MIN_PRIORITY);
|
||||
myBuildsExecutor = Executors.newFixedThreadPool(MAX_SIMULTANEOUS_BUILD_SESSIONS);
|
||||
myChannelFactory = new NioServerSocketChannelFactory(threadPool, threadPool, 1);
|
||||
final ChannelRegistrar channelRegistrar = new ChannelRegistrar();
|
||||
myMessageHandler = new ServerMessageHandler(this, new AsyncTaskExecutor() {
|
||||
myMessageHandler = new ServerMessageHandler(this, new Executor() {
|
||||
@Override
|
||||
public void submit(final Runnable runnable) {
|
||||
public void execute(final Runnable command) {
|
||||
myBuildsExecutor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
runnable.run();
|
||||
command.run();
|
||||
}
|
||||
finally {
|
||||
Thread.interrupted(); // clear interrupted status before returning to pull
|
||||
@@ -105,17 +102,6 @@ public class Server {
|
||||
);
|
||||
}
|
||||
};
|
||||
ServerState.getInstance().setKeepTempCachesInMemory(cachesInMemory);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook thread") {
|
||||
public void run() {
|
||||
try {
|
||||
myMessageHandler.cancelAllBuildsAndClearState();
|
||||
}
|
||||
finally {
|
||||
Server.this.stop();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void start(int listenPort) {
|
||||
@@ -192,10 +178,6 @@ public class Server {
|
||||
myLastPingTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isStopped() {
|
||||
return myScheduler.isShutdown();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
int port = DEFAULT_SERVER_PORT;
|
||||
@@ -212,10 +194,21 @@ public class Server {
|
||||
systemDir = new File(args[1]);
|
||||
}
|
||||
|
||||
final Server server = new Server(systemDir, System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null);
|
||||
final Server server = new Server(systemDir);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook thread") {
|
||||
public void run() {
|
||||
try {
|
||||
server.myMessageHandler.cancelAllBuildsAndClearState();
|
||||
}
|
||||
finally {
|
||||
server.stop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
initLoggers();
|
||||
server.start(port);
|
||||
ServerState.getInstance().setKeepTempCachesInMemory(System.getProperty(GlobalOptions.USE_MEMORY_TEMP_CACHE_OPTION) != null);
|
||||
|
||||
System.out.println("Server classpath: " + System.getProperty("java.class.path"));
|
||||
System.err.println(SERVER_SUCCESS_START_MESSAGE + port);
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
|
||||
/**
|
||||
@@ -27,9 +28,9 @@ class ServerMessageHandler extends SimpleChannelHandler {
|
||||
private final Map<String, SequentialTaskExecutor> myTaskExecutors = new HashMap<String, SequentialTaskExecutor>();
|
||||
private final List<Pair<RunnableFuture, CompilationTask>> myBuildsInProgress = Collections.synchronizedList(new LinkedList<Pair<RunnableFuture, CompilationTask>>());
|
||||
private final Server myServer;
|
||||
private final AsyncTaskExecutor myAsyncExecutor;
|
||||
private final Executor myAsyncExecutor;
|
||||
|
||||
public ServerMessageHandler(Server server, final AsyncTaskExecutor asyncExecutor) {
|
||||
public ServerMessageHandler(Server server, final Executor asyncExecutor) {
|
||||
myServer = server;
|
||||
myAsyncExecutor = asyncExecutor;
|
||||
}
|
||||
@@ -80,13 +81,14 @@ class ServerMessageHandler extends SimpleChannelHandler {
|
||||
new GlobalLibrary(library.getName(), library.getPathList())
|
||||
);
|
||||
}
|
||||
final String globalEncoding = setupCommand.isInitialized()? setupCommand.getGlobalEncoding() : null;
|
||||
facade.setGlobals(libs, pathVars, globalEncoding, setupCommand.getIgnoredFilesPatterns());
|
||||
final String globalEncoding = setupCommand.hasGlobalEncoding()? setupCommand.getGlobalEncoding() : null;
|
||||
final String ignoredPatterns = setupCommand.hasIgnoredFilesPatterns()? setupCommand.getIgnoredFilesPatterns() : null;
|
||||
facade.setGlobals(libs, pathVars, globalEncoding, ignoredPatterns);
|
||||
reply = ProtoUtil.toMessage(sessionId, ProtoUtil.createCommandCompletedEvent(null));
|
||||
break;
|
||||
|
||||
case SHUTDOWN_COMMAND :
|
||||
myAsyncExecutor.submit(new Runnable() {
|
||||
myAsyncExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
cancelAllBuildsAndClearState();
|
||||
|
||||
@@ -45,7 +45,7 @@ class ServerState {
|
||||
private final List<GlobalLibrary> myGlobalLibraries = new ArrayList<GlobalLibrary>();
|
||||
private volatile String myGlobalEncoding = null;
|
||||
private volatile boolean myKeepTempCachesInMemory = false;
|
||||
private String myIgnoredFilesPatterns;
|
||||
private volatile String myIgnoredFilesPatterns;
|
||||
|
||||
public void setGlobals(List<GlobalLibrary> libs, Map<String, String> pathVars, String globalEncoding, String ignoredFilesPatterns) {
|
||||
synchronized (myConfigurationLock) {
|
||||
@@ -53,7 +53,7 @@ class ServerState {
|
||||
myGlobalLibraries.addAll(libs);
|
||||
myPathVariables.putAll(pathVars);
|
||||
myGlobalEncoding = StringUtil.isEmpty(globalEncoding)? null : globalEncoding;
|
||||
myIgnoredFilesPatterns = ignoredFilesPatterns;
|
||||
myIgnoredFilesPatterns = StringUtil.isEmpty(ignoredFilesPatterns)? "" : ignoredFilesPatterns;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -28,6 +28,7 @@ log4j.jar
|
||||
jgoodies-common-1.2.1.jar
|
||||
jgoodies-looks-2.4.2.jar
|
||||
microba.jar
|
||||
miglayout-swing.jar
|
||||
nanoxml-2.2.3.jar
|
||||
nekohtml-1.9.14.jar
|
||||
org.eclipse.jdt.core_3.5.2.v_981_R35x.jar
|
||||
@@ -45,5 +46,5 @@ xmlrpc-2.0.jar
|
||||
xpp3-1.1.4-min.jar
|
||||
xstream.jar
|
||||
swingx-core-1.6.2.jar
|
||||
netty-3.3.1.Final.jar
|
||||
netty-3.4.0.Final.jar
|
||||
protobuf-2.4.1.jar
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -16,15 +16,28 @@
|
||||
|
||||
package com.intellij.execution;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: May 18, 2009
|
||||
*/
|
||||
public abstract class BeforeRunTask implements Cloneable{
|
||||
public abstract class BeforeRunTask<T extends BeforeRunTask> implements Cloneable {
|
||||
@NotNull
|
||||
protected final Key<T> myProviderId;
|
||||
private boolean myIsEnabled;
|
||||
|
||||
protected BeforeRunTask(@NotNull Key<T> providerId) {
|
||||
myProviderId = providerId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Key<T> getProviderId() {
|
||||
return myProviderId;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return myIsEnabled;
|
||||
}
|
||||
@@ -59,13 +72,13 @@ public abstract class BeforeRunTask implements Cloneable{
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BeforeRunTask that = (BeforeRunTask)o;
|
||||
|
||||
if (myProviderId != that.myProviderId) return false;
|
||||
if (myIsEnabled != that.myIsEnabled) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (myIsEnabled ? 1 : 0);
|
||||
return 31 * myProviderId.hashCode() + (myIsEnabled ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,13 @@ package com.intellij.execution;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
|
||||
public static final ExtensionPointName<BeforeRunTaskProvider<BeforeRunTask>> EXTENSION_POINT_NAME = new ExtensionPointName<BeforeRunTaskProvider<BeforeRunTask>>("com.intellij.stepsBeforeRunProvider");
|
||||
|
||||
@@ -35,9 +39,22 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
|
||||
|
||||
public abstract Key<T> getId();
|
||||
|
||||
public abstract String getDescription(final RunConfiguration runConfiguration, T task);
|
||||
public abstract String getName();
|
||||
|
||||
public abstract boolean hasConfigurationButton();
|
||||
@Nullable
|
||||
public Icon getIcon() {
|
||||
return null;
|
||||
};
|
||||
|
||||
public abstract String getDescription(T task);
|
||||
|
||||
|
||||
@Nullable
|
||||
public Icon getTaskIcon(T task) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract boolean isConfigurable();
|
||||
|
||||
/**
|
||||
* @return 'before run' task for the configuration or null, if the task from this provider is not applicable to the specified configuration
|
||||
@@ -50,8 +67,18 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
|
||||
*/
|
||||
public abstract boolean configureTask(final RunConfiguration runConfiguration, T task);
|
||||
|
||||
public abstract boolean canExecuteTask(RunConfiguration configuration, T task);
|
||||
|
||||
public abstract boolean executeTask(DataContext context, RunConfiguration configuration, T task);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return <code>true</code> if at most one task may be configured
|
||||
*/
|
||||
public boolean isSingleton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get runner id that current run is about to be made by
|
||||
* @param context data context that is passed to <code>{@link #executeTask(com.intellij.openapi.actionSystem.DataContext, com.intellij.execution.configurations.RunConfiguration, BeforeRunTask)}</code>
|
||||
@@ -61,4 +88,14 @@ public abstract class BeforeRunTaskProvider<T extends BeforeRunTask> {
|
||||
public static String getRunnerId(DataContext context) {
|
||||
return (String)context.getData(RUNNER_ID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends BeforeRunTask> BeforeRunTaskProvider<T> getProvider(Project project, Key<T> key) {
|
||||
BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, project);
|
||||
for (BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
|
||||
if (provider.getId() == key)
|
||||
return (BeforeRunTaskProvider<T>)provider;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,8 @@ class DaemonListeners implements Disposable {
|
||||
@Override
|
||||
public void caretPositionChanged(CaretEvent e) {
|
||||
Editor editor = e.getEditor();
|
||||
if (!editor.getComponent().isShowing() || !worthBothering(editor.getDocument(), editor.getProject())) {
|
||||
if ((!editor.getComponent().isShowing() && !ApplicationManager.getApplication().isUnitTestMode()) ||
|
||||
!worthBothering(editor.getDocument(), editor.getProject())) {
|
||||
return; //no need to stop daemon if something happened in the console
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -20,16 +20,16 @@ import com.intellij.codeInsight.folding.CodeFoldingManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocCommentBase;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
|
||||
public class CollapseExpandDocCommentsHandler implements CodeInsightActionHandler {
|
||||
private final boolean myExpand;
|
||||
|
||||
public CollapseExpandJavadocsHandler(boolean isExpand) {
|
||||
public CollapseExpandDocCommentsHandler(boolean isExpand) {
|
||||
myExpand = isExpand;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CollapseExpandJavadocsHandler implements CodeInsightActionHandler {
|
||||
public void run() {
|
||||
for (FoldRegion region : allFoldRegions) {
|
||||
PsiElement element = EditorFoldingInfo.get(editor).getPsiElement(region);
|
||||
if (element instanceof PsiDocComment) {
|
||||
if (element instanceof PsiDocCommentBase) {
|
||||
region.setExpanded(myExpand);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -17,11 +17,11 @@ package com.intellij.codeInsight.folding.impl.actions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
|
||||
import com.intellij.codeInsight.folding.impl.CollapseExpandJavadocsHandler;
|
||||
import com.intellij.codeInsight.folding.impl.CollapseExpandDocCommentsHandler;
|
||||
|
||||
public class ExpandJavadocsAction extends BaseCodeInsightAction{
|
||||
public class CollapseDocCommentsAction extends BaseCodeInsightAction{
|
||||
@Override
|
||||
protected CodeInsightActionHandler getHandler(){
|
||||
return new CollapseExpandJavadocsHandler(true);
|
||||
return new CollapseExpandDocCommentsHandler(false);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -17,11 +17,11 @@ package com.intellij.codeInsight.folding.impl.actions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
|
||||
import com.intellij.codeInsight.folding.impl.CollapseExpandJavadocsHandler;
|
||||
import com.intellij.codeInsight.folding.impl.CollapseExpandDocCommentsHandler;
|
||||
|
||||
public class CollapseJavadocsAction extends BaseCodeInsightAction{
|
||||
public class ExpandDocCommentsAction extends BaseCodeInsightAction{
|
||||
@Override
|
||||
protected CodeInsightActionHandler getHandler(){
|
||||
return new CollapseExpandJavadocsHandler(false);
|
||||
return new CollapseExpandDocCommentsHandler(true);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,13 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement
|
||||
if (myIsDeleted) return false;
|
||||
return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
public Boolean compute() {
|
||||
|
||||
final PsiFile file = myID.getContainingFile();
|
||||
//no need to check resolve in offline mode
|
||||
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
return file != null && file.isPhysical();
|
||||
}
|
||||
|
||||
final PsiElement element = getElement();
|
||||
return element != null && element.isPhysical();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Segment;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
@@ -210,8 +211,8 @@ public class RefManagerImpl extends RefManager {
|
||||
|
||||
if (refEntity instanceof RefElement) {
|
||||
final RefElement refElement = (RefElement)refEntity;
|
||||
PsiElement psiElement = refElement.getElement();
|
||||
PsiFile psiFile = psiElement.getContainingFile();
|
||||
final SmartPsiElementPointer pointer = refElement.getPointer();
|
||||
PsiFile psiFile = pointer.getContainingFile();
|
||||
|
||||
Element fileElement = new Element("file");
|
||||
Element lineElement = new Element("line");
|
||||
@@ -220,9 +221,10 @@ public class RefManagerImpl extends RefManager {
|
||||
fileElement.addContent(virtualFile.getUrl());
|
||||
|
||||
if (actualLine == -1) {
|
||||
final Document document = PsiDocumentManager.getInstance(refElement.getRefManager().getProject()).getDocument(psiFile);
|
||||
final Document document = PsiDocumentManager.getInstance(pointer.getProject()).getDocument(psiFile);
|
||||
LOG.assertTrue(document != null);
|
||||
lineElement.addContent(String.valueOf(document.getLineNumber(psiElement.getTextOffset()) + 1));
|
||||
final Segment range = pointer.getRange();
|
||||
lineElement.addContent(String.valueOf(range != null ? (document.getLineNumber(range.getStartOffset()) + 1) : -1));
|
||||
}
|
||||
else {
|
||||
lineElement.addContent(String.valueOf(actualLine));
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Manages {@link RunConfiguration}s.
|
||||
@@ -55,20 +55,23 @@ public abstract class RunManagerEx extends RunManager {
|
||||
@NotNull
|
||||
public abstract RunnerAndConfigurationSettings createConfiguration(String name, ConfigurationFactory type);
|
||||
|
||||
public abstract void addConfiguration(RunnerAndConfigurationSettings settings, boolean isShared, Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks);
|
||||
public abstract void addConfiguration(RunnerAndConfigurationSettings settings, boolean isShared, List<BeforeRunTask> tasks);
|
||||
|
||||
public abstract void addConfiguration(final RunnerAndConfigurationSettings settings, final boolean isShared);
|
||||
|
||||
public abstract boolean isConfigurationShared(RunnerAndConfigurationSettings settings);
|
||||
|
||||
@NotNull
|
||||
public abstract <T extends BeforeRunTask> Map<Key<T>, BeforeRunTask> getBeforeRunTasks(RunConfiguration settings);
|
||||
|
||||
@Nullable
|
||||
public abstract <T extends BeforeRunTask> T getBeforeRunTask(RunConfiguration settings, Key<T> taskProviderID);
|
||||
public abstract List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings);
|
||||
|
||||
@NotNull
|
||||
public abstract <T extends BeforeRunTask> Collection<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks);
|
||||
public abstract List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings, boolean includeOnlyActiveTasks);
|
||||
|
||||
@NotNull
|
||||
public abstract <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID);
|
||||
|
||||
@NotNull
|
||||
public abstract <T extends BeforeRunTask> List<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks);
|
||||
|
||||
public abstract RunnerAndConfigurationSettings findConfigurationByName(@Nullable final String name);
|
||||
|
||||
|
||||
+21
-14
@@ -39,9 +39,8 @@ import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extends DialogWrapper {
|
||||
@@ -180,8 +179,12 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
|
||||
}
|
||||
|
||||
private boolean isConfigurationAssigned(RunConfiguration configuration) {
|
||||
final T task = RunManagerEx.getInstanceEx(myProject).getBeforeRunTask(configuration, getTaskID());
|
||||
return task != null && isRunning(task);
|
||||
final java.util.List<T> tasks = RunManagerEx.getInstanceEx(myProject).getBeforeRunTasks(configuration, getTaskID());
|
||||
for (T task : tasks) {
|
||||
if (isRunning(task))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void doOKAction() {
|
||||
@@ -215,20 +218,24 @@ public abstract class BaseExecuteBeforeRunDialog<T extends BeforeRunTask> extend
|
||||
protected abstract boolean isRunning(T task);
|
||||
|
||||
private void update(RunConfiguration config, boolean enabled, RunManagerImpl runManager) {
|
||||
T task = runManager.getBeforeRunTask(config, getTaskID());
|
||||
if (task == null) return;
|
||||
|
||||
List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(config);
|
||||
BeforeRunTaskProvider<T> provider = BeforeRunTaskProvider.getProvider(myProject, getTaskID());
|
||||
if (provider == null)
|
||||
return;
|
||||
T task = provider.createTask(config);
|
||||
update(task);
|
||||
task.setEnabled(true);
|
||||
if (enabled) {
|
||||
task.setEnabled(true);
|
||||
update(task);
|
||||
if (!tasks.contains(task)) {
|
||||
tasks.add(task);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isRunning(task)) {
|
||||
task.setEnabled(false);
|
||||
clear(task);
|
||||
if (tasks.contains(task)) {
|
||||
tasks.remove(task);
|
||||
}
|
||||
// do not change the task otherwise
|
||||
}
|
||||
runManager.setBeforeRunTasks(config, tasks);
|
||||
}
|
||||
|
||||
protected abstract void update(T task);
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.UnknownRunConfiguration;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Vassiliy Kudryashov
|
||||
*/
|
||||
class BeforeRunStepsPanel extends JPanel {
|
||||
private JCheckBox myShowSettingsBeforeRunCheckBox;
|
||||
private JBList myList;
|
||||
private final CollectionListModel<BeforeRunTask> myModel;
|
||||
private RunConfiguration myRunConfiguration;
|
||||
|
||||
private final List<BeforeRunTask> originalTasks = new ArrayList<BeforeRunTask>();
|
||||
private StepsBeforeRunListener myListener;
|
||||
|
||||
BeforeRunStepsPanel(StepsBeforeRunListener listener) {
|
||||
myListener = listener;
|
||||
myModel = new CollectionListModel<BeforeRunTask>();
|
||||
myList = new JBList(myModel);
|
||||
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myList.setCellRenderer(new MyListCellRenderer());
|
||||
ToolbarDecorator myDecorator = ToolbarDecorator.createDecorator(myList);
|
||||
myDecorator.setEditAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
int index = myList.getSelectedIndex();
|
||||
if (index ==-1)
|
||||
return;
|
||||
Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> selection = getSelection();
|
||||
if (selection == null)
|
||||
return;
|
||||
BeforeRunTask task = selection.getFirst();
|
||||
BeforeRunTaskProvider<BeforeRunTask> provider = selection.getSecond();
|
||||
if (provider.configureTask(myRunConfiguration, task)) {
|
||||
myModel.setElementAt(task, index);
|
||||
}
|
||||
}
|
||||
});
|
||||
myDecorator.setEditActionUpdater(new AnActionButtonUpdater() {
|
||||
@Override
|
||||
public boolean isEnabled(AnActionEvent e) {
|
||||
Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> selection = getSelection();
|
||||
return selection != null && selection.getSecond().isConfigurable();
|
||||
}
|
||||
});
|
||||
myDecorator.setAddAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
public void run(AnActionButton button) {
|
||||
doAddAction(button);
|
||||
}
|
||||
});
|
||||
|
||||
myShowSettingsBeforeRunCheckBox = new JCheckBox(ExecutionBundle.message("configuration.edit.before.run"));
|
||||
|
||||
setLayout(new MigLayout("fill, ins 0, gap 10"));
|
||||
add(myShowSettingsBeforeRunCheckBox, "shrinky, wrap");
|
||||
add(myDecorator.createPanel(), "grow, push");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> getSelection() {
|
||||
final int index = myList.getSelectedIndex();
|
||||
if (index ==-1)
|
||||
return null;
|
||||
BeforeRunTask task = myModel.getElementAt(index);
|
||||
Key providerId = task.getProviderId();
|
||||
BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), providerId);
|
||||
return provider != null ? Pair.create(task, provider) : null;
|
||||
}
|
||||
|
||||
void doReset(RunnerAndConfigurationSettings settings) {
|
||||
myRunConfiguration = settings.getConfiguration();
|
||||
|
||||
originalTasks.clear();
|
||||
originalTasks.addAll(RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()).getBeforeRunTasks(myRunConfiguration, true));
|
||||
myModel.replaceAll(originalTasks);
|
||||
myShowSettingsBeforeRunCheckBox.setSelected(settings.isEditBeforeRun());
|
||||
myShowSettingsBeforeRunCheckBox.setEnabled(!(myRunConfiguration instanceof UnknownRunConfiguration));
|
||||
}
|
||||
|
||||
public List<BeforeRunTask> getTasks(boolean applyCurrentState) {
|
||||
if (applyCurrentState) {
|
||||
originalTasks.clear();
|
||||
originalTasks.addAll(myModel.getItems());
|
||||
}
|
||||
return Collections.unmodifiableList(originalTasks);
|
||||
}
|
||||
|
||||
public boolean needEditBeforeRun() {
|
||||
return myShowSettingsBeforeRunCheckBox.isSelected();
|
||||
}
|
||||
|
||||
void doAddAction(AnActionButton button) {
|
||||
if (myRunConfiguration instanceof UnknownRunConfiguration) {
|
||||
return;
|
||||
}
|
||||
|
||||
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
|
||||
final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME,
|
||||
myRunConfiguration.getProject());
|
||||
final List<Key> activeProviderKeys = getActiveProviderKeys();
|
||||
|
||||
DefaultActionGroup actionGroup = new DefaultActionGroup(null, false);
|
||||
for (final BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
|
||||
String providerName = provider.getName();
|
||||
if (provider.createTask(myRunConfiguration) == null)
|
||||
continue;
|
||||
if (activeProviderKeys.contains(provider.getId()) && provider.isSingleton())
|
||||
continue;
|
||||
AnAction providerAction = new AnAction(providerName, null, provider.getIcon()) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
BeforeRunTask task = provider.createTask(myRunConfiguration);
|
||||
if (task != null) {
|
||||
provider.configureTask(myRunConfiguration, task);
|
||||
if (!provider.canExecuteTask(myRunConfiguration, task))
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
task.setEnabled(true);
|
||||
|
||||
Set<RunConfiguration> configurationSet = new HashSet<RunConfiguration>();
|
||||
getAllRunBeforeRuns(task, configurationSet);
|
||||
if (configurationSet.contains(myRunConfiguration)) {
|
||||
JOptionPane.showMessageDialog(BeforeRunStepsPanel.this,
|
||||
ExecutionBundle.message("before.launch.panel.cyclic_dependency_warning",
|
||||
myRunConfiguration.getName(),
|
||||
provider.getDescription(task)),
|
||||
ExecutionBundle.message("warning.common.title"),JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
myModel.add(task);
|
||||
myListener.fireStepsBeforeRunChanged();
|
||||
}
|
||||
};
|
||||
actionGroup.add(providerAction);
|
||||
}
|
||||
final ListPopup popup =
|
||||
popupFactory.createActionGroupPopup(ExecutionBundle.message("add.new.run.configuration.acrtion.name"), actionGroup,
|
||||
SimpleDataContext.getProjectContext(myRunConfiguration.getProject()), false, false, false, null,
|
||||
-1, Condition.TRUE);
|
||||
popup.show(button.getPreferredPopupPoint());
|
||||
}
|
||||
|
||||
private List<Key> getActiveProviderKeys() {
|
||||
List<Key> result = new ArrayList<Key>();
|
||||
for (BeforeRunTask task : myModel.getItems()) {
|
||||
result.add(task.getProviderId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getAllRunBeforeRuns(BeforeRunTask task, Set<RunConfiguration> configurationSet) {
|
||||
if (task instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
|
||||
RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask runTask
|
||||
= (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask)task;
|
||||
RunConfiguration configuration = runTask.getSettings().getConfiguration();
|
||||
|
||||
List<BeforeRunTask> tasks = RunManagerImpl.getInstanceImpl(configuration.getProject()).getBeforeRunTasks(configuration, true);
|
||||
for (BeforeRunTask beforeRunTask : tasks) {
|
||||
if (beforeRunTask instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
|
||||
configurationSet.add(((RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask)beforeRunTask).getSettings().getConfiguration());
|
||||
getAllRunBeforeRuns(beforeRunTask, configurationSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface StepsBeforeRunListener {
|
||||
void fireStepsBeforeRunChanged();
|
||||
}
|
||||
|
||||
private class MyListCellRenderer extends JBList.StripedListCellRenderer {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (value instanceof BeforeRunTask) {
|
||||
BeforeRunTask task = (BeforeRunTask)value;
|
||||
BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), task.getProviderId());
|
||||
if (provider != null) {
|
||||
setIcon(provider.getTaskIcon(task));
|
||||
setText(provider.getDescription(task));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,13 +17,13 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="d489d" binding="myStepsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<grid id="d489d" binding="myBeforeLaunchContainer" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ExecutionBundle" title-key="before.launch.panel.title"/>
|
||||
<children/>
|
||||
|
||||
+17
-124
@@ -17,8 +17,6 @@
|
||||
package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.BeforeRunTaskProvider;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.UnknownRunConfiguration;
|
||||
@@ -27,48 +25,43 @@ import com.intellij.ide.impl.TypeSafeDataProviderAdapter;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 27-Mar-2006
|
||||
*/
|
||||
public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAndConfigurationSettings> {
|
||||
public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAndConfigurationSettings>
|
||||
implements BeforeRunStepsPanel.StepsBeforeRunListener {
|
||||
public static DataKey<ConfigurationSettingsEditorWrapper> CONFIGURATION_EDITOR_KEY = DataKey.create("ConfigurationSettingsEditor");
|
||||
private JPanel myComponentPlace;
|
||||
private JCheckBox myCbStoreProjectConfiguration;
|
||||
private JPanel myWholePanel;
|
||||
|
||||
private JPanel myStepsPanel;
|
||||
private JCheckBox myShowSettingsBeforeRunCheckBox;
|
||||
private Map<Key<? extends BeforeRunTask>, BeforeRunTask> myStepsBeforeLaunch;
|
||||
private final Map<Key<? extends BeforeRunTask>, StepBeforeLaunchRow> myStepBeforeLaunchRows = new THashMap<Key<? extends BeforeRunTask>, StepBeforeLaunchRow>();
|
||||
private JPanel myBeforeLaunchContainer;
|
||||
private BeforeRunStepsPanel myBeforeRunStepsPanel;
|
||||
|
||||
private boolean myStoreProjectConfiguration;
|
||||
private boolean myEditBeforeRun;
|
||||
|
||||
private final ConfigurationSettingsEditor myEditor;
|
||||
|
||||
public ConfigurationSettingsEditorWrapper(final RunnerAndConfigurationSettings settings) {
|
||||
myEditor = new ConfigurationSettingsEditor(settings);
|
||||
Disposer.register(this, myEditor);
|
||||
myBeforeRunStepsPanel = new BeforeRunStepsPanel(this);
|
||||
myBeforeLaunchContainer.setLayout(new MigLayout("fill, ins 0"));
|
||||
myBeforeLaunchContainer.add(myBeforeRunStepsPanel, "grow, push");
|
||||
doReset(settings);
|
||||
}
|
||||
|
||||
@@ -76,54 +69,8 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
final RunConfiguration runConfiguration = settings.getConfiguration();
|
||||
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
|
||||
|
||||
myStepsBeforeLaunch = runManager.getBeforeRunTasks(runConfiguration);
|
||||
myStepBeforeLaunchRows.clear();
|
||||
|
||||
final BeforeRunTaskProvider<BeforeRunTask>[] providers = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME,
|
||||
runConfiguration.getProject());
|
||||
myStepsPanel.removeAll();
|
||||
if (runConfiguration instanceof UnknownRunConfiguration) {
|
||||
myStepsPanel.setVisible(false);
|
||||
}
|
||||
else {
|
||||
List<StepBeforeLaunchRow> stepsRows = new ArrayList<StepBeforeLaunchRow>();
|
||||
for (BeforeRunTaskProvider<BeforeRunTask> provider : providers) {
|
||||
final BeforeRunTask task = myStepsBeforeLaunch.get(provider.getId());
|
||||
if (task != null) {
|
||||
final StepBeforeLaunchRow stepRow = new StepBeforeLaunchRow(runConfiguration, provider, task);
|
||||
myStepBeforeLaunchRows.put(provider.getId(), stepRow);
|
||||
stepsRows.add(stepRow);
|
||||
}
|
||||
}
|
||||
|
||||
int maxStepRowWidth = 0;
|
||||
for (StepBeforeLaunchRow stepRow : stepsRows) {
|
||||
maxStepRowWidth = Math.max(maxStepRowWidth, stepRow.getPreferredSize().width);
|
||||
}
|
||||
if (maxStepRowWidth * 3 < getComponent().getPreferredSize().width || maxStepRowWidth < 200) {
|
||||
myStepsPanel.setLayout(new GridLayout(0, 3, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
|
||||
} else if (maxStepRowWidth * 2 < getComponent().getPreferredSize().width || maxStepRowWidth < 300) {
|
||||
myStepsPanel.setLayout(new GridLayout(0, 2, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
|
||||
} else {
|
||||
myStepsPanel.setLayout(new GridLayout(0, 1, UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
|
||||
}
|
||||
for (StepBeforeLaunchRow stepRow : stepsRows) {
|
||||
myStepsPanel.add(stepRow);
|
||||
}
|
||||
}
|
||||
|
||||
myEditBeforeRun = settings.isEditBeforeRun();
|
||||
myShowSettingsBeforeRunCheckBox = new JCheckBox(ExecutionBundle.message("configuration.edit.before.run"));
|
||||
myShowSettingsBeforeRunCheckBox.setEnabled(!(runConfiguration instanceof UnknownRunConfiguration));
|
||||
myShowSettingsBeforeRunCheckBox.setSelected(myEditBeforeRun);
|
||||
myShowSettingsBeforeRunCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myEditBeforeRun = myShowSettingsBeforeRunCheckBox.isSelected();
|
||||
}
|
||||
});
|
||||
myShowSettingsBeforeRunCheckBox.setVisible(!settings.isTemplate());
|
||||
myStepsPanel.add(myShowSettingsBeforeRunCheckBox);
|
||||
myBeforeRunStepsPanel.doReset(settings);
|
||||
myBeforeLaunchContainer.setVisible(!(runConfiguration instanceof UnknownRunConfiguration));
|
||||
|
||||
myStoreProjectConfiguration = runManager.isConfigurationShared(settings);
|
||||
myCbStoreProjectConfiguration.setEnabled(!(runConfiguration instanceof UnknownRunConfiguration));
|
||||
@@ -141,15 +88,10 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
protected JComponent createEditor() {
|
||||
myComponentPlace.setLayout(new BorderLayout());
|
||||
myComponentPlace.add(myEditor.getComponent(), BorderLayout.CENTER);
|
||||
//myComponentPlace.revalidate();
|
||||
DataManager.registerDataProvider(myWholePanel, new TypeSafeDataProviderAdapter(new MyDataProvider()));
|
||||
return myWholePanel;
|
||||
}
|
||||
|
||||
public void updateBeforeRunTaskPanel(@NotNull Key<? extends BeforeRunTask> key) {
|
||||
myStepBeforeLaunchRows.get(key).update(myStepsBeforeLaunch.get(key));
|
||||
}
|
||||
|
||||
protected void disposeEditor() {
|
||||
}
|
||||
|
||||
@@ -172,71 +114,22 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
private void doApply(final RunnerAndConfigurationSettings settings) {
|
||||
final RunConfiguration runConfiguration = settings.getConfiguration();
|
||||
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
|
||||
runManager.setBeforeRunTasks(runConfiguration, myStepsBeforeLaunch);
|
||||
runManager.setBeforeRunTasks(runConfiguration, myBeforeRunStepsPanel.getTasks(true));
|
||||
runManager.shareConfiguration(runConfiguration, myStoreProjectConfiguration);
|
||||
runManager.setEditBeforeRun(runConfiguration, myEditBeforeRun);
|
||||
runManager.setEditBeforeRun(runConfiguration, myBeforeRunStepsPanel.needEditBeforeRun());
|
||||
}
|
||||
|
||||
public Map<Key<? extends BeforeRunTask>, BeforeRunTask> getStepsBeforeLaunch() {
|
||||
return Collections.unmodifiableMap(myStepsBeforeLaunch);
|
||||
public List<BeforeRunTask> getStepsBeforeLaunch() {
|
||||
return Collections.unmodifiableList(myBeforeRunStepsPanel.getTasks(false));
|
||||
}
|
||||
|
||||
public boolean isStoreProjectConfiguration() {
|
||||
return myStoreProjectConfiguration;
|
||||
}
|
||||
|
||||
private class StepBeforeLaunchRow extends JPanel {
|
||||
private final JCheckBox myCheckBox;
|
||||
private FixedSizeButton myButton;
|
||||
private final RunConfiguration myRunConfiguration;
|
||||
private final BeforeRunTaskProvider<BeforeRunTask> myProvider;
|
||||
|
||||
public StepBeforeLaunchRow(final RunConfiguration runConfiguration, final BeforeRunTaskProvider<BeforeRunTask> provider,
|
||||
final BeforeRunTask beforeRunTask) {
|
||||
super(new GridBagLayout());
|
||||
myRunConfiguration = runConfiguration;
|
||||
myProvider = provider;
|
||||
final boolean isChecked = beforeRunTask.isEnabled();
|
||||
myCheckBox = new JCheckBox(provider.getDescription(runConfiguration, beforeRunTask), isChecked);
|
||||
GridBagConstraints gc = new GridBagConstraints(GridBagConstraints.RELATIVE, 0 , 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0);
|
||||
add(myCheckBox, gc);
|
||||
gc.weightx = 1;
|
||||
if (provider.hasConfigurationButton()) {
|
||||
myButton = new FixedSizeButton(20);
|
||||
add(myButton, gc);
|
||||
|
||||
myButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (provider.configureTask(runConfiguration, beforeRunTask)) {
|
||||
myCheckBox.setText(provider.getDescription(runConfiguration, beforeRunTask));
|
||||
fireEditorStateChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
add(Box.createHorizontalBox(), gc);
|
||||
}
|
||||
enableSettings(beforeRunTask);
|
||||
myCheckBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
beforeRunTask.setEnabled(myCheckBox.isSelected());
|
||||
enableSettings(beforeRunTask);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enableSettings(final BeforeRunTask task) {
|
||||
if (myButton != null) {
|
||||
myButton.setEnabled(myCheckBox.isSelected());
|
||||
}
|
||||
myCheckBox.setText(myProvider.getDescription(myRunConfiguration, task));
|
||||
}
|
||||
|
||||
public void update(BeforeRunTask task) {
|
||||
myCheckBox.setSelected(task.isEnabled());
|
||||
enableSettings(task);
|
||||
}
|
||||
@Override
|
||||
public void fireStepsBeforeRunChanged() {
|
||||
fireEditorStateChanged();
|
||||
}
|
||||
|
||||
private class MyDataProvider implements TypeSafeDataProvider {
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -41,9 +40,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dyoma
|
||||
@@ -99,24 +96,25 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
final RunConfiguration runConfiguration = (RunConfiguration)configuration;
|
||||
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
|
||||
|
||||
final Map<BeforeRunTaskProvider<BeforeRunTask>, BeforeRunTask> activeProviders = new LinkedHashMap<BeforeRunTaskProvider<BeforeRunTask>, BeforeRunTask>();
|
||||
for (final BeforeRunTaskProvider<BeforeRunTask> provider : Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myProject)) {
|
||||
final BeforeRunTask task = runManager.getBeforeRunTask(runConfiguration, provider.getId());
|
||||
if (task != null && task.isEnabled()) {
|
||||
activeProviders.put(provider, task);
|
||||
final List<BeforeRunTask> activeTasks = new ArrayList<BeforeRunTask>();
|
||||
final List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(runConfiguration);
|
||||
for (BeforeRunTask task : tasks) {
|
||||
if (task != null && task.isEnabled()) {
|
||||
activeTasks.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationPerRunnerSettings configurationSettings = state != null ? state.getConfigurationSettings() : null;
|
||||
final DataContext projectContext = SimpleDataContext.getProjectContext(myProject);
|
||||
final DataContext dataContext = configurationSettings != null ? SimpleDataContext
|
||||
.getSimpleContext(BeforeRunTaskProvider.RUNNER_ID, configurationSettings.getRunnerId(), projectContext) : projectContext;
|
||||
|
||||
if (!activeProviders.isEmpty()) {
|
||||
if (!activeTasks.isEmpty()) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
for (BeforeRunTaskProvider<BeforeRunTask> provider : activeProviders.keySet()) {
|
||||
if(!provider.executeTask(dataContext, runConfiguration, activeProviders.get(provider))) {
|
||||
for (BeforeRunTask task : activeTasks) {
|
||||
BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId());
|
||||
if(provider != null && !provider.executeTask(dataContext, runConfiguration, task)) {
|
||||
if (onCancelRunnable != null) {
|
||||
SwingUtilities.invokeLater(onCancelRunnable);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
@@ -65,6 +64,7 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -895,7 +895,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
});
|
||||
final ListPopup popup =
|
||||
popupFactory.createListPopup(new BaseListPopupStep<ConfigurationType>(
|
||||
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), configurationTypes) {
|
||||
ExecutionBundle.message("add.new.run.configuration.acrtion.name"), configurationTypes) {
|
||||
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationType type) {
|
||||
@@ -953,7 +953,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
}
|
||||
});
|
||||
return new BaseListPopupStep<ConfigurationFactory>(
|
||||
ExecutionBundle.message("add.new.run.configuration.action.name", type.getDisplayName()), factories) {
|
||||
ExecutionBundle.message("add.new.run.configuration.action.name", type.getDisplayName()), factories) {
|
||||
|
||||
@NotNull
|
||||
public String getTextFor(final ConfigurationFactory value) {
|
||||
@@ -1168,15 +1168,15 @@ class RunConfigurable extends BaseConfigurable {
|
||||
private static class RunConfigurationBean {
|
||||
private final RunnerAndConfigurationSettings mySettings;
|
||||
private final boolean myShared;
|
||||
private final Map<Key<? extends BeforeRunTask>, BeforeRunTask> myStepsBeforeLaunch;
|
||||
private final List<BeforeRunTask> myStepsBeforeLaunch;
|
||||
private final SingleConfigurationConfigurable myConfigurable;
|
||||
|
||||
public RunConfigurationBean(final RunnerAndConfigurationSettings settings,
|
||||
final boolean shared,
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> stepsBeforeLaunch) {
|
||||
final List<BeforeRunTask> stepsBeforeLaunch) {
|
||||
mySettings = settings;
|
||||
myShared = shared;
|
||||
myStepsBeforeLaunch = Collections.unmodifiableMap(stepsBeforeLaunch);
|
||||
myStepsBeforeLaunch = Collections.unmodifiableList(stepsBeforeLaunch);
|
||||
myConfigurable = null;
|
||||
}
|
||||
|
||||
@@ -1196,7 +1196,7 @@ class RunConfigurable extends BaseConfigurable {
|
||||
return myShared;
|
||||
}
|
||||
|
||||
public Map<Key<? extends BeforeRunTask>, BeforeRunTask> getStepsBeforeLaunch() {
|
||||
public List<BeforeRunTask> getStepsBeforeLaunch() {
|
||||
return myStepsBeforeLaunch;
|
||||
}
|
||||
|
||||
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.executors.DefaultRunExecutor;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Vassiliy Kudryashov
|
||||
*/
|
||||
public class RunConfigurationBeforeRunProvider
|
||||
extends BeforeRunTaskProvider<RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask> {
|
||||
private static final Icon ICON = IconLoader.getIcon("/actions/execute.png");
|
||||
|
||||
public static final Key<RunConfigurableBeforeRunTask> ID = Key.create("RunConfigurationTask");
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.impl.RunConfigurationBeforeRunProvider");
|
||||
|
||||
private final Project myProject;
|
||||
|
||||
public RunConfigurationBeforeRunProvider(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<RunConfigurableBeforeRunTask> getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getTaskIcon(RunConfigurableBeforeRunTask task) {
|
||||
if (task.getSettings() == null)
|
||||
return null;
|
||||
return ProgramRunnerUtil.getConfigurationIcon(myProject, task.getSettings(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ExecutionBundle.message("before.launch.run.another.configuration");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(RunConfigurableBeforeRunTask task) {
|
||||
if (task.getSettings() == null) {
|
||||
return ExecutionBundle.message("before.launch.run.another.configuration");
|
||||
}
|
||||
else {
|
||||
return ExecutionBundle.message("before.launch.run.certain.configuration", task.getSettings().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunConfigurableBeforeRunTask createTask(RunConfiguration runConfiguration) {
|
||||
return new RunConfigurableBeforeRunTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configureTask(RunConfiguration runConfiguration, RunConfigurableBeforeRunTask task) {
|
||||
final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
|
||||
|
||||
final ArrayList<RunnerAndConfigurationSettings> configurations
|
||||
= new ArrayList<RunnerAndConfigurationSettings>(runManager.getSortedConfigurations());
|
||||
String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
|
||||
for (Iterator<RunnerAndConfigurationSettings> iterator = configurations.iterator(); iterator.hasNext();) {
|
||||
RunnerAndConfigurationSettings settings = iterator.next();
|
||||
final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
|
||||
if (runner == null)
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
SelectionDialog dialog =
|
||||
new SelectionDialog(task.getSettings(), configurations);
|
||||
dialog.show();
|
||||
RunnerAndConfigurationSettings settings = dialog.getSelectedSettings();
|
||||
if (settings != null) {
|
||||
task.setSettings(settings);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecuteTask(RunConfiguration configuration,
|
||||
RunConfigurableBeforeRunTask task) {
|
||||
RunnerAndConfigurationSettings settings = task.getSettings();
|
||||
if (settings == null) {
|
||||
return false;
|
||||
}
|
||||
String executorId = DefaultRunExecutor.getRunExecutorInstance().getId();
|
||||
final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
|
||||
if (runner == null)
|
||||
return false;
|
||||
final ExecutionEnvironment environment = new ExecutionEnvironment(runner, settings, myProject);
|
||||
return runner.canRun(executorId, environment.getRunProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean executeTask(final DataContext dataContext, RunConfiguration configuration, RunConfigurableBeforeRunTask task) {
|
||||
RunnerAndConfigurationSettings settings = task.getSettings();
|
||||
if (settings == null) {
|
||||
return false;
|
||||
}
|
||||
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
|
||||
String executorId = executor.getId();
|
||||
final ProgramRunner runner = ProgramRunnerUtil.getRunner(executorId, settings);
|
||||
if (runner == null)
|
||||
return false;
|
||||
final ExecutionEnvironment environment = new ExecutionEnvironment(runner, settings, myProject);
|
||||
if (!runner.canRun(executorId, environment.getRunProfile())) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
final Semaphore targetDone = new Semaphore();
|
||||
final boolean[] result = new boolean[1];
|
||||
try {
|
||||
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
targetDone.down();
|
||||
try {
|
||||
runner.execute(executor, environment, new ProgramRunner.Callback() {
|
||||
@Override
|
||||
public void processStarted(RunContentDescriptor descriptor) {
|
||||
ProcessHandler processHandler = descriptor != null ? descriptor.getProcessHandler() : null;
|
||||
if (processHandler != null) {
|
||||
processHandler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void processTerminated(ProcessEvent event) {
|
||||
result[0] = event.getExitCode() == 0;
|
||||
targetDone.up();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
return false;
|
||||
}
|
||||
targetDone.waitFor();
|
||||
return result[0];
|
||||
}
|
||||
}
|
||||
|
||||
class RunConfigurableBeforeRunTask extends BeforeRunTask<RunConfigurableBeforeRunTask> {
|
||||
private String myConfigurationName;
|
||||
private String myConfigurationType;
|
||||
private boolean myInitialized = false;
|
||||
|
||||
private RunnerAndConfigurationSettings mySettings;
|
||||
|
||||
RunConfigurableBeforeRunTask() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
if (myConfigurationName != null && myConfigurationType != null) {
|
||||
element.setAttribute("run_configuration_name", myConfigurationName);
|
||||
element.setAttribute("run_configuration_type", myConfigurationType);
|
||||
}
|
||||
else if (mySettings != null) {
|
||||
element.setAttribute("run_configuration_name", mySettings.getName());
|
||||
element.setAttribute("run_configuration_type", mySettings.getType().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) {
|
||||
super.readExternal(element);
|
||||
Attribute configurationNameAttr = element.getAttribute("run_configuration_name");
|
||||
Attribute configurationTypeAttr = element.getAttribute("run_configuration_type");
|
||||
myConfigurationName = configurationNameAttr != null ? configurationNameAttr.getValue() : null;
|
||||
myConfigurationType = configurationTypeAttr != null ? configurationTypeAttr.getValue() : null;
|
||||
}
|
||||
|
||||
void init() {
|
||||
if (myInitialized) {
|
||||
return;
|
||||
}
|
||||
if (myConfigurationName != null && myConfigurationType != null) {
|
||||
Collection<RunnerAndConfigurationSettings> configurations = RunManagerImpl.getInstanceImpl(myProject).getSortedConfigurations();
|
||||
for (RunnerAndConfigurationSettings runConfiguration : configurations) {
|
||||
ConfigurationType type = runConfiguration.getType();
|
||||
if (myConfigurationName.equals(runConfiguration.getName())
|
||||
&& type != null
|
||||
&& myConfigurationType.equals(type.getId())) {
|
||||
setSettings(runConfiguration);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setSettings(RunnerAndConfigurationSettings settings) {
|
||||
mySettings = settings;
|
||||
myInitialized = true;
|
||||
}
|
||||
|
||||
RunnerAndConfigurationSettings getSettings() {
|
||||
init();
|
||||
return mySettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
RunConfigurableBeforeRunTask that = (RunConfigurableBeforeRunTask)o;
|
||||
|
||||
if (myConfigurationName != null ? !myConfigurationName.equals(that.myConfigurationName) : that.myConfigurationName != null) return false;
|
||||
if (myConfigurationType != null ? !myConfigurationType.equals(that.myConfigurationType) : that.myConfigurationType != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (myConfigurationName != null ? myConfigurationName.hashCode() : 0);
|
||||
result = 31 * result + (myConfigurationType != null ? myConfigurationType.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class SelectionDialog extends DialogWrapper {
|
||||
private RunnerAndConfigurationSettings mySelectedSettings;
|
||||
@NotNull private final List<RunnerAndConfigurationSettings> mySettings;
|
||||
private JBList myJBList;
|
||||
|
||||
private SelectionDialog(RunnerAndConfigurationSettings selectedSettings, @NotNull List<RunnerAndConfigurationSettings> settings) {
|
||||
super(myProject);
|
||||
setTitle("Choose Configuration to Execute");
|
||||
mySelectedSettings = selectedSettings;
|
||||
mySettings = settings;
|
||||
init();
|
||||
myJBList.setSelectedValue(mySelectedSettings, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
myJBList = new JBList(mySettings);
|
||||
myJBList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myJBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
Object selectedValue = myJBList.getSelectedValue();
|
||||
if (selectedValue instanceof RunnerAndConfigurationSettings) {
|
||||
mySelectedSettings = (RunnerAndConfigurationSettings)selectedValue;
|
||||
}
|
||||
else {
|
||||
mySelectedSettings = null;
|
||||
}
|
||||
setOKActionEnabled(mySelectedSettings != null);
|
||||
}
|
||||
});
|
||||
myJBList.setCellRenderer(new ColoredListCellRenderer() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value instanceof RunnerAndConfigurationSettings) {
|
||||
RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings)value;
|
||||
RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
|
||||
setIcon(runManager.getConfigurationIcon(settings));
|
||||
RunConfiguration configuration = settings.getConfiguration();
|
||||
append(configuration.getName(), runManager.isTemporary(configuration)
|
||||
? SimpleTextAttributes.GRAY_ATTRIBUTES
|
||||
: SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
});
|
||||
return new JBScrollPane(myJBList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
RunnerAndConfigurationSettings getSelectedSettings() {
|
||||
return mySelectedSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,11 +48,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
private final Map<Integer, RunnerAndConfigurationSettings> myConfigurations =
|
||||
new LinkedHashMap<Integer, RunnerAndConfigurationSettings>(); // template configurations are not included here
|
||||
private final Map<Integer, Boolean> mySharedConfigurations = new TreeMap<Integer, Boolean>();
|
||||
/**
|
||||
* configurationID -> [BeforeTaskProviderName->BeforeRunTask]
|
||||
*/
|
||||
private final Map<RunConfiguration, Map<Key<? extends BeforeRunTask>, BeforeRunTask>> myConfigurationToBeforeTasksMap =
|
||||
new WeakHashMap<RunConfiguration, Map<Key<? extends BeforeRunTask>, BeforeRunTask>>();
|
||||
private final Map<RunConfiguration, List<BeforeRunTask>> myConfigurationToBeforeTasksMap = new WeakHashMap<RunConfiguration, List<BeforeRunTask>>();
|
||||
|
||||
// When readExternal not all configuration may be loaded, so we need to remember the selected configuration
|
||||
// so that when it is eventually loaded, we can mark is as a selected.
|
||||
@@ -244,7 +240,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
|
||||
public void addConfiguration(RunnerAndConfigurationSettings settings,
|
||||
boolean shared,
|
||||
Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks) {
|
||||
List<BeforeRunTask> tasks) {
|
||||
final RunConfiguration configuration = settings.getConfiguration();
|
||||
|
||||
Integer existingId = findConfigurationIdByUniqueName(getUniqueName(settings));
|
||||
@@ -441,35 +437,12 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
((RunnerAndConfigurationSettingsImpl)settings).writeExternal(configurationElement);
|
||||
|
||||
if (!(settings.getConfiguration() instanceof UnknownRunConfiguration)) {
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks = getBeforeRunTasks(settings.getConfiguration());
|
||||
Map<Key<? extends BeforeRunTask>, BeforeRunTask> templateTasks;
|
||||
if (!settings.isTemplate()) {
|
||||
final RunnerAndConfigurationSettings templateSettings = getConfigurationTemplate(settings.getFactory());
|
||||
templateTasks = getBeforeRunTasks(templateSettings.getConfiguration());
|
||||
}
|
||||
else {
|
||||
templateTasks = null;
|
||||
}
|
||||
final List<Key<? extends BeforeRunTask>> order = new ArrayList<Key<? extends BeforeRunTask>>(tasks.keySet());
|
||||
Collections.sort(order, new Comparator<Key<? extends BeforeRunTask>>() {
|
||||
public int compare(Key<? extends BeforeRunTask> o1, Key<? extends BeforeRunTask> o2) {
|
||||
return o1.toString().compareToIgnoreCase(o2.toString());
|
||||
}
|
||||
});
|
||||
final List<BeforeRunTask> tasks = getBeforeRunTasks(settings.getConfiguration());
|
||||
final Element methodsElement = new Element(METHOD);
|
||||
for (Key<? extends BeforeRunTask> providerID : order) {
|
||||
final BeforeRunTask beforeRunTask = tasks.get(providerID);
|
||||
|
||||
if (templateTasks != null) {
|
||||
final BeforeRunTask templateTask = templateTasks.get(providerID);
|
||||
if (beforeRunTask.equals(templateTask)) {
|
||||
continue; // not neccesary saving if the task is the same as template
|
||||
}
|
||||
}
|
||||
|
||||
for (BeforeRunTask task : tasks) {
|
||||
final Element child = new Element(OPTION);
|
||||
child.setAttribute(NAME_ATTR, providerID.toString());
|
||||
beforeRunTask.writeExternal(child);
|
||||
child.setAttribute(NAME_ATTR, task.getProviderId().toString());
|
||||
task.writeExternal(child);
|
||||
methodsElement.addContent(child);
|
||||
}
|
||||
configurationElement.addContent(methodsElement);
|
||||
@@ -575,13 +548,13 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
final Element methodsElement = element.getChild(METHOD);
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> map = readStepsBeforeRun(methodsElement, settings);
|
||||
final List<BeforeRunTask> tasks = readStepsBeforeRun(methodsElement, settings);
|
||||
if (settings.isTemplate()) {
|
||||
myTemplateConfigurationsMap.put(factory.getType().getId() + "." + factory.getName(), settings);
|
||||
setBeforeRunTasks(settings.getConfiguration(), map);
|
||||
setBeforeRunTasks(settings.getConfiguration(), tasks);
|
||||
}
|
||||
else {
|
||||
addConfiguration(settings, isShared, map);
|
||||
addConfiguration(settings, isShared, tasks);
|
||||
if (Boolean.valueOf(element.getAttributeValue(SELECTED_ATTR)).booleanValue()) { //to support old style
|
||||
setSelectedConfiguration(settings);
|
||||
}
|
||||
@@ -590,9 +563,8 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<Key<? extends BeforeRunTask>, BeforeRunTask> readStepsBeforeRun(final Element child,
|
||||
RunnerAndConfigurationSettings settings) {
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> map = new HashMap<Key<? extends BeforeRunTask>, BeforeRunTask>();
|
||||
private List<BeforeRunTask> readStepsBeforeRun(final Element child, RunnerAndConfigurationSettings settings) {
|
||||
final List<BeforeRunTask> result = new ArrayList<BeforeRunTask>();
|
||||
if (child != null) {
|
||||
for (Object o : child.getChildren(OPTION)) {
|
||||
final Element methodElement = (Element)o;
|
||||
@@ -602,11 +574,11 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
final BeforeRunTask beforeRunTask = provider.createTask(settings.getConfiguration());
|
||||
if (beforeRunTask != null) {
|
||||
beforeRunTask.readExternal(methodElement);
|
||||
map.put(id, beforeRunTask);
|
||||
result.add(beforeRunTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -730,22 +702,27 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
return shared != null && shared.booleanValue();
|
||||
}
|
||||
|
||||
public <T extends BeforeRunTask> Collection<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks) {
|
||||
final Collection<T> tasks = new ArrayList<T>();
|
||||
@NotNull
|
||||
public <T extends BeforeRunTask> List<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks) {
|
||||
final List<T> tasks = new ArrayList<T>();
|
||||
if (includeOnlyActiveTasks) {
|
||||
final Set<RunnerAndConfigurationSettings> checkedTemplates = new HashSet<RunnerAndConfigurationSettings>();
|
||||
final List<RunnerAndConfigurationSettings> checkedTemplates = new ArrayList<RunnerAndConfigurationSettings>();
|
||||
for (RunnerAndConfigurationSettings settings : myConfigurations.values()) {
|
||||
final BeforeRunTask runTask = getBeforeRunTask(settings.getConfiguration(), taskProviderID);
|
||||
if (runTask != null && runTask.isEnabled()) {
|
||||
tasks.add((T)runTask);
|
||||
}
|
||||
else {
|
||||
final RunnerAndConfigurationSettings template = getConfigurationTemplate(settings.getFactory());
|
||||
if (!checkedTemplates.contains(template)) {
|
||||
checkedTemplates.add(template);
|
||||
final BeforeRunTask templateTask = getBeforeRunTask(template.getConfiguration(), taskProviderID);
|
||||
if (templateTask != null && templateTask.isEnabled()) {
|
||||
tasks.add((T)templateTask);
|
||||
final List<BeforeRunTask> runTasks = getBeforeRunTasks(settings.getConfiguration());
|
||||
for (BeforeRunTask task : runTasks) {
|
||||
if (task != null && task.isEnabled() && task.getProviderId() == taskProviderID) {
|
||||
tasks.add((T)task);
|
||||
}
|
||||
else {
|
||||
final RunnerAndConfigurationSettings template = getConfigurationTemplate(settings.getFactory());
|
||||
if (!checkedTemplates.contains(template)) {
|
||||
checkedTemplates.add(template);
|
||||
final List<BeforeRunTask> templateTasks = getBeforeRunTasks(template.getConfiguration());
|
||||
for (BeforeRunTask templateTask : templateTasks) {
|
||||
if (templateTask != null && templateTask.isEnabled() && templateTask.getProviderId() == taskProviderID) {
|
||||
tasks.add((T)templateTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -753,15 +730,17 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
else {
|
||||
for (RunnerAndConfigurationSettings settings : myTemplateConfigurationsMap.values()) {
|
||||
final T task = getBeforeRunTask(settings.getConfiguration(), taskProviderID);
|
||||
if (task != null) {
|
||||
tasks.add(task);
|
||||
final List<BeforeRunTask> tasks_ = getBeforeRunTasks(settings.getConfiguration());
|
||||
for (BeforeRunTask task : tasks_) {
|
||||
if (task != null && task.getProviderId() == taskProviderID)
|
||||
tasks.add((T)task);
|
||||
}
|
||||
}
|
||||
for (RunnerAndConfigurationSettings settings : myConfigurations.values()) {
|
||||
final T task = getBeforeRunTask(settings.getConfiguration(), taskProviderID);
|
||||
if (task != null) {
|
||||
tasks.add(task);
|
||||
final List<BeforeRunTask> tasks_ = getBeforeRunTasks(settings.getConfiguration());
|
||||
for (BeforeRunTask task : tasks_) {
|
||||
if (task != null && task.getProviderId() == taskProviderID)
|
||||
tasks.add((T)task);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -811,49 +790,64 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends BeforeRunTask> T getBeforeRunTask(RunConfiguration settings, Key<T> taskProviderID) {
|
||||
Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks = myConfigurationToBeforeTasksMap.get(settings);
|
||||
if (tasks == null) {
|
||||
tasks = getBeforeRunTasks(settings);
|
||||
myConfigurationToBeforeTasksMap.put(settings, tasks);
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID) {
|
||||
List<BeforeRunTask> tasks = getBeforeRunTasks(settings);
|
||||
List<T> result = new ArrayList<T>();
|
||||
for (BeforeRunTask task : tasks) {
|
||||
if (task.getProviderId() == taskProviderID)
|
||||
result.add((T)task);
|
||||
}
|
||||
return (T)tasks.get(taskProviderID);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<Key<? extends BeforeRunTask>, BeforeRunTask> getBeforeRunTasks(final RunConfiguration settings) {
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks = myConfigurationToBeforeTasksMap.get(settings);
|
||||
@NotNull
|
||||
public List<BeforeRunTask> getBeforeRunTasks(final RunConfiguration settings) {
|
||||
return getBeforeRunTasks(settings, false);
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
public List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings, boolean includeOnlyActiveTasks) {
|
||||
final List<BeforeRunTask> tasks = myConfigurationToBeforeTasksMap.get(settings);
|
||||
if (tasks != null) {
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> _tasks = new HashMap<Key<? extends BeforeRunTask>, BeforeRunTask>();
|
||||
for (Map.Entry<Key<? extends BeforeRunTask>, BeforeRunTask> entry : tasks.entrySet()) {
|
||||
_tasks.put(entry.getKey(), entry.getValue().clone());
|
||||
}
|
||||
return _tasks;
|
||||
return getCopies(tasks, includeOnlyActiveTasks);
|
||||
}
|
||||
|
||||
final RunnerAndConfigurationSettings template = getConfigurationTemplate(settings.getFactory());
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> templateTasks = myConfigurationToBeforeTasksMap.get(template.getConfiguration());
|
||||
final List<BeforeRunTask> templateTasks = myConfigurationToBeforeTasksMap.get(template.getConfiguration());
|
||||
if (templateTasks != null) {
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> _tasks = new HashMap<Key<? extends BeforeRunTask>, BeforeRunTask>();
|
||||
for (Map.Entry<Key<? extends BeforeRunTask>, BeforeRunTask> entry : templateTasks.entrySet()) {
|
||||
_tasks.put(entry.getKey(), entry.getValue().clone());
|
||||
}
|
||||
return _tasks;
|
||||
return getCopies(templateTasks, includeOnlyActiveTasks);
|
||||
}
|
||||
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> _tasks = new HashMap<Key<? extends BeforeRunTask>, BeforeRunTask>();
|
||||
final List<BeforeRunTask> _tasks = new ArrayList<BeforeRunTask>();
|
||||
for (BeforeRunTaskProvider<? extends BeforeRunTask> provider : Extensions
|
||||
.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myProject)) {
|
||||
BeforeRunTask task = provider.createTask(settings);
|
||||
if (task != null) {
|
||||
if (includeOnlyActiveTasks && !task.isEnabled())
|
||||
continue;
|
||||
Key<? extends BeforeRunTask> providerID = provider.getId();
|
||||
_tasks.put(providerID, task);
|
||||
_tasks.add(task);
|
||||
settings.getFactory().configureBeforeRunTaskDefaults(providerID, task);
|
||||
}
|
||||
}
|
||||
return _tasks;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<BeforeRunTask> getCopies(List<BeforeRunTask> original, boolean includeOnlyActiveTasks) {
|
||||
List<BeforeRunTask> result = new ArrayList<BeforeRunTask>();
|
||||
if (original != null) {
|
||||
for (BeforeRunTask task : original) {
|
||||
if (includeOnlyActiveTasks && !task.isEnabled())
|
||||
continue;
|
||||
result.add(task.clone());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void shareConfiguration(final RunConfiguration runConfiguration, final boolean shareConfiguration) {
|
||||
RunnerAndConfigurationSettings settings = getSettings(runConfiguration);
|
||||
boolean shouldFire = settings != null && isConfigurationShared(settings) != shareConfiguration;
|
||||
@@ -864,14 +858,8 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
if (shouldFire) fireRunConfigurationChanged(settings);
|
||||
}
|
||||
|
||||
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks) {
|
||||
final Map<Key<? extends BeforeRunTask>, BeforeRunTask> taskMap = getBeforeRunTasks(runConfiguration);
|
||||
for (Map.Entry<Key<? extends BeforeRunTask>, BeforeRunTask> entry : tasks.entrySet()) {
|
||||
//if (taskMap.containsKey(entry.getKey())) {
|
||||
taskMap.put(entry.getKey(), entry.getValue());
|
||||
//}
|
||||
}
|
||||
myConfigurationToBeforeTasksMap.put(runConfiguration, taskMap);
|
||||
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, List<BeforeRunTask> tasks) {
|
||||
myConfigurationToBeforeTasksMap.put(runConfiguration, tasks);
|
||||
fireBeforeRunTasksUpdated();
|
||||
}
|
||||
|
||||
@@ -881,7 +869,7 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
public void addConfiguration(final RunnerAndConfigurationSettings settings, final boolean isShared) {
|
||||
addConfiguration(settings, isShared, Collections.<Key<? extends BeforeRunTask>, BeforeRunTask>emptyMap());
|
||||
addConfiguration(settings, isShared, new ArrayList<BeforeRunTask>());
|
||||
}
|
||||
|
||||
public static RunManagerImpl getInstanceImpl(final Project project) {
|
||||
@@ -958,8 +946,8 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
|
||||
}
|
||||
|
||||
private void initProviderMaps() {
|
||||
myBeforeStepsMap = new HashMap<Key<? extends BeforeRunTask>, BeforeRunTaskProvider>();
|
||||
myProviderKeysMap = new HashMap<String, Key<? extends BeforeRunTask>>();
|
||||
myBeforeStepsMap = new LinkedHashMap<Key<? extends BeforeRunTask>, BeforeRunTaskProvider>();
|
||||
myProviderKeysMap = new LinkedHashMap<String, Key<? extends BeforeRunTask>>();
|
||||
for (BeforeRunTaskProvider<? extends BeforeRunTask> provider : Extensions
|
||||
.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myProject)) {
|
||||
final Key<? extends BeforeRunTask> id = provider.getId();
|
||||
|
||||
+2
-1
@@ -368,7 +368,8 @@ public class RunnerAndConfigurationSettingsImpl implements JDOMExternalizable, C
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getType() + ": " + getName();
|
||||
ConfigurationType type = getType();
|
||||
return (type != null ? type.getDisplayName() + ": " : "" ) + getName();
|
||||
}
|
||||
|
||||
private class InfoProvider implements ConfigurationInfoProvider {
|
||||
|
||||
+19
-6
@@ -18,6 +18,7 @@ package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.BeforeRunTask;
|
||||
import com.intellij.execution.BeforeRunTaskProvider;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
@@ -42,30 +43,42 @@ public class UnknownBeforeRunTaskProvider extends BeforeRunTaskProvider<UnknownB
|
||||
return myId;
|
||||
}
|
||||
|
||||
public String getDescription(RunConfiguration runConfiguration, UnknownTask task) {
|
||||
return "Unknown task " + myId.toString();
|
||||
@Override
|
||||
public String getName() {
|
||||
return ExecutionBundle.message("before.launch.run.unknown.task");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(UnknownTask task) {
|
||||
return ExecutionBundle.message("before.launch.run.unknown.task") + " " + myId.toString();
|
||||
}
|
||||
|
||||
public boolean configureTask(RunConfiguration runConfiguration, UnknownTask task) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecuteTask(RunConfiguration configuration, UnknownTask task) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean executeTask(DataContext context, RunConfiguration configuration, UnknownTask task) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasConfigurationButton() {
|
||||
public boolean isConfigurable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public UnknownTask createTask(RunConfiguration runConfiguration) {
|
||||
return new UnknownTask();
|
||||
return new UnknownTask(getId());
|
||||
}
|
||||
|
||||
public static final class UnknownTask extends BeforeRunTask {
|
||||
public static final class UnknownTask extends BeforeRunTask<UnknownTask> {
|
||||
private Element myConfig;
|
||||
|
||||
public UnknownTask() {
|
||||
public UnknownTask(Key<UnknownTask> providerId) {
|
||||
super(providerId);
|
||||
}
|
||||
|
||||
public void readExternal(Element element) {
|
||||
|
||||
@@ -393,7 +393,7 @@ public class FindInProjectUtil {
|
||||
public boolean processFile(@NotNull VirtualFile virtualFile) {
|
||||
if (!virtualFile.isDirectory() &&
|
||||
(fileMaskRegExp == null || fileMaskRegExp.matcher(virtualFile.getName()).matches()) &&
|
||||
customScope.contains(virtualFile)) {
|
||||
(customScope == null || customScope.contains(virtualFile))) {
|
||||
final PsiFile psiFile = psiManager.findFile(virtualFile);
|
||||
if (psiFile != null && !filesForFastWordSearch.contains(psiFile)) {
|
||||
myFiles.add(psiFile);
|
||||
@@ -411,7 +411,7 @@ public class FindInProjectUtil {
|
||||
|
||||
if (psiDirectory == null) {
|
||||
boolean success = fileIndex.iterateContent(iterator);
|
||||
if (success && customScope.isSearchInLibraries()) {
|
||||
if (success && customScope != null && customScope.isSearchInLibraries()) {
|
||||
OrderEnumerator enumerator = module == null ? OrderEnumerator.orderEntries(project) : OrderEnumerator.orderEntries(module);
|
||||
final VirtualFile[] librarySources = enumerator.withoutModuleSourceEntries().withoutDepModules().getSourceRoots();
|
||||
iterateAll(librarySources, customScope, iterator);
|
||||
@@ -451,14 +451,11 @@ public class FindInProjectUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
private static GlobalSearchScope toGlobal(@NotNull Project project, @Nullable SearchScope scope) {
|
||||
if (scope instanceof GlobalSearchScope) {
|
||||
if (scope instanceof GlobalSearchScope || scope == null) {
|
||||
return (GlobalSearchScope)scope;
|
||||
}
|
||||
if (scope == null) {
|
||||
return projectContentScope(project);
|
||||
}
|
||||
Set<VirtualFile> files = new HashSet<VirtualFile>();
|
||||
for (PsiElement element : ((LocalSearchScope)scope).getScope()) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
@@ -471,8 +468,8 @@ public class FindInProjectUtil {
|
||||
|
||||
@NotNull
|
||||
private static Pair<Boolean, Collection<PsiFile>> getFilesForFastWordSearch(@NotNull final FindModel findModel, @NotNull final Project project,
|
||||
@Nullable final PsiDirectory psiDirectory, final Pattern fileMaskRegExp,
|
||||
@Nullable final Module module) {
|
||||
@Nullable final PsiDirectory psiDirectory, final Pattern fileMaskRegExp,
|
||||
@Nullable final Module module) {
|
||||
if (DumbService.getInstance(project).isDumb()) {
|
||||
return new Pair<Boolean, Collection<PsiFile>>(false, Collections.<PsiFile>emptyList());
|
||||
}
|
||||
@@ -480,13 +477,16 @@ public class FindInProjectUtil {
|
||||
PsiManager pm = PsiManager.getInstance(project);
|
||||
CacheManager cacheManager = CacheManager.SERVICE.getInstance(project);
|
||||
SearchScope customScope = findModel.getCustomScope();
|
||||
@NotNull GlobalSearchScope scope = psiDirectory != null
|
||||
? GlobalSearchScopes.directoryScope(psiDirectory, true)
|
||||
: module != null
|
||||
? moduleContentScope(module)
|
||||
: customScope instanceof GlobalSearchScope
|
||||
? (GlobalSearchScope)customScope
|
||||
: toGlobal(project, customScope);
|
||||
GlobalSearchScope scope = psiDirectory != null
|
||||
? GlobalSearchScopes.directoryScope(psiDirectory, true)
|
||||
: module != null
|
||||
? moduleContentScope(module)
|
||||
: customScope instanceof GlobalSearchScope
|
||||
? (GlobalSearchScope)customScope
|
||||
: toGlobal(project, customScope);
|
||||
if (scope == null) {
|
||||
scope = GlobalSearchScope.projectScope(project);
|
||||
}
|
||||
|
||||
Set<Integer> keys = new THashSet<Integer>(30);
|
||||
Set<PsiFile> resultFiles = new THashSet<PsiFile>();
|
||||
@@ -554,16 +554,7 @@ public class FindInProjectUtil {
|
||||
return new Pair<Boolean, Collection<PsiFile>>(fast, resultFiles);
|
||||
}
|
||||
|
||||
private static GlobalSearchScope projectContentScope(final Project project) {
|
||||
GlobalSearchScope result = null;
|
||||
for (Module module : ModuleManager.getInstance(project).getModules()) {
|
||||
GlobalSearchScope moduleContent = moduleContentScope(module);
|
||||
result = result == null ? moduleContent : result.uniteWith(moduleContent);
|
||||
}
|
||||
return result == null ? GlobalSearchScope.EMPTY_SCOPE : result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
private static GlobalSearchScope moduleContentScope(@NotNull final Module module) {
|
||||
VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
|
||||
GlobalSearchScope result = null;
|
||||
|
||||
@@ -614,12 +614,7 @@ public class ProjectRootManagerImpl extends ProjectRootManagerEx implements Proj
|
||||
private void addRootsToWatch() {
|
||||
final Set<String> rootPaths = getAllRoots(false);
|
||||
if (rootPaths == null) return;
|
||||
|
||||
final Set<LocalFileSystem.WatchRequest> newRootsToWatch = LocalFileSystem.getInstance().addRootsToWatch(rootPaths, true);
|
||||
|
||||
//remove old requests after adding new ones, helps avoiding unnecessary synchronizations
|
||||
LocalFileSystem.getInstance().removeWatchedRoots(myRootsToWatch);
|
||||
myRootsToWatch = newRootsToWatch;
|
||||
myRootsToWatch = LocalFileSystem.getInstance().replaceWatchedRoots(myRootsToWatch, rootPaths, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+55
-21
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.impl.libraries;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -12,17 +27,15 @@ import com.intellij.openapi.vfs.newvfs.events.*;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author ksafonov
|
||||
*/
|
||||
public abstract class JarDirectoryWatcher implements Disposable {
|
||||
|
||||
private final JarDirectories myJarDirectories;
|
||||
private MessageBusConnection myBusConnection = null;
|
||||
private final List<LocalFileSystem.WatchRequest> myWatchRequests = new ArrayList<LocalFileSystem.WatchRequest>();
|
||||
private Collection<LocalFileSystem.WatchRequest> myWatchRequests = Collections.emptySet();
|
||||
|
||||
public JarDirectoryWatcher(JarDirectories jarDirectories) {
|
||||
myJarDirectories = jarDirectories;
|
||||
@@ -30,21 +43,39 @@ public abstract class JarDirectoryWatcher implements Disposable {
|
||||
|
||||
public void updateWatchedRoots() {
|
||||
final LocalFileSystem fs = LocalFileSystem.getInstance();
|
||||
if (!myWatchRequests.isEmpty()) {
|
||||
fs.removeWatchedRoots(myWatchRequests);
|
||||
myWatchRequests.clear();
|
||||
}
|
||||
if (!myJarDirectories.isEmpty()) {
|
||||
final Set<String> recursiveRoots = new HashSet<String>();
|
||||
final Set<String> flatRoots = new HashSet<String>();
|
||||
final VirtualFileManager fm = VirtualFileManager.getInstance();
|
||||
for (OrderRootType rootType : myJarDirectories.getRootTypes()) {
|
||||
for (String url : myJarDirectories.getDirectories(rootType)) {
|
||||
if (fm.getFileSystem(VirtualFileManager.extractProtocol(url)) instanceof LocalFileSystem) {
|
||||
final boolean watchRecursively = myJarDirectories.isRecursive(rootType, url);
|
||||
final LocalFileSystem.WatchRequest request = fs.addRootToWatch(VirtualFileManager.extractPath(url), watchRecursively);
|
||||
myWatchRequests.add(request);
|
||||
final String path = VirtualFileManager.extractPath(url);
|
||||
(watchRecursively ? recursiveRoots : flatRoots).add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flatRoots.isEmpty()) {
|
||||
myWatchRequests = fs.replaceWatchedRoots(myWatchRequests, recursiveRoots, true);
|
||||
}
|
||||
else if (recursiveRoots.isEmpty()) {
|
||||
myWatchRequests = fs.replaceWatchedRoots(myWatchRequests, flatRoots, false);
|
||||
}
|
||||
else {
|
||||
fs.removeWatchedRoots(myWatchRequests);
|
||||
final int rootsTotal = flatRoots.size() + recursiveRoots.size();
|
||||
if (rootsTotal > 0) {
|
||||
myWatchRequests = new ArrayList<LocalFileSystem.WatchRequest>(rootsTotal);
|
||||
myWatchRequests.addAll(fs.addRootsToWatch(flatRoots, false));
|
||||
myWatchRequests.addAll(fs.addRootsToWatch(recursiveRoots, true));
|
||||
}
|
||||
else {
|
||||
myWatchRequests = Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
if (myBusConnection == null) {
|
||||
myBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
myBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
|
||||
@@ -58,17 +89,18 @@ public abstract class JarDirectoryWatcher implements Disposable {
|
||||
for (VFileEvent event : events) {
|
||||
if (event instanceof VFileCopyEvent) {
|
||||
final VFileCopyEvent copyEvent = (VFileCopyEvent)event;
|
||||
final VirtualFile file = copyEvent.getFile();
|
||||
if (isUnderJarDirectory(copyEvent.getNewParent() + "/" + copyEvent.getNewChildName()) ||
|
||||
isUnderJarDirectory(copyEvent.getFile().getUrl())) {
|
||||
file != null && isUnderJarDirectory(file.getUrl())) {
|
||||
changesDetected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (event instanceof VFileMoveEvent) {
|
||||
final VFileMoveEvent moveEvent = (VFileMoveEvent)event;
|
||||
|
||||
final VirtualFile file = moveEvent.getFile();
|
||||
if (isUnderJarDirectory(file.getUrl()) || isUnderJarDirectory(moveEvent.getOldParent().getUrl() + "/" + file.getName())) {
|
||||
if (file != null &&
|
||||
(isUnderJarDirectory(file.getUrl()) || isUnderJarDirectory(moveEvent.getOldParent().getUrl() + "/" + file.getName()))) {
|
||||
changesDetected = true;
|
||||
break;
|
||||
}
|
||||
@@ -106,11 +138,7 @@ public abstract class JarDirectoryWatcher implements Disposable {
|
||||
}
|
||||
}
|
||||
else {
|
||||
final MessageBusConnection connection = myBusConnection;
|
||||
if (connection != null) {
|
||||
myBusConnection = null;
|
||||
connection.disconnect();
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,13 +146,19 @@ public abstract class JarDirectoryWatcher implements Disposable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
if (!myWatchRequests.isEmpty()) {
|
||||
LocalFileSystem.getInstance().removeWatchedRoots(myWatchRequests);
|
||||
myWatchRequests.clear();
|
||||
myWatchRequests = Collections.emptySet();
|
||||
}
|
||||
if (myBusConnection != null) {
|
||||
myBusConnection.disconnect();
|
||||
|
||||
final MessageBusConnection connection = myBusConnection;
|
||||
if (connection != null) {
|
||||
myBusConnection = null;
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,8 @@ public class ExtractIncludeDialog extends DialogWrapper {
|
||||
private void validateOKButton() {
|
||||
final String fileName = myNameField.getText().trim();
|
||||
setOKActionEnabled(myTargetDirectoryField.getText().trim().length() > 0 &&
|
||||
fileName.length() > 0 && fileName.indexOf(File.separatorChar) < 0 && !StringUtil.containsAnyChar(fileName, "*?><\":;|"));
|
||||
fileName.length() > 0 && fileName.indexOf(File.separatorChar) < 0 &&
|
||||
!StringUtil.containsAnyChar(fileName, "*?><\":;|") && fileName.indexOf(".") != 0);
|
||||
}
|
||||
|
||||
private static boolean isFileExist(@NotNull final String directory, @NotNull final String fileName) {
|
||||
|
||||
@@ -99,18 +99,21 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener
|
||||
if (value != null) {
|
||||
configureEditor(getEditor(), value);
|
||||
IdeFocusManager.getGlobalInstance().requestFocus(ComboBox.this, true);
|
||||
assert myJBPopup != null;
|
||||
ComboBox.this.getUI().setPopupVisible(ComboBox.this, false);
|
||||
myJBPopup.cancel();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setFocusOwners(new Component[]{this})
|
||||
.setMinSize(new Dimension(getWidth(), -1))
|
||||
.setMovable(false)
|
||||
.setResizable(false)
|
||||
.createPopup();
|
||||
list.setBorder(IdeBorderFactory.createEmptyBorder(0));
|
||||
myJBPopup.showUnderneathOf(this);
|
||||
list.addFocusListener(new FocusAdapter() {
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
ComboBox.this.getUI().setPopupVisible(ComboBox.this, false);
|
||||
myJBPopup.cancel();
|
||||
}
|
||||
});
|
||||
@@ -167,8 +170,10 @@ public class ComboBox extends ComboBoxWithWidePopup implements AWTEventListener
|
||||
public void removeNotify() {
|
||||
super.removeNotify();
|
||||
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
|
||||
if (myJBPopup != null && myJBPopup.isVisible()) {
|
||||
if (myJBPopup != null) {
|
||||
getUI().setPopupVisible(this, false);
|
||||
myJBPopup.cancel();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
|
||||
public abstract class LocalFileSystem extends NewVirtualFileSystem {
|
||||
@NonNls public static final String PROTOCOL = "file";
|
||||
@NonNls public static final String PROTOCOL_PREFIX = PROTOCOL + "://";
|
||||
@@ -125,14 +128,34 @@ public abstract class LocalFileSystem extends NewVirtualFileSystem {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively);
|
||||
public WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean watchRecursively) {
|
||||
final Set<WatchRequest> result = addRootsToWatch(singleton(rootPath), watchRecursively);
|
||||
return result.size() == 1 ? result.iterator().next() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean toWatchRecursively);
|
||||
public abstract Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean watchRecursively);
|
||||
|
||||
public abstract void removeWatchedRoots(@NotNull final Collection<WatchRequest> rootsToWatch);
|
||||
public void removeWatchedRoot(@Nullable final WatchRequest watchRequest) {
|
||||
if (watchRequest != null) {
|
||||
removeWatchedRoots(singleton(watchRequest));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void removeWatchedRoot(@NotNull final WatchRequest watchRequest);
|
||||
public abstract void removeWatchedRoots(@NotNull final Collection<WatchRequest> watchRequests);
|
||||
|
||||
@Nullable
|
||||
public WatchRequest replaceWatchedRoot(@Nullable final WatchRequest watchRequest,
|
||||
@NotNull final String rootPath,
|
||||
final boolean watchRecursively) {
|
||||
final Set<WatchRequest> requests = watchRequest != null ? singleton(watchRequest) : Collections.<WatchRequest>emptySet();
|
||||
final Set<WatchRequest> result = replaceWatchedRoots(requests, singleton(rootPath), watchRecursively);
|
||||
return result.size() == 1 ? result.iterator().next() : null;
|
||||
}
|
||||
|
||||
public abstract Set<WatchRequest> replaceWatchedRoots(@NotNull final Collection<WatchRequest> watchRequests,
|
||||
@NotNull final Collection<String> rootPaths,
|
||||
final boolean watchRecursively);
|
||||
|
||||
public abstract void registerAuxiliaryFileOperationsHandler(@NotNull LocalFileOperationsHandler handler);
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ public class CollectionListModel<T> extends AbstractListModel {
|
||||
}
|
||||
|
||||
public void add(@NotNull final List<? extends T> elements) {
|
||||
if (elements.isEmpty())
|
||||
return;
|
||||
int i = myItems.size();
|
||||
myItems.addAll(elements);
|
||||
fireIntervalAdded(this, i, i + elements.size() - 1);
|
||||
@@ -93,8 +95,7 @@ public class CollectionListModel<T> extends AbstractListModel {
|
||||
}
|
||||
|
||||
public void replaceAll(@NotNull final List<? extends T> elements) {
|
||||
myItems.clear();
|
||||
myItems.addAll(elements);
|
||||
fireIntervalAdded(this, 0, elements.size() - 1);
|
||||
removeAll();
|
||||
add(elements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +168,29 @@ public class ListUtil {
|
||||
if (model instanceof FilteringListModel) {
|
||||
return (DefaultListModel)((FilteringListModel)model).getOriginalModel();
|
||||
}
|
||||
if (model instanceof CollectionListModel) {
|
||||
return getWrapperModel(((CollectionListModel)model));
|
||||
}
|
||||
return (DefaultListModel)model;
|
||||
}
|
||||
|
||||
private static DefaultListModel getWrapperModel(final CollectionListModel source) {
|
||||
DefaultListModel model = new DefaultListModel() {
|
||||
@Override
|
||||
public Object set(int index, Object element) {
|
||||
Object o = source.getElementAt(index);
|
||||
source.setElementAt(element, index);
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(int index) {
|
||||
return source.getElementAt(index);
|
||||
}
|
||||
};
|
||||
return model;
|
||||
}
|
||||
|
||||
public static boolean canMoveSelectedItemsDown(JList list) {
|
||||
ListModel model = list.getModel();
|
||||
int[] indices = list.getSelectedIndices();
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ComponentWithExpandableItems;
|
||||
import com.intellij.ui.ExpandableItemsHandler;
|
||||
import com.intellij.ui.ExpandableItemsHandlerFactory;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
@@ -225,4 +226,15 @@ public class JBList extends JList implements ComponentWithEmptyText, ComponentWi
|
||||
public void disableEmptyText() {
|
||||
getEmptyText().setText("");
|
||||
}
|
||||
|
||||
public static class StripedListCellRenderer extends DefaultListCellRenderer {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (!isSelected && index % 2 == 0) {
|
||||
setBackground(JBTable.DECORATED_ROW_BG_COLOR);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.util.Comparator;
|
||||
import java.util.EventObject;
|
||||
|
||||
public class JBTable extends JTable implements ComponentWithEmptyText, ComponentWithExpandableItems<TableCell> {
|
||||
private static final Color DECORATED_ROW_BG_COLOR = new Color(242, 245, 249);
|
||||
public static final Color DECORATED_ROW_BG_COLOR = new Color(242, 245, 249);
|
||||
private StatusText myEmptyText;
|
||||
private ExpandableItemsHandler<TableCell> myExpandableItemsHandler;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<orderEntry type="library" name="winp" level="project" />
|
||||
<orderEntry type="library" name="swingx" level="project" />
|
||||
<orderEntry type="module" module-name="core-impl" exported="" />
|
||||
<orderEntry type="library" exported="" name="miglayout-swing" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -287,7 +287,7 @@ public class IdeEventQueue extends EventQueue {
|
||||
return myDispatchers.contains(dispatcher);
|
||||
}
|
||||
|
||||
public void addPostprocessor(EventDispatcher dispatcher, Disposable parent) {
|
||||
public void addPostprocessor(EventDispatcher dispatcher, @Nullable Disposable parent) {
|
||||
_addProcessor(dispatcher, parent, myPostprocessors);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,10 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
@@ -42,7 +45,6 @@ import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowManagerImpl;
|
||||
import com.intellij.openapi.wm.impl.content.GraphicsConfig;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.speedSearch.NameFilteringListModel;
|
||||
@@ -142,25 +144,25 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) return;
|
||||
boolean selectFirstItem = false;
|
||||
if (SWITCHER == null) {
|
||||
synchronized (Switcher.class) {
|
||||
if (SWITCHER == null) {
|
||||
SWITCHER = createAndShowSwitcher(project, SWITCHER_TITLE, false);
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(SWITCHER_FEATURE_ID);
|
||||
selectFirstItem = !FileEditorManagerEx.getInstanceEx(project).hasOpenedFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert SWITCHER != null;
|
||||
if (e.getInputEvent().isShiftDown()) {
|
||||
SWITCHER.goBack();
|
||||
} else {
|
||||
if (selectFirstItem) {
|
||||
SWITCHER.files.setSelectedIndex(0);
|
||||
if (!SWITCHER.isPinnedMode()) {
|
||||
if (e.getInputEvent().isShiftDown()) {
|
||||
SWITCHER.goBack();
|
||||
} else {
|
||||
SWITCHER.goForward();
|
||||
if (!FileEditorManagerEx.getInstanceEx(project).hasOpenedFile()) {
|
||||
SWITCHER.files.setSelectedIndex(0);
|
||||
} else {
|
||||
SWITCHER.goForward();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +249,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
public boolean value(String s) {
|
||||
return !mySpeedSearch.isPopupActive()
|
||||
|| StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix())
|
||||
|| mySpeedSearch.matchingFragments(s) != null;
|
||||
|| mySpeedSearch.getComparator().matchingFragments(mySpeedSearch.getEnteredPrefix(), s) != null;
|
||||
}
|
||||
}, mySpeedSearch);
|
||||
}
|
||||
@@ -291,6 +293,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
};
|
||||
separator.setBackground(Color.WHITE);
|
||||
|
||||
int selectionIndex = -1;
|
||||
final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(project);
|
||||
final ArrayList<FileInfo> filesData = new ArrayList<FileInfo>();
|
||||
final ArrayList<FileInfo> editors = new ArrayList<FileInfo>();
|
||||
@@ -320,12 +323,13 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
filesData.add(info);
|
||||
if (!firstRecentMarked) {
|
||||
firstRecentMarked = true;
|
||||
info.isSeparator = true;
|
||||
selectionIndex = filesData.size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (editors.size() == 1 && (filesData.isEmpty() || !editors.get(0).getFirst().equals(filesData.get(0).getFirst()))) {
|
||||
filesData.add(0, editors.get(0));
|
||||
selectionIndex--;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < Math.min(MAX_FILES_IN_SWITCHER, editors.size()); i++) {
|
||||
@@ -338,22 +342,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
filesModel.addElement(editor);
|
||||
}
|
||||
|
||||
final VirtualFilesRenderer filesRenderer = new VirtualFilesRenderer(project, mySpeedSearch) {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
final JComponent renderer = (JComponent)super.getListCellRendererComponent(list, value, index, selected, hasFocus);
|
||||
if (selected) {
|
||||
return renderer;
|
||||
}
|
||||
final Color bgColor = list == mouseMoveSrc && index == mouseMoveListIndex ? ON_MOUSE_OVER_BG_COLOR : Color.WHITE;
|
||||
UIUtil.changeBackGround(renderer, bgColor);
|
||||
return renderer;
|
||||
}
|
||||
};
|
||||
final VirtualFilesRenderer filesRenderer = new VirtualFilesRenderer(project);
|
||||
|
||||
final ListSelectionListener filesSelectionListener = new ListSelectionListener() {
|
||||
private String getTitle2Text(String fullText) {
|
||||
@@ -403,7 +392,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
public boolean value(String s) {
|
||||
return !mySpeedSearch.isPopupActive()
|
||||
|| StringUtil.isEmpty(mySpeedSearch.getEnteredPrefix())
|
||||
|| mySpeedSearch.matchingFragments(s) != null;
|
||||
|| mySpeedSearch.getComparator().matchingFragments(mySpeedSearch.getEnteredPrefix(), s) != null;
|
||||
}
|
||||
}, mySpeedSearch);
|
||||
}
|
||||
@@ -437,6 +426,9 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
} else {
|
||||
this.add(files, BorderLayout.EAST);
|
||||
}
|
||||
if (selectionIndex > -1) {
|
||||
files.setSelectedIndex(selectionIndex);
|
||||
}
|
||||
this.add(separator, BorderLayout.CENTER);
|
||||
}
|
||||
this.add(descriptions, BorderLayout.SOUTH);
|
||||
@@ -554,6 +546,12 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
case VK_ESCAPE:
|
||||
cancel();
|
||||
break;
|
||||
case VK_PAGE_DOWN:
|
||||
ListScrollingUtil.movePageDown(getSelectedList());
|
||||
break;
|
||||
case VK_PAGE_UP:
|
||||
ListScrollingUtil.movePageUp(getSelectedList());
|
||||
break;
|
||||
case VK_DELETE:
|
||||
case VK_BACK_SPACE: // Mac users
|
||||
closeTabOrToolWindow();
|
||||
@@ -886,49 +884,30 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
|
||||
private static class VirtualFilesRenderer extends ColoredListCellRenderer {
|
||||
private final Project myProject;
|
||||
private final SpeedSearchBase mySearch;
|
||||
private boolean hide = false;
|
||||
private boolean separator = false;
|
||||
|
||||
public VirtualFilesRenderer(Project project, SpeedSearchBase search) {
|
||||
public VirtualFilesRenderer(Project project) {
|
||||
myProject = project;
|
||||
mySearch = search;
|
||||
}
|
||||
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
hide = false;
|
||||
if (value instanceof FileInfo) {
|
||||
final VirtualFile virtualFile = ((FileInfo)value).first;
|
||||
final String name = virtualFile.getPresentableName();
|
||||
VirtualFile virtualFile = ((FileInfo)value).getFirst();
|
||||
String name = virtualFile.getPresentableName();
|
||||
setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject));
|
||||
separator = ((FileInfo)value).isSeparator;
|
||||
|
||||
if ( mySearch != null && mySearch.isPopupActive()) {
|
||||
hide = mySearch.matchingFragments(name) == null && !StringUtil.isEmpty(mySearch.getEnteredPrefix());
|
||||
}
|
||||
|
||||
final FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile);
|
||||
final TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN);
|
||||
FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile);
|
||||
TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE,
|
||||
Font.PLAIN);
|
||||
append(name, SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPaint(Graphics2D g) {
|
||||
GraphicsConfig config = new GraphicsConfig(g);
|
||||
if (hide) {
|
||||
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.15f));
|
||||
}
|
||||
super.doPaint(g);
|
||||
config.restore();
|
||||
if (separator) {
|
||||
UIUtil.drawDottedLine(g, 0, 0, getWidth(), 0, Color.WHITE, Color.BLACK);
|
||||
if (!selected && FileEditorManager.getInstance(myProject).isFileOpen(virtualFile)) {
|
||||
setBackground(LightColors.SLIGHTLY_GREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileInfo extends Pair<VirtualFile, EditorWindow> {
|
||||
boolean isSeparator = false;
|
||||
public FileInfo(VirtualFile first, EditorWindow second) {
|
||||
super(first, second);
|
||||
}
|
||||
|
||||
@@ -736,7 +736,7 @@ public class DnDManagerImpl extends DnDManager implements Disposable {
|
||||
return myApp;
|
||||
}
|
||||
|
||||
public void setLastDropHandler(Component c) {
|
||||
public void setLastDropHandler(@Nullable Component c) {
|
||||
if (c == null) {
|
||||
myLastDropHandler = null;
|
||||
} else {
|
||||
@@ -744,6 +744,7 @@ public class DnDManagerImpl extends DnDManager implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Component getLastDropHandler() {
|
||||
return myLastDropHandler != null ? myLastDropHandler.get() : null;
|
||||
}
|
||||
|
||||
@@ -103,8 +103,10 @@ public class InstalledPluginsTableModel extends PluginTableModel {
|
||||
}
|
||||
|
||||
public static void updateExistingPlugin(IdeaPluginDescriptor descriptor, IdeaPluginDescriptor existing) {
|
||||
updateExistingPluginInfo(descriptor, existing);
|
||||
updatedPlugins.add(existing.getPluginId());
|
||||
if (existing != null) {
|
||||
updateExistingPluginInfo(descriptor, existing);
|
||||
updatedPlugins.add(existing.getPluginId());
|
||||
}
|
||||
}
|
||||
|
||||
public String getPluginHostUrl(String idString) {
|
||||
|
||||
+13
-8
@@ -15,27 +15,32 @@
|
||||
*/
|
||||
package com.intellij.openapi.application.impl;
|
||||
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* Allows to process elements in the Application pooled thread.
|
||||
* Processes elements in batches, no longer than 200ms per batch, and reschedules processing later for longer batches.
|
||||
* Passes elements for processing in the dedicated thread.
|
||||
* Processes elements in batches, no longer than {maxUnitOfWorkThresholdMs}ms per batch, and reschedules processing later for longer batches.
|
||||
* Usage: {@link #offer(Object)} } : schedules element for processing in a pooled thread
|
||||
*/
|
||||
public class TransferToPooledThreadQueue<T> extends TransferToEDTQueue<T> {
|
||||
public TransferToPooledThreadQueue(@NotNull String name,
|
||||
@NotNull Processor<T> processorInEDT,
|
||||
private final ScheduledThreadPoolExecutor myExecutor = ConcurrencyUtil.newSingleScheduledThreadExecutor("Encoding detection thread");
|
||||
|
||||
public TransferToPooledThreadQueue(@NonNls @NotNull String name,
|
||||
@NotNull Condition<?> shutUpCondition,
|
||||
int maxUnitOfWorkThresholdMs) {
|
||||
super(name, processorInEDT, shutUpCondition, maxUnitOfWorkThresholdMs);
|
||||
int maxUnitOfWorkThresholdMs,
|
||||
@NotNull Processor<T> processor) {
|
||||
super(name, processor, shutUpCondition, maxUnitOfWorkThresholdMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void schedule(@NotNull Runnable updateRunnable) {
|
||||
JobScheduler.getScheduler().execute(updateRunnable);
|
||||
myExecutor.execute(updateRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.editor.ex.util;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.HighlighterColors;
|
||||
@@ -317,7 +318,7 @@ public class LexerEditorHighlighter implements EditorHighlighter, PrioritizedDoc
|
||||
}
|
||||
processor.finish();
|
||||
|
||||
if(myEditor != null) {
|
||||
if(myEditor != null && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
UIUtil.invokeLaterIfNeeded(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -331,50 +331,51 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
public void save() {
|
||||
if (ApplicationManagerEx.getApplicationEx().isDoNotSave()) return; //no need to save
|
||||
|
||||
if (mySavingInProgress.compareAndSet(false, true)) {
|
||||
try {
|
||||
if (isToSaveProjectName()) {
|
||||
final IProjectStore stateStore = getStateStore();
|
||||
final VirtualFile baseDir = stateStore.getProjectBaseDir();
|
||||
if (baseDir != null && baseDir.isValid()) {
|
||||
final VirtualFile ideaDir = baseDir.findChild(DIRECTORY_STORE_FOLDER);
|
||||
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
|
||||
final File nameFile = new File(ideaDir.getPath(), ".name");
|
||||
try {
|
||||
FileUtil.writeToFile(nameFile, getName().getBytes("UTF-8"), false);
|
||||
myOldName = null;
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info("Unable to store project name to: " + nameFile.getPath());
|
||||
}
|
||||
if (!mySavingInProgress.compareAndSet(false, true)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (isToSaveProjectName()) {
|
||||
final IProjectStore stateStore = getStateStore();
|
||||
final VirtualFile baseDir = stateStore.getProjectBaseDir();
|
||||
if (baseDir != null && baseDir.isValid()) {
|
||||
final VirtualFile ideaDir = baseDir.findChild(DIRECTORY_STORE_FOLDER);
|
||||
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
|
||||
final File nameFile = new File(ideaDir.getPath(), ".name");
|
||||
try {
|
||||
FileUtil.writeToFile(nameFile, getName().getBytes("UTF-8"), false);
|
||||
myOldName = null;
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info("Unable to store project name to: " + nameFile.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StoreUtil.doSave(getStateStore());
|
||||
}
|
||||
catch (IComponentStore.SaveCancelledException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
catch (PluginException e) {
|
||||
PluginManager.disablePlugin(e.getPluginId().getIdString());
|
||||
Notification notification = new Notification(
|
||||
PLUGIN_SETTINGS_ERROR,
|
||||
"Unable to save plugin settings!",
|
||||
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
|
||||
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>" : ""),
|
||||
NotificationType.ERROR);
|
||||
Notifications.Bus.notify(notification, this);
|
||||
LOG.info("Unable to save plugin settings",e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
MessagesEx.error(this, ProjectBundle.message("project.save.error", e.getMessage())).showLater();
|
||||
LOG.info("Error saving project", e);
|
||||
} finally {
|
||||
mySavingInProgress.set(false);
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectSaved.TOPIC).saved(this);
|
||||
}
|
||||
StoreUtil.doSave(getStateStore());
|
||||
}
|
||||
catch (IComponentStore.SaveCancelledException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
catch (PluginException e) {
|
||||
PluginManager.disablePlugin(e.getPluginId().getIdString());
|
||||
Notification notification = new Notification(
|
||||
PLUGIN_SETTINGS_ERROR,
|
||||
"Unable to save plugin settings!",
|
||||
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
|
||||
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>" : ""),
|
||||
NotificationType.ERROR);
|
||||
Notifications.Bus.notify(notification, this);
|
||||
LOG.info("Unable to save plugin settings",e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
MessagesEx.error(this, ProjectBundle.message("project.save.error", e.getMessage())).showLater();
|
||||
LOG.info("Error saving project", e);
|
||||
} finally {
|
||||
mySavingInProgress.set(false);
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectSaved.TOPIC).saved(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -86,15 +86,18 @@ public class EncodingManagerImpl extends EncodingManager implements PersistentSt
|
||||
private static final Key<Charset> CACHED_CHARSET_FROM_CONTENT = Key.create("CACHED_CHARSET_FROM_CONTENT");
|
||||
|
||||
private final TransferToPooledThreadQueue<Reference<Document>> myChangedDocuments = new TransferToPooledThreadQueue<Reference<Document>>(
|
||||
"Loading documents", new Processor<Reference<Document>>() {
|
||||
@Override
|
||||
public boolean process(Reference<Document> ref) {
|
||||
Document document = ref.get();
|
||||
if (document == null) return true; // document gced, don't bother
|
||||
handleDocument(document);
|
||||
return true;
|
||||
}
|
||||
}, ApplicationManager.getApplication().getDisposed(), -1); // drain the whole queue, do not reschedule
|
||||
"Loading documents",
|
||||
ApplicationManager.getApplication().getDisposed(),
|
||||
-1, // drain the whole queue, do not reschedule
|
||||
new Processor<Reference<Document>>() {
|
||||
@Override
|
||||
public boolean process(Reference<Document> ref) {
|
||||
Document document = ref.get();
|
||||
if (document == null) return true; // document gced, don't bother
|
||||
handleDocument(document);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
public EncodingManagerImpl(EditorFactory editorFactory) {
|
||||
editorFactory.getEventMulticaster().addDocumentListener(new DocumentAdapter() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileAttributes;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -46,6 +47,8 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
|
||||
new ConcurrentHashSet<String>() :
|
||||
new ConcurrentHashSet<String>(CaseInsensitiveStringHashingStrategy.INSTANCE);
|
||||
|
||||
private final static Logger LOG = Logger.getInstance(JarFileSystemImpl.class);
|
||||
|
||||
@NonNls private static final String IDEA_JARS_NOCOPY = "idea.jars.nocopy";
|
||||
private File myNoCopyJarDir;
|
||||
|
||||
@@ -86,6 +89,7 @@ public class JarFileSystemImpl extends JarFileSystem implements ApplicationCompo
|
||||
SystemInfo.isFileSystemCaseSensitive)) {
|
||||
VirtualFile jarRootToRefresh = markDirty(jarPath);
|
||||
if (jarRootToRefresh != null) {
|
||||
LOG.info(jarPath + " will be refreshed due to " + event);
|
||||
rootsToRefresh.add(jarRootToRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
+114
-113
@@ -15,12 +15,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.vfs.impl.local;
|
||||
|
||||
import com.intellij.openapi.application.AccessToken;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileAttributes;
|
||||
import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -114,6 +113,12 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
public void disposeComponent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "LocalFileSystem";
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void cleanupForNextTest(Set<VirtualFile> survivors) throws IOException {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@@ -231,31 +236,29 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
|
||||
private void setUpFileWatcher() {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isDisposeInProgress() || !myWatcher.isOperational()) return;
|
||||
|
||||
if (application.isDisposeInProgress()) return;
|
||||
final AccessToken token = application.acquireReadActionLock();
|
||||
try {
|
||||
synchronized (myLock) {
|
||||
final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh();
|
||||
final List<String> myRecursiveRoots = new ArrayList<String>();
|
||||
final List<String> myFlatRoots = new ArrayList<String>();
|
||||
|
||||
if (myWatcher.isOperational()) {
|
||||
application.runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (myLock) {
|
||||
final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh();
|
||||
List<String> myRecursiveRoots = new ArrayList<String>();
|
||||
List<String> myFlatRoots = new ArrayList<String>();
|
||||
|
||||
for (WatchRequestImpl root : watchRequests) {
|
||||
if (root.isToWatchRecursively()) {
|
||||
myRecursiveRoots.add(root.myFSRootPath);
|
||||
}
|
||||
else {
|
||||
myFlatRoots.add(root.myFSRootPath);
|
||||
}
|
||||
}
|
||||
|
||||
myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots);
|
||||
for (WatchRequestImpl watchRequest : watchRequests) {
|
||||
if (watchRequest.isToWatchRecursively()) {
|
||||
myRecursiveRoots.add(watchRequest.myFSRootPath);
|
||||
}
|
||||
else {
|
||||
myFlatRoots.add(watchRequest.myFSRootPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,48 +283,6 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "LocalFileSystem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively) {
|
||||
if (rootPath.length() == 0 || !myWatcher.isOperational()) return null;
|
||||
|
||||
Application app = ApplicationManager.getApplication();
|
||||
return app.runReadAction(new Computable<WatchRequest>() {
|
||||
@Override
|
||||
public WatchRequest compute() {
|
||||
synchronized (myLock) {
|
||||
final WatchRequestImpl result = new WatchRequestImpl(rootPath, toWatchRecursively);
|
||||
boolean alreadyWatched = isAlreadyWatched(result);
|
||||
if (!alreadyWatched) {
|
||||
final VirtualFile existingFile = findFileByPathIfCached(rootPath);
|
||||
if (existingFile != null) {
|
||||
final ModalityState modalityState = ModalityState.defaultModalityState();
|
||||
RefreshQueue.getInstance().refresh(true, toWatchRecursively, null, modalityState, existingFile);
|
||||
if (existingFile.isDirectory() && !toWatchRecursively && existingFile instanceof NewVirtualFile) {
|
||||
for (VirtualFile child : ((NewVirtualFile)existingFile).getCachedChildren()) {
|
||||
RefreshQueue.getInstance().refresh(true, false, null, modalityState, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myRootsToWatch.add(result);
|
||||
if (alreadyWatched) {
|
||||
result.myDominated = true;
|
||||
return result;
|
||||
}
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isAlreadyWatched(final WatchRequestImpl request) {
|
||||
for (final WatchRequestImpl current : normalizeRootsForRefresh()) {
|
||||
if (dominates(current, request)) return true;
|
||||
@@ -339,74 +300,114 @@ public final class LocalFileSystemImpl extends LocalFileSystemBase implements Ap
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean toWatchRecursively) {
|
||||
if (!myWatcher.isOperational()) return Collections.emptySet();
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean watchRecursively) {
|
||||
if (rootPaths.isEmpty() || !myWatcher.isOperational()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
else {
|
||||
return replaceWatchedRoots(Collections.<WatchRequest>emptySet(), rootPaths, watchRecursively);
|
||||
}
|
||||
}
|
||||
|
||||
final Set<WatchRequest> result = new HashSet<WatchRequest>();
|
||||
final Set<VirtualFile> filesToSynchronize = new HashSet<VirtualFile>();
|
||||
@Override
|
||||
public void removeWatchedRoots(@NotNull final Collection<WatchRequest> watchRequests) {
|
||||
if (watchRequests.isEmpty()) return;
|
||||
|
||||
Application application = ApplicationManager.getApplication();
|
||||
application.runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
synchronized (myLock) {
|
||||
for (String rootPath : rootPaths) {
|
||||
LOG.assertTrue(rootPath != null);
|
||||
if (rootPath.length() > 0) {
|
||||
final WatchRequestImpl request = new WatchRequestImpl(rootPath, toWatchRecursively);
|
||||
final VirtualFile existingFile = findFileByPathIfCached(rootPath);
|
||||
if (existingFile != null) {
|
||||
if (!isAlreadyWatched(request)) {
|
||||
filesToSynchronize.add(existingFile);
|
||||
}
|
||||
}
|
||||
result.add(request);
|
||||
myRootsToWatch.add(request); //add in any case, safe to add inplace without copying myRootsToWatch before the loop
|
||||
}
|
||||
}
|
||||
final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
synchronized (myLock) {
|
||||
final boolean update = doRemoveWatchedRoots(watchRequests);
|
||||
if (update) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
|
||||
if (!application.isUnitTestMode() && !filesToSynchronize.isEmpty()) {
|
||||
for (VirtualFile file : filesToSynchronize) {
|
||||
if (file instanceof NewVirtualFile && file.getFileSystem() instanceof LocalFileSystem) {
|
||||
((NewVirtualFile)file).markDirtyRecursively();
|
||||
@Override
|
||||
public Set<WatchRequest> replaceWatchedRoots(@NotNull final Collection<WatchRequest> watchRequests,
|
||||
@NotNull final Collection<String> rootPaths,
|
||||
final boolean watchRecursively) {
|
||||
if (rootPaths.isEmpty() || !myWatcher.isOperational()) {
|
||||
removeWatchedRoots(watchRequests);
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
final Set<WatchRequest> result = new HashSet<WatchRequest>();
|
||||
final Set<VirtualFile> filesToSync = new HashSet<VirtualFile>();
|
||||
|
||||
final AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
synchronized (myLock) {
|
||||
final boolean update = doAddRootsToWatch(rootPaths, watchRecursively, result, filesToSync) ||
|
||||
doRemoveWatchedRoots(watchRequests);
|
||||
if (update) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
}
|
||||
refreshFiles(filesToSynchronize, true, toWatchRecursively, null);
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
|
||||
syncFiles(filesToSync, watchRecursively);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoot(@NotNull final WatchRequest watchRequest) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
synchronized (myLock) {
|
||||
if (myRootsToWatch.remove((WatchRequestImpl)watchRequest) && !((WatchRequestImpl)watchRequest).myDominated) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
private boolean doAddRootsToWatch(@NotNull final Collection<String> roots,
|
||||
final boolean recursively,
|
||||
@NotNull final Set<WatchRequest> results,
|
||||
@NotNull final Set<VirtualFile> filesToSync) {
|
||||
boolean update = false;
|
||||
|
||||
for (String root : roots) {
|
||||
final WatchRequestImpl result = new WatchRequestImpl(root, recursively);
|
||||
final boolean alreadyWatched = isAlreadyWatched(result);
|
||||
|
||||
if (!alreadyWatched) {
|
||||
final VirtualFile existingFile = findFileByPathIfCached(root);
|
||||
if (existingFile != null) {
|
||||
if (existingFile.isDirectory() && !recursively && existingFile instanceof NewVirtualFile) {
|
||||
filesToSync.addAll(((NewVirtualFile)existingFile).getCachedChildren());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
result.myDominated = alreadyWatched;
|
||||
myRootsToWatch.add(result);
|
||||
results.add(result);
|
||||
|
||||
update |= !alreadyWatched;
|
||||
}
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoots(@NotNull final Collection<WatchRequest> rootsToWatch) {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
synchronized (myLock) {
|
||||
if (myRootsToWatch.removeAll(rootsToWatch)) {
|
||||
myCachedNormalizedRequests = null;
|
||||
setUpFileWatcher();
|
||||
}
|
||||
}
|
||||
private void syncFiles(@NotNull final Set<VirtualFile> filesToSync, final boolean watchRecursively) {
|
||||
if (filesToSync.isEmpty() || ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
for (VirtualFile file : filesToSync) {
|
||||
if (file instanceof NewVirtualFile && file.getFileSystem() instanceof LocalFileSystem) {
|
||||
((NewVirtualFile)file).markDirtyRecursively();
|
||||
}
|
||||
});
|
||||
}
|
||||
refreshFiles(filesToSync, true, watchRecursively, null);
|
||||
}
|
||||
|
||||
private boolean doRemoveWatchedRoots(@NotNull final Collection<WatchRequest> watchRequests) {
|
||||
boolean update = false;
|
||||
|
||||
for (WatchRequest watchRequest : watchRequests) {
|
||||
final boolean wasWatched = myRootsToWatch.remove((WatchRequestImpl)watchRequest) && !((WatchRequestImpl)watchRequest).myDominated;
|
||||
update |= wasWatched;
|
||||
}
|
||||
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-8
@@ -181,24 +181,19 @@ public class Win32LocalFileSystem extends LocalFileSystemBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WatchRequest addRootToWatch(@NotNull String rootPath, boolean toWatchRecursively) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull Collection<String> rootPaths, boolean toWatchRecursively) {
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull Collection<String> rootPaths, boolean watchRecursively) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoots(@NotNull Collection<WatchRequest> rootsToWatch) {
|
||||
public void removeWatchedRoots(@NotNull Collection<WatchRequest> watchRequests) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoot(@NotNull WatchRequest watchRequest) {
|
||||
public Set<WatchRequest> replaceWatchedRoots(@NotNull Collection<WatchRequest> watchRequests, @NotNull Collection<String> rootPaths, boolean watchRecursively) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@@ -375,10 +375,10 @@ action.ExpandAllRegions.text=_Expand All
|
||||
action.ExpandAllRegions.description=Expand all folding regions
|
||||
action.CollapseAllRegions.text=Collapse _All
|
||||
action.CollapseAllRegions.description=Collapse all folding regions
|
||||
action.ExpandJavadocs.text=Expand Java_docs
|
||||
action.ExpandJavadocs.description=Expand all javadoc comments
|
||||
action.CollapseJavadocs.text=Collapse _Javadocs
|
||||
action.CollapseJavadocs.description=Collapse all javadoc comments
|
||||
action.ExpandDocComments.text=Expand _doc comments
|
||||
action.ExpandDocComments.description=Expand all documentation comments
|
||||
action.CollapseDocComments.text=Collapse d_oc comments
|
||||
action.CollapseDocComments.description=Collapse all documentation comments
|
||||
action.CollapseSelection.text=Fold _Selection / Remove region
|
||||
action.CollapseSelection.description=Fold selected block
|
||||
action.CollapseBlock.text=Fold Code _Block
|
||||
|
||||
@@ -282,6 +282,10 @@ run.configuration.cannot.find.vm.executable=Cannot find VM executable
|
||||
|
||||
logs.tab.title=Logs
|
||||
before.launch.panel.title=Before Launch
|
||||
before.launch.panel.cyclic_dependency_warning=''{0}'' has already configured to be launched before {1}.\nSuch cyclic dependencies are not allowed.
|
||||
before.launch.run.another.configuration=Run another Configuration
|
||||
before.launch.run.certain.configuration=Run ''{0}''
|
||||
before.launch.run.unknown.task=Unknown task
|
||||
action.name.save.as.configuration=Save As
|
||||
default.junit.config.name.all.in.module=All in {0}
|
||||
default.junit.config.name.all.in.package.in.module={0} in {1}
|
||||
|
||||
@@ -151,9 +151,6 @@ compiler.server.use.external.javac.process.description=Run javac compiler in ext
|
||||
compiler.server.ping.interval=5
|
||||
compiler.server.ping.interval.description=Interval in seconds between ping requests the IDE periodically sends to server. If server does not receive pings for some time, it shuts down. Specify -1 to disable this feature.
|
||||
|
||||
compiler.server.in.process=false
|
||||
compiler.server.in.process.description=Launch compiler server in IDEA process
|
||||
|
||||
compiler.server.debug.port=-1
|
||||
#compiler.server.javac.debug.port=-1
|
||||
|
||||
|
||||
@@ -217,7 +217,10 @@
|
||||
<action id="ExpandAllRegions" class="com.intellij.codeInsight.folding.impl.actions.ExpandAllRegionsAction"/>
|
||||
<action id="CollapseAllRegions" class="com.intellij.codeInsight.folding.impl.actions.CollapseAllRegionsAction"/>
|
||||
<separator/>
|
||||
<group id="LanguageSpecificFoldingGroup"/>
|
||||
<group id="LanguageSpecificFoldingGroup">
|
||||
<action id="ExpandDocComments" class="com.intellij.codeInsight.folding.impl.actions.ExpandDocCommentsAction"/>
|
||||
<action id="CollapseDocComments" class="com.intellij.codeInsight.folding.impl.actions.CollapseDocCommentsAction"/>
|
||||
</group>
|
||||
<separator/>
|
||||
<action id="CollapseSelection" class="com.intellij.codeInsight.folding.impl.actions.CollapseSelectionAction"/>
|
||||
</group>
|
||||
|
||||
@@ -81,24 +81,20 @@ public class MockLocalFileSystem extends LocalFileSystem {
|
||||
public void refreshFiles(@NotNull Iterable<VirtualFile> files, boolean async, boolean recursive, @Nullable Runnable onFinish) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public WatchRequest addRootToWatch(@NotNull final String rootPath, final boolean toWatchRecursively) {
|
||||
throw new UnsupportedOperationException("'addRootToWatch' not implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean toWatchRecursively) {
|
||||
throw new UnsupportedOperationException("'addRootsToWatch' not implemented in " + getClass().getName());
|
||||
public Set<WatchRequest> addRootsToWatch(@NotNull final Collection<String> rootPaths, final boolean watchRecursively) {
|
||||
throw new UnsupportedOperationException("Not implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoots(@NotNull final Collection<WatchRequest> rootsToWatch) {
|
||||
throw new UnsupportedOperationException("Not implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWatchedRoot(@NotNull final WatchRequest watchRequest) {
|
||||
public Set<WatchRequest> replaceWatchedRoots(@NotNull Collection<WatchRequest> watchRequests, @NotNull Collection<String> rootPaths, boolean watchRecursively) {
|
||||
throw new UnsupportedOperationException("Not implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
@@ -100,9 +100,7 @@ public class MockRunManager extends RunManagerEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConfiguration(RunnerAndConfigurationSettings settings,
|
||||
boolean isShared,
|
||||
Map<Key<? extends BeforeRunTask>, BeforeRunTask> tasks) {
|
||||
public void addConfiguration(RunnerAndConfigurationSettings settings, boolean isShared, List<BeforeRunTask> tasks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,19 +114,26 @@ public class MockRunManager extends RunManagerEx {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> Map<Key<T>, BeforeRunTask> getBeforeRunTasks(RunConfiguration settings) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BeforeRunTask> T getBeforeRunTask(RunConfiguration settings, Key<T> taskProviderID) {
|
||||
public List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> Collection<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks) {
|
||||
return null;
|
||||
public List<BeforeRunTask> getBeforeRunTasks(RunConfiguration settings, boolean includeOnlyActiveTasks) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> List<T> getBeforeRunTasks(Key<T> taskProviderID, boolean includeOnlyActiveTasks) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends BeforeRunTask> List<T> getBeforeRunTasks(RunConfiguration settings, Key<T> taskProviderID) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -286,7 +286,7 @@ import java.util.Collection;
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
final ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
final String parentUrl = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, libDir);
|
||||
final String parentUrl = VirtualFileManager.constructUrl(classRoots[0].endsWith(".jar!/") ? JarFileSystem.PROTOCOL : LocalFileSystem.PROTOCOL, libDir);
|
||||
final Library library = model.getModuleLibraryTable().createLibrary(libName);
|
||||
final Library.ModifiableModel libModifiableModel = library.getModifiableModel();
|
||||
for (String classRoot : classRoots) {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.testFramework.vcs;
|
||||
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public class MockChangeList extends LocalChangeList {
|
||||
|
||||
Collection<Change> myChanges = new ArrayList<Change>();
|
||||
private final String myName;
|
||||
|
||||
public MockChangeList(String name) {
|
||||
myName = name;
|
||||
}
|
||||
|
||||
public void add(Change change) {
|
||||
myChanges.add(change);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Change> getChanges() {
|
||||
return myChanges;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(@NotNull String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComment(String comment) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadOnly(boolean isReadOnly) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList copy() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
<orderEntry type="module" module-name="community-resources" scope="RUNTIME" />
|
||||
<orderEntry type="library" exported="" scope="TEST" name="Mocks" level="project" />
|
||||
<orderEntry type="module" module-name="java-runtime" exported="" />
|
||||
<orderEntry type="module" module-name="vcs-impl" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+321
@@ -0,0 +1,321 @@
|
||||
package com.intellij.testFramework.vcs;
|
||||
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.continuation.ContinuationPause;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public class MockChangeListManager extends ChangeListManager {
|
||||
|
||||
public static final String DEFAULT_CHANGE_LIST_NAME = "Default";
|
||||
|
||||
private final Map<String, MockChangeList> myChangeLists = new HashMap<String, MockChangeList>();
|
||||
private LocalChangeList myActiveChangeList;
|
||||
private final MockChangeList myDefaultChangeList;
|
||||
|
||||
public MockChangeListManager() {
|
||||
myDefaultChangeList = new MockChangeList(DEFAULT_CHANGE_LIST_NAME);
|
||||
myChangeLists.put(DEFAULT_CHANGE_LIST_NAME, myDefaultChangeList);
|
||||
myActiveChangeList = myDefaultChangeList;
|
||||
}
|
||||
|
||||
public void addChanges(Change... changes) {
|
||||
MockChangeList changeList = myChangeLists.get(DEFAULT_CHANGE_LIST_NAME);
|
||||
for (Change change : changes) {
|
||||
changeList.add(change);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleUpdate() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleUpdate(boolean updateUnversionedFiles) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeAfterUpdate(Runnable afterUpdate,
|
||||
InvokeAfterUpdateMode mode,
|
||||
String title,
|
||||
ModalityState state) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeAfterUpdate(Runnable afterUpdate,
|
||||
InvokeAfterUpdateMode mode,
|
||||
String title,
|
||||
Consumer<VcsDirtyScopeManager> dirtyScopeManager,
|
||||
ModalityState state) {
|
||||
afterUpdate.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ensureUpToDate(boolean canBeCanceled) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalChangeList> getChangeListsCopy() {
|
||||
return new ArrayList<LocalChangeList>(myChangeLists.values());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<LocalChangeList> getChangeLists() {
|
||||
return getChangeListsCopy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<File> getAffectedPaths() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<VirtualFile> getAffectedFiles() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileAffected(VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Change> getAllChanges() {
|
||||
Collection<Change> changes = new ArrayList<Change>();
|
||||
for (MockChangeList list : myChangeLists.values()) {
|
||||
changes.addAll(list.getChanges());
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList findChangeList(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList getChangeList(String id) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList getDefaultChangeList() {
|
||||
return myActiveChangeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefaultChangeList(ChangeList list) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList getChangeList(Change change) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChangeListNameIfOnlyOne(Change[] changes) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Runnable prepareForChangeDeletion(Collection<Change> changes) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change getChange(@NotNull VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList getChangeList(@NotNull VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change getChange(FilePath file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnversioned(VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FileStatus getStatus(VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Change> getChangesIn(VirtualFile dir) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Change> getChangesIn(FilePath path) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChangeListListener(ChangeListListener listener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChangeListListener(ChangeListListener listener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommitExecutor(CommitExecutor executor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commitChanges(LocalChangeList changeList, List<Change> changes) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commitChangesSynchronously(LocalChangeList changeList, List<Change> changes) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commitChangesSynchronouslyWithResult(LocalChangeList changeList, List<Change> changes) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reopenFiles(List<FilePath> paths) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommitExecutor> getRegisteredExecutors() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFilesToIgnore(IgnoredFileBean... ignoredFiles) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilesToIgnore(IgnoredFileBean... ignoredFiles) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IgnoredFileBean[] getFilesToIgnore() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoredFile(@NotNull VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwitchedBranch(VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultListName() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeze(ContinuationPause context, String reason) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void letGo() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String isFreezed() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFreezedWithNotification(@Nullable String modalTitle) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VirtualFile> getModifiedWithoutEditing() {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList addChangeList(@NotNull String name, @Nullable String comment) {
|
||||
MockChangeList changeList = new MockChangeList(name);
|
||||
myChangeLists.put(name, changeList);
|
||||
return changeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultChangeList(@NotNull LocalChangeList list) {
|
||||
myActiveChangeList = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChangeList(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChangeList(LocalChangeList list) {
|
||||
myChangeLists.remove(list.getName());
|
||||
if (myActiveChangeList.equals(list)) {
|
||||
myActiveChangeList = myDefaultChangeList;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveChangesTo(LocalChangeList list, Change[] changes) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setReadOnly(String name, boolean value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editName(@NotNull String fromName, @NotNull String toName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String editComment(@NotNull String fromName, String newComment) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
|
||||
package com.intellij.testFramework.vcs;
|
||||
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class MockContentRevision implements ContentRevision {
|
||||
private final FilePath myPath;
|
||||
private final VcsRevisionNumber myRevisionNumber;
|
||||
|
||||
public MockContentRevision(final FilePath path, final VcsRevisionNumber revisionNumber) {
|
||||
myPath = path;
|
||||
myRevisionNumber = revisionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getContent() throws VcsException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FilePath getFile() {
|
||||
return myPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public VcsRevisionNumber getRevisionNumber() {
|
||||
return myRevisionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myPath.getName() + ":" + myRevisionNumber;
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public class StringUtil extends StringUtilRt {
|
||||
@NonNls private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(" *(\r|\n|\r\n)+ *");
|
||||
|
||||
public static final NotNullFunction<String, String> QUOTER = new NotNullFunction<String, String>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public String fun(String s) {
|
||||
return "\"" + s + "\"";
|
||||
@@ -51,18 +52,20 @@ public class StringUtil extends StringUtilRt {
|
||||
};
|
||||
|
||||
public static final NotNullFunction<String, String> SINGLE_QUOTER = new NotNullFunction<String, String>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public String fun(String s) {
|
||||
return "'" + s + "'";
|
||||
}
|
||||
};
|
||||
|
||||
public static List<String> getWordsInStringLongestFirst(String find) {
|
||||
@NotNull
|
||||
public static List<String> getWordsInStringLongestFirst(@NotNull String find) {
|
||||
List<String> words = getWordsIn(find);
|
||||
// hope long words are rare
|
||||
Collections.sort(words, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(final String o1, final String o2) {
|
||||
public int compare(@NotNull final String o1, @NotNull final String o2) {
|
||||
return o2.length() - o1.length();
|
||||
}
|
||||
});
|
||||
@@ -70,31 +73,34 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String escapePattern(final @NotNull String text) {
|
||||
public static String escapePattern(@NotNull final String text) {
|
||||
return replace(replace(text, "'", "''"), "{", "'{'");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> Function<T, String> createToStringFunction(Class<T> cls) {
|
||||
return new Function<T, String>() {
|
||||
@Override
|
||||
public String fun(T o) {
|
||||
public String fun(@NotNull T o) {
|
||||
return o.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Function<String, String> TRIMMER = new Function<String, String>() {
|
||||
@NotNull public static Function<String, String> TRIMMER = new Function<String, String>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String fun(String s) {
|
||||
public String fun(@Nullable String s) {
|
||||
return s == null ? null : s.trim();
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
public static String replace(@NonNls @NotNull String text, @NonNls @NotNull String oldS, @NonNls @Nullable String newS) {
|
||||
return replace(text, oldS, newS, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String replaceIgnoreCase(@NotNull String text, @NotNull String oldS, @Nullable String newS) {
|
||||
return replace(text, oldS, newS, true);
|
||||
}
|
||||
@@ -128,6 +134,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return newBuffer == null ? buffer : newBuffer.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String replace(@NotNull final String text, @NotNull final String oldS, @Nullable final String newS, boolean ignoreCase) {
|
||||
if (text.length() < oldS.length()) return text;
|
||||
|
||||
@@ -222,6 +229,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return html.replaceAll("<(.|\n)*?>", "");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String toLowerCase(@Nullable final String str) {
|
||||
//noinspection ConstantConditions
|
||||
return str == null ? null : str.toLowerCase();
|
||||
@@ -411,11 +419,12 @@ public class StringUtil extends StringUtilRt {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static NotNullFunction<String, String> escaper(final boolean escapeSlash, @Nullable final String additionalChars) {
|
||||
return new NotNullFunction<String, String>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String fun(String dom) {
|
||||
public String fun(@NotNull String dom) {
|
||||
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
|
||||
try {
|
||||
StringUtil.escapeStringCharacters(dom.length(), dom, additionalChars, escapeSlash, builder);
|
||||
@@ -523,7 +532,8 @@ public class StringUtil extends StringUtilRt {
|
||||
/**
|
||||
* This is just an optimized version of Matcher.quoteReplacement
|
||||
*/
|
||||
public static String quoteReplacement(String s) {
|
||||
@NotNull
|
||||
public static String quoteReplacement(@NotNull String s) {
|
||||
boolean needReplacements = false;
|
||||
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
@@ -690,7 +700,7 @@ public class StringUtil extends StringUtilRt {
|
||||
|
||||
@NotNull
|
||||
public static String capitalize(@NotNull String s) {
|
||||
if (s.length() == 0) return s;
|
||||
if (s.isEmpty()) return s;
|
||||
if (s.length() == 1) return StringUtilRt.toUpperCase(s);
|
||||
|
||||
// Optimization
|
||||
@@ -699,7 +709,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
public static boolean isCapitalized(@Nullable String s) {
|
||||
return s != null && s.length() > 0 && Character.isUpperCase(s.charAt(0));
|
||||
return s != null && !s.isEmpty() && Character.isUpperCase(s.charAt(0));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -710,7 +720,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return capitalize(s);
|
||||
}
|
||||
|
||||
public static int stringHashCode(CharSequence chars) {
|
||||
public static int stringHashCode(@NotNull CharSequence chars) {
|
||||
if (chars instanceof String) return chars.hashCode();
|
||||
if (chars instanceof CharSequenceWithStringHash) return chars.hashCode();
|
||||
if (chars instanceof CharArrayCharSequence) return chars.hashCode();
|
||||
@@ -718,7 +728,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return stringHashCode(chars, 0, chars.length());
|
||||
}
|
||||
|
||||
public static int stringHashCode(CharSequence chars, int from, int to) {
|
||||
public static int stringHashCode(@NotNull CharSequence chars, int from, int to) {
|
||||
int h = 0;
|
||||
for (int off = from; off < to; off++) {
|
||||
h = 31 * h + chars.charAt(off);
|
||||
@@ -734,7 +744,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return h;
|
||||
}
|
||||
|
||||
public static int stringHashCodeInsensitive(char[] chars, int from, int to) {
|
||||
public static int stringHashCodeInsensitive(@NotNull char[] chars, int from, int to) {
|
||||
int h = 0;
|
||||
for (int off = from; off < to; off++) {
|
||||
h = 31 * h + toLowerCase(chars[off]);
|
||||
@@ -742,7 +752,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return h;
|
||||
}
|
||||
|
||||
public static int stringHashCodeInsensitive(CharSequence chars, int from, int to) {
|
||||
public static int stringHashCodeInsensitive(@NotNull CharSequence chars, int from, int to) {
|
||||
int h = 0;
|
||||
for (int off = from; off < to; off++) {
|
||||
h = 31 * h + toLowerCase(chars.charAt(off));
|
||||
@@ -762,7 +772,7 @@ public class StringUtil extends StringUtilRt {
|
||||
* @param secondPrefix
|
||||
* @return
|
||||
*/
|
||||
public static boolean startsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix) {
|
||||
public static boolean startsWithConcatenationOf(@NotNull String testee, @NotNull String firstPrefix, @NotNull String secondPrefix) {
|
||||
int l1 = firstPrefix.length();
|
||||
int l2 = secondPrefix.length();
|
||||
if (testee.length() < l1 + l2) return false;
|
||||
@@ -777,7 +787,8 @@ public class StringUtil extends StringUtilRt {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String trimLog(final String text, final int limit) {
|
||||
@NotNull
|
||||
public static String trimLog(@NotNull final String text, final int limit) {
|
||||
if (limit > 5 && text.length() > limit) {
|
||||
return text.substring(0, limit - 5) + " ...\n";
|
||||
}
|
||||
@@ -833,11 +844,11 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(@Nullable String s) {
|
||||
return s != null && s.length() > 0;
|
||||
return s != null && !s.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(@Nullable String s) {
|
||||
return s == null || s.length() == 0;
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(@Nullable CharSequence cs) {
|
||||
@@ -854,17 +865,17 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String notNullize(final String s, @NotNull String defaultValue) {
|
||||
public static String notNullize(@Nullable final String s, @NotNull String defaultValue) {
|
||||
return s == null ? defaultValue : s;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String nullize(final @Nullable String s) {
|
||||
public static String nullize(@Nullable final String s) {
|
||||
return nullize(s, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String nullize(final @Nullable String s, boolean nullizeSpaces) {
|
||||
public static String nullize(@Nullable final String s, boolean nullizeSpaces) {
|
||||
if (nullizeSpaces) {
|
||||
if (isEmpty(s)) return null;
|
||||
}
|
||||
@@ -875,7 +886,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
public static boolean isEmptyOrSpaces(@Nullable final String s) {
|
||||
return s == null || s.trim().length() == 0;
|
||||
return s == null || s.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -960,7 +971,7 @@ public class StringUtil extends StringUtilRt {
|
||||
@NotNull
|
||||
public static List<String> split(@NotNull String s, @NotNull String separator,
|
||||
boolean excludeSeparator, boolean excludeEmptyStrings) {
|
||||
if (separator.length() == 0) {
|
||||
if (separator.isEmpty()) {
|
||||
return Collections.singletonList(s);
|
||||
}
|
||||
List<String> result = new ArrayList<String>();
|
||||
@@ -970,7 +981,7 @@ public class StringUtil extends StringUtilRt {
|
||||
if (index == -1) break;
|
||||
final int nextPos = index + separator.length();
|
||||
String token = s.substring(pos, excludeSeparator ? index : nextPos);
|
||||
if (token.length() != 0 || !excludeEmptyStrings) {
|
||||
if (!token.isEmpty() || !excludeEmptyStrings) {
|
||||
result.add(token);
|
||||
}
|
||||
pos = nextPos;
|
||||
@@ -985,16 +996,21 @@ public class StringUtil extends StringUtilRt {
|
||||
public static Iterable<String> tokenize(@NotNull String s, @NotNull String separators) {
|
||||
final com.intellij.util.text.StringTokenizer tokenizer = new com.intellij.util.text.StringTokenizer(s, separators);
|
||||
return new Iterable<String>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
return new Iterator<String>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return tokenizer.hasMoreTokens();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String next() {
|
||||
return tokenizer.nextToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -1004,18 +1020,23 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Iterable<String> tokenize(final StringTokenizer tokenizer) {
|
||||
public static Iterable<String> tokenize(@NotNull final StringTokenizer tokenizer) {
|
||||
return new Iterable<String>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
return new Iterator<String>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return tokenizer.hasMoreTokens();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String next() {
|
||||
return tokenizer.nextToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -1119,7 +1140,7 @@ public class StringUtil extends StringUtilRt {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
for (T item : items) {
|
||||
String string = f.fun(item);
|
||||
if (string != null && string.length() != 0) {
|
||||
if (string != null && !string.isEmpty()) {
|
||||
if (result.length() != 0) result.append(separator);
|
||||
result.append(string);
|
||||
}
|
||||
@@ -1131,7 +1152,7 @@ public class StringUtil extends StringUtilRt {
|
||||
public static String join(@NotNull Collection<? extends String> strings, @NotNull final String separator) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
for (String string : strings) {
|
||||
if (string != null && string.length() != 0) {
|
||||
if (string != null && !string.isEmpty()) {
|
||||
if (result.length() != 0) result.append(separator);
|
||||
result.append(string);
|
||||
}
|
||||
@@ -1150,7 +1171,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String join(final String... strings) {
|
||||
public static String join(@Nullable final String... strings) {
|
||||
if (strings == null || strings.length == 0) return "";
|
||||
|
||||
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
|
||||
@@ -1254,6 +1275,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String stripEnding(@NotNull String name, @NotNull String ending) {
|
||||
if (name.endsWith(ending)) {
|
||||
if (name.equals(ending)) return name; // do not return empty string
|
||||
@@ -1277,13 +1299,13 @@ public class StringUtil extends StringUtilRt {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean containsChar(final String value, final char ch) {
|
||||
public static boolean containsChar(@NotNull final String value, final char ch) {
|
||||
return value.indexOf(ch) >= 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String firstLetterToUpperCase(@Nullable final String displayString) {
|
||||
if (displayString == null || displayString.length() == 0) return displayString;
|
||||
if (displayString == null || displayString.isEmpty()) return displayString;
|
||||
char firstChar = displayString.charAt(0);
|
||||
char uppedFirstChar = toUpperCase(firstChar);
|
||||
|
||||
@@ -1313,11 +1335,13 @@ public class StringUtil extends StringUtilRt {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static List<String> findMatches(String s, Pattern pattern) {
|
||||
@NotNull
|
||||
public static List<String> findMatches(@NotNull String s, @NotNull Pattern pattern) {
|
||||
return findMatches(s, pattern, 1);
|
||||
}
|
||||
|
||||
public static List<String> findMatches(String s, Pattern pattern, int groupIndex) {
|
||||
@NotNull
|
||||
public static List<String> findMatches(@NotNull String s, @NotNull Pattern pattern, int groupIndex) {
|
||||
List<String> result = new SmartList<String>();
|
||||
Matcher m = pattern.matcher(s);
|
||||
while (m.find()) {
|
||||
@@ -1435,7 +1459,7 @@ public class StringUtil extends StringUtilRt {
|
||||
* @return <code>true</code> if given symbol is contained at the target range of the given char sequence;
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public static boolean contains(CharSequence s, int start, int end, char c) {
|
||||
public static boolean contains(@NotNull CharSequence s, int start, int end, char c) {
|
||||
return indexOf(s, c, start, end) >= 0;
|
||||
}
|
||||
|
||||
@@ -1476,17 +1500,18 @@ public class StringUtil extends StringUtilRt {
|
||||
return i + subString.length();
|
||||
}
|
||||
|
||||
public static int indexOfAny(final String s, final String chars) {
|
||||
public static int indexOfAny(@NotNull final String s, @NotNull final String chars) {
|
||||
return indexOfAny(s, chars, 0, s.length());
|
||||
}
|
||||
|
||||
public static int indexOfAny(final String s, final String chars, final int start, final int end) {
|
||||
public static int indexOfAny(@NotNull final String s, @NotNull final String chars, final int start, final int end) {
|
||||
for (int i = start; i < end; i++) {
|
||||
if (containsChar(chars, s.charAt(i))) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String substringAfter(@NotNull String text, @NotNull String subString) {
|
||||
int i = text.indexOf(subString);
|
||||
if (i == -1) return null;
|
||||
@@ -1578,7 +1603,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
private static void unescapeSlashes(StringBuilder buf, String str) {
|
||||
private static void unescapeSlashes(@NotNull StringBuilder buf, @NotNull String str) {
|
||||
final int length = str.length();
|
||||
final int last = length - 1;
|
||||
for (int i = 0; i < length; i++) {
|
||||
@@ -1605,12 +1630,14 @@ public class StringUtil extends StringUtilRt {
|
||||
@NonNls private static final String[] REPLACES_REFS = {"<", ">", "&", "'", """};
|
||||
@NonNls private static final String[] REPLACES_DISP = {"<", ">", "&", "'", "\""};
|
||||
|
||||
public static String unescapeXml(final String text) {
|
||||
@Nullable
|
||||
public static String unescapeXml(@Nullable final String text) {
|
||||
if (text == null) return null;
|
||||
return replace(text, REPLACES_REFS, REPLACES_DISP);
|
||||
}
|
||||
|
||||
public static String escapeXml(final String text) {
|
||||
@Nullable
|
||||
public static String escapeXml(@Nullable final String text) {
|
||||
if (text == null) return null;
|
||||
return replace(text, REPLACES_DISP, REPLACES_REFS);
|
||||
}
|
||||
@@ -1659,14 +1686,14 @@ public class StringUtil extends StringUtilRt {
|
||||
public static String[] filterEmptyStrings(@NotNull String[] strings) {
|
||||
int emptyCount = 0;
|
||||
for (String string : strings) {
|
||||
if (string == null || string.length() == 0) emptyCount++;
|
||||
if (string == null || string.isEmpty()) emptyCount++;
|
||||
}
|
||||
if (emptyCount == 0) return strings;
|
||||
|
||||
String[] result = ArrayUtil.newStringArray(strings.length - emptyCount);
|
||||
int count = 0;
|
||||
for (String string : strings) {
|
||||
if (string == null || string.length() == 0) continue;
|
||||
if (string == null || string.isEmpty()) continue;
|
||||
result[count++] = string;
|
||||
}
|
||||
|
||||
@@ -1715,6 +1742,7 @@ public class StringUtil extends StringUtilRt {
|
||||
return r.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getPropertyName(@NonNls @NotNull String methodName) {
|
||||
if (methodName.startsWith("get")) {
|
||||
return Introspector.decapitalize(methodName.substring(3));
|
||||
@@ -1829,8 +1857,8 @@ public class StringUtil extends StringUtilRt {
|
||||
return escaped.toString();
|
||||
}
|
||||
|
||||
public static String getQualifiedName(String packageName, String className) {
|
||||
if (packageName == null || packageName.length() == 0) {
|
||||
public static String getQualifiedName(@Nullable String packageName, String className) {
|
||||
if (packageName == null || packageName.isEmpty()) {
|
||||
return className;
|
||||
}
|
||||
return packageName + '.' + className;
|
||||
@@ -1899,7 +1927,8 @@ public class StringUtil extends StringUtilRt {
|
||||
return "a" + Character.toUpperCase(c) + name.substring(1);
|
||||
}
|
||||
|
||||
public static String sanitizeJavaIdentifier(String name) {
|
||||
@NotNull
|
||||
public static String sanitizeJavaIdentifier(@NotNull String name) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
@@ -1983,11 +2012,11 @@ public class StringUtil extends StringUtilRt {
|
||||
* Implementation of "Sorting for Humans: Natural Sort Order":
|
||||
* http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html
|
||||
*/
|
||||
public static int naturalCompare(String string1, String string2) {
|
||||
public static int naturalCompare(@NotNull String string1, @NotNull String string2) {
|
||||
return naturalCompare(string1, string2, false);
|
||||
}
|
||||
|
||||
private static int naturalCompare(String string1, String string2, boolean caseSensitive) {
|
||||
private static int naturalCompare(@NotNull String string1, @NotNull String string2, boolean caseSensitive) {
|
||||
final int string1Length = string1.length();
|
||||
final int string2Length = string2.length();
|
||||
for (int i = 0, j = 0; i < string1Length && j < string2Length; i++, j++) {
|
||||
@@ -2058,7 +2087,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
private static boolean isDigit(char c) {
|
||||
return (c >= '0' && c <= '9');
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
public static int compare(@Nullable String s1, @Nullable String s2, boolean ignoreCase) {
|
||||
@@ -2143,7 +2172,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String shortenTextWithEllipsis(final String text, final int max_length, final int suffix_length) {
|
||||
public static String shortenTextWithEllipsis(@NotNull final String text, final int max_length, final int suffix_length) {
|
||||
final int prefix_length = max_length - suffix_length - 3;
|
||||
assert prefix_length > 0;
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.CommitExecutor;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.merge.MergeDialogCustomizer;
|
||||
@@ -162,4 +164,14 @@ public abstract class AbstractVcsHelper {
|
||||
@Nullable String cancelActionName) {
|
||||
return selectFilePathsToProcess(files, title, prompt, singleFileTitle, singleFilePromptTemplate, confirmationOption);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Shows commit dialog, fills it with the given changes and given commit message, initially selects the given changelist.
|
||||
* @return true if user commits the changes, and commit succeeds; false if user presses Cancel or commit fails with errors.
|
||||
*/
|
||||
public abstract boolean commitChanges(@NotNull List<Change> changes, @NotNull LocalChangeList initialChangeList,
|
||||
@NotNull String commitMessage, @Nullable CommitExecutor executor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -237,14 +237,8 @@ public class LocalChangeListImpl extends LocalChangeList {
|
||||
public synchronized boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
final LocalChangeListImpl list = (LocalChangeListImpl)o;
|
||||
|
||||
if (myIsDefault != list.myIsDefault) return false;
|
||||
if (!myName.equals(list.myName)) return false;
|
||||
if (myIsReadOnly != list.myIsReadOnly) return false;
|
||||
|
||||
return true;
|
||||
return myName.equals(list.myName);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user