From b6fd2cba6ab0cf3a4ba3bd6bdc481a414b71461b Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 29 Oct 2014 13:03:57 +0300 Subject: [PATCH 01/23] fixed leaking MethodOccurence objects --- .../debugger/ui/impl/watch/MethodsTracker.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java index 40435a0f14a7..3f526b7066c3 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/MethodsTracker.java @@ -19,9 +19,7 @@ import com.sun.jdi.Method; import org.jetbrains.annotations.Nullable; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; /** * @author Eugene Zhuravlev @@ -29,7 +27,7 @@ import java.util.Set; */ public class MethodsTracker { private final Map myMethodToOccurrenceMap = new HashMap(); - private final Set myProcessedFrames = new HashSet(); + private final Map myInitialOccurence = new HashMap(); public final class MethodOccurrence { private final Method myMethod; @@ -54,12 +52,13 @@ public class MethodsTracker { } public MethodOccurrence getMethodOccurrence(int frameIndex, @Nullable Method method) { - int occurenceIndex = getOccurrenceCount(method); - if (!myProcessedFrames.contains(frameIndex)) { - myMethodToOccurrenceMap.put(method, occurenceIndex + 1); - myProcessedFrames.add(frameIndex); + Integer initial = myInitialOccurence.get(frameIndex); + if (initial == null) { + initial = getOccurrenceCount(method); + myMethodToOccurrenceMap.put(method, initial + 1); + myInitialOccurence.put(frameIndex, initial); } - return new MethodOccurrence(method, occurenceIndex); + return new MethodOccurrence(method, initial); } private int getOccurrenceCount(Method method) { From ade5beb9b256d9670267dc0d3c895de7ebfa5265 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Tue, 28 Oct 2014 17:46:27 +0100 Subject: [PATCH 02/23] regex: fix handling of empty character class (which is not allowed in Java, Python & Ruby, but allowed in JavaScript) --- .../org/intellij/lang/regexp/_RegExLexer.java | 213 +++++++++--------- .../intellij/lang/regexp/regexp-lexer.flex | 17 +- RegExpSupport/testData/RETest.xml | 10 +- .../regexp/PythonRegexpParserDefinition.java | 3 +- 4 files changed, 117 insertions(+), 126 deletions(-) diff --git a/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java b/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java index cc1fd353a327..6c56b6c2cc8b 100644 --- a/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java +++ b/RegExpSupport/gen/org/intellij/lang/regexp/_RegExLexer.java @@ -1,4 +1,4 @@ -/* The following code was generated by JFlex 1.4.3 on 10/28/14 3:07 PM */ +/* The following code was generated by JFlex 1.4.3 on 10/28/14 5:18 PM */ /* It's an automatically generated code. Do not modify it. */ package org.intellij.lang.regexp; @@ -15,7 +15,7 @@ import java.util.EnumSet; /** * This class is a scanner generated by * JFlex 1.4.3 - * on 10/28/14 3:07 PM from the specification file + * on 10/28/14 5:18 PM from the specification file * /Users/bas/Projects/IntelliJ IDEA Ultimate/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex */ class _RegExLexer implements FlexLexer { @@ -24,7 +24,7 @@ class _RegExLexer implements FlexLexer { /** lexical states */ public static final int EMBRACED = 4; - public static final int CLASS1PY = 8; + public static final int NEGATE_CLASS1 = 8; public static final int PY_NAMED_GROUP_REF = 22; public static final int QUOTED = 2; public static final int OPTIONS = 14; @@ -730,68 +730,68 @@ class _RegExLexer implements FlexLexer { { yybegin(YYINITIAL); return RegExpTT.GROUP_END; } case 88: break; - case 37: - { yybegin(YYINITIAL); return RegExpTT.COLON; - } - case 89: break; - case 6: - { return RegExpTT.GROUP_END; - } - case 90: break; - case 25: - { assert false : yytext(); - } - case 91: break; - case 18: - { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER; - } - case 92: break; - case 46: - { return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE; - } - case 93: break; - case 23: - { return RegExpTT.NAME; - } - case 94: break; - case 29: - { yypopstate(); return RegExpTT.CLASS_END; - } - case 95: break; - case 34: - { yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER; - } - case 96: break; - case 52: - { yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN; - } - case 97: break; - case 21: - { return RegExpTT.NUMBER; - } - case 98: break; - case 4: - { return RegExpTT.DOT; - } - case 99: break; - case 72: - { return RegExpTT.NEG_LOOKBEHIND; - } - case 100: break; - case 33: - { yypopstate(); if (allowCategoryShorthand) return RegExpTT.CATEGORY_SHORT_HAND; else yypushback(1); - } - case 101: break; - case 44: - { return (allowOctalNoLeadingZero ? RegExpTT.OCT_CHAR : RegExpTT.BAD_OCT_VALUE); - } - case 102: break; case 41: // lookahead expression with fixed base length zzMarkedPos = zzStartRead + 1; - { yypushstate(CLASS1); + { if (allowEmptyCharacterClass) yypushstate(CLASS2); else yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } + case 89: break; + case 37: + { yybegin(YYINITIAL); return RegExpTT.COLON; + } + case 90: break; + case 6: + { return RegExpTT.GROUP_END; + } + case 91: break; + case 25: + { assert false : yytext(); + } + case 92: break; + case 18: + { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER; + } + case 93: break; + case 46: + { return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE; + } + case 94: break; + case 23: + { return RegExpTT.NAME; + } + case 95: break; + case 29: + { yypopstate(); return RegExpTT.CLASS_END; + } + case 96: break; + case 34: + { yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER; + } + case 97: break; + case 52: + { yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN; + } + case 98: break; + case 21: + { return RegExpTT.NUMBER; + } + case 99: break; + case 4: + { return RegExpTT.DOT; + } + case 100: break; + case 72: + { return RegExpTT.NEG_LOOKBEHIND; + } + case 101: break; + case 33: + { yypopstate(); if (allowCategoryShorthand) return RegExpTT.CATEGORY_SHORT_HAND; else yypushback(1); + } + case 102: break; + case 44: + { return (allowOctalNoLeadingZero ? RegExpTT.OCT_CHAR : RegExpTT.BAD_OCT_VALUE); + } case 103: break; case 63: { return RegExpTT.NEG_LOOKAHEAD; @@ -809,18 +809,6 @@ class _RegExLexer implements FlexLexer { { yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP; } case 107: break; - case 66: - // lookahead expression with fixed base length - zzMarkedPos = zzStartRead + 1; - { if (allowEmptyCharacterClass) { - yypushstate(CLASS1PY); - } - else { - yypushstate(CLASS2); - } - return RegExpTT.CLASS_BEGIN; - } - case 108: break; case 28: { if (allowNestedCharacterClasses) { yypushstate(CLASS2); @@ -828,24 +816,24 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.CHARACTER; } - case 109: break; + case 108: break; case 19: { if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER; } - case 110: break; + case 109: break; case 51: { yypushstate(PROP); return RegExpTT.PROPERTY; } - case 111: break; + case 110: break; case 8: { yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN; } - case 112: break; + case 111: break; case 71: { return RegExpTT.POS_LOOKBEHIND; } - case 113: break; + case 112: break; case 20: { if (allowDanglingMetacharacters) { yypopstate(); yypushback(1); @@ -853,15 +841,15 @@ class _RegExLexer implements FlexLexer { return RegExpTT.BAD_CHARACTER; } } - case 114: break; + case 113: break; case 73: { return RegExpTT.HEX_CHAR; } - case 115: break; + case 114: break; case 1: { handleOptions(); return RegExpTT.OPTIONS_ON; } - case 116: break; + case 115: break; case 43: { if (yystate() == CLASS2) return RegExpTT.ESC_CHARACTER; while (yylength() > 2 && Integer.parseInt(yytext().toString().substring(1)) > capturingGroupCount) { @@ -869,55 +857,55 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.BACKREF; } - case 117: break; + case 116: break; case 59: { return allowNestedCharacterClasses ? RegExpTT.ANDAND : RegExpTT.CHARACTER; } - case 118: break; + case 117: break; case 2: { yypopstate(); return RegExpTT.COMMENT; } - case 119: break; + case 118: break; case 17: { return RegExpTT.MINUS; } - case 120: break; + case 119: break; case 47: { return RegExpTT.ESC_CTRL_CHARACTER; } - case 121: break; + case 120: break; case 32: { yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE; } - case 122: break; + case 121: break; case 13: { return RegExpTT.QUEST; } - case 123: break; + case 122: break; case 5: { capturingGroupCount++; return RegExpTT.GROUP_BEGIN; } - case 124: break; + case 123: break; case 15: { return RegExpTT.PLUS; } - case 125: break; + case 124: break; case 67: { return RegExpTT.OCT_CHAR; } - case 126: break; + case 125: break; case 39: { yybegin(YYINITIAL); return RegExpTT.QUOTE; } - case 127: break; + case 126: break; case 31: { yypopstate(); yypushback(1); } - case 128: break; + case 127: break; case 27: { yybegin(CLASS1); return RegExpTT.CARET; } - case 129: break; + case 128: break; case 57: // lookahead expression with fixed base length zzMarkedPos = zzStartRead + 1; @@ -927,71 +915,78 @@ class _RegExLexer implements FlexLexer { } return RegExpTT.CHARACTER; } - case 130: break; + case 129: break; case 58: { if (!allowNestedCharacterClasses) return RegExpTT.CHARACTER; return RegExpTT.REDUNDANT_ESCAPE; } - case 131: break; + case 130: break; case 38: { yybegin(YYINITIAL); return RegExpTT.GT; } - case 132: break; + case 131: break; case 69: { yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF; } - case 133: break; + case 132: break; case 16: { return RegExpTT.UNION; } - case 134: break; + case 133: break; case 3: { return RegExpTT.CHARACTER; } - case 135: break; + case 134: break; case 64: { yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP; } - case 136: break; + case 135: break; case 40: { yybegin(OPTIONS); return RegExpTT.SET_OPTIONS; } - case 137: break; + case 136: break; case 26: { yybegin(CLASS2); return RegExpTT.CHARACTER; } - case 138: break; + case 137: break; case 68: { if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL; } - case 139: break; + case 138: break; case 30: { return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER; } - case 140: break; + case 139: break; case 12: { return RegExpTT.DOLLAR; } - case 141: break; + case 140: break; case 50: { if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } - case 142: break; + case 141: break; case 42: { return RegExpTT.REDUNDANT_ESCAPE; } - case 143: break; + case 142: break; case 55: { return (allowHexDigitClass || allowHorizontalWhitespaceClass ? RegExpTT.CHAR_CLASS : StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN); } - case 144: break; + case 143: break; case 48: { return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER; } - case 145: break; + case 144: break; case 22: { yypopstate(); return RegExpTT.RBRACE; } + case 145: break; + case 66: + // lookahead expression with fixed base length + zzMarkedPos = zzStartRead + 1; + { if (allowEmptyCharacterClass) yypushstate(CLASS2); else yypushstate(NEGATE_CLASS1); + return RegExpTT.CLASS_BEGIN; + } case 146: break; case 54: { return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN; diff --git a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex index 2d5daf7f65ab..e722b9516310 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex +++ b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex @@ -75,7 +75,7 @@ import java.util.EnumSet; %xstate QUOTED %xstate EMBRACED %xstate CLASS1 -%xstate CLASS1PY +%xstate NEGATE_CLASS1 %state CLASS2 %state PROP %xstate OPTIONS @@ -228,18 +228,11 @@ HEX_CHAR=[0-9a-fA-F] } } -{LBRACKET} / {RBRACKET} { yypushstate(CLASS1); +{LBRACKET} / {RBRACKET} { if (allowEmptyCharacterClass) yypushstate(CLASS2); else yypushstate(CLASS1); return RegExpTT.CLASS_BEGIN; } -/* Python understands that, Java doesn't */ -{LBRACKET} / "^" {RBRACKET} { if (allowEmptyCharacterClass) { - yypushstate(CLASS1PY); - } - else { - yypushstate(CLASS2); - } - return RegExpTT.CLASS_BEGIN; - } +{LBRACKET} / "^" {RBRACKET} { if (allowEmptyCharacterClass) yypushstate(CLASS2); else yypushstate(NEGATE_CLASS1); + return RegExpTT.CLASS_BEGIN; } {LBRACKET} { yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN; } @@ -250,7 +243,7 @@ HEX_CHAR=[0-9a-fA-F] . { assert false : yytext(); } } - { + { "^" { yybegin(CLASS1); return RegExpTT.CARET; } . { assert false : yytext(); } } diff --git a/RegExpSupport/testData/RETest.xml b/RegExpSupport/testData/RETest.xml index f42b9af45c51..470851e4bda8 100644 --- a/RegExpSupport/testData/RETest.xml +++ b/RegExpSupport/testData/RETest.xml @@ -296,6 +296,10 @@ a[]b ERR + + [^] + ERR + [abhgefdc]ij OK @@ -583,11 +587,11 @@ \x4a OK - + \x{0} OK - + \x{2011F} OK @@ -1043,7 +1047,7 @@ - + \h \H \v \V OK diff --git a/python/src/com/jetbrains/python/codeInsight/regexp/PythonRegexpParserDefinition.java b/python/src/com/jetbrains/python/codeInsight/regexp/PythonRegexpParserDefinition.java index 25cc6495e1f4..a28460c6ca0c 100644 --- a/python/src/com/jetbrains/python/codeInsight/regexp/PythonRegexpParserDefinition.java +++ b/python/src/com/jetbrains/python/codeInsight/regexp/PythonRegexpParserDefinition.java @@ -33,8 +33,7 @@ public class PythonRegexpParserDefinition extends RegExpParserDefinition { public static final IFileElementType PYTHON_REGEXP_FILE = new IFileElementType("PYTHON_REGEXP_FILE", PythonRegexpLanguage.INSTANCE); protected final EnumSet CAPABILITIES = EnumSet.of(RegExpCapability.DANGLING_METACHARACTERS, RegExpCapability.OCTAL_NO_LEADING_ZERO, - RegExpCapability.OMIT_NUMBERS_IN_QUANTIFIERS, - RegExpCapability.ALLOW_EMPTY_CHARACTER_CLASS); + RegExpCapability.OMIT_NUMBERS_IN_QUANTIFIERS); @NotNull public Lexer createLexer(Project project) { From cc206c0fd2b85b13be78735d57ec34a8f80ef23d Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 29 Oct 2014 13:27:09 +0300 Subject: [PATCH 03/23] Emmet: use editor preferred size in max size calculation --- .../template/emmet/EmmetPreviewHint.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java index 01c809e6a459..626582db1113 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/EmmetPreviewHint.java @@ -89,13 +89,13 @@ public class EmmetPreviewHint extends LightweightHint implements Disposable { JRootPane pane = myParentEditor.getComponent().getRootPane(); JComponent layeredPane = pane != null ? pane.getLayeredPane() : myParentEditor.getComponent(); HintHint hintHint = new HintHint(layeredPane, position.first) - .setAwtTooltip(true) - .setContentActive(true) - .setExplicitClose(true) - .setShowImmediately(true) - .setPreferredPosition(position.second == HintManager.ABOVE ? Balloon.Position.above : Balloon.Position.below) - .setTextBg(myParentEditor.getColorsScheme().getDefaultBackground()) - .setBorderInsets(new Insets(1, 1, 1, 1)); + .setAwtTooltip(true) + .setContentActive(true) + .setExplicitClose(true) + .setShowImmediately(true) + .setPreferredPosition(position.second == HintManager.ABOVE ? Balloon.Position.above : Balloon.Position.below) + .setTextBg(myParentEditor.getColorsScheme().getDefaultBackground()) + .setBorderInsets(new Insets(1, 1, 1, 1)); int hintFlags = HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING; HintManagerImpl.getInstanceImpl().showEditorHint(this, myParentEditor, position.first, hintFlags, 0, false, hintHint); @@ -123,7 +123,7 @@ public class EmmetPreviewHint extends LightweightHint implements Disposable { } }, 100); } - + @TestOnly @NotNull public String getContent() { @@ -143,7 +143,9 @@ public class EmmetPreviewHint extends LightweightHint implements Disposable { } @NotNull - public static EmmetPreviewHint createHint(@NotNull final EditorEx parentEditor, @NotNull String templateText, @NotNull FileType fileType) { + public static EmmetPreviewHint createHint(@NotNull final EditorEx parentEditor, + @NotNull String templateText, + @NotNull FileType fileType) { EditorFactory editorFactory = EditorFactory.getInstance(); Document document = editorFactory.createDocument(templateText); final EditorEx previewEditor = (EditorEx)editorFactory.createEditor(document, parentEditor.getProject(), fileType, true); @@ -172,9 +174,9 @@ public class EmmetPreviewHint extends LightweightHint implements Disposable { Dimension parentEditorSize = parentEditor.getScrollPane().getSize(); int maxWidth = (int)parentEditorSize.getWidth() / 3; int maxHeight = (int)parentEditorSize.getHeight() / 2; - Dimension contentSize = previewEditor.getContentSize(); - return new Dimension(maxWidth > contentSize.getWidth() && !settings.isUseSoftWraps() ? (int)size.getWidth() : maxWidth, - maxHeight > contentSize.getHeight() ? (int)size.getHeight() : maxHeight); + final int width = settings.isUseSoftWraps() ? maxWidth : Math.min((int)size.getWidth(), maxWidth); + final int height = Math.min((int)size.getHeight(), maxHeight); + return new Dimension(width, height); } @NotNull From 633cc944d77f2ff417926e050761c54bebf81009 Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Wed, 29 Oct 2014 13:55:28 +0300 Subject: [PATCH 04/23] IDEA-82746 Disable "Push" button in Push dialog for Git when there is nothing to push * HgPushOptionsPanel simplified; * push button should not be disabled for hg single repo project, because we would like to push without loading commits --- .../intellij/dvcs/push/PushController.java | 8 +++++++ .../zmlx/hg4idea/push/HgPushOptionsPanel.java | 21 +++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java index e4a8c1a64826..188f3ff77a91 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java +++ b/platform/dvcs-impl/src/com/intellij/dvcs/push/PushController.java @@ -256,6 +256,13 @@ public class PushController implements Disposable { } private boolean isPushAllowed(@NotNull PushSupport pushSupport) { + if (mySingleRepoProject) { + MyRepoModel repoModel = ContainerUtil.getFirstItem(myView2Model.values()); + assert repoModel != null; + return hasSomethingToPush(myView2Model.keySet()) || + !repoModel.getLoadedCommits().isEmpty() || + myDialog.getAdditionalOptionValue(pushSupport) != null; + } Collection nodes = getNodesForSupport(pushSupport); if (pushSupport.getRepositoryManager().isSyncEnabled()) { return hasSomethingToPush(nodes) || (hasCheckedNode(nodes) && allNodesAreLoaded(nodes)); @@ -330,6 +337,7 @@ public class PushController implements Disposable { boolean shouldBeSelected; if (!errors.isEmpty()) { shouldBeSelected = false; + model.setLoadedCommits(outgoing.getCommits()); myPushLog.setChildren(node, ContainerUtil.map(errors, new Function() { @Override public DefaultMutableTreeNode fun(final VcsError error) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java index 32d22730e560..470bf925aa2b 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushOptionsPanel.java @@ -16,31 +16,24 @@ package org.zmlx.hg4idea.push; import com.intellij.dvcs.push.VcsPushOptionsPanel; -import com.intellij.openapi.ui.ComboBox; -import org.jetbrains.annotations.NotNull; +import com.intellij.ui.components.JBCheckBox; +import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.awt.*; public class HgPushOptionsPanel extends VcsPushOptionsPanel { - private final ComboBox myReferenceStrategyCombobox; + private final JBCheckBox myPushBookmarkCheckBox; public HgPushOptionsPanel() { setLayout(new BorderLayout()); - myReferenceStrategyCombobox = new ComboBox(); - HgVcsPushOptionValue[] values = HgVcsPushOptionValue.values(); - DefaultComboBoxModel comboModel = new DefaultComboBoxModel(values); - myReferenceStrategyCombobox.setModel(comboModel); - JLabel referenceStrategyLabel = new JLabel("Export Bookmarks: "); - add(referenceStrategyLabel, BorderLayout.WEST); - add(myReferenceStrategyCombobox, BorderLayout.CENTER); + myPushBookmarkCheckBox = new JBCheckBox("Export Active Bookmarks"); + add(myPushBookmarkCheckBox, BorderLayout.WEST); } @Override - @NotNull + @Nullable public HgVcsPushOptionValue getValue() { - return (HgVcsPushOptionValue)myReferenceStrategyCombobox.getSelectedItem(); + return myPushBookmarkCheckBox.isSelected() ? HgVcsPushOptionValue.Current : null; } - } From 541f8ca9e67e817596ddf6a44fef9181246c2dee Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Wed, 29 Oct 2014 13:51:36 +0300 Subject: [PATCH 05/23] PY-13297 Use only PSI means to insert new line after comment --- .../inspections/quickfix/AddEncodingQuickFix.java | 12 ++++++------ ...codingInEmptyFile.py => AddEncodingAtLastLine.py} | 2 +- ...yFile_after.py => AddEncodingAtLastLine_after.py} | 1 + .../testSrc/com/jetbrains/python/PyQuickFixTest.java | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) rename python/testData/inspections/{AddEncodingInEmptyFile.py => AddEncodingAtLastLine.py} (74%) rename python/testData/inspections/{AddEncodingInEmptyFile_after.py => AddEncodingAtLastLine_after.py} (50%) diff --git a/python/src/com/jetbrains/python/inspections/quickfix/AddEncodingQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/AddEncodingQuickFix.java index 82f61cfb1b57..3e3e55028abe 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/AddEncodingQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/AddEncodingQuickFix.java @@ -25,9 +25,9 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiComment; -import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiWhiteSpace; import com.jetbrains.python.PyBundle; import com.jetbrains.python.inspections.PyEncodingUtil; import com.jetbrains.python.psi.LanguageLevel; @@ -71,20 +71,20 @@ public class AddEncodingQuickFix implements LocalQuickFix { if (firstLine instanceof PsiComment && firstLine.getText().startsWith("#!")) { firstLine = firstLine.getNextSibling(); } + final LanguageLevel languageLevel = LanguageLevel.forElement(file); final String commentText = String.format(PyEncodingUtil.ENCODING_FORMAT_PATTERN[myEncodingFormatIndex], myDefaultEncoding); final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); - PsiComment encodingComment = elementGenerator.createFromText(LanguageLevel.forElement(file), PsiComment.class, commentText); + PsiComment encodingComment = elementGenerator.createFromText(languageLevel, PsiComment.class, commentText); encodingComment = (PsiComment)file.addBefore(encodingComment, firstLine); final FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(element.getContainingFile().getVirtualFile()); if (fileEditor instanceof TextEditor) { + if (encodingComment.getNextSibling() == null || !encodingComment.getNextSibling().textContains('\n')) { + file.addAfter(elementGenerator.createFromText(languageLevel, PsiWhiteSpace.class, "\n"), encodingComment); + } final Editor editor = ((TextEditor)fileEditor).getEditor(); final Document document = editor.getDocument(); final int insertedLineNumber = document.getLineNumber(encodingComment.getTextOffset()); - if (insertedLineNumber == document.getLineCount() - 1) { - PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document); - document.insertString(document.getLineEndOffset(insertedLineNumber), "\n"); - } editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(insertedLineNumber + 1, 0)); } } diff --git a/python/testData/inspections/AddEncodingInEmptyFile.py b/python/testData/inspections/AddEncodingAtLastLine.py similarity index 74% rename from python/testData/inspections/AddEncodingInEmptyFile.py rename to python/testData/inspections/AddEncodingAtLastLine.py index 376db9193fc4..a7868cf286f9 100644 --- a/python/testData/inspections/AddEncodingInEmptyFile.py +++ b/python/testData/inspections/AddEncodingAtLastLine.py @@ -1 +1 @@ - +#!/usr/bin/env python \ No newline at end of file diff --git a/python/testData/inspections/AddEncodingInEmptyFile_after.py b/python/testData/inspections/AddEncodingAtLastLine_after.py similarity index 50% rename from python/testData/inspections/AddEncodingInEmptyFile_after.py rename to python/testData/inspections/AddEncodingAtLastLine_after.py index 76ea4ea7c759..5e9beaa6da1d 100644 --- a/python/testData/inspections/AddEncodingInEmptyFile_after.py +++ b/python/testData/inspections/AddEncodingAtLastLine_after.py @@ -1,2 +1,3 @@ +#!/usr/bin/env python # coding=utf-8 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java index c7e8d138aa83..6cc2e578fb30 100644 --- a/python/testSrc/com/jetbrains/python/PyQuickFixTest.java +++ b/python/testSrc/com/jetbrains/python/PyQuickFixTest.java @@ -356,8 +356,8 @@ public class PyQuickFixTest extends PyTestCase { } // PY-13297 - public void testAddEncodingInEmptyFile() { - doInspectionTest("AddEncodingInEmptyFile.py", PyMandatoryEncodingInspection.class, + public void testAddEncodingAtLastLine() { + doInspectionTest("AddEncodingAtLastLine.py", PyMandatoryEncodingInspection.class, PyBundle.message("QFIX.add.encoding"), true, true); } From cbeccb96932505ca5ecd36d1c809d6c565ea5e2b Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 28 Oct 2014 15:20:13 +0100 Subject: [PATCH 06/23] cleanup --- .../compiler/CompilerConfigurationImpl.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java index c262c65dc497..9d4a76fcfed7 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java @@ -104,7 +104,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements @Nullable private String myBytecodeTargetLevel = null; // null means compiler default - private final Map myModuleBytecodeTarget = new java.util.HashMap(); + private final Map myModuleBytecodeTarget = new HashMap(); public CompilerConfigurationImpl(Project project) { myProject = project; @@ -112,16 +112,19 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements Disposer.register(project, myExcludedEntriesConfiguration); MessageBusConnection connection = project.getMessageBus().connect(project); connection.subscribe(ProjectTopics.MODULES, new ModuleAdapter() { + @Override public void beforeModuleRemoved(Project project, Module module) { getAnnotationProcessingConfiguration(module).removeModuleName(module.getName()); } + @Override public void moduleAdded(Project project, Module module) { myProcessorsProfilesMap = null; // clear cache } }); } + @Override public Element getState() { try { @NonNls final Element e = new Element("state"); @@ -134,6 +137,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements } } + @Override public void loadState(Element state) { try { readExternal(state); @@ -162,6 +166,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return myModuleBytecodeTarget; } + @Override public void setBytecodeTargetLevel(Module module, String level) { final String previous; if (StringUtil.isEmpty(level)) { @@ -229,11 +234,14 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements } } + @Override public void disposeComponent() { } + @Override public void initComponent() { } + @Override public void projectClosed() { } @@ -242,6 +250,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return JAVAC_EXTERNAL_BACKEND; } + @Override public void projectOpened() { createCompilers(); } @@ -304,6 +313,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return ArrayUtil.toStringArray(myWildcardPatterns); } + @Override public void addResourceFilePattern(String namePattern) throws MalformedPatternException { addWildcardResourcePattern(namePattern); } @@ -321,6 +331,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return myExcludedEntriesConfiguration; } + @Override public boolean isExcludedFromCompilation(final VirtualFile virtualFile) { return myExcludedEntriesConfiguration.isExcluded(virtualFile); } @@ -505,6 +516,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return wildcardPattern.length() > 1 && wildcardPattern.charAt(0) == '!'; } + @Override public boolean isResourceFile(String name) { return isResourceFile(name, null); } @@ -647,7 +659,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements final Element bytecodeTargetElement = parentNode.getChild(JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL); if (bytecodeTargetElement != null) { myBytecodeTargetLevel = bytecodeTargetElement.getAttributeValue(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE); - for (Element elem : (Collection)bytecodeTargetElement.getChildren(JpsJavaCompilerConfigurationSerializer.MODULE)) { + for (Element elem : bytecodeTargetElement.getChildren(JpsJavaCompilerConfigurationSerializer.MODULE)) { final String name = elem.getAttributeValue(JpsJavaCompilerConfigurationSerializer.NAME); if (name == null) { continue; @@ -796,6 +808,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements } } + @Override @NotNull @NonNls public String getComponentName() { return "CompilerConfiguration"; @@ -839,9 +852,11 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements ); final String wildcardPatterns = Messages.showInputDialog( myProject, message, CompilerBundle.message("pattern.conversion.dialog.title"), Messages.getWarningIcon(), initialPatternString, new InputValidator() { + @Override public boolean checkInput(String inputString) { return true; } + @Override public boolean canClose(String inputString) { final StringTokenizer tokenizer = new StringTokenizer(inputString, ";", false); StringBuilder malformedPatterns = new StringBuilder(); @@ -925,6 +940,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements return extensionsString.toString(); } + @Override public boolean isCompilableResourceFile(final Project project, final VirtualFile file) { if (!isResourceFile(file)) { return false; @@ -938,7 +954,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements @Nullable final Pattern dir; @Nullable final Pattern srcRoot; - private CompiledPattern(Pattern fileName, Pattern dir, Pattern srcRoot) { + private CompiledPattern(@NotNull Pattern fileName, @Nullable Pattern dir, @Nullable Pattern srcRoot) { this.fileName = fileName; this.dir = dir; this.srcRoot = srcRoot; From 2d94da56a71e7ae978d64fa9ab769a86259c4e89 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 28 Oct 2014 15:26:13 +0100 Subject: [PATCH 07/23] cleanup --- .../compiler/CompilerConfigurationImpl.java | 106 +++++++++--------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java index 9d4a76fcfed7..1ed63531e18f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerConfigurationImpl.java @@ -126,15 +126,61 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements @Override public Element getState() { + Element state = new Element("state"); try { - @NonNls final Element e = new Element("state"); - writeExternal(e); - return e; + DefaultJDOMExternalizer.writeExternal(this, state); } - catch (WriteExternalException e1) { - LOG.error(e1); + catch (WriteExternalException e) { + LOG.error(e); return null; } + + if (!myAddNotNullAssertions) { + addChild(state, JpsJavaCompilerConfigurationSerializer.ADD_NOTNULL_ASSERTIONS).setAttribute( + JpsJavaCompilerConfigurationSerializer.ENABLED, String.valueOf(myAddNotNullAssertions)); + } + + if (myExcludedEntriesConfiguration.getExcludeEntryDescriptions().length > 0) { + myExcludedEntriesConfiguration.writeExternal(addChild(state, JpsJavaCompilerConfigurationSerializer.EXCLUDE_FROM_COMPILE)); + } + + final Element newChild = addChild(state, JpsJavaCompilerConfigurationSerializer.RESOURCE_EXTENSIONS); + for (final String pattern : getRegexpPatterns()) { + addChild(newChild, JpsJavaCompilerConfigurationSerializer.ENTRY).setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, pattern); + } + + if (myWildcardPatternsInitialized || !myWildcardPatterns.isEmpty()) { + final Element wildcardPatterns = addChild(state, JpsJavaCompilerConfigurationSerializer.WILDCARD_RESOURCE_PATTERNS); + for (final String wildcardPattern : myWildcardPatterns) { + addChild(wildcardPatterns, JpsJavaCompilerConfigurationSerializer.ENTRY).setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, wildcardPattern); + } + } + + final Element annotationProcessingSettings = addChild(state, JpsJavaCompilerConfigurationSerializer.ANNOTATION_PROCESSING); + final Element defaultProfileElem = addChild(annotationProcessingSettings, "profile").setAttribute("default", "true"); + AnnotationProcessorProfileSerializer.writeExternal(myDefaultProcessorsProfile, defaultProfileElem); + for (ProcessorConfigProfile profile : myModuleProcessorProfiles) { + final Element profileElem = addChild(annotationProcessingSettings, "profile").setAttribute("default", "false"); + AnnotationProcessorProfileSerializer.writeExternal(profile, profileElem); + } + + if (!StringUtil.isEmpty(myBytecodeTargetLevel) || !myModuleBytecodeTarget.isEmpty()) { + final Element bytecodeTarget = addChild(state, JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL); + if (!StringUtil.isEmpty(myBytecodeTargetLevel)) { + bytecodeTarget.setAttribute(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE, myBytecodeTargetLevel); + } + if (!myModuleBytecodeTarget.isEmpty()) { + final List moduleNames = new ArrayList(myModuleBytecodeTarget.keySet()); + Collections.sort(moduleNames, String.CASE_INSENSITIVE_ORDER); + for (String name : moduleNames) { + final Element moduleElement = addChild(bytecodeTarget, JpsJavaCompilerConfigurationSerializer.MODULE); + moduleElement.setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, name); + final String value = myModuleBytecodeTarget.get(name); + moduleElement.setAttribute(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE, value != null ? value : ""); + } + } + } + return state; } @Override @@ -758,56 +804,6 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements } } - private void writeExternal(Element parentNode) throws WriteExternalException { - DefaultJDOMExternalizer.writeExternal(this, parentNode); - - if (myAddNotNullAssertions != true) { - addChild(parentNode, JpsJavaCompilerConfigurationSerializer.ADD_NOTNULL_ASSERTIONS).setAttribute( - JpsJavaCompilerConfigurationSerializer.ENABLED, String.valueOf(myAddNotNullAssertions)); - } - - if(myExcludedEntriesConfiguration.getExcludeEntryDescriptions().length > 0) { - myExcludedEntriesConfiguration.writeExternal(addChild(parentNode, JpsJavaCompilerConfigurationSerializer.EXCLUDE_FROM_COMPILE)); - } - - final Element newChild = addChild(parentNode, JpsJavaCompilerConfigurationSerializer.RESOURCE_EXTENSIONS); - for (final String pattern : getRegexpPatterns()) { - addChild(newChild, JpsJavaCompilerConfigurationSerializer.ENTRY).setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, pattern); - } - - if (myWildcardPatternsInitialized || !myWildcardPatterns.isEmpty()) { - final Element wildcardPatterns = addChild(parentNode, JpsJavaCompilerConfigurationSerializer.WILDCARD_RESOURCE_PATTERNS); - for (final String wildcardPattern : myWildcardPatterns) { - addChild(wildcardPatterns, JpsJavaCompilerConfigurationSerializer.ENTRY).setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, wildcardPattern); - } - } - - final Element annotationProcessingSettings = addChild(parentNode, JpsJavaCompilerConfigurationSerializer.ANNOTATION_PROCESSING); - final Element defaultProfileElem = addChild(annotationProcessingSettings, "profile").setAttribute("default", "true"); - AnnotationProcessorProfileSerializer.writeExternal(myDefaultProcessorsProfile, defaultProfileElem); - for (ProcessorConfigProfile profile : myModuleProcessorProfiles) { - final Element profileElem = addChild(annotationProcessingSettings, "profile").setAttribute("default", "false"); - AnnotationProcessorProfileSerializer.writeExternal(profile, profileElem); - } - - if (!StringUtil.isEmpty(myBytecodeTargetLevel) || !myModuleBytecodeTarget.isEmpty()) { - final Element bytecodeTarget = addChild(parentNode, JpsJavaCompilerConfigurationSerializer.BYTECODE_TARGET_LEVEL); - if (!StringUtil.isEmpty(myBytecodeTargetLevel)) { - bytecodeTarget.setAttribute(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE, myBytecodeTargetLevel); - } - if (!myModuleBytecodeTarget.isEmpty()) { - final List moduleNames = new ArrayList(myModuleBytecodeTarget.keySet()); - Collections.sort(moduleNames, String.CASE_INSENSITIVE_ORDER); - for (String name : moduleNames) { - final Element moduleElement = addChild(bytecodeTarget, JpsJavaCompilerConfigurationSerializer.MODULE); - moduleElement.setAttribute(JpsJavaCompilerConfigurationSerializer.NAME, name); - final String value = myModuleBytecodeTarget.get(name); - moduleElement.setAttribute(JpsJavaCompilerConfigurationSerializer.TARGET_ATTRIBUTE, value != null? value : ""); - } - } - } - } - @Override @NotNull @NonNls public String getComponentName() { From 9b615d3dd14bc8ee0be6f432dad5afc7d73d958c Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 29 Oct 2014 13:31:33 +0100 Subject: [PATCH 08/23] Preferences: 'Sopes' moved dowin in 'Appearance' group --- platform/platform-resources/src/META-INF/PlatformLangPlugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml index ffeeeef7871b..44ef7698cac6 100644 --- a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml +++ b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml @@ -82,7 +82,7 @@ - + From a584c7e6f66a4da8f02895ae05bbfe1909b6926a Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 29 Oct 2014 13:53:42 +0100 Subject: [PATCH 09/23] Testing framework now allows checking only specified warnings and highlightings (bug fixed) (c280b5094ed1f9ee4b0801e61d5cb796bb5a5399) --- .../fixtures/impl/CodeInsightTestFixtureImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index a433ccadd30a..f188bfd0c207 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -407,7 +407,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override public long checkHighlighting(final boolean checkWarnings, final boolean checkInfos, final boolean checkWeakWarnings, boolean ignoreExtraHighlighting) { try { - return collectAndCheckHighlighting(checkWarnings, checkInfos, checkWeakWarnings); + return collectAndCheckHighlighting(checkWarnings, checkInfos, checkWeakWarnings, ignoreExtraHighlighting); } catch (Exception e) { throw new RuntimeException(e); @@ -1501,8 +1501,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig private long collectAndCheckHighlighting(boolean checkWarnings, boolean checkInfos, boolean checkWeakWarnings, boolean ignoreExtraHighlighting) throws Exception { ExpectedHighlightingData data = new ExpectedHighlightingData(myEditor.getDocument(), - checkWarnings, checkWeakWarnings, ignoreExtraHighlighting, - checkInfos, getHostFile()); + checkWarnings, checkWeakWarnings, checkInfos, ignoreExtraHighlighting, getHostFile()); data.init(); return collectAndCheckHighlighting(data); } From 89fbb331fd599c44ef18c34445605922c1f89bb6 Mon Sep 17 00:00:00 2001 From: Liana Bakradze Date: Wed, 29 Oct 2014 16:01:05 +0300 Subject: [PATCH 10/23] fixed broken shortcut for next task window action --- .../python/edu/StudyTaskManager.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/edu/learn-python/src/com/jetbrains/python/edu/StudyTaskManager.java b/python/edu/learn-python/src/com/jetbrains/python/edu/StudyTaskManager.java index f37adf0b19f6..365aa25afd23 100644 --- a/python/edu/learn-python/src/com/jetbrains/python/edu/StudyTaskManager.java +++ b/python/edu/learn-python/src/com/jetbrains/python/edu/StudyTaskManager.java @@ -217,14 +217,14 @@ public class StudyTaskManager implements ProjectComponent, PersistentStateCompon } }); } - addShortcut(StudyNextWindowAction.SHORTCUT, StudyNextWindowAction.ACTION_ID); - addShortcut(StudyPrevWindowAction.SHORTCUT, StudyPrevWindowAction.ACTION_ID); - addShortcut(StudyShowHintAction.SHORTCUT, StudyShowHintAction.ACTION_ID); - addShortcut(StudyNextWindowAction.SHORTCUT2, StudyNextWindowAction.ACTION_ID); - addShortcut(StudyCheckAction.SHORTCUT, StudyCheckAction.ACTION_ID); - addShortcut(StudyNextStudyTaskAction.SHORTCUT, StudyNextStudyTaskAction.ACTION_ID); - addShortcut(StudyPreviousStudyTaskAction.SHORTCUT, StudyPreviousStudyTaskAction.ACTION_ID); - addShortcut(StudyRefreshTaskFileAction.SHORTCUT, StudyRefreshTaskFileAction.ACTION_ID); + addShortcut(StudyNextWindowAction.SHORTCUT, StudyNextWindowAction.ACTION_ID, false); + addShortcut(StudyPrevWindowAction.SHORTCUT, StudyPrevWindowAction.ACTION_ID, false); + addShortcut(StudyShowHintAction.SHORTCUT, StudyShowHintAction.ACTION_ID, false); + addShortcut(StudyNextWindowAction.SHORTCUT2, StudyNextWindowAction.ACTION_ID, true); + addShortcut(StudyCheckAction.SHORTCUT, StudyCheckAction.ACTION_ID, false); + addShortcut(StudyNextStudyTaskAction.SHORTCUT, StudyNextStudyTaskAction.ACTION_ID, false); + addShortcut(StudyPreviousStudyTaskAction.SHORTCUT, StudyPreviousStudyTaskAction.ACTION_ID, false); + addShortcut(StudyRefreshTaskFileAction.SHORTCUT, StudyRefreshTaskFileAction.ACTION_ID, false); } } }); @@ -233,10 +233,10 @@ public class StudyTaskManager implements ProjectComponent, PersistentStateCompon } - private static void addShortcut(@NotNull final String shortcutString, @NotNull final String actionIdString) { + private static void addShortcut(@NotNull final String shortcutString, @NotNull final String actionIdString, boolean isAdditional) { Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); Shortcut[] shortcuts = keymap.getShortcuts(actionIdString); - if (shortcuts.length > 0) { + if (shortcuts.length > 0 && !isAdditional) { return; } Shortcut studyActionShortcut = new KeyboardShortcut(KeyStroke.getKeyStroke(shortcutString), null); From 6a08e626c6a92a16e0fcc2004f0bfc73029e2241 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 29 Oct 2014 16:07:51 +0300 Subject: [PATCH 11/23] code cleanup - use singletonList for single element collections --- .../intellij/debugger/engine/JavaExecutionStack.java | 3 +-- .../debugger/settings/ImageObjectRenderer.java | 4 ++-- .../debugger/ui/impl/watch/CompilingEvaluator.java | 11 ++++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java index 61bd5d4df803..c19b0e8ec027 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaExecutionStack.java @@ -32,7 +32,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.Arrays; import java.util.Collections; import java.util.Iterator; @@ -176,7 +175,7 @@ public class JavaExecutionStack extends XExecutionStack { } if (first || DebuggerSettings.getInstance().SHOW_LIBRARY_STACKFRAMES || (!frame.getDescriptor().isSynthetic() && !frame.getDescriptor().isInLibraryContent())) { if (++myAdded > mySkip) { - myContainer.addStackFrames(Arrays.asList(frame), false); + myContainer.addStackFrames(Collections.singletonList(frame), false); } } myDebugProcess.getManagerThread().schedule( diff --git a/java/debugger/impl/src/com/intellij/debugger/settings/ImageObjectRenderer.java b/java/debugger/impl/src/com/intellij/debugger/settings/ImageObjectRenderer.java index 8f48ae93b995..fa332a347794 100644 --- a/java/debugger/impl/src/com/intellij/debugger/settings/ImageObjectRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/settings/ImageObjectRenderer.java @@ -32,7 +32,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -88,7 +88,7 @@ class ImageObjectRenderer extends CompoundReferenceRenderer implements FullValue if (cls != null) { List methods = cls.methodsByName(methodName); if (!methods.isEmpty()) { - return process.invokeMethod(evaluationContext, cls, methods.get(0), Arrays.asList(obj)); + return process.invokeMethod(evaluationContext, cls, methods.get(0), Collections.singletonList(obj)); } } return null; diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java index 90df15380b3f..8900db300cf1 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/CompilingEvaluator.java @@ -50,10 +50,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes; import javax.tools.*; import java.io.ByteArrayOutputStream; import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import java.util.*; /** * @author egor @@ -250,9 +247,9 @@ public class CompilingEvaluator implements ExpressionEvaluator { StringReference url = proxy.mirrorOf("file:a"); keep(url, context); ObjectReference reference = classType.newInstance(threadReference, classType.concreteMethodByName("", "(Ljava/lang/String;)V"), - Arrays.asList(url), ClassType.INVOKE_SINGLE_THREADED); + Collections.singletonList(url), ClassType.INVOKE_SINGLE_THREADED); keep(reference, context); - arrayRef.setValues(Arrays.asList(reference)); + arrayRef.setValues(Collections.singletonList(reference)); return arrayRef; } @@ -290,7 +287,7 @@ public class CompilingEvaluator implements ExpressionEvaluator { diagnostic, options, null, - Arrays.asList(new SourceFileObject(getMainClassName(), JavaFileObject.Kind.SOURCE, getClassCode())) + Collections.singletonList(new SourceFileObject(getMainClassName(), JavaFileObject.Kind.SOURCE, getClassCode())) ).call()) { StringBuilder res = new StringBuilder("Compilation failed:\n"); for (Diagnostic d : diagnostic.getDiagnostics()) { From f0fc85674e9c62f756f02cec81d87f0229820994 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 29 Oct 2014 14:03:03 +0100 Subject: [PATCH 12/23] diamonds: constructor varargs (IDEA-131918) --- .../src/com/intellij/psi/PsiDiamondTypeImpl.java | 5 +++++ .../daemonCodeAnalyzer/lambda/diamond/Varargs.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java index 5f3eee5c6be3..a9522c333b3d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/PsiDiamondTypeImpl.java @@ -206,6 +206,11 @@ public class PsiDiamondTypeImpl extends PsiDiamondType { protected PsiClass getContainingClass(PsiMethod method) { return containingClass; } + + @Override + protected boolean acceptVarargs() { + return true; + } }; processor.setArgumentList(argumentList); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java index 9afe7e792e3e..516e12cd6935 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/diamond/Varargs.java @@ -24,3 +24,12 @@ class A { bar(s(get(), "")); } } + +class B { + public B(T entity) {} + public B(T entity, Integer... error){} + + void foo(final Integer generalError){ + B value = new B<>("", generalError); + } +} \ No newline at end of file From bf3ef3eb09e5c2e1790e9beb999dd298a1e94de6 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Wed, 29 Oct 2014 16:28:21 +0300 Subject: [PATCH 13/23] IDEA-131263 Visual issues with editor gutters --- .../impl/EditorGutterComponentImpl.java | 39 +++++++------------ .../openapi/editor/impl/EditorImpl.java | 7 +--- .../fileEditor/impl/EditorComposite.java | 14 +------ .../src/DefaultColorSchemesManager.xml | 6 +-- .../vcs/ex/LineStatusTrackerDrawing.java | 11 +++--- 5 files changed, 25 insertions(+), 52 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java index 17c37d822fe2..b65a147fa0ef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java @@ -76,7 +76,6 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private static final int FREE_PAINTERS_AREA_WIDTH = 5; private static final int GAP_BETWEEN_ICONS = 3; private static final TooltipGroup GUTTER_TOOLTIP_GROUP = new TooltipGroup("GUTTER_TOOLTIP_GROUP", 0); - private static final Color COLOR_F0F0 = new Color(0xF0F0F0); public static final TIntFunction ID = new TIntFunction() { @Override public int execute(int value) { @@ -96,7 +95,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private TIntArrayList myTextAnnotationGutterSizes = new TIntArrayList(); private ArrayList myTextAnnotationGutters = new ArrayList(); private final Map myProviderToListener = new HashMap(); - private static final int GAP_BETWEEN_ANNOTATIONS = 6; + private static final int GAP_BETWEEN_ANNOTATIONS = 5; private Color myBackgroundColor = null; private String myLastGutterToolTip = null; private int myLastPreferredHeight = -1; @@ -227,7 +226,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private void paintEditorBackgrounds(Graphics g, Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) { Color defaultBackgroundColor = myEditor.getBackgroundColor(); - int startX = getWhitespaceSeparatorOffset() + 1; + int startX = getWhitespaceSeparatorOffset() + (isFoldingOutlineShown() ? 1 : 0); IterationState state = new IterationState(myEditor, firstVisibleOffset, lastVisibleOffset, false, true); while (!state.atEnd()) { VisualPosition visualStart = myEditor.offsetToVisualPosition(state.getStartOffset()); @@ -329,19 +328,12 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse x += myTextAnnotationGutterSizes.get(i); } - - if (!myEditor.isInDistractionFreeMode()) { - UIUtil.drawVDottedLine((Graphics2D)g, getAnnotationsAreaOffset() + w - 1, clip.y, clip.y + clip.height, null, getOutlineColor(false)); - } } private void paintFoldingTree(Graphics g, Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) { if (isFoldingOutlineShown()) { doPaintFoldingTree((Graphics2D)g, clip, firstVisibleOffset, lastVisibleOffset); } - else { - UIUtil.drawVDottedLine((Graphics2D)g, clip.x + clip.width - 1, clip.y, clip.y + clip.height, null, getOutlineColor(false)); - } } private void paintLineMarkers(Graphics g, Rectangle clip, int firstVisibleOffset, int lastVisibleOffset) { @@ -378,8 +370,6 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private void paintLineNumbers(Graphics g, Rectangle clip) { if (isLineNumbersShown()) { - int x = getLineNumberAreaOffset() + getLineNumberAreaWidth() - 2; - UIUtil.drawVDottedLine((Graphics2D)g, x, clip.y, clip.y + clip.height, null, getOutlineColor(false)); doPaintLineNumbers(g, clip); } } @@ -396,7 +386,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse EditorColorsScheme colorsScheme = myEditor.getColorsScheme(); boolean distractionMode = myEditor.isInDistractionFreeMode(); Color color = distractionMode ? colorsScheme.getDefaultBackground() : colorsScheme.getColor(EditorColors.GUTTER_BACKGROUND); - myBackgroundColor = color == null ? COLOR_F0F0 : color; + myBackgroundColor = color == null ? EditorColors.GUTTER_BACKGROUND.getDefaultColor() : color; } return myBackgroundColor; } @@ -648,9 +638,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse } }); - myLineMarkerAreaWidth = myIconsAreaWidth + FREE_PAINTERS_AREA_WIDTH + - // if folding outline is shown, there will be enough place for change markers, otherwise add place for it. - (isFoldingOutlineShown() ? 0 : getFoldingAnchorWidth() / 2); + myLineMarkerAreaWidth = myIconsAreaWidth + FREE_PAINTERS_AREA_WIDTH; } private void paintGutterRenderers(final Graphics g, int firstVisibleOffset, int lastVisibleOffset) { @@ -739,7 +727,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse int height = endY - startY; int w = FREE_PAINTERS_AREA_WIDTH; - int x = getLineMarkerAreaOffset() + myIconsAreaWidth; + int x = getLineMarkerAreaOffset() + myIconsAreaWidth - 1; return new Rectangle(x, startY, w, height); } @@ -770,7 +758,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse final int leftSize = x - getLineMarkerAreaOffset(); - x = getLineMarkerAreaOffset() + myIconsAreaWidth; + x = getLineMarkerAreaOffset() + myIconsAreaWidth - 2; // because of 2px LineMarkerRenderers for (GutterMark r : row) { if (((GutterIconRenderer)r).getAlignment() == GutterIconRenderer.Alignment.RIGHT) { Icon icon = r.getIcon(); @@ -780,7 +768,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse } } - int rightSize = myIconsAreaWidth + getLineMarkerAreaOffset() - x; + int rightSize = myIconsAreaWidth + getLineMarkerAreaOffset() - x + 1; if (middleCount > 0) { middleSize -= GAP_BETWEEN_ICONS; @@ -845,7 +833,9 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse private void paintFoldingLines(final Graphics2D g, final Rectangle clip) { if (!isFoldingOutlineShown()) return; - UIUtil.drawVDottedLine(g, getWhitespaceSeparatorOffset(), clip.y, clip.y + clip.height, null, getOutlineColor(false)); + g.setColor(getOutlineColor(false)); + int x = getWhitespaceSeparatorOffset(); + UIUtil.drawLine(g, x, clip.y, x, clip.y + clip.height); final int anchorX = getFoldingAreaOffset(); final int width = getFoldingAnchorWidth(); @@ -981,14 +971,11 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse } public int getFoldingAreaOffset() { - return getLineMarkerAreaOffset() + - getLineMarkerAreaWidth(); + return getLineMarkerAreaOffset() + getLineMarkerAreaWidth(); } public int getFoldingAreaWidth() { - return isFoldingOutlineShown() - ? getFoldingAnchorWidth() + 2 - : 0; + return getFoldingAnchorWidth() + (isFoldingOutlineShown() ? 2 : 0); } @Override @@ -1347,7 +1334,7 @@ class EditorGutterComponentImpl extends EditorGutterComponentEx implements Mouse } @Override - public void actionPerformed(AnActionEvent e) { + public void actionPerformed(@NotNull AnActionEvent e) { closeAllAnnotations(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 5179512af245..484191e67b07 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -303,7 +303,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private final TIntFunction myLineNumberAreaWidthFunction = new TIntFunction() { @Override public int execute(int lineNumber) { - return getFontMetrics(Font.PLAIN).stringWidth(Integer.toString(lineNumber + 1)) + 6; + return getFontMetrics(Font.PLAIN).stringWidth(Integer.toString(lineNumber + 1)) + 5; } }; @@ -6771,10 +6771,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi g.setColor(ButtonlessScrollBarUI.getTrackBackground()); g.fillRect(0, 0, width, height); - int shortner = 0; - if (myGutterComponent.isFoldingOutlineShown()) { - shortner = myGutterComponent.getFoldingAreaWidth() / 2; - } + int shortner = myGutterComponent.getFoldingAreaWidth() / 2; g.setColor(myGutterComponent.getBackground()); g.fillRect(0, 0, width - shortner, height); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java index d8a704d891bf..87668ba25ea0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorComposite.java @@ -36,7 +36,6 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.FocusWatcher; import com.intellij.ui.PrevNextActionsDescriptor; -import com.intellij.ui.SideBorder; import com.intellij.ui.TabbedPaneWrapper; import com.intellij.ui.tabs.UiDecorator; import com.intellij.util.SmartList; @@ -351,7 +350,7 @@ public abstract class EditorComposite implements Disposable { if (remove) { container.remove(component.getParent()); } else { - container.add(new TopBottomComponentWrapper(component, top)); + container.add(new TopBottomComponentWrapper(component)); } container.revalidate(); } @@ -474,19 +473,10 @@ public abstract class EditorComposite implements Disposable { private static class TopBottomComponentWrapper extends JPanel { private final JComponent myWrappee; - public TopBottomComponentWrapper(JComponent component, boolean top) { + public TopBottomComponentWrapper(JComponent component) { super(new BorderLayout()); myWrappee = component; setOpaque(false); - - setBorder(new SideBorder(null, top ? SideBorder.BOTTOM : SideBorder.TOP, true) { - @Override - public Color getLineColor() { - Color result = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.TEARLINE_COLOR); - return result == null ? Color.black : result; - } - }); - add(component); } diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index 42ab4dcb3abc..ad7511a69f82 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -18,10 +18,10 @@