Merge remote branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-01-13 15:22:03 +01:00
25 changed files with 368 additions and 225 deletions
@@ -2,7 +2,7 @@
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.remote.RemoteConfigurable">
<grid id="715ea" binding="myPanel" layout-manager="GridBagLayout">
<constraints>
<xy x="64" y="1" width="589" height="309"/>
<xy x="64" y="1" width="589" height="319"/>
</constraints>
<properties/>
<border type="none"/>
@@ -149,7 +149,7 @@
<component id="4362c" class="com.intellij.execution.ui.ConfigurationArgumentsHelpArea" binding="myJDK13HelpArea">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
<gridbag top="5" left="0" bottom="15" right="0" weightx="1.0" weighty="0.0"/>
<gridbag top="15" left="0" bottom="15" right="0" weightx="1.0" weighty="0.0"/>
</constraints>
<properties/>
</component>
@@ -30,6 +30,7 @@
<properties>
<editable value="false"/>
<lineWrap value="true"/>
<minimumSize width="250" height="16"/>
<wrapStyleWord value="true"/>
</properties>
</component>
@@ -674,6 +674,9 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
final List<OrderEntry> orderEntries = fileIndex.getOrderEntriesForFile(virtualFile);
for (OrderEntry orderEntry : orderEntries) {
if (orderEntry instanceof ModuleOrderEntry) {
continue;
}
final String[] files = orderEntry.getUrls(JavadocOrderRootType.getInstance());
final List<String> httpRoot = PlatformDocumentationUtil.getHttpRoots(files, relPath);
if (httpRoot != null) return httpRoot;
@@ -7,7 +7,7 @@ public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
myPrintInfo = new Queryable.PrintInfo(new String[]{"className", "fileName", "fieldName", "methodName", "packageName"});
myPrintInfo = new Queryable.PrintInfo();
}
public void test1() {
@@ -33,24 +33,6 @@ public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
" Form1.form\n" +
" Form2.form\n");
assertStructureEqual("Project\n" +
" External Libraries\n" +
" Library: < java 1.7 >\n" +
" annotations.jar\n" +
" META-INF\n" +
" MANIFEST.MF\n" +
" classpath.index\n" +
" org\n" +
" intellij\n" +
" lang\n" +
" annotations\n" +
" Identifier\n" +
" Language\n" +
" Pattern\n" +
" PrintFormat\n" +
" PrintFormatPattern\n" +
" RegExp\n");
getProjectTreeStructure().setProviders();
assertStructureEqual(getPackageDirectory(),
@@ -62,23 +44,6 @@ public class ProjectTreeStructureTest extends BaseProjectViewTestCase {
" Form1.java\n" +
" Form2.form\n");
assertStructureEqual("Project\n" +
" External Libraries\n" +
" Library: < java 1.7 >\n" +
" annotations.jar\n" +
" META-INF\n" +
" MANIFEST.MF\n" +
" classpath.index\n" +
" org\n" +
" intellij\n" +
" lang\n" +
" annotations\n" +
" Identifier.class\n" +
" Language.class\n" +
" Pattern.class\n" +
" PrintFormat.class\n" +
" PrintFormatPattern.class\n" +
" RegExp.class\n");
}
public void testShowClassMembers() {
@@ -31,7 +31,7 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement;
import com.intellij.testFramework.IdeaTestUtil;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.testFramework.ProjectViewTestUtil;
import com.intellij.testFramework.TestSourceBasedTestCase;
import com.intellij.util.Function;
@@ -112,10 +112,6 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
return (AbstractProjectTreeStructure)myStructure;
}
protected void assertStructureEqual(@NonNls String expected) {
assertStructureEqual(myStructure.getRootElement(), expected);
}
protected void assertStructureEqual(String expected, Comparator comparator) {
assertStructureEqual(myStructure.getRootElement(), expected, 27, comparator);
}
@@ -123,16 +119,12 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
private void assertStructureEqual(PsiDirectory root, String expected, int maxRowCount, AbstractTreeStructure structure) {
assertNotNull(root);
PsiDirectoryNode rootNode = new PsiDirectoryNode(myProject, root, (ViewSettings)structure);
assertStructureEqual(rootNode, expected, maxRowCount, IdeaTestUtil.createComparator(myPrintInfo));
}
private void assertStructureEqual(Object rootNode, String expected) {
assertStructureEqual(rootNode, expected, 17, IdeaTestUtil.createComparator(myPrintInfo));
assertStructureEqual(rootNode, expected, maxRowCount, PlatformTestUtil.createComparator(myPrintInfo));
}
private void assertStructureEqual(Object rootNode, String expected, int maxRowCount, Comparator comparator) {
checkGetParentConsistency(rootNode);
StringBuffer actual = IdeaTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ', myPrintInfo);
StringBuffer actual = PlatformTestUtil.print(myStructure, rootNode, 0, comparator, maxRowCount, ' ', myPrintInfo);
assertEquals(expected, actual.toString());
}
@@ -185,7 +177,7 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
}
protected static void assertListsEqual(ListModel model, String expected) {
assertEquals(expected, IdeaTestUtil.print(model));
assertEquals(expected, PlatformTestUtil.print(model));
}
public static void checkContainsMethod(final Object rootElement, final AbstractTreeStructure structure) {
@@ -26,8 +26,8 @@ public interface Queryable {
void putInfo(@NotNull Map<String, String> info);
class PrintInfo {
String[] myIdKeys;
String[] myInfoKeys;
private final String[] myIdKeys;
private final String[] myInfoKeys;
public PrintInfo() {
this(null, null);
@@ -57,13 +57,13 @@ public interface Queryable {
String id = null;
String[] names = print.myIdKeys != null ? print.myIdKeys : new String[] {"name"};
for (String eachKey : names) {
String eachValue = map.get(eachKey);
if (eachValue != null) {
id = eachValue;
}
}
//String[] names = print.myIdKeys != null ? print.myIdKeys : new String[] {"name"};
//for (String eachKey : names) {
// String eachValue = map.get(eachKey);
// if (eachValue != null) {
// id = eachValue;
// }
//}
if (!map.isEmpty()) {
id = map.values().iterator().next();
@@ -1029,7 +1029,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
}
@Override
public void putInfo(Map<String, String> info) {
public void putInfo(@NotNull Map<String, String> info) {
putInfo(this, info);
}
@@ -428,6 +428,8 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
final boolean wasCollapsed = myTree.isCollapsed(path);
final Runnable runnable = new Runnable() {
public void run() {
TreeUtil.sort(rootToReload, getNodeComparator());
treeModel.reload(rootToReload);
if (!wasCollapsed) {
myTree.collapsePath(path);
for (TreePath treePath : treePaths) {
@@ -437,8 +439,6 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable {
TreeUtil.selectPath(myTree, selectionPath);
}
}
TreeUtil.sort(rootToReload, getNodeComparator());
treeModel.reload(rootToReload);
}
};
if (ApplicationManager.getApplication().isUnitTestMode()) {
@@ -97,7 +97,6 @@ public class PerformanceWatcher implements ApplicationComponent {
myLogDir = new File(PathManager.getLogPath() + "/threadDumps-" + myDateFormat.format(new Date())
+ "-" + ApplicationInfo.getInstance().getBuild().asString());
myLogDir.mkdirs();
myCurHangLogDir = myLogDir;
try {
@@ -165,7 +164,6 @@ public class PerformanceWatcher implements ApplicationComponent {
if (myUnresponsiveDuration == UNRESPONSIVE_THRESHOLD) {
//System.out.println("EDT is not responding at " + myPrintDateFormat.format(new Date()));
myCurHangLogDir = new File(myLogDir, myDateFormat.format(new Date()));
myCurHangLogDir.mkdirs();
}
if (myUnresponsiveDuration >= UNRESPONSIVE_THRESHOLD) {
dumpThreads(false);
@@ -174,7 +172,9 @@ public class PerformanceWatcher implements ApplicationComponent {
else {
if (myUnresponsiveDuration >= UNRESPONSIVE_THRESHOLD) {
//System.out.println("EDT was unresponsive for " + myUnresponsiveDuration + " seconds");
myCurHangLogDir.renameTo(new File(myLogDir, getLogDirForHang()));
if (myCurHangLogDir.exists()) {
myCurHangLogDir.renameTo(new File(myLogDir, getLogDirForHang()));
}
myUnresponsiveDuration = 0;
myCurHangLogDir = myLogDir;
@@ -199,6 +199,8 @@ public class PerformanceWatcher implements ApplicationComponent {
public void dumpThreads(boolean millis) {
final String suffix = millis ? "-" + String.valueOf(System.currentTimeMillis()) : "";
myCurHangLogDir.mkdirs();
File f = new File(myCurHangLogDir, "threadDump-" + myDateFormat.format(new Date()) + suffix + ".txt");
FileOutputStream fos;
try {
@@ -16,15 +16,24 @@
package com.intellij.ide.plugins;
import com.intellij.ide.IdeBundle;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.net.IOExceptionDialog;
import org.jetbrains.annotations.NotNull;
import javax.swing.event.HyperlinkEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -81,7 +90,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
IdeaPluginDescriptor[] selection = getPluginTable().getSelectedObjects();
if (userConfirm(selection)) {
ArrayList<PluginNode> list = new ArrayList<PluginNode>();
final ArrayList<PluginNode> list = new ArrayList<PluginNode>();
for (IdeaPluginDescriptor descr : selection) {
PluginNode pluginNode = null;
if (descr instanceof PluginNode) {
@@ -99,31 +108,69 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
}
}
try {
if (PluginManagerMain.downloadPlugins(list, host.getPluginsModel().view)) {
for (PluginNode pluginNode : list) {
final String idString = pluginNode.getPluginId().getIdString();
final PluginManagerUISettings pluginManagerUISettings = PluginManagerUISettings.getInstance();
if (!pluginManagerUISettings.myInstalledPlugins.contains(idString)) {
pluginManagerUISettings.myInstalledPlugins.add(idString);
final Runnable onInstallRunnable = new Runnable() {
@Override
public void run() {
installedPluginsToModel(list);
installed.setRequireShutdown(true);
if (!installed.isDisposed()) {
getPluginTable().updateUI();
}
else {
notifyPluginsWereInstalled();
}
pluginManagerUISettings.myOutdatedPlugins.remove(idString);
}
final InstalledPluginsTableModel installedPluginsModel = (InstalledPluginsTableModel)installed.getPluginsModel();
for (PluginNode node : list) {
installedPluginsModel.appendOrUpdateDescriptor(node);
}
installed.setRequireShutdown(true);
}
};
PluginManagerMain.downloadPlugins(list, host.getPluginsModel().view, onInstallRunnable);
}
catch (IOException e1) {
PluginManagerMain.LOG.error(e1);
IOExceptionDialog
.showErrorDialog(IdeBundle.message("action.download.and.install.plugin"), IdeBundle.message("error.plugin.download.failed"));
}
getPluginTable().updateUI();
}
}
private void installedPluginsToModel(ArrayList<PluginNode> list) {
for (PluginNode pluginNode : list) {
final String idString = pluginNode.getPluginId().getIdString();
final PluginManagerUISettings pluginManagerUISettings = PluginManagerUISettings.getInstance();
if (!pluginManagerUISettings.myInstalledPlugins.contains(idString)) {
pluginManagerUISettings.myInstalledPlugins.add(idString);
}
pluginManagerUISettings.myOutdatedPlugins.remove(idString);
}
final InstalledPluginsTableModel installedPluginsModel = (InstalledPluginsTableModel)installed.getPluginsModel();
for (PluginNode node : list) {
installedPluginsModel.appendOrUpdateDescriptor(node);
}
}
private static void notifyPluginsWereInstalled() {
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
final boolean restartCapable = app.isRestartCapable();
String message = "<html>";
message += restartCapable ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getProductName())
: IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getProductName());
message += "<br><a href=";
message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
message += "</a></html>";
Notifications.Bus.notify(new Notification(IdeBundle.message("title.plugin.error"), IdeBundle.message("title.plugin.error"),
message, NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
notification.expire();
if (restartCapable) {
app.restart();
}
else {
app.exit(true);
}
}
}));
}
public PluginTable getPluginTable() {
return host.getPluginTable();
@@ -22,9 +22,12 @@ import com.intellij.ide.ui.search.SearchUtil;
import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.updateSettings.impl.PluginDownloader;
@@ -99,6 +102,7 @@ public abstract class PluginManagerMain implements Disposable {
protected final MyPluginsFilter myFilter = new MyPluginsFilter();
protected PluginManagerUISettings myUISettings;
private boolean myDisposed = false;
public PluginManagerMain(
PluginManagerUISettings uiSettings) {
@@ -125,6 +129,11 @@ public abstract class PluginManagerMain implements Disposable {
protected abstract JScrollPane createTable();
public void dispose() {
myDisposed = true;
}
public boolean isDisposed() {
return myDisposed;
}
public void filter(String filter) {
@@ -280,14 +289,18 @@ public abstract class PluginManagerMain implements Disposable {
loadPluginsFromHostInBackground();
}
public static boolean downloadPlugins(final List<PluginNode> plugins, final List<IdeaPluginDescriptor> allPlugins) throws IOException {
public static boolean downloadPlugins(final List<PluginNode> plugins, final List<IdeaPluginDescriptor> allPlugins, final Runnable onSuccess) throws IOException {
final boolean[] result = new boolean[1];
try {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
result[0] = PluginInstaller.prepareToInstall(plugins, allPlugins);
ProgressManager.getInstance().run(new Task.Backgroundable(null, IdeBundle.message("progress.download.plugins"), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
if (PluginInstaller.prepareToInstall(plugins, allPlugins)) {
ApplicationManager.getApplication().invokeLater(onSuccess);
result[0] = true;
}
}
}, IdeBundle.message("progress.download.plugins"), true, null);
});
}
catch (RuntimeException e) {
if (e.getCause() != null && e.getCause() instanceof IOException) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,27 +55,38 @@ public class EditorActionUtil {
private EditorActionUtil() {
}
public static void scrollRelatively(Editor editor, int lineShift) {
/**
* Tries to change given editor's viewport position in vertical dimension by the given number of visual lines.
*
* @param editor target editor which viewport position should be changed
* @param lineShift defines viewport position's change length
* @param moveCaret flag that identifies whether caret should be moved if its current position becomes off-screen
*/
public static void scrollRelatively(Editor editor, int lineShift, boolean moveCaret) {
if (lineShift != 0) {
editor.getScrollingModel().scrollVertically(
editor.getScrollingModel().getVerticalScrollOffset() + lineShift * editor.getLineHeight()
);
}
//Rectangle viewRectangle = editor.getScrollingModel().getVisibleArea();
//int lineNumber = editor.getCaretModel().getVisualPosition().line;
//if (viewRectangle != null) {
// VisualPosition startPos = editor.xyToVisualPosition(new Point(0, viewRectangle.y));
// int start = startPos.line + 1;
// VisualPosition endPos = editor.xyToVisualPosition(new Point(0, viewRectangle.y + viewRectangle.height));
// int end = endPos.line - 2;
//if (lineNumber < start) {
// editor.getCaretModel().moveCaretRelatively(0, start - lineNumber, false, false, true);
//}
//else if (lineNumber > end) {
// editor.getCaretModel().moveCaretRelatively(0, end - lineNumber, false, false, true);
//}
//}
if (!moveCaret) {
return;
}
Rectangle viewRectangle = editor.getScrollingModel().getVisibleArea();
int lineNumber = editor.getCaretModel().getVisualPosition().line;
if (viewRectangle != null) {
VisualPosition startPos = editor.xyToVisualPosition(new Point(0, viewRectangle.y));
int start = startPos.line + 1;
VisualPosition endPos = editor.xyToVisualPosition(new Point(0, viewRectangle.y + viewRectangle.height));
int end = endPos.line - 2;
if (lineNumber < start) {
editor.getCaretModel().moveCaretRelatively(0, start - lineNumber, false, false, true);
}
else if (lineNumber > end) {
editor.getCaretModel().moveCaretRelatively(0, end - lineNumber, false, false, true);
}
}
}
public static void moveCaretRelativelyAndScroll(Editor editor,
@@ -215,9 +226,11 @@ public class EditorActionUtil {
}
if (isCamel) {
if (firstIsIdentifierPart && secondIsIdentifierPart &&
(Character.isLowerCase(prev) && Character.isUpperCase(current) || prev != '_' && current == '_' ||
Character.isUpperCase(prev) && Character.isUpperCase(current) && Character.isLowerCase(next))) {
if (firstIsIdentifierPart
&& (Character.isLowerCase(prev) && Character.isUpperCase(current)
|| prev != '_' && current == '_'
|| Character.isUpperCase(prev) && Character.isUpperCase(current) && Character.isLowerCase(next)))
{
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class ScrollDownAction extends InactiveEditorAction {
private static class Handler extends EditorActionHandler {
@Override
public void execute(Editor editor, DataContext dataContext) {
EditorActionUtil.scrollRelatively(editor, 1);
EditorActionUtil.scrollRelatively(editor, 1, false);
}
}
}
@@ -0,0 +1,40 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.editor.actions;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
/**
* Moves editor viewport one visual line down. Caret is also moved one line down if it becomes off-screen
*
* @author Denis Zhdanov
* @since 1/13/12 1:22 PM
*/
public class ScrollDownAndMoveAction extends InactiveEditorAction {
public ScrollDownAndMoveAction() {
super(new Handler());
}
private static class Handler extends EditorActionHandler {
@Override
public void execute(Editor editor, DataContext dataContext) {
EditorActionUtil.scrollRelatively(editor, 1, true);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class ScrollUpAction extends InactiveEditorAction {
private static class Handler extends EditorActionHandler {
@Override
public void execute(Editor editor, DataContext dataContext) {
EditorActionUtil.scrollRelatively(editor, -1);
EditorActionUtil.scrollRelatively(editor, -1, false);
}
}
}
@@ -0,0 +1,40 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.editor.actions;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
/**
* Moves editor viewport one visual line up. Caret is also moved one line up if it becomes off-screen.
*
* @author Denis Zhdanov
* @since 1/13/12 1:21 PM
*/
public class ScrollUpAndMoveAction extends InactiveEditorAction {
public ScrollUpAndMoveAction() {
super(new Handler());
}
private static class Handler extends EditorActionHandler {
@Override
public void execute(Editor editor, DataContext dataContext) {
EditorActionUtil.scrollRelatively(editor, -1, true);
}
}
}
@@ -89,6 +89,8 @@ action.EditorTab.text=Tab
action.EmacsStyleIndent.text=Emacs Tab
action.EditorScrollUp.text=Scroll Up
action.EditorScrollDown.text=Scroll Down
action.EditorScrollUpAndMove.text=Scroll Up and Move if Necessary
action.EditorScrollDownAndMove.text=Scroll Down and Move if Necessary
action.EditorScrollTop.text=Scroll to Top
action.EditorScrollBottom.text=Scroll to Bottom
action.EditorMoveUpAndScroll.text=Move Up and Scroll
@@ -247,10 +247,10 @@ remote.configuration.socket.radio=Socket
remote.configuration.shared.memory.address.label=Shared memory address:
remote.configuration.port.label=Port:
remote.configuration.host.label=Host:
remote.configuration.remote.debugging.allows.you.to.connect.idea.to.a.running.jvm.label=Remote debugging allows you to connect IDEA to a running JVM started with the following command line arguments
remote.configuration.remote.debugging.allows.you.to.connect.idea.to.a.running.jvm.label=&Remote debugging allows you to connect IDEA to a running JVM started with the following command line arguments
standard.runner.description=Run selected configuration
environment.variables.helper.use.arguments.label=<html><body>Use the following command line arguments for running remote JVM</body></html>
environment.variables.helper.use.arguments.jdk13.label=<html><body>If the application runs on JDK 1.3.x or earlier, use following arguments</body></html>
environment.variables.helper.use.arguments.jdk13.label=<html><body>If the &application runs on JDK 1.3.x or earlier, use following arguments</body></html>
select.run.configuration.for.item.action.name=Select {0}
save.run.configuration.for.item.action.name=Save {0}
junit.runing.info.status.done.count=Done: {0}
@@ -51,6 +51,8 @@
<action id="EditorTab" class="com.intellij.openapi.editor.actions.TabAction"/>
<action id="EditorScrollUp" class="com.intellij.openapi.editor.actions.ScrollUpAction"/>
<action id="EditorScrollDown" class="com.intellij.openapi.editor.actions.ScrollDownAction"/>
<action id="EditorScrollUpAndMove" class="com.intellij.openapi.editor.actions.ScrollUpAndMoveAction"/>
<action id="EditorScrollDownAndMove" class="com.intellij.openapi.editor.actions.ScrollDownAndMoveAction"/>
<action id="EditorScrollTop" class="com.intellij.openapi.editor.actions.ScrollToTopAction"/>
<action id="EditorScrollBottom" class="com.intellij.openapi.editor.actions.ScrollToBottomAction"/>
<action id="EditorMoveUpAndScroll" class="com.intellij.openapi.editor.actions.MoveUpAndScrollAction"/>
@@ -52,6 +52,7 @@ public class UpdateRequestsQueue {
private volatile boolean myIgnoreBackgroundOperation;
private boolean myRequestSubmitted;
private boolean myRequestRunning;
private final List<Runnable> myWaitingUpdateCompletionQueue;
private final ProjectLevelVcsManager myPlVcsManager;
//private final ScheduledSlowlyClosingAlarm mySharedExecutor;
@@ -156,7 +157,7 @@ public class UpdateRequestsQueue {
semaphore.up();
}
};
if (myRequestSubmitted && !myStopped) {
if (myRequestSubmitted || myRequestRunning) {
myWaitingUpdateCompletionQueue.add(runnable);
}
else {
@@ -169,7 +170,7 @@ public class UpdateRequestsQueue {
}
synchronized (myLock) {
if (!myRequestSubmitted || myStopped) {
if (!myRequestSubmitted && !myRequestRunning) {
return;
}
}
@@ -236,9 +237,10 @@ public class UpdateRequestsQueue {
private class MyRunnable implements Runnable {
public void run() {
final List<Runnable> copy = new ArrayList<Runnable>(myWaitingUpdateCompletionQueue.size());
try {
synchronized (myLock) {
LOG.assertTrue(!myRequestRunning);
myRequestRunning = true;
if (myStopped) {
myRequestSubmitted = false;
LOG.debug("MyRunnable: STOPPED, project: " + myProject.getName() + ", runnable: " + hashCode());
@@ -269,6 +271,7 @@ public class UpdateRequestsQueue {
LOG.debug("MyRunnable: invokeD, project: " + myProject.getName() + ", runnable: " + hashCode());
} finally {
synchronized (myLock) {
myRequestRunning = false;
LOG.debug("MyRunnable: delete executed, project: " + myProject.getName() + ", runnable: " + hashCode());
if (! copy.isEmpty()) {
myWaitingUpdateCompletionQueue.removeAll(copy);
@@ -498,18 +498,33 @@ public class ForCanBeForeachInspection extends BaseInspection {
if (tokenType.equals(JavaTokenType.LT)) {
arrayLengthExpression = (PsiReferenceExpression)ParenthesesUtils.stripParentheses(rhs);
indexName = lhs.getText();
} else if (tokenType.equals(JavaTokenType.GT)) {
}
else if (tokenType.equals(JavaTokenType.GT)) {
arrayLengthExpression = (PsiReferenceExpression)ParenthesesUtils.stripParentheses(lhs);
indexName = rhs.getText();
} else {
}
else {
return null;
}
if (arrayLengthExpression == null) {
return null;
}
final PsiReferenceExpression arrayReference = (PsiReferenceExpression)arrayLengthExpression.getQualifierExpression();
PsiReferenceExpression arrayReference = (PsiReferenceExpression)arrayLengthExpression.getQualifierExpression();
if (arrayReference == null) {
return null;
final PsiElement target = arrayLengthExpression.resolve();
if (!(target instanceof PsiVariable)) {
return null;
}
final PsiVariable variable = (PsiVariable)target;
final PsiExpression initializer = variable.getInitializer();
if (!(initializer instanceof PsiReferenceExpression)) {
return null;
}
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)initializer;
arrayReference = (PsiReferenceExpression)referenceExpression.getQualifierExpression();
if (arrayReference == null) {
return null;
}
}
final PsiArrayType arrayType = (PsiArrayType)arrayReference.getType();
if (arrayType == null) {
@@ -524,33 +539,24 @@ public class ForCanBeForeachInspection extends BaseInspection {
final PsiVariable arrayVariable = (PsiVariable)target;
final PsiStatement body = forStatement.getBody();
final PsiStatement firstStatement = getFirstStatement(body);
final boolean isDeclaration =
isArrayElementDeclaration(firstStatement, arrayVariable,
indexName);
final boolean isDeclaration = isArrayElementDeclaration(firstStatement, arrayVariable, indexName);
final String contentVariableName;
@NonNls final String finalString;
final PsiStatement statementToSkip;
if (isDeclaration) {
final PsiDeclarationStatement declarationStatement =
(PsiDeclarationStatement)firstStatement;
final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)firstStatement;
assert declarationStatement != null;
final PsiElement[] declaredElements =
declarationStatement.getDeclaredElements();
final PsiElement[] declaredElements = declarationStatement.getDeclaredElements();
final PsiElement declaredElement = declaredElements[0];
if (!(declaredElement instanceof PsiVariable)) {
return null;
}
final PsiVariable variable =
(PsiVariable)declaredElement;
if (VariableAccessUtils.variableIsAssigned(variable,
forStatement)) {
final String collectionName =
arrayReference.getReferenceName();
contentVariableName = createNewVariableName(forStatement,
componentType, collectionName);
final PsiVariable variable = (PsiVariable)declaredElement;
if (VariableAccessUtils.variableIsAssigned(variable, forStatement)) {
final String collectionName = arrayReference.getReferenceName();
contentVariableName = createNewVariableName(forStatement, componentType, collectionName);
final Project project = forStatement.getProject();
final CodeStyleSettings codeStyleSettings =
CodeStyleSettingsManager.getSettings(project);
final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project);
if (codeStyleSettings.GENERATE_FINAL_LOCALS) {
finalString = "final ";
}
@@ -571,13 +577,10 @@ public class ForCanBeForeachInspection extends BaseInspection {
}
}
else {
final String collectionName =
arrayReference.getReferenceName();
contentVariableName = createNewVariableName(forStatement,
componentType, collectionName);
final String collectionName = arrayReference.getReferenceName();
contentVariableName = createNewVariableName(forStatement, componentType, collectionName);
final Project project = forStatement.getProject();
final CodeStyleSettings codeStyleSettings =
CodeStyleSettingsManager.getSettings(project);
final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project);
if (codeStyleSettings.GENERATE_FINAL_LOCALS) {
finalString = "final ";
}
@@ -597,8 +600,7 @@ public class ForCanBeForeachInspection extends BaseInspection {
out.append(arrayName);
out.append(')');
if (body != null) {
replaceArrayAccess(body, contentVariableName, arrayVariable,
indexName, statementToSkip, out);
replaceArrayAccess(body, contentVariableName, arrayVariable, indexName, statementToSkip, out);
}
return out.toString();
}
@@ -991,7 +993,14 @@ public class ForCanBeForeachInspection extends BaseInspection {
}
final PsiDeclarationStatement declaration = (PsiDeclarationStatement)initialization;
final PsiElement[] declaredElements = declaration.getDeclaredElements();
if (declaredElements.length < 1) {
final PsiElement secondDeclaredElement;
if (declaredElements.length == 1) {
secondDeclaredElement = null;
}
else if (declaredElements.length == 2) {
secondDeclaredElement = declaredElements[1];
}
else {
return false;
}
final PsiElement declaredElement = declaredElements[0];
@@ -1012,7 +1021,7 @@ public class ForCanBeForeachInspection extends BaseInspection {
return false;
}
final PsiExpression condition = forStatement.getCondition();
final Holder collectionHolder = getCollectionFromSizeComparison(condition, indexVariable);
final Holder collectionHolder = getCollectionFromSizeComparison(condition, indexVariable, secondDeclaredElement);
if (collectionHolder == null) {
return false;
}
@@ -1041,10 +1050,16 @@ public class ForCanBeForeachInspection extends BaseInspection {
if (!(initialization instanceof PsiDeclarationStatement)) {
return false;
}
final PsiDeclarationStatement declaration =
(PsiDeclarationStatement)initialization;
final PsiDeclarationStatement declaration = (PsiDeclarationStatement)initialization;
final PsiElement[] declaredElements = declaration.getDeclaredElements();
if (declaredElements.length != 1) {
final PsiElement secondDeclaredElement;
if (declaredElements.length == 1) {
secondDeclaredElement = null;
}
else if (declaredElements.length == 2) {
secondDeclaredElement = declaredElements[1];
}
else {
return false;
}
final PsiElement declaredElement = declaredElements[0];
@@ -1065,15 +1080,12 @@ public class ForCanBeForeachInspection extends BaseInspection {
if (integer.intValue() != 0) {
return false;
}
//if (!isArrayLengthComparison(condition, indexVariable)) {
// return false;
//}
final PsiStatement update = forStatement.getUpdate();
if (!VariableAccessUtils.variableIsIncremented(indexVariable, update)) {
return false;
}
final PsiExpression condition = forStatement.getCondition();
final PsiReferenceExpression arrayReference = getVariableReferenceFromCondition(condition, indexVariable);
final PsiReferenceExpression arrayReference = getVariableReferenceFromCondition(condition, indexVariable, secondDeclaredElement);
if (arrayReference == null) {
return false;
}
@@ -1083,17 +1095,10 @@ public class ForCanBeForeachInspection extends BaseInspection {
}
final PsiVariable arrayVariable = (PsiVariable)element;
final PsiStatement body = forStatement.getBody();
if (body == null) {
return true;
}
if (!isIndexVariableOnlyUsedAsIndex(arrayVariable, indexVariable, body)) {
return false;
}
if (VariableAccessUtils.variableIsAssigned(arrayVariable, body)) {
return false;
}
return !VariableAccessUtils.arrayContentsAreAssigned(arrayVariable,
body);
return body == null ||
isIndexVariableOnlyUsedAsIndex(arrayVariable, indexVariable, body) &&
!VariableAccessUtils.variableIsAssigned(arrayVariable, body) &&
!VariableAccessUtils.arrayContentsAreAssigned(arrayVariable, body);
}
private static boolean isIndexVariableOnlyUsedAsIndex(
@@ -1280,8 +1285,9 @@ public class ForCanBeForeachInspection extends BaseInspection {
}
@Nullable
private static PsiReferenceExpression getVariableReferenceFromCondition(PsiExpression condition, PsiVariable variable) {
System.out.println("ForCanBeForeachInspection.getVariableReferenceFromCondition(" + condition + ")");
private static PsiReferenceExpression getVariableReferenceFromCondition(PsiExpression condition,
PsiVariable variable,
PsiElement secondDeclaredElement) {
condition = ParenthesesUtils.stripParentheses(condition);
if (!(condition instanceof PsiBinaryExpression)) {
return null;
@@ -1293,40 +1299,51 @@ public class ForCanBeForeachInspection extends BaseInspection {
if (rhs == null) {
return null;
}
final PsiReferenceExpression referenceExpression;
PsiReferenceExpression referenceExpression;
if (tokenType.equals(JavaTokenType.LT)) {
if (!VariableAccessUtils.evaluatesToVariable(lhs, variable) || !expressionIsArrayLengthLookup(rhs)) {
return null;
}
if (rhs instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression expression = (PsiMethodCallExpression)rhs;
referenceExpression = expression.getMethodExpression();
}
else if (rhs instanceof PsiReferenceExpression) {
referenceExpression = (PsiReferenceExpression)rhs;
}
else {
if (!VariableAccessUtils.evaluatesToVariable(lhs, variable) || !(rhs instanceof PsiReferenceExpression)) {
return null;
}
referenceExpression = (PsiReferenceExpression)rhs;
}
else if (tokenType.equals(JavaTokenType.GT)) {
if (!VariableAccessUtils.evaluatesToVariable(rhs, variable) || !expressionIsArrayLengthLookup(lhs)) {
return null;
}
if (lhs instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression expression = (PsiMethodCallExpression)lhs;
referenceExpression = expression.getMethodExpression();
}
else if (lhs instanceof PsiReferenceExpression) {
referenceExpression = (PsiReferenceExpression)lhs;
}
else {
if (!VariableAccessUtils.evaluatesToVariable(rhs, variable) || !(lhs instanceof PsiReferenceExpression)) {
return null;
}
referenceExpression = (PsiReferenceExpression)lhs;
}
else {
return null;
}
if (!expressionIsArrayLengthLookup(referenceExpression)) {
final PsiElement target = referenceExpression.resolve();
if (secondDeclaredElement != null && !secondDeclaredElement.equals(target)) {
return null;
}
if (target instanceof PsiVariable) {
final PsiVariable maxVariable = (PsiVariable)target;
final PsiCodeBlock context = PsiTreeUtil.getParentOfType(maxVariable, PsiCodeBlock.class);
if (context == null) {
return null;
}
if (VariableAccessUtils.variableIsAssigned(maxVariable, context)) {
return null;
}
final PsiExpression expression = ParenthesesUtils.stripParentheses(maxVariable.getInitializer());
if (!(expression instanceof PsiReferenceExpression)) {
return null;
}
referenceExpression = (PsiReferenceExpression)expression;
if (!expressionIsArrayLengthLookup(referenceExpression)) {
return null;
}
}
}
else {
if (secondDeclaredElement != null) {
return null;
}
}
final PsiExpression qualifierExpression = referenceExpression.getQualifierExpression();
if (qualifierExpression instanceof PsiReferenceExpression) {
return (PsiReferenceExpression)qualifierExpression;
@@ -1341,27 +1358,8 @@ public class ForCanBeForeachInspection extends BaseInspection {
}
}
private static boolean isArrayLengthComparison(PsiExpression condition, PsiVariable variable) {
System.out.println("ForCanBeForeachInspection.isArrayLengthComparison(" + condition + ", " + variable + ")");
condition = ParenthesesUtils.stripParentheses(condition);
if (!(condition instanceof PsiBinaryExpression)) {
return false;
}
final PsiBinaryExpression binaryExpression = (PsiBinaryExpression)condition;
final IElementType tokenType = binaryExpression.getOperationTokenType();
final PsiExpression lhs = binaryExpression.getLOperand();
final PsiExpression rhs = binaryExpression.getROperand();
if (tokenType.equals(JavaTokenType.LT)) {
return VariableAccessUtils.evaluatesToVariable(lhs, variable) && rhs != null && expressionIsArrayLengthLookup(rhs);
}
else if (tokenType.equals(JavaTokenType.GT)) {
return VariableAccessUtils.evaluatesToVariable(rhs, variable) && expressionIsArrayLengthLookup(lhs);
}
return false;
}
private static Holder getCollectionFromSizeComparison(
PsiExpression condition, PsiVariable variable) {
@Nullable
private static Holder getCollectionFromSizeComparison(PsiExpression condition, PsiVariable variable, PsiElement secondDeclaredElement) {
condition = ParenthesesUtils.stripParentheses(condition);
if (!(condition instanceof PsiBinaryExpression)) {
return null;
@@ -1374,13 +1372,13 @@ public class ForCanBeForeachInspection extends BaseInspection {
if (!VariableAccessUtils.evaluatesToVariable(lhs, variable)) {
return null;
}
return getCollectionFromListMethodCall(rhs, HardcodedMethodConstants.SIZE);
return getCollectionFromListMethodCall(rhs, HardcodedMethodConstants.SIZE, secondDeclaredElement);
}
else if (tokenType.equals(JavaTokenType.GT)) {
if (!VariableAccessUtils.evaluatesToVariable(rhs, variable)) {
return null;
}
return getCollectionFromListMethodCall(lhs, HardcodedMethodConstants.SIZE);
return getCollectionFromListMethodCall(lhs, HardcodedMethodConstants.SIZE, secondDeclaredElement);
}
return null;
}
@@ -1407,23 +1405,31 @@ public class ForCanBeForeachInspection extends BaseInspection {
CommonClassNames.JAVA_UTIL_LIST);
}
private static Holder getCollectionFromListMethodCall(
PsiExpression expression, String methodName) {
@Nullable
private static Holder getCollectionFromListMethodCall(PsiExpression expression, String methodName, PsiElement secondDeclaredElement) {
expression = ParenthesesUtils.stripParentheses(expression);
if (expression instanceof PsiReferenceExpression) {
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)expression;
final PsiElement target = referenceExpression.resolve();
if (target instanceof PsiVariable) {
final PsiVariable variable = (PsiVariable)target;
final PsiCodeBlock context = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
if (context != null) {
if (!VariableAccessUtils.variableIsAssigned(variable, context)) {
expression = ParenthesesUtils.stripParentheses(variable.getInitializer());
}
}
if (secondDeclaredElement != null && !secondDeclaredElement.equals(target)) {
return null;
}
if (!(target instanceof PsiVariable)) {
return null;
}
final PsiVariable variable = (PsiVariable)target;
final PsiCodeBlock context = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
if (context == null) {
return null;
}
if (VariableAccessUtils.variableIsAssigned(variable, context)) {
return null;
}
expression = ParenthesesUtils.stripParentheses(variable.getInitializer());
}
else if (secondDeclaredElement != null) {
return null;
}
if (!(expression instanceof PsiMethodCallExpression)) {
return null;
}
@@ -1466,7 +1472,6 @@ public class ForCanBeForeachInspection extends BaseInspection {
}
private static boolean expressionIsArrayLengthLookup(PsiExpression expression) {
System.out.println("ForCanBeForeachInspection.expressionIsArrayLengthLookup(" + expression + ")");
expression = ParenthesesUtils.stripParentheses(expression);
if (!(expression instanceof PsiReferenceExpression)) {
return false;
@@ -258,5 +258,13 @@ public class ForCanBeForEach {
public void food(int[] is) {
for (int i = 0; is.length > i; i++) {
}
for (int i = 0, j = 10; i < is.length; i++) {
}
}
void foo(List<String> l) {
for (int i = 0, j = 10; i < l.size(); i++) {
System.out.println(j);
}
}
}
@@ -106,6 +106,13 @@
<description>&lt;code&gt;for&lt;/code&gt; loop replaceable with 'for each' #loc</description>
</problem>
<problem>
<file>ForCanBeForEach.java</file>
<line>252</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'for' loop replaceable with 'for each'</problem_class>
<description>&lt;code&gt;for&lt;/code&gt; loop replaceable with 'for each' #loc</description>
</problem>
<problem>
<file>ForCanBeForEach.java</file>
<line>259</line>
@@ -60,7 +60,7 @@ public class MvcModuleStructureSynchronizer extends AbstractProjectComponent {
private long myModificationCount = 0;
private ModificationTracker myModificationTracker = new ModificationTracker() {
private final ModificationTracker myModificationTracker = new ModificationTracker() {
@Override
public long getModificationCount() {
return myModificationCount;
@@ -88,7 +88,7 @@ public interface MavenDomBuild extends MavenDomBuildBase {
*/
@NotNull
@Required(value = false, nonEmpty = true)
@Convert(value = PathReferenceConverter.class, soft = false)
@Convert(value = PathReferenceConverter.class, soft = true)
GenericDomValue<PathReference> getOutputDirectory();
/**
@@ -102,7 +102,7 @@ public interface MavenDomBuild extends MavenDomBuildBase {
*/
@NotNull
@Required(value = false, nonEmpty = true)
@Convert(value = PathReferenceConverter.class, soft = false)
@Convert(value = PathReferenceConverter.class, soft = true)
GenericDomValue<PathReference> getTestOutputDirectory();
/**