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) 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"))}") 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 dc86cba28de2..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 true; - } } 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; + } } 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/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index e485a812d2ce..c5de46f9332a 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -264,6 +264,10 @@ public class DocumentationManager extends DockablePopupManagernewArrayList(); } 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()); + } } 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 @@