From f80977de4402d2aac9512e1c9749ab6995a44187 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 6 Feb 2015 13:26:05 +0100 Subject: [PATCH 01/13] honor FileEditorProvider's dumb-awareness --- .../fileEditor/impl/FileEditorProviderManagerImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java index 3fb69a7f5089..aba649be7115 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.java @@ -25,6 +25,7 @@ import com.intellij.openapi.fileEditor.FileEditorProvider; import com.intellij.openapi.fileEditor.WeighedFileEditorProvider; import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager; import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Condition; @@ -86,6 +87,9 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag if (ApplicationManager.getApplication().runReadAction(new Computable() { @Override public Boolean compute() { + if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) { + return false; + } return provider.accept(project, file); } })) { From f1733d2ed73e45841227c5fcfaa6b53176a3d67e Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 6 Feb 2015 14:19:28 +0100 Subject: [PATCH 02/13] ApplicationUtil add @NotNull --- .../com/intellij/openapi/application/ex/ApplicationUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java index fac3451878b3..3ef73a61e10e 100644 --- a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java +++ b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationUtil.java @@ -62,7 +62,7 @@ public class ApplicationUtil { * Note that the process may continue to run in background indefinitely - so avoid using this method unless absolutely needed. */ public static T runWithCheckCanceled(@NotNull final Callable callable, - @NotNull final ProgressIndicator indicator, ExecutorService executorService) throws Exception { + @NotNull final ProgressIndicator indicator, @NotNull ExecutorService executorService) throws Exception { final Ref result = Ref.create(); final Ref error = Ref.create(); From a88ab17b3f26c8e7f98f0e8c5db3609dd22f85ec Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 6 Feb 2015 14:49:37 +0100 Subject: [PATCH 03/13] IDEA-136079 "Contract violation" warnings are reported for inferred method contract for method with varargs --- .../codeInspection/dataFlow/value/DfaVariableValue.java | 6 +++++- .../inspection/dataFlow/contractCheck/VarargInferred.java | 6 ++++++ .../com/intellij/codeInspection/ContractCheckTest.java | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/inspection/dataFlow/contractCheck/VarargInferred.java diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java index 65b5e61b28a7..fd45fdfc8b5a 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaVariableValue.java @@ -57,7 +57,11 @@ public class DfaVariableValue extends DfaValue { } public DfaVariableValue createVariableValue(PsiVariable myVariable, boolean isNegated) { - return createVariableValue(myVariable, myVariable.getType(), isNegated, null); + PsiType varType = myVariable.getType(); + if (varType instanceof PsiEllipsisType) { + varType = new PsiArrayType(((PsiEllipsisType)varType).getComponentType()); + } + return createVariableValue(myVariable, varType, isNegated, null); } @NotNull public DfaVariableValue createVariableValue(@NotNull PsiModifierListOwner myVariable, diff --git a/java/java-tests/testData/inspection/dataFlow/contractCheck/VarargInferred.java b/java/java-tests/testData/inspection/dataFlow/contractCheck/VarargInferred.java new file mode 100644 index 000000000000..7f38129033be --- /dev/null +++ b/java/java-tests/testData/inspection/dataFlow/contractCheck/VarargInferred.java @@ -0,0 +1,6 @@ +class X { + public static String compute(String... s) { + if (s == null) return null; + return ""; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ContractCheckTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ContractCheckTest.java index c2cddc127835..50355f3c9ced 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ContractCheckTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ContractCheckTest.java @@ -40,4 +40,5 @@ public class ContractCheckTest extends LightCodeInsightFixtureTestCase { public void testNestedCallsMayThrow() { doTest(); } public void testSignatureIssues() { doTest(); } + public void testVarargInferred() { doTest(); } } From ef8a480730937ff26efe7d066fa8eefc7a8e8318 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 6 Feb 2015 14:59:48 +0100 Subject: [PATCH 04/13] diagnostics for lookup disposed during typing (IDEA-136066) --- .../intellij/codeInsight/lookup/impl/LookupTypedHandler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java index dd370f6dfe7f..e84667ebd4d0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java @@ -207,6 +207,7 @@ public class LookupTypedHandler extends TypedActionHandlerBase { @Nullable private static CharFilter.Result getFiltersDecision(char charTyped, LookupImpl lookup) { + lookup.checkValid(); LookupElement item = lookup.getCurrentItem(); int prefixLength = item == null ? lookup.getAdditionalPrefix().length(): lookup.itemPattern(item).length(); @@ -215,6 +216,9 @@ public class LookupTypedHandler extends TypedActionHandlerBase { if (result != null) { return result; } + if (lookup.isLookupDisposed()) { + throw new AssertionError("Lookup disposed after " + extension); + } } return null; } From afb11843f488b864d6f3e0e4316b34bc36396ae2 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 6 Feb 2015 15:51:47 +0100 Subject: [PATCH 05/13] =?UTF-8?q?IDEA-135004=20New=20=E2=80=9Cnon=20null?= =?UTF-8?q?=20fields=20must=20be=20initialised=E2=80=9D=20not=20helpful=20?= =?UTF-8?q?when=20DI=20is=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nullable/NullableStuffInspectionBase.java | 18 +++++++++++------- .../nullable/NullableStuffInspection.java | 4 ++++ .../codeInspection/nullable/OptionsPanel.form | 16 ++++++++++++---- .../NotNullFieldNotInitializedSetting.java | 9 +++++++++ .../NullableStuffInspectionTest.java | 6 ++++++ 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 java/java-tests/testData/inspection/nullableProblems/NotNullFieldNotInitializedSetting.java diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java index cb2c3fda0b68..bda9f4be9581 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspectionBase.java @@ -53,6 +53,7 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_PARAMETER_OVERRIDES_NOTNULL = true; @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_GETTER = true; @SuppressWarnings({"WeakerAccess"}) public boolean IGNORE_EXTERNAL_SUPER_NOTNULL = false; + @SuppressWarnings({"WeakerAccess"}) public boolean REQUIRE_NOTNULL_FIELDS_INITIALIZED = true; @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED = false; @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_NOT_ANNOTATED_SETTER_PARAMETER = true; @Deprecated @SuppressWarnings({"WeakerAccess"}) public boolean REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true; // remains for test @@ -67,7 +68,8 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo String name = child.getAttributeValue("name"); String value = child.getAttributeValue("value"); if ("IGNORE_EXTERNAL_SUPER_NOTNULL".equals(name) && "false".equals(value) || - "REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED".equals(name) && "false".equals(value)) { + "REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED".equals(name) && "false".equals(value) || + "REQUIRE_NOTNULL_FIELDS_INITIALIZED".equals(name) && "true".equals(value)) { node.removeContent(child); } } @@ -178,12 +180,14 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo } List initializers = DfaPsiUtil.findAllConstructorInitializers(field); - if (annotated.isDeclaredNotNull && initializers.isEmpty()) { - final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, manager.getNotNulls()); - if (annotation != null) { - holder.registerProblem(annotation.isPhysical() ? annotation : field.getNameIdentifier(), - "Not-null fields must be initialized", - ProblemHighlightType.GENERIC_ERROR_OR_WARNING); + if (REQUIRE_NOTNULL_FIELDS_INITIALIZED) { + if (annotated.isDeclaredNotNull && initializers.isEmpty()) { + final PsiAnnotation annotation = AnnotationUtil.findAnnotation(field, manager.getNotNulls()); + if (annotation != null) { + holder.registerProblem(annotation.isPhysical() ? annotation : field.getNameIdentifier(), + "Not-null fields must be initialized", + ProblemHighlightType.GENERIC_ERROR_OR_WARNING); + } } } diff --git a/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java b/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java index b860a937d412..125bb6a2c11b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/nullable/NullableStuffInspection.java @@ -40,6 +40,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase { private JButton myConfigureAnnotationsButton; private JCheckBox myIgnoreExternalSuperNotNull; private JCheckBox myNNParameterOverridesNA; + private JCheckBox myRequireNNFieldsInitialized; private OptionsPanel() { super(new BorderLayout()); @@ -56,6 +57,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase { myNNParameterOverridesNA.addActionListener(actionListener); myReportNotAnnotatedGetter.addActionListener(actionListener); myIgnoreExternalSuperNotNull.addActionListener(actionListener); + myRequireNNFieldsInitialized.addActionListener(actionListener); myConfigureAnnotationsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -74,6 +76,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase { myReportNotAnnotatedGetter.setSelected(REPORT_NOT_ANNOTATED_GETTER); myIgnoreExternalSuperNotNull.setSelected(IGNORE_EXTERNAL_SUPER_NOTNULL); myNNParameterOverridesNA.setSelected(REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED); + myRequireNNFieldsInitialized.setSelected(REQUIRE_NOTNULL_FIELDS_INITIALIZED); myIgnoreExternalSuperNotNull.setEnabled(myNAMethodOverridesNN.isSelected()); } @@ -84,6 +87,7 @@ public class NullableStuffInspection extends NullableStuffInspectionBase { REPORT_NOT_ANNOTATED_GETTER = myReportNotAnnotatedGetter.isSelected(); IGNORE_EXTERNAL_SUPER_NOTNULL = myIgnoreExternalSuperNotNull.isSelected(); REPORT_NOTNULL_PARAMETERS_OVERRIDES_NOT_ANNOTATED = myNNParameterOverridesNA.isSelected(); + REQUIRE_NOTNULL_FIELDS_INITIALIZED = myRequireNNFieldsInitialized.isSelected(); REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = REPORT_NOT_ANNOTATED_METHOD_OVERRIDES_NOTNULL; myIgnoreExternalSuperNotNull.setEnabled(myNAMethodOverridesNN.isSelected()); diff --git a/java/java-impl/src/com/intellij/codeInspection/nullable/OptionsPanel.form b/java/java-impl/src/com/intellij/codeInspection/nullable/OptionsPanel.form index 34c5535fa6fd..c9d38f447b36 100644 --- a/java/java-impl/src/com/intellij/codeInspection/nullable/OptionsPanel.form +++ b/java/java-impl/src/com/intellij/codeInspection/nullable/OptionsPanel.form @@ -1,16 +1,16 @@
- + - + - + @@ -39,7 +39,7 @@ - + @@ -61,6 +61,14 @@ + + + + + + + + diff --git a/java/java-tests/testData/inspection/nullableProblems/NotNullFieldNotInitializedSetting.java b/java/java-tests/testData/inspection/nullableProblems/NotNullFieldNotInitializedSetting.java new file mode 100644 index 000000000000..5513b01408d9 --- /dev/null +++ b/java/java-tests/testData/inspection/nullableProblems/NotNullFieldNotInitializedSetting.java @@ -0,0 +1,9 @@ +import org.jetbrains.annotations.*; + +class Test { + @NotNull Object member; + + private void accessMember() { + member = new Object(); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java index 0b8e6c086b16..40302703f045 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java @@ -48,7 +48,13 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase public void testNullableFieldNotnullParam() throws Exception{ doTest(); } public void testNotNullFieldNullableParam() throws Exception{ doTest(); } public void testNotNullCustomException() throws Exception{ doTest(); } + public void testNotNullFieldNotInitialized() throws Exception{ doTest(); } + public void testNotNullFieldNotInitializedSetting() { + myInspection.REQUIRE_NOTNULL_FIELDS_INITIALIZED = false; + doTest(); + } + public void testNotNullAnnotationChecksInChildClassMethods() { doTest(); } public void testGetterSetterProblems() throws Exception{ doTest(); } From 64e33ad08168f9074cf440d1865054099fa1da56 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 6 Feb 2015 16:08:36 +0100 Subject: [PATCH 06/13] sleep a bit when trying to do gc in tests, maybe this will help with blinking --- platform/testFramework/src/com/intellij/util/GCUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/testFramework/src/com/intellij/util/GCUtil.java b/platform/testFramework/src/com/intellij/util/GCUtil.java index 610537beffa0..ab2f1a419b68 100644 --- a/platform/testFramework/src/com/intellij/util/GCUtil.java +++ b/platform/testFramework/src/com/intellij/util/GCUtil.java @@ -52,6 +52,7 @@ public class GCUtil { if (q.poll() != null) { break; } + TimeoutUtil.sleep(10); long bytes = Math.min(Runtime.getRuntime().freeMemory() / 2, Integer.MAX_VALUE); list.add(new SoftReference(new byte[(int)bytes])); } From 047814b137347e1e51b6b375db70f15115b26b99 Mon Sep 17 00:00:00 2001 From: "Vladimir.Orlov" Date: Fri, 6 Feb 2015 18:11:53 +0300 Subject: [PATCH 07/13] IDEA-135960 IDEA 14.0.2 to 14.0.3 update fails on restart due to missing restarter.exe --- platform/util/src/com/intellij/util/Restarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/Restarter.java b/platform/util/src/com/intellij/util/Restarter.java index fdcc4f876b3f..3e8692d7b9bd 100644 --- a/platform/util/src/com/intellij/util/Restarter.java +++ b/platform/util/src/com/intellij/util/Restarter.java @@ -155,8 +155,8 @@ public class Restarter { public static File createTempExecutable(File executable) throws IOException { File executableDir = new File(System.getProperty("user.home") + "/." + System.getProperty("idea.paths.selector") + "/restart"); - File copy = new File(executableDir.getPath() + "/" + executable.getName()); if (!FileUtilRt.createDirectory(executableDir)) throw new IOException("Cannot create dir: " + executableDir); + File copy = new File(executableDir.getPath() + "/" + executable.getName()); if (!FileUtilRt.ensureCanCreateFile(copy) || (copy.exists() && !copy.delete())) { String ext = FileUtilRt.getExtension(executable.getName()); copy = FileUtilRt.createTempFile(executableDir, FileUtilRt.getNameWithoutExtension(copy.getName()), From 2ed103a958d4f80918df379567917f75fbb182c7 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Fri, 6 Feb 2015 18:36:34 +0300 Subject: [PATCH 08/13] editor: allow to disable default foldings - update after review --- .../src/com/intellij/diff/util/DiffUtil.java | 2 +- .../com/intellij/openapi/editor/EditorSettings.java | 4 ++-- .../folding/impl/CodeFoldingManagerImpl.java | 4 ++-- .../intellij/openapi/editor/impl/SettingsImpl.java | 11 +++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java index 29d554ccf3d8..a54a57ede2de 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/DiffUtil.java @@ -157,7 +157,7 @@ public class DiffUtil { if (enableFolding) { editor.getSettings().setFoldingOutlineShown(true); - editor.getSettings().setCodeFoldingEnabled(false); + editor.getSettings().setAutoCodeFoldingEnabled(false); } else { editor.getSettings().setFoldingOutlineShown(false); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java index 68cb3b57b641..56e6d9a3489f 100644 --- a/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java @@ -54,8 +54,8 @@ public interface EditorSettings { boolean isFoldingOutlineShown(); void setFoldingOutlineShown(boolean val); - boolean isCodeFoldingEnabled(); - void setCodeFoldingEnabled(boolean val); + boolean isAutoCodeFoldingEnabled(); + void setAutoCodeFoldingEnabled(boolean val); boolean isUseTabCharacter(Project project); void setUseTabCharacter(boolean useTabCharacter); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java index eaaea3c7570e..7a3695f46fcb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/folding/impl/CodeFoldingManagerImpl.java @@ -248,7 +248,6 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec } private void initFolding(@NotNull final Editor editor) { - if (!editor.getSettings().isCodeFoldingEnabled()) return; final Document document = editor.getDocument(); editor.getFoldingModel().runBatchFoldingOperation(new Runnable() { @Override @@ -289,6 +288,7 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec } public void updateFoldRegions(Editor editor, boolean quick) { + if (!editor.getSettings().isAutoCodeFoldingEnabled()) return; PsiDocumentManager.getInstance(myProject).commitDocument(editor.getDocument()); Runnable runnable = updateFoldRegions(editor, false, quick); if (runnable != null) { @@ -322,6 +322,7 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec @Override @Nullable public Runnable updateFoldRegionsAsync(@NotNull final Editor editor, final boolean firstTime) { + if (!editor.getSettings().isAutoCodeFoldingEnabled()) return null; final Runnable runnable = updateFoldRegions(editor, firstTime, false); return new Runnable() { @Override @@ -338,7 +339,6 @@ public class CodeFoldingManagerImpl extends CodeFoldingManager implements Projec @Nullable private Runnable updateFoldRegions(@NotNull Editor editor, boolean applyDefaultState, boolean quick) { - if (!editor.getSettings().isCodeFoldingEnabled()) return null; PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument()); if (file != null) { return FoldingUpdate.updateFoldRegions(editor, file, applyDefaultState, quick); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java index 6264fa486a7c..ed14e128a804 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java @@ -51,7 +51,7 @@ public class SettingsImpl implements EditorSettings { private int myLineCursorWidth = Registry.intValue("editor.caret.width", 2); private boolean myLineMarkerAreaShown = true; private boolean myAllowSingleLogicalLineFolding = false; - private boolean myCodeFoldingEnabled = true; + private boolean myAutoCodeFoldingEnabled = true; // These comes from CodeStyleSettings private Integer myTabSize = null; @@ -281,14 +281,13 @@ public class SettingsImpl implements EditorSettings { } @Override - public boolean isCodeFoldingEnabled() { - return myCodeFoldingEnabled; + public boolean isAutoCodeFoldingEnabled() { + return myAutoCodeFoldingEnabled; } @Override - public void setCodeFoldingEnabled(boolean val) { - myCodeFoldingEnabled = val; - fireEditorRefresh(); + public void setAutoCodeFoldingEnabled(boolean val) { + myAutoCodeFoldingEnabled = val; } @Override From dbe3b9165167b069be59f53adbcc03a465117c72 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 6 Feb 2015 16:54:05 +0100 Subject: [PATCH 09/13] IDEA-136053 (annotation parsing loop protection) --- .../lang/java/parser/DeclarationParser.java | 7 +++++-- .../parser-partial/declarations/AnnoLoop.txt | 18 ++++++++++++++++++ .../parser/partial/DeclarationParserTest.java | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/psi/parser-partial/declarations/AnnoLoop.txt diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java index 36d024726bbf..9ff9da60f09c 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -767,7 +767,10 @@ public class DeclarationParser { final PsiBuilder.Marker anno = builder.mark(); builder.advanceLexer(); - final PsiBuilder.Marker classRef = myParser.getReferenceParser().parseJavaCodeReference(builder, true, false, false, false); + PsiBuilder.Marker classRef = null; + if (builder.getTokenType() == JavaTokenType.IDENTIFIER) { + classRef = myParser.getReferenceParser().parseJavaCodeReference(builder, true, false, false, false); + } if (classRef == null) { error(builder, JavaErrorMessages.message("expected.class.reference")); } diff --git a/java/java-tests/testData/psi/parser-partial/declarations/AnnoLoop.txt b/java/java-tests/testData/psi/parser-partial/declarations/AnnoLoop.txt new file mode 100644 index 000000000000..36ed65b5c563 --- /dev/null +++ b/java/java-tests/testData/psi/parser-partial/declarations/AnnoLoop.txt @@ -0,0 +1,18 @@ +PsiJavaFile:AnnoLoop.java + PsiJavaToken:LBRACE('{') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected token + PsiJavaToken:AT('@') + PsiJavaToken:AT('@') + PsiJavaToken:AT('@') + PsiWhiteSpace(' ') + PsiField:i + PsiModifierList: + + PsiTypeElement:int + PsiKeyword:int('int') + PsiWhiteSpace(' ') + PsiIdentifier:i('i') + PsiJavaToken:SEMICOLON(';') + PsiWhiteSpace(' ') + PsiJavaToken:RBRACE('}') \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java index e088797031a4..d29a9d8eee12 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java @@ -64,6 +64,7 @@ public class DeclarationParserTest extends JavaParsingTestCase { public void testAnnoNested() { doParserTest("{ @interface Inner { String bar () default \"\"; } }", true, false); } public void testAnnoInner() { doParserTest("{ @interface Inner { double bar () default 0.0; } }"); } public void testAnnoOtherMembers() { doParserTest("{ int field;\n void m() {}\n class C {}\n interface I {} }", true, false); } + public void testAnnoLoop() { doParserTest("{ @@@ int i; }"); } public void testFieldSimple() { doParserTest("{ int field = 0; }"); } public void testFieldMulti() { doParserTest("{ int field1 = 0, field2; }"); } From 76f2928beafd474dcd4b1e2294f33383e2a6008a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 6 Feb 2015 16:58:00 +0100 Subject: [PATCH 10/13] Cleanup (formatting) --- .../psi/parser-partial/declarations/AnnoDefault.txt | 1 - .../lang/java/parser/partial/DeclarationParserTest.java | 2 +- .../src/com/intellij/lang/impl/PsiBuilderImpl.java | 7 +++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/java/java-tests/testData/psi/parser-partial/declarations/AnnoDefault.txt b/java/java-tests/testData/psi/parser-partial/declarations/AnnoDefault.txt index 5d8e43524fb3..7ce071b2355e 100644 --- a/java/java-tests/testData/psi/parser-partial/declarations/AnnoDefault.txt +++ b/java/java-tests/testData/psi/parser-partial/declarations/AnnoDefault.txt @@ -13,7 +13,6 @@ PsiJavaFile:AnnoDefault.java PsiWhiteSpace(' ') PsiIdentifier:foo('foo') - PsiWhiteSpace(' ') PsiParameterList:() PsiJavaToken:LPARENTH('(') PsiJavaToken:RPARENTH(')') diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java index d29a9d8eee12..624aea51f565 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/DeclarationParserTest.java @@ -60,7 +60,7 @@ public class DeclarationParserTest extends JavaParsingTestCase { public void testEnumWithoutConstants() { doParserTest("{ private A }", false, true); } public void testAnnoSimple() { doParserTest("{ int foo (); }", true, false); } - public void testAnnoDefault() { doParserTest("{ Class foo () default String.class; }", true, false); } + public void testAnnoDefault() { doParserTest("{ Class foo() default String.class; }", true, false); } public void testAnnoNested() { doParserTest("{ @interface Inner { String bar () default \"\"; } }", true, false); } public void testAnnoInner() { doParserTest("{ @interface Inner { double bar () default 0.0; } }"); } public void testAnnoOtherMembers() { doParserTest("{ int field;\n void m() {}\n class C {}\n interface I {} }", true, false); } diff --git a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index 885720f0251f..da2212ccd5e0 100644 --- a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.lang.impl; import com.intellij.lang.*; @@ -66,6 +65,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { public static final Key, ThreeState>> CUSTOM_COMPARATOR = Key.create("CUSTOM_COMPARATOR"); + private static TokenSet ourAnyLanguageWhitespaceTokens = TokenSet.EMPTY; + private final Project myProject; private PsiFile myFile; @@ -75,7 +76,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { private final MyList myProduction = new MyList(); - @NotNull private final Lexer myLexer; + private final Lexer myLexer; private final TokenSet myWhitespaces; private TokenSet myComments; @@ -92,8 +93,6 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { private final MyTreeStructure myParentLightTree; private final int myOffset; - private static TokenSet ourAnyLanguageWhitespaceTokens = TokenSet.EMPTY; - private Map myUserData = null; private IElementType myCachedTokenType; From 2a7ec5a483ed3cb2411aa103f80f530f09303b4f Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 6 Feb 2015 16:59:16 +0100 Subject: [PATCH 11/13] platform: more correct cancellation check; condition simplified --- .../src/com/intellij/lang/impl/PsiBuilderImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index da2212ccd5e0..c984f56575fd 100644 --- a/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/core-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -763,14 +763,16 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { @Override public void advanceLexer() { + ProgressIndicatorProvider.checkCanceled(); + if (eof()) return; if (!myTokenTypeChecked) { - LOG.assertTrue(eof(), "Probably a bug: eating token without its type checking"); + LOG.error("Probably a bug: eating token without its type checking"); } + myTokenTypeChecked = false; myCurrentLexeme++; - ProgressIndicatorProvider.checkCanceled(); clearCachedTokenType(); } From efeff677aef4b52f2bb83bc0dea4e4c854e0429c Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 6 Feb 2015 16:41:05 +0100 Subject: [PATCH 12/13] EA-63660 - assert: PsiMethodReferenceExpressionImpl.setQualifierExpression --- .../refactoring/move/moveMembers/MoveJavaMemberHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java index bfeade036b0e..59dbd1ab271f 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveJavaMemberHandler.java @@ -203,7 +203,7 @@ public class MoveJavaMemberHandler implements MoveMemberHandler { } protected static void changeQualifier(PsiReferenceExpression refExpr, PsiClass aClass, PsiMember member) throws IncorrectOperationException { - if (RefactoringUtil.hasOnDemandStaticImport(refExpr, aClass)) { + if (RefactoringUtil.hasOnDemandStaticImport(refExpr, aClass) && !(refExpr instanceof PsiMethodReferenceExpression)) { refExpr.setQualifierExpression(null); } else if (!ImportsUtil.hasStaticImportOn(refExpr, member, false)){ From 903b16a40d65303df30c7f90865f890d02165cd3 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 6 Feb 2015 16:56:20 +0100 Subject: [PATCH 13/13] close/closeHovered icons: copy from closeNew, remove usages of closeNew/Hovered --- platform/icons/src/actions/close.png | Bin 163 -> 165 bytes platform/icons/src/actions/close@2x.png | Bin 0 -> 319 bytes platform/icons/src/actions/close@2x_dark.png | Bin 0 -> 319 bytes platform/icons/src/actions/closeHovered.png | Bin 502 -> 165 bytes platform/icons/src/actions/closeHovered@2x.png | Bin 0 -> 316 bytes .../icons/src/actions/closeHovered@2x_dark.png | Bin 0 -> 318 bytes .../icons/src/actions/closeHovered_dark.png | Bin 0 -> 165 bytes platform/icons/src/actions/close_dark.png | Bin 0 -> 165 bytes .../ArrangementRemoveConditionAction.java | 4 ++-- .../ui/layout/actions/CloseViewAction.java | 4 ++-- .../ui/popup/util/MasterDetailPopupBuilder.java | 2 +- .../fileEditor/impl/EditorTabbedContainer.java | 4 ++-- .../learning/actions/StudyEditInputAction.java | 4 ++-- 13 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 platform/icons/src/actions/close@2x.png create mode 100644 platform/icons/src/actions/close@2x_dark.png create mode 100644 platform/icons/src/actions/closeHovered@2x.png create mode 100644 platform/icons/src/actions/closeHovered@2x_dark.png create mode 100644 platform/icons/src/actions/closeHovered_dark.png create mode 100644 platform/icons/src/actions/close_dark.png diff --git a/platform/icons/src/actions/close.png b/platform/icons/src/actions/close.png index 7e4dedc4f1336bf99740cd58a425e8ba197577c7..c5f4c69877c37abc6ea3ee9eeb9af1adbf5d24d6 100644 GIT binary patch delta 149 zcmV;G0BZlE0i^+u7=H)`0000V^Z#K0003-BL_t(|+U=4-4uBvG1Pg!F=&f%Ngpcu` zx+FDe)I*6^4wGgN3`+`$2>pSk;4NV01sos%(s_c-E2uy~0udC=*((S}(sXu7@Crz8 zZbs5GjWo!Q26d!CGKZqc#VgqFH=8Z=t*rAae{%umE5bu1`3}l_00000NkvXXu0mjf Dq8~eE delta 147 zcmZ3=xR`N*L_G^L0|Ud`yN`l^lyrbki0is_>(;Md|NsAg2m_f6Is35_sEoZN$S)X3 zXJzH)E`PuK7?5e;>Eal|5uF^+#KiVU;#J=v--NcJZdaih3t!wj#*!E@#YsX-RZc*Y i*Lj+n6Wby~hPmH_Kdf~xO5g!%X7F_Nb6Mw<&;$TbgF7++ diff --git a/platform/icons/src/actions/close@2x.png b/platform/icons/src/actions/close@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..5b8b5bceb6733975affd4262c270c2b8f49ef834 GIT binary patch literal 319 zcmV-F0l@x=P);9LWpDYq82GW z2;?!}2QS4~p66M=#4-UUzy$n#fa|(GA>kZE*gsPS#K8#$6G?hM#^8y~&*oT&q RGp_&u002ovPDHLkV1gGXd58c2 literal 0 HcmV?d00001 diff --git a/platform/icons/src/actions/close@2x_dark.png b/platform/icons/src/actions/close@2x_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..5b8b5bceb6733975affd4262c270c2b8f49ef834 GIT binary patch literal 319 zcmV-F0l@x=P);9LWpDYq82GW z2;?!}2QS4~p66M=#4-UUzy$n#fa|(GA>kZE*gsPS#K8#$6G?hM#^8y~&*oT&q RGp_&u002ovPDHLkV1gGXd58c2 literal 0 HcmV?d00001 diff --git a/platform/icons/src/actions/closeHovered.png b/platform/icons/src/actions/closeHovered.png index 5c2b1fd66ff17728db268b0b79ed86932085a19d..155a0bbf021e5f4fb7cbba3f36aa6c435c8470b1 100644 GIT binary patch delta 138 zcmV;50CoTN1Em3wBYyyFNkl;p9V9YOdQ|EWt-lSVz1c;zr@ z_Q0^DkciM9XbRo}W?sMn0wA3y*t~)Y1SAka(VV@4U?fdvmjthX^yX$HJ<~{o{Af@| s8YFWlnq0hs{eH9ALf^_dzw$R1okFz^%@c1700000NkvXXt^-0~g7F7A;{X5v delta 477 zcmV<30V4jT0rmrsBYy$CNklW)0Hu{qxUVPLh64|x8v0BnZFO%r}puP7IQII;KJ z?)8U=caY)dC4V##*BNd=xl&EI0NZgBhW7(ouGWWur(e%-iTL{tL%vku1NsAp8vOxi zh!@NCzIg%D*_=IlK?vn0jjpgr$r@qd{)lCM#Kbh=1y)a|8Sk*e6a#2 zh4K!coM*B}XZ(lMQZ;ffs|2x7yKaiuOc5vPz!1~i>1PqKko|Z@KD-w2ZhzxnXkYj@ T{p!to00000NkvXXu0mjfB8=ok diff --git a/platform/icons/src/actions/closeHovered@2x.png b/platform/icons/src/actions/closeHovered@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..64ad175444423d57e2af5c3b7836066ac30be2bb GIT binary patch literal 316 zcmV-C0mJ@@P)dY^9f1kAj1BcG9V6Sp!GrC1PhR$4B+xP@W2hU1LRjR zw**P5fGpUF4|DFC2rj=!GkZ{^TtPt-(GhnIjl4wt1~_@Jl|&CP)W}^EkMLcD%t4l$ z3gG0Fb#P9q++;uWqeKi$1XMNhvbf8DwGzQ716+-~ zqO2yZiKtQqM8PCLE=R1y+!VwpR}cZ?0J%>JjJTX^1@?!;2G{@_V44>%!kgl_h=hp% O0000P)N}QmMGW_y;l&LL8eHwMg+n zAdmSzcqzv6JkR*zpfD?urN|zX&sXP^4TzK@rjBcXfrlMEwRBd9W2k4=_~7Z5@yBU4+O% zlAl-JY}{2leu{RsYm}bu1~B3 P+RNbS>gTe~DWM4fMKnPT literal 0 HcmV?d00001 diff --git a/platform/icons/src/actions/close_dark.png b/platform/icons/src/actions/close_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..c5f4c69877c37abc6ea3ee9eeb9af1adbf5d24d6 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ii4<#Ar-gYPIBaHP~c(VuD|+X zZN6Yj|Ht{eR7^9kICqBgO-|$I@#gB}_}jSbfo{SxRv86`OO;J$wO2SeFbRsBy{XON zcB!Py^8=ShexBPU<6e^!{cNR69F5u+ojj_2