From 5b128908c54bf9617a25bc47093516550c4b3dff Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 8 Apr 2014 14:15:55 +0200 Subject: [PATCH] disable closure folding on Java 8 as confusing --- .../codeInsight/folding/impl/JavaFoldingBuilderBase.java | 2 +- .../com/intellij/codeInsight/folding/JavaFoldingTest.groovy | 6 ++++++ .../src/messages/ApplicationBundle.properties | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java b/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java index c1875bcf8b91..550ffc26b062 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/folding/impl/JavaFoldingBuilderBase.java @@ -744,7 +744,7 @@ public abstract class JavaFoldingBuilderBase extends CustomFoldingBuilder implem if (argumentList != null && argumentList.getExpressions().length == 0) { final PsiMethod[] methods = anonymousClass.getMethods(); PsiClass baseClass = anonymousClass.getBaseClassType().resolve(); - if (hasOnlyOneLambdaMethod(anonymousClass, !quick) && seemsLikeLambda(baseClass)) { + if (hasOnlyOneLambdaMethod(anonymousClass, !quick) && seemsLikeLambda(baseClass) && !PsiUtil.isLanguageLevel8OrHigher(anonymousClass)) { final PsiMethod method = methods[0]; final PsiCodeBlock body = method.getBody(); if (body != null) { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy index b462263eeba3..ffe09fdfcbcb 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/folding/JavaFoldingTest.groovy @@ -29,6 +29,7 @@ import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass import com.intellij.psi.PsiMethod import com.intellij.psi.search.GlobalSearchScope +import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase /** @@ -40,6 +41,11 @@ public class JavaFoldingTest extends LightCodeInsightFixtureTestCase { def JavaCodeFoldingSettingsImpl myFoldingSettings def JavaCodeFoldingSettingsImpl myFoldingStateToRestore + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JAVA_1_7 + } + @Override public void setUp() { super.setUp() diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties index 9088b59dd45e..d5dccd501729 100644 --- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties +++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties @@ -343,7 +343,7 @@ group.code.folding=Code Folding checkbox.collapse.xml.tags=XML tags checkbox.collapse.html.style.attribute=HTML 'style' attribute checkbox.collapse.anonymous.classes=Anonymous classes -checkbox.collapse.closures="Closures" (anonymous classes implementing one method) +checkbox.collapse.closures="Closures" (anonymous classes implementing one method, before Java 8) checkbox.collapse.generic.constructor.parameters=Generic constructor and method parameters checkbox.collapse.i18n.messages=I18n strings checkbox.collapse.annotations=Annotations