mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -15,6 +15,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static com.intellij.openapi.util.Conditions.compose;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
*/
|
||||
@@ -96,12 +98,12 @@ public class SyntaxTraverser<T> extends FilteredTraverserBase<T, SyntaxTraverser
|
||||
|
||||
@NotNull
|
||||
public SyntaxTraverser<T> expandTypes(@NotNull Condition<? super IElementType> condition) {
|
||||
return super.expand(Conditions.compose(api.TO_TYPE(), condition));
|
||||
return super.expand(compose(api.TO_TYPE(), condition));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SyntaxTraverser<T> filterTypes(@NotNull Condition<? super IElementType> condition) {
|
||||
return super.filter(Conditions.compose(api.TO_TYPE(), condition));
|
||||
return super.filter(compose(api.TO_TYPE(), condition));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -125,7 +127,6 @@ public class SyntaxTraverser<T> extends FilteredTraverserBase<T, SyntaxTraverser
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public abstract static class Api<T> implements Function<T, Iterable<? extends T>> {
|
||||
@NotNull
|
||||
public abstract IElementType typeOf(@NotNull T node);
|
||||
|
||||
@@ -624,6 +624,13 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
|
||||
myGuardsSuppressed = true;
|
||||
}
|
||||
|
||||
// This data is used during the immediate editor painting to detect whether PSI synchronization is in progress.
|
||||
// PsiToDocumentSynchronizer.doCommitTransaction should probably perform bulk document updates.
|
||||
// TODO Remove this getter later
|
||||
public boolean isGuardsSuppressed() {
|
||||
return myGuardsSuppressed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unSuppressGuardedExceptions() {
|
||||
myGuardsSuppressed = false;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DiffApplication extends ApplicationStarterBase {
|
||||
if (file1 == null) throw new Exception("Can't find file " + path1);
|
||||
if (file2 == null) throw new Exception("Can't find file " + path2);
|
||||
|
||||
VfsUtil.markDirtyAndRefresh(false, false, false, file1, file2);
|
||||
VfsUtil.markDirtyAndRefresh(false, true, true, file1, file2);
|
||||
DiffRequest request = DiffRequestFactory.getInstance().createFromFiles(null, file1, file2);
|
||||
|
||||
Project project = DefaultProjectFactory.getInstance().getDefaultProject();
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.presentation.java.SymbolPresentationUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.popup.AbstractPopup;
|
||||
import com.intellij.ui.popup.PopupPositionManager;
|
||||
@@ -185,7 +185,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
((AbstractPopup)hint).focusPreferredComponent();
|
||||
return;
|
||||
}
|
||||
if (action instanceof ListScrollingUtil.ListScrollAction) return;
|
||||
if (action instanceof ScrollingUtil.ListScrollAction) return;
|
||||
if (action == myActionManager.getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN)) return;
|
||||
if (action == myActionManager.getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_UP)) return;
|
||||
if (action == myActionManager.getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_PAGE_DOWN)) return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
|
||||
public class EndHandler extends EditorActionHandler {
|
||||
private final EditorActionHandler myOriginalHandler;
|
||||
@@ -39,7 +39,7 @@ public class EndHandler extends EditorActionHandler {
|
||||
}
|
||||
|
||||
lookup.markSelectionTouched();
|
||||
ListScrollingUtil.moveEnd(lookup.getList());
|
||||
ScrollingUtil.moveEnd(lookup.getList());
|
||||
lookup.refreshUi(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
|
||||
public class HomeHandler extends EditorActionHandler {
|
||||
private final EditorActionHandler myOriginalHandler;
|
||||
@@ -39,6 +39,6 @@ public class HomeHandler extends EditorActionHandler {
|
||||
}
|
||||
|
||||
lookup.markSelectionTouched();
|
||||
ListScrollingUtil.moveHome(lookup.getList());
|
||||
ScrollingUtil.moveHome(lookup.getList());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -31,7 +31,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -84,9 +84,9 @@ public abstract class LookupActionHandler extends EditorActionHandler {
|
||||
}
|
||||
}
|
||||
if (up) {
|
||||
ListScrollingUtil.moveUp(lookup.getList(), 0);
|
||||
ScrollingUtil.moveUp(lookup.getList(), 0);
|
||||
} else {
|
||||
ListScrollingUtil.moveDown(lookup.getList(), 0);
|
||||
ScrollingUtil.moveDown(lookup.getList(), 0);
|
||||
}
|
||||
lookup.markSelectionTouched();
|
||||
lookup.refreshUi(false, true);
|
||||
@@ -166,7 +166,7 @@ public abstract class LookupActionHandler extends EditorActionHandler {
|
||||
@Override
|
||||
protected void executeInLookup(final LookupImpl lookup, DataContext context, Caret caret) {
|
||||
lookup.setFocusDegree(LookupImpl.FocusDegree.FOCUSED);
|
||||
ListScrollingUtil.movePageDown(lookup.getList());
|
||||
ScrollingUtil.movePageDown(lookup.getList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public abstract class LookupActionHandler extends EditorActionHandler {
|
||||
@Override
|
||||
protected void executeInLookup(final LookupImpl lookup, DataContext context, Caret caret) {
|
||||
lookup.setFocusDegree(LookupImpl.FocusDegree.FOCUSED);
|
||||
ListScrollingUtil.movePageUp(lookup.getList());
|
||||
ScrollingUtil.movePageUp(lookup.getList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -323,7 +323,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
|
||||
}
|
||||
|
||||
if (!forceTopSelection) {
|
||||
ListScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1);
|
||||
ScrollingUtil.ensureIndexIsVisible(myList, myList.getSelectedIndex(), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
|
||||
return;
|
||||
}
|
||||
|
||||
ListScrollingUtil.ensureRangeIsVisible(myList, top, top + myList.getLastVisibleIndex() - firstVisibleIndex);
|
||||
ScrollingUtil.ensureRangeIsVisible(myList, top, top + myList.getLastVisibleIndex() - firstVisibleIndex);
|
||||
}
|
||||
|
||||
boolean truncatePrefix(boolean preserveSelection) {
|
||||
@@ -402,7 +402,7 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable,
|
||||
}
|
||||
|
||||
private boolean isSelectionVisible() {
|
||||
return ListScrollingUtil.isIndexFullyVisible(myList, myList.getSelectedIndex());
|
||||
return ScrollingUtil.isIndexFullyVisible(myList, myList.getSelectedIndex());
|
||||
}
|
||||
|
||||
private boolean checkReused() {
|
||||
|
||||
@@ -242,7 +242,7 @@ public abstract class GotoTargetHandler implements CodeInsightActionHandler {
|
||||
};
|
||||
}
|
||||
|
||||
protected static PsiElementListCellRenderer createRenderer(GotoData gotoData, PsiElement eachTarget) {
|
||||
public static PsiElementListCellRenderer createRenderer(GotoData gotoData, PsiElement eachTarget) {
|
||||
PsiElementListCellRenderer renderer = null;
|
||||
for (GotoTargetRendererProvider eachProvider : Extensions.getExtensions(GotoTargetRendererProvider.EP_NAME)) {
|
||||
renderer = eachProvider.getRenderer(eachTarget, gotoData);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -144,7 +144,7 @@ public class SeverityEditorDialog extends DialogWrapper {
|
||||
((DefaultListModel)myOptionsList.getModel()).addElement(newSeverityBasedTextAttributes);
|
||||
|
||||
myOptionsList.clearSelection();
|
||||
ListScrollingUtil.selectItem(myOptionsList, newSeverityBasedTextAttributes);
|
||||
ScrollingUtil.selectItem(myOptionsList, newSeverityBasedTextAttributes);
|
||||
}
|
||||
}).setMoveUpAction(new AnActionButtonRunnable() {
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.find.FindSettings;
|
||||
import com.intellij.find.actions.ShowUsagesAction;
|
||||
import com.intellij.ide.util.scopeChooser.ScopeChooserCombo;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -647,7 +648,7 @@ public class FindDialog extends DialogWrapper {
|
||||
pane.insertTab("Options", null, optionsPanel, null, 0);
|
||||
pane.insertTab(PREVIEW_TITLE, null, myPreviewSplitter, null, RESULTS_PREVIEW_TAB_INDEX);
|
||||
myContent = pane;
|
||||
AnAction anAction = new AnAction() {
|
||||
final AnAction anAction = new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
int selectedIndex = myContent.getSelectedIndex();
|
||||
@@ -656,7 +657,16 @@ public class FindDialog extends DialogWrapper {
|
||||
};
|
||||
|
||||
final ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_SWITCHER).getShortcutSet();
|
||||
anAction.registerCustomShortcutSet(shortcutSet, getRootPane());
|
||||
final JRootPane rootPane = getRootPane();
|
||||
|
||||
anAction.registerCustomShortcutSet(shortcutSet, rootPane);
|
||||
Disposer.register(myDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
anAction.unregisterCustomShortcutSet(rootPane);
|
||||
}
|
||||
});
|
||||
|
||||
if (myPreviewResultsTabWasSelected) myContent.setSelectedIndex(RESULTS_PREVIEW_TAB_INDEX);
|
||||
|
||||
return pane.getComponent();
|
||||
|
||||
@@ -433,8 +433,8 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
if (more < newIndex) {
|
||||
more = myList.getItemsCount() - 1;
|
||||
}
|
||||
ListScrollingUtil.ensureIndexIsVisible(myList, more, forward ? 1 : -1);
|
||||
ListScrollingUtil.ensureIndexIsVisible(myList, newIndex, forward ? 1 : -1);
|
||||
ScrollingUtil.ensureIndexIsVisible(myList, more, forward ? 1 : -1);
|
||||
ScrollingUtil.ensureIndexIsVisible(myList, newIndex, forward ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2136,7 +2136,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
myList.revalidate();
|
||||
myList.repaint();
|
||||
}
|
||||
ListScrollingUtil.ensureSelectionExists(myList);
|
||||
ScrollingUtil.ensureSelectionExists(myList);
|
||||
if (myList.getModel().getSize() > 0) {
|
||||
updatePopupBounds();
|
||||
}
|
||||
@@ -2193,7 +2193,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
case RUN_CONFIGURATIONS: moreIndex.runConfigurations = -1; break;
|
||||
}
|
||||
}
|
||||
ListScrollingUtil.selectItem(myList, index);
|
||||
ScrollingUtil.selectItem(myList, index);
|
||||
myDone.setDone();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@ package com.intellij.ide.navigationToolbar;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -53,7 +53,7 @@ class NavBarListWrapper extends JBScrollPane implements DataProvider {
|
||||
}
|
||||
});
|
||||
|
||||
ListScrollingUtil.installActions(list);
|
||||
ScrollingUtil.installActions(list);
|
||||
|
||||
final int modelSize = list.getModel().getSize();
|
||||
setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ import com.intellij.problems.WolfTheProblemSolver;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.PsiTreeChangeEvent;
|
||||
import com.intellij.psi.PsiTreeChangeListener;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -311,7 +311,7 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
|
||||
return action instanceof PopupAction
|
||||
|| action instanceof CopyAction
|
||||
|| action instanceof CutAction
|
||||
|| action instanceof ListScrollingUtil.ListScrollAction;
|
||||
|| action instanceof ScrollingUtil.ListScrollAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -130,7 +130,7 @@ public class NavBarPopup extends LightweightHint implements Disposable{
|
||||
show(myPanel, p.x - offset, p.y, myPanel, new HintHint(myPanel, p));
|
||||
final JBList list = getList();
|
||||
if (0 <= myIndex && myIndex < list.getItemsCount()) {
|
||||
ListScrollingUtil.selectItem(list, myIndex);
|
||||
ScrollingUtil.selectItem(list, myIndex);
|
||||
}
|
||||
}
|
||||
if (myPanel.isInFloatingMode()) {
|
||||
|
||||
@@ -378,10 +378,10 @@ public class FileStructureDialog extends DialogWrapper {
|
||||
int index = myList.getSelectedIndex();
|
||||
if (index != -1 && index < myList.getModel().getSize()) {
|
||||
myList.clearSelection();
|
||||
ListScrollingUtil.selectItem(myList, index);
|
||||
ScrollingUtil.selectItem(myList, index);
|
||||
}
|
||||
else {
|
||||
ListScrollingUtil.ensureSelectionExists(myList);
|
||||
ScrollingUtil.ensureSelectionExists(myList);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -438,7 +438,7 @@ public class FileStructureDialog extends DialogWrapper {
|
||||
public void scrollSelectionInView() {
|
||||
int selectedIndex = myList.getSelectedIndex();
|
||||
if (selectedIndex >= 0) {
|
||||
ListScrollingUtil.ensureIndexIsVisible(myList, selectedIndex, 0);
|
||||
ScrollingUtil.ensureIndexIsVisible(myList, selectedIndex, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,6 @@ import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.DialogBuilder;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -309,7 +308,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
|
||||
updateExtensionList();
|
||||
final int index = myPatterns.getListModel().indexOf(matcher.getPresentableString());
|
||||
if (index >= 0) {
|
||||
ListScrollingUtil.selectItem(myPatterns.myPatternsList, index);
|
||||
ScrollingUtil.selectItem(myPatterns.myPatternsList, index);
|
||||
}
|
||||
myPatterns.myPatternsList.requestFocus();
|
||||
}
|
||||
@@ -512,7 +511,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
|
||||
listModel.addElement(type);
|
||||
}
|
||||
}
|
||||
ListScrollingUtil.ensureSelectionExists(myFileTypesList);
|
||||
ScrollingUtil.ensureSelectionExists(myFileTypesList);
|
||||
}
|
||||
|
||||
public int getSelectedIndex() {
|
||||
@@ -579,12 +578,12 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
|
||||
}
|
||||
|
||||
public void ensureSelectionExists() {
|
||||
ListScrollingUtil.ensureSelectionExists(myPatternsList);
|
||||
ScrollingUtil.ensureSelectionExists(myPatternsList);
|
||||
}
|
||||
|
||||
public void addPatternAndSelect(String pattern) {
|
||||
addPattern(pattern);
|
||||
ListScrollingUtil.selectItem(myPatternsList, getListModel().getSize() - 1);
|
||||
ScrollingUtil.selectItem(myPatternsList, getListModel().getSize() - 1);
|
||||
}
|
||||
|
||||
public void select(final String pattern) {
|
||||
@@ -593,7 +592,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable
|
||||
if (at instanceof String) {
|
||||
final FileNameMatcher matcher = FileTypeManager.parseFromString((String)at);
|
||||
if (FileNameMatcherEx.acceptsCharSequence(matcher, pattern)) {
|
||||
ListScrollingUtil.selectItem(myPatternsList, i);
|
||||
ScrollingUtil.selectItem(myPatternsList, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -19,24 +19,62 @@ package com.intellij.refactoring.rename.naming;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* When an element is renamed, allows to prompt the user to rename other elements with names derived from the name of the
|
||||
* element being renamed (for example, when a class is renamed, allows to prompt the user to rename variables of this class
|
||||
* that have names similar to the name of the class).
|
||||
*
|
||||
* @author yole
|
||||
*/
|
||||
public interface AutomaticRenamerFactory {
|
||||
ExtensionPointName<AutomaticRenamerFactory> EP_NAME = ExtensionPointName.create("com.intellij.automaticRenamerFactory");
|
||||
|
||||
/**
|
||||
* Checks if this factory can provide additional elements to be renamed for the given element being renamed.
|
||||
*
|
||||
* @param element the element being renamed.
|
||||
* @return
|
||||
*/
|
||||
boolean isApplicable(@NotNull PsiElement element);
|
||||
|
||||
/**
|
||||
* Returns the title of the checkbox shown in the rename dialog which enables or disables this renamer factory,
|
||||
* or null if the renamer factory does not require showing a checkbox in the rename dialog.
|
||||
*
|
||||
* @return the checkbox title.
|
||||
*/
|
||||
@Nullable
|
||||
@Nls
|
||||
String getOptionName();
|
||||
|
||||
/**
|
||||
* Returns true if this renamer factory is enabled (and the checkbox representing its state should be checked.)
|
||||
* Normally, the implementation of this method needs to load the persisted state of the checkbox.
|
||||
* @return
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Persists the state of the checkbox which enables or disables the renamer factory.
|
||||
*
|
||||
* @param enabled true if the checkbox is checked, false otherwise.
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Creates an automatic renamer for the given rename operation.
|
||||
*
|
||||
* @param element the primary element being renamed.
|
||||
* @param newName the new name of the element
|
||||
* @param usages the list of usages of the primary element.
|
||||
* @return the renamer instance.
|
||||
*/
|
||||
@NotNull
|
||||
AutomaticRenamer createRenamer(final PsiElement element, final String newName, final Collection<UsageInfo> usages);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -63,7 +63,7 @@ public class OutputFiltersDialog extends DialogWrapper {
|
||||
append(info.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
});
|
||||
ListScrollingUtil.ensureSelectionExists(myFiltersList);
|
||||
ScrollingUtil.ensureSelectionExists(myFiltersList);
|
||||
}
|
||||
|
||||
private String suggestFilterName() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -538,7 +538,7 @@ public class PopupChooserBuilder {
|
||||
ListUtil.installAutoSelectOnMouseMove(list);
|
||||
}
|
||||
|
||||
ListScrollingUtil.installActions(list);
|
||||
ScrollingUtil.installActions(list);
|
||||
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
|
||||
myList = list;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -106,7 +106,7 @@ public abstract class ReorderableListController <T> {
|
||||
((DefaultListModel)listModel).addElement(element);
|
||||
}
|
||||
myList.clearSelection();
|
||||
ListScrollingUtil.selectItem(myList, element);
|
||||
ScrollingUtil.selectItem(myList, element);
|
||||
}
|
||||
|
||||
public static <T> ReorderableListController<T> create(final JList list, final DefaultActionGroup actionGroup) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
@@ -383,7 +383,7 @@ public final class TreeUtil {
|
||||
return showRowCentred(tree, tree.getRowForPath(path));
|
||||
} else {
|
||||
final int row = tree.getRowForPath(path);
|
||||
return showAndSelect(tree, row - ListScrollingUtil.ROW_PADDING, row + ListScrollingUtil.ROW_PADDING, row, -1);
|
||||
return showAndSelect(tree, row - ScrollingUtil.ROW_PADDING, row + ScrollingUtil.ROW_PADDING, row, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -76,7 +76,7 @@ public class ActionMacroConfigurationPanel implements Disposable {
|
||||
myMacrosModel.addElement(macro.clone());
|
||||
}
|
||||
myMacrosList.setModel(myMacrosModel);
|
||||
ListScrollingUtil.ensureSelectionExists(myMacrosList);
|
||||
ScrollingUtil.ensureSelectionExists(myMacrosList);
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
@@ -136,7 +136,7 @@ public class ActionMacroConfigurationPanel implements Disposable {
|
||||
actionModel.addElement(action);
|
||||
}
|
||||
myMacroActionsList.setModel(actionModel);
|
||||
ListScrollingUtil.ensureSelectionExists(myMacroActionsList);
|
||||
ScrollingUtil.ensureSelectionExists(myMacroActionsList);
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
|
||||
@@ -321,10 +321,10 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
}
|
||||
});
|
||||
toolWindows.addKeyListener(this);
|
||||
ListScrollingUtil.installActions(toolWindows);
|
||||
ScrollingUtil.installActions(toolWindows);
|
||||
toolWindows.addMouseListener(this);
|
||||
toolWindows.addMouseMotionListener(this);
|
||||
ListScrollingUtil.ensureSelectionExists(toolWindows);
|
||||
ScrollingUtil.ensureSelectionExists(toolWindows);
|
||||
myClickListener.installOn(toolWindows);
|
||||
toolWindows.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(@NotNull ListSelectionEvent e) {
|
||||
@@ -512,11 +512,11 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
files.setCellRenderer(filesRenderer);
|
||||
files.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 20));
|
||||
files.addKeyListener(this);
|
||||
ListScrollingUtil.installActions(files);
|
||||
ScrollingUtil.installActions(files);
|
||||
files.addMouseListener(this);
|
||||
files.addMouseMotionListener(this);
|
||||
myClickListener.installOn(files);
|
||||
ListScrollingUtil.ensureSelectionExists(files);
|
||||
ScrollingUtil.ensureSelectionExists(files);
|
||||
|
||||
this.add(toolWindows, BorderLayout.WEST);
|
||||
if (filesModel.size() > 0) {
|
||||
@@ -1066,7 +1066,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
files.repaint();
|
||||
toolWindows.repaint();
|
||||
if (value != null) {
|
||||
ListScrollingUtil.ensureSelectionExists(getSelectedList(list));
|
||||
ScrollingUtil.ensureSelectionExists(getSelectedList(list));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ public abstract class ContentChooser<Data> extends DialogWrapper {
|
||||
mySplitter.setSecondComponent(new JPanel());
|
||||
rebuildListContent();
|
||||
|
||||
ListScrollingUtil.installActions(myList);
|
||||
ListScrollingUtil.ensureSelectionExists(myList);
|
||||
ScrollingUtil.installActions(myList);
|
||||
ScrollingUtil.ensureSelectionExists(myList);
|
||||
updateViewerForSelection();
|
||||
myList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
@@ -309,7 +309,7 @@ public abstract class ContentChooser<Data> extends DialogWrapper {
|
||||
|
||||
public void setSelectedIndex(int index) {
|
||||
myList.setSelectedIndex(index);
|
||||
ListScrollingUtil.ensureIndexIsVisible(myList, index, 0);
|
||||
ScrollingUtil.ensureIndexIsVisible(myList, index, 0);
|
||||
updateViewerForSelection();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.UndoConfirmationPolicy;
|
||||
import com.intellij.openapi.command.undo.UndoManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.actionSystem.*;
|
||||
@@ -2174,8 +2175,13 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
print(g, newText, point, ascent, font, color);
|
||||
}
|
||||
|
||||
private static boolean canPaintImmediately(@NotNull DocumentEvent e) {
|
||||
return !contains(e.getOldFragment(), '\n') &&
|
||||
private boolean canPaintImmediately(@NotNull DocumentEvent e) {
|
||||
UndoManager undoManager = UndoManager.getInstance(myProject);
|
||||
return !undoManager.isUndoInProgress() && // Undo / Redo actions might start multiple write actions and make multiple document changes.
|
||||
!undoManager.isRedoInProgress() && // Can we optimize the subsystem to start only one write action and do a single update?
|
||||
myDocument instanceof DocumentImpl &&
|
||||
!((DocumentImpl)myDocument).isGuardsSuppressed() && // Heuristics. Can PsiToDocumentSynchronizer perform bulk document updates?
|
||||
!contains(e.getOldFragment(), '\n') &&
|
||||
!contains(e.getNewFragment(), '\n') &&
|
||||
!(e.getNewLength() == 1 && DOCUMENT_CHARS_TO_SKIP.contains(e.getNewFragment().charAt(0)));
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -35,7 +35,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.codeStyle.MinusculeMatcher;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.list.GroupedItemsListRenderer;
|
||||
import com.intellij.util.ui.update.LazyUiDisposable;
|
||||
@@ -778,20 +778,20 @@ public abstract class FileTextFieldImpl implements FileLookup, Disposable, FileT
|
||||
|
||||
if ("selectNextRow".equals(action)) {
|
||||
if (ensureSelectionExists()) {
|
||||
ListScrollingUtil.moveDown(myList, e.getModifiersEx());
|
||||
ScrollingUtil.moveDown(myList, e.getModifiersEx());
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
else if ("selectPreviousRow".equals(action)) {
|
||||
ListScrollingUtil.moveUp(myList, e.getModifiersEx());
|
||||
ScrollingUtil.moveUp(myList, e.getModifiersEx());
|
||||
e.consume();
|
||||
}
|
||||
else if ("scrollDown".equals(action)) {
|
||||
ListScrollingUtil.movePageDown(myList);
|
||||
ScrollingUtil.movePageDown(myList);
|
||||
e.consume();
|
||||
}
|
||||
else if ("scrollUp".equals(action)) {
|
||||
ListScrollingUtil.movePageUp(myList);
|
||||
ScrollingUtil.movePageUp(myList);
|
||||
e.consume();
|
||||
}
|
||||
else if (getSelectedFileFromCompletionPopup() != null && (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB) && e.getModifiers() == 0) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.ui.DoubleClickListener;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.util.FunctionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -109,7 +109,7 @@ public class FileTypeChooser extends DialogWrapper {
|
||||
}
|
||||
);
|
||||
|
||||
ListScrollingUtil.selectItem(myList, FileTypes.PLAIN_TEXT);
|
||||
ScrollingUtil.selectItem(myList, FileTypes.PLAIN_TEXT);
|
||||
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.ui.InputValidatorEx;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -77,7 +77,7 @@ public class EditProjectGroupAction extends RecentProjectsWelcomeScreenActionBas
|
||||
Object element = model.get(i);
|
||||
if (element instanceof ProjectGroupActionGroup) {
|
||||
if (((ProjectGroupActionGroup)element).getGroup().equals(group)) {
|
||||
ListScrollingUtil.selectItem(list, i);
|
||||
ScrollingUtil.selectItem(list, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -350,7 +350,7 @@ public class FlatWelcomeFrame extends JFrame implements IdeFrame {
|
||||
@Override
|
||||
public void run() {
|
||||
final JBList list = panel.second;
|
||||
ListScrollingUtil.ensureSelectionExists(list);
|
||||
ScrollingUtil.ensureSelectionExists(list);
|
||||
final ListSelectionListener[] listeners =
|
||||
((DefaultListSelectionModel)list.getSelectionModel()).getListeners(ListSelectionListener.class);
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.ReopenProjectAction;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RemoveSelectedProjectsAction extends RecentProjectsWelcomeScreenAct
|
||||
|
||||
JList list = getList(e);
|
||||
if (list != null) {
|
||||
ListScrollingUtil.ensureSelectionExists(list);
|
||||
ScrollingUtil.ensureSelectionExists(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public abstract class FinderRecursivePanel<T> extends JBSplitter implements Data
|
||||
updateRightComponent(true);
|
||||
}
|
||||
});
|
||||
ListScrollingUtil.installActions(list);
|
||||
ScrollingUtil.installActions(list);
|
||||
|
||||
// installSpeedSearch(list); // TODO
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ public class ListSpeedSearch extends SpeedSearchBase<JList> {
|
||||
}
|
||||
|
||||
protected void selectElement(Object element, String selectedText) {
|
||||
ListScrollingUtil.selectItem(myComponent, element);
|
||||
ScrollingUtil.selectItem(myComponent, element);
|
||||
}
|
||||
|
||||
protected int getSelectedIndex() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -44,6 +44,6 @@ public class MultipleTraitsListSpeedSearch extends MultipleTraitsSpeedSearch<JLi
|
||||
|
||||
@Override
|
||||
protected void selectElement(Object element, String selectedText) {
|
||||
ListScrollingUtil.selectItem(myComponent, element);
|
||||
ScrollingUtil.selectItem(myComponent, element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.statistics.StatisticsInfo;
|
||||
import com.intellij.psi.statistics.StatisticsManager;
|
||||
import com.intellij.ui.JBListWithHintProvider;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SeparatorWithText;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.popup.ClosableByLeftArrow;
|
||||
@@ -124,7 +124,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
if (listStep instanceof MultiSelectionListPopupStep<?>) {
|
||||
int[] indices = ((MultiSelectionListPopupStep)listStep).getDefaultOptionIndices();
|
||||
if (indices.length > 0) {
|
||||
ListScrollingUtil.ensureIndexIsVisible(myList, indices[0], 0);
|
||||
ScrollingUtil.ensureIndexIsVisible(myList, indices[0], 0);
|
||||
myList.setSelectedIndices(indices);
|
||||
selected = true;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
else {
|
||||
final int defaultIndex = listStep.getDefaultOptionIndex();
|
||||
if (defaultIndex >= 0 && defaultIndex < myList.getModel().getSize()) {
|
||||
ListScrollingUtil.selectItem(myList, defaultIndex);
|
||||
ScrollingUtil.selectItem(myList, defaultIndex);
|
||||
selected = true;
|
||||
}
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
}
|
||||
|
||||
if (mostUsedValue > 0) {
|
||||
ListScrollingUtil.selectItem(myList, mostUsedValue);
|
||||
ScrollingUtil.selectItem(myList, mostUsedValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
Insets padding = UIUtil.getListViewportPadding();
|
||||
myList.setBorder(new EmptyBorder(padding));
|
||||
|
||||
ListScrollingUtil.installActions(myList);
|
||||
ScrollingUtil.installActions(myList);
|
||||
|
||||
myList.setCellRenderer(getListElementRenderer());
|
||||
|
||||
|
||||
@@ -43,14 +43,14 @@ public class ListModelEditor<T> extends ListModelEditorBase<T> {
|
||||
if (!model.isEmpty()) {
|
||||
T lastItem = model.getElementAt(model.getSize() - 1);
|
||||
if (ListModelEditor.this.itemEditor.isEmpty(lastItem)) {
|
||||
ListScrollingUtil.selectItem(list, ContainerUtil.indexOfIdentity(model.getItems(), lastItem));
|
||||
ScrollingUtil.selectItem(list, ContainerUtil.indexOfIdentity(model.getItems(), lastItem));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
T item = createElement();
|
||||
model.add(item);
|
||||
ListScrollingUtil.selectItem(list, ContainerUtil.indexOfIdentity(model.getItems(), item));
|
||||
ScrollingUtil.selectItem(list, ContainerUtil.indexOfIdentity(model.getItems(), item));
|
||||
}
|
||||
})
|
||||
.setRemoveActionUpdater(new AnActionButtonUpdater() {
|
||||
|
||||
+78
-11
@@ -16,15 +16,14 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Functions;
|
||||
import com.intellij.util.PairFunction;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author gregsh
|
||||
@@ -40,6 +39,23 @@ public class TreeTraverserTest extends TestCase {
|
||||
build();
|
||||
}
|
||||
|
||||
private static Map<Integer, Collection<Integer>> numbers2() {
|
||||
return ContainerUtil.<Integer, Collection<Integer>>immutableMapBuilder().
|
||||
put(1, Arrays.asList(2, 3, 4)).
|
||||
put(2, Arrays.asList(5, 6, 7)).
|
||||
put(3, Arrays.asList(8, 9, 10)).
|
||||
put(4, Arrays.asList(11, 12, 13)).
|
||||
put(5, Arrays.asList(14, 15, 16)).
|
||||
put(6, Arrays.asList(17, 18, 19)).
|
||||
put(7, Arrays.asList(20, 21, 22)).
|
||||
put(8, Arrays.asList(23, 24, 25)).
|
||||
put(9, Arrays.asList(26, 27, 28)).
|
||||
put(10, Arrays.asList(29, 30, 31)).
|
||||
put(11, Arrays.asList(32, 33, 34)).
|
||||
put(12, Arrays.asList(35, 36, 37)).
|
||||
build();
|
||||
}
|
||||
|
||||
private static final Condition<Integer> IS_ODD = new Condition<Integer>() {
|
||||
@Override
|
||||
public boolean value(Integer integer) {
|
||||
@@ -47,6 +63,15 @@ public class TreeTraverserTest extends TestCase {
|
||||
}
|
||||
};
|
||||
|
||||
private static Condition<Integer> inRange(final int s, final int e) {
|
||||
return new Condition<Integer>() {
|
||||
@Override
|
||||
public boolean value(Integer integer) {
|
||||
return s <= integer && integer <= e;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static final Function<Integer, Integer> INCREMENT = new Function<Integer, Integer>() {
|
||||
@Override
|
||||
public Integer fun(Integer k) {
|
||||
@@ -177,20 +202,37 @@ public class TreeTraverserTest extends TestCase {
|
||||
// TreeTraversal ----------------------------------------------
|
||||
|
||||
@NotNull
|
||||
private static Function<Integer, JBIterable<Integer>> traverser(TreeTraversal t) {
|
||||
private static Function<Integer, JBIterable<Integer>> numTraverser(TreeTraversal t) {
|
||||
return t.traversal(Functions.fromMap(numbers()));
|
||||
}
|
||||
@NotNull
|
||||
private static Function<Integer, JBIterable<Integer>> numTraverser2(TreeTraversal t) {
|
||||
return t.traversal(Functions.fromMap(numbers2()));
|
||||
}
|
||||
|
||||
public void testSimplePreOrderDfs() {
|
||||
assertEquals(Arrays.asList(1, 2, 5, 6, 7, 3, 8, 9, 10, 4, 11, 12, 13), traverser(TreeTraversal.PRE_ORDER_DFS).fun(1).toList());
|
||||
assertEquals(Arrays.asList(1, 2, 5, 6, 7, 3, 8, 9, 10, 4, 11, 12, 13), numTraverser(TreeTraversal.PRE_ORDER_DFS).fun(1).toList());
|
||||
}
|
||||
|
||||
public void testSimplePreOrderDfsBacktrace() {
|
||||
List<Integer> backDfs = Collections.emptyList();
|
||||
for (TreeTraversal.TracingIt<Integer> it = numTraverser2(TreeTraversal.PRE_ORDER_DFS).fun(1).typedIterator(); it.hasNext(); ) {
|
||||
if (it.next().equals(37)) backDfs = it.backtrace().toList();
|
||||
}
|
||||
List<Integer> backBfs = Collections.emptyList();
|
||||
for (TreeTraversal.TracingIt<Integer> it = numTraverser2(TreeTraversal.TRACING_BFS).fun(1).typedIterator(); it.hasNext(); ) {
|
||||
if (it.next().equals(37)) backBfs = it.backtrace().toList();
|
||||
}
|
||||
assertEquals(Arrays.asList(37, 12, 4, 1), backDfs);
|
||||
assertEquals(Arrays.asList(37, 12, 4, 1), backBfs);
|
||||
}
|
||||
|
||||
public void testSimplePostOrderDfs() {
|
||||
assertEquals(Arrays.asList(5, 6, 7, 2, 8, 9, 10, 3, 11, 12, 13, 4, 1), traverser(TreeTraversal.POST_ORDER_DFS).fun(1).toList());
|
||||
assertEquals(Arrays.asList(5, 6, 7, 2, 8, 9, 10, 3, 11, 12, 13, 4, 1), numTraverser(TreeTraversal.POST_ORDER_DFS).fun(1).toList());
|
||||
}
|
||||
|
||||
public void testSimpleBfs() {
|
||||
assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), traverser(TreeTraversal.PLAIN_BFS).fun(1).toList());
|
||||
assertEquals(JBIterable.generate(1, INCREMENT).take(37).toList(), numTraverser2(TreeTraversal.PLAIN_BFS).fun(1).toList());
|
||||
}
|
||||
|
||||
// FilteredTraverser ----------------------------------------------
|
||||
@@ -217,18 +259,43 @@ public class TreeTraverserTest extends TestCase {
|
||||
|
||||
public void testSkipExpandedDfs() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(2, 8, 9, 10, 4), t.withRoot(1).expand(IS_ODD).leavesOnly(true).leavesOnlyDfsTraversal().toList());
|
||||
assertEquals(Arrays.asList(2, 8, 9, 10, 4), t.withRoot(1).expand(IS_ODD).leavesOnlyDfsTraversal().toList());
|
||||
}
|
||||
|
||||
public void testRangeChildrenLeavesDfs() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(5, 6, 3, 11, 12, 13), t.withRoot(1).children(Conditions.not(inRange(7, 10))).leavesOnlyDfsTraversal().toList());
|
||||
}
|
||||
|
||||
public void testRangeChildrenLeavesBfs() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(5, 6, 3, 11, 12, 13), t.withRoot(1).children(Conditions.not(inRange(7, 10))).leavesOnlyDfsTraversal().toList());
|
||||
}
|
||||
|
||||
public void testSkipExpandedBfs() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(2, 4, 8, 9, 10), t.withRoot(1).expand(IS_ODD).leavesOnly(true).leavesOnlyBfsTraversal().toList());
|
||||
assertEquals(Arrays.asList(2, 4, 8, 9, 10), t.withRoot(1).expand(IS_ODD).leavesOnlyBfsTraversal().toList());
|
||||
}
|
||||
|
||||
public void testExpandSkipFilterReset() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(1, 5, 7, 3, 9, 11, 13), t.withRoot(1).expand(IS_ODD).
|
||||
leavesOnly(true).reset().filter(IS_ODD).toList());
|
||||
withTraversal(TreeTraversal.LEAVES_ONLY_DFS).reset().filter(IS_ODD).toList());
|
||||
}
|
||||
|
||||
public void testForceExlcudeReset() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(1, 2, 6, 4, 12), t.withRoot(1).forceExclude(IS_ODD).reset().toList());
|
||||
}
|
||||
|
||||
public void testForceSkipReset() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(1, 2, 6, 8, 10, 4, 12), t.withRoot(1).forceExpandAndSkip(IS_ODD).reset().toList());
|
||||
}
|
||||
|
||||
public void testForceSkipLeavesDfs() {
|
||||
FilteredTraverser<Integer> t = filteredTraverser();
|
||||
assertEquals(Arrays.asList(6, 8, 10, 12), t.withRoot(1).forceExpandAndSkip(IS_ODD).leavesOnlyDfsTraversal().toList());
|
||||
}
|
||||
|
||||
public void testFilterChildren() {
|
||||
@@ -257,7 +324,7 @@ public class TreeTraverserTest extends TestCase {
|
||||
TreeTraversal.TracingIt<Integer> cursor = JBIterator.cursor(it).first();
|
||||
assertNotNull(cursor);
|
||||
assertSame(cursor, it);
|
||||
assertEquals(Arrays.asList(20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1), cursor.backtrace().toList());
|
||||
assertEquals(Arrays.asList(21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1), cursor.backtrace().toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -41,6 +41,7 @@ import com.intellij.openapi.progress.util.ColorProgressBar;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pass;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
@@ -808,6 +809,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
|
||||
new SimpleDateFormat(HISTORY_DATE_FORMAT).format(new Date());
|
||||
|
||||
myOutputFile = new File(AbstractImportTestsAction.getTestHistoryRoot(myProject), configurationNameIncludedDate + ".xml");
|
||||
FileUtilRt.createParentDirs(myOutputFile);
|
||||
handler.setResult(new StreamResult(new FileWriter(myOutputFile)));
|
||||
final SMTestProxy.SMRootTestProxy root = myRoot;
|
||||
final RunConfiguration configuration = myConfiguration;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -25,6 +24,8 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.util.Conditions.*;
|
||||
|
||||
public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBase<T, Self>> implements Iterable<T> {
|
||||
|
||||
protected final Meta<T> meta;
|
||||
@@ -66,7 +67,7 @@ public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBas
|
||||
|
||||
@NotNull
|
||||
public JBIterable<T> traverse() {
|
||||
return meta.skipExpanded ? leavesOnlyDfsTraversal() : preOrderDfsTraversal();
|
||||
return traverse(meta.traversal);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -101,7 +102,7 @@ public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBas
|
||||
|
||||
@NotNull
|
||||
public Self reset() {
|
||||
return newInstance(Meta.<T>empty().exclude(meta.excludeFilter).withRoots(meta.roots));
|
||||
return newInstance(Meta.<T>empty().forceExclude(meta.forceExclude).forceExpandAndSkip(meta.forceExpandAndSkip).withRoots(meta.roots));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -115,8 +116,8 @@ public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBas
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Self leavesOnly(boolean flag) {
|
||||
return newInstance(meta.skipExpanded(flag));
|
||||
public Self withTraversal(TreeTraversal type) {
|
||||
return newInstance(meta.withTraversal(type));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -131,7 +132,7 @@ public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBas
|
||||
|
||||
@NotNull
|
||||
public Self expandAndSkip(Condition<? super T> filter) {
|
||||
return newInstance(meta.expand(filter).filter(Conditions.not(filter)));
|
||||
return newInstance(meta.expand(filter).filter(not(filter)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -150,15 +151,22 @@ public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBas
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Self exclude(@NotNull Condition<? super T> filter) {
|
||||
return newInstance(meta.exclude(filter));
|
||||
public Self forceExclude(@NotNull Condition<? super T> filter) {
|
||||
return newInstance(meta.forceExclude(filter));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Self forceExpandAndSkip(@NotNull Condition<? super T> filter) {
|
||||
return newInstance(meta.forceExpandAndSkip(filter));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JBIterable<T> children(@NotNull T node) {
|
||||
if (isAlwaysLeaf(node)) return JBIterable.empty();
|
||||
JBIterable<T> children = JBIterable.from(tree.fun(node));
|
||||
if (meta.childFilter == Conditions.TRUE) return children.filter(Conditions.not(meta.excludeFilter));
|
||||
if (meta.childFilter == TRUE && meta.forceExpandAndSkip == Condition.FALSE) {
|
||||
return children.filter(not(meta.forceExclude));
|
||||
}
|
||||
// traverse subtree to select accepted children
|
||||
return newInstance(meta.forChildren(children)).traverse();
|
||||
}
|
||||
@@ -179,61 +187,76 @@ public abstract class FilteredTraverserBase<T, Self extends FilteredTraverserBas
|
||||
|
||||
|
||||
protected static class Meta<T> {
|
||||
final Iterable<? extends T> roots;
|
||||
final boolean skipExpanded;
|
||||
final Condition<? super T> expandFilter;
|
||||
final Condition<? super T> childFilter;
|
||||
final Condition<? super T> resultFilter;
|
||||
final Condition<? super T> excludeFilter;
|
||||
public final Iterable<? extends T> roots;
|
||||
public final TreeTraversal traversal;
|
||||
public final Condition<? super T> expandFilter;
|
||||
public final Condition<? super T> childFilter;
|
||||
public final Condition<? super T> resultFilter;
|
||||
|
||||
public final Condition<? super T> forceExclude;
|
||||
public final Condition<? super T> forceExpandAndSkip;
|
||||
|
||||
public Meta(@NotNull Iterable<? extends T> roots,
|
||||
boolean skipExpanded,
|
||||
@NotNull TreeTraversal traversal,
|
||||
@NotNull Condition<? super T> expandFilter,
|
||||
@NotNull Condition<? super T> childFilter,
|
||||
@NotNull Condition<? super T> resultFilter,
|
||||
@NotNull Condition<? super T> excludeFilter) {
|
||||
@NotNull Condition<? super T> forceExclude,
|
||||
@NotNull Condition<? super T> forceExpandAndSkip) {
|
||||
this.roots = roots;
|
||||
this.skipExpanded = skipExpanded;
|
||||
this.traversal = traversal;
|
||||
this.expandFilter = expandFilter;
|
||||
this.childFilter = childFilter;
|
||||
this.resultFilter = resultFilter;
|
||||
this.excludeFilter = excludeFilter;
|
||||
this.forceExclude = forceExclude;
|
||||
this.forceExpandAndSkip = forceExpandAndSkip;
|
||||
}
|
||||
|
||||
public Meta<T> withRoots(@NotNull Iterable<? extends T> roots) {
|
||||
return new Meta<T>(roots, skipExpanded, expandFilter, childFilter, resultFilter, excludeFilter);
|
||||
return new Meta<T>(roots, traversal, expandFilter, childFilter, resultFilter, forceExclude, forceExpandAndSkip);
|
||||
}
|
||||
|
||||
public Meta<T> skipExpanded(boolean flag) {
|
||||
return new Meta<T>(roots, flag, expandFilter, childFilter, resultFilter, excludeFilter);
|
||||
public Meta<T> withTraversal(TreeTraversal traversal) {
|
||||
return new Meta<T>(roots, traversal, expandFilter, childFilter, resultFilter, forceExclude, forceExpandAndSkip);
|
||||
}
|
||||
|
||||
public Meta<T> expand(@NotNull Condition<? super T> filter) {
|
||||
return new Meta<T>(roots, skipExpanded, Conditions.and2(expandFilter, filter), childFilter, resultFilter, excludeFilter);
|
||||
return new Meta<T>(roots, traversal, and2(expandFilter, filter), childFilter, resultFilter, forceExclude,
|
||||
forceExpandAndSkip);
|
||||
}
|
||||
|
||||
public Meta<T> children(@NotNull Condition<? super T> filter) {
|
||||
return new Meta<T>(roots, skipExpanded, expandFilter, Conditions.and2(childFilter, filter), resultFilter, excludeFilter);
|
||||
return new Meta<T>(roots, traversal, expandFilter, and2(childFilter, filter), resultFilter, forceExclude,
|
||||
forceExpandAndSkip);
|
||||
}
|
||||
|
||||
public Meta<T> filter(@NotNull Condition<? super T> filter) {
|
||||
return new Meta<T>(roots, skipExpanded, expandFilter, childFilter, Conditions.and2(resultFilter, filter), excludeFilter);
|
||||
return new Meta<T>(roots, traversal, expandFilter, childFilter, and2(resultFilter, filter), forceExclude,
|
||||
forceExpandAndSkip);
|
||||
}
|
||||
|
||||
public Meta<T> exclude(Condition<? super T> filter) {
|
||||
// exclude filter is always accumulated
|
||||
return new Meta<T>(roots, skipExpanded, expandFilter, childFilter, resultFilter, Conditions.or2(excludeFilter, filter));
|
||||
// forceExclude and forceSkip filter is always accumulated
|
||||
public Meta<T> forceExclude(Condition<? super T> filter) {
|
||||
return new Meta<T>(roots, traversal, expandFilter, childFilter, resultFilter, or2(forceExclude, filter),
|
||||
forceExpandAndSkip);
|
||||
}
|
||||
|
||||
public Meta<T> forceExpandAndSkip(Condition<? super T> filter) {
|
||||
return new Meta<T>(roots, traversal, expandFilter, childFilter, resultFilter, forceExclude, or2(forceExpandAndSkip, filter));
|
||||
}
|
||||
|
||||
public Meta<T> forChildren(JBIterable<T> children) {
|
||||
Condition<T> expand = or2(forceExpandAndSkip, not(childFilter));
|
||||
return new Meta<T>(children, TreeTraversal.LEAVES_ONLY_DFS, expand, TRUE, not(or2(expand, forceExclude)), FALSE, FALSE);
|
||||
}
|
||||
|
||||
private static final Meta<?> EMPTY = new Meta<Object>(
|
||||
JBIterable.empty(), false, Conditions.TRUE, Conditions.TRUE, Conditions.TRUE, Conditions.FALSE);
|
||||
JBIterable.empty(), TreeTraversal.PRE_ORDER_DFS,
|
||||
TRUE, TRUE, TRUE,
|
||||
FALSE, FALSE);
|
||||
|
||||
public static <T> Meta<T> empty() {
|
||||
return (Meta<T>)EMPTY;
|
||||
}
|
||||
|
||||
public Meta<T> forChildren(Iterable<? extends T> children) {
|
||||
return new Meta<T>(children, false, Conditions.not(childFilter), Conditions.TRUE, childFilter, excludeFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Functions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* A redesigned version of com.google.common.collect.TreeTraversal.
|
||||
@@ -203,55 +202,51 @@ public abstract class TreeTraversal {
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
private abstract static class DfsIt<T> extends TracingIt<T> {
|
||||
final ArrayDeque<Pair<T, Iterator<? extends T>>> stack = new ArrayDeque<Pair<T, Iterator<? extends T>>>();
|
||||
final ArrayDeque<P<T>> stack = new ArrayDeque<P<T>>();
|
||||
|
||||
@Nullable
|
||||
public T parent() {
|
||||
Iterator<Pair<T, Iterator<? extends T>>> it = stack.descendingIterator();
|
||||
if (stack.isEmpty()) throw new NoSuchElementException();
|
||||
Iterator<P<T>> it = stack.descendingIterator();
|
||||
it.next();
|
||||
return it.hasNext() ? it.next().first : null;
|
||||
return it.hasNext() ? it.next().node : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JBIterable<T> backtrace() {
|
||||
return new JBIterable<Pair<T, Iterator<? extends T>>>() {
|
||||
if (stack.isEmpty()) throw new NoSuchElementException();
|
||||
return new JBIterable<P<T>>() {
|
||||
@Override
|
||||
public Iterator<Pair<T, Iterator<? extends T>>> iterator() {
|
||||
Iterator<Pair<T, Iterator<? extends T>>> iterator = stack.descendingIterator();
|
||||
iterator.next();
|
||||
return iterator;
|
||||
public Iterator<P<T>> iterator() {
|
||||
return stack.descendingIterator();
|
||||
}
|
||||
}.transform(Functions.<T>pairFirst()).filter(Condition.NOT_NULL);
|
||||
}.transform(P.<T>toNode()).filter(Condition.NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
private final static class PreOrderIt<T> extends DfsIt<T> {
|
||||
|
||||
final Function<T, ? extends Iterable<? extends T>> tree;
|
||||
int doneCount;
|
||||
|
||||
PreOrderIt(@NotNull Iterable<? extends T> roots, Function<T, ? extends Iterable<? extends T>> tree) {
|
||||
this.tree = tree;
|
||||
Iterator<? extends T> iterator = roots.iterator();
|
||||
if (iterator.hasNext()) {
|
||||
stack.addLast(Pair.<T, Iterator<? extends T>>create(null, iterator));
|
||||
}
|
||||
stack.addLast(P.create(roots));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T nextImpl() {
|
||||
if (stack.size() <= doneCount) return stop();
|
||||
Pair<T, Iterator<? extends T>> top;
|
||||
while (!(top = stack.getLast()).second.hasNext()) {
|
||||
stack.removeLast();
|
||||
doneCount--;
|
||||
while (!stack.isEmpty()) {
|
||||
Iterator<? extends T> it = stack.getLast().iterator(tree);
|
||||
if (it.hasNext()) {
|
||||
T result = it.next();
|
||||
stack.addLast(P.create(result));
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
stack.removeLast();
|
||||
}
|
||||
}
|
||||
T result = top.second.next();
|
||||
if (!top.second.hasNext()) doneCount++;
|
||||
Iterator<? extends T> childItr = children(result, tree).iterator();
|
||||
stack.addLast(Pair.<T, Iterator<? extends T>>create(result, childItr));
|
||||
if (!childItr.hasNext()) doneCount++;
|
||||
return result;
|
||||
return stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,21 +257,20 @@ public abstract class TreeTraversal {
|
||||
PostOrderIt(@NotNull Iterable<? extends T> roots, Function<T, ? extends Iterable<? extends T>> tree) {
|
||||
this.tree = tree;
|
||||
for (T root : roots) {
|
||||
stack.addLast(Pair.<T, Iterator<? extends T>>create(root, children(root, tree).iterator()));
|
||||
stack.addLast(P.create(root));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T nextImpl() {
|
||||
while (!stack.isEmpty()) {
|
||||
Pair<T, Iterator<? extends T>> top = stack.getLast();
|
||||
if (top.second.hasNext()) {
|
||||
T child = top.second.next();
|
||||
stack.addLast(Pair.<T, Iterator<? extends T>>create(child, children(child, tree).iterator()));
|
||||
Iterator<? extends T> it = stack.getLast().iterator(tree);
|
||||
if (it.hasNext()) {
|
||||
T result = it.next();
|
||||
stack.addLast(P.create(result));
|
||||
}
|
||||
else {
|
||||
stack.removeLast();
|
||||
return top.first;
|
||||
return stack.removeLast().node;
|
||||
}
|
||||
}
|
||||
return stop();
|
||||
@@ -289,29 +283,20 @@ public abstract class TreeTraversal {
|
||||
|
||||
LeavesDfsIt(@NotNull Iterable<? extends T> roots, Function<T, ? extends Iterable<? extends T>> tree) {
|
||||
this.tree = tree;
|
||||
for (T root : roots) {
|
||||
Iterator<? extends T> childrenIt = children(root, tree).iterator();
|
||||
stack.addLast(Pair.<T, Iterator<? extends T>>create(root, childrenIt.hasNext() ? childrenIt : null));
|
||||
}
|
||||
stack.addLast(P.create(roots));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T nextImpl() {
|
||||
while (!stack.isEmpty()) {
|
||||
Pair<T, Iterator<? extends T>> top = stack.getLast();
|
||||
if (top.second != null && top.second.hasNext()) {
|
||||
T child = top.second.next();
|
||||
Iterator<? extends T> childrenIt = children(child, tree).iterator();
|
||||
if (childrenIt.hasNext()) {
|
||||
stack.addLast(Pair.<T, Iterator<? extends T>>create(child, childrenIt));
|
||||
}
|
||||
else {
|
||||
return child;
|
||||
}
|
||||
P<T> top = stack.getLast();
|
||||
if (top.iterator(tree).hasNext() && !top.empty) {
|
||||
T child = top.iterator(tree).next();
|
||||
stack.addLast(P.create(child));
|
||||
}
|
||||
else {
|
||||
stack.removeLast();
|
||||
if (top.second == null) return top.first;
|
||||
if (top.empty) return stack.isEmpty() ? stop() : top.node;
|
||||
}
|
||||
}
|
||||
return stop();
|
||||
@@ -410,4 +395,42 @@ public abstract class TreeTraversal {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static class P<T> {
|
||||
T node;
|
||||
Iterable<? extends T> itle;
|
||||
Iterator<? extends T> it;
|
||||
boolean empty;
|
||||
|
||||
Iterator<? extends T> iterator(@NotNull Function<T, ? extends Iterable<? extends T>> tree) {
|
||||
if (it != null) return it;
|
||||
it = (itle != null ? itle : (itle = children(node, tree))).iterator();
|
||||
empty = !it.hasNext();
|
||||
return it;
|
||||
}
|
||||
|
||||
static <T> P<T> create(T node) {
|
||||
P<T> p = new P<T>();
|
||||
p.node = node;
|
||||
return p;
|
||||
}
|
||||
|
||||
static <T> P<T> create(Iterable<? extends T> it) {
|
||||
P<T> p = new P<T>();
|
||||
p.itle = it;
|
||||
return p;
|
||||
}
|
||||
|
||||
static <T> Function<P<T>, T> toNode() {
|
||||
//noinspection unchecked
|
||||
return TO_NODE;
|
||||
}
|
||||
|
||||
static final Function TO_NODE = new Function<P<?>, Object>() {
|
||||
@Override
|
||||
public Object fun(P<?> tp) {
|
||||
return tp.node;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ public class StringBufferReplaceableByStringInspection extends BaseInspection {
|
||||
}
|
||||
|
||||
if (element instanceof PsiWhiteSpace) {
|
||||
if (element.getText().contains("\n")) {
|
||||
if (element.getText().contains("\n") && result.length() > 0) {
|
||||
result.append('\n'); // keep line break structure
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Linebreaks {
|
||||
|
||||
void m(String code) {
|
||||
String controlDigit = String.valueOf(code.charAt(5)) +
|
||||
code.charAt(7) +
|
||||
code.charAt(9) +
|
||||
code.charAt(11);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Linebreaks {
|
||||
|
||||
void m(String code) {
|
||||
String controlDigit = new Stri<caret>ngBuilder()
|
||||
.append(code.charAt(5))
|
||||
.append(code.charAt(7))
|
||||
.append(code.charAt(9))
|
||||
.append(code.charAt(11)).toString();
|
||||
}
|
||||
}
|
||||
+1
@@ -35,4 +35,5 @@ public class StringBufferReplaceableByStringFixTest extends IGQuickFixesTestCase
|
||||
public void testMethodCallOnString() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
|
||||
public void testComplex1() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
|
||||
public void testComplex2() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
|
||||
public void testLinebreaks() { doTest(InspectionGadgetsBundle.message("string.builder.replaceable.by.string.quickfix")); }
|
||||
}
|
||||
|
||||
+94
@@ -16,26 +16,43 @@
|
||||
package org.jetbrains.jps.maven.compiler;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Base64;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.artifacts.ArtifactBuildTaskProvider;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.BuildTask;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.ProjectBuildException;
|
||||
import org.jetbrains.jps.incremental.artifacts.impl.JpsArtifactUtil;
|
||||
import org.jetbrains.jps.maven.model.JpsMavenExtensionService;
|
||||
import org.jetbrains.jps.maven.model.impl.MavenModuleResourceConfiguration;
|
||||
import org.jetbrains.jps.maven.model.impl.MavenProjectConfiguration;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
import org.jetbrains.jps.model.artifact.elements.JpsArtifactRootElement;
|
||||
import org.jetbrains.jps.model.artifact.elements.JpsFileCopyPackagingElement;
|
||||
import org.jetbrains.jps.model.artifact.elements.JpsPackagingElement;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -72,6 +89,7 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP
|
||||
try {
|
||||
File output = new File(myArtifact.getOutputPath(), JarFile.MANIFEST_NAME);
|
||||
FileUtil.writeToFile(output, Base64.decode(moduleResourceConfiguration.manifest));
|
||||
handleSkinnyWars(context, projectConfiguration, moduleResourceConfiguration);
|
||||
}
|
||||
// do not fail the whole 'Make' if there is an invalid manifest cached (e.g. non encoded string generated by previous IDEA version)
|
||||
catch (Exception e) {
|
||||
@@ -80,6 +98,82 @@ public class MavenManifestGenerationBuildTaskProvider extends ArtifactBuildTaskP
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSkinnyWars(final CompileContext context,
|
||||
final MavenProjectConfiguration projectConfiguration,
|
||||
MavenModuleResourceConfiguration moduleResourceConfiguration) {
|
||||
if (!"ear".equals(moduleResourceConfiguration.modelMap.get("packaging"))) return;
|
||||
if (!Boolean.parseBoolean(moduleResourceConfiguration.modelMap.get("build.plugin.maven-ear-plugin.skinnyWars"))) return;
|
||||
|
||||
final String earClasspath = moduleResourceConfiguration.classpath;
|
||||
if (earClasspath == null) return;
|
||||
|
||||
final Map<String, String> earClasspathMap = ContainerUtil.map2Map(
|
||||
StringUtil.split(earClasspath, " "), new Function<String, Pair<String, String>>() {
|
||||
@Override
|
||||
public Pair<String, String> fun(String s) {
|
||||
final int idx = s.lastIndexOf("/");
|
||||
return Pair.create(s.substring(idx == -1 ? 0 : idx + 1), s);
|
||||
}
|
||||
});
|
||||
|
||||
JpsArtifactUtil.processPackagingElements(myArtifact.getRootElement(), new Processor<JpsPackagingElement>() {
|
||||
@Override
|
||||
public boolean process(JpsPackagingElement element) {
|
||||
if (!(element instanceof JpsFileCopyPackagingElement)) return true;
|
||||
|
||||
final String filePath = ((JpsFileCopyPackagingElement)element).getFilePath();
|
||||
final File skinnyManifest = new File(filePath);
|
||||
if (!"SKINNY_MANIFEST.MF".equals(skinnyManifest.getName())) return true;
|
||||
|
||||
final String skinnyWarModuleName = skinnyManifest.getParentFile().getParentFile().getName();
|
||||
final MavenModuleResourceConfiguration warConfiguration = projectConfiguration.moduleConfigurations.get(skinnyWarModuleName);
|
||||
if (warConfiguration == null || warConfiguration.classpath == null) return true;
|
||||
|
||||
try {
|
||||
final byte[] warManifestData = Base64.decode(warConfiguration.manifest);
|
||||
Manifest warManifest = new Manifest(new ByteArrayInputStream(warManifestData));
|
||||
|
||||
List<String> skinnyWarClasspath = ContainerUtil.newArrayList();
|
||||
for (String entry : StringUtil.split(warConfiguration.classpath, " ")) {
|
||||
final int idx = entry.lastIndexOf("/");
|
||||
final String entryName = entry.substring(idx == -1 ? 0 : idx + 1);
|
||||
final String earEntryPath = earClasspathMap.get(entryName);
|
||||
skinnyWarClasspath.add(earEntryPath == null ? entry : earEntryPath);
|
||||
}
|
||||
|
||||
final Attributes warManifestMainAttributes = warManifest.getMainAttributes();
|
||||
warManifestMainAttributes.putValue("Class-Path", StringUtil.join(skinnyWarClasspath, " "));
|
||||
|
||||
FileUtil.createParentDirs(skinnyManifest);
|
||||
FileOutputStream outputStream = new FileOutputStream(skinnyManifest);
|
||||
try {
|
||||
warManifest.write(outputStream);
|
||||
|
||||
final ProjectDescriptor projectDescriptor = context.getProjectDescriptor();
|
||||
final Collection<BuildRootDescriptor> descriptors =
|
||||
projectDescriptor.getBuildRootIndex().findAllParentDescriptors(skinnyManifest, context);
|
||||
for (BuildRootDescriptor descriptor : descriptors) {
|
||||
try {
|
||||
projectDescriptor.fsState.markDirty(context, skinnyManifest, descriptor, projectDescriptor.timestamps.getStorage());
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
StreamUtil.closeStream(outputStream);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.debug(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getModuleName(@NotNull String artifactName) {
|
||||
return StringUtil.substringBefore(artifactName, ":");
|
||||
|
||||
+5
@@ -45,6 +45,10 @@ public class MavenModuleResourceConfiguration {
|
||||
@Tag("manifest")
|
||||
public String manifest;
|
||||
|
||||
@Nullable
|
||||
@Tag("classpath")
|
||||
public String classpath;
|
||||
|
||||
@NotNull
|
||||
@Tag("delimiters-pattern")
|
||||
public String delimitersPattern;
|
||||
@@ -110,6 +114,7 @@ public class MavenModuleResourceConfiguration {
|
||||
result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
|
||||
result = 31 * result + directory.hashCode();
|
||||
result = 31 * result + (manifest != null ? manifest.hashCode() : 0);
|
||||
result = 31 * result + (classpath != null ? classpath.hashCode() : 0);
|
||||
result = 31 * result + delimitersPattern.hashCode();
|
||||
result = 31 * result + modelMap.hashCode();
|
||||
result = 31 * result + properties.hashCode();
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public abstract class ManifestImporter {
|
||||
String classpathPrefix = getClasspathPrefix(manifestConfiguration);
|
||||
for (MavenArtifact mavenArtifact : mavenProject.getDependencies()) {
|
||||
final DependencyScope scope = MavenModuleImporter.selectScope(mavenArtifact.getScope());
|
||||
if (scope.isForProductionRuntime()) {
|
||||
if (scope.isForProductionCompile() || scope.isForProductionRuntime()) {
|
||||
if (classpath.length() > 0) {
|
||||
classpath.append(" ");
|
||||
}
|
||||
|
||||
@@ -149,6 +149,12 @@ public abstract class MavenImporter {
|
||||
Map<MavenProject, String> mavenProjectToModuleName,
|
||||
List<MavenProjectsProcessorTask> postTasks);
|
||||
|
||||
public void postProcess(Module module,
|
||||
MavenProject mavenProject,
|
||||
MavenProjectChanges changes,
|
||||
MavenModifiableModelsProvider modifiableModelsProvider) {
|
||||
}
|
||||
|
||||
public boolean processChangedModulesOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
+25
@@ -159,6 +159,31 @@ public class MavenModuleImporter {
|
||||
});
|
||||
}
|
||||
|
||||
public void postConfigFacets() {
|
||||
MavenUtil.invokeAndWaitWriteAction(myModule.getProject(), new Runnable() {
|
||||
public void run() {
|
||||
if (myModule.isDisposed()) return;
|
||||
|
||||
final ModuleType moduleType = ModuleType.get(myModule);
|
||||
|
||||
for (final MavenImporter importer : getSuitableImporters()) {
|
||||
final MavenProjectChanges changes;
|
||||
if (myMavenProjectChanges == null) {
|
||||
if (importer.processChangedModulesOnly()) continue;
|
||||
changes = MavenProjectChanges.NONE;
|
||||
}
|
||||
else {
|
||||
changes = myMavenProjectChanges;
|
||||
}
|
||||
|
||||
if (importer.getModuleType() == moduleType) {
|
||||
importer.postProcess(myModule, myMavenProject, changes, myModifiableModelsProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<MavenImporter> getSuitableImporters() {
|
||||
return myMavenProject.getSuitableImporters();
|
||||
}
|
||||
|
||||
+6
-2
@@ -431,7 +431,7 @@ public class MavenProjectImporter {
|
||||
javacOptions.ADDITIONAL_OPTIONS_STRING = options;
|
||||
}
|
||||
|
||||
private void importModules(final List<MavenProjectsProcessorTask> postTasks) {
|
||||
private void importModules(final List<MavenProjectsProcessorTask> tasks) {
|
||||
Map<MavenProject, MavenProjectChanges> projectsWithChanges = myProjectsToImportWithChanges;
|
||||
|
||||
Set<MavenProject> projectsWithNewlyCreatedModules = new THashSet<MavenProject>();
|
||||
@@ -471,7 +471,11 @@ public class MavenProjectImporter {
|
||||
}
|
||||
|
||||
for (MavenModuleImporter importer : importers) {
|
||||
importer.configFacets(postTasks);
|
||||
importer.configFacets(tasks);
|
||||
}
|
||||
|
||||
for (MavenModuleImporter importer : importers) {
|
||||
importer.postConfigFacets();
|
||||
}
|
||||
|
||||
setMavenizedModules(modulesToMavenize, true);
|
||||
|
||||
+9
@@ -129,6 +129,8 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
addEarModelMapEntries(mavenProject, resourceConfig.modelMap);
|
||||
|
||||
Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
|
||||
|
||||
resourceConfig.outputDirectory = getResourcesPluginGoalOutputDirectory(mavenProject, pluginConfiguration, "resources");
|
||||
@@ -190,6 +192,12 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
});
|
||||
}
|
||||
|
||||
private static void addEarModelMapEntries(@NotNull MavenProject mavenProject, @NotNull Map<String, String> modelMap) {
|
||||
Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-ear-plugin");
|
||||
final String skinnyWars = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "skinnyWars", "false");
|
||||
modelMap.put("build.plugin.maven-ear-plugin.skinnyWars", skinnyWars);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getResourcesPluginGoalOutputDirectory(@NotNull MavenProject mavenProject,
|
||||
@Nullable Element pluginConfiguration,
|
||||
@@ -234,6 +242,7 @@ public class MavenResourceCompilerConfigurationGenerator {
|
||||
finally {
|
||||
StreamUtil.closeStream(outputStream);
|
||||
}
|
||||
resourceConfig.classpath = ManifestBuilder.getClasspath(mavenProject);
|
||||
}
|
||||
catch (ManifestBuilder.ManifestBuilderException e) {
|
||||
LOG.warn("Unable to generate artifact manifest", e);
|
||||
|
||||
@@ -67,18 +67,7 @@ public class ManifestBuilder {
|
||||
@NotNull
|
||||
public java.util.jar.Manifest build() throws ManifestBuilderException {
|
||||
try {
|
||||
Element mavenPackagingPluginConfiguration = null;
|
||||
final String packaging = myMavenProject.getPackaging();
|
||||
if (StringUtil.isEmpty(packaging)) {
|
||||
mavenPackagingPluginConfiguration = myMavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-jar-plugin");
|
||||
}
|
||||
else {
|
||||
final String pluginArtifactId = PACKAGING_PLUGINS.get(StringUtil.toLowerCase(packaging));
|
||||
if (pluginArtifactId != null) {
|
||||
mavenPackagingPluginConfiguration = myMavenProject.getPluginConfiguration("org.apache.maven.plugins", pluginArtifactId);
|
||||
}
|
||||
}
|
||||
|
||||
Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(myMavenProject);
|
||||
final Element mavenArchiveConfiguration =
|
||||
mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null;
|
||||
|
||||
@@ -110,6 +99,16 @@ public class ManifestBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getClasspath(@NotNull MavenProject mavenProject) {
|
||||
Element mavenPackagingPluginConfiguration = getMavenPackagingPluginConfiguration(mavenProject);
|
||||
final Element mavenArchiveConfiguration =
|
||||
mavenPackagingPluginConfiguration != null ? mavenPackagingPluginConfiguration.getChild("archive") : null;
|
||||
final Element manifestConfiguration = mavenArchiveConfiguration != null ? mavenArchiveConfiguration.getChild("manifest") : null;
|
||||
final ManifestImporter manifestImporter = ManifestImporter.getManifestImporter(mavenProject.getPackaging());
|
||||
return manifestImporter.getClasspath(mavenProject, manifestConfiguration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getClasspathPrefix(@Nullable Element manifestConfiguration) {
|
||||
String classpathPrefix = MavenJDOMUtil.findChildValueByPath(manifestConfiguration, "classpathPrefix", "").replaceAll("\\\\", "/");
|
||||
@@ -119,6 +118,22 @@ public class ManifestBuilder {
|
||||
return classpathPrefix;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Element getMavenPackagingPluginConfiguration(@NotNull MavenProject mavenProject) {
|
||||
Element mavenPackagingPluginConfiguration = null;
|
||||
final String packaging = mavenProject.getPackaging();
|
||||
if (StringUtil.isEmpty(packaging)) {
|
||||
mavenPackagingPluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-jar-plugin");
|
||||
}
|
||||
else {
|
||||
final String pluginArtifactId = PACKAGING_PLUGINS.get(StringUtil.toLowerCase(packaging));
|
||||
if (pluginArtifactId != null) {
|
||||
mavenPackagingPluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", pluginArtifactId);
|
||||
}
|
||||
}
|
||||
return mavenPackagingPluginConfiguration;
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, String> getManifestEntries(Element manifestEntries) {
|
||||
boolean hasManifestEntries = manifestEntries != null && manifestEntries.getContentSize() > 0;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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
|
||||
* 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
|
||||
* 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.
|
||||
* 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.tasks.actions;
|
||||
@@ -29,7 +29,7 @@ import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.tasks.Task;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SortedListModel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -141,17 +141,17 @@ public abstract class SearchSupport<T extends Task> {
|
||||
|
||||
if ("selectNextRow".equals(action)) {
|
||||
if (ensureSelectionExists()) {
|
||||
ListScrollingUtil.moveDown(myList, e.getModifiersEx());
|
||||
ScrollingUtil.moveDown(myList, e.getModifiersEx());
|
||||
}
|
||||
}
|
||||
else if ("selectPreviousRow".equals(action)) {
|
||||
ListScrollingUtil.moveUp(myList, e.getModifiersEx());
|
||||
ScrollingUtil.moveUp(myList, e.getModifiersEx());
|
||||
}
|
||||
else if ("scrollDown".equals(action)) {
|
||||
ListScrollingUtil.movePageDown(myList);
|
||||
ScrollingUtil.movePageDown(myList);
|
||||
}
|
||||
else if ("scrollUp".equals(action)) {
|
||||
ListScrollingUtil.movePageUp(myList);
|
||||
ScrollingUtil.movePageUp(myList);
|
||||
}
|
||||
else if ((e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB) && e.getModifiers() == 0) {
|
||||
hideCurrentPopup();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,8 @@ package com.theoryinpractice.testng.configuration.browser;
|
||||
|
||||
import com.intellij.openapi.ui.DialogBuilder;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.ui.ListScrollingUtil;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SortedListModel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -50,7 +50,7 @@ public class GroupList extends JPanel
|
||||
model.addAll(array);
|
||||
add(ScrollPaneFactory.createScrollPane(list));
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
ListScrollingUtil.ensureSelectionExists(list);
|
||||
ScrollingUtil.ensureSelectionExists(list);
|
||||
}
|
||||
|
||||
public String getSelected()
|
||||
|
||||
Reference in New Issue
Block a user