() {
+ public Boolean compute() {
+ if (!ProjectManagerEx.getInstanceEx().closeProject(project)) return false;
+ Disposer.dispose(project);
+ return true;
+ }
+ });
}
/**
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
index baac4465d04c..238ad166919c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
@@ -104,6 +104,9 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
private boolean myDoNotSave = false;
private volatile boolean myDisposeInProgress = false;
+ private int myRestartCode = 0;
+ private volatile int myExitCode = 0;
+
private final AtomicBoolean mySaveSettingsIsInProgress = new AtomicBoolean(false);
@SuppressWarnings({"UseOfArchaicSystemPropertyAccessors"}) private static final int ourDumpThreadsOnLongWriteActionWaiting = Integer.getInteger(
System.getProperty("dump.threads.on.long.write.action.waiting"), 0);
@@ -226,6 +229,14 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
}
});
}
+
+ final String s = System.getProperty("jb.restart.code");
+ if (s != null) {
+ try {
+ myRestartCode = Integer.parseInt(s);
+ } catch (NumberFormatException ignore) {
+ }
+ }
}
private void registerShutdownHook() {
@@ -678,7 +689,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
if (!canExit()) return;
- if (disposeSelf()) System.exit(0);
+ if (disposeSelf()) System.exit(myExitCode);
}
};
@@ -1146,7 +1157,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
}
public boolean isRestartCapable() {
- return SystemInfo.isWindows || SystemInfo.isMacOSSnowLeopard;
+ return SystemInfo.isWindows || SystemInfo.isMacOSSnowLeopard || myRestartCode > 0;
}
public void restart() {
@@ -1156,8 +1167,12 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
else if (SystemInfo.isMacOSSnowLeopard) {
MacRestarter.restart();
}
+ else if (myRestartCode > 0) {
+ myExitCode = myRestartCode;
+ exit(true);
+ }
else {
- exit();
+ exit(true);
}
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/MacRestarter.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/MacRestarter.java
index 19d0c3bec596..10bf5ffa82a4 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/MacRestarter.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/MacRestarter.java
@@ -44,7 +44,7 @@ public class MacRestarter {
try {
final String executablePath = Foundation.toStringViaUTF8(stringURL);
final URL url = new URL(executablePath);
- final String path = url.getPath();
+ final String path = url.getPath().replace("%20", " ");
if (path.contains(".app")) {
final int appIndex = path.indexOf(".app");
final String appPath = path.substring(0, appIndex + 4);
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
index c30a0970c3a8..33a40608216c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
@@ -5173,6 +5173,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
info.put("caret", visual.getLine() + ":" + visual.getColumn());
}
+ public static boolean isChangeFontSize(MouseWheelEvent e) {
+ return SystemInfo.isMac
+ ? !e.isControlDown() && e.isMetaDown() && !e.isAltDown() && !e.isShiftDown()
+ : e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && !e.isShiftDown();
+ }
+
private class MyScrollPane extends JBScrollPane {
@@ -5182,10 +5188,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
protected void processMouseWheelEvent(MouseWheelEvent e) {
if (mySettings.isWheelFontChangeEnabled()) {
- boolean changeFontSize = SystemInfo.isMac
- ? !e.isControlDown() && e.isMetaDown() && !e.isAltDown() && !e.isShiftDown()
- : e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && !e.isShiftDown();
- if (changeFontSize) {
+ if (isChangeFontSize(e)) {
setFontSize(myScheme.getEditorFontSize() + e.getWheelRotation());
return;
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
index f2a9a597e533..c473abf4c7d3 100644
--- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectImpl.java
@@ -80,13 +80,8 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
private final AtomicBoolean mySavingInProgress = new AtomicBoolean(false);
- @NonNls private static final String PROJECT_LAYER = "project-components";
-
public boolean myOptimiseTestLoadSpeed;
@NonNls public static final String TEMPLATE_PROJECT_NAME = "Default (Template) Project";
- @NonNls private static final String DEPRECATED_MESSAGE = "Deprecated method usage: {0}.\n" +
- "This method will cease to exist in IDEA 7.0 final release.\n" +
- "Please contact plugin developers for plugin update.";
private final Condition myDisposedCondition = new Condition() {
public boolean value(final Object o) {
@@ -325,7 +320,11 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
public synchronized void dispose() {
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
- assert application.isHeadlessEnvironment() || application.isUnitTestMode() || application.isDispatchThread() || application.isInModalProgressThread();
+ assert application.isDispatchThread();
+
+ // can call dispose only via com.intellij.ide.impl.ProjectUtil.closeProject()
+ LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || !ProjectManagerEx.getInstanceEx().isProjectOpened(this));
+
LOG.assertTrue(!isDisposed());
if (myProjectManagerListener != null) {
myManager.removeProjectManagerListener(this, myProjectManagerListener);
@@ -472,10 +471,10 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
public static class UnableToSaveProjectNotification extends Notification {
private Project myProject;
- private String[] myFileNames;
+ private final String[] myFileNames;
private UnableToSaveProjectNotification(@NotNull final Project project, final VirtualFile[] readOnlyFiles) {
- super("Project Settings", "Could not save project!", buildMessage(readOnlyFiles), NotificationType.ERROR, new NotificationListener() {
+ super("Project Settings", "Could not save project!", buildMessage(), NotificationType.ERROR, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification;
@@ -501,7 +500,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
return myFileNames;
}
- private static String buildMessage(final VirtualFile[] readOnlyFiles) {
+ private static String buildMessage() {
final StringBuffer sb = new StringBuffer(
"Unable to save project files. Please ensure project files are writable and you have permissions to modify them.");
return sb.append(" Try to save project again.
").toString();
@@ -517,5 +516,4 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
super.expire();
}
}
-
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
index 273f62fea55f..adf6866eacf3 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
@@ -496,19 +496,29 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
private void activateEditorComponent(final boolean forced) {
+ activateEditorComponent(forced, false);
+ }
+ private void activateEditorComponent(final boolean forced, boolean now) {
if (LOG.isDebugEnabled()) {
LOG.debug("enter: activateEditorComponent()");
}
ApplicationManager.getApplication().assertIsDispatchThread();
- getFocusManager().doWhenFocusSettlesDown(new Runnable() {
+ Runnable runnable = new Runnable() {
@Override
public void run() {
final ArrayList commandList = new ArrayList();
activateEditorComponentImpl(getSplittersFromFocus(), commandList, forced);
execute(commandList);
}
- });
+ };
+
+ if (now) {
+ runnable.run();
+ } else {
+ getFocusManager().doWhenFocusSettlesDown(runnable);
+
+ }
}
private EditorsSplitters getSplittersFromFocus() {
@@ -2035,10 +2045,10 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
if (ModalityState.NON_MODAL.equals(ModalityState.current())) {
final String activeId = getActiveToolWindowId();
if (myEditorComponentActive || activeId == null || getToolWindow(activeId) == null) {
- activateEditorComponent(forced);
+ activateEditorComponent(forced, true);
}
else {
- activateToolWindow(activeId, forced, false);
+ activateToolWindow(activeId, forced, true);
}
}
return new ActionCallback.Done();
diff --git a/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java b/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java
index 94b4bbbdee29..aaa7ebeaf936 100644
--- a/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java
+++ b/platform/platform-impl/src/com/intellij/ui/popup/PopupComponent.java
@@ -23,6 +23,8 @@ import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
public interface PopupComponent {
@@ -144,6 +146,14 @@ public interface PopupComponent {
public void hide(boolean dispose) {
myPopup.hide();
+
+ Window wnd = getWindow();
+ if (wnd instanceof JWindow) {
+ JRootPane rootPane = ((JWindow)wnd).getRootPane();
+ if (rootPane != null) {
+ ReflectionUtil.resetField(rootPane, "clientProperties");
+ }
+ }
}
public void show() {
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties
index 32276921d6a3..0bad426867c8 100644
--- a/platform/platform-resources-en/src/messages/IdeBundle.properties
+++ b/platform/platform-resources-en/src/messages/IdeBundle.properties
@@ -848,7 +848,7 @@ label.implements.method.of_interfaces=implements methods of the following classe
element.method=method
element.of.interface=of interface
element.of.class=of class
-prompt.do.you.want.to.action_verb.the.method.from_class=Do you want to {0} the base {1,choice,1#method|2#methods}?
+prompt.do.you.want.to.action_verb.the.method.from_class=Do you want {0} the base {1,choice,1#method|2#methods}?
jar.no.java.modules.in.project.error=There are no Java modules found in the project.\nOnly Java modules can be jarred.
jar.build.progress=Building jar {0}...
jar.build.error.title=Error Creating Jar
diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java
index a4e1e31e47e3..9c7bda8404b2 100644
--- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java
+++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java
@@ -415,7 +415,12 @@ public class NameUtil {
return false;
}
- return myMatcher.matches(name, myPattern);
+ try {
+ return myMatcher.matches(name, myPattern);
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ throw new RuntimeException("Name=" + name + "; pattern=" + myPattern.getPattern() , e);
+ }
}
private static String preparePattern(String pattern) {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
index 53d50e986dc3..d6a019e047a4 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java
@@ -41,6 +41,7 @@ import com.intellij.openapi.vcs.actions.ShowNextChangeMarkerAction;
import com.intellij.openapi.vcs.actions.ShowPrevChangeMarkerAction;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ColoredSideBorder;
+import com.intellij.ui.HintHint;
import com.intellij.ui.HintListener;
import com.intellij.ui.LightweightHint;
import com.intellij.util.ui.UIUtil;
@@ -208,7 +209,7 @@ public class LineStatusTrackerDrawing {
HintManagerImpl.getInstanceImpl().showEditorHint(lightweightHint, editor, point, HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE |
HintManagerImpl.HIDE_BY_OTHER_HINT | HintManagerImpl.HIDE_BY_SCROLLING,
- -1, false);
+ -1, false, new HintHint(editor, point));
}
private static String getFileName(final Document document) {
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java
index badc500ae727..b2a550d36647 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java
@@ -17,6 +17,7 @@ package com.intellij.xdebugger.frame;
import com.intellij.xdebugger.Obsolescent;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -47,4 +48,11 @@ public interface XCompositeNode extends Obsolescent {
* @param errorMessage message describing the error
*/
void setErrorMessage(@NotNull String errorMessage);
+
+ /**
+ * Indicates that an error occurs
+ * @param errorMessage message describing the error
+ * @param link describes a hyperlink which will be appended to the error message
+ */
+ void setErrorMessage(@NotNull String errorMessage, @Nullable XDebuggerTreeNodeHyperlink link);
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerNodeLink.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XDebuggerTreeNodeHyperlink.java
similarity index 76%
rename from platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerNodeLink.java
rename to platform/xdebugger-api/src/com/intellij/xdebugger/frame/XDebuggerTreeNodeHyperlink.java
index ea93a8ad7b99..b7689ae65d5f 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerNodeLink.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XDebuggerTreeNodeHyperlink.java
@@ -13,20 +13,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.intellij.xdebugger.impl.ui.tree.nodes;
+package com.intellij.xdebugger.frame;
+
+import org.jetbrains.annotations.NotNull;
import java.awt.event.MouseEvent;
/**
+ * Describes a hyperlink inside a debugger node
+ *
* @author nik
*/
-public abstract class XDebuggerNodeLink {
+public abstract class XDebuggerTreeNodeHyperlink {
private String myLinkText;
- protected XDebuggerNodeLink(String linkText) {
+ protected XDebuggerTreeNodeHyperlink(@NotNull String linkText) {
myLinkText = linkText;
}
+ @NotNull
public String getLinkText() {
return myLinkText;
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java
index d002d1f2da1a..425aec3cb0a2 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTree.java
@@ -28,6 +28,7 @@ import com.intellij.util.containers.Convertor;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
+import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
import com.intellij.xdebugger.impl.ui.tree.nodes.*;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -78,8 +79,8 @@ public class XDebuggerTree extends DnDAwareTree implements DataProvider {
new TreeLinkMouseListener(new XDebuggerTreeRenderer()) {
@Override
protected void handleTagClick(Object tag, MouseEvent event) {
- if (tag instanceof XDebuggerNodeLink) {
- ((XDebuggerNodeLink)tag).onClick(event);
+ if (tag instanceof XDebuggerTreeNodeHyperlink) {
+ ((XDebuggerTreeNodeHyperlink)tag).onClick(event);
}
}
}.install(this);
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeRenderer.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeRenderer.java
index 06f901c7f4c7..a7a20094c15c 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeRenderer.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/XDebuggerTreeRenderer.java
@@ -17,7 +17,7 @@ package com.intellij.xdebugger.impl.ui.tree;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
-import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerNodeLink;
+import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import javax.swing.*;
@@ -35,7 +35,7 @@ class XDebuggerTreeRenderer extends ColoredTreeCellRenderer {
final boolean hasFocus) {
XDebuggerTreeNode node = (XDebuggerTreeNode)value;
node.getText().appendToComponent(this);
- final XDebuggerNodeLink link = node.getLink();
+ final XDebuggerTreeNodeHyperlink link = node.getLink();
if (link != null) {
append(link.getLinkText(), SimpleTextAttributes.LINK_ATTRIBUTES, link);
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java
index e3c70553dcb4..ec47fecf023d 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/MessageTreeNode.java
@@ -15,8 +15,11 @@
*/
package com.intellij.xdebugger.impl.ui.tree.nodes;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.ui.EmptyIcon;
import com.intellij.xdebugger.XDebuggerBundle;
+import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import org.jetbrains.annotations.NotNull;
@@ -24,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.tree.TreeNode;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -31,17 +35,25 @@ import java.util.List;
* @author nik
*/
public class MessageTreeNode extends XDebuggerTreeNode {
+ private static final EmptyIcon EMPTY_ICON = new EmptyIcon(XDebuggerUIConstants.ERROR_MESSAGE_ICON);
private boolean myEllipsis;
+ private XDebuggerTreeNodeHyperlink myLink;
private MessageTreeNode(XDebuggerTree tree, final XDebuggerTreeNode parent, final String message, final SimpleTextAttributes attributes,
@Nullable Icon icon) {
- this(tree, parent, message, attributes, icon, false);
+ this(tree, parent, message, attributes, icon, null);
}
- private MessageTreeNode(XDebuggerTree tree, final XDebuggerTreeNode parent, final String message, final SimpleTextAttributes attributes, @Nullable Icon icon,
- final boolean ellipsis) {
+ private MessageTreeNode(XDebuggerTree tree, final XDebuggerTreeNode parent, final String message, final SimpleTextAttributes attributes,
+ @Nullable Icon icon, final XDebuggerTreeNodeHyperlink link) {
+ this(tree, parent, message, attributes, icon, false, link);
+ }
+
+ private MessageTreeNode(XDebuggerTree tree, final XDebuggerTreeNode parent, final String message, final SimpleTextAttributes attributes,
+ @Nullable Icon icon, final boolean ellipsis, final XDebuggerTreeNodeHyperlink link) {
super(tree, parent, true);
myEllipsis = ellipsis;
+ myLink = link;
setIcon(icon);
myText.append(message, attributes);
}
@@ -51,11 +63,6 @@ public class MessageTreeNode extends XDebuggerTreeNode {
myEllipsis = false;
}
- private MessageTreeNode(XDebuggerTree tree, XDebuggerTreeNode parent, String infoMessage, String errorMessage) {
- super(tree, parent, true);
- myEllipsis = false;
- }
-
protected List extends TreeNode> getChildren() {
return Collections.emptyList();
}
@@ -64,6 +71,11 @@ public class MessageTreeNode extends XDebuggerTreeNode {
return myEllipsis;
}
+ @Override
+ public XDebuggerTreeNodeHyperlink getLink() {
+ return myLink;
+ }
+
public List extends XDebuggerTreeNode> getLoadedChildren() {
return null;
}
@@ -74,7 +86,7 @@ public class MessageTreeNode extends XDebuggerTreeNode {
public static MessageTreeNode createEllipsisNode(XDebuggerTree tree, XDebuggerTreeNode parent, final int remaining) {
String message = remaining == -1 ? "..." : XDebuggerBundle.message("node.text.ellipsis.0.more.nodes.double.click.to.show", remaining);
- return new MessageTreeNode(tree, parent, message, SimpleTextAttributes.REGULAR_ATTRIBUTES, null, true);
+ return new MessageTreeNode(tree, parent, message, SimpleTextAttributes.REGULAR_ATTRIBUTES, null, true, null);
}
public static MessageTreeNode createMessageNode(XDebuggerTree tree, XDebuggerTreeNode parent, String message, @Nullable Icon icon) {
@@ -85,16 +97,19 @@ public class MessageTreeNode extends XDebuggerTreeNode {
return new MessageTreeNode(tree, parent, XDebuggerUIConstants.COLLECTING_DATA_MESSAGE, XDebuggerUIConstants.COLLECTING_DATA_HIGHLIGHT_ATTRIBUTES, null);
}
- public static MessageTreeNode createEvaluatingMessage(XDebuggerTree tree, final XDebuggerTreeNode parent, final String message) {
- return new MessageTreeNode(tree, parent, message, XDebuggerUIConstants.EVALUATING_EXPRESSION_HIGHLIGHT_ATTRIBUTES, null);
- }
-
public static MessageTreeNode createEvaluatingMessage(XDebuggerTree tree, final XDebuggerTreeNode parent) {
return new MessageTreeNode(tree, parent, XDebuggerUIConstants.EVALUATING_EXPRESSION_MESSAGE, XDebuggerUIConstants.EVALUATING_EXPRESSION_HIGHLIGHT_ATTRIBUTES, null);
}
- public static MessageTreeNode createErrorMessage(XDebuggerTree tree, final XDebuggerTreeNode parent, @NotNull String errorMessage) {
- return new MessageTreeNode(tree, parent, errorMessage, XDebuggerUIConstants.ERROR_MESSAGE_ATTRIBUTES, XDebuggerUIConstants.ERROR_MESSAGE_ICON);
+ public static List createErrorMessages(XDebuggerTree tree, final XDebuggerTreeNode parent, @NotNull String errorMessage,
+ XDebuggerTreeNodeHyperlink link) {
+ List messages = new ArrayList(1);
+ final List lines = StringUtil.split(errorMessage, "\n");
+ for (int i = 0; i < lines.size(); i++) {
+ final Icon icon = i == 0 ? XDebuggerUIConstants.ERROR_MESSAGE_ICON : EMPTY_ICON;
+ messages.add(new MessageTreeNode(tree, parent, lines.get(i), XDebuggerUIConstants.ERROR_MESSAGE_ATTRIBUTES, icon, i == 0 ? link : null));
+ }
+ return messages;
}
public static MessageTreeNode createInfoMessage(XDebuggerTree tree, final XDebuggerTreeNode parent, @NotNull String message) {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java
index 78019ab2d30d..31985506f5a6 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XDebuggerTreeNode.java
@@ -17,6 +17,7 @@ package com.intellij.xdebugger.impl.ui.tree.nodes;
import com.intellij.ui.SimpleColoredText;
import com.intellij.util.enumeration.EmptyEnumeration;
+import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -87,7 +88,7 @@ public abstract class XDebuggerTreeNode implements TreeNode {
}
@Nullable
- public XDebuggerNodeLink getLink() {
+ public XDebuggerTreeNodeHyperlink getLink() {
return null;
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java
index 03fa75102232..2faa7711094d 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java
@@ -16,6 +16,7 @@
package com.intellij.xdebugger.impl.ui.tree.nodes;
import com.intellij.xdebugger.frame.XCompositeNode;
+import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink;
import com.intellij.xdebugger.frame.XValue;
import com.intellij.xdebugger.frame.XValueContainer;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
@@ -110,20 +111,29 @@ public abstract class XValueContainerNode messages) {
myCachedAllChildren = null;
final int[] indices = getNodesIndices(myMessageChildren);
final TreeNode[] nodes = getChildNodes(indices);
myMessageChildren = Collections.emptyList();
fireNodesRemoved(indices, nodes);
- myMessageChildren = Collections.singletonList(messageNode);
+ myMessageChildren = messages;
myCachedAllChildren = null;
fireNodesInserted(myMessageChildren);
}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java
index 7a85c146fb19..1aa1934598e6 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueNodeImpl.java
@@ -19,10 +19,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.SimpleTextAttributes;
import com.intellij.util.StringBuilderSpinAllocator;
-import com.intellij.xdebugger.frame.XCompositeNode;
-import com.intellij.xdebugger.frame.XFullValueEvaluator;
-import com.intellij.xdebugger.frame.XValue;
-import com.intellij.xdebugger.frame.XValueNode;
+import com.intellij.xdebugger.frame.*;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree;
@@ -117,9 +114,9 @@ public class XValueNodeImpl extends XValueContainerNode implements XValu
@Override
- public XDebuggerNodeLink getLink() {
+ public XDebuggerTreeNodeHyperlink getLink() {
if (myFullValueEvaluator != null) {
- return new XDebuggerNodeLink(myFullValueEvaluator.getLinkText()) {
+ return new XDebuggerTreeNodeHyperlink(myFullValueEvaluator.getLinkText()) {
@Override
public void onClick(MouseEvent event) {
DebuggerUIUtil.showValuePopup(myFullValueEvaluator, event, myTree.getProject());
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java
index 159382a39c89..840feb65f3ac 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/controlflow/ConstantIfStatementInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,33 +26,36 @@ import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.psiutils.BoolUtils;
+import com.siyeh.ig.psiutils.VariableSearchUtils;
import org.jetbrains.annotations.NotNull;
-import java.util.HashSet;
-import java.util.Set;
-
public class ConstantIfStatementInspection extends BaseInspection {
+ @Override
@NotNull
public String getDisplayName() {
return InspectionGadgetsBundle.message(
"constant.if.statement.display.name");
}
+ @Override
public boolean isEnabledByDefault() {
return true;
}
+ @Override
@NotNull
protected String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message(
"constant.if.statement.problem.descriptor");
}
+ @Override
public BaseInspectionVisitor buildVisitor() {
return new ConstantIfStatementVisitor();
}
+ @Override
public InspectionGadgetsFix buildFix(Object... infos) {
//if (PsiUtil.isInJspFile(location)) {
// return null;
@@ -103,7 +106,8 @@ public class ConstantIfStatementInspection extends BaseInspection {
final PsiCodeBlock block =
((PsiBlockStatement)branch).getCodeBlock();
final boolean hasConflicts =
- containsConflictingDeclarations(block, parentBlock);
+ VariableSearchUtils.containsConflictingDeclarations(
+ block, parentBlock);
if (hasConflicts) {
final String elseText = branch.getText();
replaceStatement(statement, elseText);
@@ -112,9 +116,12 @@ public class ConstantIfStatementInspection extends BaseInspection {
final PsiStatement[] statements = block.getStatements();
if (statements.length > 0) {
assert containingElement != null;
- final PsiElement added = containingElement.addRangeBefore(statements[0], statements[statements.length - 1], statement);
+ final PsiElement added =
+ containingElement.addRangeBefore(statements[0],
+ statements[statements.length - 1], statement);
final Project project = statement.getProject();
- final CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
+ final CodeStyleManager codeStyleManager =
+ CodeStyleManager.getInstance(project);
codeStyleManager.reformat(added);
}
statement.delete();
@@ -124,43 +131,6 @@ public class ConstantIfStatementInspection extends BaseInspection {
replaceStatement(statement, elseText);
}
}
-
- private static boolean containsConflictingDeclarations(
- PsiCodeBlock block, PsiCodeBlock parentBlock) {
- final PsiStatement[] statements = block.getStatements();
- final Set declaredVars = new HashSet();
- for (final PsiStatement statement : statements) {
- if (statement instanceof PsiDeclarationStatement) {
- final PsiDeclarationStatement declaration =
- (PsiDeclarationStatement)statement;
- final PsiElement[] vars = declaration.getDeclaredElements();
- for (PsiElement var : vars) {
- if (var instanceof PsiLocalVariable) {
- declaredVars.add(var);
- }
- }
- }
- }
- for (Object declaredVar : declaredVars) {
- final PsiLocalVariable variable =
- (PsiLocalVariable)declaredVar;
- final String variableName = variable.getName();
- if (conflictingDeclarationExists(variableName, parentBlock,
- block)) {
- return true;
- }
- }
- return false;
- }
-
- private static boolean conflictingDeclarationExists(
- String name, PsiCodeBlock parentBlock,
- PsiCodeBlock exceptBlock) {
- final ConflictingDeclarationVisitor visitor =
- new ConflictingDeclarationVisitor(name, exceptBlock);
- parentBlock.accept(visitor);
- return visitor.hasConflictingDeclaration();
- }
}
private static class ConstantIfStatementVisitor
@@ -181,50 +151,4 @@ public class ConstantIfStatementInspection extends BaseInspection {
}
}
}
-
- private static class ConflictingDeclarationVisitor
- extends JavaRecursiveElementVisitor {
-
- private final String variableName;
- private final PsiCodeBlock exceptBlock;
- private boolean hasConflictingDeclaration = false;
-
- ConflictingDeclarationVisitor(String variableName,
- PsiCodeBlock exceptBlock) {
- super();
- this.variableName = variableName;
- this.exceptBlock = exceptBlock;
- }
-
- @Override public void visitElement(@NotNull PsiElement element) {
- if (!hasConflictingDeclaration) {
- super.visitElement(element);
- }
- }
-
- @Override public void visitCodeBlock(PsiCodeBlock block) {
- if (hasConflictingDeclaration) {
- return;
- }
- if (block.equals(exceptBlock)) {
- return;
- }
- super.visitCodeBlock(block);
- }
-
- @Override public void visitVariable(PsiVariable variable) {
- if (hasConflictingDeclaration) {
- return;
- }
- super.visitVariable(variable);
- final String name = variable.getName();
- if (name != null && name.equals(variableName)) {
- hasConflictingDeclaration = true;
- }
- }
-
- public boolean hasConflictingDeclaration() {
- return hasConflictingDeclaration;
- }
- }
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableSearchUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableSearchUtils.java
index a1ba06ec29ee..987c86b287d4 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableSearchUtils.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/VariableSearchUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,226 +15,55 @@
*/
package com.siyeh.ig.psiutils;
+import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.HashSet;
-import java.util.Set;
public class VariableSearchUtils {
private VariableSearchUtils() {}
- public static boolean existsLocalOrParameter(@NotNull String variableName,
- @Nullable PsiElement context) {
- if (context == null) {
- return false;
- }
- if (existsParameter(variableName, context)) {
- return true;
- }
- if (existsLocal(variableName, context)) {
- return true;
- }
- if (existsCatchSectionLocal(variableName, context)) {
- return true;
- }
- if (existsForLoopLocal(variableName, context)) {
- return true;
- }
- return existsForeachLoopLocal(variableName, context);
- }
-
- private static boolean existsParameter(@NotNull String variableName,
- PsiElement context) {
- PsiMethod ancestor =
- PsiTreeUtil.getParentOfType(context, PsiMethod.class);
- while (ancestor != null) {
- final PsiParameterList parameterList = ancestor.getParameterList();
- final PsiParameter[] parameters = parameterList.getParameters();
- for (final PsiParameter parameter : parameters) {
- final String parameterName = parameter.getName();
- if (variableName.equals(parameterName)) {
- return true;
- }
- }
- ancestor = PsiTreeUtil.getParentOfType(ancestor, PsiMethod.class);
- }
- return false;
- }
-
- private static boolean existsLocal(@NotNull String variableName,
- PsiElement context) {
- PsiCodeBlock ancestor =
- PsiTreeUtil.getParentOfType(context, PsiCodeBlock.class);
- while (ancestor != null) {
- final PsiStatement[] statements = ancestor.getStatements();
- for (final PsiStatement statement : statements) {
- if (statement instanceof PsiDeclarationStatement) {
- final PsiDeclarationStatement declarationStatement =
- (PsiDeclarationStatement) statement;
- final PsiElement[] elements =
- declarationStatement.getDeclaredElements();
- for (PsiElement element : elements) {
- if (!(element instanceof PsiLocalVariable)) {
- continue;
- }
- final PsiLocalVariable localVariable =
- (PsiLocalVariable) element;
- final String localVariableName =
- localVariable.getName();
- if(variableName.equals(localVariableName)) {
- return true;
- }
- }
- }
- }
- ancestor =
- PsiTreeUtil.getParentOfType(ancestor, PsiCodeBlock.class);
- }
- return false;
- }
-
- private static boolean existsCatchSectionLocal(@NotNull String variableName,
- PsiElement context) {
- PsiCatchSection catchSectionAncestor =
- PsiTreeUtil.getParentOfType(context, PsiCatchSection.class);
- while (catchSectionAncestor != null) {
- final PsiParameter parameter =
- catchSectionAncestor.getParameter();
- if (parameter != null) {
- final String parameterName = parameter.getName();
- if (variableName.equals(parameterName)) {
- return true;
- }
- }
- catchSectionAncestor =
- PsiTreeUtil.getParentOfType(catchSectionAncestor,
- PsiCatchSection.class);
- }
- return false;
- }
-
- private static boolean existsForLoopLocal(@NotNull String variableName,
- PsiElement context) {
- PsiForStatement forLoopAncestor =
- PsiTreeUtil.getParentOfType(context, PsiForStatement.class);
- while (forLoopAncestor != null) {
- final PsiStatement initialization =
- forLoopAncestor.getInitialization();
- if (initialization instanceof PsiDeclarationStatement) {
- final PsiDeclarationStatement declarationStatement =
- (PsiDeclarationStatement) initialization;
- final PsiElement[] elements =
- declarationStatement.getDeclaredElements();
- for (PsiElement element : elements) {
- final PsiLocalVariable localVariable =
- (PsiLocalVariable) element;
- final String localVariableName = localVariable.getName();
- if (variableName.equals(localVariableName)) {
- return true;
- }
- }
- }
- forLoopAncestor = PsiTreeUtil.getParentOfType(forLoopAncestor,
- PsiForStatement.class);
- }
- return false;
- }
-
- private static boolean existsForeachLoopLocal(@NotNull String variableName,
- PsiElement context) {
- PsiForeachStatement forLoopAncestor =
- PsiTreeUtil.getParentOfType(context, PsiForeachStatement.class);
- while (forLoopAncestor != null) {
- final PsiParameter parameter =
- forLoopAncestor.getIterationParameter();
- final String parameterName = parameter.getName();
- if (variableName.equals(parameterName)) {
- return true;
- }
- forLoopAncestor = PsiTreeUtil.getParentOfType(forLoopAncestor,
- PsiForeachStatement.class);
- }
- return false;
+ public static boolean variableNameResolvesToTarget(
+ @NotNull String variableName, @NotNull PsiVariable target,
+ @NotNull PsiElement context) {
+
+ final Project project = context.getProject();
+ final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
+ final PsiResolveHelper resolveHelper = psiFacade.getResolveHelper();
+ final PsiVariable variable =
+ resolveHelper.resolveAccessibleReferencedVariable(
+ variableName, context);
+ return target.equals(variable);
}
public static boolean containsConflictingDeclarations(
- PsiCodeBlock block, PsiCodeBlock parentBlock){
+ PsiCodeBlock block, PsiCodeBlock parentBlock) {
final PsiStatement[] statements = block.getStatements();
- final Set variableNames = new HashSet();
- for(final PsiStatement statement : statements){
+ final Project project = block.getProject();
+ final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
+ final PsiResolveHelper resolveHelper = facade.getResolveHelper();
+ for (final PsiStatement statement : statements) {
if (!(statement instanceof PsiDeclarationStatement)) {
continue;
}
final PsiDeclarationStatement declaration =
- (PsiDeclarationStatement) statement;
- final PsiElement[] declaredElements =
+ (PsiDeclarationStatement)statement;
+ final PsiElement[] variables =
declaration.getDeclaredElements();
- for(PsiElement declaredElement : declaredElements){
- if (!(declaredElement instanceof PsiLocalVariable)) {
+ for (PsiElement variable : variables) {
+ if (!(variable instanceof PsiLocalVariable)) {
continue;
}
- final PsiLocalVariable variable =
- (PsiLocalVariable)declaredElement;
- final String variableName = variable.getName();
- if (variableName == null) {
- continue;
+ final PsiLocalVariable localVariable =
+ (PsiLocalVariable) variable;
+ final PsiVariable target =
+ resolveHelper.resolveAccessibleReferencedVariable(
+ localVariable.getName(), parentBlock);
+ if (target != null) {
+ return true;
}
- variableNames.add(variableName);
}
}
- final ConflictingDeclarationVisitor visitor =
- new ConflictingDeclarationVisitor(variableNames, block);
- parentBlock.accept(visitor);
- return visitor.hasConflictingDeclaration();
- }
-
- private static class ConflictingDeclarationVisitor
- extends JavaRecursiveElementVisitor{
-
- private final Set variableNames;
- private final PsiCodeBlock exceptBlock;
- private boolean hasConflictingDeclaration = false;
-
- ConflictingDeclarationVisitor(@NotNull Set variableNames,
- PsiCodeBlock exceptBlock){
- this.variableNames = variableNames;
- this.exceptBlock = exceptBlock;
- }
-
- @Override public void visitElement(@NotNull PsiElement element){
- if (hasConflictingDeclaration) {
- return;
- }
- super.visitElement(element);
- }
-
- @Override public void visitCodeBlock(PsiCodeBlock block){
- if(hasConflictingDeclaration){
- return;
- }
- if(block.equals(exceptBlock)){
- return;
- }
- super.visitCodeBlock(block);
- }
-
- @Override public void visitVariable(@NotNull PsiVariable variable){
- if(hasConflictingDeclaration){
- return;
- }
- super.visitVariable(variable);
- final String name = variable.getName();
- if(variableNames.contains(name)){
- hasConflictingDeclaration = true;
- }
- }
-
- public boolean hasConflictingDeclaration(){
- return hasConflictingDeclaration;
- }
+ return false;
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryThisInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryThisInspection.java
index 2dd7625f998f..0c9cf1d6a04a 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryThisInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/style/UnnecessaryThisInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2010 Dave Griffith, Bas Leijdekkers
*
* 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.siyeh.ig.style;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
@@ -29,17 +30,20 @@ import org.jetbrains.annotations.NotNull;
public class UnnecessaryThisInspection extends BaseInspection {
+ @Override
@NotNull
public String getDisplayName() {
return InspectionGadgetsBundle.message("unnecessary.this.display.name");
}
+ @Override
@NotNull
protected String buildErrorString(Object... infos) {
return InspectionGadgetsBundle.message(
"unnecessary.this.problem.descriptor");
}
+ @Override
public InspectionGadgetsFix buildFix(Object... infos) {
return new UnnecessaryThisFix();
}
@@ -66,6 +70,7 @@ public class UnnecessaryThisInspection extends BaseInspection {
}
}
+ @Override
public BaseInspectionVisitor buildVisitor() {
return new UnnecessaryThisVisitor();
}
@@ -103,8 +108,13 @@ public class UnnecessaryThisInspection extends BaseInspection {
registerError(qualifierExpression);
return;
}
- if (VariableSearchUtils.existsLocalOrParameter(referenceName,
- expression)) {
+ final PsiElement target = expression.resolve();
+ if (!(target instanceof PsiVariable)) {
+ return;
+ }
+ final PsiVariable variable = (PsiVariable) target;
+ if (!VariableSearchUtils.variableNameResolvesToTarget(
+ referenceName, variable, expression)) {
return;
}
registerError(thisExpression);
@@ -124,24 +134,43 @@ public class UnnecessaryThisInspection extends BaseInspection {
final String methodName = calledMethod.getName();
PsiClass parentClass =
ClassUtils.getContainingClass(expression);
+ final Project project = expression.getProject();
+ final JavaPsiFacade psiFacade =
+ JavaPsiFacade.getInstance(project);
+ final PsiResolveHelper resolveHelper =
+ psiFacade.getResolveHelper();
while (parentClass != null) {
if (qualifierName.equals(parentClass.getName())) {
registerError(thisExpression);
}
- //resolve will point to any _accessible_ method with the same name
final PsiMethod[] methods =
- parentClass.findMethodsByName(methodName,
- true);
- //todo: filter only accessible methods
- if (methods.length > 0) {
- return;
+ parentClass.findMethodsByName(methodName, true);
+ for (PsiMethod method : methods) {
+ final PsiClass containingClass =
+ method.getContainingClass();
+ if (resolveHelper.isAccessible(method,
+ expression, containingClass)) {
+ if (method.hasModifierProperty(
+ PsiModifier.PRIVATE) &&
+ !PsiTreeUtil.isAncestor(containingClass,
+ expression, true)) {
+ continue;
+ }
+ return;
+ }
+
}
parentClass =
ClassUtils.getContainingClass(parentClass);
}
} else {
- if (VariableSearchUtils.existsLocalOrParameter(referenceName,
- expression)) {
+ final PsiElement target = expression.resolve();
+ if (!(target instanceof PsiVariable)) {
+ return;
+ }
+ final PsiVariable variable = (PsiVariable) target;
+ if (!VariableSearchUtils.variableNameResolvesToTarget(
+ referenceName, variable, expression)) {
return;
}
PsiClass parentClass =
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/UnnecessaryThisInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/UnnecessaryThisInspection.java
index 4552710b662c..4edef3d03e70 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/UnnecessaryThisInspection.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/UnnecessaryThisInspection.java
@@ -53,4 +53,20 @@ public class UnnecessaryThisInspection
throwable.printStackTrace();
}
}
+
+ public void foo(String s) {}
+
+ class D{
+
+ private void foo(String s) {}
+ }
+ class C extends D {
+
+ class Box {
+
+ void bar() {
+ UnnecessaryThisInspection.this.foo("");
+ }
+ }
+ }
}
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/expected.xml
index 7491a3413bde..d620f795222c 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/expected.xml
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/unnecessary_this/expected.xml
@@ -14,4 +14,12 @@
Unnecessary 'this' qualifier
<code>this</code> is unnecessary in this context #loc
+
+
+ UnnecessaryThisInspection.java
+ 68
+ Unnecessary 'this' qualifier
+ <code>UnnecessaryThisInspection.this</code> is unnecessary in this context #loc
+
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryThisInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryThisInspectionTest.java
index 04c361bf5325..5e36cc3bd064 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryThisInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryThisInspectionTest.java
@@ -5,6 +5,7 @@ import com.IGInspectionTestCase;
public class UnnecessaryThisInspectionTest extends IGInspectionTestCase {
public void test() throws Exception {
- doTest("com/siyeh/igtest/style/unnecessary_this", new UnnecessaryThisInspection());
+ doTest("com/siyeh/igtest/style/unnecessary_this",
+ new UnnecessaryThisInspection());
}
}
\ No newline at end of file
diff --git a/plugins/android/src/META-INF/plugin.xml b/plugins/android/src/META-INF/plugin.xml
index cf98c409a0bc..d367db87fe0b 100644
--- a/plugins/android/src/META-INF/plugin.xml
+++ b/plugins/android/src/META-INF/plugin.xml
@@ -137,6 +137,7 @@
+
diff --git a/plugins/android/src/org/jetbrains/android/AndroidProblemFileHighlightingFilter.java b/plugins/android/src/org/jetbrains/android/AndroidProblemFileHighlightingFilter.java
new file mode 100644
index 000000000000..3711c925ba59
--- /dev/null
+++ b/plugins/android/src/org/jetbrains/android/AndroidProblemFileHighlightingFilter.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2010 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.android;
+
+import com.android.sdklib.SdkConstants;
+import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.android.facet.AndroidFacet;
+import org.jetbrains.android.resourceManagers.ResourceManager;
+
+/**
+ * @author Eugene.Kudelevsky
+ */
+public class AndroidProblemFileHighlightingFilter implements Condition {
+ private final Project myProject;
+
+ public AndroidProblemFileHighlightingFilter(Project project) {
+ myProject = project;
+ }
+
+ @Override
+ public boolean value(VirtualFile file) {
+ if (file.getFileType() != StdFileTypes.XML) {
+ return false;
+ }
+ if (SdkConstants.FN_ANDROID_MANIFEST_XML.equals(file.getName())) {
+ Module module = ModuleUtil.findModuleForFile(file, myProject);
+ return module != null && AndroidFacet.getInstance(module) != null;
+ }
+
+ VirtualFile parent = file.getParent();
+ if (parent == null) return false;
+ parent = parent.getParent();
+ if (parent == null) return false;
+ return ResourceManager.isResourceDirectory(parent, myProject);
+ }
+}
diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java
index 9c3d3705ed13..f54ecf418262 100644
--- a/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java
+++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidAptCompiler.java
@@ -124,7 +124,8 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler {
return;
}
String className = FileUtil.getNameWithoutExtension(aptItem.myGeneratedFile);
- AndroidCompileUtil.removeDuplicatingClasses(aptItem.myModule, aptItem.myPackage, className, aptItem.myGeneratedFile);
+ AndroidCompileUtil.removeDuplicatingClasses(aptItem.myModule, aptItem.myPackage, className, aptItem.myGeneratedFile,
+ aptItem.mySourceRootPath);
}
});
}
diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java
index 3d4facc7a179..e1be4068fbff 100644
--- a/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java
+++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidCompileUtil.java
@@ -27,9 +27,7 @@ import com.intellij.openapi.compiler.GeneratingCompiler;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ContentEntry;
-import com.intellij.openapi.roots.ModifiableRootModel;
-import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.*;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
@@ -187,16 +185,24 @@ public class AndroidCompileUtil {
// must be invoked in a read action!
public static void removeDuplicatingClasses(final Module module, @NotNull final String packageName, @NotNull String className,
- @Nullable final File classFile) {
+ @Nullable final File classFile, String sourceRootPath) {
+ if (sourceRootPath == null) {
+ return;
+ }
+ VirtualFile sourceRoot = LocalFileSystem.getInstance().findFileByPath(sourceRootPath);
+ if (sourceRoot == null) {
+ return;
+ }
final Project project = module.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final String interfaceQualifiedName = packageName + '.' + className;
PsiClass[] classes = facade.findClasses(interfaceQualifiedName, GlobalSearchScope.moduleScope(module));
+ final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
for (PsiClass c : classes) {
PsiFile psiFile = c.getContainingFile();
if (className.equals(FileUtil.getNameWithoutExtension(psiFile.getName()))) {
VirtualFile virtualFile = psiFile.getVirtualFile();
- if (virtualFile != null) {
+ if (virtualFile != null && projectFileIndex.getSourceRootForFile(virtualFile) == sourceRoot) {
final String path = virtualFile.getPath();
File f = new File(path);
if (!f.equals(classFile) && f.exists()) {
diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java
index 38486a4395d7..e20427b2ae53 100644
--- a/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java
+++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidIdlCompiler.java
@@ -114,6 +114,7 @@ public class AndroidIdlCompiler implements SourceGeneratingCompiler {
final IAndroidTarget myAndroidTarget;
final File myGeneratedFile;
final String myPackageName;
+ final String mySourceRootPath;
public IdlGenerationItem(@NotNull Module module,
@NotNull VirtualFile file,
@@ -126,6 +127,7 @@ public class AndroidIdlCompiler implements SourceGeneratingCompiler {
myTestSource = testSource;
myAndroidTarget = androidTarget;
myPackageName = packageName;
+ mySourceRootPath = sourceRootPath;
myGeneratedFile =
new File(sourceRootPath, packageName.replace('.', File.separatorChar) + File.separator + file.getNameWithoutExtension() + ".java");
}
@@ -222,7 +224,9 @@ public class AndroidIdlCompiler implements SourceGeneratingCompiler {
public void run() {
if (idlItem.myModule.getProject().isDisposed()) return;
String className = FileUtil.getNameWithoutExtension(idlItem.myGeneratedFile);
- AndroidCompileUtil.removeDuplicatingClasses(idlItem.myModule, idlItem.myPackageName, className, idlItem.myGeneratedFile);
+ AndroidCompileUtil.removeDuplicatingClasses(idlItem.myModule, idlItem.myPackageName, className,
+ idlItem.myGeneratedFile.exists() ? idlItem.myGeneratedFile : null,
+ idlItem.mySourceRootPath);
}
});
}
diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java
index 38b7f9dfeeba..e5eb49cd9069 100644
--- a/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java
+++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidMavenResourcesCompiler.java
@@ -106,7 +106,8 @@ public class AndroidMavenResourcesCompiler implements SourceGeneratingCompiler {
ApplicationManager.getApplication().runReadAction(new Runnable() {
public void run() {
String className = FileUtil.getNameWithoutExtension(genItem.myGeneratedFile);
- AndroidCompileUtil.removeDuplicatingClasses(genItem.myModule, genItem.myPackage, className, genItem.myGeneratedFile);
+ AndroidCompileUtil.removeDuplicatingClasses(genItem.myModule, genItem.myPackage, className, genItem.myGeneratedFile,
+ genItem.mySourceRootPath);
}
});
}
@@ -132,12 +133,14 @@ public class AndroidMavenResourcesCompiler implements SourceGeneratingCompiler {
final Module myModule;
final String myPackage;
final File myGeneratedFile;
+ final String mySourceRootPath;
private MyGenerationItem(@NotNull Module module, @NotNull String aPackage, @NotNull String sourceRootPath) {
myModule = module;
myPackage = aPackage;
myGeneratedFile =
new File(sourceRootPath, aPackage.replace('.', File.separatorChar) + File.separator + AndroidUtils.R_JAVA_FILENAME);
+ mySourceRootPath = sourceRootPath;
}
@Nullable
diff --git a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java
index 8040b125acf8..d1bef6b08245 100644
--- a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java
+++ b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java
@@ -455,7 +455,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
myConfiguration.ASSETS_FOLDER_RELATIVE_PATH = '/' + getAndCheckRelativePath(absAssetsPath, false);
String absApkPath = (String)myApkPathCombo.getComboBox().getEditor().getItem();
- if (absResPath.length() == 0) {
+ if (absApkPath.length() == 0) {
myConfiguration.APK_PATH = "";
}
else {
diff --git a/plugins/android/src/org/jetbrains/android/facet/AndroidResourceFilesListener.java b/plugins/android/src/org/jetbrains/android/facet/AndroidResourceFilesListener.java
index 63c8133334e0..bbb49e855a69 100644
--- a/plugins/android/src/org/jetbrains/android/facet/AndroidResourceFilesListener.java
+++ b/plugins/android/src/org/jetbrains/android/facet/AndroidResourceFilesListener.java
@@ -142,7 +142,8 @@ class AndroidResourceFilesListener extends VirtualFileAdapter {
Manifest manifest = myFacet.getManifest();
String aPackage = manifest != null ? manifest.getPackage().getValue() : null;
if (myCachedPackage != null && !myCachedPackage.equals(aPackage)) {
- AndroidCompileUtil.removeDuplicatingClasses(myModule, myCachedPackage, AndroidUtils.R_CLASS_NAME, null);
+ String aptGenDirPath = myFacet.getAptGenSourceRootPath();
+ AndroidCompileUtil.removeDuplicatingClasses(myModule, myCachedPackage, AndroidUtils.R_CLASS_NAME, null, aptGenDirPath);
}
myCachedPackage = aPackage;
myFacet.getLocalResourceManager().invalidateAttributeDefinitions();
diff --git a/plugins/android/src/org/jetbrains/android/resourceManagers/ResourceManager.java b/plugins/android/src/org/jetbrains/android/resourceManagers/ResourceManager.java
index 32ae1e47a73a..2faaaac0478d 100644
--- a/plugins/android/src/org/jetbrains/android/resourceManagers/ResourceManager.java
+++ b/plugins/android/src/org/jetbrains/android/resourceManagers/ResourceManager.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtil;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -332,13 +333,21 @@ public abstract class ResourceManager {
return dir != null && isResourceDirectory(dir);
}
+ public static boolean isResourceDirectory(VirtualFile dir, Project project) {
+ Module module = ModuleUtil.findModuleForFile(dir, project);
+ if (module != null) {
+ AndroidFacet facet = AndroidFacet.getInstance(module);
+ return facet != null && facet.getLocalResourceManager().isResourceDir(dir);
+ }
+ return false;
+ }
+
public static boolean isResourceDirectory(PsiDirectory dir) {
// check facet settings
VirtualFile vf = dir.getVirtualFile();
- Module module = ModuleUtil.findModuleForPsiElement(dir);
- if (module != null) {
- AndroidFacet facet = AndroidFacet.getInstance(module);
- return facet != null && facet.getLocalResourceManager().isResourceDir(vf);
+
+ if (isResourceDirectory(vf, dir.getProject())) {
+ return true;
}
// method can be invoked for system resource dir, so we should check it
diff --git a/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java b/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java
index e722e92751b8..c66569c778c0 100644
--- a/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java
+++ b/plugins/android/src/org/jetbrains/android/util/AndroidUtils.java
@@ -119,6 +119,8 @@ public class AndroidUtils {
public static final String EXT_NATIVE_LIB = "so";
@NonNls public static final String RES_OVERLAY_DIR_NAME = "res-overlay";
+ private static final int TIMEOUT = 30000;
+
private AndroidUtils() {
}
@@ -345,7 +347,7 @@ public class AndroidUtils {
device.executeShellCommand(command, receiver, 0);
}
else {
- device.executeShellCommand(command, receiver);
+ device.executeShellCommand(command, receiver, TIMEOUT);
}
if (infinite && !receiver.isCancelled()) {
attempt++;
diff --git a/plugins/ant/tests/data/psi/Dirname_u.txt b/plugins/ant/tests/data/psi/Dirname_u.txt
new file mode 100644
index 000000000000..ea49effbd1e5
--- /dev/null
+++ b/plugins/ant/tests/data/psi/Dirname_u.txt
@@ -0,0 +1,57 @@
+XmlFile:Dirname.ant
+ PsiElement(XML_DOCUMENT)
+ PsiElement(XML_PROLOG)
+
+ XmlTag:project
+ XmlToken:XML_START_TAG_START('<')
+ XmlToken:XML_NAME('project')
+ PsiWhiteSpace(' ')
+ PsiElement(XML_ATTRIBUTE)
+ XmlToken:XML_NAME('default')
+ XmlToken:XML_EQ('=')
+ PsiElement(XML_ATTRIBUTE_VALUE)
+ XmlToken:XML_ATTRIBUTE_VALUE_START_DELIMITER('"')
+ XmlToken:XML_ATTRIBUTE_VALUE_TOKEN('A')
+ XmlToken:XML_ATTRIBUTE_VALUE_END_DELIMITER('"')
+ XmlToken:XML_TAG_END('>')
+ XmlText
+ PsiWhiteSpace('\n ')
+ XmlTag:dirname
+ XmlToken:XML_START_TAG_START('<')
+ XmlToken:XML_NAME('dirname')
+ PsiWhiteSpace(' ')
+ PsiElement(XML_ATTRIBUTE)
+ XmlToken:XML_NAME('property')
+ XmlToken:XML_EQ('=')
+ PsiElement(XML_ATTRIBUTE_VALUE)
+ XmlToken:XML_ATTRIBUTE_VALUE_START_DELIMITER('"')
+ XmlToken:XML_ATTRIBUTE_VALUE_TOKEN('prop')
+ XmlToken:XML_ATTRIBUTE_VALUE_END_DELIMITER('"')
+ PsiWhiteSpace(' ')
+ PsiElement(XML_ATTRIBUTE)
+ XmlToken:XML_NAME('file')
+ XmlToken:XML_EQ('=')
+ PsiElement(XML_ATTRIBUTE_VALUE)
+ XmlToken:XML_ATTRIBUTE_VALUE_START_DELIMITER('"')
+ XmlToken:XML_ATTRIBUTE_VALUE_TOKEN('${ant.file}')
+ XmlToken:XML_ATTRIBUTE_VALUE_END_DELIMITER('"')
+ XmlToken:XML_EMPTY_ELEMENT_END('/>')
+ XmlText
+ PsiWhiteSpace('\n ')
+ XmlTag:target
+ XmlToken:XML_START_TAG_START('<')
+ XmlToken:XML_NAME('target')
+ PsiWhiteSpace(' ')
+ PsiElement(XML_ATTRIBUTE)
+ XmlToken:XML_NAME('name')
+ XmlToken:XML_EQ('=')
+ PsiElement(XML_ATTRIBUTE_VALUE)
+ XmlToken:XML_ATTRIBUTE_VALUE_START_DELIMITER('"')
+ XmlToken:XML_ATTRIBUTE_VALUE_TOKEN('A')
+ XmlToken:XML_ATTRIBUTE_VALUE_END_DELIMITER('"')
+ XmlToken:XML_EMPTY_ELEMENT_END('/>')
+ XmlText
+ PsiWhiteSpace('\n')
+ XmlToken:XML_END_TAG_START('')
+ XmlToken:XML_NAME('project')
+ XmlToken:XML_TAG_END('>')
\ No newline at end of file
diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java b/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java
index fa52f2fd258a..f9559579f0fa 100644
--- a/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java
+++ b/plugins/copyright/src/com/maddyhome/idea/copyright/util/FileTypeUtil.java
@@ -162,7 +162,6 @@ public class FileTypeUtil
{
line = StringUtil.trimStart(StringUtil.trimStart(line.trim(), pre.toString()), open);
line = StringUtil.trimEnd(line, close);
- if (line.isEmpty()) continue;
preview.append(leader).append(pre);
int len = 0;
if (pre.length() > 0 && line.length() > 0)
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java
index 27067213a990..8b7ed5b6ba98 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManager.java
@@ -126,6 +126,7 @@ public class EclipseModuleManager implements PersistentStateComponent{
public void setForceConfigureJDK() {
myForceConfigureJDK = true;
+ myExpectedModuleSourcePlace++;
}
public void registerEclipseLibUrl(String url) {
diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml
index 2079f73db038..aabff7b1f236 100644
--- a/plugins/git4idea/git4idea.iml
+++ b/plugins/git4idea/git4idea.iml
@@ -4,9 +4,9 @@
+
-
diff --git a/plugins/git4idea/src/git4idea/GitReference.java b/plugins/git4idea/src/git4idea/GitReference.java
index 66b960e655bc..5025d5b23f10 100644
--- a/plugins/git4idea/src/git4idea/GitReference.java
+++ b/plugins/git4idea/src/git4idea/GitReference.java
@@ -37,7 +37,7 @@ public abstract class GitReference implements Comparable {
* @param name the used name
*/
public GitReference(@NotNull String name) {
- myName = name;
+ myName = new String(name);
}
/**
diff --git a/plugins/git4idea/src/git4idea/GitTag.java b/plugins/git4idea/src/git4idea/GitTag.java
index acc607b96661..be875f1af791 100644
--- a/plugins/git4idea/src/git4idea/GitTag.java
+++ b/plugins/git4idea/src/git4idea/GitTag.java
@@ -76,7 +76,7 @@ public class GitTag extends GitReference {
if (line.length() == 0) {
continue;
}
- tags.add(line);
+ tags.add(new String(line));
}
}
diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java
index b131efa0b8fb..45b6bddfb3c1 100644
--- a/plugins/git4idea/src/git4idea/GitUtil.java
+++ b/plugins/git4idea/src/git4idea/GitUtil.java
@@ -713,7 +713,7 @@ public class GitUtil {
if (file == null || path.length == 0) return null;
VirtualFile current = file;
- final List backTrace = new LinkedList();
+ final List backTrace = new ArrayList();
int idx = path.length - 1;
while (current != null) {
if (SystemInfo.isFileSystemCaseSensitive ? current.getName().equals(path[idx]) : current.getName().equalsIgnoreCase(path[idx])) {
diff --git a/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java b/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java
index b48d47c575e3..ff3a683a9c5c 100644
--- a/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java
+++ b/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java
@@ -35,7 +35,10 @@ import git4idea.i18n.GitBundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* Base class for actions that affect the entire git repository.
@@ -45,7 +48,7 @@ public abstract class GitRepositoryAction extends DumbAwareAction {
/**
* The task delayed until end of the primary action. These tasks happen after repository refresh.
*/
- final LinkedList myDelayedTasks = new LinkedList();
+ final List myDelayedTasks = new ArrayList();
/**
* {@inheritDoc}
diff --git a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java
index 7b88a704648f..a317c3e77027 100644
--- a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java
+++ b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java
@@ -122,7 +122,7 @@ public class GitChangeUtils {
}
public static Collection parseDiffForPaths(final String rootPath, final StringScanner s) throws VcsException {
- final Collection result = new LinkedList();
+ final Collection result = new ArrayList();
while (s.hasMoreData()) {
if (s.isEol()) {
diff --git a/plugins/git4idea/src/git4idea/changes/GitOutgoingChangesProvider.java b/plugins/git4idea/src/git4idea/changes/GitOutgoingChangesProvider.java
index 81fa4983cf8c..78bb134f20f6 100644
--- a/plugins/git4idea/src/git4idea/changes/GitOutgoingChangesProvider.java
+++ b/plugins/git4idea/src/git4idea/changes/GitOutgoingChangesProvider.java
@@ -98,7 +98,7 @@ public class GitOutgoingChangesProvider implements VcsOutgoingChangesProvider result = new ArrayList(revisions);
for (Iterator iterator = result.iterator(); iterator.hasNext();) {
final U t = iterator.next();
- final LinkedList branches = new LinkedList();
+ final List branches = new ArrayList();
// we do not use passed revision convertor since it returns just recent commit on repo
final VcsRevisionNumber revision = GitHistoryUtils.getCurrentRevision(myProject, filePatchConvertor.convert(t), null);
if (revision == null) continue; // will be true for new files; they are anyway outgoing
diff --git a/plugins/git4idea/src/git4idea/commands/GitHandler.java b/plugins/git4idea/src/git4idea/commands/GitHandler.java
index 9e39a986c89b..d3f11f0e021b 100644
--- a/plugins/git4idea/src/git4idea/commands/GitHandler.java
+++ b/plugins/git4idea/src/git4idea/commands/GitHandler.java
@@ -48,7 +48,7 @@ public abstract class GitHandler {
protected final GitCommand myCommand;
private final HashSet myIgnoredErrorCodes = new HashSet(); // Error codes that are ignored for the handler
- private final List myErrors = Collections.synchronizedList(new LinkedList());
+ private final List myErrors = Collections.synchronizedList(new ArrayList());
private static final Logger log = Logger.getInstance(GitHandler.class.getName());
final GeneralCommandLine myCommandLine;
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
diff --git a/plugins/git4idea/src/git4idea/history/GitLogParser.java b/plugins/git4idea/src/git4idea/history/GitLogParser.java
index face9e3b0bd6..1d226a19aca2 100644
--- a/plugins/git4idea/src/git4idea/history/GitLogParser.java
+++ b/plugins/git4idea/src/git4idea/history/GitLogParser.java
@@ -161,10 +161,10 @@ class GitLogParser {
line = infoAndPath[0];
if (infoAndPath.length > 1) {
// taking the last element, thus avoiding possible blank line
- final List nameAndPathSplit = new LinkedList(Arrays.asList(infoAndPath[infoAndPath.length-1].split("[\\s]")));
+ final List nameAndPathSplit = new ArrayList(Arrays.asList(infoAndPath[infoAndPath.length - 1].split("[\\s]")));
// not relying that separator is tab => so splitting by any whitespace.
// Then removing blank (or whitespace) lines which could appear by this splitting:
- for (Iterator it = nameAndPathSplit.iterator(); it.hasNext(); ) {
+ for (Iterator it = nameAndPathSplit.iterator(); it.hasNext();) {
if (it.next().trim().isEmpty()) {
it.remove();
}
diff --git a/plugins/git4idea/src/git4idea/history/GitLogRecord.java b/plugins/git4idea/src/git4idea/history/GitLogRecord.java
index 240ef0318d01..5d2f34aa6199 100644
--- a/plugins/git4idea/src/git4idea/history/GitLogRecord.java
+++ b/plugins/git4idea/src/git4idea/history/GitLogRecord.java
@@ -70,15 +70,19 @@ class GitLogRecord {
return res;
}
+ private String lookup(GitLogParser.GitLogOption key) {
+ return shortBuffer(myOptions.get(key));
+ }
+
// trivial access methods
- String getHash() { return myOptions.get(HASH); }
- String getShortHash() { return myOptions.get(SHORT_HASH); }
- String getAuthorName() { return myOptions.get(AUTHOR_NAME); }
- String getAuthorEmail() { return myOptions.get(AUTHOR_EMAIL); }
- String getCommitterName() { return myOptions.get(COMMITTER_NAME); }
- String getCommitterEmail() { return myOptions.get(COMMITTER_EMAIL); }
- String getSubject() { return myOptions.get(SUBJECT); }
- String getBody() { return myOptions.get(BODY); }
+ String getHash() { return lookup(HASH); }
+ String getShortHash() { return lookup(SHORT_HASH); }
+ String getAuthorName() { return lookup(AUTHOR_NAME); }
+ String getAuthorEmail() { return lookup(AUTHOR_EMAIL); }
+ String getCommitterName() { return lookup(COMMITTER_NAME); }
+ String getCommitterEmail() { return lookup(COMMITTER_EMAIL); }
+ String getSubject() { return lookup(SUBJECT); }
+ String getBody() { return lookup(BODY); }
// access methods with some formatting or conversion
@@ -101,11 +105,11 @@ class GitLogRecord {
}
String[] getParentsShortHashes() {
- return myOptions.get(SHORT_PARENTS).split(" ");
+ return lookup(SHORT_PARENTS).split(" ");
}
String[] getParentsHashes() {
- return myOptions.get(PARENTS).split(" ");
+ return lookup(PARENTS).split(" ");
}
/**
@@ -117,17 +121,17 @@ class GitLogRecord {
Pair, List> getTagsAndBranches(Collection allBranchesSet) {
final String decorate = myOptions.get(REF_NAMES);
final String[] refNames = parseRefNames(decorate);
- final List tags = refNames.length > 0 ? new LinkedList() : Collections.emptyList();
- final List branches = refNames.length > 0 ? new LinkedList() : Collections.emptyList();
+ final List tags = refNames.length > 0 ? new ArrayList() : Collections.emptyList();
+ final List branches = refNames.length > 0 ? new ArrayList() : Collections.emptyList();
for (String refName : refNames) {
if (allBranchesSet.contains(refName)) {
// also some gits can return ref name twice (like (HEAD, HEAD), so check we will show it only once)
if (!branches.contains(refName)) {
- branches.add(refName);
+ branches.add(shortBuffer(refName));
}
} else {
if (!tags.contains(refName)) {
- tags.add(refName);
+ tags.add(shortBuffer(refName));
}
}
}
@@ -142,4 +146,8 @@ class GitLogRecord {
return refs.split(", ");
}
+ private static String shortBuffer(String raw) {
+ return new String(raw);
+ }
+
}
diff --git a/plugins/git4idea/src/git4idea/history/GitUsersComponent.java b/plugins/git4idea/src/git4idea/history/GitUsersComponent.java
index 2d02aa2071a3..2411513bc72e 100644
--- a/plugins/git4idea/src/git4idea/history/GitUsersComponent.java
+++ b/plugins/git4idea/src/git4idea/history/GitUsersComponent.java
@@ -174,7 +174,7 @@ public class GitUsersComponent {
private boolean myStartReached;
private UsersData() {
- myUsers = new LinkedList();
+ myUsers = new ArrayList();
final long now = System.currentTimeMillis();
myCloserDate = new UpdatedReference(now);
myEarlierDate = new UpdatedReference(now + 1);
@@ -327,7 +327,7 @@ public class GitUsersComponent {
final long earlierUpdate = in.readLong();
data.setEarlierDate(new UpdatedReference(earlierDate, earlierUpdate));
- final List users = new LinkedList();
+ final List users = new ArrayList();
final int size = in.readInt();
for (int i = 0; i < size; i++) {
users.add(in.readUTF());
diff --git a/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java b/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java
index bd692c40ce6a..3f3cd75ce51b 100644
--- a/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java
+++ b/plugins/git4idea/src/git4idea/history/browser/ChangesFilter.java
@@ -36,7 +36,7 @@ public class ChangesFilter {
private MemoryFilter myResult;
protected Merger() {
- myFilters = new LinkedList();
+ myFilters = new ArrayList();
}
protected abstract boolean acceptImpl(MemoryFilter filter);
@@ -81,7 +81,7 @@ public class ChangesFilter {
final Merger[] mergers = {new UsersMerger()};
if (filters.isEmpty()) return Collections.emptyList();
- final List result = new LinkedList();
+ final List result = new ArrayList();
for (Filter filter : filters) {
boolean taken = false;
for (Merger combiner : mergers) {
@@ -361,7 +361,7 @@ public class ChangesFilter {
// todo optimization here
public boolean addPath(final VirtualFile vf) {
final Collection filesWeAlreadyHave = myMap.values();
- final Collection childrenToRemove = new LinkedList();
+ final Collection childrenToRemove = new ArrayList();
for (VirtualFile current : filesWeAlreadyHave) {
if (current.equals(vf)) return false; // doesnt add exact same
if (VfsUtil.isAncestor(vf, current, false)) {
diff --git a/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java b/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java
index cf9b6b1c6502..4aa724e8442b 100644
--- a/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java
+++ b/plugins/git4idea/src/git4idea/history/browser/CherryPicker.java
@@ -51,10 +51,10 @@ public class CherryPicker {
myListsCache = listsCache;
myAccess = access;
- myExceptions = new LinkedList();
- myWarnings = new LinkedList();
+ myExceptions = new ArrayList();
+ myWarnings = new ArrayList();
- myDirtyFiles = new LinkedList();
+ myDirtyFiles = new ArrayList();
myMessagesInOrder = new ArrayList(hashes.size());
myFilesToMove = new HashMap>();
}
diff --git a/plugins/git4idea/src/git4idea/history/browser/GitLogHelper.java b/plugins/git4idea/src/git4idea/history/browser/GitLogHelper.java
index fa6f1fed1d33..9e88a0b5d346 100644
--- a/plugins/git4idea/src/git4idea/history/browser/GitLogHelper.java
+++ b/plugins/git4idea/src/git4idea/history/browser/GitLogHelper.java
@@ -30,7 +30,7 @@ public class GitLogHelper {
@NotNull
public Portion loadPortion(final Collection startingPoints, final Date beforePoint, final Date afterPoint,
final Collection filtersIn, int maxCnt, List branches) throws VcsException {
- final Collection filters = new LinkedList(filtersIn);
+ final Collection filters = new ArrayList(filtersIn);
if (beforePoint != null) {
filters.add(new ChangesFilter.BeforeDate(new Date(beforePoint.getTime() - 1)));
}
diff --git a/plugins/git4idea/src/git4idea/history/browser/GitLogTree.java b/plugins/git4idea/src/git4idea/history/browser/GitLogTree.java
index 7c8491bc0e21..5e53324d1d5a 100644
--- a/plugins/git4idea/src/git4idea/history/browser/GitLogTree.java
+++ b/plugins/git4idea/src/git4idea/history/browser/GitLogTree.java
@@ -114,7 +114,7 @@ public class GitLogTree implements GitTreeViewI {
myMainSplitter.setDividerWidth(3);
myFiltersSplitter.setDividerWidth(3);
- myInitWaiters = new LinkedList();
+ myInitWaiters = new ArrayList();
myCommitsList = new JBList();
myController.init();
}
@@ -1547,7 +1547,7 @@ public class GitLogTree implements GitTreeViewI {
if (wasEmpty) {
myFiltering.addFilter(myFilter);
} else {
- final List toRemove = new LinkedList();
+ final List toRemove = new ArrayList();
for (StructureNode child : getChildren()) {
final VirtualFile file = child.getFile();
if (! myFilter.containsFile(file)) {
@@ -1657,7 +1657,7 @@ public class GitLogTree implements GitTreeViewI {
myText = text;
myType = type;
myIcon = icon;
- myChildren = myAllowsChildren ? new LinkedList() : Collections.emptyList();
+ myChildren = myAllowsChildren ? new ArrayList() : Collections.emptyList();
myDescriptor = new PresentableNodeDescriptor(myProject, myParent == null ? null : myParent.getDescriptor()) {
@Override
public PresentableNodeDescriptor getChildToHighlightAt(int index) {
diff --git a/plugins/git4idea/src/git4idea/history/browser/GitTreeController.java b/plugins/git4idea/src/git4idea/history/browser/GitTreeController.java
index 23cb9c4a49a4..b15eaf8f061f 100644
--- a/plugins/git4idea/src/git4idea/history/browser/GitTreeController.java
+++ b/plugins/git4idea/src/git4idea/history/browser/GitTreeController.java
@@ -34,6 +34,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Alarm;
import com.intellij.util.Consumer;
import com.intellij.util.Processor;
+import com.intellij.util.SmartList;
import com.intellij.util.containers.SLRUCache;
import git4idea.GitVcs;
import git4idea.changes.GitChangeUtils;
@@ -158,8 +159,8 @@ class GitTreeController implements ManageGitTreeView {
private void loadCommitsUsingMemoryAndNativeFilters(final Collection startingPoints, final Pair beforePoint,
final Date afterPoint, final Collection filters, final int maxCnt) throws VcsException {
assert maxCnt > 0;
- final List memoryFilters = new LinkedList();
- final List commandFilters = new LinkedList();
+ final List memoryFilters = new SmartList();
+ final List commandFilters = new SmartList();
for (ChangesFilter.Filter filter : filters) {
final ChangesFilter.CommandParametersFilter commandFilter = filter.getCommandParametersFilter();
if (commandFilter == null) {
@@ -319,8 +320,8 @@ class GitTreeController implements ManageGitTreeView {
}
private void loadTagsNBranches() {
- final List branches = new LinkedList();
- final List tags = new LinkedList();
+ final List branches = new ArrayList();
+ final List tags = new ArrayList();
try {
myAccess.loadAllBranches(branches);
@@ -381,7 +382,7 @@ class GitTreeController implements ManageGitTreeView {
myAlarm.addRequest(new Runnable() {
public void run() {
// start from beginning
- final List> wayList = new LinkedList>();
+ final List> wayList = new SmartList>();
while (true) {
final Pair startFrom = wayList.isEmpty() ? null : wayList.get(wayList.size() - 1);
@@ -438,7 +439,7 @@ class GitTreeController implements ManageGitTreeView {
final Application application = ApplicationManager.getApplication();
myAlarm.addRequest(new Runnable() {
public void run() {
- final List loaded = new LinkedList();
+ final List loaded = new ArrayList();
final Set requested = new HashSet(hashes.size());
for (SHAHash hash : hashes) {
requested.add(GitChangeUtils.longForSHAHash(hash.getValue()));
@@ -483,11 +484,11 @@ class GitTreeController implements ManageGitTreeView {
}
public List getAllBranchesOrdered() {
- return new ArrayList(myBranches.get());
+ return Collections.unmodifiableList(myBranches.get());
}
public List getAllTagsOrdered() {
- return new ArrayList(myTags.get());
+ return Collections.unmodifiableList(myTags.get());
}
public boolean isInitialized() {
@@ -566,7 +567,7 @@ class GitTreeController implements ManageGitTreeView {
myLock = new Object();
myStartingPoints = new HashSet();
myFilters = new HashSet();
- myContinuationPoints = new LinkedList>();
+ myContinuationPoints = new SmartList>();
}
public boolean isDirty() {
diff --git a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java
index 6e19dce17cf1..f2239f97b56c 100644
--- a/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java
+++ b/plugins/git4idea/src/git4idea/history/browser/LowLevelAccessImpl.java
@@ -50,7 +50,7 @@ public class LowLevelAccessImpl implements LowLevelAccess {
@NotNull final Collection endPoints,
@NotNull final Collection