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:
@@ -122,5 +122,6 @@
|
||||
<orderEntry type="module" module-name="android-jps-plugin" scope="TEST" />
|
||||
<orderEntry type="module" module-name="script-debugger-ui" scope="TEST" />
|
||||
<orderEntry type="module" module-name="remote-servers-git-java" />
|
||||
<orderEntry type="module" module-name="terminal" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -378,7 +378,7 @@ public class BuildManager implements Disposable {
|
||||
doNotify(paths, true);
|
||||
}
|
||||
|
||||
public void runCommand(Runnable command) {
|
||||
public void runCommand(@NotNull Runnable command) {
|
||||
myRequestsProcessor.submit(command);
|
||||
}
|
||||
|
||||
@@ -672,13 +672,12 @@ public class BuildManager implements Disposable {
|
||||
return null;
|
||||
}
|
||||
|
||||
final DelegateFuture<BuilderMessageHandler> _future = new DelegateFuture<BuilderMessageHandler>();
|
||||
final DelegateFuture<?> _future = new DelegateFuture<>();
|
||||
// by using the same queue that processes events we ensure that
|
||||
// the build will be aware of all events that have happened before this request
|
||||
runCommand(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final Pair<RequestFuture<PreloadedProcessMessageHandler>, OSProcessHandler> preloaded = takePreloadedProcess(projectPath);
|
||||
final RequestFuture<PreloadedProcessMessageHandler> preloadedFuture = preloaded != null? preloaded.first : null;
|
||||
final boolean usingPreloadedProcess = preloadedFuture != null;
|
||||
@@ -694,7 +693,6 @@ public class BuildManager implements Disposable {
|
||||
}
|
||||
|
||||
final RequestFuture<? extends BuilderMessageHandler> future = usingPreloadedProcess? preloadedFuture : new RequestFuture<BuilderMessageHandler>(handler, sessionId, new CancelBuildSessionAction<BuilderMessageHandler>());
|
||||
_future.setDelegate(future);
|
||||
|
||||
if (!usingPreloadedProcess && (future.isCancelled() || project.isDisposed())) {
|
||||
// in case of preloaded process the process was already running, so the handler will be notified upon process termination
|
||||
@@ -741,7 +739,7 @@ public class BuildManager implements Disposable {
|
||||
}
|
||||
|
||||
try {
|
||||
projectTaskQueue.submit(new Runnable() {
|
||||
Future<?> buildFuture = projectTaskQueue.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Throwable execFailure = null;
|
||||
@@ -778,11 +776,11 @@ public class BuildManager implements Disposable {
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(Throwable e) {
|
||||
catch (Throwable e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processHandler = launchBuildProcess(project, myListenPort, sessionId, false);
|
||||
errorsOnLaunch = new StringBuffer();
|
||||
processHandler.addProcessListener(new StdOutputCollector((StringBuffer)errorsOnLaunch));
|
||||
@@ -840,10 +838,12 @@ public class BuildManager implements Disposable {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
TaskFutureAdapter adapter = new TaskFutureAdapter<>(buildFuture);
|
||||
boolean set = _future.setDelegate(adapter);
|
||||
assert set;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
handleProcessExecutionFailure(sessionId, e);
|
||||
|
||||
@@ -30,10 +30,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ThreeState;
|
||||
import com.intellij.xdebugger.frame.XStackFrame;
|
||||
import com.sun.jdi.InternalException;
|
||||
import com.sun.jdi.Location;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.VMDisconnectedException;
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.request.ClassPrepareRequest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -72,7 +69,7 @@ public class CompoundPositionManager extends PositionManagerEx implements MultiR
|
||||
return processor.process(positionManager);
|
||||
}
|
||||
catch (NoDataException | ProcessCanceledException ignored) {}
|
||||
catch (VMDisconnectedException e) {throw e;}
|
||||
catch (VMDisconnectedException | ObjectCollectedException e) {throw e;}
|
||||
catch (InternalException e) {LOG.info(e);}
|
||||
catch (Exception | AssertionError e) {LOG.error(e);}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.debugger.engine;
|
||||
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.engine.events.DebuggerCommandImpl;
|
||||
import com.intellij.debugger.engine.jdi.ThreadReferenceProxy;
|
||||
@@ -23,9 +24,8 @@ import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.SingleAlarm;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
import com.sun.jdi.IncompatibleThreadStateException;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
@@ -36,6 +36,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
@@ -45,12 +47,12 @@ public class ThreadBlockedMonitor {
|
||||
|
||||
private final Collection<ThreadReferenceProxy> myWatchedThreads = new HashSet<>();
|
||||
|
||||
private final SingleAlarm myAlarm;
|
||||
private ScheduledFuture<?> myTask;
|
||||
private final DebugProcessImpl myProcess;
|
||||
|
||||
public ThreadBlockedMonitor(DebugProcessImpl process, Disposable disposable) {
|
||||
myProcess = process;
|
||||
myAlarm = new SingleAlarm(this::checkBlockingThread, 5000, Alarm.ThreadToUse.POOLED_THREAD, disposable);
|
||||
Disposer.register(disposable, this::cancelTask);
|
||||
}
|
||||
|
||||
public void startWatching(@Nullable ThreadReferenceProxy thread) {
|
||||
@@ -58,7 +60,9 @@ public class ThreadBlockedMonitor {
|
||||
DebuggerManagerThreadImpl.assertIsManagerThread();
|
||||
if (thread != null) {
|
||||
myWatchedThreads.add(thread);
|
||||
myAlarm.request();
|
||||
if (myTask == null) {
|
||||
myTask = JobScheduler.getScheduler().scheduleWithFixedDelay(this::checkBlockingThread, 5, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +75,14 @@ public class ThreadBlockedMonitor {
|
||||
myWatchedThreads.clear();
|
||||
}
|
||||
if (myWatchedThreads.isEmpty()) {
|
||||
myAlarm.cancel();
|
||||
cancelTask();
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelTask() {
|
||||
if (myTask != null) {
|
||||
myTask.cancel(true);
|
||||
myTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +140,6 @@ public class ThreadBlockedMonitor {
|
||||
}
|
||||
finally {
|
||||
vmProxy.getVirtualMachine().resume();
|
||||
myAlarm.request();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.testIntegration;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.TestStateStorage;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class DeadTestsCleaner implements Runnable {
|
||||
private final TestStateStorage myTestStorage;
|
||||
private final Collection<String> myTestUrls;
|
||||
private final TestLocator myTestLocator;
|
||||
|
||||
public DeadTestsCleaner(TestStateStorage storage, Collection<String> urls, TestLocator locator) {
|
||||
myTestStorage = storage;
|
||||
myTestUrls = urls;
|
||||
myTestLocator = locator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String url : myTestUrls) {
|
||||
processUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
private void processUrl(final String url) {
|
||||
final Ref<Location> locationRef = Ref.create();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location location = myTestLocator.getLocation(url);
|
||||
locationRef.set(location);
|
||||
}
|
||||
});
|
||||
if (locationRef.get() == null) {
|
||||
myTestStorage.removeState(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,29 +16,21 @@
|
||||
package com.intellij.testIntegration;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.testframework.JavaTestLocator;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RecentTestRunner {
|
||||
enum Mode { RUN, DEBUG }
|
||||
enum Mode {
|
||||
RUN,
|
||||
DEBUG
|
||||
}
|
||||
|
||||
void setMode(Mode mode);
|
||||
|
||||
void run(Location location);
|
||||
|
||||
Location getLocation(String url);
|
||||
|
||||
boolean isSuite(String url);
|
||||
}
|
||||
|
||||
class RecentTestRunnerImpl implements RecentTestRunner {
|
||||
@@ -46,12 +38,7 @@ class RecentTestRunnerImpl implements RecentTestRunner {
|
||||
private static AnAction DEBUG = ActionManager.getInstance().getAction("DebugClass");
|
||||
|
||||
protected AnAction myCurrentAction = RUN;
|
||||
private final Project myProject;
|
||||
|
||||
public RecentTestRunnerImpl(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
|
||||
public void setMode(Mode mode) {
|
||||
switch (mode) {
|
||||
case RUN:
|
||||
@@ -62,26 +49,6 @@ class RecentTestRunnerImpl implements RecentTestRunner {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation(String url) {
|
||||
String protocol = VirtualFileManager.extractProtocol(url);
|
||||
String path = VirtualFileManager.extractPath(url);
|
||||
|
||||
if (protocol != null) {
|
||||
List<Location> locations = JavaTestLocator.INSTANCE.getLocation(protocol, path, myProject, GlobalSearchScope.allScope(myProject));
|
||||
if (!locations.isEmpty()) {
|
||||
return locations.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuite(String url) {
|
||||
String protocol = VirtualFileManager.extractProtocol(url);
|
||||
return JavaTestLocator.SUITE_PROTOCOL.equals(protocol);
|
||||
}
|
||||
|
||||
public void run(final Location location) {
|
||||
DataContext data = new DataContext() {
|
||||
|
||||
+38
-23
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.testIntegration;
|
||||
|
||||
import com.intellij.execution.TestStateStorage;
|
||||
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -27,7 +28,40 @@ import java.util.*;
|
||||
import static com.intellij.execution.testframework.sm.runner.states.TestStateInfo.Magnitude.*;
|
||||
import static com.intellij.testIntegration.TestInfo.select;
|
||||
|
||||
public class RecentTestsData {
|
||||
|
||||
public class RecentTestsListProvider {
|
||||
private final Map<String, TestStateStorage.Record> myRecords;
|
||||
|
||||
public RecentTestsListProvider(Map<String, TestStateStorage.Record> records) {
|
||||
myRecords = records;
|
||||
}
|
||||
|
||||
public List<String> getUrlsToShowFromHistory() {
|
||||
if (myRecords == null) return ContainerUtil.emptyList();
|
||||
|
||||
RecentTestsData data = new RecentTestsData();
|
||||
for (Map.Entry<String, TestStateStorage.Record> entry : myRecords.entrySet()) {
|
||||
String url = entry.getKey();
|
||||
TestStateStorage.Record record = entry.getValue();
|
||||
if (TestLocator.canLocate(url)) {
|
||||
data.addTest(url, getMagnitude(record.magnitude), record.date);
|
||||
}
|
||||
}
|
||||
|
||||
return data.getSortedTestsList();
|
||||
}
|
||||
|
||||
private static TestStateInfo.Magnitude getMagnitude(int magnitude) {
|
||||
for (TestStateInfo.Magnitude m : values()) {
|
||||
if (m.getValue() == magnitude) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class RecentTestsData {
|
||||
private static Comparator<TestInfo> BY_PATH_COMPARATOR = new Comparator<TestInfo>() {
|
||||
@Override
|
||||
public int compare(TestInfo o1, TestInfo o2) {
|
||||
@@ -50,18 +84,13 @@ public class RecentTestsData {
|
||||
return -o1.getRunDate().compareTo(o2.getRunDate());
|
||||
}
|
||||
};
|
||||
|
||||
private final RecentTestRunner myRunner;
|
||||
|
||||
private final Map<String, SuiteInfo> mySuites = ContainerUtil.newHashMap();
|
||||
|
||||
private List<TestInfo> myTestsWithoutSuites = ContainerUtil.newArrayList();
|
||||
|
||||
public RecentTestsData(RecentTestRunner runner) {
|
||||
myRunner = runner;
|
||||
}
|
||||
|
||||
public void addTest(String url, TestStateInfo.Magnitude magnitude, Date runDate) {
|
||||
if (myRunner.isSuite(url)) {
|
||||
if (TestLocator.isSuite(url)) {
|
||||
mySuites.put(url, new SuiteInfo(url, magnitude, runDate));
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +120,7 @@ public class RecentTestsData {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> calculateTestList() {
|
||||
public List<String> getSortedTestsList() {
|
||||
distributeUnmatchedTests();
|
||||
List<String> result = ContainerUtil.newArrayList();
|
||||
fillWithTests(result, ERROR_INDEX, FAILED_INDEX);
|
||||
@@ -288,18 +317,4 @@ class TestInfo {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static <T extends TestInfo> List<T> selectNot(Collection<T> infos, final TestStateInfo.Magnitude... magnitudes) {
|
||||
return ContainerUtil.filter(infos, new Condition<T>() {
|
||||
@Override
|
||||
public boolean value(T t) {
|
||||
for (TestStateInfo.Magnitude magnitude : magnitudes) {
|
||||
if (t.getMagnitude() == magnitude) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,6 @@
|
||||
package com.intellij.testIntegration;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.TestStateStorage;
|
||||
import com.intellij.execution.testframework.TestIconMapper;
|
||||
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -29,34 +26,20 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SelectTestStep extends BaseListPopupStep<String> {
|
||||
private final Map<String, TestStateStorage.Record> myRecords;
|
||||
private final RecentTestRunner myRunner;
|
||||
private final TestLocator myTestLocator;
|
||||
private final Map<String, Icon> myIcons;
|
||||
|
||||
public SelectTestStep(Map<String, TestStateStorage.Record> records, RecentTestRunner runner) {
|
||||
super("Debug Recent Tests", getUrls(records, runner));
|
||||
public SelectTestStep(List<String> urls, Map<String, Icon> icons, RecentTestRunner runner, TestLocator locator) {
|
||||
super("Debug Recent Tests", urls);
|
||||
myRunner = runner;
|
||||
myRecords = records;
|
||||
myIcons = icons;
|
||||
myTestLocator = locator;
|
||||
}
|
||||
|
||||
private static List<String> getUrls(Map<String, TestStateStorage.Record> records, RecentTestRunner runner) {
|
||||
RecentTestsData data = new RecentTestsData(runner);
|
||||
|
||||
for (Map.Entry<String, TestStateStorage.Record> entry : records.entrySet()) {
|
||||
String url = entry.getKey();
|
||||
TestStateStorage.Record record = entry.getValue();
|
||||
data.addTest(url, getMagnitude(record.magnitude), record.date);
|
||||
}
|
||||
|
||||
return data.calculateTestList();
|
||||
}
|
||||
|
||||
private static TestStateInfo.Magnitude getMagnitude(int magnitude) {
|
||||
for (TestStateInfo.Magnitude m : TestStateInfo.Magnitude.values()) {
|
||||
if (m.getValue() == magnitude) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@Override
|
||||
public Icon getIconFor(String value) {
|
||||
return myIcons.get(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -69,17 +52,10 @@ public class SelectTestStep extends BaseListPopupStep<String> {
|
||||
public boolean isSpeedSearchEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIconFor(String value) {
|
||||
TestStateStorage.Record record = myRecords.get(value);
|
||||
TestStateInfo.Magnitude magnitude = TestIconMapper.getMagnitude(record.magnitude);
|
||||
return TestIconMapper.getIcon(magnitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PopupStep onChosen(String url, boolean finalChoice) {
|
||||
Location location = myRunner.getLocation(url);
|
||||
Location location = myTestLocator.getLocation(url);
|
||||
myRunner.run(location);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -17,21 +17,28 @@ package com.intellij.testIntegration;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.TestStateStorage;
|
||||
import com.intellij.execution.testframework.TestIconMapper;
|
||||
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.keymap.MacKeymapUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.ListPopupStep;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PsiNavigateUtil;
|
||||
import com.intellij.util.Time;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ShowRecentTests extends AnAction {
|
||||
@@ -51,21 +58,43 @@ public class ShowRecentTests extends AnAction {
|
||||
final Project project = e.getProject();
|
||||
if (project == null) return;
|
||||
|
||||
Map<String, TestStateStorage.Record> records = TestStateStorage.getInstance(project).getRecentTests(TEST_LIMIT, getSinceDate());
|
||||
RecentTestRunner testRunner = new RecentTestRunnerImpl(project);
|
||||
final TestStateStorage testStorage = TestStateStorage.getInstance(project);
|
||||
final TestLocator testLocator = new TestLocator(project);
|
||||
final RecentTestRunnerImpl testRunner = new RecentTestRunnerImpl();
|
||||
|
||||
SelectTestStep selectStepTest = new SelectTestStep(records, testRunner);
|
||||
RecentTestsListPopup popup = new RecentTestsListPopup(selectStepTest, testRunner);
|
||||
final Map<String, TestStateStorage.Record> records = testStorage.getRecentTests(TEST_LIMIT, getSinceDate());
|
||||
RecentTestsListProvider listProvider = new RecentTestsListProvider(records);
|
||||
List<String> urls = listProvider.getUrlsToShowFromHistory();
|
||||
Map<String, Icon> icons = ContainerUtil.map2Map(urls, new Function<String, Pair<String, Icon>>() {
|
||||
@Override
|
||||
public Pair<String, Icon> fun(String url) {
|
||||
return Pair.create(url, getIconFor(url, records));
|
||||
}
|
||||
});
|
||||
SelectTestStep selectStepTest = new SelectTestStep(urls, icons, testRunner, testLocator);
|
||||
|
||||
RecentTestsListPopup popup = new RecentTestsListPopup(selectStepTest, testRunner, testLocator);
|
||||
popup.showCenteredInCurrentWindow(project);
|
||||
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new DeadTestsCleaner(testStorage, urls, testLocator));
|
||||
}
|
||||
|
||||
private static Icon getIconFor(String value, Map<String, TestStateStorage.Record> records) {
|
||||
TestStateStorage.Record record = records.get(value);
|
||||
TestStateInfo.Magnitude magnitude = TestIconMapper.getMagnitude(record.magnitude);
|
||||
return TestIconMapper.getIcon(magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
class RecentTestsListPopup extends ListPopupImpl {
|
||||
private final RecentTestRunner myTestRunner;
|
||||
private final TestLocator myLocator;
|
||||
|
||||
public RecentTestsListPopup(ListPopupStep<String> popupStep, RecentTestRunner testRunner) {
|
||||
public RecentTestsListPopup(ListPopupStep<String> popupStep, RecentTestRunner testRunner, TestLocator locator) {
|
||||
super(popupStep);
|
||||
myTestRunner = testRunner;
|
||||
myLocator = locator;
|
||||
|
||||
shiftReleased();
|
||||
registerActions(this);
|
||||
|
||||
@@ -97,7 +126,7 @@ class RecentTestsListPopup extends ListPopupImpl {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object[] values = getSelectedValues();
|
||||
if (values.length == 1) {
|
||||
Location location = myTestRunner.getLocation(values[0].toString());
|
||||
Location location = myLocator.getLocation(values[0].toString());
|
||||
if (location != null) {
|
||||
cancel();
|
||||
PsiNavigateUtil.navigate(location.getPsiElement());
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.testIntegration;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.testframework.JavaTestLocator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestLocator {
|
||||
private final Project myProject;
|
||||
|
||||
public TestLocator(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public Location getLocation(String url) {
|
||||
return getLocation(url, myProject);
|
||||
}
|
||||
|
||||
public static Location getLocation(String url, Project project) {
|
||||
String protocol = VirtualFileManager.extractProtocol(url);
|
||||
String path = VirtualFileManager.extractPath(url);
|
||||
|
||||
if (protocol != null) {
|
||||
List<Location> locations = JavaTestLocator.INSTANCE.getLocation(protocol, path, project, GlobalSearchScope.allScope(project));
|
||||
if (!locations.isEmpty()) {
|
||||
return locations.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean canLocate(String url) {
|
||||
return isSuite(url) || isTest(url);
|
||||
}
|
||||
|
||||
public static boolean isSuite(String url) {
|
||||
String protocol = VirtualFileManager.extractProtocol(url);
|
||||
return JavaTestLocator.SUITE_PROTOCOL.equals(protocol);
|
||||
}
|
||||
|
||||
public static boolean isTest(String url) {
|
||||
String protocol = VirtualFileManager.extractProtocol(url);
|
||||
return JavaTestLocator.TEST_PROTOCOL.equals(protocol);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
|
||||
import com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel;
|
||||
import com.intellij.ide.util.newProjectWizard.FrameworkSupportNode;
|
||||
import com.intellij.ide.util.newProjectWizard.TemplatesGroup;
|
||||
import com.intellij.ide.util.newProjectWizard.WizardDelegate;
|
||||
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
|
||||
import com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode;
|
||||
import com.intellij.ide.util.projectWizard.*;
|
||||
@@ -650,6 +651,7 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D
|
||||
if (builder != null) {
|
||||
myWizard.getSequence().setType(builder.getBuilderId());
|
||||
}
|
||||
myWizard.setDelegate(builder instanceof WizardDelegate ? (WizardDelegate)builder : null);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
|
||||
@@ -53,15 +53,19 @@ import java.io.File;
|
||||
*/
|
||||
public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardStep> {
|
||||
protected final WizardContext myWizardContext;
|
||||
@Nullable
|
||||
private WizardDelegate myDelegate;
|
||||
|
||||
public AbstractProjectWizard(String title, Project project, String defaultPath) {
|
||||
super(title, project);
|
||||
myWizardContext = initContext(project, defaultPath, getDisposable());
|
||||
myWizardContext.setWizard(this);
|
||||
}
|
||||
|
||||
public AbstractProjectWizard(String title, Project project, Component dialogParent) {
|
||||
super(title, dialogParent);
|
||||
myWizardContext = initContext(project, null, getDisposable());
|
||||
myWizardContext.setWizard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,6 +178,10 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean doFinishAction() {
|
||||
if (myDelegate != null) {
|
||||
myDelegate.doFinishAction();
|
||||
return true;
|
||||
}
|
||||
int idx = getCurrentStep();
|
||||
try {
|
||||
do {
|
||||
@@ -239,6 +247,10 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS
|
||||
|
||||
@Override
|
||||
public void doNextAction() {
|
||||
if (myDelegate != null) {
|
||||
myDelegate.doNextAction();
|
||||
return;
|
||||
}
|
||||
final ModuleWizardStep step = getCurrentStepObject();
|
||||
if (!commitStepData(step)) {
|
||||
return;
|
||||
@@ -269,6 +281,10 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS
|
||||
|
||||
@Override
|
||||
protected void doPreviousAction() {
|
||||
if (myDelegate != null) {
|
||||
myDelegate.doPreviousAction();
|
||||
return;
|
||||
}
|
||||
final ModuleWizardStep step = getCurrentStepObject();
|
||||
step.onStepLeaving();
|
||||
if (step instanceof StepWithSubSteps) {
|
||||
@@ -335,4 +351,8 @@ public abstract class AbstractProjectWizard extends AbstractWizard<ModuleWizardS
|
||||
private static boolean isNotFirstSubStepInStep(ModuleWizardStep current) {
|
||||
return current instanceof StepWithSubSteps && !((StepWithSubSteps)current).isFirst();
|
||||
}
|
||||
|
||||
public void setDelegate(@Nullable WizardDelegate delegate) {
|
||||
myDelegate = delegate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
package com.intellij.ide.util.newProjectWizard;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.ide.wizard.CommitStepException;
|
||||
import com.intellij.ide.wizard.Step;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CustomShortcutSet;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class AddModuleWizardPro extends AddModuleWizard {
|
||||
protected JPanel myStepsPanel;
|
||||
|
||||
public AddModuleWizardPro(Project project, @NotNull ModulesProvider modulesProvider, @Nullable String defaultPath) {
|
||||
super(project, modulesProvider, defaultPath);
|
||||
getWizardContext().addContextListener(new WizardContext.Listener() {
|
||||
@Override
|
||||
public void buttonsUpdateRequested() {
|
||||
updateStepsPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nextStepRequested() {
|
||||
updateStepsPanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateButtons() {
|
||||
super.updateButtons();
|
||||
if (isLastStep()) {
|
||||
getNextButton().setText("Done");
|
||||
}
|
||||
|
||||
getPreviousButton().setVisible(false);
|
||||
getCancelButton().setVisible(false);
|
||||
}
|
||||
|
||||
public AddModuleWizardPro(Component parent, Project project, @NotNull ModulesProvider modulesProvider) {
|
||||
super(parent, project, modulesProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createDefaultActions() {
|
||||
super.createDefaultActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
myStepsPanel = new JPanel() {
|
||||
@Override
|
||||
public void addNotify() {
|
||||
super.addNotify();
|
||||
getNextStepObject().updateDataModel();
|
||||
updateStepsPanel();
|
||||
new AnAction(){
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
if (!isLastStep()) doNextAction();
|
||||
}
|
||||
}.registerCustomShortcutSet(CustomShortcutSet.fromString("control TAB"), getContentPanel(), getDisposable());
|
||||
new AnAction(){
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
doPreviousAction();
|
||||
}
|
||||
}.registerCustomShortcutSet(CustomShortcutSet.fromString("control shift TAB"), getContentPanel(), getDisposable());
|
||||
new AnAction(){
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myCurrentStep = mySteps.size() - 1;
|
||||
doOKAction();
|
||||
}
|
||||
}.registerCustomShortcutSet(CustomShortcutSet.fromString("control shift ENTER"), getContentPanel(), getDisposable());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
final Component c = getComponent(getComponentCount() - 1);
|
||||
int y = c.getBounds().y + c.getBounds().height + 4;
|
||||
g.translate(0, y);
|
||||
myIcon.paintIcon(g);
|
||||
g.translate(0, -y);
|
||||
}
|
||||
};
|
||||
myStepsPanel.setLayout(new BoxLayout(myStepsPanel, BoxLayout.Y_AXIS) {
|
||||
@Override
|
||||
public void layoutContainer(Container target) {
|
||||
super.layoutContainer(target);
|
||||
int maxWidth = -1;
|
||||
for (Component c : target.getComponents()) {
|
||||
maxWidth = Math.max(maxWidth, c.getWidth());
|
||||
}
|
||||
for (Component c : target.getComponents()) {
|
||||
final Rectangle b = c.getBounds();
|
||||
c.setBounds(b.x, b.y, maxWidth, b.height);
|
||||
}
|
||||
}
|
||||
});
|
||||
myStepsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));
|
||||
updateStepsPanel();
|
||||
|
||||
final JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(myStepsPanel, BorderLayout.WEST);
|
||||
panel.add(myContentPanel, BorderLayout.CENTER);
|
||||
return panel;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doNextAction() {
|
||||
super.doNextAction();
|
||||
updateStepsPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPreviousAction() {
|
||||
super.doPreviousAction();
|
||||
updateStepsPanel();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected ValidationInfo doValidate() {
|
||||
final ValidationInfo result = super.doValidate();
|
||||
updateStepsPanel();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updateStepsPanel() {
|
||||
myStepsPanel.removeAll();
|
||||
int index = 0;
|
||||
final ButtonGroup group = new ButtonGroup();
|
||||
while (index != -1) {
|
||||
final int ind = index;
|
||||
final ModuleWizardStep step = mySteps.get(index);
|
||||
final JRadioButton rb = new JRadioButton(step.getName(), index == myCurrentStep);
|
||||
rb.setFocusable(false);
|
||||
rb.setUI(new WizardArrowUI(rb, index < myCurrentStep));
|
||||
myStepsPanel.add(rb);
|
||||
group.add(rb);
|
||||
rb.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final ModuleWizardStep step = getCurrentStepObject();
|
||||
if (ind > getCurrentStep() && !commitStepData(step)) {
|
||||
updateStepsPanel();
|
||||
return;
|
||||
}
|
||||
step.onStepLeaving();
|
||||
|
||||
// Commit data of current step
|
||||
final Step currentStep = mySteps.get(myCurrentStep);
|
||||
try {
|
||||
currentStep._commit(false);
|
||||
}
|
||||
catch (final CommitStepException exc) {
|
||||
Messages.showErrorDialog(
|
||||
myContentPanel,
|
||||
exc.getMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
myCurrentStep = ind;
|
||||
updateStep();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
final int next = getNextStep(index);
|
||||
index = index == next ? -1 : next;
|
||||
}
|
||||
|
||||
final Enumeration<AbstractButton> buttons = group.getElements();
|
||||
while (buttons.hasMoreElements()) {
|
||||
final JRadioButton b = (JRadioButton)buttons.nextElement();
|
||||
b.setUI(new WizardArrowUI(b, index < myCurrentStep));
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myStepsPanel.revalidate();
|
||||
myStepsPanel.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.ide.util.newProjectWizard;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public interface WizardDelegate {
|
||||
|
||||
void doNextAction();
|
||||
|
||||
void doPreviousAction();
|
||||
|
||||
void doFinishAction();
|
||||
}
|
||||
+2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.MethodSignatureUtil;
|
||||
@@ -62,6 +63,7 @@ public class TrivialMethodReferenceInspection extends BaseJavaBatchLocalInspecti
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
PsiElement element = descriptor.getPsiElement();
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
|
||||
final PsiElement parent = element != null ? element.getParent() : null;
|
||||
if (parent instanceof PsiMethodReferenceExpression) {
|
||||
final PsiExpression qualifierExpression = ((PsiMethodReferenceExpression)parent).getQualifierExpression();
|
||||
|
||||
@@ -55,7 +55,7 @@ import java.util.Set;
|
||||
public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
|
||||
private final DaemonCodeAnalyzerSettings myDaemonSettings;
|
||||
private final EditorColorsManager myColorsManager;
|
||||
private final Option myLambdaOption = new Option("java.lambda", "Lambda", AllIcons.Gutter.ImplementingFunctional);
|
||||
private final Option myLambdaOption = new Option("java.lambda", "Lambda", AllIcons.Gutter.ImplementingFunctionalInterface);
|
||||
|
||||
public JavaLineMarkerProvider(DaemonCodeAnalyzerSettings daemonSettings, EditorColorsManager colorsManager) {
|
||||
myDaemonSettings = daemonSettings;
|
||||
@@ -81,7 +81,7 @@ public class JavaLineMarkerProvider extends LineMarkerProviderDescriptor {
|
||||
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(element);
|
||||
final PsiElement firstChild = element.getFirstChild();
|
||||
if (interfaceMethod != null && firstChild != null && LineMarkerSettings.getSettings().isEnabled(myLambdaOption)) {
|
||||
return createSuperMethodLineMarkerInfo(firstChild, AllIcons.Gutter.ImplementingFunctional, Pass.UPDATE_ALL);
|
||||
return createSuperMethodLineMarkerInfo(firstChild, AllIcons.Gutter.ImplementingFunctionalInterface, Pass.UPDATE_ALL);
|
||||
}
|
||||
|
||||
if (myDaemonSettings.SHOW_METHOD_SEPARATORS && firstChild == null) {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ExtractClassUtil {
|
||||
final boolean isPreviewUsages = dialog.isPreviewUsages();
|
||||
JavaRefactoringSettings.getInstance().EXTRACT_INTERFACE_PREVIEW_USAGES = isPreviewUsages;
|
||||
TurnRefsToSuperProcessor processor =
|
||||
new TurnRefsToSuperProcessor(project, (PsiClass)classElement, superClass, true);
|
||||
new TurnRefsToSuperProcessor(project, (PsiClass)classElement, superClass, false);
|
||||
processor.setPreviewUsages(isPreviewUsages);
|
||||
processor.run();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
psi.error.attempt.to.edit.class.file=Cannot modify compiled element
|
||||
psi.error.attempt.to.edit.class.file=Cannot modify compiled element in file ''{0}''
|
||||
|
||||
default.language.level.description=SDK default
|
||||
jdk.1.3.language.level.description=1.3 - Plain old Java
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -26,7 +26,6 @@ import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -122,7 +121,7 @@ public class ClsAnnotationImpl extends ClsRepositoryPsiElement<PsiAnnotationStub
|
||||
|
||||
@Override
|
||||
public <T extends PsiAnnotationMemberValue> T setDeclaredAttributeValue(@NonNls String attributeName, T value) {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -22,7 +22,6 @@ import com.intellij.psi.impl.meta.MetaRegistry;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,13 +29,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public abstract class ClsAnnotationValueImpl extends ClsElementImpl implements PsiAnnotation, Navigatable {
|
||||
abstract class ClsAnnotationValueImpl extends ClsElementImpl implements PsiAnnotation, Navigatable {
|
||||
private final ClsElementImpl myParent;
|
||||
private final ClsJavaCodeReferenceElementImpl myReferenceElement;
|
||||
private final ClsAnnotationParameterListImpl myParameterList;
|
||||
|
||||
@SuppressWarnings("AbstractMethodCallInConstructor")
|
||||
public ClsAnnotationValueImpl(@NotNull ClsElementImpl parent) {
|
||||
ClsAnnotationValueImpl(@NotNull ClsElementImpl parent) {
|
||||
myParent = parent;
|
||||
myReferenceElement = createReference();
|
||||
myParameterList = createParameterList();
|
||||
@@ -112,7 +111,7 @@ public abstract class ClsAnnotationValueImpl extends ClsElementImpl implements P
|
||||
|
||||
@Override
|
||||
public <T extends PsiAnnotationMemberValue> T setDeclaredAttributeValue(@NonNls String attributeName, T value) {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettingsFacade;
|
||||
import com.intellij.psi.impl.PsiElementBase;
|
||||
@@ -43,11 +44,9 @@ import java.util.List;
|
||||
public abstract class ClsElementImpl extends PsiElementBase implements PsiCompiledElement {
|
||||
public static final Key<PsiCompiledElement> COMPILED_ELEMENT = Key.create("COMPILED_ELEMENT");
|
||||
|
||||
protected static final String CAN_NOT_MODIFY_MESSAGE = JavaCoreBundle.message("psi.error.attempt.to.edit.class.file");
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsElementImpl");
|
||||
|
||||
private volatile TreeElement myMirror = null;
|
||||
private volatile TreeElement myMirror;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@@ -107,37 +106,44 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil
|
||||
|
||||
@Override
|
||||
public void checkAdd(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static IncorrectOperationException cannotModifyException(@NotNull ClsElementImpl element) {
|
||||
VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
|
||||
String path = virtualFile == null ? "?" : virtualFile.getPresentableUrl();
|
||||
return new IncorrectOperationException(JavaCoreBundle.message("psi.error.attempt.to.edit.class.file", path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement addBefore(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement addAfter(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkDelete() throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
public abstract void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer);
|
||||
@@ -259,7 +265,7 @@ public abstract class ClsElementImpl extends PsiElementBase implements PsiCompil
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static void goNextLine(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
static void goNextLine(int indentLevel, @NotNull StringBuilder buffer) {
|
||||
buffer.append('\n');
|
||||
for (int i = 0; i < indentLevel; i++) buffer.append(' ');
|
||||
}
|
||||
|
||||
@@ -77,8 +77,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.reference.SoftReference.dereference;
|
||||
|
||||
public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx, Queryable, PsiClassOwnerEx, PsiCompiledFile {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClsFileImpl");
|
||||
@@ -99,8 +97,8 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
private final boolean myIsForDecompiling;
|
||||
private volatile SoftReference<StubTree> myStub;
|
||||
private volatile TreeElement myMirrorFileElement;
|
||||
private volatile ClsPackageStatementImpl myPackageStatement = null;
|
||||
private volatile LanguageLevel myLanguageLevel = null;
|
||||
private volatile ClsPackageStatementImpl myPackageStatement;
|
||||
private volatile LanguageLevel myLanguageLevel;
|
||||
private boolean myIsPhysical = true;
|
||||
private boolean myInvalidated;
|
||||
|
||||
@@ -154,7 +152,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
return !myInvalidated && (myIsForDecompiling || getVirtualFile().isValid());
|
||||
}
|
||||
|
||||
protected boolean isForDecompiling() {
|
||||
boolean isForDecompiling() {
|
||||
return myIsForDecompiling;
|
||||
}
|
||||
|
||||
@@ -259,12 +257,12 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSetName(String name) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -347,6 +345,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
try {
|
||||
final TreeElement finalMirrorTreeElement = mirrorTreeElement;
|
||||
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setMirror(finalMirrorTreeElement);
|
||||
putUserData(CLS_DOCUMENT_LINK_KEY, document);
|
||||
@@ -478,7 +477,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
public StubTree getStubTree() {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
|
||||
StubTree stubTree = dereference(myStub);
|
||||
StubTree stubTree = SoftReference.dereference(myStub);
|
||||
if (stubTree != null) return stubTree;
|
||||
|
||||
// build newStub out of lock to avoid deadlock
|
||||
@@ -491,7 +490,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
}
|
||||
|
||||
synchronized (myStubLock) {
|
||||
stubTree = dereference(myStub);
|
||||
stubTree = SoftReference.dereference(myStub);
|
||||
if (stubTree != null) return stubTree;
|
||||
|
||||
stubTree = newStubTree;
|
||||
@@ -520,7 +519,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
|
||||
synchronized (myStubLock) {
|
||||
StubTree stubTree = dereference(myStub);
|
||||
StubTree stubTree = SoftReference.dereference(myStub);
|
||||
myStub = null;
|
||||
if (stubTree != null) {
|
||||
//noinspection unchecked
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -254,12 +254,12 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
|
||||
|
||||
@Override
|
||||
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -51,12 +51,12 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElement<PsiModifierList
|
||||
|
||||
@Override
|
||||
public void setModifierProperty(@NotNull String name, boolean value) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSetModifierProperty(@NotNull String name, boolean value) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +79,7 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElement<PsiModifierList
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotation addAnnotation(@NotNull @NonNls String qualifiedName) {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -18,19 +18,18 @@ package com.intellij.psi.impl.compiled;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class ClsNameValuePairImpl extends ClsElementImpl implements PsiNameValuePair {
|
||||
class ClsNameValuePairImpl extends ClsElementImpl implements PsiNameValuePair {
|
||||
private final ClsElementImpl myParent;
|
||||
private final ClsIdentifierImpl myNameIdentifier;
|
||||
private final PsiAnnotationMemberValue myMemberValue;
|
||||
|
||||
public ClsNameValuePairImpl(@NotNull ClsElementImpl parent, @Nullable String name, @NotNull PsiAnnotationMemberValue value) {
|
||||
ClsNameValuePairImpl(@NotNull ClsElementImpl parent, @Nullable String name, @NotNull PsiAnnotationMemberValue value) {
|
||||
myParent = parent;
|
||||
myNameIdentifier = name != null ? new ClsIdentifierImpl(this, name) : null;
|
||||
myMemberValue = ClsParsingUtil.getMemberValue(value, this);
|
||||
@@ -100,6 +99,6 @@ public class ClsNameValuePairImpl extends ClsElementImpl implements PsiNameValue
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiAnnotationMemberValue setValue(@NotNull PsiAnnotationMemberValue newValue) {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -108,7 +108,7 @@ public class ClsParameterImpl extends ClsRepositoryPsiElement<PsiParameterStub>
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
|
||||
throw cannotModifyException(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.codeInsight;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -5,6 +20,8 @@ import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.codeInsight.generation.GenerationInfo;
|
||||
import com.intellij.codeInsight.generation.PsiGenerationInfo;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -47,7 +64,12 @@ public class GenerateMembersUtilTest extends LightCodeInsightTestCase {
|
||||
PsiMethod method = factory.createMethod("foo", PsiType.VOID);
|
||||
int offset = getEditor().getCaretModel().getOffset();
|
||||
List<GenerationInfo> list = Collections.<GenerationInfo>singletonList(new PsiGenerationInfo<PsiMethod>(method));
|
||||
List<GenerationInfo> members = GenerateMembersUtil.insertMembersAtOffset(getFile(), offset, list);
|
||||
List<GenerationInfo> members = ApplicationManager.getApplication().runWriteAction(new Computable<List<GenerationInfo>>() {
|
||||
@Override
|
||||
public List<GenerationInfo> compute() {
|
||||
return GenerateMembersUtil.insertMembersAtOffset(getFile(), offset, list);
|
||||
}
|
||||
});
|
||||
members.get(0).positionCaret(myEditor, true);
|
||||
checkResultByFile(null, BASE_PATH + getTestName(false) + "_after.java", true);
|
||||
}
|
||||
@@ -63,10 +85,16 @@ public class GenerateMembersUtilTest extends LightCodeInsightTestCase {
|
||||
PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject())
|
||||
.createFileFromText(JavaLanguage.INSTANCE, "class A {void foo() {}}\n class B extends A {void foo() {}\n}");
|
||||
|
||||
method = file.getClasses()[1].getMethods()[0];
|
||||
GenerateMembersUtil.setupGeneratedMethod(method);
|
||||
assertEquals("@Override void foo() {\n" +
|
||||
" super.foo();\n" +
|
||||
" }", method.getText());
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiMethod newMethod = file.getClasses()[1].getMethods()[0];
|
||||
GenerateMembersUtil.setupGeneratedMethod(newMethod);
|
||||
assertEquals("@Override void foo() {\n" +
|
||||
" super.foo();\n" +
|
||||
" }", newMethod.getText());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.codeInsight;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.generation.actions.GenerateSuperMethodCallAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -43,7 +59,13 @@ public class GenerateSuperMethodCallTest extends LightCodeInsightTestCase {
|
||||
return super.getHandler();
|
||||
}
|
||||
}.getHandler();
|
||||
handler.invoke(getProject(), getEditor(), getFile());
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handler.invoke(getProject(), getEditor(), getFile());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
checkResultByFile(after);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.codeInsight.generation.PsiMethodMember;
|
||||
import com.intellij.codeInsight.intention.impl.ImplementAbstractMethodHandler;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -163,19 +164,27 @@ public class OverrideImplement15Test extends LightCodeInsightTestCase {
|
||||
PsiElement context = getFile().findElementAt(offset);
|
||||
PsiClass psiClass = PsiTreeUtil.getParentOfType(context, PsiClass.class);
|
||||
assert psiClass != null;
|
||||
if (toImplement == null) {
|
||||
PsiClassType[] implement = psiClass.getImplementsListTypes();
|
||||
final PsiClass superClass = implement.length == 0 ? psiClass.getSuperClass() : implement[0].resolve();
|
||||
assert superClass != null;
|
||||
PsiMethod method = superClass.getMethods()[0];
|
||||
final PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, psiClass, PsiSubstitutor.EMPTY);
|
||||
final List<PsiMethodMember> candidates = Collections.singletonList(new PsiMethodMember(method,
|
||||
OverrideImplementExploreUtil.correctSubstitutor(method, substitutor)));
|
||||
OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(getEditor(), psiClass, candidates, copyJavadoc, true);
|
||||
}
|
||||
else {
|
||||
OverrideImplementUtil.chooseAndOverrideOrImplementMethods(getProject(), getEditor(), psiClass, toImplement);
|
||||
}
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toImplement == null) {
|
||||
PsiClassType[] implement = psiClass.getImplementsListTypes();
|
||||
final PsiClass superClass = implement.length == 0 ? psiClass.getSuperClass() : implement[0].resolve();
|
||||
assert superClass != null;
|
||||
PsiMethod method = superClass.getMethods()[0];
|
||||
final PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, psiClass, PsiSubstitutor.EMPTY);
|
||||
final List<PsiMethodMember> candidates = Collections.singletonList(new PsiMethodMember(method,
|
||||
OverrideImplementExploreUtil
|
||||
.correctSubstitutor(method,
|
||||
substitutor)));
|
||||
OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(getEditor(), psiClass, candidates, copyJavadoc, true);
|
||||
}
|
||||
else {
|
||||
OverrideImplementUtil.chooseAndOverrideOrImplementMethods(getProject(), getEditor(), psiClass, toImplement);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
checkResultByFile(BASE_DIR + "after" + name + ".java");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ide.DataManager;
|
||||
import com.intellij.lang.properties.psi.PropertiesFile;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
@@ -61,8 +62,15 @@ public class I18nizeTest extends LightCodeInsightTestCase {
|
||||
if (afterFileExists) {
|
||||
PsiLiteralExpression literalExpression = I18nizeAction.getEnclosingStringLiteral(getFile(), getEditor());
|
||||
assertNotNull(handler);
|
||||
handler.performI18nization(getFile(), getEditor(), literalExpression, Collections.<PropertiesFile>emptyList(), "key1", "value1", "i18nizedExpr",
|
||||
PsiExpression.EMPTY_ARRAY, JavaI18nUtil.DEFAULT_PROPERTY_CREATION_HANDLER);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
handler.performI18nization(getFile(), getEditor(), literalExpression, Collections.<PropertiesFile>emptyList(), "key1", "value1",
|
||||
"i18nizedExpr",
|
||||
PsiExpression.EMPTY_ARRAY, JavaI18nUtil.DEFAULT_PROPERTY_CREATION_HANDLER);
|
||||
}
|
||||
});
|
||||
|
||||
checkResultByFile(afterFile);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.lang.LanguageSurrounders;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.lang.surroundWith.SurroundDescriptor;
|
||||
import com.intellij.lang.surroundWith.Surrounder;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -216,14 +217,26 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
|
||||
PsiElement[] elements = item.getElementsToSurround(getFile(), selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
|
||||
assertTrue(surrounder.isApplicable(elements));
|
||||
|
||||
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
|
||||
}
|
||||
});
|
||||
|
||||
checkResultByFile(BASE_PATH + fileName + "_after.java");
|
||||
}
|
||||
|
||||
private void doTestWithTemplateFinish(@NotNull String fileName, Surrounder surrounder, @Nullable String textToType) {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
configureByFile(BASE_PATH + fileName + ".java");
|
||||
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder);
|
||||
}
|
||||
});
|
||||
|
||||
if (textToType != null) {
|
||||
type(textToType);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.intention.impl.SplitIfAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
|
||||
@@ -61,6 +77,11 @@ public class SplitIfActionTest extends LightCodeInsightTestCase {
|
||||
private void perform() throws Exception {
|
||||
SplitIfAction action = new SplitIfAction();
|
||||
assertTrue(action.isAvailable(getProject(), getEditor(), getFile()));
|
||||
action.invoke(getProject(), getEditor(), getFile());
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
action.invoke(getProject(), getEditor(), getFile());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Maxim.Mossienko
|
||||
@@ -6,6 +22,7 @@
|
||||
*/
|
||||
package com.intellij.editor;
|
||||
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.impl.LineSet;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
@@ -55,46 +72,56 @@ public class LineSetIncrementalUpdateTest extends LightCodeInsightTestCase {
|
||||
}
|
||||
|
||||
private static void doInsert() {
|
||||
Document document = myEditor.getDocument();
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING6);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING5);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING4);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING3);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING2);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING1);
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
Document document = myEditor.getDocument();
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING6);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING5);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING4);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING3);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING2);
|
||||
document.insertString(myEditor.getCaretModel().getOffset(), STRING1);
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
|
||||
private static void doDelete() {
|
||||
Document document = myEditor.getDocument();
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
Document document = myEditor.getDocument();
|
||||
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING1.length()
|
||||
);
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING1.length()
|
||||
);
|
||||
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING2.length()
|
||||
);
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING2.length()
|
||||
);
|
||||
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING3.length()
|
||||
);
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING3.length()
|
||||
);
|
||||
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING4.length()
|
||||
);
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING4.length()
|
||||
);
|
||||
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING5.length()
|
||||
);
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING5.length()
|
||||
);
|
||||
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING6.length()
|
||||
);
|
||||
document.deleteString(
|
||||
myEditor.getCaretModel().getOffset(),
|
||||
myEditor.getCaretModel().getOffset() + STRING6.length()
|
||||
);
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -43,9 +43,4 @@ public class FoldingExceptionTest extends LightCodeInsightTestCase {
|
||||
PsiDocumentManager.getInstance(ourProject).commitAllDocuments();
|
||||
CodeInsightTestFixtureImpl.instantiateAndRun(myFile, myEditor, new int[]{Pass.UPDATE_ALL, Pass.LOCAL_INSPECTIONS}, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRunInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.codeInsight.folding.CodeFoldingManager;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
@@ -80,11 +81,24 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT
|
||||
"}");
|
||||
executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS);
|
||||
checkFoldingState("[FoldRegion +(25:33), placeholder='{...}']");
|
||||
|
||||
myEditor.getDocument().insertString(0, "/*");
|
||||
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
myEditor.getDocument().insertString(0, "/*");
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
checkFoldingState("[FoldRegion -(0:37), placeholder='/.../', FoldRegion +(27:35), placeholder='{...}']");
|
||||
|
||||
myEditor.getDocument().deleteString(0, 2);
|
||||
|
||||
WriteCommandAction.runWriteCommandAction(getProject(),
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myEditor.getDocument().deleteString(0, 2);
|
||||
}
|
||||
});
|
||||
|
||||
checkFoldingState("[FoldRegion +(25:33), placeholder='{...}']");
|
||||
}
|
||||
|
||||
@@ -97,7 +111,13 @@ public class FoldingProcessingOnDocumentModificationTest extends AbstractEditorT
|
||||
executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS);
|
||||
checkFoldingState("[FoldRegion +(25:33), placeholder='{...}']");
|
||||
|
||||
myEditor.getDocument().insertString(0, "/*");
|
||||
new WriteCommandAction.Simple(getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
myEditor.getDocument().insertString(0, "/*");
|
||||
}
|
||||
}.execute().throwException();
|
||||
|
||||
checkFoldingState("[FoldRegion -(0:37), placeholder='/.../', FoldRegion +(27:35), placeholder='{...}']");
|
||||
|
||||
executeAction(IdeActions.ACTION_EXPAND_ALL_REGIONS);
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
@@ -1084,7 +1101,13 @@ public class TreeIsCorrectAfterDiffReparseTest extends LightCodeInsightTestCase
|
||||
|
||||
final PsiDocumentManager docManager = PsiDocumentManager.getInstance(ourProject);
|
||||
final Document doc = docManager.getDocument(myFile);
|
||||
doc.insertString(part1.length(), "/**");
|
||||
WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doc.insertString(part1.length(), "/**");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
boolean old = DebugUtil.CHECK;
|
||||
DebugUtil.CHECK = true;
|
||||
|
||||
+9
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.formatter.java;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
@@ -168,7 +169,13 @@ public class JavaFormatterInEditorTest extends LightPlatformCodeInsightTestCase
|
||||
|
||||
public void doTest(@NotNull String before, @NotNull String after) throws IOException {
|
||||
configureFromFileText(getTestName(false) + ".java", before);
|
||||
CodeStyleManager.getInstance(getProject()).reformatText(getFile(), 0, getEditor().getDocument().getTextLength());
|
||||
WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CodeStyleManager.getInstance(getProject()).reformatText(getFile(), 0, getEditor().getDocument().getTextLength());
|
||||
}
|
||||
});
|
||||
|
||||
checkResultByText(after);
|
||||
}
|
||||
}
|
||||
+29
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -66,7 +66,13 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase {
|
||||
final PsiClass cloneableClass = getJavaFacade().findClass("java.lang.Cloneable");
|
||||
assertNotNull(cloneableClass);
|
||||
final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass);
|
||||
extendsList.addAfter(reference, extendsList.getReferenceElements()[0]);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
extendsList.addAfter(reference, extendsList.getReferenceElements()[0]);
|
||||
}
|
||||
});
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
@@ -76,7 +82,13 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase {
|
||||
final PsiClass cloneableClass = getJavaFacade().findClass("java.lang.Cloneable");
|
||||
assertNotNull(cloneableClass);
|
||||
final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass);
|
||||
extendsList.addBefore(reference, extendsList.getReferenceElements()[0]);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
extendsList.addBefore(reference, extendsList.getReferenceElements()[0]);
|
||||
}
|
||||
});
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
@@ -86,7 +98,13 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase {
|
||||
final PsiClass cloneableClass = getJavaFacade().findClass("java.lang.Cloneable");
|
||||
assertNotNull(cloneableClass);
|
||||
final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass);
|
||||
extendsList.addBefore(reference, null);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
extendsList.addBefore(reference, null);
|
||||
}
|
||||
});
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
@@ -96,7 +114,13 @@ public class ExtendsBoundListTest extends LightCodeInsightTestCase {
|
||||
final PsiClass cloneableClass = getJavaFacade().findClass(CommonClassNames.JAVA_LANG_RUNNABLE);
|
||||
assertNotNull(cloneableClass);
|
||||
final PsiJavaCodeReferenceElement reference = getJavaFacade().getElementFactory().createClassReferenceElement(cloneableClass);
|
||||
extendsList.add(reference);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
extendsList.add(reference);
|
||||
}
|
||||
});
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.refactoring;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
@@ -919,7 +920,12 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
for (final Match match : duplicates) {
|
||||
if (!match.getMatchStart().isValid() || !match.getMatchEnd().isValid()) continue;
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
processor.processMatch(match);
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processor.processMatch(match);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -215,8 +215,4 @@ public class InplaceIntroduceParameterTest extends AbstractJavaInplaceIntroduceT
|
||||
return super.invokeImpl(project, localVariable, editor);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean isRunInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -18,8 +18,4 @@ package com.intellij.refactoring;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
|
||||
public abstract class LightRefactoringTestCase extends LightCodeInsightTestCase{
|
||||
@Override
|
||||
protected boolean isRunInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,11 @@ package com.intellij.testIntergration
|
||||
|
||||
import com.intellij.execution.Location
|
||||
import com.intellij.execution.TestStateStorage
|
||||
import com.intellij.execution.testframework.JavaTestLocator
|
||||
import com.intellij.execution.testframework.sm.runner.states.TestStateInfo
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.testIntegration.RecentTestRunner
|
||||
import com.intellij.testIntegration.SelectTestStep
|
||||
import com.intellij.testFramework.LightIdeaTestCase
|
||||
import com.intellij.testIntegration.*
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mockito.Matchers
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.mock
|
||||
@@ -33,8 +30,8 @@ import java.util.*
|
||||
fun passed(date: Date) = TestStateStorage.Record(TestStateInfo.Magnitude.PASSED_INDEX.value, date)
|
||||
fun failed(date: Date) = TestStateStorage.Record(TestStateInfo.Magnitude.FAILED_INDEX.value, date)
|
||||
|
||||
class RecentTestsStepTest {
|
||||
val runner = createRunner()
|
||||
class RecentTestsStepTest: LightIdeaTestCase() {
|
||||
val runner = mock(RecentTestRunner::class.java)
|
||||
|
||||
val passed = passed(Date(0))
|
||||
val failed = failed(Date(0))
|
||||
@@ -42,14 +39,14 @@ class RecentTestsStepTest {
|
||||
class TestStorage {
|
||||
private val map: MutableMap<String, TestStateStorage.Record> = hashMapOf()
|
||||
|
||||
fun addSuite(name: String, pass: Boolean, date: Date = Date(0)) {
|
||||
fun addSuite(name: String, pass: Boolean, date: Date = Date(0), language: String = "java") {
|
||||
val magnitude = if (pass) TestStateInfo.Magnitude.PASSED_INDEX else TestStateInfo.Magnitude.FAILED_INDEX
|
||||
addSuite(name, magnitude, date)
|
||||
addSuite(name, magnitude, date, language)
|
||||
}
|
||||
|
||||
fun addSuite(name: String, magnitude: TestStateInfo.Magnitude, date: Date = Date(0)) {
|
||||
fun addSuite(name: String, magnitude: TestStateInfo.Magnitude, date: Date = Date(0), language: String = "java") {
|
||||
val record = TestStateStorage.Record(magnitude.value, date)
|
||||
map.put("java:suite://$name", record)
|
||||
map.put("$language:suite://$name", record)
|
||||
}
|
||||
|
||||
fun addTest(name: String, magnitude: TestStateInfo.Magnitude, date: Date = Date(0)) {
|
||||
@@ -63,23 +60,27 @@ class RecentTestsStepTest {
|
||||
}
|
||||
|
||||
fun getMap() = map
|
||||
|
||||
fun getSuite(name: String, language: String = "java") = map["$language:suite://$name"]
|
||||
|
||||
fun removeUrl(url: String) {
|
||||
map.remove(url)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show sorted by date`() {
|
||||
fun `test show sorted by date`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("ASTest", true, Date(1000))
|
||||
storage.addSuite("JSTest", true, Date(1200))
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf("JSTest", "ASTest"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show tests sorted by date`() {
|
||||
fun `test show tests sorted by date`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("ASTest", false, Date(0))
|
||||
@@ -89,27 +90,25 @@ class RecentTestsStepTest {
|
||||
storage.addTest("ASTest.cccc", false, Date(20000))
|
||||
storage.addTest("ASTest.bbbb", false, Date(30000))
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf("ASTest", "ASTest.bbbb", "ASTest.cccc", "ASTest.aaaa"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show ignored`() {
|
||||
fun `test show ignored`() {
|
||||
val storage = TestStorage()
|
||||
storage.addSuite("ASTest", TestStateInfo.Magnitude.IGNORED_INDEX)
|
||||
storage.addTest("ASTest.ignored", TestStateInfo.Magnitude.IGNORED_INDEX)
|
||||
storage.addTest("ASTest.passed", pass = true)
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf("ASTest"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when suite passed - show only suite`() {
|
||||
fun `test when suite passed - show only suite`() {
|
||||
val map: MutableMap<String, TestStateStorage.Record> = hashMapOf()
|
||||
|
||||
map.put("java:suite://JavaFormatterSuperDuperTest", passed)
|
||||
@@ -121,19 +120,36 @@ class RecentTestsStepTest {
|
||||
map.put("java:test://Test.textQQQ", passed)
|
||||
map.put("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", passed)
|
||||
|
||||
val step = SelectTestStep(map, runner)
|
||||
|
||||
val expected = listOf(
|
||||
"java:suite://JavaFormatterSuperDuperTest",
|
||||
"java:suite://Test"
|
||||
)
|
||||
|
||||
assertThat(step.values).isEqualTo(expected)
|
||||
val list = getSortedList(map)
|
||||
assertThat(list).isEqualTo(expected)
|
||||
}
|
||||
|
||||
private fun getSortedList(map: MutableMap<String, TestStateStorage.Record>): List<String> {
|
||||
val provider = RecentTestsListProvider(map)
|
||||
return provider.urlsToShowFromHistory
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show failed first`() {
|
||||
|
||||
fun `test show only java tests`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("JavaTest1", true)
|
||||
storage.addSuite("JavaTest2", true)
|
||||
|
||||
storage.addSuite("JsSuite1", true, Date(0), "js")
|
||||
storage.addSuite("JsSuite2", true, Date(0), "js")
|
||||
storage.addSuite("JsSuite3", true, Date(0), "js")
|
||||
|
||||
val values = getSortedList(storage.getMap())
|
||||
assertThat(values.map { VirtualFileManager.extractPath(it) }).isEqualTo(listOf("JavaTest1", "JavaTest2"))
|
||||
}
|
||||
|
||||
fun `test show failed first`() {
|
||||
val map: MutableMap<String, TestStateStorage.Record> = hashMapOf()
|
||||
|
||||
map.put("java:suite://JavaFormatterSuperDuperTest", failed)
|
||||
@@ -148,7 +164,7 @@ class RecentTestsStepTest {
|
||||
map.put("java:test://Test.textQQQ", passed)
|
||||
map.put("java:test://JavaFormatterSuperDuperTest.testUnconditionalAlignmentErrorneous", passed)
|
||||
|
||||
val step = SelectTestStep(map, runner)
|
||||
val values = getSortedList(map)
|
||||
|
||||
val expected = listOf(
|
||||
"java:test://JavaFormatterFailed.fail",
|
||||
@@ -158,11 +174,10 @@ class RecentTestsStepTest {
|
||||
"java:suite://Test"
|
||||
)
|
||||
|
||||
assertThat(step.values).isEqualTo(expected)
|
||||
assertThat(values).isEqualTo(expected)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if failed more than 2 tests show suite first`() {
|
||||
|
||||
fun `test if failed more than 2 tests show suite first`() {
|
||||
val storage = TestStorage()
|
||||
storage.addSuite("ASTest", false)
|
||||
storage.addTest("ASTest.failed1", false, Date(3000))
|
||||
@@ -170,8 +185,8 @@ class RecentTestsStepTest {
|
||||
storage.addTest("ASTest.failed3", false, Date(1000))
|
||||
storage.addTest("ASTest.passed1", true)
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf(
|
||||
"ASTest",
|
||||
@@ -180,9 +195,8 @@ class RecentTestsStepTest {
|
||||
"ASTest.failed3"
|
||||
))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if failed less than 3 tests, show tests first`() {
|
||||
|
||||
fun `test if failed less than 3 tests, show tests first`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("ASTest", false)
|
||||
@@ -190,8 +204,8 @@ class RecentTestsStepTest {
|
||||
storage.addTest("ASTest.failed2", false, Date(2000))
|
||||
storage.addTest("ASTest.passed1", true)
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf(
|
||||
"ASTest.failed1",
|
||||
@@ -199,9 +213,8 @@ class RecentTestsStepTest {
|
||||
"ASTest"
|
||||
))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `if all failed show only suite`() {
|
||||
|
||||
fun `test if all failed show only suite`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("ASTest", false)
|
||||
@@ -210,17 +223,33 @@ class RecentTestsStepTest {
|
||||
storage.addTest("ASTest.failed3", false)
|
||||
storage.addTest("ASTest.failed4", false)
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf("ASTest"))
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun `do not show urls without location`() {
|
||||
val storage = TestStorage()
|
||||
private fun locatorReturningNullIfContains(substring: String): TestLocator {
|
||||
val locator = mock(TestLocator::class.java)
|
||||
`when`(locator.getLocation(Matchers.anyString())).thenAnswer {
|
||||
val url = it.arguments[0] as String
|
||||
if (url.contains(substring)) null else mock(Location::class.java)
|
||||
}
|
||||
return locator
|
||||
}
|
||||
|
||||
fun `test shown value without protocol`() {
|
||||
val step = SelectTestStep(emptyList(), emptyMap(), runner, mock(TestLocator::class.java))
|
||||
var shownValue = step.getTextFor("java:suite://JavaFormatterSuperDuperTest")
|
||||
assertThat(shownValue).isEqualTo("JavaFormatterSuperDuperTest")
|
||||
|
||||
shownValue = step.getTextFor("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt")
|
||||
assertThat(shownValue).isEqualTo("JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt")
|
||||
}
|
||||
|
||||
fun `test do not show urls which we can locate without location`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("ASTest", true)
|
||||
storage.addSuite("BSTest", false)
|
||||
storage.addTest("BSTest.fff", false)
|
||||
@@ -229,34 +258,47 @@ class RecentTestsStepTest {
|
||||
storage.addTest("<default package>", false)
|
||||
storage.addSuite("<default package>", false)
|
||||
|
||||
val step = SelectTestStep(storage.getMap(), runner)
|
||||
val values = step.values.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf("BSTest", "BSTest.fff", "ASTest"))
|
||||
val testStorageMock = createMockStorage(storage)
|
||||
|
||||
val map = storage.getMap()
|
||||
|
||||
val cleaner = DeadTestsCleaner(testStorageMock, map.keys.toList(), locatorReturningNullIfContains("<"))
|
||||
cleaner.run()
|
||||
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
val values = sortedUrlList.map { VirtualFileManager.extractPath(it) }
|
||||
|
||||
assertThat(values).isEqualTo(listOf("BSTest.fff", "BSTest", "ASTest"))
|
||||
assertThat(storage.getSuite("<default package>")).isEqualTo(null)
|
||||
}
|
||||
|
||||
private fun createRunner(): RecentTestRunner {
|
||||
val runner = mock(RecentTestRunner::class.java)
|
||||
`when`(runner.isSuite(Matchers.anyString())).thenAnswer {
|
||||
val url = it.arguments[0] as String
|
||||
val protocol = VirtualFileManager.extractProtocol(url)
|
||||
JavaTestLocator.SUITE_PROTOCOL.startsWith(protocol.toString())
|
||||
}
|
||||
`when`(runner.getLocation(Matchers.anyString())).thenAnswer {
|
||||
val url = it.arguments[0] as String
|
||||
if (url.contains("<")) null else mock(Location::class.java)
|
||||
}
|
||||
return runner
|
||||
fun `test do not remove tests if we are unable to locate them`() {
|
||||
val storage = TestStorage()
|
||||
|
||||
storage.addSuite("ASTest", true)
|
||||
|
||||
storage.addSuite("JsSuite1", true, Date(), "js")
|
||||
storage.addSuite("JsSuite2", true, Date(), "js")
|
||||
|
||||
val testStorageMock = createMockStorage(storage)
|
||||
|
||||
val sortedUrlList = getSortedList(storage.getMap())
|
||||
|
||||
val cleaner = DeadTestsCleaner(testStorageMock, sortedUrlList, locatorReturningNullIfContains("JsSuite"))
|
||||
cleaner.run()
|
||||
|
||||
assertThat(storage.getSuite("JsSuite1", "js")).isNotEqualTo(null)
|
||||
assertThat(storage.getSuite("JsSuite2", "js")).isNotEqualTo(null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `shown value without protocol`() {
|
||||
val step = SelectTestStep(emptyMap(), runner)
|
||||
var shownValue = step.getTextFor("java:suite://JavaFormatterSuperDuperTest")
|
||||
assertThat(shownValue).isEqualTo("JavaFormatterSuperDuperTest")
|
||||
|
||||
shownValue = step.getTextFor("java:test://JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt")
|
||||
assertThat(shownValue).isEqualTo("JavaFormatterSuperDuperTest.testItMakesMeSadToFixIt")
|
||||
private fun createMockStorage(storage: TestStorage): TestStateStorage? {
|
||||
val testStorageMock = mock(TestStateStorage::class.java)
|
||||
`when`(testStorageMock.removeState(Matchers.anyString())).then {
|
||||
val url = it.arguments[0]as String
|
||||
storage.removeUrl(url)
|
||||
}
|
||||
return testStorageMock
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 18-Mar-2008
|
||||
@@ -8,7 +24,6 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PsiImmediateClassType;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.typeMigration.TypeMigrationLabeler;
|
||||
import com.intellij.refactoring.typeMigration.TypeMigrationProcessor;
|
||||
import com.intellij.refactoring.typeMigration.TypeMigrationRules;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
@@ -143,9 +158,4 @@ public class ChangeTypeSignatureTest extends LightCodeInsightTestCase {
|
||||
public void testMethodReturnTypeMigration() throws Exception {
|
||||
doTest(true, "java.lang.Integer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRunInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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 org.jetbrains.jps.api;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* Makes TaskFuture from the supplied Future
|
||||
*/
|
||||
public class TaskFutureAdapter<T> implements TaskFuture<T> {
|
||||
@NotNull private final Future<T> myFuture;
|
||||
|
||||
public TaskFutureAdapter(@NotNull Future<T> future) {
|
||||
myFuture = future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waitFor() {
|
||||
try {
|
||||
get();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (CancellationException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean waitFor(long timeout, TimeUnit unit) {
|
||||
try {
|
||||
get(timeout, unit);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (TimeoutException ignored) {
|
||||
}
|
||||
catch (CancellationException ignored) {
|
||||
}
|
||||
return isDone();
|
||||
}
|
||||
|
||||
// delegates
|
||||
@Override
|
||||
public boolean cancel(boolean mayInterruptIfRunning) {
|
||||
return myFuture.cancel(mayInterruptIfRunning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return myFuture.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDone() {
|
||||
return myFuture.isDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get() throws InterruptedException, ExecutionException {
|
||||
return myFuture.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(long timeout, @NotNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return myFuture.get(timeout, unit);
|
||||
}
|
||||
}
|
||||
+19
@@ -1,10 +1,29 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.psi.impl.source.resolve.reference.impl.providers;
|
||||
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface FileReferenceResolver {
|
||||
@Nullable
|
||||
PsiFileSystemItem resolveFileReference(@NotNull FileReference reference, @NotNull String name);
|
||||
|
||||
Collection<Object> getVariants(@NotNull FileReference reference);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ private class BuiltInWebServerTest : BuiltInServerTestCase() {
|
||||
|
||||
private fun testIndex(vararg paths: String) {
|
||||
val project = BuiltInServerTestCase.projectRule.project
|
||||
val newPath = tempDirManager.newPath(refreshVfs = false)
|
||||
val newPath = tempDirManager.newPath()
|
||||
newPath.writeChild(manager.filePath!!, "hello")
|
||||
newPath.refreshVfs()
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ internal class TestManager(val projectRule: ProjectRule, private val tempDirMana
|
||||
projectRule.project
|
||||
|
||||
if (filePath!! == "_tmp_") {
|
||||
val file = tempDirManager.newPath(".txt")
|
||||
val file = tempDirManager.newPath(".txt", refreshVfs = true)
|
||||
if (!annotation!!.doNotCreate) {
|
||||
file.createFile()
|
||||
}
|
||||
|
||||
@@ -33,14 +33,15 @@ import com.intellij.util.LineSeparator
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.SystemProperties
|
||||
import com.intellij.util.containers.SmartHashSet
|
||||
import com.intellij.util.systemIndependentPath
|
||||
import gnu.trove.THashMap
|
||||
import org.jdom.Element
|
||||
import java.io.File
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.file.Path
|
||||
|
||||
open class DirectoryBasedStorage(private val dir: File,
|
||||
open class DirectoryBasedStorage(private val dir: Path,
|
||||
private val splitter: StateSplitter,
|
||||
private val pathMacroSubstitutor: TrackingPathMacroSubstitutor? = null) : StateStorageBase<StateMap>() {
|
||||
private @Volatile var virtualFile: VirtualFile? = null
|
||||
@@ -93,7 +94,7 @@ open class DirectoryBasedStorage(private val dir: File,
|
||||
private fun getVirtualFile(): VirtualFile? {
|
||||
var result = virtualFile
|
||||
if (result == null) {
|
||||
result = LocalFileSystem.getInstance().findFileByIoFile(dir)
|
||||
result = LocalFileSystem.getInstance().findFileByPath(dir.systemIndependentPath)
|
||||
virtualFile = result
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -27,7 +27,8 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.lang.CompoundRuntimeException
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
const val ROOT_CONFIG = "\$ROOT_CONFIG$"
|
||||
|
||||
@@ -59,7 +60,7 @@ sealed class SchemeManagerFactoryBase : SchemesManagerFactory(), SettingsSavingC
|
||||
return originalPath
|
||||
}
|
||||
|
||||
abstract fun pathToFile(path: String, storageManager: StateStorageManager): File
|
||||
abstract fun pathToFile(path: String, storageManager: StateStorageManager): Path
|
||||
|
||||
fun process(processor: (SchemeManagerImpl<Scheme, ExternalizableScheme>) -> Unit) {
|
||||
for (manager in managers) {
|
||||
@@ -100,12 +101,12 @@ sealed class SchemeManagerFactoryBase : SchemesManagerFactory(), SettingsSavingC
|
||||
return path
|
||||
}
|
||||
|
||||
override fun pathToFile(path: String, storageManager: StateStorageManager) = File(storageManager.expandMacros("$ROOT_CONFIG/$path"))
|
||||
override fun pathToFile(path: String, storageManager: StateStorageManager) = Paths.get(storageManager.expandMacros(ROOT_CONFIG), path)
|
||||
}
|
||||
|
||||
private class ProjectSchemeManagerFactory(private val project: Project) : SchemeManagerFactoryBase() {
|
||||
override val componentManager = project
|
||||
|
||||
override fun pathToFile(path: String, storageManager: StateStorageManager) = File(project.basePath, if (ProjectUtil.isDirectoryBased(project)) "${Project.DIRECTORY_STORE_FOLDER}/$path" else ".$path")
|
||||
override fun pathToFile(path: String, storageManager: StateStorageManager) = Paths.get(project.basePath, if (ProjectUtil.isDirectoryBased(project)) "${Project.DIRECTORY_STORE_FOLDER}/$path" else ".$path")
|
||||
}
|
||||
}
|
||||
@@ -35,28 +35,24 @@ import com.intellij.openapi.util.text.StringUtilRt
|
||||
import com.intellij.openapi.vfs.*
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile
|
||||
import com.intellij.openapi.vfs.tracker.VirtualFileTracker
|
||||
import com.intellij.util.PathUtil
|
||||
import com.intellij.util.PathUtilRt
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.ThrowableConvertor
|
||||
import com.intellij.util.*
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.io.URLUtil
|
||||
import com.intellij.util.text.UniqueNameGenerator
|
||||
import gnu.trove.THashMap
|
||||
import gnu.trove.THashSet
|
||||
import gnu.trove.TObjectObjectProcedure
|
||||
import gnu.trove.TObjectProcedure
|
||||
import org.jdom.Document
|
||||
import org.jdom.Element
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
|
||||
class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: String,
|
||||
private val processor: SchemeProcessor<E>,
|
||||
private val provider: StreamProvider?,
|
||||
private val ioDirectory: File,
|
||||
private val ioDirectory: Path,
|
||||
val roamingType: RoamingType = RoamingType.DEFAULT,
|
||||
virtualFileTrackerDisposable: Disposable? = null,
|
||||
val presentableName: String? = null) : SchemesManager<T, E>(), SafeWriteRequestor {
|
||||
@@ -104,7 +100,7 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
|
||||
private fun refreshVirtualDirectoryAndAddListener(virtualFileTrackerDisposable: Disposable?) {
|
||||
// store refreshes root directory, so, we don't need to use refreshAndFindFile
|
||||
val directory = LocalFileSystem.getInstance().findFileByIoFile(ioDirectory) ?: return
|
||||
val directory = LocalFileSystem.getInstance().findFileByPath(ioDirectory.systemIndependentPath) ?: return
|
||||
|
||||
this.directory = directory
|
||||
directory.children
|
||||
@@ -118,7 +114,7 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
}
|
||||
|
||||
private fun addVfsListener(virtualFileTrackerDisposable: Disposable?) {
|
||||
service<VirtualFileTracker>().addTracker("${LocalFileSystem.PROTOCOL_PREFIX}${ioDirectory.absolutePath.replace(File.separatorChar, '/')}", object : VirtualFileAdapter() {
|
||||
service<VirtualFileTracker>().addTracker("${LocalFileSystem.PROTOCOL_PREFIX}${ioDirectory.toAbsolutePath().systemIndependentPath}", object : VirtualFileAdapter() {
|
||||
override fun contentsChanged(event: VirtualFileEvent) {
|
||||
if (event.requestor != null || !isMy(event)) {
|
||||
return
|
||||
@@ -268,17 +264,17 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
}
|
||||
}
|
||||
else {
|
||||
ioDirectory.listFiles({ parent, name -> canRead(name) })?.let {
|
||||
ioDirectory.directoryStreamIfExists({ canRead(it.fileName.toString()) }) {
|
||||
for (file in it) {
|
||||
if (file.isDirectory) {
|
||||
if (file.isDirectory()) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
loadScheme(file.name, file.inputStream(), true)
|
||||
loadScheme(file.fileName.toString(), file.inputStream(), true)
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
LOG.error("Cannot read scheme ${file.path}", e)
|
||||
LOG.error("Cannot read scheme $file", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -467,16 +463,16 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
}
|
||||
|
||||
private fun removeDirectoryIfEmpty(errors: MutableList<Throwable>) {
|
||||
ioDirectory.listFiles()?.let {
|
||||
ioDirectory.directoryStreamIfExists {
|
||||
for (file in it) {
|
||||
if (!file.isHidden) {
|
||||
LOG.info("Directory ${ioDirectory.name} is not deleted: at least one file ${file.name} exists")
|
||||
return
|
||||
if (!file.isHidden()) {
|
||||
LOG.info("Directory ${ioDirectory.fileName} is not deleted: at least one file ${file.fileName} exists")
|
||||
return@removeDirectoryIfEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("Remove schemes directory ${ioDirectory.name}")
|
||||
LOG.info("Remove schemes directory ${ioDirectory.fileName}")
|
||||
directory = null
|
||||
|
||||
var deleteUsingIo = !useVfs
|
||||
@@ -496,7 +492,7 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
}
|
||||
|
||||
if (deleteUsingIo) {
|
||||
errors.catch { FileUtil.delete(ioDirectory) }
|
||||
errors.catch { ioDirectory.deleteRecursively() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,7 +577,7 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
if (renamed) {
|
||||
externalInfo!!.scheduleDelete()
|
||||
}
|
||||
FileUtil.writeToFile(File(ioDirectory, fileName), byteOut.internalBuffer, 0, byteOut.size())
|
||||
ioDirectory.resolve(fileName).write(byteOut.internalBuffer, 0, byteOut.size())
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -655,7 +651,7 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
|
||||
if (deleteUsingIo) {
|
||||
for (name in filesToDelete) {
|
||||
errors.catch { FileUtil.delete(File(ioDirectory, name)) }
|
||||
errors.catch { ioDirectory.resolve(name).delete() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,13 +661,13 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
private fun getDirectory(): VirtualFile? {
|
||||
var result = directory
|
||||
if (result == null) {
|
||||
result = LocalFileSystem.getInstance().findFileByIoFile(ioDirectory)
|
||||
result = LocalFileSystem.getInstance().findFileByPath(ioDirectory.systemIndependentPath)
|
||||
directory = result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getRootDirectory() = ioDirectory
|
||||
override fun getRootDirectory() = ioDirectory.toFile()
|
||||
|
||||
override fun setSchemes(newSchemes: List<T>, newCurrentScheme: T?, removeCondition: Condition<T>?) {
|
||||
val oldCurrentScheme = currentScheme
|
||||
@@ -705,25 +701,23 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
return
|
||||
}
|
||||
|
||||
schemeToInfo.retainEntries(object : TObjectObjectProcedure<E, ExternalInfo> {
|
||||
override fun execute(scheme: E, info: ExternalInfo): Boolean {
|
||||
if (readOnlyExternalizableSchemes[scheme.name] == scheme) {
|
||||
return true
|
||||
}
|
||||
|
||||
for (t in newSchemes) {
|
||||
// by identity
|
||||
if (t === scheme) {
|
||||
if (filesToDelete.isNotEmpty()) {
|
||||
filesToDelete.remove("${info.fileName}")
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
info.scheduleDelete()
|
||||
return false
|
||||
schemeToInfo.retainEntries(TObjectObjectProcedure<E, ExternalInfo> { scheme, info ->
|
||||
if (readOnlyExternalizableSchemes[scheme.name] == scheme) {
|
||||
return@TObjectObjectProcedure true
|
||||
}
|
||||
|
||||
for (t in newSchemes) {
|
||||
// by identity
|
||||
if (t === scheme) {
|
||||
if (filesToDelete.isNotEmpty()) {
|
||||
filesToDelete.remove("${info.fileName}")
|
||||
}
|
||||
return@TObjectObjectProcedure true
|
||||
}
|
||||
}
|
||||
|
||||
info.scheduleDelete()
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -777,12 +771,10 @@ class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(val fileSpec: Stri
|
||||
}
|
||||
|
||||
override fun clearAllSchemes() {
|
||||
schemeToInfo.forEachValue(object : TObjectProcedure<ExternalInfo> {
|
||||
override fun execute(info: ExternalInfo): Boolean {
|
||||
info.scheduleDelete()
|
||||
return true
|
||||
}
|
||||
})
|
||||
schemeToInfo.forEachValue {
|
||||
it.scheduleDelete()
|
||||
true
|
||||
}
|
||||
|
||||
currentScheme = null
|
||||
schemes.clear()
|
||||
@@ -895,11 +887,11 @@ private inline fun MutableList<Throwable>.catch(runnable: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
fun createDir(ioDir: File, requestor: Any): VirtualFile {
|
||||
ioDir.mkdirs()
|
||||
fun createDir(ioDir: Path, requestor: Any): VirtualFile {
|
||||
ioDir.createDirectories()
|
||||
val parentFile = ioDir.parent
|
||||
val parentVirtualFile = (if (parentFile == null) null else VfsUtil.createDirectoryIfMissing(parentFile)) ?: throw IOException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile))
|
||||
return getFile(ioDir.name, parentVirtualFile, requestor)
|
||||
val parentVirtualFile = (if (parentFile == null) null else VfsUtil.createDirectoryIfMissing(parentFile.systemIndependentPath)) ?: throw IOException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile))
|
||||
return getFile(ioDir.fileName.toString(), parentVirtualFile, requestor)
|
||||
}
|
||||
|
||||
fun getFile(fileName: String, parent: VirtualFile, requestor: Any): VirtualFile {
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.jdom.Element
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import java.util.regex.Pattern
|
||||
@@ -195,7 +197,7 @@ open class StateStorageManagerImpl(private val rootTagName: String,
|
||||
val filePath = expandMacros(collapsedPath)
|
||||
@Suppress("DEPRECATION")
|
||||
if (stateSplitter != StateSplitter::class.java && stateSplitter != StateSplitterEx::class.java) {
|
||||
val storage = MyDirectoryStorage(this, File(filePath), ReflectionUtil.newInstance(stateSplitter))
|
||||
val storage = MyDirectoryStorage(this, Paths.get(filePath), ReflectionUtil.newInstance(stateSplitter))
|
||||
virtualFileTracker?.put(filePath, storage)
|
||||
return storage
|
||||
}
|
||||
@@ -212,7 +214,7 @@ open class StateStorageManagerImpl(private val rootTagName: String,
|
||||
return storage
|
||||
}
|
||||
|
||||
private class MyDirectoryStorage(override val storageManager: StateStorageManagerImpl, file: File, @Suppress("DEPRECATION") splitter: StateSplitter) :
|
||||
private class MyDirectoryStorage(override val storageManager: StateStorageManagerImpl, file: Path, @Suppress("DEPRECATION") splitter: StateSplitter) :
|
||||
DirectoryBasedStorage(file, splitter, storageManager.pathMacroSubstitutor), StorageVirtualFileTracker.TrackedStorage
|
||||
|
||||
private class MyFileStorage(override val storageManager: StateStorageManagerImpl,
|
||||
|
||||
@@ -62,7 +62,7 @@ internal class ApplicationStoreTest {
|
||||
private var componentStore: MyComponentStore by Delegates.notNull()
|
||||
|
||||
@Before fun setUp() {
|
||||
testAppConfig = tempDirManager.newPath(refreshVfs = false)
|
||||
testAppConfig = tempDirManager.newPath()
|
||||
componentStore = MyComponentStore(testAppConfig.systemIndependentPath)
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ internal class ApplicationStoreTest {
|
||||
@Test fun `don't save if only format is changed`() {
|
||||
val oldContent = "<application><component name=\"A\" foo=\"old\" deprecated=\"old\"/></application>"
|
||||
val file = writeConfig("a.xml", oldContent)
|
||||
val oldModificationTime = file.getLastModifiedTime()
|
||||
val oldModificationTime = file.lastModified()
|
||||
testAppConfig.refreshVfs()
|
||||
|
||||
val component = A()
|
||||
@@ -230,7 +230,7 @@ internal class ApplicationStoreTest {
|
||||
saveStore()
|
||||
|
||||
assertThat(file).hasContent(oldContent)
|
||||
assertThat(oldModificationTime).isEqualTo(file.getLastModifiedTime())
|
||||
assertThat(oldModificationTime).isEqualTo(file.lastModified())
|
||||
|
||||
component.options.bar = "2"
|
||||
component.options.foo = "1"
|
||||
|
||||
@@ -65,8 +65,8 @@ internal class DirectoryBasedStorageTest {
|
||||
@Rule fun getChain() = ruleChain
|
||||
|
||||
@Test fun save() {
|
||||
val dir = tempDirManager.newPath()
|
||||
val storage = DirectoryBasedStorage(dir.toFile(), TestStateSplitter())
|
||||
val dir = tempDirManager.newPath(refreshVfs = true)
|
||||
val storage = DirectoryBasedStorage(dir, TestStateSplitter())
|
||||
|
||||
val componentName = "test"
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ internal class ModuleStoreRenameTest {
|
||||
object : ExternalResource() {
|
||||
override fun before() {
|
||||
runInEdtAndWait {
|
||||
module = projectRule.createModule(tempDirManager.newPath().resolve("m.iml"))
|
||||
module = projectRule.createModule(tempDirManager.newPath(refreshVfs = true).resolve("m.iml"))
|
||||
}
|
||||
|
||||
module.messageBus.connect().subscribe(ProjectTopics.MODULES, object : ModuleAdapter() {
|
||||
|
||||
@@ -76,7 +76,7 @@ class ModuleStoreTest {
|
||||
|
||||
@Test fun `must be empty if classpath storage`() {
|
||||
// we must not use VFS here, file must not be created
|
||||
val moduleFile = tempDirManager.newPath("module").resolve("test.iml")
|
||||
val moduleFile = tempDirManager.newPath("module", refreshVfs = true).resolve("test.iml")
|
||||
moduleFile.createModule().useAndDispose {
|
||||
ModuleRootModificationUtil.addContentRoot(this, moduleFile.parentSystemIndependentPath)
|
||||
saveStore()
|
||||
@@ -92,7 +92,7 @@ class ModuleStoreTest {
|
||||
|
||||
@Test fun `one batch update session if several modules changed`() {
|
||||
val nameToCount = TObjectIntHashMap<String>()
|
||||
val root = tempDirManager.newPath()
|
||||
val root = tempDirManager.newPath(refreshVfs = true)
|
||||
|
||||
fun Module.addContentRoot() {
|
||||
val moduleName = name
|
||||
|
||||
@@ -27,11 +27,11 @@ import com.intellij.openapi.project.ex.ProjectEx
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx
|
||||
import com.intellij.openapi.project.impl.ProjectImpl
|
||||
import com.intellij.openapi.project.impl.ProjectManagerImpl
|
||||
import com.intellij.openapi.util.io.systemIndependentPath
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.testFramework.*
|
||||
import com.intellij.util.PathUtil
|
||||
import com.intellij.util.readText
|
||||
import com.intellij.util.systemIndependentPath
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.junit.ClassRule
|
||||
@@ -52,7 +52,7 @@ private fun createOrLoadProject(tempDirManager: TemporaryDirectory, task: (Proje
|
||||
runInEdtAndWait {
|
||||
var filePath: String
|
||||
if (projectCreator == null) {
|
||||
filePath = tempDirManager.newDirectory("test${if (directoryBased) "" else ProjectFileType.DOT_DEFAULT_EXTENSION}").systemIndependentPath
|
||||
filePath = tempDirManager.newPath("test${if (directoryBased) "" else ProjectFileType.DOT_DEFAULT_EXTENSION}").systemIndependentPath
|
||||
}
|
||||
else {
|
||||
filePath = runWriteAction { projectCreator(tempDirManager.newVirtualDirectory()) }
|
||||
|
||||
@@ -18,13 +18,12 @@ package com.intellij.configurationStore
|
||||
import com.intellij.openapi.options.BaseSchemeProcessor
|
||||
import com.intellij.openapi.options.ExternalizableScheme
|
||||
import com.intellij.openapi.options.SchemesManagerFactory
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.ProjectRule
|
||||
import com.intellij.testFramework.TemporaryDirectory
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.*
|
||||
import com.intellij.util.lang.CompoundRuntimeException
|
||||
import com.intellij.util.xmlb.XmlSerializer
|
||||
import com.intellij.util.xmlb.annotations.Attribute
|
||||
@@ -40,6 +39,7 @@ import org.junit.ClassRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
internal val FILE_SPEC = "REMOTE"
|
||||
|
||||
@@ -55,8 +55,8 @@ internal class SchemeManagerTest {
|
||||
private val tempDirManager = TemporaryDirectory()
|
||||
@Rule fun getTemporaryFolder() = tempDirManager
|
||||
|
||||
private var localBaseDir: File? = null
|
||||
private var remoteBaseDir: File? = null
|
||||
private var localBaseDir: Path? = null
|
||||
private var remoteBaseDir: Path? = null
|
||||
|
||||
private fun getTestDataPath() = PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/platform/platform-tests/testData/options"
|
||||
|
||||
@@ -112,14 +112,14 @@ internal class SchemeManagerTest {
|
||||
firstScheme!!.name = "first_renamed"
|
||||
manager.save()
|
||||
|
||||
checkSchemes(File(remoteBaseDir, "REMOTE"), "first_renamed->first_renamed;2->second", true)
|
||||
checkSchemes(remoteBaseDir!!.resolve("REMOTE"), "first_renamed->first_renamed;2->second", true)
|
||||
checkSchemes(localBaseDir!!, "", false)
|
||||
|
||||
firstScheme.name = "first_renamed2"
|
||||
manager.removeScheme(firstScheme)
|
||||
manager.save()
|
||||
|
||||
checkSchemes(File(remoteBaseDir, "REMOTE"), "2->second", true)
|
||||
checkSchemes(remoteBaseDir!!.resolve("REMOTE"), "2->second", true)
|
||||
checkSchemes(localBaseDir!!, "", false)
|
||||
}
|
||||
|
||||
@@ -142,16 +142,16 @@ internal class SchemeManagerTest {
|
||||
assertThat("first2").isEqualTo(scheme.name)
|
||||
}
|
||||
|
||||
fun TestScheme.save(file: File) {
|
||||
FileUtil.writeToFile(file, serialize().toByteArray())
|
||||
fun TestScheme.save(file: Path) {
|
||||
file.write(serialize().toByteArray())
|
||||
}
|
||||
|
||||
@Test fun `different extensions`() {
|
||||
val dir = tempDirManager.newDirectory()
|
||||
val dir = tempDirManager.newPath()
|
||||
|
||||
val scheme = TestScheme("local", "true")
|
||||
scheme.save(File(dir, "1.icls"))
|
||||
TestScheme("local", "false").save(File(dir, "1.xml"))
|
||||
scheme.save(dir.resolve("1.icls"))
|
||||
TestScheme("local", "false").save(dir.resolve("1.xml"))
|
||||
|
||||
val schemesManager = SchemeManagerImpl<TestScheme, TestScheme>(FILE_SPEC, object: TestSchemesProcessor() {
|
||||
override fun isUpgradeNeeded() = true
|
||||
@@ -161,18 +161,18 @@ internal class SchemeManagerTest {
|
||||
schemesManager.loadSchemes()
|
||||
assertThat(schemesManager.allSchemes).containsOnly(scheme)
|
||||
|
||||
assertThat(File(dir, "1.icls")).isFile()
|
||||
assertThat(File(dir, "1.xml")).isFile()
|
||||
assertThat(dir.resolve("1.icls")).isRegularFile()
|
||||
assertThat(dir.resolve("1.xml")).isRegularFile()
|
||||
|
||||
scheme.data = "newTrue"
|
||||
schemesManager.save()
|
||||
|
||||
assertThat(File(dir, "1.icls")).isFile()
|
||||
assertThat(File(dir, "1.xml")).doesNotExist()
|
||||
assertThat(dir.resolve("1.icls")).isRegularFile()
|
||||
assertThat(dir.resolve("1.xml")).doesNotExist()
|
||||
}
|
||||
|
||||
@Test fun setSchemes() {
|
||||
val dir = tempDirManager.newDirectory()
|
||||
val dir = tempDirManager.newPath()
|
||||
val schemeManager = createSchemeManager(dir)
|
||||
schemeManager.loadSchemes()
|
||||
assertThat(schemeManager.allSchemes).isEmpty()
|
||||
@@ -183,12 +183,12 @@ internal class SchemeManagerTest {
|
||||
val schemes = schemeManager.allSchemes
|
||||
assertThat(schemes).containsOnly(scheme)
|
||||
|
||||
assertThat(File(dir, "s1.xml")).doesNotExist()
|
||||
assertThat(dir.resolve("s1.xml")).doesNotExist()
|
||||
|
||||
scheme.data = "newTrue"
|
||||
schemeManager.save()
|
||||
|
||||
assertThat(File(dir, "s1.xml")).isFile()
|
||||
assertThat(dir.resolve("s1.xml")).isRegularFile()
|
||||
|
||||
schemeManager.setSchemes(emptyList())
|
||||
|
||||
@@ -198,7 +198,7 @@ internal class SchemeManagerTest {
|
||||
}
|
||||
|
||||
@Test fun `save only if scheme differs from bundled`() {
|
||||
val dir = tempDirManager.newDirectory()
|
||||
val dir = tempDirManager.newPath()
|
||||
var schemeManager = createSchemeManager(dir)
|
||||
val converter: (Element) -> TestScheme = { XmlSerializer.deserialize(it, TestScheme::class.java)!! }
|
||||
val bundledPath = "/bundledSchemes/default"
|
||||
@@ -219,7 +219,7 @@ internal class SchemeManagerTest {
|
||||
|
||||
customScheme.data = "foo"
|
||||
schemeManager.save()
|
||||
assertThat(File(dir, "default.xml")).isFile()
|
||||
assertThat(dir.resolve("default.xml")).isRegularFile()
|
||||
|
||||
schemeManager = createSchemeManager(dir)
|
||||
schemeManager.loadBundledScheme(bundledPath, this, converter)
|
||||
@@ -230,7 +230,7 @@ internal class SchemeManagerTest {
|
||||
}
|
||||
|
||||
@Test fun `don't remove dir if no schemes but at least one non-hidden file exists`() {
|
||||
val dir = tempDirManager.newDirectory()
|
||||
val dir = tempDirManager.newPath()
|
||||
val schemeManager = createSchemeManager(dir)
|
||||
|
||||
val scheme = TestScheme("s1")
|
||||
@@ -238,12 +238,12 @@ internal class SchemeManagerTest {
|
||||
|
||||
schemeManager.save()
|
||||
|
||||
val schemeFile = File(dir, "s1.xml")
|
||||
assertThat(schemeFile).isFile()
|
||||
val schemeFile = dir.resolve("s1.xml")
|
||||
assertThat(schemeFile).isRegularFile()
|
||||
|
||||
schemeManager.setSchemes(emptyList())
|
||||
|
||||
FileUtil.writeToFile(File(dir, "empty"), byteArrayOf())
|
||||
dir.resolve("empty").write(byteArrayOf())
|
||||
|
||||
schemeManager.save()
|
||||
|
||||
@@ -252,11 +252,11 @@ internal class SchemeManagerTest {
|
||||
}
|
||||
|
||||
@Test fun `remove empty directory only if some file was deleted`() {
|
||||
val dir = tempDirManager.newDirectory()
|
||||
val dir = tempDirManager.newPath()
|
||||
val schemeManager = createSchemeManager(dir)
|
||||
schemeManager.loadSchemes()
|
||||
|
||||
assertThat(dir.mkdirs()).isTrue()
|
||||
dir.createDirectories()
|
||||
schemeManager.save()
|
||||
assertThat(dir).isDirectory()
|
||||
|
||||
@@ -270,7 +270,7 @@ internal class SchemeManagerTest {
|
||||
}
|
||||
|
||||
@Test fun rename() {
|
||||
val dir = tempDirManager.newDirectory()
|
||||
val dir = tempDirManager.newPath()
|
||||
val schemeManager = createSchemeManager(dir)
|
||||
schemeManager.loadSchemes()
|
||||
assertThat(schemeManager.allSchemes).isEmpty()
|
||||
@@ -281,19 +281,19 @@ internal class SchemeManagerTest {
|
||||
val schemes = schemeManager.allSchemes
|
||||
assertThat(schemes).containsOnly(scheme)
|
||||
|
||||
assertThat(File(dir, "s1.xml")).doesNotExist()
|
||||
assertThat(dir.resolve("s1.xml")).doesNotExist()
|
||||
|
||||
scheme.data = "newTrue"
|
||||
schemeManager.save()
|
||||
|
||||
assertThat(File(dir, "s1.xml")).isFile()
|
||||
assertThat(dir.resolve("s1.xml")).isRegularFile()
|
||||
|
||||
scheme.name = "s2"
|
||||
|
||||
schemeManager.save()
|
||||
|
||||
assertThat(File(dir, "s1.xml")).doesNotExist()
|
||||
assertThat(File(dir, "s2.xml")).isFile()
|
||||
assertThat(dir.resolve("s1.xml")).doesNotExist()
|
||||
assertThat(dir.resolve("s2.xml")).isRegularFile()
|
||||
}
|
||||
|
||||
@Test fun `path must not contains ROOT_CONFIG macro`() {
|
||||
@@ -304,7 +304,7 @@ internal class SchemeManagerTest {
|
||||
assertThatThrownBy({SchemesManagerFactory.getInstance().create<TestScheme, TestScheme>("foo\\bar", TestSchemesProcessor())}).hasMessage("Path must be system-independent, use forward slash instead of backslash")
|
||||
}
|
||||
|
||||
private fun createSchemeManager(dir: File) = SchemeManagerImpl<TestScheme, TestScheme>(FILE_SPEC, TestSchemesProcessor(), null, dir)
|
||||
private fun createSchemeManager(dir: Path) = SchemeManagerImpl<TestScheme, TestScheme>(FILE_SPEC, TestSchemesProcessor(), null, dir)
|
||||
|
||||
private fun createAndLoad(testData: String): SchemeManagerImpl<TestScheme, TestScheme> {
|
||||
createTempFiles(testData)
|
||||
@@ -314,30 +314,30 @@ internal class SchemeManagerTest {
|
||||
private fun doLoadSaveTest(testData: String, expected: String, localExpected: String = "") {
|
||||
val schemesManager = createAndLoad(testData)
|
||||
schemesManager.save()
|
||||
checkSchemes(File(remoteBaseDir, "REMOTE"), expected, true)
|
||||
checkSchemes(remoteBaseDir!!.resolve("REMOTE"), expected, true)
|
||||
checkSchemes(localBaseDir!!, localExpected, false)
|
||||
}
|
||||
|
||||
private fun checkSchemes(expected: String) {
|
||||
checkSchemes(File(remoteBaseDir, "REMOTE"), expected, true)
|
||||
checkSchemes(remoteBaseDir!!.resolve("REMOTE"), expected, true)
|
||||
checkSchemes(localBaseDir!!, "", false)
|
||||
}
|
||||
|
||||
private fun createAndLoad(): SchemeManagerImpl<TestScheme, TestScheme> {
|
||||
val schemesManager = SchemeManagerImpl<TestScheme, TestScheme>(FILE_SPEC, TestSchemesProcessor(), MockStreamProvider(remoteBaseDir!!), localBaseDir!!)
|
||||
val schemesManager = SchemeManagerImpl<TestScheme, TestScheme>(FILE_SPEC, TestSchemesProcessor(), MockStreamProvider(remoteBaseDir!!.toFile()), localBaseDir!!)
|
||||
schemesManager.loadSchemes()
|
||||
return schemesManager
|
||||
}
|
||||
|
||||
private fun createTempFiles(testData: String) {
|
||||
val temp = tempDirManager.newDirectory()
|
||||
localBaseDir = File(temp, "__local")
|
||||
val temp = tempDirManager.newPath()
|
||||
localBaseDir = temp.resolve("__local")
|
||||
remoteBaseDir = temp
|
||||
FileUtil.copyDir(File("${getTestDataPath()}/$testData"), File(temp, "REMOTE"))
|
||||
FileUtil.copyDir(File("${getTestDataPath()}/$testData"), temp.resolve("REMOTE").toFile())
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkSchemes(baseDir: File, expected: String, ignoreDeleted: Boolean) {
|
||||
private fun checkSchemes(baseDir: Path, expected: String, ignoreDeleted: Boolean) {
|
||||
val filesToScheme = StringUtil.split(expected, ";")
|
||||
val fileToSchemeMap = THashMap<String, String>()
|
||||
for (fileToScheme in filesToScheme) {
|
||||
@@ -345,10 +345,9 @@ private fun checkSchemes(baseDir: File, expected: String, ignoreDeleted: Boolean
|
||||
fileToSchemeMap.put(fileToScheme.substring(0, index), fileToScheme.substring(index + 2))
|
||||
}
|
||||
|
||||
val files = baseDir.listFiles()
|
||||
if (files != null) {
|
||||
for (file in files) {
|
||||
val fileName = FileUtil.getNameWithoutExtension(file)
|
||||
baseDir.directoryStreamIfExists {
|
||||
for (file in it) {
|
||||
val fileName = FileUtil.getNameWithoutExtension(file.fileName.toString())
|
||||
if ("--deleted" == fileName && ignoreDeleted) {
|
||||
assertThat(fileToSchemeMap).containsKey(fileName)
|
||||
}
|
||||
@@ -356,14 +355,14 @@ private fun checkSchemes(baseDir: File, expected: String, ignoreDeleted: Boolean
|
||||
}
|
||||
|
||||
for (file in fileToSchemeMap.keys) {
|
||||
assertThat(File(baseDir, "$file.xml")).isFile()
|
||||
assertThat(baseDir.resolve("$file.xml")).isRegularFile()
|
||||
}
|
||||
|
||||
if (files != null) {
|
||||
baseDir.directoryStreamIfExists {
|
||||
val schemesProcessor = TestSchemesProcessor()
|
||||
for (file in files) {
|
||||
val scheme = schemesProcessor.readScheme(JDOMUtil.load(file), true)!!
|
||||
assertThat(fileToSchemeMap.get(FileUtil.getNameWithoutExtension(file))).isEqualTo(scheme.name)
|
||||
for (file in it) {
|
||||
val scheme = schemesProcessor.readScheme(loadElement(file), true)!!
|
||||
assertThat(fileToSchemeMap.get(FileUtil.getNameWithoutExtension(file.fileName.toString()))).isEqualTo(scheme.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ public class PluginManagerCore {
|
||||
int i = 0;
|
||||
for (URL url : urls) {
|
||||
IdeaPluginDescriptorImpl descriptor = loadDescriptorFromResource(url);
|
||||
if (descriptor != null) {
|
||||
if (descriptor != null && !result.contains(descriptor)) {
|
||||
descriptor.setUseCoreClassLoader(true);
|
||||
result.add(descriptor);
|
||||
if (progress != null && !SPECIAL_IDEA_PLUGIN.equals(descriptor.getName())) {
|
||||
|
||||
@@ -217,7 +217,7 @@ public class DocumentCommitThread extends DocumentCommitProcessor implements Run
|
||||
|
||||
@Override
|
||||
public void log(Project project, @NonNls String msg, @Nullable CommitTask task, @NonNls Object... args) {
|
||||
//if (true) return;
|
||||
if (true) return;
|
||||
|
||||
String indent = new SimpleDateFormat("hh:mm:ss:SSSS").format(new Date()) +
|
||||
(SwingUtilities.isEventDispatchThread() ? "-(EDT) " :
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -505,6 +506,16 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
}
|
||||
actions.add(action);
|
||||
myDocumentCommitProcessor.log(myProject, "PDI: added performWhenAllCommitted", null, action);
|
||||
|
||||
ModalityState current = ModalityState.current();
|
||||
if (current != ModalityState.NON_MODAL) {
|
||||
// re-add all uncommitted documents into the queue with this new modality
|
||||
// because this client obviously expects them to commit even inside modal dialog
|
||||
for (Document document : myUncommittedDocuments) {
|
||||
myDocumentCommitProcessor.commitAsynchronously(myProject, document,
|
||||
"re-added with modality "+current+" because performWhenAllCommitted("+current+") was called", current);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.intellij.diff.chains;
|
||||
|
||||
public class DiffRequestProducerException extends Exception {
|
||||
public DiffRequestProducerException(Throwable cause) {
|
||||
super(cause);
|
||||
super(cause.getMessage(), cause);
|
||||
}
|
||||
|
||||
public DiffRequestProducerException(String message, Throwable cause) {
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.diff.requests;
|
||||
|
||||
import com.intellij.diff.DiffContext;
|
||||
import com.intellij.diff.DiffContextEx;
|
||||
import com.intellij.diff.util.DiffUtil;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.fileTypes.UnknownFileType;
|
||||
@@ -28,11 +27,14 @@ import com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class UnknownFileTypeDiffRequest extends ComponentDiffRequest {
|
||||
@Nullable private final String myFileName;
|
||||
@@ -52,6 +54,7 @@ public class UnknownFileTypeDiffRequest extends ComponentDiffRequest {
|
||||
@Override
|
||||
public JComponent getComponent(@NotNull final DiffContext context) {
|
||||
final SimpleColoredComponent label = new SimpleColoredComponent();
|
||||
label.setTextAlign(SwingConstants.CENTER);
|
||||
label.append("Can't show diff for unknown file type. ",
|
||||
new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getInactiveTextColor()));
|
||||
if (myFileName != null) {
|
||||
@@ -69,7 +72,7 @@ public class UnknownFileTypeDiffRequest extends ComponentDiffRequest {
|
||||
});
|
||||
LinkMouseListenerBase.installSingleTagOn(label);
|
||||
}
|
||||
return DiffUtil.createMessagePanel(label);
|
||||
return JBUI.Panels.simplePanel(label).withBorder(JBUI.Borders.empty(5));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -84,7 +84,7 @@ import com.intellij.util.DocumentUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.LineSeparator;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.GridBag;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.*;
|
||||
@@ -284,24 +284,21 @@ public class DiffUtil {
|
||||
|
||||
@NotNull
|
||||
public static JPanel createMessagePanel(@NotNull String message) {
|
||||
Pair<JPanel, JLabel> pair = createMessagePanel();
|
||||
pair.getSecond().setText(message);
|
||||
return pair.getFirst();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Pair<JPanel, JLabel> createMessagePanel() {
|
||||
JLabel label = new JLabel();
|
||||
String text = StringUtil.replace(message, "\n", "<br>");
|
||||
JLabel label = new JBLabel(text) {
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
Dimension size = super.getMinimumSize();
|
||||
size.width = Math.min(size.width, 200);
|
||||
size.height = Math.min(size.height, 100);
|
||||
return size;
|
||||
}
|
||||
}.setCopyable(true);
|
||||
label.setForeground(UIUtil.getInactiveTextColor());
|
||||
JPanel wrapper = createMessagePanel(label);
|
||||
return Pair.create(wrapper, label);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JPanel createMessagePanel(@NotNull JComponent comp) {
|
||||
JPanel wrapper = new JPanel(new GridBagLayout());
|
||||
wrapper.add(comp, new GridBag().insets(JBUI.insets(1)));
|
||||
return wrapper;
|
||||
JPanel panel = new CenteredPanel(label);
|
||||
panel.setBorder(JBUI.Borders.empty(5));
|
||||
return panel;
|
||||
}
|
||||
|
||||
public static void addActionBlock(@NotNull DefaultActionGroup group, AnAction... actions) {
|
||||
@@ -1289,4 +1286,49 @@ public class DiffUtil {
|
||||
return height;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CenteredPanel extends JPanel {
|
||||
private final JComponent myComponent;
|
||||
|
||||
public CenteredPanel(@NotNull JComponent component) {
|
||||
myComponent = component;
|
||||
add(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLayout() {
|
||||
final Dimension size = getSize();
|
||||
final Dimension preferredSize = myComponent.getPreferredSize();
|
||||
|
||||
Insets insets = getInsets();
|
||||
JBInsets.removeFrom(size, insets);
|
||||
|
||||
int width = Math.min(size.width, preferredSize.width);
|
||||
int height = Math.min(size.height, preferredSize.height);
|
||||
int x = Math.max(0, (size.width - preferredSize.width) / 2);
|
||||
int y = Math.max(0, (size.height - preferredSize.height) / 2);
|
||||
|
||||
myComponent.setBounds(insets.left + x, insets.top + y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return addInsets(myComponent.getPreferredSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return addInsets(myComponent.getMinimumSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return addInsets(myComponent.getMaximumSize());
|
||||
}
|
||||
|
||||
private Dimension addInsets(Dimension dimension) {
|
||||
JBInsets.addTo(dimension, getInsets());
|
||||
return dimension;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,5 +58,5 @@ public interface ExternalSystemExecutionConsoleManager<
|
||||
|
||||
boolean isApplicableFor(@NotNull ExternalSystemTask task);
|
||||
|
||||
AnAction[] getRestartActions();
|
||||
AnAction[] getRestartActions(@NotNull ExternalSystemExecutionConsole consoleView);
|
||||
}
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ package com.intellij.openapi.externalSystem.model.project;
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -58,7 +57,7 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
@NotNull String internalName,
|
||||
@NotNull String moduleFileDirectoryPath,
|
||||
@NotNull String externalConfigPath) {
|
||||
super(owner, externalName, FileUtil.sanitizeFileName(internalName));
|
||||
super(owner, externalName, internalName);
|
||||
myId = id;
|
||||
myModuleTypeId = typeId;
|
||||
myExternalConfigPath = externalConfigPath;
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class DefaultExternalSystemExecutionConsoleManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnAction[] getRestartActions() {
|
||||
public AnAction[] getRestartActions(@NotNull ExecutionConsole consoleView) {
|
||||
return new AnAction[0];
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunConfiguration clone() {
|
||||
public ExternalSystemRunConfiguration clone() {
|
||||
ExternalSystemRunConfiguration result = (ExternalSystemRunConfiguration)super.clone();
|
||||
result.mySettings = mySettings.clone();
|
||||
return result;
|
||||
@@ -234,7 +234,7 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
|
||||
}
|
||||
});
|
||||
DefaultExecutionResult result = new DefaultExecutionResult(consoleView, processHandler);
|
||||
result.setRestartActions(consoleManager.getRestartActions());
|
||||
result.setRestartActions(consoleManager.getRestartActions(consoleView));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 582 B |
@@ -16,7 +16,7 @@
|
||||
package com.intellij.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.wizard.AbstractWizard;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
@@ -53,6 +53,7 @@ public class WizardContext extends UserDataHolderBase {
|
||||
private boolean myNewWizard;
|
||||
private ModulesProvider myModulesProvider;
|
||||
private boolean myProjectFileDirectorySetExplicitly;
|
||||
private AbstractWizard myWizard;
|
||||
|
||||
public void setProjectStorageFormat(StorageScheme format) {
|
||||
myProjectStorageFormat = format;
|
||||
@@ -78,6 +79,14 @@ public class WizardContext extends UserDataHolderBase {
|
||||
return myDisposable;
|
||||
}
|
||||
|
||||
public AbstractWizard getWizard() {
|
||||
return myWizard;
|
||||
}
|
||||
|
||||
public void setWizard(AbstractWizard wizard) {
|
||||
myWizard = wizard;
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void buttonsUpdateRequested();
|
||||
void nextStepRequested();
|
||||
@@ -109,10 +118,10 @@ public class WizardContext extends UserDataHolderBase {
|
||||
if (myProjectFileDirectory != null) {
|
||||
return myProjectFileDirectory;
|
||||
}
|
||||
final String lastProjectLocation = RecentProjectsManager.getInstance().getLastProjectCreationLocation();
|
||||
if (lastProjectLocation != null) {
|
||||
return lastProjectLocation.replace('/', File.separatorChar);
|
||||
}
|
||||
//final String lastProjectLocation = RecentProjectsManager.getInstance().getLastProjectCreationLocation();
|
||||
//if (lastProjectLocation != null) {
|
||||
// return lastProjectLocation.replace('/', File.separatorChar);
|
||||
//}
|
||||
final String userHome = SystemProperties.getUserHome();
|
||||
//noinspection HardCodedStringLiteral
|
||||
String productName = ApplicationNamesInfo.getInstance().getLowercaseProductName();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -27,7 +27,7 @@ public interface UpdateParameterInfoContext extends ParameterInfoContext {
|
||||
void setHighlightedParameter(final Object parameter);
|
||||
void setCurrentParameter(final int index);
|
||||
boolean isUIComponentEnabled(int index);
|
||||
void setUIComponentEnabled(int index, boolean b);
|
||||
void setUIComponentEnabled(int index, boolean enabled);
|
||||
|
||||
int getParameterListStart();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface FileDownloader {
|
||||
* @param targetDirectoryPath target directory for downloaded files. If {@code null} a file chooser will be shown to select target directory
|
||||
* @param project project instance used to show the progress window
|
||||
* @param parentComponent parent component for the progress window
|
||||
* @return list of downloaded files of {@code null} if the downloading process was failed or cancelled
|
||||
* @return list of downloaded files or {@code null} if the downloading process was failed or cancelled
|
||||
*/
|
||||
@Nullable
|
||||
List<VirtualFile> downloadFilesWithProgress(@Nullable String targetDirectoryPath, @Nullable Project project, @Nullable JComponent parentComponent);
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class GutterIconsConfigurable implements Configurable, Configurable.NoScr
|
||||
@Nullable
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return null;
|
||||
return "reference.settings.editor.gutter.icons";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package com.intellij.codeInsight.editorActions.fillParagraph;
|
||||
import com.intellij.codeInsight.CodeInsightActionHandler;
|
||||
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -16,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*
|
||||
* The action came from Emacs users // PY-4775
|
||||
*/
|
||||
public class FillParagraphAction extends BaseCodeInsightAction {
|
||||
public class FillParagraphAction extends BaseCodeInsightAction implements DumbAware {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -413,8 +413,8 @@ public class ParameterInfoController implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUIComponentEnabled(int index, boolean b) {
|
||||
myComponent.setEnabled(index, b);
|
||||
public void setUIComponentEnabled(int index, boolean enabled) {
|
||||
myComponent.setEnabled(index, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-3
@@ -33,11 +33,12 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.extensions.ExtensionException;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
@@ -136,8 +137,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code
|
||||
|
||||
private static void gotoTargetElement(@NotNull PsiElement element, @NotNull Editor currentEditor, @NotNull PsiFile currentFile) {
|
||||
if (element.getContainingFile() == currentFile) {
|
||||
currentEditor.getCaretModel().moveToOffset(element.getTextOffset());
|
||||
currentEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
|
||||
Project project = element.getProject();
|
||||
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
|
||||
new OpenFileDescriptor(project, currentFile.getViewProvider().getVirtualFile(), element.getTextOffset()).navigateIn(currentEditor);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,17 @@ public class TestStateStorage implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removeState(String url) {
|
||||
if (myMap != null) {
|
||||
try {
|
||||
myMap.remove(url);
|
||||
}
|
||||
catch (IOException e) {
|
||||
thingsWentWrongLetsReinitialize(e, "Can't remove state for " + url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public synchronized Map<String, Record> getRecentTests(int limit, Date since) {
|
||||
if (myMap == null) return null;
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.ide.navigationToolbar.ui;
|
||||
|
||||
import com.intellij.ide.navigationToolbar.NavBarItem;
|
||||
import com.intellij.ide.navigationToolbar.NavBarPanel;
|
||||
import com.intellij.ide.navigationToolbar.NavBarRootPaneExtension;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
@@ -290,15 +289,15 @@ public abstract class AbstractNavBarUI implements NavBarUI {
|
||||
|
||||
@Override
|
||||
public Insets getWrapperPanelInsets(Insets insets) {
|
||||
//final JBInsets result = JBUI.insets(insets);
|
||||
//if (shouldPaintWrapperPanel()) {
|
||||
// result.top += JBUI.scale(1);
|
||||
//}
|
||||
return insets;
|
||||
final JBInsets result = JBUI.insets(insets);
|
||||
if (shouldPaintWrapperPanel()) {
|
||||
result.top += JBUI.scale(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean shouldPaintWrapperPanel() {
|
||||
return !UISettings.getInstance().SHOW_MAIN_TOOLBAR && NavBarRootPaneExtension.runToolbarExists();
|
||||
return false; //return !UISettings.getInstance().SHOW_MAIN_TOOLBAR && NavBarRootPaneExtension.runToolbarExists();
|
||||
}
|
||||
|
||||
protected Color getBackgroundColor() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -17,9 +17,6 @@ package com.intellij.internal.psiView;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
@@ -33,36 +30,28 @@ import com.intellij.openapi.project.Project;
|
||||
public class PsiViewerAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
|
||||
new PsiViewerDialog(project, false, null, null).show();
|
||||
new PsiViewerDialog(e.getProject(), false, null, null).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
|
||||
final Presentation p = e.getPresentation();
|
||||
if (project == null) {
|
||||
p.setVisible(false);
|
||||
p.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
boolean enabled = false;
|
||||
|
||||
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
|
||||
p.setVisible(true);
|
||||
p.setEnabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
for (Module module : modules) {
|
||||
if ("PLUGIN_MODULE".equals(ModuleType.get(module).getId())) {
|
||||
p.setVisible(true);
|
||||
p.setEnabled(true);
|
||||
return;
|
||||
Project project = e.getProject();
|
||||
if (project != null) {
|
||||
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
|
||||
enabled = true;
|
||||
}
|
||||
else {
|
||||
for (Module module : ModuleManager.getInstance(project).getModules()) {
|
||||
if ("PLUGIN_MODULE".equals(ModuleType.get(module).getId())) {
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.setVisible(false);
|
||||
p.setEnabled(false);
|
||||
|
||||
e.getPresentation().setEnabledAndVisible(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -18,36 +18,24 @@ package com.intellij.internal.psiView;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Nadya.Zabrodina
|
||||
* Date: 7/4/11
|
||||
* Time: 4:16 PM
|
||||
* @author Nadya.Zabrodina
|
||||
*/
|
||||
public class PsiViewerForContextAction extends AnAction implements DumbAware {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
|
||||
Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
|
||||
PsiFile currentFile = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
|
||||
new PsiViewerDialog(currentFile.getProject(), false, currentFile, editor).show();
|
||||
DataContext ctx = e.getDataContext();
|
||||
new PsiViewerDialog(e.getProject(), false, CommonDataKeys.PSI_FILE.getData(ctx), CommonDataKeys.EDITOR.getData(ctx)).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
if (!ApplicationManagerEx.getApplicationEx().isInternal()) {
|
||||
e.getPresentation().setVisible(false);
|
||||
e.getPresentation().setEnabled(false);
|
||||
return;
|
||||
}
|
||||
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
|
||||
PsiFile currentFile = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
|
||||
e.getPresentation().setEnabled(project != null && currentFile != null);
|
||||
boolean enabled = ApplicationManagerEx.getApplicationEx().isInternal() && e.getProject() != null;
|
||||
e.getPresentation().setEnabled(enabled);
|
||||
e.getPresentation().setVisible(enabled && CommonDataKeys.PSI_FILE.getData(e.getDataContext()) != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,10 @@ import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
|
||||
@State(
|
||||
name = "DependencyUISettings",
|
||||
storages = @Storage("other.xml")
|
||||
storages = {
|
||||
@Storage("ui.lnf.xml"),
|
||||
@Storage(value = "other.xml", deprecated = true)
|
||||
}
|
||||
)
|
||||
public class DependencyUISettings implements PersistentStateComponent<DependencyUISettings> {
|
||||
public boolean UI_FLATTEN_PACKAGES = true;
|
||||
|
||||
+15
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -26,6 +26,7 @@ import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.FilteringProcessor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -76,17 +77,23 @@ public class FileReferenceCompletionImpl extends FileReferenceCompletion {
|
||||
FileReference.getOriginalFile(fileSystemItem));
|
||||
}
|
||||
};
|
||||
|
||||
List<Object> additionalItems = ContainerUtil.newArrayList();
|
||||
for (PsiFileSystemItem context : reference.getContexts()) {
|
||||
for (final PsiElement child : context.getChildren()) {
|
||||
if (child instanceof PsiFileSystemItem) {
|
||||
processor.execute((PsiFileSystemItem)child);
|
||||
}
|
||||
}
|
||||
if (context instanceof FileReferenceResolver) {
|
||||
additionalItems.addAll(((FileReferenceResolver)context).getVariants(reference));
|
||||
}
|
||||
}
|
||||
|
||||
final THashSet<PsiElement> set = new THashSet<PsiElement>(collector.getResults(), VARIANTS_HASHING_STRATEGY);
|
||||
final PsiElement[] candidates = PsiUtilCore.toPsiElementArray(set);
|
||||
|
||||
final Object[] variants = new Object[candidates.length];
|
||||
final Object[] variants = new Object[candidates.length + additionalItems.size()];
|
||||
for (int i = 0; i < candidates.length; i++) {
|
||||
PsiElement candidate = candidates[i];
|
||||
Object item = reference.createLookupItem(candidate);
|
||||
@@ -95,10 +102,14 @@ public class FileReferenceCompletionImpl extends FileReferenceCompletion {
|
||||
}
|
||||
variants[i] = item;
|
||||
}
|
||||
|
||||
for (int i = 0; i < additionalItems.size(); i++) {
|
||||
variants[i + candidates.length] = additionalItems.get(i);
|
||||
}
|
||||
if (!reference.getFileReferenceSet().isUrlEncoded()) {
|
||||
return variants;
|
||||
}
|
||||
List<Object> encodedVariants = new ArrayList<Object>(variants.length);
|
||||
List<Object> encodedVariants = new ArrayList<Object>(variants.length + additionalItems.size());
|
||||
for (int i = 0; i < candidates.length; i++) {
|
||||
final PsiElement element = candidates[i];
|
||||
if (element instanceof PsiNamedElement) {
|
||||
@@ -116,6 +127,7 @@ public class FileReferenceCompletionImpl extends FileReferenceCompletion {
|
||||
}
|
||||
}
|
||||
}
|
||||
encodedVariants.addAll(additionalItems);
|
||||
return ArrayUtil.toObjectArray(encodedVariants);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package com.intellij.refactoring.invertBoolean;
|
||||
|
||||
import com.intellij.lang.LanguageNamesValidation;
|
||||
import com.intellij.lang.findUsages.DescriptiveNameUtil;
|
||||
import com.intellij.lang.refactoring.NamesValidator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -61,7 +63,8 @@ public class InvertBooleanDialog extends RefactoringDialog {
|
||||
protected void doAction() {
|
||||
Project project = myElement.getProject();
|
||||
final String name = myNameField.getText().trim();
|
||||
if (name.length() == 0) {
|
||||
final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(myElement.getLanguage());
|
||||
if (namesValidator != null && !namesValidator.isIdentifier(name, myProject)) {
|
||||
CommonRefactoringUtil.showErrorMessage(InvertBooleanHandler.REFACTORING_NAME,
|
||||
RefactoringBundle.message("please.enter.a.valid.name.for.inverted.element",
|
||||
UsageViewUtil.getType(myElement)),
|
||||
|
||||
+3
-2
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.refactoring.rename.PsiElementRenameHandler;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -47,7 +48,7 @@ public class InvertBooleanHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
final PsiElement namedElement = delegate.adjustElement(element, project, editor);
|
||||
if (namedElement != null) {
|
||||
if (namedElement != null && PsiElementRenameHandler.canRename(project, editor, namedElement)) {
|
||||
new InvertBooleanDialog(namedElement).show();
|
||||
}
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public class InvertBooleanHandler implements RefactoringActionHandler {
|
||||
return;
|
||||
}
|
||||
PsiElement element = delegate.adjustElement(elements[0], project, null);
|
||||
if (element != null) {
|
||||
if (element != null && PsiElementRenameHandler.canRename(project, null, element)) {
|
||||
new InvertBooleanDialog(element).show();
|
||||
}
|
||||
}
|
||||
|
||||
+21
-3
@@ -23,6 +23,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor;
|
||||
import com.intellij.refactoring.rename.RenameProcessor;
|
||||
import com.intellij.refactoring.rename.RenameUtil;
|
||||
import com.intellij.refactoring.ui.ConflictsDialog;
|
||||
import com.intellij.refactoring.util.MoveRenameUsageInfo;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewDescriptor;
|
||||
@@ -30,6 +31,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -54,8 +56,25 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
myElement = namedElement;
|
||||
myNewName = newName;
|
||||
final Project project = namedElement.getProject();
|
||||
myRenameProcessor = !(namedElement instanceof PsiNamedElement) || Comparing.equal(((PsiNamedElement)namedElement).getName(), myNewName)
|
||||
? null : new RenameProcessor(project, namedElement, newName, false, false);
|
||||
final boolean canRename =
|
||||
namedElement instanceof PsiNamedElement && !Comparing.equal(((PsiNamedElement)namedElement).getName(), myNewName);
|
||||
myRenameProcessor = canRename ? new RenameProcessor(project, namedElement, newName, false, false) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected ConflictsDialog createConflictsDialog(@NotNull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) {
|
||||
return new ConflictsDialog(myProject, conflicts, usages == null ? null : new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InvertBooleanProcessor.this.execute(usages);
|
||||
}
|
||||
}, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareSuccessful() {
|
||||
InvertBooleanProcessor.this.prepareSuccessful();
|
||||
}
|
||||
} : null;
|
||||
mySmartPointerManager = SmartPointerManager.getInstance(project);
|
||||
myDelegate = InvertBooleanDelegate.findInvertBooleanDelegate(myElement);
|
||||
LOG.assertTrue(myDelegate != null);
|
||||
@@ -139,7 +158,6 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
return extractedUsages.toArray(new UsageInfo[extractedUsages.size()]);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void performRefactoring(@NotNull UsageInfo[] usages) {
|
||||
if (myRenameProcessor != null) {
|
||||
|
||||
@@ -119,7 +119,7 @@ public class PsiElementRenameHandler implements RenameHandler {
|
||||
rename(element, project, nameSuggestionContext, editor);
|
||||
}
|
||||
|
||||
static boolean canRename(Project project, Editor editor, PsiElement element) throws CommonRefactoringUtil.RefactoringErrorHintException {
|
||||
public static boolean canRename(Project project, Editor editor, PsiElement element) throws CommonRefactoringUtil.RefactoringErrorHintException {
|
||||
String message = renameabilityStatus(project, element);
|
||||
if (StringUtil.isNotEmpty(message)) {
|
||||
showErrorMessage(project, editor, message);
|
||||
|
||||
@@ -473,7 +473,12 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
}
|
||||
|
||||
protected void updateButtons() {
|
||||
if (isLastStep()) {
|
||||
boolean lastStep = isLastStep();
|
||||
updateButtons(lastStep, lastStep ? canFinish() : canGoNext(), isFirstStep());
|
||||
}
|
||||
|
||||
public void updateButtons(boolean lastStep, boolean canGoNext, boolean firstStep) {
|
||||
if (lastStep) {
|
||||
if (mySteps.size() > 1) {
|
||||
myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.finish")));
|
||||
myNextButton.setMnemonic('F');
|
||||
@@ -481,19 +486,23 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
|
||||
else {
|
||||
myNextButton.setText(IdeBundle.message("button.ok"));
|
||||
}
|
||||
myNextButton.setEnabled(canFinish());
|
||||
myNextButton.setEnabled(canGoNext);
|
||||
}
|
||||
else {
|
||||
myNextButton.setText(UIUtil.removeMnemonic(IdeBundle.message("button.wizard.next")));
|
||||
myNextButton.setMnemonic('N');
|
||||
myNextButton.setEnabled(canGoNext());
|
||||
myNextButton.setEnabled(canGoNext);
|
||||
}
|
||||
|
||||
if (myNextButton.isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
getRootPane().setDefaultButton(myNextButton);
|
||||
}
|
||||
|
||||
myPreviousButton.setEnabled(myCurrentStep > 0);
|
||||
myPreviousButton.setEnabled(!firstStep);
|
||||
}
|
||||
|
||||
protected boolean isFirstStep() {
|
||||
return myCurrentStep == 0;
|
||||
}
|
||||
|
||||
protected boolean isLastStep() {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.openapi.util.*;
|
||||
@@ -710,7 +711,7 @@ public abstract class DialogWrapper {
|
||||
final char mnemonic = (char)eachInfo.getMnemonic();
|
||||
JRootPane rootPane = getPeer().getRootPane();
|
||||
if (rootPane != null) {
|
||||
new AnAction() {
|
||||
new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final JBOptionButton buttonToActivate = eachInfo.getButton();
|
||||
@@ -1250,7 +1251,7 @@ public abstract class DialogWrapper {
|
||||
myPeer.setContentPane(root);
|
||||
|
||||
final CustomShortcutSet sc = new CustomShortcutSet(SHOW_OPTION_KEYSTROKE);
|
||||
final AnAction toggleShowOptions = new AnAction() {
|
||||
final AnAction toggleShowOptions = new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
expandNextOptionButton();
|
||||
@@ -1306,7 +1307,7 @@ public abstract class DialogWrapper {
|
||||
}
|
||||
|
||||
private static void installEnterHook(JComponent root, Disposable disposable) {
|
||||
new AnAction() {
|
||||
new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ScreenUtil {
|
||||
public static final String DISPOSE_TEMPORARY = "dispose.temporary";
|
||||
|
||||
@Nullable private static final Map<GraphicsConfiguration, Pair<Insets, Long>> ourInsetsCache =
|
||||
Patches.JDK_BUG_ID_8004103 ? new WeakHashMap<GraphicsConfiguration, Pair<Insets, Long>>() : null;
|
||||
Patches.isJdkBugId8004103() ? new WeakHashMap<GraphicsConfiguration, Pair<Insets, Long>>() : null;
|
||||
private static final int ourInsetsTimeout = 5000; // shouldn't be too long
|
||||
|
||||
private ScreenUtil() { }
|
||||
|
||||
@@ -149,7 +149,9 @@ public class JBScrollPane extends JScrollPane {
|
||||
}
|
||||
|
||||
private void updateViewportBorder() {
|
||||
setViewportBorder(new ViewportBorder(myViewportBorderWidth >= 0 ? myViewportBorderWidth : 1));
|
||||
if (getViewportBorder() instanceof ViewportBorder) {
|
||||
setViewportBorder(new ViewportBorder(myViewportBorderWidth >= 0 ? myViewportBorderWidth : 1));
|
||||
}
|
||||
}
|
||||
|
||||
public static ViewportBorder createIndentBorder() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.diagnostic.OutOfMemoryDialog">
|
||||
<grid id="cbd77" binding="myContentPane" layout-manager="GridLayoutManager" row-count="6" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="cbd77" binding="myContentPane" layout-manager="GridLayoutManager" row-count="7" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="22" y="17" width="405" height="297"/>
|
||||
@@ -10,7 +10,7 @@
|
||||
<children>
|
||||
<component id="c9355" class="com.intellij.ui.components.JBLabel" binding="myIconLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="6" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="7" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
@@ -139,9 +139,18 @@
|
||||
<text value="Label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3a803" class="com.intellij.ui.components.JBLabel" binding="myDumpMessageLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="5" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Label"/>
|
||||
<visible value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="1bbcf">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="5" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<grid row="6" column="1" row-span="1" col-span="5" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="51" height="14"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -18,11 +18,15 @@ package com.intellij.diagnostic;
|
||||
import com.intellij.diagnostic.VMOptions.MemoryKind;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.idea.Main;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.MemoryDumpHelper;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.TimeoutUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -48,8 +52,10 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
private JBLabel myCodeCacheUnitsLabel;
|
||||
private JBLabel myCodeCacheCurrentValueLabel;
|
||||
private JBLabel mySettingsFileHintLabel;
|
||||
private JBLabel myDumpMessageLabel;
|
||||
private final Action myContinueAction;
|
||||
private final Action myShutdownAction;
|
||||
private final Action myHeapDumpAction;
|
||||
|
||||
public OutOfMemoryDialog(@NotNull MemoryKind memoryKind) {
|
||||
super(false);
|
||||
@@ -89,6 +95,14 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
};
|
||||
myShutdownAction.putValue(DialogWrapper.DEFAULT_ACTION, true);
|
||||
|
||||
boolean heapDump = memoryKind == MemoryKind.HEAP && MemoryDumpHelper.memoryDumpAvailable();
|
||||
myHeapDumpAction = !heapDump ? null : new DialogWrapperAction(DiagnosticBundle.message("diagnostic.out.of.memory.dump")) {
|
||||
@Override
|
||||
protected void doAction(ActionEvent e) {
|
||||
snapshot();
|
||||
}
|
||||
};
|
||||
|
||||
configControls(MemoryKind.HEAP, myHeapSizeLabel, myHeapSizeField, myHeapUnitsLabel, myHeapCurrentValueLabel);
|
||||
configControls(MemoryKind.PERM_GEN, myPermGenSizeLabel, myPermGenSizeField, myPermGenUnitsLabel, myPermGenCurrentValueLabel);
|
||||
configControls(MemoryKind.CODE_CACHE, myCodeCacheSizeLabel, myCodeCacheSizeField, myCodeCacheUnitsLabel, myCodeCacheCurrentValueLabel);
|
||||
@@ -137,6 +151,51 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
catch (NumberFormatException ignored) { }
|
||||
}
|
||||
|
||||
@SuppressWarnings("SSBasedInspection")
|
||||
private void snapshot() {
|
||||
enableControls(false);
|
||||
myDumpMessageLabel.setVisible(true);
|
||||
myDumpMessageLabel.setText("Dumping memory...");
|
||||
|
||||
Runnable task = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TimeoutUtil.sleep(250); // to give UI chance to update
|
||||
String message = "";
|
||||
try {
|
||||
String name = ApplicationNamesInfo.getInstance().getLowercaseProductName();
|
||||
String path = SystemProperties.getUserHome() + File.separator + "heapDump-" + name + '-' + System.currentTimeMillis() + ".hprof";
|
||||
MemoryDumpHelper.captureMemoryDump(path);
|
||||
message = "Dumped to " + path;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
message = "Error: " + t.getMessage();
|
||||
}
|
||||
finally {
|
||||
final String _message = message;
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myDumpMessageLabel.setText(_message);
|
||||
enableControls(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
new Thread(task, "OOME Heap Dump").start();
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void enableControls(boolean enabled) {
|
||||
myHeapSizeField.setEnabled(enabled);
|
||||
myPermGenSizeField.setEnabled(enabled);
|
||||
myCodeCacheSizeField.setEnabled(enabled);
|
||||
myShutdownAction.setEnabled(enabled);
|
||||
myContinueAction.setEnabled(enabled);
|
||||
myHeapDumpAction.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return myContentPane;
|
||||
@@ -145,7 +204,8 @@ public class OutOfMemoryDialog extends DialogWrapper {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Action[] createActions() {
|
||||
return new Action[]{myShutdownAction, myContinueAction};
|
||||
return myHeapDumpAction != null ? new Action[]{myShutdownAction, myContinueAction, myHeapDumpAction}
|
||||
: new Action[]{myShutdownAction, myContinueAction};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -15,17 +15,18 @@
|
||||
*/
|
||||
package com.intellij.internal;
|
||||
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.SingleAlarm;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
@@ -33,11 +34,11 @@ import java.lang.management.ManagementFactory;
|
||||
public class DebugAttachDetector {
|
||||
private static final Logger LOG = Logger.getInstance(DebugAttachDetector.class);
|
||||
|
||||
private String myHost = null;
|
||||
private String myHost;
|
||||
private int myPort = -1;
|
||||
private SingleAlarm myAlarm;
|
||||
private ScheduledFuture<?> myTask;
|
||||
private boolean myAttached;
|
||||
private boolean myReady = false;
|
||||
private boolean myReady;
|
||||
|
||||
public DebugAttachDetector() {
|
||||
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
@@ -74,24 +75,22 @@ public class DebugAttachDetector {
|
||||
|
||||
if (myPort < 0) return;
|
||||
|
||||
myAlarm = new SingleAlarm(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean attached = !NetUtils.canConnectToRemoteSocket(myHost, myPort);
|
||||
if (!myReady) {
|
||||
myAttached = attached;
|
||||
myReady = true;
|
||||
myTask = JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean attached = !NetUtils.canConnectToRemoteSocket(myHost, myPort);
|
||||
if (!myReady) {
|
||||
myAttached = attached;
|
||||
myReady = true;
|
||||
}
|
||||
else if (attached != myAttached) {
|
||||
myAttached = attached;
|
||||
Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
|
||||
"Remote debugger",
|
||||
myAttached ? "attached" : "detached",
|
||||
NotificationType.WARNING));
|
||||
}
|
||||
}
|
||||
else if (attached != myAttached) {
|
||||
myAttached = attached;
|
||||
Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
|
||||
"Remote debugger",
|
||||
myAttached ? "attached" : "detached",
|
||||
NotificationType.WARNING));
|
||||
}
|
||||
myAlarm.request();
|
||||
}
|
||||
}, 5000, Alarm.ThreadToUse.POOLED_THREAD, app);
|
||||
myAlarm.request();
|
||||
}, 5, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -333,8 +333,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
if (text.getCaret() != null) {
|
||||
text.setCaretPosition(0);
|
||||
}
|
||||
JScrollPane pane = new JScrollPane(text); // do not add 1px border for viewport on UI update
|
||||
pane.setBorder(BorderFactory.createEmptyBorder());
|
||||
JScrollPane pane = ScrollPaneFactory.createScrollPane(text, true); // do not add 1px border for viewport on UI update
|
||||
pane.setOpaque(false);
|
||||
pane.getViewport().setOpaque(false);
|
||||
content.add(pane, BorderLayout.CENTER);
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class EditorComponentImpl extends JTextComponent implements Scrollable, D
|
||||
@Override
|
||||
public void paint(@NotNull Graphics g) {
|
||||
if (!isEnabled()) {
|
||||
g = new Grayer((Graphics2D)g, EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
|
||||
g = new Grayer((Graphics2D)g, getBackground());
|
||||
}
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ public class FileStatusManagerImpl extends FileStatusManager implements ProjectC
|
||||
DocumentAdapter documentListener = new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent event) {
|
||||
if (event.getOldLength() == 0 && event.getNewLength() == 0) return;
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(event.getDocument());
|
||||
if (file != null) {
|
||||
refreshFileStatusFromDocument(file, event.getDocument());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -17,12 +17,14 @@ package com.intellij.remote;
|
||||
|
||||
import com.intellij.execution.CommandLineUtil;
|
||||
import com.intellij.execution.TaskExecutor;
|
||||
import com.intellij.execution.process.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessOutputTypes;
|
||||
import com.intellij.execution.process.ProcessWaitFor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.io.BaseOutputReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -181,14 +183,9 @@ public class BaseRemoteProcessHandler<T extends RemoteProcess> extends AbstractR
|
||||
return myCharset;
|
||||
}
|
||||
|
||||
protected static Future<?> executeOnPooledThread(Runnable task) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
|
||||
if (application != null) {
|
||||
return application.executeOnPooledThread(task);
|
||||
}
|
||||
|
||||
return BaseOSProcessHandler.submit(task);
|
||||
@NotNull
|
||||
private static Future<?> executeOnPooledThread(@NotNull Runnable task) {
|
||||
return AppExecutorUtil.getAppExecutorService().submit(task);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -479,27 +479,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
editor.setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(myProject, myFileType));
|
||||
}
|
||||
|
||||
final EditorColorsScheme colorsScheme = editor.getColorsScheme();
|
||||
editor.getSettings().setCaretRowShown(false);
|
||||
if (!isEnabled()) {
|
||||
editor.setColorsScheme(new DelegateColorScheme(colorsScheme) {
|
||||
@Nullable
|
||||
@Override
|
||||
public Color getColor(ColorKey key) {
|
||||
return super.getColor(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextAttributes getAttributes(TextAttributesKey key) {
|
||||
final TextAttributes attributes = super.getAttributes(key);
|
||||
if (!isEnabled()) {
|
||||
return new TextAttributes(UIUtil.getInactiveTextColor(), attributes.getBackgroundColor(), attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType());
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editor.setOneLineMode(myOneLineMode);
|
||||
editor.getCaretModel().moveToOffset(myDocument.getTextLength());
|
||||
|
||||
@@ -21,12 +21,8 @@ import com.intellij.openapi.vfs.VfsUtil
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.OutputStream
|
||||
import java.nio.file.FileVisitResult
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.SimpleFileVisitor
|
||||
import java.nio.file.*
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.nio.file.attribute.FileTime
|
||||
|
||||
fun Path.exists() = Files.exists(this)
|
||||
|
||||
@@ -74,7 +70,7 @@ fun Path.deleteRecursively(): Path = if (exists()) Files.walkFileTree(this, obje
|
||||
}
|
||||
}) else this
|
||||
|
||||
fun Path.getLastModifiedTime(): FileTime? = Files.getLastModifiedTime(this)
|
||||
fun Path.lastModified() = Files.getLastModifiedTime(this)
|
||||
|
||||
val Path.systemIndependentPath: String
|
||||
get() = toString().replace(File.separatorChar, '/')
|
||||
@@ -90,15 +86,33 @@ fun Path.writeChild(relativePath: String, data: ByteArray) = resolve(relativePat
|
||||
|
||||
fun Path.writeChild(relativePath: String, data: String) = writeChild(relativePath, data.toByteArray())
|
||||
|
||||
fun Path.write(data: ByteArray): Path {
|
||||
parent?.createDirectories()
|
||||
return Files.write(this, data)
|
||||
fun Path.write(data: ByteArray, offset: Int = 0, length: Int = data.size): Path {
|
||||
outputStream().use { it.write(data, offset, length) }
|
||||
return this
|
||||
}
|
||||
|
||||
fun Path.size() = Files.size(this)
|
||||
|
||||
fun Path.sizeOrNull(): Long {
|
||||
val attributes: BasicFileAttributes
|
||||
try {
|
||||
attributes = Files.readAttributes(this, BasicFileAttributes::class.java)
|
||||
}
|
||||
catch (ignored: IOException) {
|
||||
return -1
|
||||
}
|
||||
|
||||
return attributes.size()
|
||||
}
|
||||
|
||||
fun Path.isHidden() = Files.isHidden(this)
|
||||
|
||||
fun Path.isDirectory() = Files.isDirectory(this)
|
||||
|
||||
fun Path.isFile() = Files.isRegularFile(this)
|
||||
|
||||
fun Path.move(target: Path) = Files.move(this, target)
|
||||
|
||||
/**
|
||||
* Opposite to Java, parent directories will be created
|
||||
*/
|
||||
@@ -115,4 +129,22 @@ fun Path.refreshVfs() {
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, virtualFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <R> Path.directoryStreamIfExists(task: (stream: DirectoryStream<Path>) -> R): R? {
|
||||
try {
|
||||
Files.newDirectoryStream(this).use(task)
|
||||
}
|
||||
catch (ignored: NoSuchFileException) {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
inline fun <R> Path.directoryStreamIfExists(noinline filter: ((path: Path) -> Boolean), task: (stream: DirectoryStream<Path>) -> R): R? {
|
||||
try {
|
||||
Files.newDirectoryStream(this, { filter.invoke(it) }).use(task)
|
||||
}
|
||||
catch (ignored: NoSuchFileException) {
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -7,6 +7,7 @@ diagnostic.out.of.memory.title=Out of Memory
|
||||
diagnostic.out.of.memory.currentValue=(current value: {0})
|
||||
diagnostic.out.of.memory.currentValue.unknown=Unknown
|
||||
diagnostic.out.of.memory.continue=Continue
|
||||
diagnostic.out.of.memory.dump=Memory Dump
|
||||
diagnostic.error.report.send=&Send
|
||||
diagnostic.error.report.description=<html>If you would like to get notified when the exceptions you submit are fixed,<br>please fill in your JetBrains Account login and password.</html>
|
||||
diagnostic.error.report.proxy.setup=<html><a href="#">Set up HTTP proxy settings</a></html>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user