Merge remote-tracking branch 'origin/master'
@@ -41,35 +41,22 @@ public final class EmptyPanelTest extends TestCase {
|
||||
|
||||
// add component
|
||||
final JButton button = new JButton();
|
||||
button.setPreferredSize(new Dimension(100, 20));
|
||||
button.setPreferredSize(new Dimension(100, 40));
|
||||
panel.add(button,
|
||||
new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW,
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null,
|
||||
0));
|
||||
GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
// wisdom
|
||||
layoutManager.invalidateLayout(panel);
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(new Dimension(100, 29), panel.getPreferredSize());
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout();
|
||||
assertEquals(100, button.getWidth());
|
||||
assertEquals(29, panel.getHeight());
|
||||
assertEquals(new Dimension(100, 40), panel.getPreferredSize());
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout();
|
||||
assertEquals(100, button.getWidth());
|
||||
assertEquals(40, panel.getHeight());
|
||||
|
||||
assertTrue(Arrays.equals(new int[]{0, 29}, layoutManager.getYs()));
|
||||
assertTrue(Arrays.equals(new int[]{29, 0}, layoutManager.getHeights()));
|
||||
}
|
||||
else {
|
||||
assertEquals(new Dimension(100, 20), panel.getPreferredSize());
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout();
|
||||
assertEquals(100, button.getWidth());
|
||||
assertEquals(20, panel.getHeight());
|
||||
|
||||
assertTrue(Arrays.equals(new int[]{0, 20}, layoutManager.getYs()));
|
||||
assertTrue(Arrays.equals(new int[]{20, 0}, layoutManager.getHeights()));
|
||||
}
|
||||
assertTrue(Arrays.equals(new int[]{0, 40}, layoutManager.getYs()));
|
||||
assertTrue(Arrays.equals(new int[]{40, 0}, layoutManager.getHeights()));
|
||||
|
||||
assertTrue(Arrays.equals(new int[]{0, 0, 100}, layoutManager.getXs()));
|
||||
assertTrue(Arrays.equals(new int[]{0, 100, 0}, layoutManager.getWidths()));
|
||||
|
||||
@@ -20,20 +20,20 @@ import junit.framework.TestCase;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public final class GapsTest extends TestCase{
|
||||
public final class GapsTest extends TestCase {
|
||||
public void test1() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(1,2, new Insets(0,0,0,0), 10, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), 10, 0));
|
||||
|
||||
final JTextField field1 = new JTextField();
|
||||
field1.setPreferredSize(new Dimension(100,20));
|
||||
field1.setPreferredSize(new Dimension(100, 20));
|
||||
final JTextField field2 = new JTextField();
|
||||
field2.setPreferredSize(new Dimension(100,20));
|
||||
field2.setPreferredSize(new Dimension(100, 20));
|
||||
|
||||
panel.add(field1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
assertEquals(210, preferredSize.width);
|
||||
@@ -43,18 +43,18 @@ public final class GapsTest extends TestCase{
|
||||
* field (span 2) | field (span 1)
|
||||
*/
|
||||
public void test2() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(1,3, new Insets(0,0,0,0), 7, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), 7, 0));
|
||||
|
||||
final JTextField field1 = new JTextField();
|
||||
field1.setPreferredSize(new Dimension(100,20));
|
||||
field1.setPreferredSize(new Dimension(100, 40));
|
||||
final JTextField field2 = new JTextField();
|
||||
field2.setPreferredSize(new Dimension(100,20));
|
||||
field2.setPreferredSize(new Dimension(100, 40));
|
||||
|
||||
panel.add(field1, new GridConstraints(0,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field2, new GridConstraints(0,2,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
assertEquals(207, preferredSize.width);
|
||||
@@ -62,44 +62,38 @@ public final class GapsTest extends TestCase{
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout();
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(new Rectangle(0,0,100,26), field1.getBounds());
|
||||
assertEquals(new Rectangle(107,0,100,26), field2.getBounds());
|
||||
} else {
|
||||
assertEquals(new Rectangle(0,0,100,20), field1.getBounds());
|
||||
assertEquals(new Rectangle(107,0,100,20), field2.getBounds());
|
||||
}
|
||||
assertEquals(new Rectangle(0, 0, 100, 40), field1.getBounds());
|
||||
assertEquals(new Rectangle(107, 0, 100, 40), field2.getBounds());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* btn1 | btn2 | btn4
|
||||
* btn3 (span 2) |
|
||||
* btn3 (span 2) |
|
||||
*/
|
||||
public void test3() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2,3, new Insets(0,0,0,0), 7, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), 7, 0));
|
||||
|
||||
final JButton btn1 = new JButton();
|
||||
btn1.setPreferredSize(new Dimension(100,20));
|
||||
btn1.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn2 = new JButton();
|
||||
btn2.setPreferredSize(new Dimension(100,20));
|
||||
btn2.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn3 = new JButton();
|
||||
btn3.setPreferredSize(new Dimension(100,20));
|
||||
btn3.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn4 = new JButton();
|
||||
btn4.setPreferredSize(new Dimension(100,20));
|
||||
btn4.setPreferredSize(new Dimension(100, 20));
|
||||
|
||||
panel.add(btn1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn3, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn4, new GridConstraints(0,2,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
assertEquals(314, preferredSize.width);
|
||||
@@ -109,33 +103,32 @@ public final class GapsTest extends TestCase{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* btn1 | btn2 | btn4
|
||||
* btn3 (span 2) |
|
||||
* btn3 (span 2) |
|
||||
*/
|
||||
public void test3a() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2,3, new Insets(0,0,0,0), 1000, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), 1000, 0));
|
||||
|
||||
final JButton btn1 = new JButton();
|
||||
btn1.setPreferredSize(new Dimension(100,20));
|
||||
btn1.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn2 = new JButton();
|
||||
btn2.setPreferredSize(new Dimension(100,20));
|
||||
btn2.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn3 = new JButton();
|
||||
btn3.setPreferredSize(new Dimension(100,20));
|
||||
btn3.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn4 = new JButton();
|
||||
btn4.setPreferredSize(new Dimension(100,20));
|
||||
btn4.setPreferredSize(new Dimension(100, 20));
|
||||
|
||||
panel.add(btn1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn3, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn4, new GridConstraints(0,2,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
assertEquals(2300, preferredSize.width);
|
||||
@@ -145,28 +138,27 @@ public final class GapsTest extends TestCase{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* btn1 | btn2
|
||||
* btn3 (span 2)
|
||||
* btn3 (span 2)
|
||||
*/
|
||||
public void test3b() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2,3, new Insets(0,0,0,0), 1000, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), 1000, 0));
|
||||
|
||||
final JButton btn1 = new JButton();
|
||||
btn1.setPreferredSize(new Dimension(100,20));
|
||||
btn1.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn2 = new JButton();
|
||||
btn2.setPreferredSize(new Dimension(100,20));
|
||||
btn2.setPreferredSize(new Dimension(100, 20));
|
||||
final JButton btn3 = new JButton();
|
||||
btn3.setPreferredSize(new Dimension(100,20));
|
||||
btn3.setPreferredSize(new Dimension(100, 20));
|
||||
|
||||
panel.add(btn1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn2, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn3, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn3, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
assertEquals(1200, preferredSize.width);
|
||||
@@ -183,25 +175,20 @@ public final class GapsTest extends TestCase{
|
||||
* btn2
|
||||
*/
|
||||
public void test4() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(3,1, new Insets(0,0,0,0), 0, 7));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), 0, 7));
|
||||
|
||||
final JButton btn1 = new JButton();
|
||||
btn1.setPreferredSize(new Dimension(100,20));
|
||||
btn1.setPreferredSize(new Dimension(100, 40));
|
||||
final JButton btn2 = new JButton();
|
||||
btn2.setPreferredSize(new Dimension(100,20));
|
||||
btn2.setPreferredSize(new Dimension(100, 40));
|
||||
|
||||
panel.add(btn1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn2, new GridConstraints(2,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(65, preferredSize.height);
|
||||
} else {
|
||||
assertEquals(47, preferredSize.height);
|
||||
}
|
||||
assertEquals(87, panel.getPreferredSize().height);
|
||||
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout();
|
||||
@@ -215,28 +202,24 @@ public final class GapsTest extends TestCase{
|
||||
* btn2
|
||||
*/
|
||||
public void test5() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(3,1, new Insets(0,0,0,0), 0, 7));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), 0, 7));
|
||||
|
||||
final JButton btn1 = new JButton();
|
||||
btn1.setPreferredSize(new Dimension(100,20));
|
||||
btn1.setPreferredSize(new Dimension(100, 40));
|
||||
final JButton btn2 = new JButton();
|
||||
btn2.setPreferredSize(new Dimension(100,20));
|
||||
btn2.setPreferredSize(new Dimension(100, 40));
|
||||
|
||||
panel.add(btn1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(new Spacer(), new GridConstraints(1,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0));
|
||||
panel.add(new Spacer(), new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null,
|
||||
0));
|
||||
|
||||
panel.add(btn2, new GridConstraints(2,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(65, preferredSize.height);
|
||||
} else {
|
||||
assertEquals(47, preferredSize.height);
|
||||
}
|
||||
assertEquals(87, panel.getPreferredSize().height);
|
||||
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout();
|
||||
@@ -248,28 +231,22 @@ public final class GapsTest extends TestCase{
|
||||
* btn2
|
||||
*/
|
||||
public void test6() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2,1, new Insets(0,0,0,0), 0, 500));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), 0, 500));
|
||||
|
||||
final JButton btn1 = new JButton();
|
||||
btn1.setPreferredSize(new Dimension(100,20));
|
||||
btn1.setPreferredSize(new Dimension(100, 40));
|
||||
final JButton btn2 = new JButton();
|
||||
btn2.setPreferredSize(new Dimension(100,20));
|
||||
btn2.setPreferredSize(new Dimension(100, 40));
|
||||
|
||||
panel.add(btn1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(btn2, new GridConstraints(1,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(btn2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(558, preferredSize.height);
|
||||
} else {
|
||||
assertEquals(540, preferredSize.height);
|
||||
}
|
||||
assertEquals(580, panel.getPreferredSize().height);
|
||||
|
||||
panel.setSize(panel.getPreferredSize());
|
||||
panel.doLayout(); // should not crash
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,22 +20,21 @@ import junit.framework.TestCase;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public final class Layout3Test extends TestCase{
|
||||
public final class Layout3Test extends TestCase {
|
||||
public void test1() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2,1, new Insets(0,0,0,0), 0, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
final JButton button1 = new JButton();
|
||||
button1.setPreferredSize(new Dimension(100,20));
|
||||
button1.setPreferredSize(new Dimension(100, 40));
|
||||
final JButton button2 = new JButton();
|
||||
button2.setPreferredSize(new Dimension(100,100));
|
||||
button2.setPreferredSize(new Dimension(100, 100));
|
||||
|
||||
panel.add(button1, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(button1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(button2, new GridConstraints(1,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_BOTH,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(button2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
assertEquals(SystemInfo.isMac ? 129 : 120, preferredSize.height);
|
||||
assertEquals(140, panel.getPreferredSize().height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,133 +20,103 @@ import junit.framework.TestCase;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public final class SpansTest extends TestCase{
|
||||
|
||||
public final class SpansTest extends TestCase {
|
||||
|
||||
/**
|
||||
* button(can grow) | text field (want grow)
|
||||
* text field (want grow, span 2)
|
||||
*/
|
||||
* text field (want grow, span 2)
|
||||
*/
|
||||
public void test1() {
|
||||
final GridLayoutManager layout = new GridLayoutManager(2,2, new Insets(0,0,0,0), 0, 0);
|
||||
final GridLayoutManager layout = new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), 0, 0);
|
||||
final JPanel panel = new JPanel(layout);
|
||||
|
||||
final JButton button = new JButton();
|
||||
button.setPreferredSize(new Dimension(50, 10));
|
||||
|
||||
button.setPreferredSize(new Dimension(80, 10));
|
||||
|
||||
final JTextField field1 = new JTextField();
|
||||
field1.setPreferredSize(new Dimension(50, 10));
|
||||
|
||||
final JTextField field2 = new JTextField();
|
||||
|
||||
panel.add(button, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(button, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field1, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field2, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(125, preferredSize.width);
|
||||
} else {
|
||||
assertEquals(100, preferredSize.width);
|
||||
}
|
||||
assertEquals(130, panel.getPreferredSize().width);
|
||||
|
||||
panel.setSize(new Dimension(500, panel.getHeight()));
|
||||
panel.doLayout();
|
||||
|
||||
assertEquals(500, field2.getWidth());
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(75, button.getWidth());
|
||||
assertEquals(425, field1.getWidth());
|
||||
} else {
|
||||
assertEquals(50, button.getWidth());
|
||||
assertEquals(450, field1.getWidth());
|
||||
}
|
||||
assertEquals(80, button.getWidth());
|
||||
assertEquals(420, field1.getWidth());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* button(can grow) | text field (can grow)
|
||||
* text field (want grow, span 2)
|
||||
* text field (want grow, span 2)
|
||||
*/
|
||||
public void test2() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2,2, new Insets(0,0,0,0), 0, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
final JButton button = new JButton();
|
||||
button.setPreferredSize(new Dimension(50, 10));
|
||||
button.setPreferredSize(new Dimension(80, 10));
|
||||
|
||||
final JTextField field1 = new JTextField();
|
||||
field1.setPreferredSize(new Dimension(50, 10));
|
||||
field1.setPreferredSize(new Dimension(80, 10));
|
||||
|
||||
final JTextField field2 = new JTextField();
|
||||
|
||||
panel.add(button, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(button, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field1, new GridConstraints(0,1,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field2, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(125, preferredSize.width);
|
||||
} else {
|
||||
assertEquals(100, preferredSize.width);
|
||||
}
|
||||
assertEquals(160, panel.getPreferredSize().width);
|
||||
|
||||
panel.setSize(new Dimension(500, panel.getHeight()));
|
||||
panel.doLayout();
|
||||
|
||||
assertEquals(500, field2.getWidth());
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(263, button.getWidth());
|
||||
assertEquals(237, field1.getWidth());
|
||||
} else {
|
||||
assertEquals(250, button.getWidth());
|
||||
assertEquals(250, field1.getWidth());
|
||||
}
|
||||
assertEquals(250, button.getWidth());
|
||||
assertEquals(250, field1.getWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
* button(can grow) | text field (want grow, span 2)
|
||||
*/
|
||||
public void test3() {
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(1,3, new Insets(0,0,0,0), 0, 0));
|
||||
final JPanel panel = new JPanel(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), 0, 0));
|
||||
|
||||
final JButton button = new JButton();
|
||||
button.setPreferredSize(new Dimension(50, 10));
|
||||
button.setPreferredSize(new Dimension(80, 10));
|
||||
|
||||
final JTextField field1 = new JTextField();
|
||||
field1.setPreferredSize(new Dimension(110, 10));
|
||||
|
||||
panel.add(button, new GridConstraints(0,0,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(button, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field1, new GridConstraints(0,1,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field1, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(185, preferredSize.width);
|
||||
} else {
|
||||
assertEquals(160, preferredSize.width);
|
||||
}
|
||||
assertEquals(190, panel.getPreferredSize().width);
|
||||
|
||||
panel.setSize(new Dimension(500, panel.getHeight()));
|
||||
panel.doLayout();
|
||||
|
||||
if (SystemInfo.isMac) {
|
||||
assertEquals(75, button.getWidth());
|
||||
assertEquals(425, field1.getWidth());
|
||||
} else {
|
||||
assertEquals(50, button.getWidth());
|
||||
assertEquals(450, field1.getWidth());
|
||||
}
|
||||
assertEquals(80, button.getWidth());
|
||||
assertEquals(420, field1.getWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +124,7 @@ public final class SpansTest extends TestCase{
|
||||
* text field 2 (want grow, span 2) | empty
|
||||
*/
|
||||
public void test4() {
|
||||
final GridLayoutManager layoutManager = new GridLayoutManager(2,3, new Insets(0,0,0,0), 0, 0);
|
||||
final GridLayoutManager layoutManager = new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), 0, 0);
|
||||
final JPanel panel = new JPanel(layoutManager);
|
||||
|
||||
final JButton button = new JButton();
|
||||
@@ -166,14 +136,14 @@ public final class SpansTest extends TestCase{
|
||||
final JTextField field2 = new JTextField();
|
||||
field2.setPreferredSize(new Dimension(110, 10));
|
||||
|
||||
panel.add(button, new GridConstraints(0,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(button, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field1, new GridConstraints(0,2,1,1,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
panel.add(field2, new GridConstraints(1,0,1,2,GridConstraints.ANCHOR_CENTER,GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
panel.add(field2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0));
|
||||
|
||||
final Dimension preferredSize = panel.getPreferredSize();
|
||||
|
||||
@@ -184,7 +154,7 @@ public final class SpansTest extends TestCase{
|
||||
assertEquals(GridConstraints.SIZEPOLICY_WANT_GROW, horizontalInfo.getCellSizePolicy(2));
|
||||
|
||||
assertEquals(220, preferredSize.width);
|
||||
|
||||
|
||||
panel.setSize(new Dimension(500, panel.getHeight()));
|
||||
panel.doLayout();
|
||||
|
||||
@@ -192,5 +162,4 @@ public final class SpansTest extends TestCase{
|
||||
assertEquals(250, field1.getWidth());
|
||||
assertEquals(250, field2.getWidth());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.jdom.Element
|
||||
import org.jetbrains.jps.model.serialization.java.compiler.JpsJavaCompilerConfigurationSerializer
|
||||
import java.util.*
|
||||
|
||||
@State(name = "ExternalCompilerConfigurationStorage", storages = arrayOf(Storage("compiler.xml")), externalStorageOnly = true)
|
||||
@State(name = "ExternalCompilerConfiguration", storages = arrayOf(Storage("compiler.xml")), externalStorageOnly = true)
|
||||
internal class ExternalCompilerConfigurationStorage(private val project: Project) : PersistentStateComponent<Element>, ProjectModelElement {
|
||||
var loadedState: Map<String, String>? = null
|
||||
private set
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.daemon.GroupNames;
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -81,7 +82,7 @@ public class FieldAccessNotGuardedInspection extends AbstractBaseJavaLocalInspec
|
||||
if (guardExpression instanceof PsiThisExpression) {
|
||||
final PsiThisExpression thisExpression = (PsiThisExpression)guardExpression;
|
||||
final PsiClass aClass = getClassFromThisExpression(thisExpression, field);
|
||||
if (aClass == null || aClass.equals(containingMethod.getContainingClass())) {
|
||||
if (aClass == null || InheritanceUtil.isInheritorOrSelf(containingMethod.getContainingClass(), aClass, true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -132,7 +133,14 @@ public abstract class BaseConvertToLocalQuickFix<V extends PsiVariable> implemen
|
||||
variable,
|
||||
references,
|
||||
delete,
|
||||
declaration -> anchorBlock.addBefore(declaration, anchor)
|
||||
declaration -> {
|
||||
PsiElement parent = anchorBlock.getParent();
|
||||
if (parent instanceof PsiSwitchStatement) {
|
||||
PsiElement switchContainer = parent.getParent();
|
||||
return switchContainer.addBefore(declaration, parent);
|
||||
}
|
||||
return anchorBlock.addBefore(declaration, anchor);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,14 +155,20 @@ public abstract class BaseConvertToLocalQuickFix<V extends PsiVariable> implemen
|
||||
return WriteAction.compute(() -> {
|
||||
final PsiElement newDeclaration = moveDeclaration(elementFactory, localName, variable, initializer, action, references);
|
||||
if (delete) {
|
||||
beforeDelete(project, variable, newDeclaration);
|
||||
variable.normalizeDeclaration();
|
||||
variable.delete();
|
||||
deleteSourceVariable(project, variable, newDeclaration);
|
||||
}
|
||||
return newDeclaration;
|
||||
});
|
||||
}
|
||||
|
||||
protected void deleteSourceVariable(@NotNull Project project, @NotNull V variable, PsiElement newDeclaration) {
|
||||
CommentTracker tracker = new CommentTracker();
|
||||
beforeDelete(project, variable, newDeclaration);
|
||||
variable.normalizeDeclaration();
|
||||
tracker.delete(variable);
|
||||
tracker.insertCommentsBefore(newDeclaration);
|
||||
}
|
||||
|
||||
protected PsiElement moveDeclaration(PsiElementFactory elementFactory,
|
||||
String localName,
|
||||
V variable,
|
||||
|
||||
@@ -70,12 +70,7 @@ public class FieldCanBeLocalInspection extends FieldCanBeLocalInspectionBase {
|
||||
}
|
||||
if (element != null) {
|
||||
final PsiElement finalElement = element;
|
||||
Runnable runnable = () -> {
|
||||
beforeDelete(project, variable, finalElement);
|
||||
variable.normalizeDeclaration();
|
||||
variable.delete();
|
||||
};
|
||||
ApplicationManager.getApplication().runWriteAction(runnable);
|
||||
ApplicationManager.getApplication().runWriteAction(() -> deleteSourceVariable(project, variable, finalElement));
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -889,16 +889,13 @@ public class RefactoringUtil {
|
||||
final PsiElement invalidBody = lambdaExpression.getBody();
|
||||
if (invalidBody == null) return declaration;
|
||||
|
||||
final PsiLambdaExpression expressionFromText = (PsiLambdaExpression)elementFactory
|
||||
.createExpressionFromText(lambdaExpression.getParameterList().getText() + " -> {}", lambdaExpression.getParent());
|
||||
String lambdaParamListWithArrowAndComments = lambdaExpression.getText()
|
||||
.substring(0, (declaration.isPhysical() ? declaration : invalidBody).getStartOffsetInParent());
|
||||
final PsiLambdaExpression expressionFromText = (PsiLambdaExpression)elementFactory.createExpressionFromText(lambdaParamListWithArrowAndComments + "{}", lambdaExpression.getParent());
|
||||
PsiCodeBlock newBody = (PsiCodeBlock)expressionFromText.getBody();
|
||||
LOG.assertTrue(newBody != null);
|
||||
newBody.add(declaration);
|
||||
|
||||
lambdaExpression =
|
||||
(PsiLambdaExpression)lambdaExpression.replace(elementFactory.createExpressionFromText(
|
||||
lambdaExpression.getParameterList().getText() + " -> " + invalidBody.getText(), lambdaExpression));
|
||||
|
||||
final PsiElement lambdaExpressionBody = lambdaExpression.getBody();
|
||||
LOG.assertTrue(lambdaExpressionBody != null);
|
||||
final PsiStatement lastBodyStatement;
|
||||
|
||||
@@ -5,6 +5,7 @@ class ITest {
|
||||
|
||||
public IntelliJBugConvertToLocal(int x, int z) {
|
||||
|
||||
//my comment to keep in code
|
||||
ArrayList<String> mayBeLocal = new ArrayList<String>();
|
||||
if (x == 5) {
|
||||
mayBeLocal.add("jjj");
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Convert to local" "true"
|
||||
class TestFieldConversion
|
||||
{
|
||||
|
||||
public void someMethod(int s) {
|
||||
int someInt = 0;
|
||||
switch (s) {
|
||||
case 1:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
case 3:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import java.util.ArrayList;
|
||||
|
||||
class ITest {
|
||||
|
||||
private ArrayList<String> may<caret>BeLocal = new ArrayList<String>();
|
||||
private ArrayList<String> may<caret>BeLocal = new ArrayList<String>(); //my comment to keep in code
|
||||
|
||||
public IntelliJBugConvertToLocal(int x, int z) {
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Convert to local" "true"
|
||||
class TestFieldConversion
|
||||
{
|
||||
private int som<caret>eInt = 0;
|
||||
|
||||
public void someMethod(int s) {
|
||||
switch (s) {
|
||||
case 1:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
case 3:
|
||||
System.out.println(someInt);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,3 +104,14 @@ class Example3
|
||||
private long total = 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Example4 {
|
||||
@GuardedBy("this")
|
||||
protected Object field;
|
||||
|
||||
static class Example4Derived extends Example4 {
|
||||
synchronized void foo() {
|
||||
Object o = field;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ class X {
|
||||
public void foo(Class<?> cls)
|
||||
{
|
||||
Stream.of(cls.getMethods())
|
||||
.filter(method -> {
|
||||
.filter(method ->//my comment to keep
|
||||
{
|
||||
Class<?> c = method.getReturnType();
|
||||
return Collection.class.isAssignableFrom(c) || Map.class.isAssignableFrom(c);
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ class X {
|
||||
public void foo(Class<?> cls)
|
||||
{
|
||||
Stream.of(cls.getMethods())
|
||||
.filter(method ->
|
||||
.filter(method ->//my comment to keep
|
||||
Collection.class.isAssignableFrom(<selection>method.getReturnType()</selection>) || Map.class.isAssignableFrom(method.getReturnType()))
|
||||
.collect(Collectors.<Method>toList());
|
||||
}
|
||||
|
||||
@@ -40,12 +40,16 @@ public class JavacMain {
|
||||
private static final String JAVA_VERSION = System.getProperty("java.version", "");
|
||||
|
||||
//private static final boolean ECLIPSE_COMPILER_SINGLE_THREADED_MODE = Boolean.parseBoolean(System.getProperty("jdt.compiler.useSingleThread", "false"));
|
||||
private static final Set<String> FILTERED_OPTIONS = new HashSet<String>(Arrays.asList(
|
||||
private static final Set<String> FILTERED_OPTIONS = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
|
||||
"-d", "-classpath", "-cp", "-bootclasspath"
|
||||
));
|
||||
private static final Set<String> FILTERED_SINGLE_OPTIONS = new HashSet<String>(Arrays.asList(
|
||||
)));
|
||||
private static final Set<String> FILTERED_SINGLE_OPTIONS = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
|
||||
/*javac options*/ "-verbose", "-proc:only", "-implicit:class", "-implicit:none", "-Xprefer:newer", "-Xprefer:source"
|
||||
));
|
||||
)));
|
||||
private static final Set<String> FILE_MANAGER_EARLY_INIT_OPTIONS = Collections.unmodifiableSet(new HashSet<String>(Collections.singletonList(
|
||||
"-encoding"
|
||||
)));
|
||||
|
||||
public static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version");
|
||||
|
||||
public static boolean compile(Collection<String> options,
|
||||
@@ -91,8 +95,13 @@ public class JavacMain {
|
||||
// i.e. getJavaFileObjectsFromFiles()
|
||||
// This way the manager will be properly initialized. Namely, the encoding will be set correctly
|
||||
// Note that due to lazy initialization in various components inside javac, handleOption() should be called before setLocation() and others
|
||||
// update: for some options their repetitive initialization would be considered as error: e.g. '--patch-module',
|
||||
// therefore we do the trick only for those options that may influence FileManager's state initialization before passing it to getTask() method
|
||||
for (Iterator<String> iterator = _options.iterator(); iterator.hasNext(); ) {
|
||||
fileManager.handleOption(iterator.next(), iterator);
|
||||
final String option = iterator.next();
|
||||
if (FILE_MANAGER_EARLY_INIT_OPTIONS.contains(option)) {
|
||||
fileManager.handleOption(option, iterator);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class JpsLoaderBase {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <E extends JpsElement> Element loadComponentData(@NotNull JpsElementExtensionSerializerBase<E> serializer, Path configFile) {
|
||||
protected <E extends JpsElement> Element loadComponentData(@NotNull JpsElementExtensionSerializerBase<E> serializer, @NotNull Path configFile) {
|
||||
return JDomSerializationUtil.findComponent(loadRootElement(configFile), serializer.getComponentName());
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,23 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
return super.loadRootElement(file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected <E extends JpsElement> Element loadComponentData(@NotNull JpsElementExtensionSerializerBase<E> serializer, @NotNull Path configFile) {
|
||||
Path externalConfigDir = resolveExternalProjectConfig("project");
|
||||
Element data = super.loadComponentData(serializer, configFile);
|
||||
if (externalConfigDir != null && serializer.getComponentName().equals("CompilerConfiguration")) {
|
||||
Element externalData = JDomSerializationUtil.findComponent(loadRootElement(externalConfigDir.resolve(configFile.getFileName())), "External" + serializer.getComponentName());
|
||||
if (data == null) {
|
||||
return externalData;
|
||||
}
|
||||
else if (externalData != null) {
|
||||
return JDOMUtil.deepMerge(data, externalData);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private void loadFromDirectory(@NotNull Path dir) {
|
||||
myProject.setName(getDirectoryBaseProjectName(dir));
|
||||
Path defaultConfigFile = dir.resolve("misc.xml");
|
||||
|
||||
@@ -37,8 +37,9 @@ public class NamedScope {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NamedScope createCopy() {
|
||||
return new NamedScope(myName, myValue != null ? myValue.createCopy() : null);
|
||||
return new NamedScope(myName, myValue == null ? null : myValue.createCopy());
|
||||
}
|
||||
|
||||
public static class UnnamedScope extends NamedScope {
|
||||
|
||||
@@ -26,9 +26,10 @@ import org.jdom.Element
|
||||
// extended in upsource
|
||||
open class ProjectStateStorageManager(macroSubstitutor: TrackingPathMacroSubstitutor,
|
||||
private val project: ProjectImpl,
|
||||
useVirtualFileTracker: Boolean = true) : StateStorageManagerImpl("project", macroSubstitutor, if (useVirtualFileTracker) project else null) {
|
||||
useVirtualFileTracker: Boolean = true) : StateStorageManagerImpl(ROOT_TAG_NAME, macroSubstitutor, if (useVirtualFileTracker) project else null) {
|
||||
companion object {
|
||||
internal val VERSION_OPTION = "version"
|
||||
internal const val VERSION_OPTION = "version"
|
||||
const val ROOT_TAG_NAME = "project"
|
||||
}
|
||||
|
||||
override fun normalizeFileSpec(fileSpec: String) = removeMacroIfStartsWith(super.normalizeFileSpec(fileSpec), PROJECT_CONFIG_DIR)
|
||||
|
||||
@@ -243,7 +243,7 @@ open class StateStorageManagerImpl(private val rootTagName: String,
|
||||
@Suppress("DEPRECATION") stateSplitter: Class<out StateSplitter>,
|
||||
exclusive: Boolean = false): StateStorage {
|
||||
if (storageClass != StateStorage::class.java) {
|
||||
val constructor = storageClass.constructors.first()
|
||||
val constructor = storageClass.constructors.first { it.parameterCount <= 3 }
|
||||
constructor.isAccessible = true
|
||||
if (constructor.parameterCount == 2) {
|
||||
return constructor.newInstance(componentManager!!, this) as StateStorage
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.LogUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.StaticGetter;
|
||||
import com.intellij.psi.impl.DebugUtil;
|
||||
@@ -222,15 +223,17 @@ public class LazyParseableElement extends CompositeElement {
|
||||
}
|
||||
|
||||
private void setChildren(@NotNull TreeElement parsedNode, @Nullable AstPath thisPath) {
|
||||
try {
|
||||
AstPath.cacheNodePaths(this, parsedNode, thisPath);
|
||||
TreeElement last = rawSetParents(parsedNode, this);
|
||||
super.setFirstChildNode(parsedNode);
|
||||
super.setLastChildNode(last);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error("Chameleon expansion may not be interrupted by exceptions", e);
|
||||
}
|
||||
ProgressManager.getInstance().executeNonCancelableSection(() -> {
|
||||
try {
|
||||
AstPath.cacheNodePaths(this, parsedNode, thisPath);
|
||||
TreeElement last = rawSetParents(parsedNode, this);
|
||||
super.setFirstChildNode(parsedNode);
|
||||
super.setLastChildNode(last);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
LOG.error("Chameleon expansion may not be interrupted by exceptions", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.externalSystem.configurationStore
|
||||
|
||||
import com.intellij.configurationStore.StateMap
|
||||
import com.intellij.configurationStore.StateStorageManager
|
||||
import com.intellij.configurationStore.StreamProviderFactory
|
||||
import com.intellij.configurationStore.XmlElementStorage
|
||||
import com.intellij.configurationStore.*
|
||||
import com.intellij.openapi.components.RoamingType
|
||||
import com.intellij.openapi.components.StateSplitterEx
|
||||
import com.intellij.openapi.components.StoragePathMacros
|
||||
@@ -25,8 +22,7 @@ internal class ExternalModuleStorage(private val module: Module, storageManager:
|
||||
}
|
||||
}
|
||||
|
||||
// for libraries only for now - we use null rootElementName because the only component is expected (libraryTable)
|
||||
internal open class ExternalProjectStorage(fileSpec: String, project: Project, storageManager: StateStorageManager) : XmlElementStorage(fileSpec, null, storageManager.macroSubstitutor, RoamingType.DISABLED) {
|
||||
internal open class ExternalProjectStorage @JvmOverloads constructor(fileSpec: String, project: Project, storageManager: StateStorageManager, rootElementName: String? = ProjectStateStorageManager.ROOT_TAG_NAME /* several components per file */) : XmlElementStorage(fileSpec, rootElementName, storageManager.macroSubstitutor, RoamingType.DISABLED) {
|
||||
protected val manager = StreamProviderFactory.EP_NAME.getExtensions(project).first { it is ExternalSystemStreamProviderFactory } as ExternalSystemStreamProviderFactory
|
||||
|
||||
override final fun loadLocalData() = manager.fileStorage.read(fileSpec)
|
||||
@@ -38,7 +34,8 @@ internal open class ExternalProjectStorage(fileSpec: String, project: Project, s
|
||||
}
|
||||
}
|
||||
|
||||
internal class ExternalProjectFilteringStorage(fileSpec: String, project: Project, storageManager: StateStorageManager) : ExternalProjectStorage(fileSpec, project, storageManager) {
|
||||
// for libraries only for now - we use null rootElementName because the only component is expected (libraryTable)
|
||||
internal class ExternalProjectFilteringStorage(fileSpec: String, project: Project, storageManager: StateStorageManager) : ExternalProjectStorage(fileSpec, project, storageManager, null /* the only component per file */) {
|
||||
override fun createSaveSession(states: StateMap) = object : XmlElementStorageSaveSession<ExternalProjectStorage>(states, this) {
|
||||
override fun saveLocally(element: Element?) {
|
||||
if (element == null || !element.children.any { it.isMarkedAsExternal() }) {
|
||||
|
||||
@@ -34,6 +34,11 @@ public class NextVariableAction extends EditorAction {
|
||||
setInjectedContext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInTransaction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,11 @@ public class PreviousVariableAction extends EditorAction {
|
||||
setInjectedContext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInTransaction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class Handler extends EditorActionHandler {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.wm;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.BusyObject;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -26,6 +27,7 @@ import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ToolWindow extends BusyObject {
|
||||
|
||||
@@ -46,6 +48,24 @@ public interface ToolWindow extends BusyObject {
|
||||
|
||||
void activate(@Nullable Runnable runnable, boolean autoFocusContents, boolean forced);
|
||||
|
||||
/**
|
||||
* Activates the tool window.
|
||||
*
|
||||
* @param runnable A command to execute right after the window gets activated. The call is asynchronous since it may require animation.
|
||||
* @param selectedFile A file that user have selected to open the window.
|
||||
*/
|
||||
default void activate(@Nullable Runnable runnable, @Nullable VirtualFile selectedFile) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file that user have opened the window for.
|
||||
*
|
||||
* @return the file, selected by user or {@link Optional#empty()}, if the user have selected nothing or file info is unavailable.
|
||||
*/
|
||||
default Optional<VirtualFile> getSelectedFile() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the tool window is visible or not.
|
||||
* @exception IllegalStateException if tool window isn't installed.
|
||||
@@ -180,7 +200,7 @@ public interface ToolWindow extends BusyObject {
|
||||
void setShowStripeButton(boolean show);
|
||||
|
||||
boolean isShowStripeButton();
|
||||
|
||||
|
||||
boolean isDisposed();
|
||||
|
||||
void showContentPopup(InputEvent inputEvent);
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.awt.*;
|
||||
|
||||
/**
|
||||
* Cell renderer CPU optimization.
|
||||
* @see javax.swing.table.DefaultTableCellRenderer#invalidate()
|
||||
*
|
||||
* @author gregsh
|
||||
* @see javax.swing.table.DefaultTableCellRenderer#invalidate()
|
||||
*/
|
||||
public class CellRendererPanel extends JPanel {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CellRendererPanel extends JPanel {
|
||||
|
||||
public CellRendererPanel() {
|
||||
super(null); // we do the layout ourselves
|
||||
setOpaque(false); // to be consistent with #isOpaque
|
||||
super.setOpaque(false); // to be consistent with #isOpaque
|
||||
}
|
||||
|
||||
public final boolean isSelected() {
|
||||
@@ -50,10 +50,14 @@ public class CellRendererPanel extends JPanel {
|
||||
}
|
||||
|
||||
// isOpaque() optimization ----------------
|
||||
public boolean isOpaque() {
|
||||
public final boolean isOpaque() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOpaque(boolean isOpaque) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
if (mySelected) {
|
||||
@@ -98,7 +102,7 @@ public class CellRendererPanel extends JPanel {
|
||||
return getComponent(0).getPreferredSize();
|
||||
}
|
||||
|
||||
protected Dimension super_getPreferredSize() {
|
||||
protected final Dimension super_getPreferredSize() {
|
||||
return super.getPreferredSize();
|
||||
}
|
||||
|
||||
@@ -128,7 +132,7 @@ public class CellRendererPanel extends JPanel {
|
||||
doLayout();
|
||||
}
|
||||
|
||||
protected void super_validate() {
|
||||
protected final void super_validate() {
|
||||
super.validate();
|
||||
}
|
||||
|
||||
@@ -144,7 +148,7 @@ public class CellRendererPanel extends JPanel {
|
||||
public void repaint() {
|
||||
}
|
||||
|
||||
// END no validation methods --------------
|
||||
// END no validation methods --------------
|
||||
|
||||
public static class SuperPreferredSize extends CellRendererPanel {
|
||||
@Override
|
||||
@@ -153,6 +157,14 @@ public class CellRendererPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public static class SuperPreferredSizeWithBackground extends SuperPreferredSize {
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public static class SuperValidate extends SuperPreferredSize {
|
||||
@Override
|
||||
public void validate() {
|
||||
|
||||
@@ -573,6 +573,6 @@ public class DarculaLaf extends BasicLookAndFeel {
|
||||
}
|
||||
|
||||
public static Icon loadIcon(String iconName) {
|
||||
return IconLoader.findIcon("/com/intellij/ide/ui/laf/icons/" + iconName, DarculaLaf.class, true);
|
||||
return IconLoader.findIcon("/com/intellij/ide/ui/laf/darcula/icons/" + iconName, DarculaLaf.class, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 204 B |
|
After Width: | Height: | Size: 343 B |
|
After Width: | Height: | Size: 210 B |
|
After Width: | Height: | Size: 353 B |
|
After Width: | Height: | Size: 200 B |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 363 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 195 B |
|
After Width: | Height: | Size: 353 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 363 B |
|
After Width: | Height: | Size: 203 B |
|
After Width: | Height: | Size: 361 B |
|
After Width: | Height: | Size: 195 B |
|
After Width: | Height: | Size: 353 B |
|
After Width: | Height: | Size: 220 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 221 B |
|
After Width: | Height: | Size: 408 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 398 B |
@@ -0,0 +1,33 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.internal.statistic.customUsageCollectors;
|
||||
|
||||
import com.intellij.internal.statistic.UsagesCollector;
|
||||
import com.intellij.internal.statistic.beans.GroupDescriptor;
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class RegistryUsagesCollector extends UsagesCollector {
|
||||
private static final GroupDescriptor GROUP_ID = GroupDescriptor.create("Registry");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<UsageDescriptor> getUsages() {
|
||||
return Registry.getAll().stream()
|
||||
.filter(key -> key.isChangedFromDefault())
|
||||
.map(key -> new UsageDescriptor(key.getKey()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GroupDescriptor getGroupId() {
|
||||
return GROUP_ID;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.intellij.openapi.actionSystem.impl;
|
||||
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaLaf;
|
||||
import com.intellij.ide.ui.laf.intellij.MacIntelliJIconCache;
|
||||
import com.intellij.internal.statistic.customUsageCollectors.actions.MainMenuCollector;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
@@ -17,13 +19,10 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.SizedIcon;
|
||||
import com.intellij.ui.components.JBCheckBoxMenuItem;
|
||||
import com.intellij.ui.plaf.beg.BegMenuItemUI;
|
||||
import com.intellij.ui.plaf.gtk.GtkMenuItemUI;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -44,9 +43,6 @@ import java.util.Set;
|
||||
import static com.intellij.openapi.keymap.KeymapUtil.getActiveKeymapShortcuts;
|
||||
|
||||
public class ActionMenuItem extends JBCheckBoxMenuItem {
|
||||
private static final Icon ourCheckedIcon = JBUI.scale(new SizedIcon(PlatformIcons.CHECK_ICON, 18, 18));
|
||||
private static final Icon ourUncheckedIcon = EmptyIcon.ICON_18;
|
||||
|
||||
private final ActionRef<AnAction> myAction;
|
||||
private final Presentation myPresentation;
|
||||
private final String myPlace;
|
||||
@@ -224,12 +220,15 @@ public class ActionMenuItem extends JBCheckBoxMenuItem {
|
||||
}
|
||||
else if (!(getUI() instanceof GtkMenuItemUI)) {
|
||||
if (myToggled) {
|
||||
setIcon(ourCheckedIcon);
|
||||
setDisabledIcon(IconLoader.getDisabledIcon(ourCheckedIcon));
|
||||
boolean darcula = UIUtil.isUnderDarcula();
|
||||
setIcon(getIcon(darcula));
|
||||
setSelectedIcon(getSelectedIcon(darcula));
|
||||
setDisabledIcon(getDisabledIcon(darcula));
|
||||
}
|
||||
else {
|
||||
setIcon(ourUncheckedIcon);
|
||||
setDisabledIcon(IconLoader.getDisabledIcon(ourUncheckedIcon));
|
||||
setIcon(EmptyIcon.ICON_16);
|
||||
setSelectedIcon(EmptyIcon.ICON_16);
|
||||
setDisabledIcon(EmptyIcon.ICON_16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,6 +239,7 @@ public class ActionMenuItem extends JBCheckBoxMenuItem {
|
||||
icon = new PoppedIcon(icon, 16, 16);
|
||||
}
|
||||
setIcon(icon);
|
||||
setSelectedIcon(icon);
|
||||
if (myPresentation.getDisabledIcon() != null) {
|
||||
setDisabledIcon(myPresentation.getDisabledIcon());
|
||||
}
|
||||
@@ -250,6 +250,21 @@ public class ActionMenuItem extends JBCheckBoxMenuItem {
|
||||
}
|
||||
}
|
||||
|
||||
private static Icon getIcon(boolean darcula) {
|
||||
if (darcula) return DarculaLaf.loadIcon("checkmark.png");
|
||||
return MacIntelliJIconCache.getIcon("checkmark", false, false, true);
|
||||
}
|
||||
|
||||
private static Icon getSelectedIcon(boolean darcula) {
|
||||
if (darcula) return DarculaLaf.loadIcon("checkmarkSelected.png");
|
||||
return MacIntelliJIconCache.getIcon("checkmark", true, false, true);
|
||||
}
|
||||
|
||||
private static Icon getDisabledIcon(boolean darcula) {
|
||||
if (darcula) return DarculaLaf.loadIcon("checkmarkDisabled.png");
|
||||
return MacIntelliJIconCache.getIcon("checkmark", false, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon(Icon icon) {
|
||||
if (SystemInfo.isMacSystemMenu && ActionPlaces.MAIN_MENU.equals(myPlace)) {
|
||||
|
||||
@@ -351,13 +351,7 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
if (matcher instanceof ExtensionFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_EXT, ((ExtensionFileNameMatcher)matcher).getExtension());
|
||||
}
|
||||
else if (matcher instanceof WildcardFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((WildcardFileNameMatcher)matcher).getPattern());
|
||||
}
|
||||
else if (matcher instanceof ExactFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((ExactFileNameMatcher)matcher).getFileName());
|
||||
}
|
||||
else {
|
||||
else if (writePattern(matcher, mapping)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -376,13 +370,7 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
mapping.setAttribute(ATTRIBUTE_APPROVED, "true");
|
||||
}
|
||||
}
|
||||
else if (matcher instanceof WildcardFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((WildcardFileNameMatcher)matcher).getPattern());
|
||||
}
|
||||
else if (matcher instanceof ExactFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((ExactFileNameMatcher)matcher).getFileName());
|
||||
}
|
||||
else {
|
||||
else if (writePattern(matcher, mapping)) {
|
||||
return null;
|
||||
}
|
||||
if (specifyTypeName) {
|
||||
@@ -392,6 +380,19 @@ public class AbstractFileType extends UserFileType<AbstractFileType> implements
|
||||
return mapping;
|
||||
}
|
||||
|
||||
private static boolean writePattern(FileNameMatcher matcher, Element mapping) {
|
||||
if (matcher instanceof WildcardFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((WildcardFileNameMatcher)matcher).getPattern());
|
||||
}
|
||||
else if (matcher instanceof ExactFileNameMatcher) {
|
||||
mapping.setAttribute(ATTRIBUTE_PATTERN, ((ExactFileNameMatcher)matcher).getFileName());
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsEditor<AbstractFileType> getEditor() {
|
||||
return new CustomFileTypeEditor();
|
||||
|
||||
@@ -318,7 +318,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
}
|
||||
}
|
||||
else if (AbstractFileType.ELEMENT_EXTENSION_MAP.equals(e.getName())) {
|
||||
readGlobalMappings(e);
|
||||
readGlobalMappings(e, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
extensionMap.addContent(new Element(AbstractFileType.ELEMENT_MAPPING)
|
||||
.setAttribute(AbstractFileType.ATTRIBUTE_EXT, "tagx")
|
||||
.setAttribute(AbstractFileType.ATTRIBUTE_TYPE, "XML"));
|
||||
readGlobalMappings(extensionMap);
|
||||
readGlobalMappings(extensionMap, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1064,7 +1064,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
myIgnoredPatterns.setIgnoreMasks(element.getAttributeValue(ATTRIBUTE_LIST));
|
||||
}
|
||||
else if (AbstractFileType.ELEMENT_EXTENSION_MAP.equals(element.getName())) {
|
||||
readGlobalMappings(element);
|
||||
readGlobalMappings(element, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1144,7 +1144,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
}
|
||||
}
|
||||
|
||||
private void readGlobalMappings(@NotNull Element e) {
|
||||
private void readGlobalMappings(@NotNull Element e, boolean isAddToInit) {
|
||||
for (Pair<FileNameMatcher, String> association : AbstractFileType.readAssociations(e)) {
|
||||
FileType type = getFileTypeByName(association.getSecond());
|
||||
FileNameMatcher matcher = association.getFirst();
|
||||
@@ -1156,6 +1156,9 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements Persistent
|
||||
}
|
||||
}
|
||||
associate(type, matcher, false);
|
||||
if (isAddToInit) {
|
||||
myInitialAssociations.addAssociation(matcher, type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myUnresolvedMappings.put(matcher, association.getSecond());
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.BusyObject;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowEx;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
@@ -54,6 +55,7 @@ import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -79,6 +81,9 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
private boolean myPlaceholderMode;
|
||||
private ToolWindowFactory myContentFactory;
|
||||
|
||||
@Nullable
|
||||
private VirtualFile mySelectedFile;
|
||||
|
||||
private static final Set<KeyStroke> FORWARD_TRAVERSAL_KEYSTROKES = new HashSet<>(Arrays.asList(
|
||||
new KeyStroke[]{
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)
|
||||
@@ -210,6 +215,17 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate(@Nullable Runnable runnable, @Nullable VirtualFile selectedFile) {
|
||||
this.mySelectedFile = selectedFile;
|
||||
activate(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<VirtualFile> getSelectedFile() {
|
||||
return Optional.ofNullable(mySelectedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isActive() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
@@ -86,6 +86,13 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSelected(JMenuItem item) {
|
||||
if (item == null) return false;
|
||||
ButtonModel model = item.getModel();
|
||||
if (model == null) return false;
|
||||
return model.isArmed() || (item instanceof JMenu) && model.isSelected();
|
||||
}
|
||||
|
||||
public void paint(Graphics g, JComponent comp) {
|
||||
UISettings.setupAntialiasing(g);
|
||||
JMenuItem jmenuitem = (JMenuItem)comp;
|
||||
@@ -118,7 +125,7 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
if (comp.isOpaque() || (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF())){
|
||||
g.setColor(jmenuitem.getBackground());
|
||||
g.fillRect(0, 0, j1, k1);
|
||||
if (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected()){
|
||||
if (isSelected(jmenuitem)) {
|
||||
if (UIUtil.isUnderAquaLookAndFeel()) {
|
||||
myAquaSelectedBackgroundPainter.paintBorder(comp, g, 0, 0, j1, k1);
|
||||
} else {
|
||||
@@ -139,7 +146,7 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
g.setColor(color2);
|
||||
}
|
||||
if (icon2 != null){
|
||||
if (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected()){
|
||||
if (isSelected(jmenuitem)) {
|
||||
g.setColor(selectionForeground);
|
||||
}
|
||||
else{
|
||||
@@ -170,7 +177,7 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
}
|
||||
if (s1 != null && s1.length() > 0){
|
||||
if (buttonmodel.isEnabled()){
|
||||
if (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected()){
|
||||
if (isSelected(jmenuitem)) {
|
||||
g.setColor(selectionForeground);
|
||||
}
|
||||
else{
|
||||
@@ -195,11 +202,11 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
if (keyStrokeText != null && !keyStrokeText.isEmpty()){
|
||||
g.setFont(acceleratorFont);
|
||||
if (buttonmodel.isEnabled()){
|
||||
if (UIUtil.isUnderAquaBasedLookAndFeel() && (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected())) {
|
||||
if (UIUtil.isUnderAquaBasedLookAndFeel() && isSelected(jmenuitem)) {
|
||||
g.setColor(selectionForeground);
|
||||
}
|
||||
else {
|
||||
if (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected()) {
|
||||
if (isSelected(jmenuitem)) {
|
||||
g.setColor(acceleratorSelectionForeground);
|
||||
}
|
||||
else {
|
||||
@@ -221,7 +228,7 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
}
|
||||
}
|
||||
if (arrowIcon != null){
|
||||
if (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected()){
|
||||
if (isSelected(jmenuitem)) {
|
||||
g.setColor(selectionForeground);
|
||||
}
|
||||
if (useCheckAndArrow()){
|
||||
@@ -457,7 +464,7 @@ public class BegMenuItemUI extends BasicMenuItemUI {
|
||||
}
|
||||
|
||||
private Icon getAllowedIcon() {
|
||||
Icon icon = menuItem.isEnabled() ? menuItem.getIcon() : menuItem.getDisabledIcon();
|
||||
Icon icon = !menuItem.isEnabled() ? menuItem.getDisabledIcon() : isSelected(menuItem) ? menuItem.getSelectedIcon() : menuItem.getIcon();
|
||||
if (icon != null && icon.getIconWidth() > myMaxGutterIconWidth){
|
||||
icon = null;
|
||||
}
|
||||
|
||||
@@ -392,6 +392,7 @@
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.actions.ActionsCollector$ActionUsagesCollector"/>
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.actions.IntentionsCollector$IntentionUsagesCollector"/>
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.ExperimentalFeaturesUsageCollector"/>
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.RegistryUsagesCollector"/>
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.actions.MainMenuCollector$MainMenuUsagesCollector"/>
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.ui.LaFUsagesCollector"/>
|
||||
<statistics.usagesCollector implementation="com.intellij.internal.statistic.customUsageCollectors.os.OsNameUsageCollector"/>
|
||||
|
||||
@@ -208,6 +208,14 @@ abstract class FirstStart(val ideType: IdeType) {
|
||||
return JDialogFixture(this, jDialog)
|
||||
}
|
||||
|
||||
fun Robot.dialog(timeoutSeconds: Long = DEFAULT_TIMEOUT, titleMatcher: (String) -> Boolean): JDialogFixture {
|
||||
val jDialog = waitUntilFound(this, null, JDialog::class.java, timeoutSeconds) { dialog ->
|
||||
titleMatcher(dialog.title)
|
||||
}
|
||||
return JDialogFixture(this, jDialog)
|
||||
}
|
||||
|
||||
|
||||
fun Robot.radioButton(text: String, timeoutSeconds: Long = DEFAULT_TIMEOUT): JRadioButtonFixture {
|
||||
val jRadioButton = waitUntilFound(this, null, JRadioButton::class.java, timeoutSeconds) { radioButton ->
|
||||
radioButton.text == text && radioButton.isShowing && radioButton.isEnabled
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.containers.hash;
|
||||
|
||||
|
||||
public interface EqualityPolicy<T> {
|
||||
EqualityPolicy<?> IDENTITY = new EqualityPolicy() {
|
||||
|
||||
public int getHashCode(Object value) {
|
||||
return System.identityHashCode(value);
|
||||
}
|
||||
@@ -29,7 +13,6 @@ public interface EqualityPolicy<T> {
|
||||
};
|
||||
|
||||
EqualityPolicy<?> CANONICAL = new EqualityPolicy() {
|
||||
|
||||
public int getHashCode(Object value) {
|
||||
return value != null ? value.hashCode() : 0;
|
||||
}
|
||||
@@ -42,4 +25,4 @@ public interface EqualityPolicy<T> {
|
||||
int getHashCode(T value);
|
||||
|
||||
boolean isEqual(T val1, T val2);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
@@ -47,7 +48,7 @@ public class CommandLineWrapperUtil {
|
||||
}
|
||||
manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, classPath.toString());
|
||||
|
||||
File jarFile = FileUtil.createTempFile("classpath", ".jar", true);
|
||||
File jarFile = FileUtil.createTempFile("classpath" + new Random().nextInt(), ".jar", true);
|
||||
new JarOutputStream(new BufferedOutputStream(new FileOutputStream(jarFile)), manifest).close();
|
||||
return jarFile;
|
||||
}
|
||||
|
||||
@@ -728,6 +728,12 @@ public class JDOMUtil {
|
||||
iterator.remove();
|
||||
|
||||
Element existingChild = to.getChild(child.getName());
|
||||
if (existingChild != null && isEmpty(existingChild)) {
|
||||
// replace empty tag
|
||||
to.removeChild(child.getName());
|
||||
existingChild = null;
|
||||
}
|
||||
|
||||
// if no children (e.g. `<module fileurl="value" />`), it means that element should be added as list item
|
||||
if (existingChild == null || existingChild.getChildren().isEmpty() || !isAttributesEqual(existingChild.getAttributes(), child.getAttributes(), false)) {
|
||||
to.addContent(child);
|
||||
|
||||
@@ -780,7 +780,7 @@ public class VcsLogPersistentIndex implements VcsLogIndex, Disposable {
|
||||
}
|
||||
}
|
||||
};
|
||||
VcsNotifier.getInstance(myProject).notifyImportantWarning("Log indexing for " + myRoot.getName() + " cancelled",
|
||||
VcsNotifier.getInstance(myProject).notifyImportantWarning("Log Indexing for \"" + myRoot.getName() + "\" Stopped",
|
||||
"Indexing was taking too long (" +
|
||||
StopWatch.formatTime(time - time % 1000) +
|
||||
")<p/><a href='resume'>Resume</a>",
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.RedundantCastUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -119,7 +120,13 @@ public class UnnecessaryLocalVariableInspectionBase extends BaseInspection {
|
||||
}
|
||||
|
||||
private boolean isCopyVariable(PsiVariable variable) {
|
||||
final PsiExpression initializer = ParenthesesUtils.stripParentheses(variable.getInitializer());
|
||||
PsiExpression initializer = ParenthesesUtils.stripParentheses(variable.getInitializer());
|
||||
if (initializer instanceof PsiTypeCastExpression) {
|
||||
PsiExpression operand = ((PsiTypeCastExpression)initializer).getOperand();
|
||||
if (operand instanceof PsiReferenceExpression && RedundantCastUtil.isCastRedundant((PsiTypeCastExpression)initializer)) {
|
||||
initializer = operand;
|
||||
}
|
||||
}
|
||||
if (!(initializer instanceof PsiReferenceExpression)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class Base {
|
||||
{
|
||||
Descendant descendant = new Descendant();
|
||||
consume((Base) descendant);
|
||||
}
|
||||
|
||||
private static void consume(Base value) {}
|
||||
private static void consume(Descendant value) {}
|
||||
}
|
||||
class Descendant extends Base {}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Base {
|
||||
{
|
||||
Descendant descendant = new Descendant();
|
||||
Base b<caret>ase = (Base) descendant;
|
||||
consume(base);
|
||||
}
|
||||
|
||||
private static void consume(Base value) {}
|
||||
private static void consume(Descendant value) {}
|
||||
}
|
||||
class Descendant extends Base {}
|
||||
@@ -33,4 +33,5 @@ public class InlineVariableFixTest extends IGQuickFixesTestCase {
|
||||
public void testSingleResourceVar() { doTest(); }
|
||||
public void testCastNeeded() { doTest(); }
|
||||
public void testArrayInitializer() { doTest(); }
|
||||
public void testCastForOverloads() { doTest(); }
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -129,7 +130,9 @@ public class ExtractToMethodReferenceIntention extends BaseElementAtCaretIntenti
|
||||
PsiMethod method = (PsiMethod)CodeStyleManager.getInstance(project).reformat(JavaCodeStyleManager.getInstance(project).shortenClassReferences(targetClass.add(emptyMethod)));
|
||||
PsiMethodReferenceExpression methodReference =
|
||||
(PsiMethodReferenceExpression)elementFactory.createExpressionFromText((canBeStatic ? targetClass.getName() : "this") + "::" + targetMethodName, lambdaExpression);
|
||||
methodReference = (PsiMethodReferenceExpression)lambdaExpression.replace(methodReference);
|
||||
CommentTracker tracker = new CommentTracker();
|
||||
methodReference = (PsiMethodReferenceExpression)tracker.replace(lambdaExpression, methodReference);
|
||||
tracker.insertCommentsBefore(methodReference);
|
||||
|
||||
startInplaceRename(editor, method, methodReference);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ class MyClass {
|
||||
|
||||
String myStr;
|
||||
void f(List<String> l){
|
||||
l.stream().filter(s -> s.startsWith(my<caret>Str));
|
||||
l.stream().filter(s -> //comment to keep
|
||||
s.startsWith(my<caret>Str));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,8 @@ class MyClass {
|
||||
|
||||
String myStr;
|
||||
void f(List<String> l){
|
||||
l.stream().filter(this::test);
|
||||
l.stream().filter(//comment to keep
|
||||
this::test);
|
||||
}
|
||||
|
||||
private boolean test(String s) {
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package git4idea.log;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcs.log.VcsLogUserFilterTest;
|
||||
import com.intellij.vcs.log.VcsUser;
|
||||
@@ -37,14 +35,6 @@ public class GitUserFilterTest extends GitSingleRepoTest {
|
||||
protected String commit(@NotNull VcsUser user) {
|
||||
String userName = user.getName();
|
||||
String userEmail = user.getEmail();
|
||||
if (SystemInfoRt.isWindows) {
|
||||
if (userName.contains("\"")) {
|
||||
userName = StringUtil.escapeChar(userName, '"');
|
||||
}
|
||||
if (userEmail.contains("\"")) {
|
||||
userEmail = StringUtil.escapeChar(userEmail, '"');
|
||||
}
|
||||
}
|
||||
GitTestUtil.setupUsername(myProject, userName, userEmail);
|
||||
String commit = modify(GitUserFilterTest.this, "file.txt");
|
||||
GitTestUtil.setupDefaultUsername(myProject);
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.idea.svn.dialogs;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -39,7 +25,7 @@ import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.components.labels.LinkListener;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.EqualityPolicy;
|
||||
import com.intellij.util.containers.hash.EqualityPolicy;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -9,4 +9,18 @@
|
||||
<resource-bundle>messages.TerminalBundle</resource-bundle>
|
||||
<xi:include href="/META-INF/terminal.xml" xpointer="xpointer(/idea-plugin/*)"/>
|
||||
|
||||
<actions>
|
||||
<action id="Terminal.OpenInTerminal" class="org.jetbrains.plugins.terminal.action.RevealFileInTerminalAction"
|
||||
text="Open in terminal"
|
||||
description="Open current file location in terminal"
|
||||
icon="TerminalIcons.OpenTerminal_13x13">
|
||||
<add-to-group group-id="EditorPopupMenu"/>
|
||||
<add-to-group group-id="ProjectViewPopupMenu"/>
|
||||
<add-to-group group-id="EditorTabPopupMenu"/>
|
||||
<add-to-group group-id="ConsoleEditorPopupMenu"/>
|
||||
<add-to-group group-id="FavoritesViewPopupMenu"/>
|
||||
<add-to-group group-id="NavbarPopupMenu"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
</idea-plugin>
|
||||
|
||||
@@ -7,7 +7,10 @@ import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.actions.CloseAction;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -16,6 +19,7 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
@@ -28,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
@@ -81,10 +86,15 @@ public abstract class AbstractTerminalRunner<T extends Process> {
|
||||
openSessionInDirectory(widget.getFirst(), widget.getSecond());
|
||||
return true;
|
||||
}, parent);
|
||||
openSessionInDirectory(terminalWidget, null);
|
||||
final ToolWindow window = getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
|
||||
openSessionForFile(terminalWidget, window.getSelectedFile().orElse(null));
|
||||
return terminalWidget;
|
||||
}
|
||||
|
||||
private ToolWindow getToolWindow(String windowId) {
|
||||
return ToolWindowManager.getInstance(myProject).getToolWindow(windowId);
|
||||
}
|
||||
|
||||
private void initConsoleUI(final T process) {
|
||||
final Executor defaultExecutor = DefaultRunExecutor.getRunExecutorInstance();
|
||||
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
|
||||
@@ -127,9 +137,9 @@ public abstract class AbstractTerminalRunner<T extends Process> {
|
||||
|
||||
public static void createAndStartSession(@NotNull TerminalWidget terminal, @NotNull TtyConnector ttyConnector) {
|
||||
TerminalSession session = terminal.createTerminalSession(ttyConnector);
|
||||
|
||||
|
||||
TerminalView.recordUsage(ttyConnector);
|
||||
|
||||
|
||||
session.start();
|
||||
}
|
||||
|
||||
@@ -146,8 +156,7 @@ public abstract class AbstractTerminalRunner<T extends Process> {
|
||||
ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, myDescriptor);
|
||||
|
||||
// Request focus
|
||||
final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(defaultExecutor.getId());
|
||||
window.activate(() -> IdeFocusManager.getInstance(myProject).requestFocus(toFocus, true));
|
||||
getToolWindow(defaultExecutor.getId()).activate(() -> IdeFocusManager.getInstance(myProject).requestFocus(toFocus, true));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -157,8 +166,25 @@ public abstract class AbstractTerminalRunner<T extends Process> {
|
||||
|
||||
public abstract String runningTargetName();
|
||||
|
||||
public void openSessionForFile(@NotNull TerminalWidget terminalWidget, @Nullable VirtualFile file) {
|
||||
openSessionInDirectory(terminalWidget, Optional.ofNullable(file).map(this::getClosestParentFolderPath).orElse(null));
|
||||
}
|
||||
|
||||
public void openSessionInDirectory(@NotNull TerminalWidget terminalWidget, @Nullable String directory) {
|
||||
@Nullable
|
||||
private String getClosestParentFolderPath(@Nullable VirtualFile selectedFile) {
|
||||
if (selectedFile != null) {
|
||||
if (selectedFile.isDirectory()) {
|
||||
return selectedFile.getPath();
|
||||
}
|
||||
VirtualFile parent = selectedFile.getParent();
|
||||
if (parent != null) {
|
||||
return parent.getPath();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void openSessionInDirectory(@NotNull TerminalWidget terminalWidget, @Nullable String directory) {
|
||||
ModalityState modalityState = ModalityState.stateForComponent(terminalWidget.getComponent());
|
||||
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||
|
||||
@@ -8,13 +8,17 @@ import com.intellij.ide.ui.UISettingsListener;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.internal.statistic.UsageTrigger;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowEx;
|
||||
@@ -41,6 +45,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author traff
|
||||
@@ -54,6 +59,9 @@ public class TerminalView {
|
||||
|
||||
private TerminalDockContainer myDockContainer;
|
||||
|
||||
@Nullable
|
||||
private VirtualFile myPreviousSelectedFile;
|
||||
|
||||
public TerminalView(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
@@ -82,8 +90,16 @@ public class TerminalView {
|
||||
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (window != null) {
|
||||
boolean visible = window.isVisible();
|
||||
if (visible && toolWindow.getContentManager().getContentCount() == 0) {
|
||||
initTerminal(window);
|
||||
if (visible) {
|
||||
VirtualFile selectedFile = window.getSelectedFile().orElse(null);
|
||||
if (toolWindow.getContentManager().getContentCount() == 0) {
|
||||
initTerminal(window);
|
||||
myPreviousSelectedFile = selectedFile;
|
||||
}
|
||||
else if (!Objects.equals(myPreviousSelectedFile, selectedFile)) {
|
||||
terminalRunner.openSessionForFile(myTerminalWidget, selectedFile);
|
||||
myPreviousSelectedFile = selectedFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +130,7 @@ public class TerminalView {
|
||||
final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
|
||||
content.setCloseable(true);
|
||||
|
||||
myPreviousSelectedFile = toolWindow.getSelectedFile().orElse(null);
|
||||
myTerminalWidget = terminalRunner.createTerminalWidget(content);
|
||||
myTerminalWidget.addTabListener(new TabbedTerminalWidget.TabListener() {
|
||||
@Override
|
||||
@@ -394,4 +411,4 @@ class TerminalToolWindowPanel extends SimpleToolWindowPanel implements UISetting
|
||||
private static boolean isDfmSupportEnabled() {
|
||||
return Registry.get("terminal.distraction.free").asBoolean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.terminal.action;
|
||||
|
||||
import com.intellij.ide.actions.ShowFilePathAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import org.jetbrains.plugins.terminal.TerminalToolWindowFactory;
|
||||
|
||||
/**
|
||||
* An action that activates the terminal window for file, selected by user.
|
||||
*
|
||||
* @see <a href="https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FIDEA-149976">Corresponding ticket</a>
|
||||
*/
|
||||
public class RevealFileInTerminalAction extends DumbAwareAction {
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabledAndVisible(getSelectedFile(e) != null);
|
||||
}
|
||||
|
||||
private static VirtualFile getSelectedFile(AnActionEvent e) {
|
||||
return ShowFilePathAction.findLocalFile(CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = getEventProject(e);
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TerminalToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (window != null && window.isAvailable()) {
|
||||
window.activate(null, getSelectedFile(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,10 @@ import org.jetbrains.intellij.build.MacDistributionCustomizer
|
||||
class PyCharmMacDistributionCustomizer extends MacDistributionCustomizer {
|
||||
@Override
|
||||
void copyAdditionalFiles(BuildContext context, String targetDirectory) {
|
||||
context.ant.copy(todir: "$targetDirectory/skeletons") {
|
||||
fileset(dir: "$context.paths.projectHome/skeletons") {
|
||||
def underTeamCity = System.getProperty("teamcity.buildType.id") != null
|
||||
|
||||
context.ant.copy(todir: "$targetDirectory/skeletons", failonerror: underTeamCity) {
|
||||
fileset(dir: "$context.paths.projectHome/skeletons", erroronmissingdir: underTeamCity) {
|
||||
include(name: "skeletons-mac*.zip")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,10 @@ abstract class PyCharmPropertiesBase extends ProductProperties {
|
||||
|
||||
new PyPrebuiltIndicesGenerator().generateResources(context)
|
||||
|
||||
context.ant.copy(todir: "$targetDirectory/index", failonerror: true) {
|
||||
fileset(dir: "$context.paths.temp/index", erroronmissingdir: true) {
|
||||
def underTeamCity = System.getProperty("teamcity.buildType.id") != null
|
||||
|
||||
context.ant.copy(todir: "$targetDirectory/index", failonerror: underTeamCity) {
|
||||
fileset(dir: "$context.paths.temp/index", erroronmissingdir: underTeamCity) {
|
||||
include(name: "**")
|
||||
}
|
||||
}
|
||||
@@ -66,11 +68,13 @@ class PyPrebuiltIndicesGenerator implements ResourcesGenerator {
|
||||
|
||||
def zipPath = "$context.paths.temp/zips"
|
||||
|
||||
context.ant.copy(todir: "$zipPath", failonerror: true) {
|
||||
fileset(dir: "$context.paths.projectHome/python-distributions", erroronmissingdir: true) {
|
||||
def underTeamCity = System.getProperty("teamcity.buildType.id") != null
|
||||
|
||||
context.ant.copy(todir: "$zipPath", failonerror: underTeamCity) {
|
||||
fileset(dir: "$context.paths.projectHome/python-distributions", erroronmissingdir: underTeamCity) {
|
||||
include(name: "*.zip")
|
||||
}
|
||||
fileset(dir: "$context.paths.projectHome/skeletons", erroronmissingdir: true) {
|
||||
fileset(dir: "$context.paths.projectHome/skeletons", erroronmissingdir: underTeamCity) {
|
||||
include(name: "*.zip")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@ import org.jetbrains.intellij.build.WindowsDistributionCustomizer
|
||||
class PyCharmWindowsDistributionCustomizer extends WindowsDistributionCustomizer {
|
||||
@Override
|
||||
void copyAdditionalFiles(BuildContext context, String targetDirectory) {
|
||||
context.ant.copy(todir: "$targetDirectory/skeletons") {
|
||||
fileset(dir: "$context.paths.projectHome/skeletons") {
|
||||
def underTeamCity = System.getProperty("teamcity.buildType.id") != null
|
||||
|
||||
context.ant.copy(todir: "$targetDirectory/skeletons", failonerror: underTeamCity) {
|
||||
fileset(dir: "$context.paths.projectHome/skeletons", erroronmissingdir: underTeamCity) {
|
||||
include(name: "skeletons-win*.zip")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.ide.customize.*;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PyCharmCustomizeIDEWizardStepsProvider implements CustomizeIDEWizardStepsProvider {
|
||||
@Override
|
||||
public void initSteps(CustomizeIDEWizardDialog wizardDialog, List<AbstractCustomizeWizardStep> steps) {
|
||||
PluginGroups groups = new PluginGroups() {
|
||||
@Override
|
||||
protected void initGroups(Map<String, Pair<Icon, List<String>>> tree, Map<String, String> featuredPlugins) {
|
||||
addVimPlugin(featuredPlugins);
|
||||
addMarkdownPlugin(featuredPlugins);
|
||||
featuredPlugins.put("BashSupport", "Languages:Bash language support:BashSupport");
|
||||
featuredPlugins.put("R Language Support", "Languages:R language support:R4Intellij");
|
||||
}
|
||||
};
|
||||
|
||||
steps.add(new CustomizeUIThemeStepPanel());
|
||||
|
||||
if (CustomizeLauncherScriptStep.isAvailable()) {
|
||||
steps.add(new CustomizeLauncherScriptStep());
|
||||
}
|
||||
|
||||
steps.add(new CustomizeFeaturedPluginsStepPanel(groups));
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.intellij.application.options.InitialConfigurationDialog;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.ide.AppLifecycleListener;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
@@ -24,15 +23,12 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Initialize PyCharm.
|
||||
*
|
||||
@@ -85,7 +81,6 @@ public class PyCharmInitialConfigurator {
|
||||
public void welcomeScreenDisplayed() {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
propertiesComponent.setValue(DISPLAYED_PROPERTY, "true");
|
||||
showInitialConfigurationDialog();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -93,9 +88,4 @@ public class PyCharmInitialConfigurator {
|
||||
|
||||
Registry.get("ide.ssh.one.time.password").setValue(true);
|
||||
}
|
||||
|
||||
private static void showInitialConfigurationDialog() {
|
||||
final JFrame frame = WindowManager.getInstance().findVisibleFrame();
|
||||
new InitialConfigurationDialog(frame, "Python").show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<names product="PyCharm" edition="Community Edition" script="charm"/>
|
||||
|
||||
<welcome-screen logo-url="/PyCharmCoreWelcomeScreen.png"/>
|
||||
<customize-ide-wizard provider="com.jetbrains.python.PyCharmCustomizeIDEWizardStepsProvider"/>
|
||||
|
||||
<plugins url="http://plugins.jetbrains.com/"/>
|
||||
<update-urls check="http://www.jetbrains.com/updates/updates.xml"
|
||||
|
||||
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -309,13 +309,8 @@ public class PyPackageUtil {
|
||||
}
|
||||
catch (ExecutionException e) {
|
||||
packagesRef.set(Collections.emptyList());
|
||||
if (LOG.isDebugEnabled()) {
|
||||
e.initCause(callStacktrace);
|
||||
LOG.debug(e);
|
||||
}
|
||||
else {
|
||||
LOG.warn(e.getMessage());
|
||||
}
|
||||
e.initCause(callStacktrace);
|
||||
LOG.warn(e);
|
||||
}
|
||||
});
|
||||
return packagesRef.get();
|
||||
|
||||
@@ -18,5 +18,6 @@
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="dom-openapi" />
|
||||
<orderEntry type="module" module-name="xml" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -13,6 +13,7 @@
|
||||
<with attribute="implementationClass" implements="com.intellij.spellchecker.tokenizer.SpellcheckingStrategy"/>
|
||||
</extensionPoint>
|
||||
<extensionPoint name="spellchecker.bundledDictionaryProvider" interface="com.intellij.spellchecker.BundledDictionaryProvider"/>
|
||||
<extensionPoint name="spellchecker.dictionary.customDictionaryProvider" interface="com.intellij.spellchecker.dictionary.CustomDictionaryProvider"/>
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
@@ -28,9 +28,8 @@ import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl;
|
||||
import com.intellij.spellchecker.dictionary.AggregatedDictionary;
|
||||
import com.intellij.spellchecker.dictionary.EditableDictionary;
|
||||
import com.intellij.spellchecker.dictionary.Loader;
|
||||
import com.intellij.spellchecker.dictionary.*;
|
||||
import com.intellij.spellchecker.dictionary.Dictionary;
|
||||
import com.intellij.spellchecker.engine.SpellCheckerEngine;
|
||||
import com.intellij.spellchecker.engine.SpellCheckerFactory;
|
||||
import com.intellij.spellchecker.engine.SuggestionProvider;
|
||||
@@ -46,6 +45,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtil.isAncestor;
|
||||
import static com.intellij.openapi.util.io.FileUtilRt.extensionEquals;
|
||||
@@ -115,7 +115,7 @@ public class SpellCheckerManager implements Disposable {
|
||||
spellChecker.removeDictionary(s);
|
||||
}
|
||||
else if (!dictionaryIsLoad && dictionaryShouldBeLoad) {
|
||||
spellChecker.loadDictionary(new FileLoader(s));
|
||||
loadDictionary(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class SpellCheckerManager implements Disposable {
|
||||
for (String folder : settings.getDictionaryFoldersPaths()) {
|
||||
SPFileUtil.processFilesRecursively(folder, s -> {
|
||||
if (!disabledDictionaries.contains(s)) {
|
||||
spellChecker.loadDictionary(new FileLoader(s));
|
||||
loadDictionary(s);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -172,6 +172,17 @@ public class SpellCheckerManager implements Disposable {
|
||||
spellChecker.addModifiableDictionary(userDictionary);
|
||||
}
|
||||
|
||||
private void loadDictionary(String path) {
|
||||
final CustomDictionaryProvider dictionaryProvider = findApplicable(path);
|
||||
if (dictionaryProvider != null) {
|
||||
final Dictionary dictionary = dictionaryProvider.get(path);
|
||||
if(dictionary != null) {
|
||||
spellChecker.addDictionary(dictionary);
|
||||
}
|
||||
}
|
||||
else spellChecker.loadDictionary(new FileLoader(path));
|
||||
}
|
||||
|
||||
public boolean hasProblem(@NotNull String word) {
|
||||
return !spellChecker.isCorrect(word);
|
||||
}
|
||||
@@ -234,6 +245,14 @@ public class SpellCheckerManager implements Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static CustomDictionaryProvider findApplicable(@NotNull String path) {
|
||||
return Stream.of(Extensions.getExtensions(CustomDictionaryProvider.EP_NAME))
|
||||
.filter(dictionaryProvider -> dictionaryProvider.isApplicable(path))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
LocalFileSystem.getInstance().removeVirtualFileListener(myCustomDictFileListener);
|
||||
@@ -275,7 +294,7 @@ public class SpellCheckerManager implements Disposable {
|
||||
if (!spellChecker.isDictionaryLoad(path) || mySettings.getDisabledDictionariesPaths().contains(path)) return;
|
||||
|
||||
spellChecker.removeDictionary(path);
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
loadDictionary(path);
|
||||
restartInspections();
|
||||
}
|
||||
|
||||
@@ -324,7 +343,7 @@ public class SpellCheckerManager implements Disposable {
|
||||
final boolean isDirectory = file.isDirectory();
|
||||
final String path = file.getPath();
|
||||
if (!isDirectory && isDic(path)) {
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
loadDictionary(path);
|
||||
restartInspections();
|
||||
}
|
||||
return isDirectory;
|
||||
@@ -332,7 +351,7 @@ public class SpellCheckerManager implements Disposable {
|
||||
});
|
||||
}
|
||||
else if (isDic(path)) {
|
||||
spellChecker.loadDictionary(new FileLoader(path));
|
||||
loadDictionary(path);
|
||||
restartInspections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,10 @@ public final class CompressedDictionary implements Dictionary {
|
||||
}
|
||||
|
||||
public void getWords(char first, int minLength, int maxLength, @NotNull Collection<String> result) {
|
||||
getWords(first, minLength, maxLength, result::add);
|
||||
}
|
||||
|
||||
public void getWords(char first, int minLength, int maxLength, @NotNull Consumer<String> consumer) {
|
||||
int index = alphabet.getIndex(first, false);
|
||||
if (index == -1) return;
|
||||
|
||||
@@ -109,13 +113,19 @@ public final class CompressedDictionary implements Dictionary {
|
||||
for (int x = 0; x < data.length; x += length) {
|
||||
if (encoder.getFirstLetterIndex(data[x]) == index) {
|
||||
String decoded = encoder.decode(data, x, x + length);
|
||||
result.add(decoded);
|
||||
consumer.consume(decoded);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getSuggestions(@NotNull String word, @NotNull Consumer<String> consumer) {
|
||||
getWords(word.charAt(0), 0, Integer.MAX_VALUE, consumer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.spellchecker.dictionary;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -94,6 +95,15 @@ public class AggregatedDictionary implements EditableDictionary {
|
||||
cachedDictionary.traverse(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSuggestions(@NotNull String word, @NotNull Consumer<String> consumer) {
|
||||
traverse(s -> {
|
||||
if (!StringUtil.isEmpty(s) && s.charAt(0) == word.charAt(0) && s.length() >= 0 && s.length() <= Integer.MAX_VALUE) {
|
||||
consumer.consume(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<String> getWords() {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.spellchecker.dictionary;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface CustomDictionaryProvider {
|
||||
ExtensionPointName<CustomDictionaryProvider> EP_NAME = ExtensionPointName.create("com.intellij.spellchecker.dictionary.customDictionaryProvider");
|
||||
|
||||
@Nullable
|
||||
Dictionary get(@NotNull String path);
|
||||
|
||||
boolean isApplicable(@NotNull String path);
|
||||
}
|
||||