Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anna Kozlova
2013-12-18 12:00:21 +04:00
10 changed files with 58 additions and 44 deletions
@@ -76,7 +76,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
final LookupImpl lookup = invokeCompletion(getTestName(false) + ".html");
assertPreferredItems(0, "p", "param", "pre");
incUseCount(lookup, 2);
assertPreferredItems(1, "p", "pre", "param");
assertPreferredItems(0, "p", "pre", "param");
}
public void testUppercaseMatters2() throws Throwable {
@@ -150,8 +150,8 @@ public abstract class VirtualFile extends UserDataHolderBase implements Modifica
* @return the presentable URL.
* @see VirtualFileSystem#extractPresentableUrl
*/
@NotNull
public final String getPresentableUrl() {
if (!isValid()) return null;
return getFileSystem().extractPresentableUrl(getPath());
}
@@ -344,7 +344,7 @@ public class CompletionLookupArranger extends LookupArranger {
for (int i = 0; i < items.size(); i++) {
LookupElement item = items.get(i);
boolean isTemplate = isLiveTemplate(item);
if (isAlphaSorted() && isPrefixItem(lookup, item, true) && !isTemplate ||
if (isPrefixItem(lookup, item, true) && !isTemplate ||
item.getLookupString().equals(selectedText)) {
return i;
}
@@ -29,7 +29,7 @@ import com.intellij.psi.PsiDirectoryContainer;
import com.intellij.psi.PsiElement;
public class FindInPathAction extends AnAction implements DumbAware {
static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("FindInPath", ToolWindowId.FIND, false);
public static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("Find in Path", ToolWindowId.FIND, false);
{ // enabled in modal content for find in path <-> replace in path modal dialog transition
setEnabledInModalContext(true);
@@ -17,12 +17,12 @@
package com.intellij.find.replaceInProject;
import com.intellij.find.*;
import com.intellij.find.actions.FindInPathAction;
import com.intellij.find.findInProject.FindInProjectManager;
import com.intellij.find.impl.FindInProjectUtil;
import com.intellij.notification.NotificationGroup;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.components.ServiceManager;
@@ -39,7 +39,6 @@ import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiDocumentManager;
@@ -58,7 +57,7 @@ import javax.swing.*;
import java.util.*;
public class ReplaceInProjectManager {
static final NotificationGroup NOTIFICATION_GROUP = NotificationGroup.toolWindowGroup("FindInPath", ToolWindowId.FIND, false);
static final NotificationGroup NOTIFICATION_GROUP = FindInPathAction.NOTIFICATION_GROUP;
private final Project myProject;
private boolean myIsFindInProgress = false;
@@ -46,7 +46,7 @@ public abstract class ExecutableValidator {
private static final Logger LOG = Logger.getInstance(ExecutableValidator.class);
private final NotificationGroup myNotificationGroup = new NotificationGroup("External Executable Critical Failures",
private static final NotificationGroup myNotificationGroup = new NotificationGroup("External Executable Critical Failures",
STICKY_BALLOON, true);
@NotNull protected final Project myProject;
@NotNull private final NotificationsManager myNotificationManager;
@@ -24,6 +24,7 @@ import com.intellij.ui.MultilineTreeCellRenderer;
import com.intellij.ui.SimpleColoredComponent;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -137,12 +138,8 @@ public class NewErrorTreeRenderer extends MultilineTreeCellRenderer {
}
}
protected void initComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final ErrorTreeElement element = getElement(value);
if(element instanceof GroupingElement) {
setFont(getFont().deriveFont(Font.BOLD));
}
@NotNull
static String calcPrefix(@Nullable ErrorTreeElement element) {
if(element instanceof SimpleMessageElement || element instanceof NavigatableMessageElement) {
String prefix = element.getKind().getPresentableText();
@@ -151,9 +148,19 @@ public class NewErrorTreeRenderer extends MultilineTreeCellRenderer {
if (!StringUtil.isEmpty(rendPrefix)) prefix += rendPrefix + " ";
}
setText(element.getText(), prefix);
return prefix;
}
else if (element != null){
return "";
}
protected void initComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
final ErrorTreeElement element = getElement(value);
if(element instanceof GroupingElement) {
setFont(getFont().deriveFont(Font.BOLD));
}
String prefix = calcPrefix(element);
if (element != null) {
String[] text = element.getText();
if (text == null) {
text = ArrayUtil.EMPTY_STRING_ARRAY;
@@ -161,7 +168,7 @@ public class NewErrorTreeRenderer extends MultilineTreeCellRenderer {
if(text.length > 0 && text[0] == null) {
text[0] = "";
}
setText(text, null);
setText(text, prefix);
}
Icon icon = null;
@@ -39,6 +39,8 @@ import com.intellij.ui.content.MessageView;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.Alarm;
import com.intellij.util.EditSourceOnDoubleClickHandler;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.MutableErrorTreeView;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
@@ -53,6 +55,7 @@ import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Collections;
import java.util.List;
public class NewErrorTreeViewPanel extends JPanel implements DataProvider, OccurenceNavigator, MutableErrorTreeView, CopyProvider {
@@ -184,16 +187,21 @@ public class NewErrorTreeViewPanel extends JPanel implements DataProvider, Occur
@Override
public void performCopy(@NotNull DataContext dataContext) {
final ErrorTreeNodeDescriptor descriptor = getSelectedNodeDescriptor();
if (descriptor != null) {
final String[] lines = descriptor.getElement().getText();
CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(lines, "\n")));
List<ErrorTreeNodeDescriptor> descriptors = getSelectedNodeDescriptors();
if (!descriptors.isEmpty()) {
CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(descriptors, new Function<ErrorTreeNodeDescriptor, String>() {
@Override
public String fun(ErrorTreeNodeDescriptor descriptor) {
ErrorTreeElement element = descriptor.getElement();
return NewErrorTreeRenderer.calcPrefix(element) + StringUtil.join(element.getText(), "\n");
}
}, "\n")));
}
}
@Override
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
return getSelectedNodeDescriptor() != null;
return !getSelectedNodeDescriptors().isEmpty();
}
@Override
@@ -259,11 +267,6 @@ public class NewErrorTreeViewPanel extends JPanel implements DataProvider, Occur
return false;
}
public void clearMessages() {
myErrorViewStructure.clear();
myBuilder.updateTree();
}
public void updateTree() {
if (!myIsDisposed) {
myBuilder.updateTree();
@@ -346,16 +349,24 @@ public class NewErrorTreeViewPanel extends JPanel implements DataProvider, Occur
@Nullable
public ErrorTreeNodeDescriptor getSelectedNodeDescriptor() {
TreePath path = myTree.getSelectionPath();
if (path == null) {
return null;
List<ErrorTreeNodeDescriptor> descriptors = getSelectedNodeDescriptors();
return descriptors.size() == 1 ? descriptors.get(0) : null;
}
private List<ErrorTreeNodeDescriptor> getSelectedNodeDescriptors() {
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null) {
return Collections.emptyList();
}
DefaultMutableTreeNode lastPathNode = (DefaultMutableTreeNode)path.getLastPathComponent();
Object userObject = lastPathNode.getUserObject();
if (!(userObject instanceof ErrorTreeNodeDescriptor)) {
return null;
List<ErrorTreeNodeDescriptor> result = ContainerUtil.newArrayList();
for (TreePath path : paths) {
DefaultMutableTreeNode lastPathNode = (DefaultMutableTreeNode)path.getLastPathComponent();
Object userObject = lastPathNode.getUserObject();
if (userObject instanceof ErrorTreeNodeDescriptor) {
result.add((ErrorTreeNodeDescriptor)userObject);
}
}
return (ErrorTreeNodeDescriptor)userObject;
return result;
}
private void navigateToSource(final boolean focusEditor) {
@@ -709,15 +709,14 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
String message;
if (causes.size() == 1) {
message = ProjectBundle.message("project.reload.external.change.single", getPresentablePath(causes.iterator().next().first));
message = ProjectBundle.message("project.reload.external.change.single", causes.iterator().next().first.getPresentableUrl());
}
else {
StringBuilder filesBuilder = new StringBuilder();
boolean first = true;
Set<String> alreadyShown = new HashSet<String>();
for (Pair<VirtualFile, StateStorage> cause : causes) {
VirtualFile file = cause.first;
String url = getPresentablePath(file);
String url = cause.first.getPresentableUrl();
if (!alreadyShown.contains(url)) {
if (alreadyShown.size() > 10) {
filesBuilder.append("\n" + "and ").append(causes.size() - alreadyShown.size()).append(" more");
@@ -736,11 +735,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
Messages.getQuestionIcon()) == 0;
}
private static String getPresentablePath(@NotNull VirtualFile file) {
String url = file.getPresentableUrl(); // might be null for invalid file
return url == null ? file.getPath() : url;
}
@Override
public boolean isFileSavedToBeReloaded(VirtualFile candidate) {
return mySavedCopies.containsKey(candidate);
@@ -866,7 +860,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
file.setBinaryContent(bytes, -1, mySavedTimestamps.get(file));
}
catch (IOException e) {
Messages.showWarningDialog(ProjectBundle.message("project.reload.write.failed", getPresentablePath(file)),
Messages.showWarningDialog(ProjectBundle.message("project.reload.write.failed", file.getPresentableUrl()),
ProjectBundle.message("project.reload.write.failed.title"));
}
}
@@ -1941,6 +1941,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
if (!actual.equals(Arrays.asList(expected))) {
UsefulTestCase.assertOrderedEquals(DumpLookupElementWeights.getLookupElementWeights(lookup), expected);
}
if (selected != list.getSelectedIndex()) {
System.out.println(DumpLookupElementWeights.getLookupElementWeights(lookup));
}
Assert.assertEquals(selected, list.getSelectedIndex());
}