From b4065a7b4daa08ac5c678a1a067685c417f3c63c Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 7 Jan 2015 13:55:35 +0100 Subject: [PATCH 1/7] project: tolerate path spaces when indexing searchable options --- build/scripts/utils.gant | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 2a57fb8ff01b..29a081c309a7 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - import org.jetbrains.jps.gant.JpsGantTool import org.jetbrains.jps.gant.TeamCityBuildInfoPrinter import org.jetbrains.jps.model.java.JavaSourceRootType @@ -929,13 +928,18 @@ binding.setVariable("buildSearchableOptions", { String target, List licenses, Cl ant.replace(file: classpathFile, token: File.pathSeparator, value: "\n") ant.java(classname: "com.intellij.rt.execution.CommandLineWrapper", fork: true, failonerror: true) { - jvmarg(line: "-Xbootclasspath/a:${projectBuilder.moduleOutput(findModule("boot"))} -ea -Xmx500m -XX:MaxPermSize=200m") - jvmarg(line: "-Didea.home.path=$home -Didea.system.path=${paths.ideaSystem} -Didea.config.path=${paths.ideaConfig}") + jvmarg(line: "-ea -Xmx500m -XX:MaxPermSize=200m") + jvmarg(value: "-Xbootclasspath/a:${projectBuilder.moduleOutput(findModule("boot"))}") + jvmarg(value: "-Didea.home.path=${home}") + jvmarg(value: "-Didea.system.path=${paths.ideaSystem}") + jvmarg(value: "-Didea.config.path=${paths.ideaConfig}") if (jvmArgs != null) { jvmarg(line: jvmArgs) } - arg(line: "${classpathFile} com.intellij.idea.Main traverseUI ${target}/searchableOptions.xml") + arg(value: "${classpathFile}") + arg(line: "com.intellij.idea.Main traverseUI") + arg(value: "${target}/searchableOptions.xml") classpath() { pathelement(location: "${projectBuilder.moduleOutput(findModule("java-runtime"))}") From 775fdd26163241b5fd19eb1b29b55d05ef48ed68 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 7 Jan 2015 14:15:14 +0100 Subject: [PATCH 2/7] project: index searchable options in CE builds --- build/scripts/dist.gant | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 3a7d54ca6c43..3d6b4f5e7502 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,8 @@ class Paths { final artifacts final artifacts_core final artifacts_jps + final ideaSystem + final ideaConfig def Paths(String out) { sandbox = out @@ -39,6 +41,8 @@ class Paths { artifacts = "$sandbox/artifacts" artifacts_core = "$artifacts/core" artifacts_jps = "$artifacts/jps" + ideaSystem = "$sandbox/system" + ideaConfig = "$sandbox/config" } } @@ -75,6 +79,8 @@ target('default': 'The default target') { zipSources(home, paths.artifacts) + indexSearchableOptions() + layoutAll([buildNumber: "IC-$snapshot", system_selector: "IdeaIC${p("component.version.major")}", tools_jar: true], @@ -83,15 +89,28 @@ target('default': 'The default target') { target('build-dist-jars' : 'Target to build jars from locally compiled classes') { loadProject() + // load ApplicationInfo.xml properties ant.xmlproperty(file: appInfoFile(), collapseAttributes: "true") + indexSearchableOptions() + layoutAll([buildNumber: "IC-$snapshot", system_selector: "IdeaIC${p("component.version.major")}", tools_jar: true], home, null, paths) } +private void indexSearchableOptions() { + buildSearchableOptions("${projectBuilder.moduleOutput(findModule("resources-en"))}/search", [], { + ant.pathelement(location: "$jdkHome/lib/tools.jar") + ant.pathelement(location: "$home/lib/junit.jar") + projectBuilder.moduleRuntimeClasspath(findModule("community-main"), false).each { + ant.pathelement(location: it) + } + }) +} + def layoutAll(Map args, String home, String out, Paths _paths = null, buildJps = false) { Paths paths = _paths != null ? _paths : new Paths(out) From 30d745d07998d3304243b643a7a6b29bfa77f0e8 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 7 Jan 2015 13:13:51 +0100 Subject: [PATCH 3/7] IDEA-135005 wrong contract inferred for method which return primitive type --- .../dataFlow/ContractInspection.java | 2 +- .../ContractInferenceFromSourceTest.groovy | 18 ++++++++++++++++++ .../openapi/vfs/local/SymlinkHandlingTest.java | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java index dc86cba28de2..c037da08be16 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java @@ -115,6 +115,6 @@ public class ContractInspection extends BaseJavaBatchLocalInspectionTool { returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE; } - return true; + return false; } } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy index 2d2aeb7c92e5..9b13347bba7a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInspection/ContractInferenceFromSourceTest.groovy @@ -291,6 +291,15 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase { assert c == [] } + public void "test double constant auto-unboxing"() { + def c = inferContracts(""" + static double method() { + return 1; + } + """) + assert c == [] + } + public void "test non-returning delegation"() { def c = inferContracts(""" static void test2(Object o) { @@ -433,6 +442,15 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase { assert c == ['null -> !null'] } + public void "test primitive return type"() { + def c = inferContracts(""" + String s(String s) { + return s != "a" ? "b" : null; + } + """) + assert c == ['null -> !null'] + } + public void "test return after if without else"() { def c = inferContracts(""" public static boolean isBlank(String s) { diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java index 3710fb4bed88..d85cf16e4837 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/vfs/local/SymlinkHandlingTest.java @@ -116,6 +116,17 @@ public class SymlinkHandlingTest extends SymlinkTestCase { link2.getPath() + "/" + link1Home.getName() + "/" + link1.getName()); } + public void testSameTargetShouldBeVisitedSeveralTimesFromSeveralNonRecursiveLinks() throws Exception { + File target = createTestDir(myTempDir, "target"); + File child = createTestDir(myTempDir, "child"); + File link1 = createSymLink(target.getPath(), myTempDir.getPath() + "/link1"); + File link2 = createSymLink(target.getPath(), myTempDir.getPath() + "/link2"); + assertVisitedPaths(myTempDir, + target.getPath(), child.getPath(), + link1.getPath(), link1.getPath() + "/child", + link2.getPath(), link2.getPath() + "/child"); + } + public void testTargetIsWritable() throws Exception { File targetFile = createTestFile(myTempDir, "target.txt"); File linkFile = createSymLink(targetFile.getPath(), myTempDir + "/link"); From 4832a1d4c94eab3ed23639e86e309a7673e26c38 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 7 Jan 2015 13:14:27 +0100 Subject: [PATCH 4/7] move isReturnTypeCompatible to InferenceFromSourceUtil --- .../dataFlow/ContractInference.java | 2 +- .../dataFlow/ContractInspection.java | 21 +------------------ .../dataFlow/InferenceFromSourceUtil.java | 20 ++++++++++++++++++ 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java index 7dcf36afb4ee..231e9d708539 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java @@ -90,7 +90,7 @@ class ContractInferenceInterpreter { if (notNull && contract.returnValue == NOT_NULL_VALUE) { return false; } - return ContractInspection.isReturnTypeCompatible(returnType, contract.returnValue); + return InferenceFromSourceUtil.isReturnTypeCompatible(returnType, contract.returnValue); } }); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java index c037da08be16..69206a74251a 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInspection.java @@ -92,29 +92,10 @@ public class ContractInspection extends BaseJavaBatchLocalInspectionTool { return "Method takes " + paramCount + " parameters, while contract clause number " + (i + 1) + " expects " + contract.arguments.length; } PsiType returnType = method.getReturnType(); - if (returnType != null && !isReturnTypeCompatible(returnType, contract.returnValue)) { + if (returnType != null && !InferenceFromSourceUtil.isReturnTypeCompatible(returnType, contract.returnValue)) { return "Method returns " + returnType.getPresentableText() + " but the contract specifies " + contract.returnValue; } } return null; } - - static boolean isReturnTypeCompatible(@Nullable PsiType returnType, @NotNull MethodContract.ValueConstraint returnValue) { - if (returnValue == MethodContract.ValueConstraint.ANY_VALUE || returnValue == MethodContract.ValueConstraint.THROW_EXCEPTION) { - return true; - } - if (PsiType.VOID.equals(returnType)) return false; - - if (PsiType.BOOLEAN.equals(returnType)) { - return returnValue == MethodContract.ValueConstraint.TRUE_VALUE || - returnValue == MethodContract.ValueConstraint.FALSE_VALUE; - } - - if (returnType instanceof PsiClassType) { - return returnValue == MethodContract.ValueConstraint.NULL_VALUE || - returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE; - } - - return false; - } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/InferenceFromSourceUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/InferenceFromSourceUtil.java index 408277627937..998abf2318d2 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/InferenceFromSourceUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/InferenceFromSourceUtil.java @@ -23,6 +23,7 @@ import com.intellij.psi.search.searches.MethodReferencesSearch; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.PsiUtilCore; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author peter @@ -52,4 +53,23 @@ public class InferenceFromSourceUtil { VirtualFile virtualFile = PsiUtilCore.getVirtualFile(method); return virtualFile != null && FileIndexFacade.getInstance(method.getProject()).isInLibrarySource(virtualFile); } + + static boolean isReturnTypeCompatible(@Nullable PsiType returnType, @NotNull MethodContract.ValueConstraint returnValue) { + if (returnValue == MethodContract.ValueConstraint.ANY_VALUE || returnValue == MethodContract.ValueConstraint.THROW_EXCEPTION) { + return true; + } + if (PsiType.VOID.equals(returnType)) return false; + + if (PsiType.BOOLEAN.equals(returnType)) { + return returnValue == MethodContract.ValueConstraint.TRUE_VALUE || + returnValue == MethodContract.ValueConstraint.FALSE_VALUE; + } + + if (returnType instanceof PsiClassType) { + return returnValue == MethodContract.ValueConstraint.NULL_VALUE || + returnValue == MethodContract.ValueConstraint.NOT_NULL_VALUE; + } + + return false; + } } From be013a9adc6c5c61442b740a51c21a8a38e9b797 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 7 Jan 2015 14:35:54 +0100 Subject: [PATCH 5/7] Execute selection in selected visible console when there are more then one (PY-14847). --- .../actions/PyExecuteSelectionAction.java | 5 ++++- .../console/PythonConsoleToolWindow.java | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java b/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java index adc8dc77fd0e..f23943f3f113 100644 --- a/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java +++ b/python/src/com/jetbrains/python/actions/PyExecuteSelectionAction.java @@ -15,6 +15,7 @@ */ package com.jetbrains.python.actions; +import com.google.common.collect.Lists; import com.intellij.execution.ExecutionHelper; import com.intellij.execution.console.LanguageConsoleView; import com.intellij.execution.process.ProcessHandler; @@ -28,6 +29,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; +import com.intellij.util.ArrayUtil; import com.intellij.util.Consumer; import com.intellij.util.NotNullFunction; import com.jetbrains.python.console.PyCodeExecutor; @@ -191,7 +193,8 @@ public class PyExecuteSelectionAction extends AnAction { PythonConsoleToolWindow toolWindow = PythonConsoleToolWindow.getInstance(project); if (toolWindow != null && toolWindow.getToolWindow().isVisible()) { - return toolWindow.getConsoleContentDescriptors(); + RunContentDescriptor selectedContentDescriptor = toolWindow.getSelectedContentDescriptor(); + return selectedContentDescriptor != null ? Lists.newArrayList(selectedContentDescriptor) : Lists.newArrayList(); } Collection descriptors = diff --git a/python/src/com/jetbrains/python/console/PythonConsoleToolWindow.java b/python/src/com/jetbrains/python/console/PythonConsoleToolWindow.java index c5cac180ed1a..1ddbe97a0fa1 100644 --- a/python/src/com/jetbrains/python/console/PythonConsoleToolWindow.java +++ b/python/src/com/jetbrains/python/console/PythonConsoleToolWindow.java @@ -45,6 +45,14 @@ import java.util.List; public class PythonConsoleToolWindow { public static final Key CONTENT_DESCRIPTOR = Key.create("CONTENT_DESCRIPTOR"); + public static final Function + CONTENT_TO_DESCRIPTOR_FUNCTION = new Function() { + @Override + public RunContentDescriptor apply(@Nullable Content input) { + return input != null ? input.getUserData(CONTENT_DESCRIPTOR) : null; + } + }; + private final Project myProject; private boolean myInitialized = false; @@ -61,12 +69,7 @@ public class PythonConsoleToolWindow { public List getConsoleContentDescriptors() { return FluentIterable.from(Lists.newArrayList(getToolWindow().getContentManager().getContents())) - .transform(new Function() { - @Override - public RunContentDescriptor apply(@Nullable Content input) { - return input != null ? input.getUserData(CONTENT_DESCRIPTOR) : null; - } - }).filter( + .transform(CONTENT_TO_DESCRIPTOR_FUNCTION).filter( Predicates.notNull()).toList(); } @@ -172,4 +175,9 @@ public class PythonConsoleToolWindow { myActivation.doWhenDone(runnable); getToolWindow().activate(null); } + + @Nullable + public RunContentDescriptor getSelectedContentDescriptor() { + return CONTENT_TO_DESCRIPTOR_FUNCTION.apply(getToolWindow().getContentManager().getSelectedContent()); + } } From ee90d442b1a959c96a7bfbe8c69658494ceb6076 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Wed, 7 Jan 2015 09:39:09 +0300 Subject: [PATCH 6/7] Emmet: fix implicit attributes expansion --- xml/impl/resources/liveTemplates/zen_html.xml | 12 +++++++-- .../template/emmet/tokens/TemplateToken.java | 26 +++---------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml index 76a1d65d4779..acb372af0c34 100644 --- a/xml/impl/resources/liveTemplates/zen_html.xml +++ b/xml/impl/resources/liveTemplates/zen_html.xml @@ -159,6 +159,14 @@