From 73503ec17f49bb1dea1b599147c33fb976c8d989 Mon Sep 17 00:00:00 2001 From: "Vladimir.Orlov" Date: Thu, 23 Mar 2017 15:08:11 +0300 Subject: [PATCH 01/14] Rename bundled jre: jre->jre32 (windows); jre->jre64 (linux). IDEA-169747 "No system java compiler" after new project is created --- .../jetbrains/intellij/build/impl/BundledJreManager.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy index acc12ac689f3..95aaba6f2a23 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/BundledJreManager.groovy @@ -93,9 +93,9 @@ class BundledJreManager { return null } buildContext.messages.block("Extract $archive.name JRE") { - String destination = "$targetDir/jre32" - if (osDirName == "win" && arch == JvmArchitecture.x64) { - destination = "$targetDir/jre64" + String destination = "$targetDir/jre64" + if (osDirName == "win" && arch == JvmArchitecture.x32) { + destination = "$targetDir/jre32" } buildContext.messages.progress("Extracting JRE from '$archive.name' archive") if (SystemInfo.isWindows) { From 44564a455fdfbeee031c566cf0d1be0576c67abd Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Thu, 23 Mar 2017 15:27:27 +0300 Subject: [PATCH 02/14] EA-99425 - NPE: ComboboxSpeedSearch.getElementText --- .../platform-impl/src/com/intellij/ui/ComboboxSpeedSearch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/ui/ComboboxSpeedSearch.java b/platform/platform-impl/src/com/intellij/ui/ComboboxSpeedSearch.java index 83ce37170579..114f2f0e90aa 100644 --- a/platform/platform-impl/src/com/intellij/ui/ComboboxSpeedSearch.java +++ b/platform/platform-impl/src/com/intellij/ui/ComboboxSpeedSearch.java @@ -56,6 +56,6 @@ public class ComboboxSpeedSearch extends SpeedSearchBase { } protected String getElementText(Object element) { - return element.toString(); + return element == null ? null : element.toString(); } } \ No newline at end of file From 85282819f643ea9ba5ff4397217f9b4827fe9a3e Mon Sep 17 00:00:00 2001 From: Kirill Kirichenko Date: Thu, 23 Mar 2017 15:52:43 +0300 Subject: [PATCH 03/14] IDEA-168273 Fix read only combobox --- .../ide/ui/laf/intellij/MacComboBoxBorder.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacComboBoxBorder.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacComboBoxBorder.java index dfdd54047bfa..3e34149726f3 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacComboBoxBorder.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/intellij/MacComboBoxBorder.java @@ -23,6 +23,7 @@ import com.intellij.util.ui.JBUI; import javax.swing.*; import java.awt.*; import java.awt.geom.Area; +import java.awt.geom.Path2D; import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; @@ -37,6 +38,7 @@ public class MacComboBoxBorder extends MacIntelliJTextBorder { try { g2.translate(x, y); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Area area = new Area(new Rectangle2D.Double(0, 0, width, height)); area.subtract(getButtonBounds(c)); @@ -46,11 +48,16 @@ public class MacComboBoxBorder extends MacIntelliJTextBorder { if (c instanceof JComboBox) { JComboBox comboBox = (JComboBox)c; - Color color = UIManager.getColor(comboBox.isEnabled() ? "ComboBox.background" : "ComboBox.disabledBackground"); - RectanglePainter.paint(g2, JBUI.scale(3), JBUI.scale(3), - c.getWidth() - JBUI.scale(6), - c.getHeight() - JBUI.scale(6), - arc, color, null); + g2.setColor(UIManager.getColor(comboBox.isEnabled() ? "ComboBox.background" : "ComboBox.disabledBackground")); + Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD); + path.moveTo(JBUI.scale(8), JBUI.scale(3)); + path.lineTo(JBUI.scale(8), c.getHeight() - JBUI.scale(3)); + path.lineTo(JBUI.scale(3) + arc, c.getHeight() - JBUI.scale(3)); + path.quadTo(JBUI.scale(3), c.getHeight() - JBUI.scale(3), JBUI.scale(3), c.getHeight() - JBUI.scale(3) - arc); + path.lineTo(JBUI.scale(3), JBUI.scale(3) + arc); + path.quadTo(JBUI.scale(3), JBUI.scale(3), JBUI.scale(3) + arc, JBUI.scale(3)); + path.lineTo(JBUI.scale(8), JBUI.scale(3)); + g2.fill(path); } RectanglePainter.paint(g2, JBUI.scale(3), JBUI.scale(3), From ffd34c0097bc3ec7b672db40c75ba42f19ebd965 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 23 Mar 2017 14:23:19 +0100 Subject: [PATCH 04/14] warm up before measuring performance in ResolveClassTest --- .../com/intellij/psi/resolve/ResolveClassTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java index 36637e540dbd..328d07955d36 100644 --- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveClassTest.java @@ -208,8 +208,9 @@ public class ResolveClassTest extends ResolveTestCase { assertInstanceOf(ref.resolve(), PsiClass.class); } - public void testStaticImportInTheSameClassPerformance() throws Exception { + warmUpResolve(); + PsiReference ref = configure(); ensureIndexUpToDate(); long start = System.currentTimeMillis(); @@ -222,7 +223,16 @@ public class ResolveClassTest extends ResolveTestCase { getJavaFacade().findClass(CommonClassNames.JAVA_UTIL_LIST, GlobalSearchScope.allScope(myProject)); } + private void warmUpResolve() { + PsiJavaCodeReferenceElement ref = JavaPsiFacade.getElementFactory(myProject).createReferenceFromText("java.util.List", null); + JavaResolveResult result = ref.advancedResolve(false); + assertNotNull(result.getElement()); + assertSize(1, result.getSubstitutor().getSubstitutionMap().keySet()); + } + public void testStaticImportNetworkPerformance() throws Exception { + warmUpResolve(); + PsiReference ref = configure(); int count = 15; From 84f03842f571c154e541c3554679a4352645627d Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Thu, 23 Mar 2017 15:45:48 +0300 Subject: [PATCH 05/14] Replace builtin `_PathLike` class with `os.PathLike` in PyTypingTypeProvider. Fix processing builtin `open` function in Py3TypeCheckerInspectionTest.testPathLikePassedToStdlibFunctions. --- .../typing/PyTypingTypeProvider.java | 17 +++++++++++++++++ .../PathLikePassedToStdlibFunctions/a.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java index 6ab2f86239f7..30694b3fd996 100644 --- a/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/typing/PyTypingTypeProvider.java @@ -118,6 +118,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { return null; } + @Override @Nullable public Ref getParameterType(@NotNull PyNamedParameter param, @NotNull PyFunction func, @NotNull TypeEvalContext context) { final Ref typeFromAnnotation = getParameterTypeFromAnnotation(param, context); @@ -784,6 +785,16 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { continue; } } + if (isBuiltinPathLike(element)) { + // see https://github.com/python/typeshed/commit/41561f11c7b06368aebe512acf69d8010662266d + // or comment in typeshed/stdlib/3/builtins.pyi near _PathLike class + final QualifiedName osPathLikeQName = QualifiedName.fromComponents("os", PyNames.PATH_LIKE); + final PsiElement osPathLike = PyResolveImportUtil.resolveTopLevelMember(osPathLikeQName, PyResolveImportUtil.fromFoothold(element)); + if (osPathLike != null) { + elements.add(osPathLike); + continue; + } + } if (element != null) { elements.add(element); } @@ -792,6 +803,12 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { return !elements.isEmpty() ? elements : Collections.singletonList(expression); } + private static boolean isBuiltinPathLike(@Nullable PsiElement element) { + return element instanceof PyClass && + PyBuiltinCache.getInstance(element).isBuiltin(element) && + ("_" + PyNames.PATH_LIKE).equals(((PyClass)element).getName()); + } + @NotNull private static Collection resolveToQualifiedNames(@NotNull PyExpression expression, @NotNull TypeEvalContext context) { final Set names = Sets.newLinkedHashSet(); diff --git a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py index 6241db2c7177..a04c3663f347 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py @@ -28,7 +28,7 @@ class B: b = B() -open(b) +open(b) os.fspath(b) os.fsencode(b) From 8b9f471f54de402a17feca6522f467096d058087 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Thu, 23 Mar 2017 16:42:50 +0300 Subject: [PATCH 06/14] Add definitions of `os.fspath`, `os.fsencode` and `os.fsdecode`. Add TODO about updating test data after enabling pyi-stubs for `os` module. --- .../PathLikePassedToStdlibFunctions/a.py | 6 +++--- .../PathLikePassedToStdlibFunctions/os.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py index a04c3663f347..5bed0c993e67 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py +++ b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/a.py @@ -30,9 +30,9 @@ b = B() open(b) -os.fspath(b) -os.fsencode(b) -os.fsdecode(b) +os.fspath(b) # TODO fail after enabling pyi-stubs for `os` module +os.fsencode(b) # TODO fail after enabling pyi-stubs for `os` module +os.fsdecode(b) # TODO fail after enabling pyi-stubs for `os` module Path(b) PurePath(b) diff --git a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/os.py b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/os.py index c777cdf8ff54..4ca9470b3dc8 100644 --- a/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/os.py +++ b/python/testData/inspections/PyTypeCheckerInspection/PathLikePassedToStdlibFunctions/os.py @@ -2,6 +2,20 @@ import abc import posixpath as path +def _fscodec(): + pass + + +fsencode, fsdecode = _fscodec() + + +def _fspath(path): + pass + + +fspath = _fspath + + class PathLike(abc.ABC): """Abstract base class for implementing the file system path protocol.""" From b6298108e1c6a3a84de04ddbf059bfbceee50378 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 23 Mar 2017 16:55:54 +0300 Subject: [PATCH 07/14] build scripts: use proper path to project output directory --- .../intellij/build/impl/CompilationContextImpl.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy index 30f07f09f4af..5807c9c52383 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/CompilationContextImpl.groovy @@ -130,7 +130,7 @@ class CompilationContextImpl implements CompilationContext { projectBuilder.targetFolder = classesOutput } else { - def outputDir = JpsPathUtil.urlToFile(JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(project).outputUrl) + def outputDir = getProjectOutputDirectory() if (!outputDir.exists()) { messages.error("$BuildOptions.USE_COMPILED_CLASSES_PROPERTY is enabled, but the project output directory $outputDir.absolutePath doesn't exist") } @@ -141,6 +141,10 @@ class CompilationContextImpl implements CompilationContext { cleanOutput(outputDirectoriesToKeep) } + File getProjectOutputDirectory() { + JpsPathUtil.urlToFile(JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(project).outputUrl) + } + void cleanOutput(List outputDirectoriesToKeep) { messages.block("Clean output") { def outputPath = paths.buildOutputRoot From f1cfb7d082b4e163929cef883227c4d7d0703682 Mon Sep 17 00:00:00 2001 From: "sergey.vasiliev" Date: Thu, 23 Mar 2017 15:04:16 +0100 Subject: [PATCH 08/14] IDEA-115428 Support "Class" type in spring XML --- .../GenericDomValueConvertersRegistry.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java b/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java index dcd1ce6ee807..8f74ebfa990d 100644 --- a/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java +++ b/java/openapi/src/com/intellij/util/xml/converters/values/GenericDomValueConvertersRegistry.java @@ -20,7 +20,9 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.Pair; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; +import com.intellij.psi.util.PsiTypesUtil; +import com.intellij.psi.util.PsiUtil; import com.intellij.util.xml.Converter; import com.intellij.util.xml.GenericDomValue; import org.jetbrains.annotations.NotNull; @@ -67,7 +69,16 @@ public class GenericDomValueConvertersRegistry { } public void registerClassValueConverters() { - registerConverter(ClassValueConverter.getClassValueConverter(), Class.class); + registerConverter(ClassValueConverter.getClassValueConverter(), pair -> { + PsiType psiType = pair.getFirst(); + if (psiType instanceof PsiClassType) { + PsiClass resolve = ((PsiClassType)psiType).resolve(); + if (resolve != null) { + return (CommonClassNames.JAVA_LANG_CLASS.equals(resolve.getQualifiedName())); + } + } + return false; + }); registerConverter(ClassArrayConverter.getClassArrayConverter(), Class[].class); } @@ -122,5 +133,4 @@ public class GenericDomValueConvertersRegistry { final String name = type.getCanonicalName(); registerConverter(provider, pair -> pair.first != null && Comparing.equal(name, pair.first.getCanonicalText())); } - } From 95bc58d947d8febdc3fb1c7ade92eb2ff3362664 Mon Sep 17 00:00:00 2001 From: "Liana.Bakradze" Date: Thu, 23 Mar 2017 17:12:51 +0300 Subject: [PATCH 09/14] fix subtask to task conversion --- .../coursecreator/CCSubtaskEditorNotificationProvider.java | 1 + .../src/com/jetbrains/edu/coursecreator/CCUtils.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCSubtaskEditorNotificationProvider.java b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCSubtaskEditorNotificationProvider.java index c8389785d577..8c6c2a49b0fa 100644 --- a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCSubtaskEditorNotificationProvider.java +++ b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCSubtaskEditorNotificationProvider.java @@ -233,6 +233,7 @@ public class CCSubtaskEditorNotificationProvider extends EditorNotifications.Pro taskFile.setTask(task); } list.set(i, task); + renameFiles(task.getTaskDir(myProject), myProject, -2); } private void updateInfoIndexes() { diff --git a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCUtils.java b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCUtils.java index 442967d374d2..71d5abe4e4b1 100644 --- a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCUtils.java +++ b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCUtils.java @@ -269,6 +269,9 @@ public class CCUtils { presentation.setEnabledAndVisible(project != null && isCourseCreator(project)); } + /** + * @param fromIndex -1 if task converted to TaskWithSubtasks, -2 if task converted from TaskWithSubtasks + */ public static void renameFiles(VirtualFile taskDir, Project project, int fromIndex) { ApplicationManager.getApplication().runWriteAction(() -> { Map newNames = new HashMap<>(); @@ -283,7 +286,7 @@ public class CCUtils { index = "0"; } else { // remove subtask - index = subtaskIndex == 1 ? "" : Integer.toString(subtaskIndex - 1); + index = fromIndex == -2 ? "" : Integer.toString(subtaskIndex - 1); } String fileName = virtualFile.getName(); String nameWithoutExtension = FileUtil.getNameWithoutExtension(fileName); From 74010049040a46c0d8df12d81c0a409b2145e02e Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 23 Mar 2017 17:16:12 +0300 Subject: [PATCH 10/14] PY-22556, PY-23233, PY-23217: Packages with out of init.py not discoverable even by py3 unittest --- .../python/testing/universalTests/PyUniversalNoseTest.kt | 2 +- .../python/testing/universalTests/PyUniversalTests.kt | 4 ++-- .../python/testing/universalTests/PyUniversalUnitTest.kt | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt index b64ea37755dc..c635fd23aaee 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalNoseTest.kt @@ -61,7 +61,7 @@ class PyUniversalNoseTestConfiguration(project: Project, factory: PyUniversalNos override fun isFrameworkInstalled() = VFSTestFrameworkListener.getInstance().isNoseTestInstalled(sdk) //https://github.com/nose-devs/nose/issues/1042 - override fun treatFoldersAsPackages(anchor: PsiElement) = true + override fun packageOnlyIfInitPy(anchor: PsiElement) = true } object PyUniversalNoseTestFactory : PyUniversalTestFactory() { diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt index 7f5549cc8dfe..76aa3c6cc688 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalTests.kt @@ -529,7 +529,7 @@ abstract class PyUniversalTestConfiguration(project: Project, /** * When checking if configuration is ok we need to know if folders could be packages: i.e. if foo.bar requires init.py in foo to work */ - open fun treatFoldersAsPackages(anchor: PsiElement) = (!LanguageLevel.forElement(anchor).isPy3K) + open fun packageOnlyIfInitPy(anchor: PsiElement) = (!LanguageLevel.forElement(anchor).isPy3K) } private fun isTestFile(file: PyFile): Boolean { @@ -595,7 +595,7 @@ object PyUniversalTestsConfigurationProducer : AbstractPythonTestConfigurationPr private fun getTargetForConfig(configuration: PyUniversalTestConfiguration, baseElement: PsiElement, fixConfiguration: Boolean = false): ConfigurationTarget? { - val setRelative = (fixConfiguration && configuration.treatFoldersAsPackages(baseElement)) + val setRelative = (fixConfiguration && configuration.packageOnlyIfInitPy(baseElement)) var element = baseElement // Go up until we reach top of the file diff --git a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt index 66e7866b0dc6..5b5573ed2282 100644 --- a/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt +++ b/python/src/com/jetbrains/python/testing/universalTests/PyUniversalUnitTest.kt @@ -24,6 +24,7 @@ import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.openapi.options.SettingsEditor import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.psi.PsiElement import com.jetbrains.python.PythonHelper import com.jetbrains.python.testing.PythonTestConfigurationsModel @@ -74,6 +75,9 @@ class PyUniversalUnitTestConfiguration(project: Project, factory: PyUniversalUni } override fun isFrameworkInstalled() = true //Unittest is always available + + // See loader.py: is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py')) + override fun packageOnlyIfInitPy(anchor: PsiElement) = true } object PyUniversalUnitTestFactory : PyUniversalTestFactory() { From a4822b754bbb9670b238afeeb4d4384d4561a28a Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 23 Mar 2017 15:28:16 +0100 Subject: [PATCH 11/14] increase daemon reactivity when highlighting large java files --- .../impl/DaemonRespondToChangesTest.java | 21 ++++++++++++++++++- .../daemon/impl/DaemonCodeAnalyzerEx.java | 3 ++- .../intellij/psi/stubs/LightStubBuilder.java | 3 +++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java index a801fc4fa87d..06b13fee91d8 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java @@ -1688,6 +1688,8 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { long e = System.currentTimeMillis(); //System.out.println("Hi elapsed: "+(e-s)); + //List dumps = new ArrayList<>(); + final DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject()); int N = Math.max(5, Timings.adjustAccordingToMySpeed(80, false)); System.out.println("N = " + N); @@ -1702,12 +1704,21 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { // wait to engage all highlighting threads return; } + // uncomment to debug what's causing pauses + /* + AtomicBoolean finished = new AtomicBoolean(); + AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> { + if (!finished.get()) { + dumps.add(ThreadDumper.dumpThreadsToString()); + } + }, 10, TimeUnit.MILLISECONDS); + */ type(' '); long end = System.currentTimeMillis(); + //finished.set(true); long interruptTime = end - now; interruptTimes[finalI] = interruptTime; assertTrue(codeAnalyzer.getUpdateProgress().isCanceled()); - System.out.println(interruptTime); throw new ProcessCanceledException(); }; try { @@ -1727,6 +1738,14 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase { //highlightErrors(); } + System.out.println("Interrupt times: " + Arrays.toString(interruptTimes)); + + /* + for (String dump : dumps) { + System.out.println("\n\n-----------------------------\n\n" + dump); + } + */ + long mean = ArrayUtil.averageAmongMedians(interruptTimes, 3); long avg = Arrays.stream(interruptTimes).sum() / interruptTimes.length; long max = Arrays.stream(interruptTimes).max().getAsLong(); diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java index b6be9a362e59..e05206d5bfa2 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java @@ -21,9 +21,9 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.ex.MarkupModelEx; -import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; import com.intellij.util.CommonProcessors; @@ -51,6 +51,7 @@ public abstract class DaemonCodeAnalyzerEx extends DaemonCodeAnalyzer { final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, marker -> { + ProgressManager.checkCanceled(); Object tt = marker.getErrorStripeTooltip(); if (!(tt instanceof HighlightInfo)) return true; HighlightInfo info = (HighlightInfo)tt; diff --git a/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java b/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java index 4be600a43222..b7583f2755b2 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java @@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.LogUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.LanguageFileType; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.psi.PsiFile; import com.intellij.psi.StubBuilder; import com.intellij.psi.impl.source.PsiFileImpl; @@ -92,6 +93,8 @@ public class LightStubBuilder implements StubBuilder { nextElement: while (element != null) { + ProgressManager.checkCanceled(); + final StubElement stub = createStub(tree, element, parentStub); boolean hasStub = stub != parentStub || parent == null; if (hasStub && !immediateParentStubbed) { From 21d1f1dc04389fa449032334728475d92c214e2f Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 23 Mar 2017 15:28:36 +0100 Subject: [PATCH 12/14] calculate performance test timings before all other heavy activities --- .../com/intellij/testFramework/LightPlatformTestCase.java | 8 +++++--- .../src/com/intellij/testFramework/UsefulTestCase.java | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index ce114a3213e5..60baf0f863fe 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -44,7 +44,6 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.impl.EditorFactoryImpl; -import com.intellij.openapi.editor.impl.EditorImpl; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl; import com.intellij.openapi.fileTypes.FileType; @@ -87,13 +86,13 @@ import com.intellij.psi.impl.PsiDocumentManagerImpl; import com.intellij.psi.impl.PsiManagerImpl; import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl; import com.intellij.psi.templateLanguages.TemplateDataLanguageMappings; -import com.intellij.util.ref.GCUtil; import com.intellij.util.IncorrectOperationException; import com.intellij.util.LocalTimeCounter; import com.intellij.util.ReflectionUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.UnindexedFilesUpdater; import com.intellij.util.messages.MessageBusConnection; +import com.intellij.util.ref.GCUtil; import com.intellij.util.ui.UIUtil; import junit.framework.AssertionFailedError; import junit.framework.TestCase; @@ -266,8 +265,11 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da protected void setUp() throws Exception { EdtTestUtil.runInEdtAndWait(() -> { super.setUp(); - initApplication(); ApplicationInfoImpl.setInStressTest(isStressTest()); + if (isPerformanceTest()) { + Timings.getStatistics(); + } + initApplication(); ourApplication.setDataProvider(this); LightProjectDescriptor descriptor = getProjectDescriptor(); diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 79e591e72ddc..174d0c123fe5 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -130,6 +130,9 @@ public abstract class UsefulTestCase extends TestCase { } boolean isStressTest = isStressTest(); ApplicationInfoImpl.setInStressTest(isStressTest); + if (isPerformanceTest()) { + Timings.getStatistics(); + } // turn off Disposer debugging for performance tests Disposer.setDebugMode(!isStressTest); } From 487a835653ca466cf4ca5b8f0455ed4692e7446a Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 23 Mar 2017 17:16:21 +0300 Subject: [PATCH 13/14] build scripts: removed unused property --- build/scripts/common_tests.gant | 1 - 1 file changed, 1 deletion(-) diff --git a/build/scripts/common_tests.gant b/build/scripts/common_tests.gant index a6778a2b3113..42a5e6b76ac7 100644 --- a/build/scripts/common_tests.gant +++ b/build/scripts/common_tests.gant @@ -71,7 +71,6 @@ target('run_tests': 'Run java tests') { [ "idea.test.group", "idea.test.patterns", - "idea.fast.only", "idea.coverage.enabled.build", "teamcity.tests.recentlyFailedTests.file" ].each { pass(jvmArgs, it) } From 0f1683c0976cc11855ccd18679b24d32e3da3433 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 23 Mar 2017 17:20:51 +0300 Subject: [PATCH 14/14] build scripts cleanup: unused code removed We don't run tests under Apple's JDK anymore. --- build/scripts/tests.gant | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build/scripts/tests.gant b/build/scripts/tests.gant index 7bba14ef69e0..4a943ded52f7 100644 --- a/build/scripts/tests.gant +++ b/build/scripts/tests.gant @@ -32,13 +32,6 @@ else { ] } -if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { - String vendor = System.getProperty("java.vm.vendor") - if (vendor != null && vendor.toLowerCase().contains("apple")) { - args << "-d32" - } -}; - args << "-Djna.nosys=true" setProperty("jvm_args", args)