From 3e8b8f31110059b653559d680c73c6d3ffa490a5 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 23 Dec 2014 20:17:08 +0100 Subject: [PATCH 01/15] tests: platform prefix for light CodeInsight tests --- .../testFramework/LightPlatformCodeInsightTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java index 40d8994e1cb1..b6dc8b458d06 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformCodeInsightTestCase.java @@ -68,7 +68,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTestCase { +public abstract class LightPlatformCodeInsightTestCase extends LightPlatformLangTestCase { private static final Logger LOG = Logger.getInstance("#com.intellij.testFramework.LightCodeInsightTestCase"); protected static Editor myEditor; From 7235bf39fe8099606475dd96ef895d55fedfd069 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Tue, 23 Dec 2014 22:42:35 +0300 Subject: [PATCH 02/15] IDEA-109052 Provide a way to delete a project from recent projects list using the mouse --- .../welcomeScreen/NewRecentProjectPanel.java | 62 +++++++++++++++--- .../welcomeScreen/RecentProjectPanel.java | 64 ++++++++++++++++--- .../util/resources/misc/registry.properties | 5 +- 3 files changed, 114 insertions(+), 17 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java index 827c9ba5d1ab..68482d0d432a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/NewRecentProjectPanel.java @@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl.welcomeScreen; import com.intellij.ide.ReopenProjectAction; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.util.io.UniqueNameBuilder; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.WelcomeScreen; import com.intellij.ui.components.JBList; import com.intellij.ui.speedSearch.ListWithFilter; @@ -25,7 +26,6 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; @@ -82,9 +82,38 @@ public class NewRecentProjectPanel extends RecentProjectPanel { @Override protected ListCellRenderer createRenderer(UniqueNameBuilder pathShortener) { return new RecentProjectItemRenderer(myPathShortener) { - { - setBorder(new EmptyBorder(0, 10, 0, 0)); + private GridBagConstraints nameCell; + private GridBagConstraints pathCell; + private GridBagConstraints closeButtonCell; + + private void initConstraints () { + nameCell = new GridBagConstraints(); + pathCell = new GridBagConstraints(); + closeButtonCell = new GridBagConstraints(); + + nameCell.gridx = 0; + nameCell.gridy = 0; + nameCell.weightx = 1.0; + nameCell.weighty = 1.0; + nameCell.anchor = GridBagConstraints.FIRST_LINE_START; + nameCell.insets = new Insets(6, 5, 1, 5); + + + + pathCell.gridx = 0; + pathCell.gridy = 1; + + pathCell.insets = new Insets(1, 5, 6, 5); + pathCell.anchor = GridBagConstraints.LAST_LINE_START; + + + closeButtonCell.gridx = 1; + closeButtonCell.gridy = 0; + closeButtonCell.gridheight = 2; + + closeButtonCell.anchor = GridBagConstraints.WEST; } + @Override protected Color getListBackground(boolean isSelected, boolean hasFocus) { return isSelected ? FlatWelcomeFrame.getListSelectionColor(hasFocus) : FlatWelcomeFrame.getProjectsBackground(); @@ -97,12 +126,29 @@ public class NewRecentProjectPanel extends RecentProjectPanel { @Override protected void layoutComponents() { - setLayout(new BorderLayout()); - myName.setBorder(new EmptyBorder(6, 0, 1, 5)); - myPath.setBorder(new EmptyBorder(1, 0, 6, 5)); - add(myName, BorderLayout.NORTH); - add(myPath, BorderLayout.SOUTH); + setLayout(new GridBagLayout()); + initConstraints(); + add(myName, nameCell); + add(myPath, pathCell); } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (Registry.is("removable.welcome.screen.projects")) { + if (myHovered) { + add(myCloseThisItem, closeButtonCell); + } + else { + remove(myCloseThisItem); + } + } + + return this; + } + }; } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java index df299567505b..f9a855ae5116 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/RecentProjectPanel.java @@ -19,6 +19,7 @@ */ package com.intellij.openapi.wm.impl.welcomeScreen; +import com.intellij.icons.AllIcons; import com.intellij.ide.RecentProjectsManager; import com.intellij.ide.RecentProjectsManagerBase; import com.intellij.ide.ReopenProjectAction; @@ -31,6 +32,7 @@ import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.UniqueNameBuilder; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.WelcomeScreen; import com.intellij.ui.ClickListener; @@ -45,6 +47,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.*; @@ -53,6 +56,20 @@ import java.io.File; public class RecentProjectPanel extends JPanel { protected final JBList myList; protected final UniqueNameBuilder myPathShortener; + protected AnAction removeRecentProjectAction; + private int myHoverIndex = -1; + + private final JPanel myCloseButtonForEditor = new JPanel() { + { + setPreferredSize(new Dimension(AllIcons.General.BalloonClose.getIconWidth(), AllIcons.General.BalloonClose.getIconHeight())); + setOpaque(true); + } + + @Override + protected void paintComponent(Graphics g) { + AllIcons.General.BalloonClose.paintIcon(this, g, 0, 0); + } + }; public RecentProjectPanel(WelcomeScreen screen) { super(new BorderLayout()); @@ -73,11 +90,19 @@ public class RecentProjectPanel extends JPanel { public boolean onClick(@NotNull MouseEvent event, int clickCount) { int selectedIndex = myList.getSelectedIndex(); if (selectedIndex >= 0) { - if (myList.getCellBounds(selectedIndex, selectedIndex).contains(event.getPoint())) { + Rectangle cellBounds = myList.getCellBounds(selectedIndex, selectedIndex); + if (cellBounds.contains(event.getPoint())) { Object selection = myList.getSelectedValue(); - if (selection != null) { - ((AnAction)selection).actionPerformed(AnActionEvent.createFromInputEvent((AnAction)selection, event, ActionPlaces.WELCOME_SCREEN)); + Rectangle closeButtonRect = myCloseButtonForEditor.getBounds(); + + Rectangle rectInListCoordinates = new Rectangle(new Point(closeButtonRect.x + cellBounds.x, closeButtonRect.y + cellBounds.y), closeButtonRect.getSize()); + + if (Registry.is("removable.welcome.screen.projects") && rectInListCoordinates.contains(event.getPoint())) { + removeRecentProjectAction.actionPerformed(null); + } else if (selection != null) { + ((AnAction)selection).actionPerformed( + AnActionEvent.createFromInputEvent((AnAction)selection, event, ActionPlaces.WELCOME_SCREEN)); } } } @@ -98,7 +123,7 @@ public class RecentProjectPanel extends JPanel { }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - new AnAction() { + removeRecentProjectAction = new AnAction() { @Override public void actionPerformed(AnActionEvent e) { Object[] selection = myList.getSelectedValues(); @@ -128,7 +153,8 @@ public class RecentProjectPanel extends JPanel { public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(!ListWithFilter.isSearchActive(myList)); } - }.registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), myList, screen); + }; + removeRecentProjectAction.registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), myList, screen); addMouseMotionListener(); @@ -167,8 +193,10 @@ public class RecentProjectPanel extends JPanel { } protected void addMouseMotionListener() { - myList.addMouseMotionListener(new MouseMotionAdapter() { + + MouseAdapter mouseAdapter = new MouseAdapter() { boolean myIsEngaged = false; + @Override public void mouseMoved(MouseEvent e) { if (myIsEngaged && !UIUtil.isSelectionButtonDown(e)) { Point point = e.getPoint(); @@ -178,16 +206,30 @@ public class RecentProjectPanel extends JPanel { final Rectangle bounds = myList.getCellBounds(index, index); if (bounds != null && bounds.contains(point)) { myList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + myHoverIndex = index; + myList.repaint(bounds); } else { myList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + myHoverIndex = -1; + myList.repaint(); } } else { myIsEngaged = true; } } - }); + + @Override + public void mouseExited(MouseEvent e) { + myHoverIndex = -1; + myList.repaint(); + } + }; + + myList.addMouseMotionListener(mouseAdapter); + myList.addMouseListener(mouseAdapter); + } protected JBList createList(AnAction[] recentProjectActions, Dimension size) { @@ -232,9 +274,13 @@ public class RecentProjectPanel extends JPanel { } } - protected static class RecentProjectItemRenderer extends JPanel implements ListCellRenderer { + protected class RecentProjectItemRenderer extends JPanel implements ListCellRenderer { + protected final JLabel myName = new JLabel(); protected final JLabel myPath = new JLabel(); + protected boolean myHovered; + protected JPanel myCloseThisItem = myCloseButtonForEditor; + private final UniqueNameBuilder myShortener; protected RecentProjectItemRenderer(UniqueNameBuilder pathShortener) { @@ -260,6 +306,8 @@ public class RecentProjectPanel extends JPanel { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + myHovered = myHoverIndex == index; + ReopenProjectAction item = (ReopenProjectAction)value; Color fore = getListForeground(isSelected, list.hasFocus()); diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 0cefc572b11d..c27a3f1b19ea 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -515,4 +515,7 @@ force.subpixel.hinting=false force.subpixel.hinting.description=Force using sub-pixel antialiasing lcd.contrast.value=140 -lcd.contrast.value.description=Set LCD text contrast value from 100 to 250 \ No newline at end of file +lcd.contrast.value.description=Set LCD text contrast value from 100 to 250 + +removable.welcome.screen.projects=false +removable.welcomesreen.projects.description=Allows removing recent projects from welcome screen with mouse From 40efd8059072a99cae48e47f0def078a8a1b5178 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 23 Dec 2014 17:04:04 +0100 Subject: [PATCH 03/15] correctly recognize Mac installations of IDEA 13 and earler as valid SDK homes --- plugins/devkit/src/projectRoots/IdeaJdk.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/devkit/src/projectRoots/IdeaJdk.java b/plugins/devkit/src/projectRoots/IdeaJdk.java index 056062606e13..7bb365476c0e 100644 --- a/plugins/devkit/src/projectRoots/IdeaJdk.java +++ b/plugins/devkit/src/projectRoots/IdeaJdk.java @@ -175,8 +175,14 @@ public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType { @Nullable public static String getBuildNumber(String ideaHome) { try { - @NonNls final String buildTxt = SystemInfo.isMac ? "/Resources/build.txt" : "/build.txt"; - return FileUtil.loadFile(new File(ideaHome + buildTxt)).trim(); + @NonNls final String buildTxt = SystemInfo.isMac ? "Resources/build.txt" : "build.txt"; + File file = new File(ideaHome, buildTxt); + if (SystemInfo.isMac && !file.exists()) { + // IntelliJ IDEA 13 and earlier used a different location for build.txt on Mac; + // recognize the old location as well + file = new File(ideaHome, "build.txt"); + } + return FileUtil.loadFile(file).trim(); } catch (IOException e) { return null; From 1e95b310a419092bd5f1ab1c7e5c72663dd07af4 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 23 Dec 2014 17:19:25 +0100 Subject: [PATCH 04/15] cache coverage summary data returned by extension in PackageAnnotator; add API to allow exluding a .class file from coverage summary statistics --- .../coverage/JavaCoverageAnnotator.java | 20 +++++++++++++ .../coverage/JavaCoverageEngineExtension.java | 10 +++++++ .../intellij/coverage/PackageAnnotator.java | 30 ++++++++++++------- .../view/JavaCoverageViewExtension.java | 7 +---- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java b/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java index 0fad443ceb23..8a5e962a66b2 100644 --- a/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java +++ b/plugins/coverage/src/com/intellij/coverage/JavaCoverageAnnotator.java @@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.containers.HashMap; +import com.intellij.util.containers.WeakHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,6 +29,8 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator { private final Map myTestDirCoverageInfos = new HashMap(); private final Map myClassCoverageInfos = new HashMap(); + private final WeakHashMap myExtensionCoverageInfos = + new WeakHashMap(); public JavaCoverageAnnotator(final Project project) { super(project); @@ -71,6 +74,7 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator { myDirCoverageInfos.clear(); myTestDirCoverageInfos.clear(); myClassCoverageInfos.clear(); + myExtensionCoverageInfos.clear(); } protected Runnable createRenewRequest(@NotNull final CoverageSuitesBundle suite, @NotNull final CoverageDataManager dataManager) { @@ -257,4 +261,20 @@ public class JavaCoverageAnnotator extends BaseCoverageAnnotator { public PackageAnnotator.ClassCoverageInfo getClassCoverageInfo(String classFQName) { return myClassCoverageInfos.get(classFQName); } + + public PackageAnnotator.SummaryCoverageInfo getExtensionCoverageInfo(PsiNamedElement value) { + PackageAnnotator.SummaryCoverageInfo cachedInfo = myExtensionCoverageInfos.get(value); + if (cachedInfo != null) { + return cachedInfo; + } + for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { + PackageAnnotator.SummaryCoverageInfo info = extension.getSummaryCoverageInfo(this, value); + if (info != null) { + myExtensionCoverageInfos.put(value, info); + return info; + } + } + + return null; + } } diff --git a/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java b/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java index 44f5ab941613..52d8b63c93d8 100644 --- a/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java +++ b/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java @@ -88,6 +88,16 @@ public abstract class JavaCoverageEngineExtension { return null; } + /** + * Returns true if the specified .class file needs to be completely excluded from the coverage statistics. + * + * @param bundle the coverage suites bundle being indexed. + * @param classFile the class file. + */ + public boolean ignoreCoverageForClass(CoverageSuitesBundle bundle, File classFile) { + return false; + } + /** * Returns true if the class coverage info for the specified .class file, for which it wasn't possible to find a corresponding * source file, needs to be preserved and made available as {@link JavaCoverageAnnotator#getClassCoverageInfo(String)}. diff --git a/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java b/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java index c60df2461fca..c5ae0bfca1f9 100644 --- a/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java +++ b/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java @@ -311,20 +311,27 @@ public class PackageAnnotator { } }); PackageCoverageInfo coverageInfoForClass = null; - if (isInSource != null && isInSource.booleanValue()) { + String classCoverageKey = classFqVMName.replace('/', '.'); + boolean ignoreClass = false; + for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { + if (extension.ignoreCoverageForClass(myCoverageManager.getCurrentSuitesBundle(), child)) { + ignoreClass = true; + break; + } + if (extension.keepCoverageInfoForClassWithoutSource(myCoverageManager.getCurrentSuitesBundle(), child)) { + coverageInfoForClass = classWithoutSourceCoverageInfo; + break; + } + } + if (ignoreClass) { + continue; + } + + if (coverageInfoForClass == null && isInSource != null && isInSource.booleanValue()) { for (DirCoverageInfo dirCoverageInfo : dirs) { if (dirCoverageInfo.sourceRoot != null && VfsUtil.isAncestor(dirCoverageInfo.sourceRoot, containingFileRef.get(), false)) { coverageInfoForClass = dirCoverageInfo; - break; - } - } - } - String classCoverageKey = toplevelClassSrcFQName; - if (coverageInfoForClass == null) { - for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { - if (extension.keepCoverageInfoForClassWithoutSource(myCoverageManager.getCurrentSuitesBundle(), child)) { - classCoverageKey = classFqVMName.replace('/', '.'); - coverageInfoForClass = classWithoutSourceCoverageInfo; + classCoverageKey = toplevelClassSrcFQName; break; } } @@ -439,6 +446,7 @@ public class PackageAnnotator { } ClassCoverageInfo classCoverageInfo = getOrCreateClassCoverageInfo(toplevelClassCoverage, toplevelClassSrcFQName); + LOG.info("Adding coverage of " + classFile.getName() + " to top-level class " + toplevelClassSrcFQName); classCoverageInfo.totalLineCount += toplevelClassCoverageInfo.totalLineCount; classCoverageInfo.fullyCoveredLineCount += toplevelClassCoverageInfo.fullyCoveredLineCount; classCoverageInfo.partiallyCoveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount; diff --git a/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java b/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java index c4ccc66e30cf..19b2f20d7054 100644 --- a/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java +++ b/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java @@ -90,12 +90,7 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { return myAnnotator.getPackageCoverageInfo((PsiPackage)value, myStateBean.myFlattenPackages); } if (value instanceof PsiNamedElement) { - for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { - PackageAnnotator.SummaryCoverageInfo info = extension.getSummaryCoverageInfo(myAnnotator, (PsiNamedElement)value); - if (info != null) { - return info; - } - } + return myAnnotator.getExtensionCoverageInfo((PsiNamedElement) value); } return null; } From f9966cd62087c7db958a52247403775b57591540 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 23 Dec 2014 17:55:20 +0100 Subject: [PATCH 05/15] don't preserve coverage data for interfaces --- .../src/com/intellij/coverage/SourceLineCounterUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/coverage/src/com/intellij/coverage/SourceLineCounterUtil.java b/plugins/coverage/src/com/intellij/coverage/SourceLineCounterUtil.java index 93667ea59508..0bad2659a932 100644 --- a/plugins/coverage/src/com/intellij/coverage/SourceLineCounterUtil.java +++ b/plugins/coverage/src/com/intellij/coverage/SourceLineCounterUtil.java @@ -33,7 +33,7 @@ public class SourceLineCounterUtil { if (!counter.isInterface()) { packageCoverageInfo.totalClassCount++; } - return true; + return !counter.isInterface(); } public static void collectSrcLinesForUntouchedFiles(final List uncoveredLines, From 4bea0ec3760792a8324347c7b1f1f1486d06803c Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 23 Dec 2014 21:36:56 +0100 Subject: [PATCH 06/15] add logging and reduce logging level --- .../com/intellij/coverage/PackageAnnotator.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java b/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java index c5ae0bfca1f9..5d98ebb358a8 100644 --- a/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java +++ b/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java @@ -418,7 +418,7 @@ public class PackageAnnotator { boolean touchedClass = false; final Collection methodSigs = classData.getMethodSigs(); for (final Object nameAndSig : methodSigs) { - if (isGeneratedDefaultConstructor(psiClass, (String) nameAndSig)) { + if (isGeneratedDefaultConstructor(psiClass, (String)nameAndSig)) { continue; } final int covered = classData.getStatus((String)nameAndSig); @@ -438,15 +438,21 @@ public class PackageAnnotator { packageCoverageInfo.coveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount; packageCoverageInfo.coveredMethodCount += toplevelClassCoverageInfo.coveredMethodCount; packageCoverageInfo.totalMethodCount += toplevelClassCoverageInfo.totalMethodCount; - } else { + } + else { + LOG.debug("Did not find any method signatures in " + classFile.getName()); + return; + } + } + else { + if (!collectNonCoveredClassInfo(classFile, psiClass, toplevelClassCoverageInfo, packageCoverageInfo)) { + LOG.debug("Did not collect non-covered class info for " + classFile.getName()); return; } - } else { - if (!collectNonCoveredClassInfo(classFile, psiClass, toplevelClassCoverageInfo, packageCoverageInfo)) return; } ClassCoverageInfo classCoverageInfo = getOrCreateClassCoverageInfo(toplevelClassCoverage, toplevelClassSrcFQName); - LOG.info("Adding coverage of " + classFile.getName() + " to top-level class " + toplevelClassSrcFQName); + LOG.debug("Adding coverage of " + classFile.getName() + " to top-level class " + toplevelClassSrcFQName); classCoverageInfo.totalLineCount += toplevelClassCoverageInfo.totalLineCount; classCoverageInfo.fullyCoveredLineCount += toplevelClassCoverageInfo.fullyCoveredLineCount; classCoverageInfo.partiallyCoveredLineCount += toplevelClassCoverageInfo.partiallyCoveredLineCount; From f596ea1e72b385880d967eff2f50540509a2de86 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 24 Dec 2014 00:39:07 +0300 Subject: [PATCH 07/15] PY-14796 Running lettuce 0.2.19 fails --- python/helpers/pycharm/behave_runner.py | 1 + python/helpers/pycharm/lettuce_runner.py | 41 +++++++++++++++--------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/python/helpers/pycharm/behave_runner.py b/python/helpers/pycharm/behave_runner.py index 79dd4d6449bc..1ecf6a0952b6 100644 --- a/python/helpers/pycharm/behave_runner.py +++ b/python/helpers/pycharm/behave_runner.py @@ -194,6 +194,7 @@ class _BehaveRunner(_bdd_utils.BddRunner): :return true if should pass """ assert isinstance(scenario, Scenario), scenario + # TODO: share with lettuce_runner.py#_get_features_to_run expected_tags = self.__config.tags scenario_name_re = self.__config.name_re if scenario_name_re and not scenario_name_re.match(scenario.name): diff --git a/python/helpers/pycharm/lettuce_runner.py b/python/helpers/pycharm/lettuce_runner.py index fbf51dbf6f29..b61f7af9a332 100644 --- a/python/helpers/pycharm/lettuce_runner.py +++ b/python/helpers/pycharm/lettuce_runner.py @@ -4,7 +4,7 @@ BDD lettuce framework runner TODO: Support other params (like tags) as well. Supports only 2 params now: folder to search "features" for or file and "-s scenario_index" """ -import argparse +import inspect import optparse import os import _bdd_utils @@ -28,25 +28,31 @@ class _LettuceRunner(_bdd_utils.BddRunner): :param base_dir base directory to run tests in :type base_dir: str :param what_to_run folder or file to run - :type options list of optparse.Option + :type options optparse.Values :param options optparse options passed by user :type what_to_run str """ super(_LettuceRunner, self).__init__(base_dir) # TODO: Copy/Paste with lettuce.bin, need to reuse somehow - tags = None - if options.tags: - tags = [tag.strip('@') for tag in options.tags] - self.__runner = lettuce.Runner(what_to_run, ",".join(scenarios), - random=options.random, - enable_xunit=options.enable_xunit, - xunit_filename=options.xunit_file, - enable_subunit=options.enable_subunit, - subunit_filename=options.subunit_filename, - failfast=options.failfast, - auto_pdb=options.auto_pdb, - tags=tags) + + # Delete args that do not exist in constructor + args_to_pass = options.__dict__ + runner_args = inspect.getargspec(lettuce.Runner.__init__)[0] + unknown_args = set(args_to_pass.keys()) - set(runner_args) + map(args_to_pass.__delitem__, unknown_args) + + # Tags is special case and need to be preprocessed + self.__tags = None # Store tags in field + if 'tags' in args_to_pass.keys() and args_to_pass['tags']: + args_to_pass['tags'] = [tag.strip('@') for tag in args_to_pass['tags']] + self.__tags = set(args_to_pass['tags']) + + # Special cases we pass directly + args_to_pass['base_path'] = what_to_run + args_to_pass['scenarios'] = ",".join(scenarios) + + self.__runner = lettuce.Runner(**args_to_pass) def _get_features_to_run(self): super(_LettuceRunner, self)._get_features_to_run() @@ -71,6 +77,11 @@ class _LettuceRunner(_bdd_utils.BddRunner): if index < len(feature.scenarios): filtered_feature_scenarios.append(feature.scenarios[index]) feature.scenarios = filtered_feature_scenarios + + # Filter out tags TODO: Share with behave_runner.py#__filter_scenarios_by_args + if self.__tags: + for feature in features: + feature.scenarios = filter(lambda s: set(s.tags) & self.__tags, feature.scenarios) return features def _run_tests(self): @@ -145,7 +156,7 @@ def _get_args(): parser = optparse.OptionParser() parser.add_option("-v", "--verbosity", dest="verbosity", - default=4, + default=0, # We do not need verbosity due to GUI we use (although user may override it) help='The verbosity level') parser.add_option("-s", "--scenarios", From 01f10409d4dc8e03bff48b2b09f22b36713151d8 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 24 Dec 2014 09:14:30 +0100 Subject: [PATCH 08/15] Recognize "tst" as test root name (http://stackoverflow.com/questions/27629258/) --- .../importSources/impl/ProjectFromSourcesBuilderImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/impl/ProjectFromSourcesBuilderImpl.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/impl/ProjectFromSourcesBuilderImpl.java index 669ea1fb12b2..743c3426fe9e 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/impl/ProjectFromSourcesBuilderImpl.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/impl/ProjectFromSourcesBuilderImpl.java @@ -410,7 +410,8 @@ public class ProjectFromSourcesBuilderImpl extends ProjectImportBuilder implemen "tests".equalsIgnoreCase(name) || "testSource".equalsIgnoreCase(name) || "testSources".equalsIgnoreCase(name) || - "testSrc".equalsIgnoreCase(name); + "testSrc".equalsIgnoreCase(name) || + "tst".equalsIgnoreCase(name); } public interface ProjectConfigurationUpdater { From fac2e468d4c368f4bb94cb3983f05b4a5a897dbe Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Wed, 24 Dec 2014 11:32:02 +0300 Subject: [PATCH 09/15] EA-63613 - IAE: ProjectRootContainerImpl.addRoot: diagnostics --- plugins/devkit/src/projectRoots/IdeaJdk.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/devkit/src/projectRoots/IdeaJdk.java b/plugins/devkit/src/projectRoots/IdeaJdk.java index 7bb365476c0e..fce82406886f 100644 --- a/plugins/devkit/src/projectRoots/IdeaJdk.java +++ b/plugins/devkit/src/projectRoots/IdeaJdk.java @@ -216,7 +216,9 @@ public class IdeaJdk extends JavaDependentSdkType implements JavaSdkType { for (File jar : jars) { @NonNls String name = jar.getName(); if (jar.isFile() && Arrays.binarySearch(forbidden, name) < 0 && (name.endsWith(".jar") || name.endsWith(".zip"))) { - result.add(jfs.findFileByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR)); + VirtualFile file = jfs.findFileByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR); + LOG.assertTrue(file != null, jar.getPath() + " not found"); + result.add(file); } } } From 31d51ff6d9afd0ba83faeac6f92b9ab7dda2268a Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 22 Dec 2014 18:49:13 +0300 Subject: [PATCH 10/15] println removed --- .../fileTypes/impl/IgnoredPatternSet.java | 4 +- .../fileTypes/impl/FileTypeManagerImpl.java | 24 +++--- .../openapi/fileTypes/impl/FileTypesTest.java | 76 ++++++++++--------- 3 files changed, 57 insertions(+), 47 deletions(-) diff --git a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java index cd31b4458246..e64ed100419e 100644 --- a/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java +++ b/jps/model-impl/src/com/intellij/openapi/fileTypes/impl/IgnoredPatternSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -65,7 +65,7 @@ public class IgnoredPatternSet { return fileName.endsWith(FileUtil.ASYNC_DELETE_EXTENSION); } - void clearPatterns() { + private void clearPatterns() { myMasks.clear(); myIgnorePatterns.removeAllAssociations(Boolean.TRUE); } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 30ae5908124e..a2a210d4bf4e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -258,11 +258,11 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME }); files.remove(null); if (toLog()) { - System.out.println("F: VFS events: " + events); + log("F: VFS events: " + events); } if (!files.isEmpty() && RE_DETECT_ASYNC) { if (toLog()) { - System.out.println("F: queued to redetect: " + files); + log("F: queued to redetect: " + files); } reDetectQueue.offerIfAbsent(files); } @@ -277,6 +277,10 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME return RE_DETECT_ASYNC && ApplicationManager.getApplication().isUnitTestMode(); } + private static void log(String message) { + //System.out.println(message); + } + private final TransferToPooledThreadQueue> reDetectQueue = new TransferToPooledThreadQueue>("File type re-detect", Conditions.alwaysFalse(), -1, new Processor>() { @Override public boolean process(Collection files) { @@ -306,7 +310,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME for (VirtualFile file : files) { boolean shouldRedetect = wasAutoDetectedBefore(file) && isDetectable(file); if (toLog()) { - System.out.println("F: Redetect file: " + file.getName() + "; shouldRedetect: " + shouldRedetect); + log("F: Redetect file: " + file.getName() + "; shouldRedetect: " + shouldRedetect); } if (shouldRedetect) { int id = file instanceof VirtualFileWithId ? ((VirtualFileWithId)file).getId() : -1; @@ -317,7 +321,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME file.putUserData(DETECTED_FROM_CONTENT_FILE_TYPE_KEY, null); FileType after = getFileTypeByFile(file); // may be back to standard file type if (toLog()) { - System.out.println("F: After redetect file: " + file.getName() + "; before: " + before.getName() + "; after: " + after.getName()+"; now getFileType()="+file.getFileType().getName()); + log("F: After redetect file: " + file.getName() + "; before: " + before.getName() + "; after: " + after.getName()+"; now getFileType()="+file.getFileType().getName()); } if (before != after) { @@ -421,7 +425,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME public static void cacheFileType(@NotNull VirtualFile file, @Nullable FileType fileType) { file.putUserData(FILE_TYPE_KEY, fileType); if (toLog()) { - System.out.println("F: Cached file type for "+file.getName()+" to "+(fileType == null ? null : fileType.getName())); + log("F: Cached file type for "+file.getName()+" to "+(fileType == null ? null : fileType.getName())); } } @@ -441,7 +445,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME FileTypeIdentifiableByVirtualFile type = mySpecialFileTypes.get(i); if (type.isMyFileType(file)) { if (toLog()) { - System.out.println("F: Special file type for "+file.getName()+"; type: "+type.getName()); + log("F: Special file type for "+file.getName()+"; type: "+type.getName()); } return type; } @@ -450,7 +454,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME fileType = getFileTypeByFileName(file.getNameSequence()); if (fileType != UnknownFileType.INSTANCE) { if (toLog()) { - System.out.println("F: By name file type for "+file.getName()+"; type: "+fileType.getName()); + log("F: By name file type for "+file.getName()+"; type: "+fileType.getName()); } return fileType; } @@ -475,7 +479,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME if (autoDetectWasRun) { FileType type = getAutoDetectedType(file, id); if (toLog()) { - System.out.println("F: autodetected getFileType("+file.getName()+") = "+type.getName()); + log("F: autodetected getFileType("+file.getName()+") = "+type.getName()); } return type; } @@ -517,7 +521,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME } if (toLog()) { - System.out.println("F: getFileType after detect run("+file.getName()+") = "+fileType.getName()); + log("F: getFileType after detect run("+file.getName()+") = "+fileType.getName()); } return fileType; @@ -638,7 +642,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME } FileType fileType = result.get(); if (toLog()) { - System.out.println("F: Redetect run for file: " + file.getName() + "; result: "+fileType.getName()); + log("F: Redetect run for file: " + file.getName() + "; result: "+fileType.getName()); } if (LOG.isDebugEnabled()) { diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java index bc57c7d1b32c..f603e518b900 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java @@ -40,6 +40,7 @@ import com.intellij.psi.impl.PsiManagerEx; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.util.PatternUtil; +import com.intellij.util.ThrowableRunnable; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import junit.framework.TestCase; @@ -104,7 +105,27 @@ public class FileTypesTest extends PlatformTestCase { } public void testExcludePerformance() { - runPerformanceTest(true); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + myFileTypeManager.setIgnoredFilesList("1*2;3*4;5*6;7*8;9*0;*1;*3;*5;*6;7*;*8*"); + } + }); + final String[] names = new String[100]; + for (int i = 0; i < names.length; i++) { + String name = String.valueOf((i%10)*10 + (i*100) + i + 1); + names[i] = (name + name + name + name); + } + PlatformTestUtil.startPerformanceTest("ignore perf", 700, new ThrowableRunnable() { + @Override + public void run() throws Throwable { + for (int i=0;i<1000;i++) { + for (String name : names) { + myFileTypeManager.isFileIgnored(name); + } + } + } + }).assertTiming(); } public void testMaskToPattern() { @@ -174,25 +195,6 @@ public class FileTypesTest extends PlatformTestCase { assertTrue(myFileTypeManager.isFileIgnored(fileName)); } - private void runPerformanceTest(boolean rerunOnOvertime) { - long startTime = System.currentTimeMillis(); - ApplicationManager.getApplication().runWriteAction(new Runnable() { - @Override - public void run() { - myFileTypeManager.setIgnoredFilesList("1*2;3*4;5*6;7*8;9*0;*1;*3;*5;*6;7*;*8*"); - } - }); - for (int i = 0; i < 100; i++) { - String name = String.valueOf((i%10)*10 + (i*100) + i + 1); - myFileTypeManager.isFileIgnored(name + name + name + name); - } - long time = System.currentTimeMillis() - startTime; - if (time > 700) { - if (rerunOnOvertime) runPerformanceTest(false); - else fail("Time=" + time); - } - } - public void testAutoDetected() throws IOException { File dir = createTempDirectory(); File file = FileUtil.createTempFile(dir, "x", "xxx_xx_xx", true); @@ -311,7 +313,7 @@ public class FileTypesTest extends PlatformTestCase { detectorCalled.add(file); String text = firstCharsIfText.toString(); FileType result = text.startsWith("TYPE:") ? fileTypeManager.findFileTypeByName(StringUtil.trimStart(text, "TYPE:")) : null; - System.out.println("T: my detector run for "+file.getName()+"; result: "+(result == null ? null : result.getName())); + log("T: my detector run for "+file.getName()+"; result: "+(result == null ? null : result.getName())); return result; } @@ -322,42 +324,46 @@ public class FileTypesTest extends PlatformTestCase { }; Extensions.getRootArea().getExtensionPoint(FileTypeRegistry.FileTypeDetector.EP_NAME).registerExtension(detector); try { - System.out.println("T: ------"); + log("T: ------"); File f = createTempFile("xx.asfdasdfas", "akjdhfksdjgf"); VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f); ensureRedetected(vFile, detectorCalled); assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof PlainTextFileType); - System.out.println("T: ------"); + log("T: ------"); VfsUtil.saveText(vFile, "TYPE:IDEA_MODULE"); ensureRedetected(vFile, detectorCalled); assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof ModuleFileType); - System.out.println("T: ------"); + log("T: ------"); VfsUtil.saveText(vFile, "TYPE:IDEA_PROJECT"); ensureRedetected(vFile, detectorCalled); assertTrue(vFile.getFileType().toString(), vFile.getFileType() instanceof ProjectFileType); - System.out.println("T: ------"); + log("T: ------"); } finally { Extensions.getRootArea().getExtensionPoint(FileTypeRegistry.FileTypeDetector.EP_NAME).unregisterExtension(detector); } } + private static void log(String message) { + //System.out.println(message); + } + private void ensureRedetected(VirtualFile vFile, Set detectorCalled) { PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - System.out.println("T: ensureRedetected: commit"); + log("T: ensureRedetected: commit"); UIUtil.dispatchAllInvocationEvents(); - System.out.println("T: ensureRedetected: dispatch"); + log("T: ensureRedetected: dispatch"); myFileTypeManager.drainReDetectQueue(); - System.out.println("T: ensureRedetected: drain"); + log("T: ensureRedetected: drain"); UIUtil.dispatchAllInvocationEvents(); - System.out.println("T: ensureRedetected: dispatch"); + log("T: ensureRedetected: dispatch"); FileType type = vFile.getFileType(); - System.out.println("T: ensureRedetected: getFileType ("+type.getName()+")"); + log("T: ensureRedetected: getFileType ("+type.getName()+")"); assertTrue(detectorCalled.contains(vFile)); detectorCalled.clear(); - System.out.println("T: ensureRedetected: clear"); + log("T: ensureRedetected: clear"); } public void testReassignedPredefinedFileType() throws Exception { @@ -404,7 +410,7 @@ public class FileTypesTest extends PlatformTestCase { Element element = new Element("foo"); myFileTypeManager.writeExternal(element); String s = JDOMUtil.writeElement(element); - System.out.println(s); + log(s); final AbstractFileType typeFromPlugin = new AbstractFileType(new SyntaxTable()); PlatformTestUtil.registerExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, new FileTypeFactory() { @@ -453,7 +459,7 @@ public class FileTypesTest extends PlatformTestCase { element = new Element("foo"); myFileTypeManager.writeExternal(element); - System.out.println(JDOMUtil.writeElement(element)); + log(JDOMUtil.writeElement(element)); Extensions.getRootArea().getExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP).unregisterExtension(factory); myFileTypeManager.clearForTests(); @@ -463,7 +469,7 @@ public class FileTypesTest extends PlatformTestCase { element = new Element("foo"); myFileTypeManager.writeExternal(element); - System.out.println(JDOMUtil.writeElement(element)); + log(JDOMUtil.writeElement(element)); Extensions.getRootArea().getExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP).registerExtension(factory); myFileTypeManager.clearForTests(); @@ -473,7 +479,7 @@ public class FileTypesTest extends PlatformTestCase { element = new Element("foo"); myFileTypeManager.writeExternal(element); - System.out.println(JDOMUtil.writeElement(element)); + log(JDOMUtil.writeElement(element)); assertEquals(typeFromPlugin, myFileTypeManager.getFileTypeByFileName("foo.foo")); } From 5f748fa85e6ef9aaa1b2eac058d186292d948972 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 23 Dec 2014 14:28:33 +0300 Subject: [PATCH 11/15] EA-53577 - assert: ComponentManagerImpl.getComponent --- .../find/editorHeaderActions/FindAllAction.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/FindAllAction.java b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/FindAllAction.java index 406885aeb756..f3412f079423 100644 --- a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/FindAllAction.java +++ b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/FindAllAction.java @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2014 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. + * 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.find.editorHeaderActions; import com.intellij.find.EditorSearchComponent; @@ -40,7 +55,7 @@ public class FindAllAction extends EditorHeaderAction implements DumbAware { super.update(e); Editor editor = getEditorSearchComponent().getEditor(); Project project = editor.getProject(); - if (project != null) { + if (project != null && !project.isDisposed()) { e.getPresentation().setEnabled(getEditorSearchComponent().hasMatches() && PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()) != null); } From bdf7ef53500b3662221b58ecf5bc5057e796efc1 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 23 Dec 2014 14:30:11 +0300 Subject: [PATCH 12/15] EA-55388 - assert: ComponentManagerImpl.getComponent --- .../codeInsight/hint/InspectionDescriptionLinkHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java index 102c8807b2de..ac1d462ccdcf 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/InspectionDescriptionLinkHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -43,7 +43,7 @@ public class InspectionDescriptionLinkHandler extends TooltipLinkHandler { LOG.error(editor); return null; } - + if (project.isDisposed()) return null; final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == null) { return null; From 6f9bb06e356782b7d0d32ff6bec5a30abecdc9b0 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 23 Dec 2014 14:53:00 +0300 Subject: [PATCH 13/15] diagnostics --- .../codeInsight/daemon/impl/CollectHighlightsUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java b/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java index a3c7e3af3cdf..33495b40ad09 100644 --- a/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java +++ b/platform/core-impl/src/com/intellij/codeInsight/daemon/impl/CollectHighlightsUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -142,7 +142,7 @@ public class CollectHighlightsUtil { PsiElement commonParent = PsiTreeUtil.findCommonParent(left, right); LOG.assertTrue(commonParent != null); - LOG.assertTrue(commonParent.getTextRange() != null); + LOG.assertTrue(commonParent.getTextRange() != null, commonParent); PsiElement parent = commonParent.getParent(); while (parent != null && commonParent.getTextRange().equals(parent.getTextRange())) { From 8ce50eec9c73f9c7c315ecff3a6088e2500ad121 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 23 Dec 2014 15:00:04 +0300 Subject: [PATCH 14/15] make stacktrace less painful to parse --- .../util/InspectionValidatorWrapper.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/openapi/compiler/util/InspectionValidatorWrapper.java b/java/compiler/impl/src/com/intellij/openapi/compiler/util/InspectionValidatorWrapper.java index 1c971743cbf2..acf293b0c192 100644 --- a/java/compiler/impl/src/com/intellij/openapi/compiler/util/InspectionValidatorWrapper.java +++ b/java/compiler/impl/src/com/intellij/openapi/compiler/util/InspectionValidatorWrapper.java @@ -28,7 +28,7 @@ import com.intellij.lang.annotation.Annotation; import com.intellij.lang.annotation.AnnotationSession; import com.intellij.lang.annotation.ExternalAnnotator; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.openapi.application.AccessToken; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.application.ReadActionProcessor; import com.intellij.openapi.application.Result; @@ -257,24 +257,23 @@ public class InspectionValidatorWrapper implements Validator { return true; } - private boolean checkUnderReadAction(PsiFile file, CompileContext context, Computable> runnable) { - AccessToken token = ReadAction.start(); - try { - if (!file.isValid()) return false; + private boolean checkUnderReadAction(final PsiFile file, final CompileContext context, final Computable> runnable) { + return ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Boolean compute() { + if (!file.isValid()) return false; - final Document document = myPsiDocumentManager.getCachedDocument(file); - if (document != null && myPsiDocumentManager.isUncommited(document)) { - final String url = file.getViewProvider().getVirtualFile().getUrl(); - context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("warning.text.file.has.been.changed"), url, -1, -1); - return false; + final Document document = myPsiDocumentManager.getCachedDocument(file); + if (document != null && myPsiDocumentManager.isUncommited(document)) { + final String url = file.getViewProvider().getVirtualFile().getUrl(); + context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("warning.text.file.has.been.changed"), url, -1, -1); + return false; + } + + if (reportProblems(context, runnable.compute())) return false; + return true; } - - if (reportProblems(context, runnable.compute())) return false; - } - finally { - token.finish(); - } - return true; + }); } private boolean reportProblems(CompileContext context, Map problemsMap) { From 3a3a34e326583bd61ce0af8817f224aa4fb9fc99 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 24 Dec 2014 12:11:58 +0300 Subject: [PATCH 15/15] EA-55785 - assert: ComponentManagerImpl.getComponent --- .../psi/impl/smartPointers/SelfElementInfo.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java index 7ebf149d7122..d141a79f5703 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java +++ b/platform/core-impl/src/com/intellij/psi/impl/smartPointers/SelfElementInfo.java @@ -224,6 +224,7 @@ public class SelfElementInfo implements SmartPointerElementInfo { return ApplicationManager.getApplication().runReadAction(new NullableComputable() { @Override public PsiFile compute() { + if (project.isDisposed()) return null; VirtualFile child; if (virtualFile.isValid()) { child = virtualFile; @@ -285,7 +286,7 @@ public class SelfElementInfo implements SmartPointerElementInfo { } @Override - public boolean pointsToTheSameElementAs(@NotNull SmartPointerElementInfo other) { + public boolean pointsToTheSameElementAs(@NotNull final SmartPointerElementInfo other) { if (other instanceof SelfElementInfo) { SelfElementInfo otherInfo = (SelfElementInfo)other; return Comparing.equal(myVirtualFile, otherInfo.myVirtualFile) @@ -296,7 +297,12 @@ public class SelfElementInfo implements SmartPointerElementInfo { && mySyncEndOffset == otherInfo.mySyncEndOffset ; } - return Comparing.equal(restoreElement(), other.restoreElement()); + return ApplicationManager.getApplication().runReadAction(new Computable() { + @Override + public Boolean compute() { + return Comparing.equal(restoreElement(), other.restoreElement()); + } + }); } @Override