From 90944177701d48014fc3886c2c67fb8680294130 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 12 Oct 2012 12:14:58 +0200 Subject: [PATCH 01/19] ignore implicit extends Object bound e.g. we skip it already in com.intellij.psi.impl.compiled.SignatureParsing.parseTypeParameter (IDEA-92740) --- .../src/com/intellij/psi/util/MethodSignatureUtil.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java index 8c692900f997..72c373ec94a5 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/MethodSignatureUtil.java @@ -306,6 +306,8 @@ public class MethodSignatureUtil { for (PsiClassType superSuper : superTypeParameter.getSuperTypes()) { superSupers.add(methodSubstitutor.substitute(PsiUtil.captureToplevelWildcards(result.substitute(superSuper), methodTypeParameter))); } + methodSupers.remove(PsiType.getJavaLangObject(methodTypeParameter.getManager(), methodTypeParameter.getResolveScope())); + superSupers.remove(PsiType.getJavaLangObject(superTypeParameter.getManager(), superTypeParameter.getResolveScope())); if (!methodSupers.equals(superSupers)) return null; } From 58c7d3e5dabce7a2553c8aed28631d7094e490c4 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 12 Oct 2012 14:03:37 +0200 Subject: [PATCH 02/19] ctrl-b: suggest ambiguous constructors as it is done for methods (IDEA-92366) --- .../src/com/intellij/codeInsight/TargetElementUtil.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java index c31dcd5023fa..141b63ff67a5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/TargetElementUtil.java @@ -111,6 +111,8 @@ public class TargetElementUtil extends TargetElementUtilBase { PsiMethod constructor = ((PsiNewExpression)parent).resolveConstructor(); if (constructor != null) { refElement = constructor; + } else if (refElement instanceof PsiClass && ((PsiClass)refElement).getConstructors().length > 0) { + return null; } } } @@ -194,10 +196,11 @@ public class TargetElementUtil extends TargetElementUtilBase { public Collection getTargetCandidates(final PsiReference reference) { PsiElement parent = reference.getElement().getParent(); - if (parent instanceof PsiMethodCallExpression) { - PsiMethodCallExpression callExpr = (PsiMethodCallExpression)parent; + if (parent instanceof PsiCallExpression) { + PsiCallExpression callExpr = (PsiCallExpression)parent; boolean allowStatics = false; - PsiExpression qualifier = callExpr.getMethodExpression().getQualifierExpression(); + PsiExpression qualifier = callExpr instanceof PsiMethodCallExpression ? ((PsiMethodCallExpression)callExpr).getMethodExpression().getQualifierExpression() + : callExpr instanceof PsiNewExpression ? ((PsiNewExpression)callExpr).getQualifier() : null; if (qualifier == null) { allowStatics = true; } From beb2c4df542c4c086508bcb80c5b7cde2d34a309 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 12 Oct 2012 14:42:20 +0200 Subject: [PATCH 03/19] method refs: do not warn about type args over raw types, non parameterized methods (IDEA-92851) --- .../impl/analysis/GenericsHighlightUtil.java | 2 +- .../methodRef/TypeArgumentsOnMethodRefs.java | 17 +++++++++++++++++ .../lambda/MethodRefHighlightingTest.java | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/TypeArgumentsOnMethodRefs.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index 41c052f206bc..370d479a1a89 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -1292,7 +1292,7 @@ public class GenericsHighlightUtil { if (((PsiModifierListOwner)element).hasModifierProperty(PsiModifier.STATIC)) return null; PsiClass containingClass = ((PsiMember)element).getContainingClass(); if (containingClass != null && PsiUtil.isRawSubstitutor(containingClass, resolveResult.getSubstitutor())) { - if (parent instanceof PsiCallExpression && PsiUtil.isLanguageLevel7OrHigher(parent)) { + if ((parent instanceof PsiCallExpression || parent instanceof PsiMethodReferenceExpression) && PsiUtil.isLanguageLevel7OrHigher(parent)) { return null; } final String message = element instanceof PsiClass diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/TypeArgumentsOnMethodRefs.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/TypeArgumentsOnMethodRefs.java new file mode 100644 index 000000000000..1fe00da253a7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/TypeArgumentsOnMethodRefs.java @@ -0,0 +1,17 @@ +class Test { + void foo(String p) {} + void foo1(String p) {} + static void foo2(String p) {} + static void foo3(String p) {} + void test() { + Test test = new Test(); + BlahBlah blahBlah = test::foo; + BlahBlah blahBlah1 = test::foo1; + BlahBlah blahBlah2 = test::foo2; + BlahBlah blahBlah3 = test::foo3; + } +} + +interface BlahBlah { + void bar(T i); +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java index 0cc6a0713330..e4e8e8b2cae1 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java @@ -125,6 +125,10 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testTypeArgumentsOnMethodRefs() throws Exception { + doTest(); + } + public void testInferenceFromReturnType() throws Exception { doTest(true); } From 7eafe63a528ec0173d2f6ae9f903b117b3fd96e9 Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 12 Oct 2012 17:06:25 +0400 Subject: [PATCH 04/19] drop unnessessary shift-tab --- .../com/intellij/ui/LanguageTextField.java | 2 - .../src/com/intellij/ui/ShiftTabAction.java | 70 ------------------- .../intelliLang/AdvancedSettingsUI.java | 6 +- .../inject/config/ui/LanguagePanel.java | 4 -- 4 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 platform/lang-impl/src/com/intellij/ui/ShiftTabAction.java diff --git a/platform/lang-impl/src/com/intellij/ui/LanguageTextField.java b/platform/lang-impl/src/com/intellij/ui/LanguageTextField.java index 6c14adeae747..875cbc2acafc 100644 --- a/platform/lang-impl/src/com/intellij/ui/LanguageTextField.java +++ b/platform/lang-impl/src/com/intellij/ui/LanguageTextField.java @@ -62,8 +62,6 @@ public class LanguageTextField extends EditorTextField { myProject = project; setEnabled(language != null); - - ShiftTabAction.attachTo(this); } public interface DocumentCreator { diff --git a/platform/lang-impl/src/com/intellij/ui/ShiftTabAction.java b/platform/lang-impl/src/com/intellij/ui/ShiftTabAction.java deleted file mode 100644 index d12a1dcf7614..000000000000 --- a/platform/lang-impl/src/com/intellij/ui/ShiftTabAction.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2006 Sascha Weinreuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.ui; - -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CustomShortcutSet; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; - -/** - * Provides Shift-Tab support in EditorTextFields which otherwise don't support this keystroke to - * move the input focus to the previous component. - */ -@SuppressWarnings({"ComponentNotRegistered"}) -public class ShiftTabAction extends AnAction { - private static final CustomShortcutSet SHIFT_TAB; - - static { - final KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK); - SHIFT_TAB = new CustomShortcutSet(keyStroke); - } - - private final EditorTextField myEditor; - - private ShiftTabAction(EditorTextField editor) { - super("Shift-Tab"); - myEditor = editor; - } - - public void actionPerformed(AnActionEvent event) { - Container container = myEditor.getParent(); - while (container != null && container.getFocusTraversalPolicy() == null) { - container = container.getParent(); - } - if (container != null) { - final FocusTraversalPolicy ftp = container.getFocusTraversalPolicy(); - if (ftp != null) { - final Component prev = ftp.getComponentBefore(container, myEditor); - if (prev != null) { - prev.requestFocus(); - } - } - } - } - - /** - * Call this method to enable Sift-Tab support for the supplied EditorTextField. - */ - public static void attachTo(EditorTextField textField) { - // TODO following code seems not needed due to textField.pleaseHandleShiftTab() - new ShiftTabAction(textField).registerCustomShortcutSet(SHIFT_TAB, textField); - } -} diff --git a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java index ab8c7a918ac2..887107ec5ca0 100644 --- a/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java +++ b/plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/AdvancedSettingsUI.java @@ -27,7 +27,6 @@ import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiClass; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.ReferenceEditorWithBrowseButton; -import com.intellij.ui.ShiftTabAction; import com.intellij.util.Function; import org.intellij.plugins.intelliLang.util.PsiUtilEx; import org.jetbrains.annotations.Nls; @@ -75,7 +74,6 @@ public class AdvancedSettingsUI implements Configurable { }, myConfiguration.getLanguageAnnotationClass()); myAnnotationField.addActionListener(new BrowseClassListener(project, myAnnotationField)); myAnnotationField.setEnabled(!project.isDefault()); - ShiftTabAction.attachTo(myAnnotationField.getEditorTextField()); addField(myLanguageAnnotationPanel, myAnnotationField); myPatternField = new ReferenceEditorWithBrowseButton(null, project, new Function() { @@ -85,7 +83,6 @@ public class AdvancedSettingsUI implements Configurable { }, myConfiguration.getPatternAnnotationClass()); myPatternField.addActionListener(new BrowseClassListener(project, myPatternField)); myPatternField.setEnabled(!project.isDefault()); - ShiftTabAction.attachTo(myPatternField.getEditorTextField()); addField(myPatternAnnotationPanel, myPatternField); mySubstField = new ReferenceEditorWithBrowseButton(null, project, new Function() { @@ -95,10 +92,9 @@ public class AdvancedSettingsUI implements Configurable { }, myConfiguration.getPatternAnnotationClass()); mySubstField.addActionListener(new BrowseClassListener(project, mySubstField)); mySubstField.setEnabled(!project.isDefault()); - ShiftTabAction.attachTo(mySubstField.getEditorTextField()); addField(mySubstAnnotationPanel, mySubstField); } - + // /** * Adds textfield into placeholder panel and assigns a directly preceding label */ diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java index 4804350a9f39..c029af24256d 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java @@ -26,7 +26,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.ui.ColoredListCellRendererWrapper; import com.intellij.ui.EditorTextField; -import com.intellij.ui.ShiftTabAction; import com.intellij.ui.SimpleTextAttributes; import org.intellij.plugins.intelliLang.inject.InjectedLanguage; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; @@ -94,9 +93,6 @@ public class LanguagePanel extends AbstractInjectionPanel { public void ancestorMoved(AncestorEvent event) { } }); - - ShiftTabAction.attachTo(myPrefix); - ShiftTabAction.attachTo(mySuffix); } private void updateHighlighters() { From db3f600a003862e4a930488ae49a4c6d92270054 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 12 Oct 2012 14:19:48 +0200 Subject: [PATCH 05/19] IDEA-92840 Grammar mistake in Class.isAnnotationPresent warning --- .../ReflectionForUnavailableAnnotation.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html index 3ecca5ce1f91..0d693c534579 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReflectionForUnavailableAnnotation.html @@ -1,7 +1,7 @@ This inspection reports any attempts to reflectively check for the presence of an -annotation which is not defined has being retained at runtime. +annotation which is not defined as being retained at runtime. Using Class.isAnnotationPresent() to test for an annotation which has source retention or class-file retention (the default) will always result in a negative result, but is easy to do inadvertently. From a9b4cd8d4f72963714a5a1db32680cd526607c17 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 12 Oct 2012 14:58:12 +0200 Subject: [PATCH 06/19] IDEA-88769 Java keyword completion: duplicate "final" suggestion --- .../codeInsight/completion/JavaCompletionData.java | 13 ++++++++----- .../keywords/finalAfterParameterAnno2.java | 3 +++ .../completion/KeywordCompletionTest.java | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/keywords/finalAfterParameterAnno2.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java index 5cdf6edce78a..6ca14f343b6e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java @@ -538,11 +538,14 @@ public class JavaCompletionData extends JavaAwareCompletionData { return false; } - if (psiElement().afterLeaf( - or( - psiElement().withoutText(".").inside(psiElement(PsiModifierList.class).withParent(not(psiElement(PsiParameter.class)))).andNot( - psiElement().inside(PsiAnnotationParameterList.class)), - psiElement().isNull())).accepts(position)) { + PsiElement prev = PsiTreeUtil.prevVisibleLeaf(position); + if (prev == null) { + return true; + } + if (psiElement().withoutText(".").inside( + psiElement(PsiModifierList.class).withParent( + not(psiElement(PsiParameter.class)).andNot(psiElement(PsiParameterList.class)))).accepts(prev) && + !psiElement().inside(PsiAnnotationParameterList.class).accepts(prev)) { return true; } diff --git a/java/java-tests/testData/codeInsight/completion/keywords/finalAfterParameterAnno2.java b/java/java-tests/testData/codeInsight/completion/keywords/finalAfterParameterAnno2.java new file mode 100644 index 000000000000..276bfb3844c3 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/keywords/finalAfterParameterAnno2.java @@ -0,0 +1,3 @@ +public class Util { + void foo(@Foo int args) { } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index fe96da3cd6a4..747417d2771a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -105,6 +105,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); } public void testReturnInTernary() throws Exception { doTest(1, "return"); } public void testFinalAfterParameterAnno() throws Exception { doTest(2, "final", "float", "class"); } + public void testFinalAfterParameterAnno2() throws Exception { doTest(2, "final", "float", "class"); } public void testClassInMethod() throws Exception { doTest(2, "class", "char"); } public void testIntInClassArray() throws Throwable { doTest(2, "int", "char", "final"); } public void testIntInClassArray2() throws Throwable { doTest(2, "int", "char", "final"); } From 844ea256d72263672ccefcfecdd840a2f21b8764 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 12 Oct 2012 15:07:44 +0200 Subject: [PATCH 07/19] logging all compiler messages in test mode --- .../compiler/impl/CompileContextImpl.java | 4 ++++ .../server/BuildMessageDispatcher.java | 3 +++ .../jetbrains/jps/cmdline/BuildSession.java | 3 +++ .../groovy/compiler/GroovyCompilerTest.groovy | 24 +++++++++---------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java index a06185b67d71..081d06f42e4e 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileContextImpl.java @@ -263,6 +263,10 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon } public void addMessage(CompilerMessage msg) { + if (ApplicationManager.getApplication().isUnitTestMode()) { + LOG.info("addMessage: " + msg); + } + Collection messages = myMessages.get(msg.getCategory()); if (messages == null) { messages = new LinkedHashSet(); diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java index 5b089127a738..b17cdbd7692a 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildMessageDispatcher.java @@ -125,6 +125,9 @@ class BuildMessageDispatcher extends SimpleChannelHandler { } } else { + if (ApplicationManager.getApplication().isUnitTestMode()) { + LOG.info("messageReceived: " + builderMessage); + } handler.handleBuildMessage(ctx.getChannel(), sessionId, builderMessage); } break; diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java index 73995ab4d56b..7b0fc8862085 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java @@ -109,6 +109,9 @@ final class BuildSession implements Runnable, CanceledStatus { if (kind == BuildMessage.Kind.ERROR) { hasErrors.set(true); } + if (Utils.IS_TEST_MODE) { + LOG.info("Processing message: " + buildMessage); + } response = CmdlineProtoUtil.createCompileMessage( kind, text, compilerMessage.getSourcePath(), compilerMessage.getProblemBeginOffset(), compilerMessage.getProblemEndOffset(), diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy index 639497debea8..0f800a6a5159 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTest.groovy @@ -207,26 +207,26 @@ public abstract class GroovyCompilerTest extends GroovyCompilerTestCase { } @Override - void runTest() { - def ideaLog = new File(TestLoggerFactory.testLogDir, "idea.log") - def makeLog = new File(PathManager.systemPath, "compile-server/server.log") - if (ideaLog.exists()) { - FileUtil.delete(ideaLog) - } - if (makeLog.exists()) { - FileUtil.delete(makeLog) - } + void runBare() { + new File(TestLoggerFactory.testLogDir, "idea.log").delete() + new File(PathManager.systemPath, "compile-server/server.log").delete() + super.runBare() + } + @Override + void runTest() { try { super.runTest() } catch (Throwable e) { + def ideaLog = new File(TestLoggerFactory.testLogDir, "idea.log") if (ideaLog.exists()) { - //println "Idea Log:" - //println ideaLog.text + println "\n\nIdea Log:" + println ideaLog.text } + def makeLog = new File(PathManager.systemPath, "compile-server/server.log") if (makeLog.exists()) { - println "Server Log:" + println "\n\nServer Log:" println makeLog.text } throw e From 298a188e0879bbba939ea2c09f868781fd5b9bed Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Fri, 12 Oct 2012 17:26:15 +0400 Subject: [PATCH 08/19] WebProjectTemplate fixed --- .../templates/ArchivedProjectTemplate.java | 3 +-- .../EmptyModuleTemplatesFactory.java | 3 +-- .../projectWizard/WebProjectTemplate.java | 19 +++++++++++++++---- .../intellij/platform/ProjectTemplate.java | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java index 019fe8a01d24..74d4e42b831c 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java +++ b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java @@ -17,7 +17,6 @@ package com.intellij.platform.templates; import com.intellij.ide.util.newProjectWizard.modes.ImportImlMode; import com.intellij.ide.util.projectWizard.ModuleBuilder; -import com.intellij.ide.util.projectWizard.ProjectBuilder; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.module.ModifiableModuleModel; import com.intellij.openapi.module.Module; @@ -90,7 +89,7 @@ public class ArchivedProjectTemplate implements ProjectTemplate { @NotNull @Override - public ProjectBuilder createModuleBuilder() { + public ModuleBuilder createModuleBuilder() { return new ModuleBuilder() { @Override public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException { diff --git a/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java index 2a5080e415aa..aa2c0450e09b 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java @@ -16,7 +16,6 @@ package com.intellij.platform.templates; import com.intellij.ide.util.projectWizard.ModuleBuilder; -import com.intellij.ide.util.projectWizard.ProjectBuilder; import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; @@ -70,7 +69,7 @@ public class EmptyModuleTemplatesFactory implements ProjectTemplatesFactory { @NotNull @Override - public ProjectBuilder createModuleBuilder() { + public ModuleBuilder createModuleBuilder() { return builder; } }; diff --git a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java index cb8b3c7a489d..01fb8ed639f1 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java +++ b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java @@ -17,14 +17,16 @@ package com.intellij.ide.util.projectWizard; import com.intellij.openapi.module.ModifiableModuleModel; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.WebModuleType; +import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.WebProjectGenerator; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.List; @@ -50,10 +52,19 @@ public abstract class WebProjectTemplate extends WebProjectGenerator imple @NotNull @Override - public ProjectBuilder createModuleBuilder() { + public ModuleBuilder createModuleBuilder() { final ModuleBuilder builder = WebModuleType.getInstance().createModuleBuilder(); - return new ProjectBuilder() { - @Nullable + return new ModuleBuilder() { + @Override + public void setupRootModel(ModifiableRootModel modifiableRootModel) throws ConfigurationException { + builder.setupRootModel(modifiableRootModel); + } + + @Override + public ModuleType getModuleType() { + return builder.getModuleType(); + } + @Override public List commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) { List modules = builder.commit(project, model, modulesProvider); diff --git a/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java b/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java index ff523b80eb36..baaaa66f02b8 100644 --- a/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java +++ b/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java @@ -15,7 +15,7 @@ */ package com.intellij.platform; -import com.intellij.ide.util.projectWizard.ProjectBuilder; +import com.intellij.ide.util.projectWizard.ModuleBuilder; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,5 +37,5 @@ public interface ProjectTemplate { JComponent getSettingsPanel(); @NotNull - ProjectBuilder createModuleBuilder(); + ModuleBuilder createModuleBuilder(); } From 47b6386700ed48253caa2983f9de50dec0c735fc Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Fri, 12 Oct 2012 17:28:32 +0400 Subject: [PATCH 09/19] js linters fixes --- .../openapi/options/newEditor/OptionsEditor.java | 5 +++++ .../openapi/options/newEditor/OptionsTree.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java index cb6a861c130e..6ec1243813a8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java @@ -283,6 +283,11 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat return myTree.findConfigurable(configurableClass); } + @Nullable + public SearchableConfigurable findConfigurableById(@NotNull String configurableId) { + return myTree.findConfigurableById(configurableId); + } + public ActionCallback clearSearchAndSelect(Configurable configurable) { clearFilter(); return select(configurable, ""); diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java index 3c504642fc68..98a10690524e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java @@ -34,6 +34,7 @@ import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -271,6 +272,19 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl return null; } + @Nullable + public SearchableConfigurable findConfigurableById(@NotNull String configurableId) { + for (Configurable configurable : myConfigurable2Node.keySet()) { + if (configurable instanceof SearchableConfigurable) { + SearchableConfigurable searchableConfigurable = (SearchableConfigurable) configurable; + if (configurableId.equals(searchableConfigurable.getId())) { + return searchableConfigurable; + } + } + } + return null; + } + class Renderer extends GroupedElementsRenderer.Tree { From f192f05c2c2b9c67158ddea131292073c41f9ed8 Mon Sep 17 00:00:00 2001 From: Evgeny Zakrevsky Date: Fri, 12 Oct 2012 17:53:50 +0400 Subject: [PATCH 10/19] Mantis support. Test fixed. --- plugins/tasks/tasks-core/tasks-core.iml | 1 + .../intellij/tasks/integration/MantisIntegrationTest.java | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/tasks/tasks-core/tasks-core.iml b/plugins/tasks/tasks-core/tasks-core.iml index c787fa9ad123..50d69b00c5c8 100644 --- a/plugins/tasks/tasks-core/tasks-core.iml +++ b/plugins/tasks/tasks-core/tasks-core.iml @@ -19,6 +19,7 @@ + diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/MantisIntegrationTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/MantisIntegrationTest.java index 147efb34cc31..0781a1df0475 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/MantisIntegrationTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/MantisIntegrationTest.java @@ -19,9 +19,8 @@ public class MantisIntegrationTest extends TaskManagerTestCase { public void testMantis12() throws Exception { MantisRepository mantisRepository = new MantisRepository(new MantisRepositoryType()); mantisRepository.setUrl("http://trackers-tests.labs.intellij.net:8142/"); - mantisRepository.setUsername("guest"); - mantisRepository.setPassword("guest"); - myManager.testConnection(mantisRepository); + mantisRepository.setUsername("deva"); + mantisRepository.setPassword("deva"); assertTrue(mantisRepository.getProjects().size() >= 2); final MantisProject mantisProject = mantisRepository.getProjects().get(1); From f11480e276cd17395472f28d03cdf068312a64ce Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Fri, 12 Oct 2012 18:09:50 +0400 Subject: [PATCH 11/19] ProjectTemplate validation IDEA-92573 New Project/Module Wizard: Create from template: "Next" button should be disabled if template version is not specified due to no Internet connection; RE at GithubProjectGeneratorPeer.getSettings() --- .../ide/util/newProjectWizard/SelectTemplateStep.java | 8 +++++++- .../platform/templates/ArchivedProjectTemplate.java | 8 ++++++++ .../platform/templates/EmptyModuleTemplatesFactory.java | 7 +++++++ .../ide/util/projectWizard/WebModuleGenerationStep.java | 6 +++++- .../ide/util/projectWizard/WebProjectTemplate.java | 8 ++++++++ .../boilerplate/GithubProjectGeneratorPeer.java | 6 +++++- .../src/com/intellij/platform/ProjectTemplate.java | 7 +++++++ 7 files changed, 47 insertions(+), 3 deletions(-) diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java index 13e2419da3a5..59d67f4a8ca0 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateStep.java @@ -26,6 +26,7 @@ import com.intellij.openapi.actionSystem.CustomShortcutSet; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; @@ -251,9 +252,14 @@ public class SelectTemplateStep extends ModuleWizardStep { @Override public boolean validate() throws ConfigurationException { - if (getSelectedTemplate() == null) { + ProjectTemplate template = getSelectedTemplate(); + if (template == null) { throw new ConfigurationException(ProjectBundle.message("project.new.wizard.from.template.error", myContext.getPresentationName())); } + ValidationInfo info = template.validateSettings(); + if (info != null) { + throw new ConfigurationException(info.message); + } return true; } diff --git a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java index 74d4e42b831c..8e26316e3a52 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java +++ b/java/idea-ui/src/com/intellij/platform/templates/ArchivedProjectTemplate.java @@ -25,6 +25,7 @@ import com.intellij.openapi.module.ModuleWithNameAlreadyExists; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.io.StreamUtil; @@ -36,6 +37,7 @@ import com.intellij.platform.templates.github.ZipUtil; import com.intellij.util.containers.ContainerUtil; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.File; @@ -129,6 +131,12 @@ public class ArchivedProjectTemplate implements ProjectTemplate { }; } + @Nullable + @Override + public ValidationInfo validateSettings() { + return null; + } + private ZipInputStream getStream() throws IOException { return new ZipInputStream(myArchivePath.openStream()); } diff --git a/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java index aa2c0450e09b..934420591f08 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java @@ -17,6 +17,7 @@ package com.intellij.platform.templates; import com.intellij.ide.util.projectWizard.ModuleBuilder; import com.intellij.ide.util.projectWizard.WizardContext; +import com.intellij.openapi.ui.ValidationInfo; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import com.intellij.util.Function; @@ -72,6 +73,12 @@ public class EmptyModuleTemplatesFactory implements ProjectTemplatesFactory { public ModuleBuilder createModuleBuilder() { return builder; } + + @Nullable + @Override + public ValidationInfo validateSettings() { + return null; + } }; } }); diff --git a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java index a1a85e3389d8..ad52821d9e56 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java +++ b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebModuleGenerationStep.java @@ -189,7 +189,11 @@ public class WebModuleGenerationStep extends ModuleWizardStep { if (peer == null) { throw new ConfigurationException("Peer should be not-null for " + myCurrentGenerator.getName()); } - return peer.validate() == null; + ValidationInfo validate = peer.validate(); + if (validate != null) { + throw new ConfigurationException(validate.message); + } + return true; } @SuppressWarnings("unchecked") diff --git a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java index 01fb8ed639f1..f3f85ee4225a 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java +++ b/platform/lang-impl/src/com/intellij/ide/util/projectWizard/WebProjectTemplate.java @@ -23,10 +23,12 @@ import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.ui.configuration.ModulesProvider; +import com.intellij.openapi.ui.ValidationInfo; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.WebProjectGenerator; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.List; @@ -76,4 +78,10 @@ public abstract class WebProjectTemplate extends WebProjectGenerator imple } }; } + + @Nullable + @Override + public ValidationInfo validateSettings() { + return myPeer.getValue().validate(); + } } diff --git a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java index f3e0e6243d16..475fc679a7cc 100644 --- a/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java +++ b/platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubProjectGeneratorPeer.java @@ -157,7 +157,11 @@ public class GithubProjectGeneratorPeer implements WebProjectGenerator.Generator @Override @Nullable public ValidationInfo validate() { - return null; + Object obj = myComboBox.getSelectedItem(); + if (obj instanceof GithubTagInfo) { + return null; + } + return new ValidationInfo("Can't handle selected version: " + obj); } @Override diff --git a/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java b/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java index baaaa66f02b8..c4dbc87f7e4c 100644 --- a/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java +++ b/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java @@ -16,6 +16,7 @@ package com.intellij.platform; import com.intellij.ide.util.projectWizard.ModuleBuilder; +import com.intellij.openapi.ui.ValidationInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,4 +39,10 @@ public interface ProjectTemplate { @NotNull ModuleBuilder createModuleBuilder(); + + /** + * @return null if ok, error message otherwise + */ + @Nullable + ValidationInfo validateSettings(); } From 94d8f9c42e3f66039c11c7ff70fa58ac03dc9a7e Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Fri, 12 Oct 2012 18:21:43 +0400 Subject: [PATCH 12/19] renames, set "include assets from libraries" option to true for existing project and false for new projects by default --- .../android/util/AndroidCommonUtils.java | 1 + .../jps/android/AndroidPackagingBuilder.java | 4 +-- .../model/JpsAndroidModuleExtension.java | 2 +- .../impl/JpsAndroidModuleExtensionImpl.java | 4 +-- .../impl/JpsAndroidModuleProperties.java | 5 +-- .../AndroidResourcesPackagingCompiler.java | 2 +- .../compiler/ResourcesValidityState.java | 2 +- .../facet/AndroidFacetConfiguration.java | 34 +++++++++++++------ .../android/facet/AndroidFacetEditorTab.java | 6 ++-- .../maven/AndroidFacetImporterBase.java | 2 +- 10 files changed, 39 insertions(+), 23 deletions(-) diff --git a/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java b/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java index dacb858218b8..08d47344bd7b 100644 --- a/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java +++ b/plugins/android/common/src/org/jetbrains/android/util/AndroidCommonUtils.java @@ -82,6 +82,7 @@ public class AndroidCommonUtils { }; @NonNls public static final String INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME = "includeSystemProguardFile"; + @NonNls public static final String INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME = "includeAssetsFromLibraraies"; @NonNls public static final String ADDITIONAL_NATIVE_LIBS_ELEMENT = "additionalNativeLibs"; @NonNls public static final String ITEM_ELEMENT = "item"; @NonNls public static final String ARCHITECTURE_ATTRIBUTE = "architecture"; diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java index 8f8a995d5453..85c2ec4a95a9 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidPackagingBuilder.java @@ -257,7 +257,7 @@ public class AndroidPackagingBuilder extends TargetBuilder RES_OVERLAY_FOLDERS = new ArrayList(); diff --git a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java index 5926f0358b0b..34e2d75fa8be 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java +++ b/plugins/android/src/org/jetbrains/android/compiler/AndroidResourcesPackagingCompiler.java @@ -102,7 +102,7 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom if (assetsDir != null) { result.add(FileUtil.toSystemDependentName(assetsDir.getPath())); } - if (facet.getConfiguration().PACK_ASSETS_FROM_LIBRARIES) { + if (facet.getConfiguration().isIncludeAssetsFromLibraries()) { for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) { final VirtualFile depAssetsDir = AndroidRootUtil.getAssetsDir(depFacet); diff --git a/plugins/android/src/org/jetbrains/android/compiler/ResourcesValidityState.java b/plugins/android/src/org/jetbrains/android/compiler/ResourcesValidityState.java index 65c601323f96..f9ae4db84044 100644 --- a/plugins/android/src/org/jetbrains/android/compiler/ResourcesValidityState.java +++ b/plugins/android/src/org/jetbrains/android/compiler/ResourcesValidityState.java @@ -77,7 +77,7 @@ public class ResourcesValidityState implements ValidityState { if (depResDir != null) { collectFiles(depResDir); } - if (configuration.PACK_ASSETS_FROM_LIBRARIES) { + if (configuration.isIncludeAssetsFromLibraries()) { final VirtualFile depAssetDir = AndroidRootUtil.getAssetsDir(depFacet); if (depAssetDir != null) { collectFiles(depAssetDir); diff --git a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java index 0febbe48859d..ac3a7436225f 100644 --- a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java +++ b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetConfiguration.java @@ -62,8 +62,6 @@ public class AndroidFacetConfiguration implements FacetConfiguration { public String ASSETS_FOLDER_RELATIVE_PATH = "/" + SdkConstants.FD_ASSETS; public String LIBS_FOLDER_RELATIVE_PATH = "/" + SdkConstants.FD_NATIVE_LIBS; - public boolean PACK_ASSETS_FROM_LIBRARIES = false; - public List RES_OVERLAY_FOLDERS = Arrays.asList("/res-overlay"); public boolean USE_CUSTOM_APK_RESOURCE_FOLDER = false; @@ -88,6 +86,7 @@ public class AndroidFacetConfiguration implements FacetConfiguration { public String PROGUARD_CFG_PATH = "/" + AndroidCompileUtil.PROGUARD_CFG_FILE_NAME; private boolean myIncludeSystemProguardCfgPath = true; + private boolean myIncludeAssetsFromLibraries = false; private List myAdditionalNativeLibraries = Collections.emptyList(); @@ -167,15 +166,18 @@ public class AndroidFacetConfiguration implements FacetConfiguration { } final Element includeSystemProguardFile = element.getChild(AndroidCommonUtils.INCLUDE_SYSTEM_PROGUARD_FILE_ELEMENT_NAME); - if (includeSystemProguardFile != null) { - final String includeSystemProguardFileValue = includeSystemProguardFile.getValue(); + final String includeSystemProguardFileValue = includeSystemProguardFile != null + ? includeSystemProguardFile.getValue() + : null; + myIncludeSystemProguardCfgPath = includeSystemProguardFileValue != null && + Boolean.parseBoolean(includeSystemProguardFileValue); - if (includeSystemProguardFileValue != null) { - myIncludeSystemProguardCfgPath = Boolean.parseBoolean(includeSystemProguardFileValue); - return; - } - } - myIncludeSystemProguardCfgPath = false; + final Element includeAssetsFromLibraries = element.getChild(AndroidCommonUtils.INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME); + final String includeAssetsFromLibrariesValue = includeAssetsFromLibraries != null + ? includeAssetsFromLibraries.getValue() + : null; + myIncludeAssetsFromLibraries = includeAssetsFromLibrariesValue == null || + Boolean.parseBoolean(includeAssetsFromLibrariesValue); } public void writeExternal(Element element) throws WriteExternalException { @@ -186,6 +188,10 @@ public class AndroidFacetConfiguration implements FacetConfiguration { includeSystemProguerdFile.setText(Boolean.toString(myIncludeSystemProguardCfgPath)); element.addContent(includeSystemProguerdFile); + final Element includeAssetsFromLibraries = new Element(AndroidCommonUtils.INCLUDE_ASSETS_FROM_LIBRARIES_ELEMENT_NAME); + includeAssetsFromLibraries.setText(Boolean.toString(myIncludeAssetsFromLibraries)); + element.addContent(includeAssetsFromLibraries); + final Element additionalNativeLibs = new Element(AndroidCommonUtils.ADDITIONAL_NATIVE_LIBS_ELEMENT); for (AndroidNativeLibData lib : myAdditionalNativeLibraries) { @@ -238,4 +244,12 @@ public class AndroidFacetConfiguration implements FacetConfiguration { public void setAdditionalNativeLibraries(@NotNull List additionalNativeLibraries) { myAdditionalNativeLibraries = additionalNativeLibraries; } + + public boolean isIncludeAssetsFromLibraries() { + return myIncludeAssetsFromLibraries; + } + + public void setIncludeAssetsFromLibraries(boolean includeAssetsFromLibraries) { + myIncludeAssetsFromLibraries = includeAssetsFromLibraries; + } } diff --git a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java index e464c58c4e98..1fb52fc130b4 100644 --- a/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java +++ b/plugins/android/src/org/jetbrains/android/facet/AndroidFacetEditorTab.java @@ -316,7 +316,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab { if (myConfiguration.PACK_TEST_CODE != myIncludeTestCodeAndCheckBox.isSelected()) { return true; } - if (myConfiguration.PACK_ASSETS_FROM_LIBRARIES != myIncludeAssetsFromLibraries.isSelected()) { + if (myConfiguration.isIncludeAssetsFromLibraries() != myIncludeAssetsFromLibraries.isSelected()) { return true; } @@ -437,7 +437,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab { myConfiguration.PACK_TEST_CODE = myIncludeTestCodeAndCheckBox.isSelected(); - myConfiguration.PACK_ASSETS_FROM_LIBRARIES = myIncludeAssetsFromLibraries.isSelected(); + myConfiguration.setIncludeAssetsFromLibraries(myIncludeAssetsFromLibraries.isSelected()); String absProguardPath = myProguardConfigFileTextField.getText().trim(); if (absProguardPath.length() == 0) { @@ -566,7 +566,7 @@ public class AndroidFacetEditorTab extends FacetEditorTab { myGenerateUnsignedApk.setSelected(myConfiguration.GENERATE_UNSIGNED_APK); myIncludeTestCodeAndCheckBox.setSelected(myConfiguration.PACK_TEST_CODE); - myIncludeAssetsFromLibraries.setSelected(myConfiguration.PACK_ASSETS_FROM_LIBRARIES); + myIncludeAssetsFromLibraries.setSelected(myConfiguration.isIncludeAssetsFromLibraries()); updateAptPanel(); diff --git a/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporterBase.java b/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporterBase.java index 2b6d23ca47e8..6cb5352becf2 100644 --- a/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporterBase.java +++ b/plugins/android/src/org/jetbrains/android/maven/AndroidFacetImporterBase.java @@ -119,7 +119,7 @@ public abstract class AndroidFacetImporterBase extends FacetImporter Date: Fri, 12 Oct 2012 19:06:28 +0400 Subject: [PATCH 13/19] IDEA-92375, IDEA-62134 console result tabs should be closeable with middle-click --- .../ui/layout/impl/GridCellImpl.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java index 6671454b81c0..1a850c04d0a4 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java @@ -17,6 +17,7 @@ package com.intellij.execution.ui.layout.impl; import com.intellij.execution.ui.layout.*; +import com.intellij.execution.ui.layout.actions.CloseViewAction; import com.intellij.execution.ui.layout.actions.MinimizeViewAction; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.DataProvider; @@ -119,7 +120,7 @@ public class GridCellImpl implements GridCell { myTabs.addTabMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent e) { if (UIUtil.isCloseClick(e)) { - minimize(e); + minimizeOrClose(e); } } }); @@ -250,7 +251,8 @@ public class GridCellImpl implements GridCell { if (myTabs.getSelectedInfo() != tab) { if (activate) { tab.fireAlert(); - } else { + } + else { tab.stopAlerting(); } } @@ -337,7 +339,8 @@ public class GridCellImpl implements GridCell { tab.setDetached(myPlaceInGrid, false); } myContext.detachTo(window, this).notifyWhenDone(result); - } else { + } + else { result.setDone(); } @@ -432,7 +435,7 @@ public class GridCellImpl implements GridCell { public Dimension getSize() { return DimensionService.getInstance().getSize(getDimensionKey(), myContext.getProject()); } - + private String getDimensionKey() { return "GridCell.Tab." + myContainer.getTab().getIndex() + "." + myPlaceInGrid.name(); } @@ -445,12 +448,16 @@ public class GridCellImpl implements GridCell { minimize(new Content[]{content}); } - public void minimize(MouseEvent e) { - if (!MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) return; - + public void minimizeOrClose(MouseEvent e) { TabInfo tabInfo = myTabs.findInfo(e); - if (tabInfo != null) { - minimize(getContentFor(tabInfo)); + if (tabInfo == null) return; + + Content content = getContentFor(tabInfo); + if (MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) { + minimize(content); + } + else if (CloseViewAction.isEnabled(new Content[]{content})) { + CloseViewAction.perform(myContext, content); } } From 59d8eafbcea35a42284e85b49b16e9756db7deee Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 12 Oct 2012 15:47:30 +0200 Subject: [PATCH 14/19] NPE (IDEA-92859) --- .../AnonymousCanBeMethodReferenceInspection.java | 2 +- .../codeInspection/LambdaCanBeMethReferenceInspection.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java index 6dba43ed261f..2952f93ebfdc 100644 --- a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java @@ -116,7 +116,7 @@ public class AnonymousCanBeMethodReferenceInspection extends BaseJavaLocalInspec final PsiCallExpression callExpression = LambdaCanBeMethReferenceInspection.canBeMethodReferenceProblem(methods[0].getBody(), parameters, anonymousClass.getBaseClassType()); if (callExpression == null) return; final String methodRefText = - LambdaCanBeMethReferenceInspection.createMethodReferenceText(callExpression, parameters, anonymousClass.getBaseClassType()); + LambdaCanBeMethReferenceInspection.createMethodReferenceText(callExpression, anonymousClass.getBaseClassType()); if (methodRefText != null) { final String canonicalText = anonymousClass.getBaseClassType().getCanonicalText(); diff --git a/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java b/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java index ca7fe43fd5d2..8c61532d14e9 100644 --- a/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java @@ -168,12 +168,12 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT } @Nullable - protected static String createMethodReferenceText(PsiElement element, final PsiParameter[] parameters, PsiType functionalInterfaceType) { + protected static String createMethodReferenceText(PsiElement element, PsiType functionalInterfaceType) { String methodRefText = null; if (element instanceof PsiMethodCallExpression) { final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element; final PsiMethod psiMethod = methodCall.resolveMethod(); - LOG.assertTrue(psiMethod != null); + if (psiMethod == null) return null; final PsiClass containingClass = psiMethod.getContainingClass(); LOG.assertTrue(containingClass != null); final PsiReferenceExpression methodExpression = methodCall.getMethodExpression(); @@ -227,7 +227,7 @@ public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionT final PsiElement element = descriptor.getPsiElement(); final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class); if (lambdaExpression == null) return; - final String methodRefText = createMethodReferenceText(element, lambdaExpression.getParameterList().getParameters(), lambdaExpression.getFunctionalInterfaceType()); + final String methodRefText = createMethodReferenceText(element, lambdaExpression.getFunctionalInterfaceType()); if (methodRefText != null) { final PsiExpression psiExpression = From 289ee1d04c6a37555f1df258659919b1b92bef17 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 12 Oct 2012 17:09:59 +0200 Subject: [PATCH 15/19] lambda: do not override already inferred types from parent (IDEA-92733) --- .../source/resolve/PsiResolveHelperImpl.java | 5 ++++- .../IncompatibleFormalParameterTypes.java | 19 +++++++++++++++++++ .../daemon/lambda/LambdaHighlightingTest.java | 6 +++++- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompatibleFormalParameterTypes.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index d193ee56081d..a346115cbea3 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -993,7 +993,10 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { if (method == null || methodParamsDependOn(typeParameter, expression, functionalInterfaceType, method.getParameterList().getParameters(), LambdaUtil.getSubstitutor(method, resolveResult))) { - return getFailedInferenceConstraint(typeParameter); + if (expression instanceof PsiMethodReferenceExpression) { + return getFailedInferenceConstraint(typeParameter); + } + return null; } } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompatibleFormalParameterTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompatibleFormalParameterTypes.java new file mode 100644 index 000000000000..ce112bb0b0b6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/IncompatibleFormalParameterTypes.java @@ -0,0 +1,19 @@ +class LambdaTest { + + public void highlightsTheBug(Stream stream) { + stream.flatMap((Block sink, String element) -> {}); + } + + public interface Block { + void apply(B t); + } + + public interface Stream { + Stream flatMap(FlatMapper mapper); + + } + + public interface FlatMapper { + void flatMapInto(Block sink, F element); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java index a4fa1a498b3e..6dac84473075 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java @@ -152,7 +152,11 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase { public void testRecursiveAccess() throws Exception { doTest(); } - + + public void testIncompatibleFormalParameterTypes() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false); } From 486c88b0491cad0ab9cf2436212475e3f07c6e58 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 12 Oct 2012 17:29:12 +0200 Subject: [PATCH 16/19] method refs -> lambda: correctly remove type element type arguments (IDEA-92862) --- .../ReplaceMethodRefWithLambdaIntention.java | 17 ++++++++++++----- .../methodRefs2lambda/TypeElementOnTheLeft.java | 9 +++++++++ .../TypeElementOnTheLeft_after.java | 9 +++++++++ ...eMethodReferenceWithLambdaIntentionTest.java | 4 ++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft.java create mode 100644 plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft_after.java diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java index ebf101b6b8e3..d54828570e2c 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java @@ -92,11 +92,18 @@ public class ReplaceMethodRefWithLambdaIntention extends Intention { final PsiElement referenceNameElement = referenceExpression.getReferenceNameElement(); if (isReceiver){ buf.append(parameters[0].getName()).append("."); - } else if (qualifier != null && - !(qualifier instanceof PsiThisExpression && ((PsiThisExpression)qualifier).getQualifier() == null) && - !(referenceNameElement instanceof PsiKeyword)){ - buf.append(qualifier.getText()).append("."); - } + } else { + if (!(referenceNameElement instanceof PsiKeyword)) { + if (qualifier instanceof PsiTypeElement) { + final PsiJavaCodeReferenceElement referenceElement = ((PsiTypeElement)qualifier).getInnermostComponentReferenceElement(); + LOG.assertTrue(referenceElement != null); + buf.append(referenceElement.getReferenceName()).append("."); + } + else if (qualifier != null && !(qualifier instanceof PsiThisExpression && ((PsiThisExpression)qualifier).getQualifier() == null)) { + buf.append(qualifier.getText()).append("."); + } + } + } //new or method name buf.append(referenceExpression.getReferenceName()); diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft.java new file mode 100644 index 000000000000..f3549e6c0c9c --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft.java @@ -0,0 +1,9 @@ +class Test { + static void foo() {} +} + +class Bar { + void test() { + Runnable runnable = Test::foo; + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft_after.java new file mode 100644 index 000000000000..6bf7b8d8d586 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/TypeElementOnTheLeft_after.java @@ -0,0 +1,9 @@ +class Test { + static void foo() {} +} + +class Bar { + void test() { + Runnable runnable = () -> Test.foo(); + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceMethodReferenceWithLambdaIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceMethodReferenceWithLambdaIntentionTest.java index 713fda56916a..bbc28d89732d 100644 --- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceMethodReferenceWithLambdaIntentionTest.java +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/types/ReplaceMethodReferenceWithLambdaIntentionTest.java @@ -81,4 +81,8 @@ public class ReplaceMethodReferenceWithLambdaIntentionTest extends IPPTestCase { public void testSubst() throws Exception { doTest(); } + + public void testTypeElementOnTheLeft() throws Exception { + doTest(); + } } From f4bea5007012cc6eb682062aa3861828c17cdbcf Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 12 Oct 2012 19:36:37 +0400 Subject: [PATCH 17/19] IDEA-18659 Debugger log tabs must be closable with middle click --- .../execution/ui/layout/impl/GridCellImpl.java | 13 +++++++------ .../execution/ui/layout/impl/RunnerContentUi.java | 10 ++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java index 1a850c04d0a4..f63aa608a776 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/GridCellImpl.java @@ -120,7 +120,8 @@ public class GridCellImpl implements GridCell { myTabs.addTabMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent e) { if (UIUtil.isCloseClick(e)) { - minimizeOrClose(e); + // see RunnerContentUi tabMouseListener as well + closeOrMinimize(e); } } }); @@ -448,17 +449,17 @@ public class GridCellImpl implements GridCell { minimize(new Content[]{content}); } - public void minimizeOrClose(MouseEvent e) { + public void closeOrMinimize(MouseEvent e) { TabInfo tabInfo = myTabs.findInfo(e); if (tabInfo == null) return; Content content = getContentFor(tabInfo); - if (MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) { - minimize(content); - } - else if (CloseViewAction.isEnabled(new Content[]{content})) { + if (CloseViewAction.isEnabled(new Content[]{content})) { CloseViewAction.perform(myContext, content); } + else if (MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) { + minimize(content); + } } ActionCallback restore(Content content) { diff --git a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java index 68ae02d5a523..f010e6c71741 100644 --- a/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java +++ b/platform/lang-impl/src/com/intellij/execution/ui/layout/impl/RunnerContentUi.java @@ -19,6 +19,7 @@ package com.intellij.execution.ui.layout.impl; import com.intellij.execution.ui.RunnerLayoutUi; import com.intellij.execution.ui.layout.*; import com.intellij.execution.ui.layout.actions.CloseViewAction; +import com.intellij.execution.ui.layout.actions.MinimizeViewAction; import com.intellij.execution.ui.layout.actions.RestoreViewAction; import com.intellij.ide.DataManager; import com.intellij.openapi.Disposable; @@ -249,11 +250,16 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac public void mousePressed(MouseEvent e) { if (UIUtil.isCloseClick(e)) { final TabInfo tabInfo = myTabs.findInfo(e); - final GridImpl grid = getGridFor(tabInfo); + final GridImpl grid = tabInfo == null? null : getGridFor(tabInfo); final Content[] contents = grid != null ? CONTENT_KEY.getData(grid) : null; - if (contents != null && CloseViewAction.isEnabled(contents)) { + if (contents == null) return; + // see GridCellImpl.closeOrMinimize as well + if (CloseViewAction.isEnabled(contents)) { CloseViewAction.perform(RunnerContentUi.this, contents[0]); } + else if (MinimizeViewAction.isEnabled(RunnerContentUi.this, contents, ViewContext.TAB_TOOLBAR_PLACE)) { + grid.getCellFor(contents[0]).minimize(contents[0]); + } } } }); From 71fa3b8250c216f40a55aaad6ee40b74365fd2bf Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Oct 2012 14:27:48 +0200 Subject: [PATCH 18/19] rounding seconds for build duration --- jps/jps-builders/src/org/jetbrains/jps/incremental/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/Utils.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/Utils.java index 8706efd46000..d8d5bc982a1d 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/Utils.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/Utils.java @@ -138,7 +138,7 @@ public class Utils { public static String formatDuration(long duration) { final long minutes = duration / 60000; - final long seconds = (duration % 60000) / 1000; + final long seconds = ((duration + 500L) % 60000) / 1000; if (minutes > 0L) { return minutes + " min " + seconds + " sec"; } From 2138432b895bbba052285425029e4772c7ce5859 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 12 Oct 2012 17:34:45 +0200 Subject: [PATCH 19/19] do not let ProcessCanceledException stop DumbService's thread unexpectedly --- .../openapi/project/CacheUpdateRunner.java | 49 ++++++++--------- .../openapi/project/DumbServiceImpl.java | 35 +++++++----- .../openapi/project/FileContentQueue.java | 54 +++++++++++-------- 3 files changed, 78 insertions(+), 60 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java index 46e586cfc845..97fbbf98162b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/CacheUpdateRunner.java @@ -212,44 +212,45 @@ class CacheUpdateRunner { public void run() { while (true) { - if (myProject.isDisposed()) return; - if (myInnerIndicator.isCanceled()) return; - - final FileContent fileContent = myQueue.take(); - if (fileContent == null) { - myFinished.set(Boolean.TRUE); + if (myProject.isDisposed() || myInnerIndicator.isCanceled()) { return; } - try { - myQueue.waitForOtherContentReleaseToPreventOOM(myInnerIndicator, fileContent); + final FileContent fileContent = myQueue.take(myInnerIndicator); + if (fileContent == null) { + myFinished.set(Boolean.TRUE); + return; + } + final Runnable action = new Runnable() { public void run() { myInnerIndicator.checkCanceled(); - - if (myProject.isDisposed()) return; - - final VirtualFile file = fileContent.getVirtualFile(); - myProgressUpdater.consume(file); - mySession.processFile(fileContent); + if (!myProject.isDisposed()) { + final VirtualFile file = fileContent.getVirtualFile(); + myProgressUpdater.consume(file); + mySession.processFile(fileContent); + } } }; - if (myProcessInReadAction) { - myApplication.runReadAction(action); + try { + if (myProcessInReadAction) { + myApplication.runReadAction(action); + } + else { + action.run(); + } } - else { - action.run(); + catch (ProcessCanceledException e) { + myQueue.pushback(fileContent); + return; + } + finally { + myQueue.release(fileContent); } } catch (ProcessCanceledException e) { - myQueue.pushback(fileContent); return; } - finally { - if (fileContent != null) { - myQueue.release(fileContent); - } - } } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index eabc98414002..149b09a1d1be 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -292,7 +292,7 @@ public class DumbServiceImpl extends DumbService { private volatile int myTotalItems; private double myCurrentBaseTotal; - public IndexUpdateRunnable(CacheUpdateRunner action) { + public IndexUpdateRunnable(@NotNull CacheUpdateRunner action) { myAction = action; myTotalItems = 0; myCurrentBaseTotal = 0; @@ -359,21 +359,28 @@ public class DumbServiceImpl extends DumbService { private void runAction(ProgressIndicator indicator, CacheUpdateRunner updateRunner) { while (updateRunner != null) { - indicator.setIndeterminate(true); - indicator.setText(IdeBundle.message("progress.indexing.scanning")); - int count = updateRunner.queryNeededFiles(indicator); + try { + indicator.checkCanceled(); + indicator.setIndeterminate(true); + indicator.setText(IdeBundle.message("progress.indexing.scanning")); + int count = updateRunner.queryNeededFiles(indicator); - myCurrentBaseTotal = count; - myTotalItems += count; + myCurrentBaseTotal = count; + myTotalItems += count; - indicator.setIndeterminate(false); - indicator.setText(IdeBundle.message("progress.indexing.updating")); - if (count > 0) { - updateRunner.processFiles(indicator, true); + indicator.setIndeterminate(false); + indicator.setText(IdeBundle.message("progress.indexing.updating")); + if (count > 0) { + updateRunner.processFiles(indicator, true); + } + updateRunner.updatingDone(); + myProcessedItems += count; + } + catch (ProcessCanceledException ignored) { + } + catch (Throwable unexpected) { + LOG.error(unexpected); } - updateRunner.updatingDone(); - myProcessedItems += count; - updateRunner = getNextUpdateRunner(); } } @@ -398,7 +405,7 @@ public class DumbServiceImpl extends DumbService { // try to obtain the next action or terminate if no actions left while (!myProject.isDisposed()) { try { - Ref ref = actionQueue.poll(500, TimeUnit.MILLISECONDS); + Ref ref = actionQueue.poll(500L, TimeUnit.MILLISECONDS); if (ref != null) { return ref.get(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java b/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java index 7033f496f972..bc626fb6f19f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/FileContentQueue.java @@ -139,36 +139,46 @@ public class FileContentQueue { } } - void waitForOtherContentReleaseToPreventOOM(ProgressIndicator indicator, FileContent content) { - final long length = content.getLength(); - while (true) { - indicator.checkCanceled(); - synchronized (this) { - boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD; - if (requestingLargeSize) { - myLargeSizeRequested = true; - } + @Nullable + public FileContent take(@NotNull ProgressIndicator indicator) throws ProcessCanceledException{ + final FileContent content = doTake(); + if (content != null) { + final long length = content.getLength(); + while (true) { try { - if (myLargeSizeRequested && !requestingLargeSize || - myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length)) - wait(300L); - else { - myTakenSize += length; - if (requestingLargeSize) { - myLargeSizeRequested = false; - } - return; - } + indicator.checkCanceled(); } - catch (InterruptedException ignore) { - + catch (ProcessCanceledException e) { + pushback(content); + throw e; + } + synchronized (this) { + final boolean requestingLargeSize = length > LARGE_SIZE_REQUEST_THRESHOLD; + if (requestingLargeSize) { + myLargeSizeRequested = true; + } + try { + if (myLargeSizeRequested && !requestingLargeSize || myTakenSize + length > Math.max(TAKEN_FILES_THRESHOLD, length)) { + wait(300L); + } + else { + myTakenSize += length; + if (requestingLargeSize) { + myLargeSizeRequested = false; + } + return content; + } + } + catch (InterruptedException ignore) { + } } } } + return content; } @Nullable - FileContent take() { + private FileContent doTake() { FileContent result; synchronized (this) { result = myPushbackBuffer.poll();