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/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 019fe8a01d24..8e26316e3a52 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; @@ -26,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; @@ -37,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; @@ -90,7 +91,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 { @@ -130,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 2a5080e415aa..934420591f08 100644 --- a/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java +++ b/java/idea-ui/src/com/intellij/platform/templates/EmptyModuleTemplatesFactory.java @@ -16,8 +16,8 @@ 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.openapi.ui.ValidationInfo; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.ProjectTemplatesFactory; import com.intellij.util.Function; @@ -70,9 +70,15 @@ public class EmptyModuleTemplatesFactory implements ProjectTemplatesFactory { @NotNull @Override - public ProjectBuilder createModuleBuilder() { + public ModuleBuilder createModuleBuilder() { return builder; } + + @Nullable + @Override + public ValidationInfo validateSettings() { + return null; + } }; } }); 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; } 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-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-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 = 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; } 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/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/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/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/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"); } 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); } 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); } 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/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"; } 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..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 @@ -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,8 @@ public class GridCellImpl implements GridCell { myTabs.addTabMouseListener(new MouseAdapter() { public void mousePressed(final MouseEvent e) { if (UIUtil.isCloseClick(e)) { - minimize(e); + // see RunnerContentUi tabMouseListener as well + closeOrMinimize(e); } } }); @@ -250,7 +252,8 @@ public class GridCellImpl implements GridCell { if (myTabs.getSelectedInfo() != tab) { if (activate) { tab.fireAlert(); - } else { + } + else { tab.stopAlerting(); } } @@ -337,7 +340,8 @@ public class GridCellImpl implements GridCell { tab.setDetached(myPlaceInGrid, false); } myContext.detachTo(window, this).notifyWhenDone(result); - } else { + } + else { result.setDone(); } @@ -432,7 +436,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 +449,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 closeOrMinimize(MouseEvent e) { TabInfo tabInfo = myTabs.findInfo(e); - if (tabInfo != null) { - minimize(getContentFor(tabInfo)); + if (tabInfo == null) return; + + Content content = getContentFor(tabInfo); + if (CloseViewAction.isEnabled(new Content[]{content})) { + CloseViewAction.perform(myContext, content); + } + else if (MinimizeViewAction.isEnabled(myContext, getContents(), ViewContext.CELL_TOOLBAR_PLACE)) { + minimize(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]); + } } } }); 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 cb8b3c7a489d..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 @@ -17,9 +17,13 @@ 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.ui.ValidationInfo; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.platform.ProjectTemplate; import com.intellij.platform.WebProjectGenerator; @@ -50,10 +54,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); @@ -65,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/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/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 { 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(); diff --git a/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java b/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java index ff523b80eb36..c4dbc87f7e4c 100644 --- a/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java +++ b/platform/platform-impl/src/com/intellij/platform/ProjectTemplate.java @@ -15,7 +15,8 @@ */ package com.intellij.platform; -import com.intellij.ide.util.projectWizard.ProjectBuilder; +import com.intellij.ide.util.projectWizard.ModuleBuilder; +import com.intellij.openapi.ui.ValidationInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -37,5 +38,11 @@ public interface ProjectTemplate { JComponent getSettingsPanel(); @NotNull - ProjectBuilder createModuleBuilder(); + ModuleBuilder createModuleBuilder(); + + /** + * @return null if ok, error message otherwise + */ + @Nullable + ValidationInfo validateSettings(); } 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. 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() { 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(); + } } 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 + 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);