Merge remote-tracking branch 'origin/master'
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Wed, 1 Jun 2016 06:05:05 +0000 (09:05 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Wed, 1 Jun 2016 06:05:05 +0000 (09:05 +0300)
16 files changed:
java/typeMigration/src/com/intellij/refactoring/typeMigration/inspections/GuavaInspection.java
platform/lang-impl/src/com/intellij/analysis/AnalysisUIOptions.java
platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java
platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineInspectionRVContentProvider.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeNode.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeState.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeUpdater.java
plugins/properties/properties-psi-api/src/com/intellij/lang/properties/psi/PropertyKeyIndex.java
plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java
plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertiesListImpl.java
plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/references/PropertiesPsiCompletionUtil.java
plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertyStubElementType.java [deleted file]

index dee2204f1db79c3d95cd7c8510626b2fac1a8ab0..61156e6b25a5033779290e51ba360e131fadba2b 100644 (file)
@@ -280,7 +280,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
     };
   }
 
-  public class MigrateGuavaTypeFix extends LocalQuickFixAndIntentionActionOnPsiElement implements BatchQuickFix<ProblemDescriptor> {
+  public class MigrateGuavaTypeFix extends LocalQuickFixAndIntentionActionOnPsiElement implements BatchQuickFix<CommonProblemDescriptor> {
     private final PsiType myTargetType;
 
     private MigrateGuavaTypeFix(@NotNull PsiElement element, PsiType targetType) {
@@ -333,13 +333,13 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
 
     @Override
     public void applyFix(@NotNull final Project project,
-                         @NotNull ProblemDescriptor[] descriptors,
+                         @NotNull CommonProblemDescriptor[] descriptors,
                          @NotNull List<PsiElement> psiElementsToIgnore,
                          @Nullable Runnable refreshViews) {
       final List<PsiElement> elementsToFix = new ArrayList<PsiElement>();
       final List<PsiType> migrationTypes = new ArrayList<PsiType>();
 
-      for (ProblemDescriptor descriptor : descriptors) {
+      for (CommonProblemDescriptor descriptor : descriptors) {
         final MigrateGuavaTypeFix fix = getFix(descriptor);
         elementsToFix.add(fix.getStartElement());
         migrationTypes.add(fix.myTargetType);
@@ -348,7 +348,7 @@ public class GuavaInspection extends BaseJavaLocalInspectionTool {
       if (!elementsToFix.isEmpty()) performTypeMigration(elementsToFix, migrationTypes);
     }
 
-    private MigrateGuavaTypeFix getFix(ProblemDescriptor descriptor) {
+    private MigrateGuavaTypeFix getFix(CommonProblemDescriptor descriptor) {
       final QuickFix[] fixes = descriptor.getFixes();
       LOG.assertTrue(fixes != null);
       for (QuickFix fix : fixes) {
index 494cb1902fa377c5cfc06d2343c25822fd37bbb1..4b683b4ffc9a9a6b341eb462b0172ff70b1d1fd5 100644 (file)
@@ -41,13 +41,13 @@ public class AnalysisUIOptions implements PersistentStateComponent<AnalysisUIOpt
 
   public boolean AUTOSCROLL_TO_SOURCE = false;
   public float SPLITTER_PROPORTION = 0.5f;
-  public boolean GROUP_BY_SEVERITY = false;
-  public boolean FILTER_RESOLVED_ITEMS = true;
+  public volatile boolean GROUP_BY_SEVERITY = false;
+  public volatile boolean FILTER_RESOLVED_ITEMS = true;
   public boolean ANALYZE_TEST_SOURCES = true;
   public int SCOPE_TYPE = AnalysisScope.PROJECT;
   public String CUSTOM_SCOPE_NAME = "";
   private final AutoScrollToSourceHandler myAutoScrollToSourceHandler;
-  public boolean SHOW_STRUCTURE = false;
+  public volatile boolean SHOW_STRUCTURE = false;
   public String FILE_MASK;
 
   public boolean ANALYSIS_IN_BACKGROUND = true;
index 03fbfd98b25112b577bafe9064b22fbb7778f52a..607b55e0b4aabdf0c703ea59643a3dda8018e3c4 100644 (file)
@@ -828,11 +828,10 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
     }
   }
 
-  private final ConcurrentMap<String, InspectionToolPresentation> myPresentationMap = ContainerUtil.newConcurrentMap();
+  private final ConcurrentMap<InspectionToolWrapper, InspectionToolPresentation> myPresentationMap = ContainerUtil.newConcurrentMap();
   @NotNull
   public InspectionToolPresentation getPresentation(@NotNull InspectionToolWrapper toolWrapper) {
-    final String shortName = toolWrapper.getShortName();
-    InspectionToolPresentation presentation = myPresentationMap.get(shortName);
+    InspectionToolPresentation presentation = myPresentationMap.get(toolWrapper);
     if (presentation == null) {
       String presentationClass = StringUtil.notNullize(toolWrapper.myEP == null ? null : toolWrapper.myEP.presentation, DefaultInspectionToolPresentation.class.getName());
 
@@ -844,7 +843,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
         LOG.error(e);
         throw new RuntimeException(e);
       }
-      presentation = ConcurrencyUtil.cacheOrGet(myPresentationMap, shortName, presentation);
+      presentation = ConcurrencyUtil.cacheOrGet(myPresentationMap, toolWrapper, presentation);
     }
     return presentation;
   }
index 671a7bbdd45624c8ceac304465b52cc19f697161..f65ea7e6eb10dfd9e7a22bb762f2283fa4db6d93 100644 (file)
@@ -39,7 +39,7 @@ import org.jetbrains.annotations.Nullable;
 import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreePath;
 import java.util.*;
-import java.util.function.Consumer;
+import java.util.function.UnaryOperator;
 
 public abstract class InspectionRVContentProvider {
   private static final Logger LOG = Logger.getInstance("#" + InspectionRVContentProvider.class.getName());
@@ -133,7 +133,7 @@ public abstract class InspectionRVContentProvider {
                                @NotNull InspectionToolWrapper toolWrapper,
                                @NotNull Function<T, UserObjectContainer<T>> computeContainer,
                                final boolean showStructure,
-                               final Consumer<InspectionTreeNode> createdNodesConsumer) {
+                               final UnaryOperator<InspectionTreeNode> createdNodesConsumer) {
     final Map<String, Map<String, InspectionPackageNode>> module2PackageMap = new HashMap<String, Map<String, InspectionPackageNode>>();
     boolean supportStructure = showStructure;
     final MultiMap<InspectionPackageNode, UserObjectContainer<T>> packageDescriptors = new MultiMap<>();
@@ -170,6 +170,7 @@ public abstract class InspectionRVContentProvider {
             if (module != null) {
               moduleNode = new InspectionModuleNode(module);
               moduleNodes.put(moduleName, moduleNode);
+              moduleNode = (InspectionModuleNode)createdNodesConsumer.apply(moduleNode);
             }
             else { //module content was removed ?
               continue;
@@ -177,13 +178,15 @@ public abstract class InspectionRVContentProvider {
           }
           else {
             for (InspectionPackageNode packageNode : packageNodes.values()) {
-              createdNodesConsumer.accept(packageNode);
+              createdNodesConsumer.apply(packageNode);
               for (UserObjectContainer<T> container : packageDescriptors.get(packageNode)) {
                 appendDescriptor(context, toolWrapper, container, packageNode, canPackageRepeat);
               }
             }
             continue;
           }
+        } else {
+          moduleNode = (InspectionModuleNode)createdNodesConsumer.apply(moduleNode);
         }
         for (InspectionPackageNode packageNode : packageNodes.values()) {
           if (packageNode.getPackageName() != null) {
@@ -198,7 +201,6 @@ public abstract class InspectionRVContentProvider {
             }
           }
         }
-        createdNodesConsumer.accept(moduleNode);
       }
     }
     else {
@@ -214,7 +216,7 @@ public abstract class InspectionRVContentProvider {
           }
           for (TreeNode childNode: childNodes) {
             if (childNode instanceof ProblemDescriptionNode) {
-              createdNodesConsumer.accept(pNode);
+              createdNodesConsumer.apply(pNode);
               break;
             }
             LOG.assertTrue(childNode instanceof RefElementNode, childNode.getClass().getName());
@@ -234,7 +236,7 @@ public abstract class InspectionRVContentProvider {
                 parentNodes.add((RefElementNode)grandChildNode);
               }
               if (!hasElementNodeUnder) {
-                createdNodesConsumer.accept(elementNode);
+                createdNodesConsumer.apply(elementNode);
                 continue;
               }
             }
@@ -256,7 +258,7 @@ public abstract class InspectionRVContentProvider {
               }
             }
             for (RefElementNode node : parentNodes) {
-              createdNodesConsumer.accept(node);
+              createdNodesConsumer.apply(node);
             }
           }
         }
@@ -315,7 +317,7 @@ public abstract class InspectionRVContentProvider {
   }
 
   @SuppressWarnings({"ConstantConditions"}) //class cast suppression
-  protected static void merge(InspectionTreeNode child, InspectionTreeNode parent, boolean merge) {
+  protected static InspectionTreeNode merge(InspectionTreeNode child, InspectionTreeNode parent, boolean merge) {
     if (merge) {
       for (int i = 0; i < parent.getChildCount(); i++) {
         InspectionTreeNode current = (InspectionTreeNode)parent.getChildAt(i);
@@ -325,31 +327,31 @@ public abstract class InspectionRVContentProvider {
         if (current instanceof InspectionPackageNode) {
           if (((InspectionPackageNode)current).getPackageName().compareTo(((InspectionPackageNode)child).getPackageName()) == 0) {
             processDepth(child, current);
-            return;
+            return current;
           }
         }
         else if (current instanceof RefElementNode) {
           if (((RefElementNode)current).getElement().getName().compareTo(((RefElementNode)child).getElement().getName()) == 0 &&
               ((RefElementNode)current).getElement().getQualifiedName().compareTo(((RefElementNode)child).getElement().getQualifiedName()) == 0) {
             processDepth(child, current);
-            return;
+            return current;
           }
         }
         else if (current instanceof InspectionNode) {
           if (((InspectionNode)current).getToolWrapper().getShortName().compareTo(((InspectionNode)child).getToolWrapper().getShortName()) == 0) {
             processDepth(child, current);
-            return;
+            return current;
           }
         }
         else if (current instanceof InspectionModuleNode) {
           if (((InspectionModuleNode)current).getName().compareTo(((InspectionModuleNode)child).getName()) == 0) {
             processDepth(child, current);
-            return;
+            return current;
           }
         }
       }
     }
-    parent.insertByOrder(child, false);
+    return parent.insertByOrder(child, false);
   }
 
   private static void processDepth(final InspectionTreeNode child, final InspectionTreeNode current) {
index c62e5913bac499fefee67cfd30d5ef0cd62bd59d..73e38eb3f92310d72a460b71cd0344c2eb400c38 100644 (file)
@@ -29,7 +29,6 @@ import com.intellij.codeInspection.reference.SmartRefElementPointer;
 import com.intellij.codeInspection.ui.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
-import com.intellij.util.Function;
 import com.intellij.util.containers.HashSet;
 import com.intellij.util.ui.tree.TreeUtil;
 import org.jetbrains.annotations.NotNull;
@@ -114,10 +113,12 @@ public class OfflineInspectionRVContentProvider extends InspectionRVContentProvi
     InspectionToolWrapper toolWrapper = toolNode.getToolWrapper();
     final Map<String, Set<OfflineProblemDescriptor>> filteredContent = getFilteredContent(context, toolWrapper);
     if (filteredContent != null && !filteredContent.values().isEmpty()) {
-      final Function<OfflineProblemDescriptor, UserObjectContainer<OfflineProblemDescriptor>> computeContainer =
-        descriptor -> new OfflineProblemDescriptorContainer(descriptor);
       parentNode.add(toolNode);
-      buildTree(context, filteredContent, false, toolWrapper, computeContainer, showStructure, toolNode::add);
+      buildTree(context, filteredContent, false, toolWrapper, OfflineProblemDescriptorContainer::new, showStructure,
+                (newChild) -> {
+                  toolNode.add(newChild);
+                  return newChild;
+                });
     }
   }
 
index d9ffb038218f00b2171951985177253baa4ba03c..dc5a4bfd9f6d1b26767bef64cc1e848524939998 100644 (file)
@@ -584,9 +584,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
     myProvider.appendToolNodeContent(myGlobalInspectionContext, toolNode, parentNode, showStructure);
     InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(toolWrapper);
     toolNode = presentation.createToolNode(myGlobalInspectionContext, toolNode, myProvider, parentNode, showStructure);
-    synchronized (getTreeStructureUpdateLock()) {
-      ((DefaultInspectionToolPresentation)presentation).setToolNode(toolNode);
-    }
+    ((DefaultInspectionToolPresentation)presentation).setToolNode(toolNode);
     registerActionShortcuts(presentation);
     return toolNode;
   }
@@ -630,9 +628,27 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
 
   public void update() {
     ApplicationManager.getApplication().assertIsDispatchThread();
-    myTree.removeAllNodes();
-    mySeverityGroupNodes.clear();
-    buildTree();
+    final Application app = ApplicationManager.getApplication();
+    final Runnable buildAction = () -> {
+      try {
+        setUpdating(true);
+        synchronized (getTreeStructureUpdateLock()) {
+          mySeverityGroupNodes.clear();
+          myGroups.clear();
+          myTree.removeAllNodes();
+          addTools(myGlobalInspectionContext.getTools().values());
+        }
+      }
+      finally {
+        setUpdating(false);
+        UIUtil.invokeLaterIfNeeded(() -> myTree.restoreExpansionAndSelection(false));
+      }
+    };
+    if (app.isUnitTestMode()) {
+      buildAction.run();
+    } else {
+      app.executeOnPooledThread(() -> app.runReadAction(buildAction));
+    }
   }
 
   public void setUpdating(boolean isUpdating) {
@@ -669,46 +685,27 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
   }
 
   public void addTools(Collection<Tools> tools) {
-    InspectionProfileImpl profile = (InspectionProfileImpl)myInspectionProfile;
-    boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY;
-    boolean singleInspectionRun = myGlobalInspectionContext.isSingleInspectionRun();
-    for (Tools currentTools : tools) {
-      InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool();
-      if (myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS && myExcludedInspectionTreeNodesManager.containsInspectionNode(defaultToolWrapper)) {
-        continue;
-      }
-      final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName());
-      for (ScopeToolState state : myProvider.getTools(currentTools)) {
-        InspectionToolWrapper toolWrapper = state.getTool();
-        if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) {
-          addTool(toolWrapper,
-                  profile.getErrorLevel(key, state.getScope(myProject), myProject),
-                  isGroupedBySeverity,
-                  singleInspectionRun);
+    synchronized (myTreeStructureUpdateLock) {
+      InspectionProfileImpl profile = (InspectionProfileImpl)myInspectionProfile;
+      boolean isGroupedBySeverity = myGlobalInspectionContext.getUIOptions().GROUP_BY_SEVERITY;
+      boolean singleInspectionRun = myGlobalInspectionContext.isSingleInspectionRun();
+      for (Tools currentTools : tools) {
+        InspectionToolWrapper defaultToolWrapper = currentTools.getDefaultState().getTool();
+        if (myGlobalInspectionContext.getUIOptions().FILTER_RESOLVED_ITEMS &&
+            myExcludedInspectionTreeNodesManager.containsInspectionNode(defaultToolWrapper)) {
+          continue;
         }
-      }
-    }
-  }
-
-  public void buildTree() {
-    final Application app = ApplicationManager.getApplication();
-    final Runnable buildAction = () -> {
-      try {
-        setUpdating(true);
-        synchronized (getTreeStructureUpdateLock()) {
-          myGroups.clear();
-          addTools(myGlobalInspectionContext.getTools().values());
+        final HighlightDisplayKey key = HighlightDisplayKey.find(defaultToolWrapper.getShortName());
+        for (ScopeToolState state : myProvider.getTools(currentTools)) {
+          InspectionToolWrapper toolWrapper = state.getTool();
+          if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) {
+            addTool(toolWrapper,
+                    profile.getErrorLevel(key, state.getScope(myProject), myProject),
+                    isGroupedBySeverity,
+                    singleInspectionRun);
+          }
         }
       }
-      finally {
-        setUpdating(false);
-        UIUtil.invokeLaterIfNeeded(() -> myTree.restoreExpansionAndSelection(null));
-      }
-    };
-    if (app.isUnitTestMode()) {
-      buildAction.run();
-    } else {
-      app.executeOnPooledThread(() -> app.runReadAction(buildAction));
     }
   }
 
index bf4179b1cecc55b8c5f6e245b5570bcc51be8a6c..18cb0ae7d7068b318b865e6cdc11dc3b2304c33b 100644 (file)
@@ -32,11 +32,9 @@ import com.intellij.codeInspection.offlineViewer.OfflineRefElementNode;
 import com.intellij.codeInspection.reference.RefElement;
 import com.intellij.codeInspection.reference.RefEntity;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeComparator;
-import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiNamedElement;
 import com.intellij.psi.PsiQualifiedNamedElement;
@@ -94,7 +92,7 @@ public class InspectionResultsViewComparator implements Comparator {
       final OfflineProblemDescriptor descriptor1 = (OfflineProblemDescriptor)userObject1;
       final OfflineProblemDescriptor descriptor2 = (OfflineProblemDescriptor)userObject2;
       if (descriptor1.getLine() != descriptor2.getLine()) return descriptor1.getLine() - descriptor2.getLine();
-      return descriptor1.getFQName().compareTo(descriptor2.getFQName());
+      return descriptor1.getFQName().compareToIgnoreCase(descriptor2.getFQName());
     }
 
     if (node1 instanceof RefElementNode && node2 instanceof RefElementNode){   //sort by filename and inside file by start offset
index 04add1887b5dd431f7798b023fab81a82acb0f4e..4920287b1911922015a90dd4847fcdae8c8a0e59 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ex.GlobalInspectionContextImpl;
 import com.intellij.codeInspection.ex.InspectionToolWrapper;
 import com.intellij.codeInspection.reference.RefEntity;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -105,7 +106,7 @@ public class InspectionTree extends Tree {
 
   public void removeAllNodes() {
     getRoot().removeAllChildren();
-    nodeStructureChanged(getRoot());
+    ApplicationManager.getApplication().invokeLater(() -> nodeStructureChanged(getRoot()));
   }
 
   public InspectionTreeNode getRoot() {
@@ -378,8 +379,8 @@ public class InspectionTree extends Tree {
     ((InspectionRootNode) getRoot()).getUpdater().update(null, true);
   }
 
-  public void restoreExpansionAndSelection(@Nullable InspectionTreeNode reloadedNode) {
-    myState.restoreExpansionAndSelection(this, reloadedNode);
+  public void restoreExpansionAndSelection(boolean treeNodesMightChange) {
+    myState.restoreExpansionAndSelection(this, treeNodesMightChange);
   }
 
   public void setState(@NotNull InspectionTreeState state) {
index ab130e12a6a9c70c64aced569992b8006bd25f00..47a52f4cd983e01a48da806608dcbc21835f4412 100644 (file)
@@ -100,15 +100,19 @@ public abstract class InspectionTreeNode extends DefaultMutableTreeNode {
     }
   }
 
-  public void insertByOrder(InspectionTreeNode child, boolean allowDuplication) {
-    if (!allowDuplication && getIndex(child) != -1) {
-      return;
+  public InspectionTreeNode insertByOrder(InspectionTreeNode child, boolean allowDuplication) {
+    if (!allowDuplication) {
+      int index = getIndex(child);
+      if (index != -1) {
+        return (InspectionTreeNode)getChildAt(index);
+      }
     }
-    final int i = TreeUtil.indexedBinarySearch(this, child, InspectionResultsViewComparator.getInstance());
-    if (!allowDuplication && i >= 0){
-      return;
+    int index = TreeUtil.indexedBinarySearch(this, child, InspectionResultsViewComparator.getInstance());
+    if (!allowDuplication && index >= 0){
+      return (InspectionTreeNode)getChildAt(index);
     }
-    insert(child, Math.abs(i + 1));
+    insert(child, Math.abs(index + 1));
+    return child;
   }
 
   @Override
index 90f804f5adbb7a232e743962f3129cccfea112f5..330dc5d1b36dadfedb32e2f9093fa7cd5f8de8f3 100644 (file)
 package com.intellij.codeInspection.ui;
 
 import com.intellij.util.ui.tree.TreeUtil;
-import org.jetbrains.annotations.NotNull;
 
 import javax.swing.tree.TreeNode;
 import javax.swing.tree.TreePath;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * @author Dmitry Batkovich
@@ -37,26 +39,15 @@ public class InspectionTreeState {
     mySelectionPath = new InspectionTreeSelectionPath(selectionPath);
   }
 
-  public void restoreExpansionAndSelection(InspectionTree tree, InspectionTreeNode reloadedNode) {
+  public void restoreExpansionAndSelection(InspectionTree tree, boolean treeNodeMightChange) {
     restoreExpansionStatus((InspectionTreeNode)tree.getModel().getRoot(), tree);
     if (mySelectionPath != null) {
-      if (reloadedNode == null || needRestore(reloadedNode)) {
-        mySelectionPath.restore(tree);
-      }
+      mySelectionPath.restore(tree, treeNodeMightChange);
     } else {
       TreeUtil.selectFirstNode(tree);
     }
   }
 
-  private boolean needRestore(@NotNull InspectionTreeNode node) {
-    for (Object o : mySelectionPath.myPath) {
-      if (InspectionResultsViewComparator.getInstance().areEqual((InspectionTreeNode)o, node)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
   private void restoreExpansionStatus(InspectionTreeNode node, InspectionTree tree) {
     if (getExpandedUserObjects().contains(node.getUserObject())) {
       //sortChildren(node);
@@ -94,33 +85,30 @@ public class InspectionTreeState {
       return idx;
     }
 
-    public void restore(InspectionTree tree) {
+    public void restore(InspectionTree tree, boolean treeNodeMightChange) {
       tree.getSelectionModel().removeSelectionPaths(tree.getSelectionModel().getSelectionPaths());
-      TreeUtil.selectPath(tree, restorePath(tree));
+      TreeUtil.selectPath(tree, restorePath(tree, treeNodeMightChange));
     }
 
-    private TreePath restorePath(InspectionTree tree) {
+    private TreePath restorePath(InspectionTree tree, boolean treeNodeMightChange) {
       ArrayList<Object> newPath = new ArrayList<Object>();
 
       newPath.add(tree.getModel().getRoot());
-      restorePath(newPath, 1);
+      restorePath(newPath, 1, treeNodeMightChange);
       return new TreePath(newPath.toArray());
     }
 
-    private void restorePath(ArrayList<Object> newPath, int idx) {
+    private void restorePath(ArrayList<Object> newPath, int idx, boolean treeNodeMightChange) {
       if (idx >= myPath.length) return;
       InspectionTreeNode oldNode = (InspectionTreeNode)myPath[idx];
-
       InspectionTreeNode newRoot = (InspectionTreeNode)newPath.get(idx - 1);
 
-
-      InspectionResultsViewComparator comparator = InspectionResultsViewComparator.getInstance();
       Enumeration children = newRoot.children();
       while (children.hasMoreElements()) {
         InspectionTreeNode child = (InspectionTreeNode)children.nextElement();
-        if (comparator.areEqual(child, oldNode)) {
+        if (treeNodeMightChange ? InspectionResultsViewComparator.getInstance().areEqual(child, oldNode) : child == oldNode) {
           newPath.add(child);
-          restorePath(newPath, idx + 1);
+          restorePath(newPath, idx + 1, treeNodeMightChange);
           return;
         }
       }
index 8720e9e89e0dd2862c5ed449db3940e4be149541..e6f099c90428cdd09b071313ec1a57b4c5550c94 100644 (file)
@@ -61,7 +61,7 @@ public class InspectionTreeUpdater {
       try {
         tree.setQueueUpdate(true);
         ((DefaultTreeModel)tree.getModel()).reload();
-        tree.restoreExpansionAndSelection(tree.getRoot());
+        tree.restoreExpansionAndSelection(true);
         myView.openRightPanelIfNeed();
         if (myDoUpdatePreviewPanel.compareAndSet(true, false)) {
           myView.updateRightPanelLoading();
index 5f4acef71be1ac2e2dd44cac7cc0b6e65def6cbf..e8c8be6f9c7228e9e689dc7b8987ffd1c7004a78 100644 (file)
@@ -43,7 +43,7 @@ public class PropertyKeyIndex extends StringStubIndexExtension<Property> {
   }
 
   @Override
-  public Collection<Property> get(@NotNull String s, @NotNull Project project, @NotNull GlobalSearchScope scope) {
-    return StubIndex.getElements(getKey(), s, project, scope, Property.class);
+  public Collection<Property> get(@NotNull String key, @NotNull Project project, @NotNull GlobalSearchScope scope) {
+    return StubIndex.getElements(getKey(), key, project, scope, Property.class);
   }
 }
index f82ee002303f91edc0261857c3a375790ff3f952..719efb7330d8d1b2499fc7b9c292eaaaebca5adf 100644 (file)
@@ -31,6 +31,9 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.TokenType;
 import com.intellij.psi.impl.source.tree.ChangeUtil;
 import com.intellij.psi.impl.source.tree.TreeElement;
+import com.intellij.psi.stubs.PsiFileStub;
+import com.intellij.psi.stubs.StubElement;
+import com.intellij.psi.stubs.StubTree;
 import com.intellij.psi.tree.TokenSet;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
@@ -42,6 +45,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile {
   private static final Logger LOG = Logger.getInstance(PropertiesFileImpl.class);
@@ -79,15 +83,29 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile {
 
   private void ensurePropertiesLoaded() {
     if (myPropertiesMap != null) return;
-
-    final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES);
+    final StubTree stubTree = getStubTree();
+    List<IProperty> properties;
     MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>();
-    List<IProperty> properties = new ArrayList<IProperty>(props.length);
-    for (final ASTNode prop : props) {
-      final Property property = (Property)prop.getPsi();
-      String key = property.getUnescapedKey();
-      propertiesMap.add(key, property);
-      properties.add(property);
+    if (stubTree != null) {
+      final PsiFileStub root = stubTree.getRoot();
+      final StubElement propertiesList = root.findChildStubByType(PropertiesElementTypes.PROPERTIES_LIST);
+      if (propertiesList != null) {
+        properties = Arrays.stream(propertiesList.getChildrenByType(PropertiesElementTypes.PROPERTY, Property[]::new))
+          .map(IProperty.class::cast)
+          .peek(p -> propertiesMap.add(p.getKey(), p))
+          .collect(Collectors.toList());
+      } else {
+        properties = Collections.emptyList();
+      }
+    } else {
+      final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES);
+      properties = new ArrayList<IProperty>(props.length);
+      for (final ASTNode prop : props) {
+        final Property property = (Property)prop.getPsi();
+        String key = property.getUnescapedKey();
+        propertiesMap.add(key, property);
+        properties.add(property);
+      }
     }
     final boolean isAlphaSorted = PropertiesImplUtil.isAlphaSorted(properties);
     synchronized (lock) {
index 4fa9af17903064723512f9f5ad3cfc6d122010c4..a40aae8b900a321e5da6689b06f0200101d44765 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.lang.ASTNode;
 import com.intellij.lang.properties.parsing.PropertiesElementTypes;
 import com.intellij.lang.properties.psi.PropertiesList;
 import com.intellij.lang.properties.psi.PropertiesListStub;
+import com.intellij.psi.PsiElement;
 
 /**
  * @author max
@@ -35,4 +36,9 @@ public class PropertiesListImpl extends PropertiesStubElementImpl<PropertiesList
   public String toString() {
     return "PropertiesList";
   }
+
+  @Override
+  public PsiElement getParent() {
+    return getParentByStub();
+  }
 }
index 4fe5ce2f8e8dec6a834f22f5f924321cc0e303cc..92aa1eb9ad8575d3b47946386819fc8fc8806698 100644 (file)
@@ -32,7 +32,7 @@ public class PropertiesPsiCompletionUtil {
                                          final PropertiesFile propertiesFile,
                                          final Set<Object> variants) {
     if (propertiesFile == null) return;
-    if (!ProjectRootManager.getInstance(propertyReference.getElement().getProject()).getFileIndex().isInContent(propertiesFile.getVirtualFile())) return;
+    if (!ProjectRootManager.getInstance(propertiesFile.getProject()).getFileIndex().isInContent(propertiesFile.getVirtualFile())) return;
     List<? extends IProperty> properties = propertiesFile.getProperties();
     for (IProperty property : properties) {
       propertyReference.addKey(property, variants);
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertyStubElementType.java b/plugins/properties/properties-psi-impl/src/com/intellij/properties/PropertyStubElementType.java
deleted file mode 100644 (file)
index 56c65dc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- */
-
-/*
- * @author max
- */
-package com.intellij.properties;
-
-import com.intellij.lang.properties.parsing.PropertiesElementTypes;
-import com.intellij.lang.properties.psi.Property;
-import com.intellij.lang.properties.psi.PropertyKeyIndex;
-import com.intellij.lang.properties.psi.PropertyStub;
-import com.intellij.lang.properties.psi.impl.PropertyImpl;
-import com.intellij.lang.properties.psi.impl.PropertyStubImpl;
-import com.intellij.psi.stubs.*;
-import com.intellij.util.io.StringRef;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.IOException;
-
-public class PropertyStubElementType extends IStubElementType<PropertyStub, Property> {
-  public PropertyStubElementType() {
-    super("PROPERTY", PropertiesElementTypes.LANG);
-  }
-
-  public Property createPsi(@NotNull final PropertyStub stub) {
-    return new PropertyImpl(stub, this);
-  }
-
-  public PropertyStub createStub(@NotNull final Property psi, final StubElement parentStub) {
-    return new PropertyStubImpl(parentStub, psi.getKey());
-  }
-
-  @NotNull
-  public String getExternalId() {
-    return "properties.prop";
-  }
-
-  public void serialize(@NotNull final PropertyStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
-    dataStream.writeName(stub.getKey());
-  }
-
-  @NotNull
-  public PropertyStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
-    final StringRef ref = dataStream.readName();
-    return new PropertyStubImpl(parentStub, ref.getString());
-  }
-
-  public void indexStub(@NotNull final PropertyStub stub, @NotNull final IndexSink sink) {
-    sink.occurrence(PropertyKeyIndex.KEY, PropertyImpl.unescape(stub.getKey()));
-  }
-}
\ No newline at end of file