Merge branch 'da/dumb_run'
authorDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Wed, 23 Aug 2017 15:52:55 +0000 (18:52 +0300)
committerDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Wed, 23 Aug 2017 15:52:55 +0000 (18:52 +0300)
# Conflicts:
# platform/lang-api/src/com/intellij/execution/configurations/ConfigurationType.java

platform/lang-api/src/com/intellij/execution/configurations/ConfigurationType.java
platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java
xml/impl/src/com/intellij/codeInsight/completion/XmlTagInsertHandler.java

index a5cb4e8f9b73c71668895fc510506e91eff218a9..3d4dafce07e2f9f303d356b79efd7a9e832bc5b3 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.execution.configurations;
 
 import com.intellij.openapi.extensions.ExtensionPointName;
 import org.jetbrains.annotations.Nls;
+import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.PossiblyDumbAware;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -76,6 +77,6 @@ public interface ConfigurationType extends PossiblyDumbAware {
 
   @Override
   default boolean isDumbAware() {
-    return false;
+    return this instanceof DumbAware;
   }
 }
\ No newline at end of file
index 24ea23b6792152dc81c2a830fd67f8f2dac64913..9e0c086220ce7f53e1e003d78201b278985c83ad 100644 (file)
@@ -201,6 +201,7 @@ class LookupUi {
     });
   }
 
+  long time = 0;
   void setCalculating(final boolean calculating) {
     Runnable setVisible = () -> myIconPanel.setVisible(myLookup.isCalculating());
     if (myLookup.isCalculating()) {
@@ -210,9 +211,14 @@ class LookupUi {
     }
 
     if (calculating) {
+      if (time == 0) {
+        time = System.currentTimeMillis();
+      }
       myProcessIcon.resume();
     } else {
       myProcessIcon.suspend();
+      System.err.println("completion took " + (System.currentTimeMillis() - time) + "ms");
+      time = 0;
     }
   }
 
index c2d6dd1b50100bd46d50c743dd45dbc77ea857df..15fb4213f575fb5c3b96be528cf43857da8c1535 100644 (file)
@@ -43,6 +43,9 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.formatter.xml.XmlCodeStyleSettings;
 import com.intellij.psi.html.HtmlTag;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -54,6 +57,7 @@ import com.intellij.xml.actions.GenerateXmlTagAction;
 import com.intellij.xml.impl.schema.XmlElementDescriptorImpl;
 import com.intellij.xml.util.HtmlUtil;
 import com.intellij.xml.util.XmlUtil;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.*;
@@ -295,7 +299,7 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
       }
     }
     else if (completionChar == '/') {
-      template.addTextSegment("/>");
+      template.addTextSegment(closeTag(tag));
     }
     else if (completionChar == ' ' && template.getSegmentsCount() == 0) {
       if (WebEditorOptions.getInstance().isAutomaticallyStartAttribute() &&
@@ -306,7 +310,7 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
     }
     else if (completionChar == Lookup.AUTO_INSERT_SELECT_CHAR || completionChar == Lookup.NORMAL_SELECT_CHAR || completionChar == Lookup.REPLACE_SELECT_CHAR) {
       if (WebEditorOptions.getInstance().isAutomaticallyInsertClosingTag() && isHtmlCode && HtmlUtil.isSingleHtmlTag(tag.getName())) {
-        template.addTextSegment(HtmlUtil.isHtmlTag(tag) ? ">" : "/>");
+        template.addTextSegment(HtmlUtil.isHtmlTag(tag) ? ">" : closeTag(tag));
       }
       else {
         if (needAlLeastOneAttribute(tag) && WebEditorOptions.getInstance().isAutomaticallyStartAttribute() && tag.getAttributes().length == 0
@@ -323,6 +327,15 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
     return false;
   }
 
+  @NotNull
+  private static String closeTag(XmlTag tag) {
+    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(tag.getProject());
+    boolean html = HtmlUtil.isHtmlTag(tag);
+    boolean needsSpace = (html && settings.HTML_SPACE_INSIDE_EMPTY_TAG) ||
+                         (!html && settings.getCustomSettings(XmlCodeStyleSettings.class).XML_SPACE_INSIDE_EMPTY_TAG);
+    return needsSpace ? " />" : "/>";
+  }
+
   private static void completeAttribute(Template template, boolean htmlCode) {
     template.addTextSegment(" ");
     template.addVariable(new MacroCallNode(new CompleteMacro()), true);
@@ -381,7 +394,7 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
         return;
       case XmlElementDescriptor.CONTENT_TYPE_EMPTY:
         if (completeIt) {
-          template.addTextSegment("/>");
+          template.addTextSegment(closeTag(context));
         }
         break;
       case XmlElementDescriptor.CONTENT_TYPE_MIXED: