Merge branch 'master' into develar/pwd
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 27 Jul 2016 09:26:29 +0000 (11:26 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 27 Jul 2016 09:26:29 +0000 (11:26 +0200)
69 files changed:
.idea/libraries/Guava.xml
.idea/libraries/guava_tools.xml [deleted file]
bin/scripts/win/format.bat [new file with mode: 0644]
build/groovy/org/jetbrains/intellij/build/CommunityLibraryLicenses.groovy
build/lib/launcher-generator.jar
build/scripts/layouts.gant
java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
java/debugger/impl/src/com/intellij/debugger/ui/tree/render/CachedEvaluator.java
java/java-tests/testSrc/com/intellij/codeInspection/StaticPseudoFunctionalStyleMethodTest.java
java/typeMigration/test/com/intellij/codeInsight/inspections/GuavaInspectionTest.java
json/src/com/jetbrains/jsonSchema/JsonSchemaFileTypeFactory.java
json/tests/test/com/jetbrains/jsonSchema/JsonSchemaCrossReferencesTest.java
lib/guava-17.0.jar [deleted file]
lib/guava-19.0.jar [new file with mode: 0644]
lib/required_for_dist.txt
lib/src/guava-17.0-sources.jar [deleted file]
lib/src/guava-19.0-sources.jar [new file with mode: 0644]
platform/core-api/src/com/intellij/psi/templateLanguages/TemplateLanguageUtil.java
platform/core-impl/core-impl.iml
platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/core-impl/src/com/intellij/psi/impl/source/tree/AstPath.java
platform/editor-ui-api/src/com/intellij/ide/ui/AntialiasingType.java
platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java
platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java
platform/lang-impl/src/com/intellij/codeInsight/template/impl/actions/ListTemplatesAction.java
platform/lang-impl/src/com/intellij/codeInsight/template/postfix/templates/PostfixLiveTemplate.java
platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java
platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewComparator.java
platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java
platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java
platform/lang-impl/src/com/intellij/formatting/commandLine/FileSetProcessor.java
platform/lang-impl/src/com/intellij/formatting/commandLine/FormatterStarter.java
platform/lang-impl/src/com/intellij/ide/scratch/ScratchFileServiceImpl.java
platform/lang-impl/src/com/intellij/lang/javascript/boilerplate/GithubTagListProvider.java
platform/lang-impl/src/com/intellij/psi/search/PredefinedSearchScopeProviderImpl.java
platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataElementType.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
platform/platform-api/src/com/intellij/openapi/ui/ComboBox.java
platform/platform-api/src/com/intellij/util/ui/BaseButtonBehavior.java
platform/platform-api/src/com/intellij/util/ui/TimedDeadzone.java
platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java
platform/platform-resources/src/META-INF/LangExtensions.xml
plugins/github/src/META-INF/plugin.xml
plugins/github/src/org/jetbrains/plugins/github/GithubOpenCommitInBrowserFromAnnotateAction.java [moved from plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java with 92% similarity]
plugins/github/src/org/jetbrains/plugins/github/GithubOpenInBrowserAction.java
plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java [deleted file]
plugins/github/src/org/jetbrains/plugins/github/extensions/GithubAnnotationGutterActionProvider.java
plugins/java-decompiler/engine/java-decompiler-engine.iml
plugins/java-decompiler/engine/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java
plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/LoggerConfigPropertyUsageProvider.java [new file with mode: 0644]
plugins/properties/src/META-INF/plugin.xml
plugins/settings-repository/src/IcsManager.kt
plugins/settings-repository/testSrc/GitTest.kt
python/educational-core/course-creator/course-creator.iml
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/ui/CCCreateAnswerPlaceholderDialog.java
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/ui/CCCreateAnswerPlaceholderPanel.java
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/StepicAdaptiveReactionsPanel.java
python/src/com/jetbrains/python/inspections/PyMissingConstructorInspection.java
python/testData/inspections/PyMissingConstructorInspection/explicitDunderClass.py [moved from python/testData/inspections/PyMissingConstructorInspection/dunderClass.py with 100% similarity]
python/testData/inspections/PyMissingConstructorInspection/implicitDunderClass.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/inspections/PyMissingConstructorTest.java
tools/launcher-generator/.idea/artifacts/launcher_generator_jar.xml
tools/launcher-generator/.idea/libraries/guava.xml [deleted file]
tools/launcher-generator/.idea/misc.xml
tools/launcher-generator/launcher-generator.iml
tools/launcher-generator/src/com/pme/launcher/LauncherGenerator.java
xml/impl/src/com/intellij/codeInsight/editorActions/XmlTagNameSynchronizer.java

index 5b480ad0d65a3890678bdc5d3c009087ae3ab7dd..3ca41301e3d2693eb3c8aec94829014e7045c311 100644 (file)
@@ -1,11 +1,11 @@
 <component name="libraryTable">
   <library name="Guava">
     <CLASSES>
-      <root url="jar://$PROJECT_DIR$/lib/guava-17.0.jar!/" />
+      <root url="jar://$PROJECT_DIR$/lib/guava-19.0.jar!/" />
     </CLASSES>
     <JAVADOC />
     <SOURCES>
-      <root url="jar://$PROJECT_DIR$/lib/src/guava-17.0-sources.jar!/" />
+      <root url="jar://$PROJECT_DIR$/lib/src/guava-19.0-sources.jar!/" />
     </SOURCES>
   </library>
 </component>
\ No newline at end of file
diff --git a/.idea/libraries/guava_tools.xml b/.idea/libraries/guava_tools.xml
deleted file mode 100644 (file)
index b492cf4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<component name="libraryTable">
-  <library name="guava-tools">
-    <CLASSES>
-      <root url="jar://$PROJECT_DIR$/lib/guava-17.0.jar!/" />
-    </CLASSES>
-    <JAVADOC />
-    <SOURCES>
-      <root url="jar://$PROJECT_DIR$/lib/src/guava-17.0-sources.jar!/" />
-    </SOURCES>
-  </library>
-</component>
\ No newline at end of file
diff --git a/bin/scripts/win/format.bat b/bin/scripts/win/format.bat
new file mode 100644 (file)
index 0000000..2ddcbd2
--- /dev/null
@@ -0,0 +1,10 @@
+@ECHO OFF
+
+::----------------------------------------------------------------------
+:: @@product_full@@ formatting script.
+::----------------------------------------------------------------------
+
+SET DEFAULT_PROJECT_PATH=%CD%
+
+SET IDE_BIN_DIR=%~dp0
+CALL "%IDE_BIN_DIR%\@@script_name@@" format %*
index 75c853218d12cad6246ff17199f7ff6497bf6485..d1d98336339b5cda81a6064cd8c4bfb941911e46 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000-2016 JetBrains s.r.o.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");,
+ * 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
  *
@@ -123,9 +123,7 @@ class CommunityLibraryLicenses {
                    licenseUrl: "http://www.gnu.org/licenses/lgpl-2.1.txt"),
     libraryLicense(name: "Groovy", version: "2.4.6", license: "Apache 2.0", url: "http://groovy-lang.org/"),
     libraryLicense(name: "Gson", version: "2.2.4", libraryName: "gson", license: "Apache 2.0", url: "http://code.google.com/p/google-gson/"),
-    libraryLicense(name: "Guava", libraryName: "guava-tools", version: "14.0.1", license: "Apache 2.0",
-                   url: "http://code.google.com/p/guava-libraries/", licenseUrl: "http://ant.apache.org/license.html"),
-    libraryLicense(name: "Guava", version: "17.0", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/",
+    libraryLicense(name: "Guava", version: "19.0", license: "Apache 2.0", url: "http://code.google.com/p/guava-libraries/",
                    licenseUrl: "http://ant.apache.org/license.html"),
     libraryLicense(name: "hamcrest", version: "1.3", license: "BSD", url: "http://hamcrest.org/",
                    licenseUrl: "http://opensource.org/licenses/BSD-3-Clause"),
index 7a1574d1017629115dbb80cb9ed1106cc78edda7..445d1b1769ada01917eb14446de58abca3173713 100644 (file)
Binary files a/build/lib/launcher-generator.jar and b/build/lib/launcher-generator.jar differ
index 4aac9d4f52b68c33159eace68be888b049292952..3729f8371fe0344e0ad76b0fe9b65e4e62c394fb 100644 (file)
  * limitations under the License.
  */
 
+
 import org.jetbrains.intellij.build.BuildContext
 import org.jetbrains.intellij.build.BuildOptions
 import org.jetbrains.intellij.build.BuildTasks
 import org.jetbrains.intellij.build.IdeaCommunityProperties
-import org.jetbrains.jps.model.module.JpsModule
 import org.jetbrains.jps.util.JpsPathUtil
 
 import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
@@ -952,7 +952,7 @@ def layout_core(String home, String target) {
     }
 
     fileset(dir: "$home/lib") {
-      include(name: "guava-17.0.jar")
+      include(name: "guava-19.0.jar")
       include(name: "picocontainer.jar")
       include(name: "trove4j.jar")
       include(name: "cli-parser-1.1.jar")
index 7ee567d0d4df69e8cf724003f3e3a08634317d06..122e5a314fbcafb80bb00ad9aa11866e9620516c 100644 (file)
@@ -1971,12 +1971,16 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
                 }
               }
               else {
+                ProcessHandler processHandler = getProcessHandler();
+                boolean terminated =
+                  processHandler != null && (processHandler.isProcessTerminating() || processHandler.isProcessTerminated());
+
                 fail();
                 DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
                   // propagate exception only in case we succeeded to obtain execution result,
                   // otherwise if the error is induced by the fact that there is nothing to debug, and there is no need to show
                   // this problem to the user
-                  if (myExecutionResult != null || !connectorIsReady.get()) {
+                  if ((myExecutionResult != null && !terminated) || !connectorIsReady.get()) {
                     ExecutionUtil.handleExecutionError(myProject, ToolWindowId.DEBUG, sessionName, e);
                   }
                 });
index 680bca874f009bb9e7d09ef18f5c7a3d85bce753..3f9a90bd85d1a343d0eb80e05395388732245f68 100644 (file)
@@ -925,7 +925,7 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
                                       DebugProcessImpl process) {
     PsiClass containingClass = psiMethod.getContainingClass();
     try {
-      return containingClass != null && Objects.equals(containingClass.getQualifiedName(), className) &&
+      return containingClass != null && Objects.equals(JVMNameUtil.getClassVMName(containingClass), className) &&
              JVMNameUtil.getJVMMethodName(psiMethod).equals(name) &&
              JVMNameUtil.getJVMSignature(psiMethod).getName(process).equals(signature);
     }
index 224e78431161ab74122d3942da4e8d278b1a7d8a..fc3100126dfc20b1dafb66cb4b518b280ac4094c 100644 (file)
@@ -76,6 +76,9 @@ public abstract class CachedEvaluator {
       }
       else {
         contextClass = DebuggerUtils.findClass(className, project, GlobalSearchScope.allScope(project));
+        if (contextClass != null) {
+          contextClass = (PsiClass)contextClass.getNavigationElement();
+        }
         if (contextClass instanceof PsiCompiledElement) {
           contextClass = (PsiClass)((PsiCompiledElement)contextClass).getMirror();
         }
index c0d1432004474f886229405141b1518e2f078547..97728d5efa58fdf1b72ddbe4bee2819e06898a26 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -20,16 +20,10 @@ import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInspection.ex.QuickFixWrapper;
 import com.intellij.codeInspection.java18StreamApi.StaticPseudoFunctionalStyleMethodInspection;
 import com.intellij.openapi.application.PathManager;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.testFramework.IdeaTestUtil;
 import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
 import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
-import com.intellij.util.PathUtil;
-import com.intellij.util.Processor;
 
 import java.io.File;
 
@@ -45,10 +39,10 @@ public class StaticPseudoFunctionalStyleMethodTest extends JavaCodeInsightFixtur
   @Override
   protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) throws Exception {
     moduleBuilder.setLanguageLevel(LanguageLevel.JDK_1_8);
-    moduleBuilder.addLibraryJars("guava-17.0.jar", PathManager.getHomePath().replace(File.separatorChar, '/') + "/community/lib/",
-                                 "guava-17.0.jar");
-    moduleBuilder.addLibraryJars("guava-17.0.jar-2", PathManager.getHomePath().replace(File.separatorChar, '/') + "/lib/",
-                                 "guava-17.0.jar");
+    moduleBuilder.addLibraryJars("guava-19.0.jar", PathManager.getHomePath().replace(File.separatorChar, '/') + "/community/lib/",
+                                 "guava-19.0.jar");
+    moduleBuilder.addLibraryJars("guava-19.0.jar-2", PathManager.getHomePath().replace(File.separatorChar, '/') + "/lib/",
+                                 "guava-19.0.jar");
     moduleBuilder.addJdk(IdeaTestUtil.getMockJdk18Path().getPath());
   }
 
index 05f46982a683be2a7eeddb667c51ab491ad0d13a..29613ff79a0261dd8e0341d7d0b8e908716fe073 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -56,7 +56,7 @@ public class GuavaInspectionTest extends JavaCodeInsightFixtureTestCase {
   @Override
   protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) throws Exception {
     moduleBuilder.setLanguageLevel(LanguageLevel.JDK_1_8);
-    moduleBuilder.addLibraryJars("guava", PathManager.getHomePathFor(Assert.class) + "/lib/", "guava-17.0.jar");
+    moduleBuilder.addLibraryJars("guava", PathManager.getHomePathFor(Assert.class) + "/lib/", "guava-19.0.jar");
     moduleBuilder.addLibraryJars("jsr305", PathManager.getHomePathFor(Assert.class) + "/lib/", "jsr305.jar");
     moduleBuilder.addJdk(IdeaTestUtil.getMockJdk18Path().getPath());
   }
@@ -121,7 +121,6 @@ public class GuavaInspectionTest extends JavaCodeInsightFixtureTestCase {
     doTest();
   }
 
-  //needs Guava 18.0 as dependency
   public void _testChainedFluentIterableWithOf() {
     doTest();
   }
index d374ed4baa2ab6a58fefee16c771f26e1b9fcd2a..83ca959ac63cd6fab87ad57709abf5de92e2ffd1 100644 (file)
@@ -25,6 +25,6 @@ import org.jetbrains.annotations.NotNull;
 public class JsonSchemaFileTypeFactory extends FileTypeFactory {
   @Override
   public void createFileTypes(@NotNull FileTypeConsumer consumer) {
-    consumer.consume(JsonSchemaFileType.INSTANCE);
+    consumer.consume(JsonSchemaFileType.INSTANCE, (String) null);
   }
 }
index 336ac7f50c90258f7f14872bf9cd9d76139632d6..676969a2846dd733323a6d975dedd95aa5139617 100644 (file)
@@ -217,13 +217,13 @@ public class JsonSchemaCrossReferencesTest extends CompletionTestCase {
 
     instance.addSchema(inherited);
 
-    testIsSchemaFile(moduleFile, "localRefSchema.json");
-    testIsSchemaFile(moduleFile, "referencingSchema.json");
-
     try {
       ApplicationManager.getApplication().runWriteAction(() -> myFileTypeManager.associatePattern(JsonSchemaFileType.INSTANCE, "*Schema.json"));
       JsonSchemaService.Impl.get(getProject()).reset();
 
+      testIsSchemaFile(moduleFile, "localRefSchema.json");
+      testIsSchemaFile(moduleFile, "referencingSchema.json");
+
       int offset = myEditor.getCaretModel().getPrimaryCaret().getOffset();
       final PsiReference referenceAt = myFile.findReferenceAt(offset);
       Assert.assertNotNull(referenceAt);
@@ -316,24 +316,30 @@ public class JsonSchemaCrossReferencesTest extends CompletionTestCase {
     instance.addSchema(inherited);
     JsonSchemaService.Impl.get(getProject()).reset();
 
-    int offset = myEditor.getCaretModel().getPrimaryCaret().getOffset();
-    PsiElement element = myFile.findElementAt(offset);
-    boolean found = false;
-    while (element.getTextRange().contains(offset)) {
-      if (JsonBySchemaObjectReferenceContributor.REF_PATTERN.accepts(element)) {
-        found = true;
-        break;
+    ApplicationManager.getApplication().runWriteAction(() -> myFileTypeManager.associatePattern(JsonSchemaFileType.INSTANCE, "*Schema.json"));
+    try {
+
+      int offset = myEditor.getCaretModel().getPrimaryCaret().getOffset();
+      PsiElement element = myFile.findElementAt(offset);
+      boolean found = false;
+      while (element.getTextRange().contains(offset)) {
+        if (JsonBySchemaObjectReferenceContributor.REF_PATTERN.accepts(element)) {
+          found = true;
+          break;
+        }
+        element = element.getParent();
       }
-      element = element.getParent();
-    }
-    Assert.assertTrue(found);
-    final PsiReference referenceAt = myFile.findReferenceAt(offset);
-    Assert.assertNotNull(referenceAt);
-    final PsiElement resolve = referenceAt.resolve();
-    Assert.assertNotNull(resolve);
-    Assert.assertEquals("\"baseEnum\"", resolve.getText());
-    Assert.assertEquals("baseProperties.json", resolve.getContainingFile().getName());
+      Assert.assertTrue(found);
+      final PsiReference referenceAt = myFile.findReferenceAt(offset);
+      Assert.assertNotNull(referenceAt);
+      final PsiElement resolve = referenceAt.resolve();
+      Assert.assertNotNull(resolve);
+      Assert.assertEquals("\"baseEnum\"", resolve.getText());
+      Assert.assertEquals("baseProperties.json", resolve.getContainingFile().getName());
 
-    instance.removeSchema(inherited);
+    } finally {
+      instance.removeSchema(inherited);
+      ApplicationManager.getApplication().runWriteAction(() -> myFileTypeManager.removeAssociatedExtension(JsonSchemaFileType.INSTANCE, "*Schema.json"));
+    }
   }
 }
diff --git a/lib/guava-17.0.jar b/lib/guava-17.0.jar
deleted file mode 100644 (file)
index 661fc74..0000000
Binary files a/lib/guava-17.0.jar and /dev/null differ
diff --git a/lib/guava-19.0.jar b/lib/guava-19.0.jar
new file mode 100644 (file)
index 0000000..b175ca8
Binary files /dev/null and b/lib/guava-19.0.jar differ
index 5cbc21b3e34cd6b0d07fea84c510c72ca2513cb2..38121eceab129b36180d6cce62aa7044389f02de 100644 (file)
@@ -16,7 +16,7 @@ httpmime-4.4.1.jar
 ecj-4.5.2.jar
 groovy-all-2.4.6.jar
 gson-2.5.jar
-guava-17.0.jar
+guava-19.0.jar
 hamcrest-core-1.3.jar
 imgscalr-lib-4.2.jar
 batik-all.jar
diff --git a/lib/src/guava-17.0-sources.jar b/lib/src/guava-17.0-sources.jar
deleted file mode 100644 (file)
index 2dab524..0000000
Binary files a/lib/src/guava-17.0-sources.jar and /dev/null differ
diff --git a/lib/src/guava-19.0-sources.jar b/lib/src/guava-19.0-sources.jar
new file mode 100644 (file)
index 0000000..633c315
Binary files /dev/null and b/lib/src/guava-19.0-sources.jar differ
index 049d93c5514733201a7a580fa0523e7a15fe8056..ec937d9c302ff485bf4184551f6b42a029cadbc5 100644 (file)
@@ -39,6 +39,11 @@ public class TemplateLanguageUtil {
     }
   }
 
+  public static PsiFile getBaseFile(@NotNull PsiFile file) {
+    FileViewProvider viewProvider = file.getViewProvider();
+    return viewProvider.getPsi(viewProvider.getBaseLanguage());
+  }
+
   public static boolean isInsideTemplateFile(@NotNull PsiElement element) {
     return element.getContainingFile().getViewProvider() instanceof TemplateLanguageFileViewProvider;
   }
index c915b21d62cae9a845cf0b9d84d904f4855909ec..9c1463b527370b5f26307c5bf02b80542e4b2d2f 100644 (file)
@@ -10,6 +10,5 @@
     <orderEntry type="module" module-name="core-api" exported="" />
     <orderEntry type="library" name="picocontainer" level="project" />
     <orderEntry type="library" name="Guava" level="project" />
-    <orderEntry type="library" name="KotlinJavaRuntime" level="project" />
   </component>
 </module>
\ No newline at end of file
index b98a4a0454a4b5ba0c2d314ea7674d40f24f21d2..712e5d1dc254cbcf449d0eb5b98147b5a7c9d63b 100644 (file)
@@ -1155,4 +1155,8 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
   public boolean useStrongRefs() {
     return myUseStrongRefs;
   }
+
+  public boolean mayCacheAst() {
+    return myFileElementBeingLoaded.get() == null;
+  }
 }
index 63219f353a62c2ea78154090fbb297aa5d11cc9a..225dad77f8b891d0df94bf93cdce0f96cb57220b 100644 (file)
@@ -173,7 +173,10 @@ public abstract class AstPath extends SubstrateRef {
     public CompositeElement getNode() {
       CompositeElement node = SoftReference.dereference(myNode);
       if (node == null) {
-        myNode = new WeakReference<CompositeElement>(node = super.getNode());
+        node = super.getNode();
+        if (myFile.mayCacheAst()) {
+          myNode = new WeakReference<CompositeElement>(node);
+        }
       }
       return node;
     }
index 2b68cbe680df1dd760b809ae4a9d8bdc841aa213..f6a4a48373e7df3496a6ab21b48aff8e0b482edc 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.ide.ui;
 
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.util.ui.UIUtil;
 import sun.swing.SwingUtilities2;
 
@@ -26,7 +27,7 @@ public enum AntialiasingType {
   OFF("No antialiasing", RenderingHints.VALUE_TEXT_ANTIALIAS_OFF, false);
 
   public static Object getAAHintForSwingComponent() {
-    UISettings uiSettings = UISettings.getInstance();
+    UISettings uiSettings = ApplicationManager.getApplication() == null ? null : UISettings.getInstance();
     if (uiSettings != null) {
       AntialiasingType type = uiSettings.IDE_AA_TYPE;
       if (type != null) return type.getTextInfo();
@@ -35,7 +36,7 @@ public enum AntialiasingType {
   }
 
   public static Object getKeyForCurrentScope(boolean inEditor) {
-    UISettings uiSettings = UISettings.getInstance();
+    UISettings uiSettings = ApplicationManager.getApplication() == null ? null : UISettings.getInstance();
     if (uiSettings != null) {
       AntialiasingType type = inEditor ? uiSettings.EDITOR_AA_TYPE : uiSettings.IDE_AA_TYPE;
       if (type != null) return type.myHint;
index 94a8b84f87716091ef054a91448be627dc2cc8d3..348ccef5f6e7e1c6b617691f77d375df80a8a54c 100644 (file)
@@ -40,6 +40,7 @@ import com.intellij.util.xmlb.annotations.Property;
 import com.intellij.util.xmlb.annotations.Transient;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import sun.swing.SwingUtilities2;
 
 import javax.swing.*;
@@ -57,6 +58,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
 
   private static UISettings ourSettings;
 
+  @Nullable
   public static UISettings getInstance() {
     return ourSettings = ServiceManager.getService(UISettings.class);
   }
@@ -65,6 +67,7 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
    * Use this method if you are not sure whether the application is initialized.
    * @return persisted UISettings instance or default values.
    */
+  @NotNull
   public static UISettings getShadowInstance() {
     Application application = ApplicationManager.getApplication();
     UISettings settings = application == null ? null : getInstance();
index 3a7af650092131ed7296a90d97c20309cdeff7b0..e7c81e2ef6f0b3ee1c6d5e3c88f8d88c7ee731d3 100644 (file)
@@ -818,13 +818,14 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
   private static class GetSetColor {
     private final ColorKey myKey;
     private final EditorColorsScheme myScheme;
-    private boolean isModified = false;
+    private final Color myInitialColor;
     private Color myColor;
 
     private GetSetColor(ColorKey key, EditorColorsScheme scheme) {
       myKey = key;
       myScheme = scheme;
       myColor = myScheme.getColor(myKey);
+      myInitialColor = myColor;
     }
 
     public Color getColor() {
@@ -833,7 +834,6 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
 
     public void setColor(Color col) {
       if (getColor() == null || !getColor().equals(col)) {
-        isModified = true;
         myColor = col;
       }
     }
@@ -844,7 +844,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
     }
 
     public boolean isModified() {
-      return isModified;
+      return !Comparing.equal(myColor, myInitialColor);
     }
   }
 
index 1564986dd269fee142addc5475e3600563a60692..1d33a3f8a0164dc18036d21a958a88f424b93702 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -30,9 +30,9 @@ import com.intellij.openapi.options.SchemeImportUtil;
 import com.intellij.openapi.options.SchemeImporter;
 import com.intellij.openapi.options.SchemeImporterEP;
 import com.intellij.openapi.project.DefaultProjectFactory;
+import com.intellij.openapi.ui.ComboBox;
 import com.intellij.openapi.ui.MessageType;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.Consumer;
 import com.intellij.util.EventDispatcher;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.ui.JBInsets;
@@ -47,7 +47,7 @@ import java.util.List;
 public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
   private final ColorAndFontOptions myOptions;
 
-  private JComboBox mySchemeComboBox;
+  private ComboBox<String> mySchemeComboBox;
 
   private JButton myDeleteButton;
   private JButton myImportButton;
@@ -55,7 +55,6 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
 
   private final EventDispatcher<ColorAndFontSettingsListener> myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class);
 
-
   public SchemesPanel(ColorAndFontOptions options) {
     super(new BorderLayout());
     myOptions = options;
@@ -98,7 +97,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent {
               new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 5),
                                      0, 0));
 
-    mySchemeComboBox = new JComboBox();
+    mySchemeComboBox = new ComboBox<String>();
     panel.add(mySchemeComboBox,
               new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new JBInsets(0, 0, 5, 10),
                                      0, 0));
index e4285bcb6605d16ff72495d3dd7deb8509834b13..eceeec25b2b067e16f252e173f5448d43dfdf0e1 100644 (file)
@@ -20,9 +20,10 @@ package com.intellij.codeInsight.template.impl.actions;
 import com.intellij.codeInsight.CodeInsightActionHandler;
 import com.intellij.codeInsight.actions.BaseCodeInsightAction;
 import com.intellij.codeInsight.template.impl.ListTemplatesHandler;
+import com.intellij.openapi.project.DumbAware;
 import org.jetbrains.annotations.NotNull;
 
-public class ListTemplatesAction extends BaseCodeInsightAction{
+public class ListTemplatesAction extends BaseCodeInsightAction implements DumbAware {
   @NotNull
   @Override
   protected CodeInsightActionHandler getHandler() {
index a4c108495182e361281f696ae5990dad4a5e0756..b90004fddd3d484ace09db4a905a7e9b168a91b5 100644 (file)
@@ -40,6 +40,7 @@ import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileFactory;
 import com.intellij.psi.impl.source.PsiFileImpl;
+import com.intellij.psi.templateLanguages.TemplateLanguageUtil;
 import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
@@ -272,7 +273,7 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
     PsiFile copy = psiFileFactory.createFileFromText(file.getName(), file.getFileType(), fileContentWithoutKey);
 
     if (copy instanceof PsiFileImpl) {
-      ((PsiFileImpl) copy).setOriginalFile(file);
+      ((PsiFileImpl) copy).setOriginalFile(TemplateLanguageUtil.getBaseFile(file));
     }
 
     VirtualFile vFile = copy.getVirtualFile();
index ae51adce63183b7e70e39832749b168992cc651e..8fef150fbf79d1f09d811cd415a1d467b248f8fa 100644 (file)
@@ -348,7 +348,10 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp
 
       InspectionResultsView view = myView == null ? new InspectionResultsView(this, createContentProvider()) : null;
       if (!(myView == null ? view : myView).hasProblems()) {
-        NOTIFICATION_GROUP.createNotification(InspectionsBundle.message("inspection.no.problems.message", scope.getFileCount(), scope.getDisplayName()), MessageType.INFO).notify(getProject());
+        NOTIFICATION_GROUP.createNotification(InspectionsBundle.message("inspection.no.problems.message",
+                                                                        scope.getFileCount(),
+                                                                        scope.getShortenName()),
+                                              MessageType.INFO).notify(getProject());
         close(true);
         if (view != null) {
           Disposer.dispose(view);
index a06afdf762ec34727b7d34384c75302ffcef2364..cb85ba7ae7025494b22a6228ac6e98537a0a78c7 100644 (file)
@@ -38,6 +38,7 @@ import com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigT
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiNamedElement;
 import com.intellij.psi.PsiQualifiedNamedElement;
+import com.intellij.psi.SmartPsiElementPointer;
 import com.intellij.psi.util.PsiUtilCore;
 
 import java.util.Comparator;
@@ -159,12 +160,16 @@ public class InspectionResultsViewComparator implements Comparator {
 
   private static int compareEntities(final RefEntity entity1, final RefEntity entity2) {
     if (entity1 instanceof RefElement && entity2 instanceof RefElement) {
-      final VirtualFile file1 = ((RefElement)entity1).getPointer().getVirtualFile();
-      final VirtualFile file2 = ((RefElement)entity2).getPointer().getVirtualFile();
-      if (file1 != null && Comparing.equal(file1, file2) && file1.isValid()) {
-        final int positionComparing = PsiUtilCore.compareElementsByPosition(((RefElement)entity1).getElement(), ((RefElement)entity2).getElement());
-        if (positionComparing != 0) {
-          return positionComparing;
+      final SmartPsiElementPointer p1 = ((RefElement)entity1).getPointer();
+      final SmartPsiElementPointer p2 = ((RefElement)entity2).getPointer();
+      if (p1 != null && p2 != null) {
+        final VirtualFile file1 = p1.getVirtualFile();
+        final VirtualFile file2 = p2.getVirtualFile();
+        if (file1 != null && Comparing.equal(file1, file2) && file1.isValid()) {
+          final int positionComparing = PsiUtilCore.compareElementsByPosition(((RefElement)entity1).getElement(), ((RefElement)entity2).getElement());
+          if (positionComparing != 0) {
+            return positionComparing;
+          }
         }
       }
     }
index 6fe216e6f1e52ee838c7ff3adf855c3b5dbfe3d3..55960664fd8c5dfc41012382ec4b225495e5f286 100644 (file)
@@ -19,18 +19,12 @@ package com.intellij.codeInspection.ui.actions;
 import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.codeInspection.ex.InspectionRVContentProvider;
 import com.intellij.codeInspection.ex.InspectionToolWrapper;
-import com.intellij.codeInspection.ex.QuickFixAction;
 import com.intellij.codeInspection.ui.InspectionResultsView;
 import com.intellij.icons.AllIcons;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.ui.popup.ListPopup;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * User: anna
@@ -52,51 +46,30 @@ public class InvokeQuickFixAction extends AnAction {
     final Presentation presentation = e.getPresentation();
     InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(true);
     final InspectionRVContentProvider provider = myView.getProvider();
-    if (myView.isUpdating() && !myView.getTree().areDescriptorNodesSelected()) {
+    if (toolWrapper == null || cantApplyFixes(myView)) {
       presentation.setEnabled(false);
       return;
     }
-    if (toolWrapper != null && provider.isContentLoaded()) {
-      presentation.setEnabled(provider.hasQuickFixes(myView.getTree()));
-    }
-    else {
-      presentation.setEnabled(false);
-    }
-  }
-
-  private static ActionGroup getFixes(final QuickFixAction[] quickFixes) {
-    return new ActionGroup() {
-      @Override
-      @NotNull
-      public AnAction[] getChildren(@Nullable AnActionEvent e) {
-        List<QuickFixAction> children = new ArrayList<QuickFixAction>();
-        for (QuickFixAction fix : quickFixes) {
-          if (fix != null) {
-            children.add(fix);
-          }
-        }
-        return children.toArray(new AnAction[children.size()]);
-      }
-    };
+    presentation.setEnabled(provider.hasQuickFixes(myView.getTree()));
   }
 
   @Override
   public void actionPerformed(AnActionEvent e) {
-    InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(true);
-    assert toolWrapper != null;
-    final QuickFixAction[] quickFixes = myView.getProvider().getQuickFixes(toolWrapper, myView.getTree());
-    if (quickFixes == null || quickFixes.length == 0) {
-      Messages.showInfoMessage(myView, "There are no applicable quickfixes", "Nothing found to fix");
+    final ActionGroup fixes = (ActionGroup)ActionManager.getInstance().getAction("QuickFixes");
+    if (fixes.getChildren(e).length == 0) {
+      Messages.showInfoMessage(myView, "There are no applicable quick fixes", "Nothing Found to Fix");
       return;
     }
-    ActionGroup fixes = getFixes(quickFixes);
     DataContext dataContext = e.getDataContext();
-    final ListPopup popup = JBPopupFactory.getInstance()
-      .createActionGroupPopup(InspectionsBundle.message("inspection.tree.popup.title"),
+    final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(InspectionsBundle.message("inspection.tree.popup.title"),
                               fixes,
                               dataContext,
                               JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                               false);
     InspectionResultsView.showPopup(e, popup);
   }
+
+  static boolean cantApplyFixes(InspectionResultsView view) {
+    return view.isUpdating() && !view.getTree().areDescriptorNodesSelected();
+  }
 }
index c76357cd60e5b0eeedaf76d37a11c66e0d73e2d4..05b4a760c50e2f93e4818b9100ab226eb7d97e38 100644 (file)
@@ -34,13 +34,15 @@ public class QuickFixesViewActionGroup extends ActionGroup {
   @Override
   public AnAction[] getChildren(@Nullable AnActionEvent e) {
     final InspectionResultsView view = getView(e);
-    if (view == null) {
+    if (view == null || InvokeQuickFixAction.cantApplyFixes(view)) {
       return AnAction.EMPTY_ARRAY;
     }
-    final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true);
-    if (wrapper == null) return AnAction.EMPTY_ARRAY;
-
-    final QuickFixAction[] fixes = view.getProvider().getQuickFixes(wrapper, view.getTree());
-    return fixes == null ? AnAction.EMPTY_ARRAY : fixes;
+    InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(true);
+    if (toolWrapper == null) return AnAction.EMPTY_ARRAY;
+    final QuickFixAction[] quickFixes = view.getProvider().getQuickFixes(toolWrapper, view.getTree());
+    if (quickFixes == null || quickFixes.length == 0) {
+      return AnAction.EMPTY_ARRAY;
+    }
+    return quickFixes;
   }
 }
index 5832be31c5f5dd0bf26d95c2bec3de3f665135cf..6d31b5d6a86a8794363fbdc1343de80a90e85261 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.formatting.commandLine;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
@@ -23,8 +24,11 @@ import java.io.File;
 import java.io.IOException;
 
 public abstract class FileSetProcessor {
+  private static final Logger LOG = Logger.getInstance("#" + FileSetProcessor.class.getName());
+
   private File myRoot;
   private String myPattern;
+  private int myProcessedFiles;
 
   FileSetProcessor(@NotNull String fileSpec) {
     setRootAndPattern(fileSpec);
@@ -37,6 +41,7 @@ public abstract class FileSetProcessor {
   private void processEntry(@NotNull File entry) throws IOException {
     if (entry.exists()) {
       if (entry.isDirectory()) {
+        LOG.info("Scanning directory " + entry.getPath());
         File[] subEntries = entry.listFiles();
         if (subEntries != null) {
           for (File subEntry : subEntries) {
@@ -50,7 +55,9 @@ public abstract class FileSetProcessor {
           if (virtualFile == null) {
             throw new IOException("Can not find " + entry.getPath());
           }
+          LOG.info("Processing " + virtualFile.getPath());
           processFile(virtualFile);
+          myProcessedFiles ++;
         }
       }
     }
@@ -97,6 +104,11 @@ public abstract class FileSetProcessor {
           break;
       }
     }
+    LOG.info("Regexp: " + result);
     return result.toString();
   }
+
+  public int getProcessedFiles() {
+    return myProcessedFiles;
+  }
 }
index 92663b9c78594bf29c6dc02bb553ac04b137ed6b..069af0ae335f68b0d351f65f2d6bd7c3e676d7c4 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.application.ApplicationStarterEx;
 import com.intellij.openapi.application.ex.ApplicationEx;
 import com.intellij.openapi.application.ex.ApplicationInfoEx;
 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.options.SchemeImportException;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -37,6 +38,7 @@ import java.io.PrintWriter;
 public class FormatterStarter extends ApplicationStarterEx {
 
   public static final String FORMAT_COMMAND_NAME = "format";
+  private static final Logger LOG = Logger.getInstance("#" + FormatterStarter.class.getName());
 
   @Override
   public boolean isHeadless() {
@@ -60,6 +62,7 @@ public class FormatterStarter extends ApplicationStarterEx {
       new PrintWriter(System.err));
     messageOutput.info(getAppInfo() + " Formatter\n");
     CodeStyleSettings settings = null;
+    logArgs(args);
     if (args.length < 2) {
       showUsageInfo(messageOutput);
     }
@@ -89,6 +92,7 @@ public class FormatterStarter extends ApplicationStarterEx {
         FileSetFormatter fileSetFormatter = new FileSetFormatter(args[i], settings, messageOutput);
         try {
           fileSetFormatter.processFiles();
+          messageOutput.info("\n" + fileSetFormatter.getProcessedFiles() + " files formatted.\n");
         }
         catch (IOException e) {
           fatalError(messageOutput, e.getLocalizedMessage());
@@ -130,4 +134,13 @@ public class FormatterStarter extends ApplicationStarterEx {
     messageOutput.info("  -s|--settings  A path to Intellij IDEA code style settings .xml file.\n");
     messageOutput.info("  fileSpec       A file specification, may contain wildcards.\n");
   }
+
+  private static void logArgs(@NotNull String[] args) {
+    StringBuilder sb = new StringBuilder();
+    for (String arg : args) {
+      if (sb.length() > 0) sb.append(",");
+      sb.append(arg);
+    }
+    LOG.info("Arguments: " + sb);
+  }
 }
index 68ca22e30bca8749dc6417af71ccdcb19ea92c6a..8c0ea1d34731796f34bf8d80146f3d928cec87b8 100644 (file)
@@ -36,6 +36,7 @@ import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider;
 import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
 import com.intellij.openapi.fileEditor.impl.NonProjectFileWritingAccessExtension;
 import com.intellij.openapi.fileTypes.*;
+import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
 import com.intellij.openapi.project.ProjectManagerAdapter;
@@ -48,8 +49,12 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.LanguageSubstitutor;
 import com.intellij.psi.LanguageSubstitutors;
 import com.intellij.psi.PsiElement;
+import com.intellij.psi.search.*;
 import com.intellij.psi.util.PsiUtilCore;
+import com.intellij.usages.impl.rules.UsageType;
+import com.intellij.usages.impl.rules.UsageTypeProvider;
 import com.intellij.util.PathUtil;
+import com.intellij.util.containers.ConcurrentFactoryMap;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.indexing.IndexableSetContributor;
 import com.intellij.util.indexing.LightDirectoryIndex;
@@ -305,6 +310,85 @@ public class ScratchFileServiceImpl extends ScratchFileService implements Persis
     return file == null ? null : LanguageUtil.getFileTypeLanguage(FileTypeManager.getInstance().getFileTypeByFileName(file.getName()));
   }
 
+  @NotNull
+  public static GlobalSearchScope buildScratchesSearchScope() {
+    final ScratchFileService service = ScratchFileService.getInstance();
+    return new GlobalSearchScope() {
+      @NotNull
+      @Override
+      public String getDisplayName() {
+        return "Scratches and Consoles";
+      }
+
+      @Override
+      public boolean contains(@NotNull VirtualFile file) {
+        RootType rootType = file.getFileType() == ScratchFileType.INSTANCE ? service.getRootType(file) : null;
+        return  rootType != null && !rootType.isHidden();
+      }
+
+      @Override
+      public boolean isSearchOutsideRootModel() {
+        return true;
+      }
+
+      @Override
+      public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
+        return 0;
+      }
+
+      @Override
+      public boolean isSearchInModuleContent(@NotNull Module aModule) {
+        return false;
+      }
+
+      @Override
+      public boolean isSearchInLibraries() {
+        return false;
+      }
+
+      @NotNull
+      @Override
+      public GlobalSearchScope intersectWith(@NotNull GlobalSearchScope scope) {
+        if (scope instanceof ProjectAndLibrariesScope) return this;
+        return super.intersectWith(scope);
+      }
+
+      @Override
+      public String toString() {
+        return getDisplayName();
+      }
+    };
+  }
+
+  public static class UseScopeExtension extends UseScopeEnlarger {
+    @Nullable
+    @Override
+    public SearchScope getAdditionalUseScope(@NotNull PsiElement element) {
+      SearchScope useScope = element.getUseScope();
+      if (useScope instanceof LocalSearchScope) return null;
+      return buildScratchesSearchScope();
+    }
+  }
+
+  public static class UsageTypeExtension implements UsageTypeProvider {
+    private static final ConcurrentFactoryMap<RootType, UsageType> ourUsageTypes = new ConcurrentFactoryMap<RootType, UsageType>() {
+      @Nullable
+      @Override
+      protected UsageType create(RootType key) {
+        return new UsageType("Usage in " + key.getDisplayName());
+      }
+    };
+
+    @Nullable
+    @Override
+    public UsageType getUsageType(PsiElement element) {
+      VirtualFile file = PsiUtilCore.getVirtualFile(element);
+      RootType rootType = file != null && file.getFileType() == ScratchFileType.INSTANCE ?
+                          ScratchFileService.getInstance().getRootType(file) : null;
+      return rootType == null ? null : ourUsageTypes.get(rootType);
+    }
+  }
+
   public static class IndexSetContributor extends IndexableSetContributor {
 
     @NotNull
index cceff485c1c1ac80e2d0042cb3a6e15ba96a1519..0caa721c21defe40d1e40dca8d420d562c89a1cf 100644 (file)
@@ -1,6 +1,20 @@
+/*
+ * Copyright 2000-2016 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.lang.javascript.boilerplate;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.io.Files;
 import com.google.gson.JsonArray;
@@ -17,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 
 public class GithubTagListProvider {
@@ -60,7 +75,7 @@ public class GithubTagListProvider {
   private Runnable createUpdateTagListAction(@NotNull final GithubProjectGeneratorPeer peer) {
     return () -> {
       if (ApplicationManager.getApplication().isUnitTestMode()) {
-        peer.onTagsUpdated(Collections.<GithubTagInfo>emptySet());
+        peer.onTagsUpdated(Collections.emptySet());
         return;
       }
       final String[] urls = formatTagListDownloadUrls();
@@ -106,7 +121,7 @@ public class GithubTagListProvider {
   private ImmutableSet<GithubTagInfo> readTagsFromFile(@NotNull File file) throws GeneratorException {
     final String content;
     try {
-      content = Files.toString(file, Charsets.UTF_8);
+      content = Files.toString(file, StandardCharsets.UTF_8);
     }
     catch (IOException e) {
       throw new GeneratorException("Can not read '" + file.getAbsolutePath() + "'!", e);
index 2228187ddcd2d8e7985d7b162fafee79fb99360f..82c9a0e70b231ed259a8996e5abad156871155f9 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.ide.IdeBundle;
 import com.intellij.ide.favoritesTreeView.FavoritesManager;
 import com.intellij.ide.hierarchy.HierarchyBrowserBase;
 import com.intellij.ide.projectView.impl.AbstractUrl;
+import com.intellij.ide.scratch.ScratchFileServiceImpl;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.actionSystem.LangDataKeys;
@@ -79,6 +80,8 @@ public class PredefinedSearchScopeProviderImpl extends PredefinedSearchScopeProv
       result.add(GlobalSearchScopesCore.projectTestScope(project));
     }
 
+    result.add(ScratchFileServiceImpl.buildScratchesSearchScope());
+
     final GlobalSearchScope openFilesScope = GlobalSearchScopes.openFilesScope(project);
     if (openFilesScope != GlobalSearchScope.EMPTY_SCOPE) {
       result.add(openFilesScope);
index 88a04947fa6a83e8c7f48f48b5482e0923b6dbce..23e666002c8ea7c9e8b45fa48112a5fb78fb2a20 100644 (file)
@@ -23,9 +23,11 @@ import com.intellij.lexer.Lexer;
 import com.intellij.lexer.MergingLexerAdapter;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileTypes.LanguageFileType;
-import com.intellij.psi.*;
+import com.intellij.psi.FileViewProvider;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.SingleRootFileViewProvider;
 import com.intellij.psi.impl.DebugUtil;
-import com.intellij.psi.impl.source.DummyHolder;
 import com.intellij.psi.impl.source.PsiFileImpl;
 import com.intellij.psi.impl.source.tree.*;
 import com.intellij.psi.tree.IElementType;
@@ -68,7 +70,6 @@ public class TemplateDataElementType extends IFileElementType implements ITempla
   @Override
   public ASTNode parseContents(ASTNode chameleon) {
     final CharTable table = SharedImplUtil.findCharTableByTree(chameleon);
-    final FileElement treeElement = new DummyHolder(((TreeElement)chameleon).getManager(), null, table).getTreeElement();
     final FileElement fileElement = TreeUtil.getFileElement((TreeElement)chameleon);
     final PsiFile file = (PsiFile)fileElement.getPsi();
     PsiFile originalFile = file.getOriginalFile();
@@ -92,28 +93,20 @@ public class TemplateDataElementType extends IFileElementType implements ITempla
       lexer.start(chars);
       insertOuters(parsed, lexer, table);
 
-      final TreeElement element = parsed.getFirstChildNode();
-      if (element != null) {
-        parsed.rawRemoveAllChildren();
-        treeElement.rawAddChildren(element);
+      TreeElement childNode = parsed.getFirstChildNode();
+
+      DebugUtil.checkTreeStructure(parsed);
+      DebugUtil.checkTreeStructure(chameleon);
+      if (fileElement != chameleon) {
+        DebugUtil.checkTreeStructure(file.getNode());
+        DebugUtil.checkTreeStructure(originalFile.getNode());
       }
+
+      return childNode;
     }
     finally {
       DebugUtil.finishPsiModification();
     }
-
-    treeElement.subtreeChanged();
-    TreeElement childNode = treeElement.getFirstChildNode();
-
-    DebugUtil.checkTreeStructure(parsed);
-    DebugUtil.checkTreeStructure(treeElement);
-    DebugUtil.checkTreeStructure(chameleon);
-    if (fileElement != chameleon) {
-      DebugUtil.checkTreeStructure(file.getNode());
-      DebugUtil.checkTreeStructure(originalFile.getNode());
-    }
-
-    return childNode;
   }
 
   protected void prepareParsedTemplateFile(@NotNull FileElement root) {
index 1d3a8a7bc364c67ba0b9a0e2c6feaf5d75b4be92..4e2c1f698c96c339dacb5ae67344cdf386b61d3b 100644 (file)
@@ -73,6 +73,7 @@ import com.intellij.psi.stubs.SerializationManagerEx;
 import com.intellij.util.*;
 import com.intellij.util.containers.ConcurrentIntObjectMap;
 import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.JBIterable;
 import com.intellij.util.io.DataOutputStream;
 import com.intellij.util.io.IOUtil;
 import com.intellij.util.io.storage.HeavyProcessLatch;
@@ -2268,28 +2269,28 @@ public class FileBasedIndexImpl extends FileBasedIndex {
     }*/
 
     final Set<VirtualFile> visitedRoots = ContainerUtil.newConcurrentSet();
+    JBIterable<VirtualFile> contributedRoots = JBIterable.empty();
     for (IndexableSetContributor contributor : Extensions.getExtensions(IndexableSetContributor.EP_NAME)) {
       //important not to depend on project here, to support per-project background reindex
       // each client gives a project to FileBasedIndex
       if (project.isDisposed()) {
         return tasks;
       }
-      for (final VirtualFile root : IndexableSetContributor.getRootsToIndex(contributor)) {
-        if (visitedRoots.add(root)) {
-          //System.out.println(root);
-          tasks.add(() -> {
-            if (project.isDisposed() || !root.isValid()) return;
-            iterateRecursively(root, processor, indicator, visitedRoots, null);
-          });
-        }
+      contributedRoots = contributedRoots.append(IndexableSetContributor.getRootsToIndex(contributor));
+      contributedRoots = contributedRoots.append(IndexableSetContributor.getProjectRootsToIndex(contributor, project));
+    }
+    for (AdditionalLibraryRootsProvider provider : Extensions.getExtensions(AdditionalLibraryRootsProvider.EP_NAME)) {
+      if (project.isDisposed()) {
+        return tasks;
       }
-      for (final VirtualFile root : IndexableSetContributor.getProjectRootsToIndex(contributor, project)) {
-        if (visitedRoots.add(root)) {
-          tasks.add(() -> {
-            if (project.isDisposed() || !root.isValid()) return;
-            iterateRecursively(root, processor, indicator, visitedRoots, null);
-          });
-        }
+      contributedRoots = contributedRoots.append(provider.getAdditionalProjectLibrarySourceRoots(project));
+    }
+    for (VirtualFile root : contributedRoots) {
+      if (visitedRoots.add(root)) {
+        tasks.add(() -> {
+          if (project.isDisposed() || !root.isValid()) return;
+          iterateRecursively(root, processor, indicator, visitedRoots, null);
+        });
       }
     }
 
index b31e5fcf549f0bf409467bd272a2535e107280eb..74b3e8930fb62b34bca848bdb01ecf5a7f57995d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -110,9 +110,9 @@ public class ComboBox<E> extends ComboBoxWithWidePopup<E> implements AWTEventLis
             final Object value = list.getSelectedValue();
             if (value != null) {
               configureEditor(getEditor(), value);
-              IdeFocusManager.getGlobalInstance().requestFocus(ComboBox.this, true);
+              IdeFocusManager.getGlobalInstance().requestFocus(this, true);
               assert myJBPopup != null;
-              ComboBox.this.getUI().setPopupVisible(ComboBox.this, false);
+              this.getUI().setPopupVisible(this, false);
               myJBPopup.cancel();
             }
           })
index 089e5b36069849d63c96e495e58d265789023b97..5606339419ae7871e342ec41a9f99cb1d35f079f 100644 (file)
@@ -88,7 +88,7 @@ public abstract class BaseButtonBehavior {
     private boolean myWasPressedOnFocusTransfer;
 
     public void mouseEntered(MouseEvent e) {
-      myMouseDeadzone.reEnter();
+      myMouseDeadzone.enter(e);
 
       setHovered(true);
       repaintComponent();
@@ -167,7 +167,7 @@ public abstract class BaseButtonBehavior {
   private class MyMouseMotionListener extends MouseMotionAdapter {
     @Override
     public void mouseMoved(final MouseEvent e) {
-      myMouseDeadzone.enter();
+      myMouseDeadzone.enter(e);
     }
   }
 
index b12510946ebc1bcca383535eeec55d34c17e5971..27e86ff6a0cc914df5882497a7509226571a3106 100644 (file)
@@ -17,13 +17,15 @@ package com.intellij.util.ui;
 
 import org.jetbrains.annotations.NotNull;
 
+import java.awt.event.MouseEvent;
+
 public final class TimedDeadzone {
   public static final Length DEFAULT = new Length(150);
   public static final Length NULL = new Length(-1);
   
   private Length myLength = NULL;
-  private boolean myWithin;
-  private long myEntered = -1;
+  private boolean myMouseWithin;
+  private long myTimeEntered = -1;
 
   public TimedDeadzone(Length zoneLength) {
     myLength = zoneLength;
@@ -33,31 +35,21 @@ public final class TimedDeadzone {
     return myLength.getLength();
   }
 
-  public void enter() {
-    if (!isWithin()) {
-      reEnter();
-    }
-  }
-
-  public void reEnter() {
-    if (myLength == NULL) {
-      clear();
+  public void enter(MouseEvent e) {
+    if (myMouseWithin) {
       return;
     }
 
-    myEntered = System.currentTimeMillis();
-    myWithin = true;
+    myTimeEntered = e.getWhen();
+    myMouseWithin = true;
   }
 
   public void clear() {
-    myWithin = false;
+    myMouseWithin = false;
   }
 
   public boolean isWithin() {
-    if (myWithin && System.currentTimeMillis() - myEntered > getLength()) {
-      myWithin = false;
-    }
-    return myWithin;
+    return myMouseWithin && System.currentTimeMillis() - myTimeEntered < getLength();
   }
 
   public void setLength(@NotNull final Length deadZone) {
index 3e2f9493eac39fbd6255a4bd0228970ad88e9ea7..44400278e7c6aea04fce8fd4daae900355f8a7e1 100644 (file)
@@ -646,7 +646,7 @@ public class AbstractPopup implements JBPopup {
         if (root != null) {
           final Container popupWindow = root.getParent();
           if (popupWindow != null && popupWindow.isShowing()) {
-            storeLocation(popupWindow.getLocationOnScreen());
+            storeLocation(fixLocateByContent(popupWindow.getLocationOnScreen(), true));
           }
         }
       }
@@ -804,10 +804,7 @@ public class AbstractPopup implements JBPopup {
       xy = myForcedLocation;
     }
 
-    if (myLocateByContent) {
-      final Dimension captionSize = myHeaderPanel.getPreferredSize();
-      xy.y -= captionSize.height;
-    }
+    fixLocateByContent(xy, false);
 
     Rectangle targetBounds = new Rectangle(xy, myContent.getPreferredSize());
     Rectangle original = new Rectangle(targetBounds);
@@ -1555,14 +1552,9 @@ public class AbstractPopup implements JBPopup {
 
   @Override
   public Point getLocationOnScreen() {
-    Dimension headerCorrectionSize = myLocateByContent ? myHeaderPanel.getPreferredSize() : null;
     Point screenPoint = myContent.getLocation();
     SwingUtilities.convertPointToScreen(screenPoint, myContent);
-    if (headerCorrectionSize != null) {
-      screenPoint.y -= headerCorrectionSize.height;
-    }
-
-    return screenPoint;
+    return fixLocateByContent(screenPoint, false);
   }
 
 
@@ -1884,6 +1876,12 @@ public class AbstractPopup implements JBPopup {
     return e != null && e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE && e.getModifiers() == 0;
   }
 
+  private Point fixLocateByContent(Point location, boolean save) {
+    Dimension size = !myLocateByContent ? null : myHeaderPanel.getPreferredSize();
+    if (size != null) location.y -= save ? -size.height : size.height;
+    return location;
+  }
+
   private boolean isBusy() {
     return myResizeListener != null && myResizeListener.isBusy() || myMoveListener != null && myMoveListener.isBusy();
   }
index 3922b254e0d2419569e06506248efdd0c29d1c2b..e1bd84c81a9a8c0b2dd0b7366fe781c359ce2764 100644 (file)
     <editorTabTitleProvider implementation="com.intellij.ide.scratch.ScratchFileServiceImpl$FilePresentation"/>
     <syntaxHighlighter factoryClass="com.intellij.ide.scratch.ScratchFileServiceImpl$Highlighter" order="first"/>
     <indexedRootsProvider implementation="com.intellij.ide.scratch.ScratchFileServiceImpl$IndexSetContributor"/>
+    <useScopeEnlarger implementation="com.intellij.ide.scratch.ScratchFileServiceImpl$UseScopeExtension"/>
+    <usageTypeProvider implementation="com.intellij.ide.scratch.ScratchFileServiceImpl$UsageTypeExtension" order="last"/>
 
     <scratch.rootType implementation="com.intellij.ide.scratch.ScratchRootType" />
     <scratch.rootType implementation="com.intellij.execution.console.HistoryRootType"/>
index eee9081823648708851c94b8a56c266f4dc50f93..acafb311cc1ad6edd08c400c0a47864d9a044b05 100644 (file)
@@ -46,8 +46,6 @@
       <add-to-group group-id="EditorPopupMenu"/>
       <add-to-group group-id="ProjectViewPopupMenu"/>
       <add-to-group group-id="EditorTabPopupMenu"/>
-    </action>
-    <action id="Github.Open.Commit.In.Browser" class="org.jetbrains.plugins.github.GithubShowCommitInBrowserAction">
       <add-to-group group-id="Git.LogContextMenu"/>
       <add-to-group group-id="Vcs.Log.ContextMenu"/>
       <add-to-group group-id="VcsHistoryActionsGroup"/>
similarity index 92%
rename from plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
rename to plugins/github/src/org/jetbrains/plugins/github/GithubOpenCommitInBrowserFromAnnotateAction.java
index a1219e362da7356ecddec739c5093bef4551e0bc..a364b4adb7dbad4ce832a9428732d361267edfe1 100644 (file)
@@ -29,11 +29,11 @@ import git4idea.repo.GitRepository;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.github.util.GithubUtil;
 
-public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommitInBrowserAction implements UpToDateLineNumberListener {
+public class GithubOpenCommitInBrowserFromAnnotateAction extends GithubOpenInBrowserAction implements UpToDateLineNumberListener {
   private final FileAnnotation myAnnotation;
   private int myLineNumber = -1;
 
-  public GithubShowCommitInBrowserFromAnnotateAction(FileAnnotation annotation) {
+  public GithubOpenCommitInBrowserFromAnnotateAction(FileAnnotation annotation) {
     myAnnotation = annotation;
   }
 
index 15250412e3087b5d8e4fb082fbb6aab3ac80d9b7..49dc9d8cbd31178b7befee997a16b9cc0f562c11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2012 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.
@@ -28,12 +28,20 @@ import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vcs.FilePath;
+import com.intellij.openapi.vcs.VcsDataKeys;
 import com.intellij.openapi.vcs.VcsException;
 import com.intellij.openapi.vcs.changes.Change;
 import com.intellij.openapi.vcs.changes.ChangeListManager;
+import com.intellij.openapi.vcs.history.VcsFileRevision;
 import com.intellij.openapi.vfs.VfsUtilCore;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ContainerUtil;
+import com.intellij.vcs.log.CommitId;
+import com.intellij.vcs.log.VcsLog;
+import com.intellij.vcs.log.VcsLogDataKeys;
 import com.intellij.vcsUtil.VcsUtil;
+import git4idea.GitFileRevision;
 import git4idea.GitRevisionNumber;
 import git4idea.GitUtil;
 import git4idea.history.GitHistoryUtils;
@@ -41,77 +49,77 @@ import git4idea.repo.GitRepository;
 import icons.GithubIcons;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.github.api.GithubFullPath;
 import org.jetbrains.plugins.github.util.GithubNotifications;
 import org.jetbrains.plugins.github.util.GithubUrlUtil;
 import org.jetbrains.plugins.github.util.GithubUtil;
 
+import java.util.List;
+
 import static org.jetbrains.plugins.github.util.GithubUtil.LOG;
 
-/**
- * Created by IntelliJ IDEA.
- *
- * @author oleg
- * @date 12/10/10
- */
 public class GithubOpenInBrowserAction extends DumbAwareAction {
   public static final String CANNOT_OPEN_IN_BROWSER = "Can't open in browser";
 
-  protected GithubOpenInBrowserAction() {
-    super("Open on GitHub", "Open selected file in browser", GithubIcons.Github_icon);
+  public GithubOpenInBrowserAction() {
+    super("Open on GitHub", "Open corresponding link in browser", GithubIcons.Github_icon);
   }
 
   @Override
   public void update(AnActionEvent e) {
-    Project project = e.getData(CommonDataKeys.PROJECT);
-    VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
-    if (project == null || project.isDefault() || virtualFile == null) {
-      e.getPresentation().setEnabledAndVisible(false);
-      return;
-    }
-
-    GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile);
-    if (gitRepository == null) {
-      e.getPresentation().setEnabledAndVisible(false);
-      return;
-    }
+    CommitData data = getData(e);
+    e.getPresentation().setEnabled(data != null &&
+                                   (data.revisionHash != null || data.virtualFile != null));
+    e.getPresentation().setVisible(data != null);
+  }
 
-    if (!GithubUtil.isRepositoryOnGitHub(gitRepository)) {
-      e.getPresentation().setEnabledAndVisible(false);
-      return;
-    }
+  @Override
+  public void actionPerformed(AnActionEvent e) {
+    CommitData data = getData(e);
+    assert data != null;
+    assert data.revisionHash != null || data.virtualFile != null;
 
-    ChangeListManager changeListManager = ChangeListManager.getInstance(project);
-    if (changeListManager.isUnversioned(virtualFile)) {
-      e.getPresentation().setVisible(true);
-      e.getPresentation().setEnabled(false);
-      return;
+    if (data.revisionHash != null) {
+      openCommitInBrowser(data.project, data.repository, data.revisionHash);
     }
-
-    Change change = changeListManager.getChange(virtualFile);
-    if (change != null && change.getType() == Change.Type.NEW) {
-      e.getPresentation().setVisible(true);
-      e.getPresentation().setEnabled(false);
-      return;
+    else {
+      Editor editor = e.getData(CommonDataKeys.EDITOR);
+      openFileInBrowser(data.project, data.repository, data.virtualFile, editor);
     }
+  }
 
-    e.getPresentation().setEnabledAndVisible(true);
+  @Nullable
+  protected CommitData getData(AnActionEvent e) {
+    CommitData data = getDataFromHistory(e);
+    if (data == null) data = getDataFromLog(e);
+    if (data == null) data = getDataFromVirtualFile(e);
+    return data;
   }
 
-  @Override
-  public void actionPerformed(AnActionEvent e) {
-    Project project = e.getData(CommonDataKeys.PROJECT);
-    VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
-    Editor editor = e.getData(CommonDataKeys.EDITOR);
-    if (virtualFile == null || project == null || project.isDisposed()) {
+  protected static void openCommitInBrowser(@NotNull Project project, @NotNull GitRepository repository, @NotNull String revisionHash) {
+    String url = GithubUtil.findGithubRemoteUrl(repository);
+    if (url == null) {
+      LOG.info(String.format("Repository is not under GitHub. Root: %s, Remotes: %s", repository.getRoot(),
+                             GitUtil.getPrintableRemotes(repository.getRemotes())));
+      return;
+    }
+    GithubFullPath userAndRepository = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url);
+    if (userAndRepository == null) {
+      GithubNotifications.showError(project, CANNOT_OPEN_IN_BROWSER, "Can't extract info about repository: " + url);
       return;
     }
 
-    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile);
-    assert repository != null;
+    String githubUrl = GithubUrlUtil.getGithubHost() + '/' + userAndRepository.getUser() + '/'
+                       + userAndRepository.getRepository() + "/commit/" + revisionHash;
+    BrowserUtil.browse(githubUrl);
+  }
 
+  private static void openFileInBrowser(@NotNull Project project, @NotNull GitRepository repository, @NotNull VirtualFile virtualFile,
+                                        @Nullable Editor editor) {
     String githubRemoteUrl = GithubUtil.findGithubRemoteUrl(repository);
     if (githubRemoteUrl == null) {
-      GithubNotifications.showError(project, CANNOT_OPEN_IN_BROWSER, "Can't find github remote");
+      LOG.info(String.format("Repository is not under GitHub. Root: %s, Remotes: %s", repository.getRoot(),
+                             GitUtil.getPrintableRemotes(repository.getRemotes())));
       return;
     }
 
@@ -128,10 +136,82 @@ public class GithubOpenInBrowserAction extends DumbAwareAction {
       return;
     }
 
-    String url = makeUrlToOpen(editor, relativePath, hash, githubRemoteUrl);
-    if (url != null) {
-      BrowserUtil.browse(url);
-    }
+    String githubUrl = makeUrlToOpen(editor, relativePath, hash, githubRemoteUrl);
+    if (githubUrl != null) BrowserUtil.browse(githubUrl);
+  }
+
+  @Nullable
+  private static CommitData getDataFromHistory(AnActionEvent e) {
+    Project project = e.getData(CommonDataKeys.PROJECT);
+    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
+    VcsFileRevision fileRevision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
+    if (project == null || filePath == null || fileRevision == null) return null;
+
+    if (!(fileRevision instanceof GitFileRevision)) return null;
+
+    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForFile(filePath);
+    if (repository == null || !GithubUtil.isRepositoryOnGitHub(repository)) return null;
+
+    return new CommitData(project, repository, fileRevision.getRevisionNumber().asString());
+  }
+
+  @Nullable
+  private static CommitData getDataFromLog(AnActionEvent e) {
+    Project project = e.getData(CommonDataKeys.PROJECT);
+    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
+    if (project == null || log == null) return null;
+
+    List<CommitId> selectedCommits = log.getSelectedCommits();
+    if (selectedCommits.size() != 1) return null;
+
+    CommitId commit = ContainerUtil.getFirstItem(selectedCommits);
+    if (commit == null) return null;
+
+    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(commit.getRoot());
+    if (repository == null || !GithubUtil.isRepositoryOnGitHub(repository)) return null;
+
+    return new CommitData(project, repository, commit.getHash().asString());
+  }
+
+  @Nullable
+  private static CommitData getDataFromVirtualFile(AnActionEvent e) {
+    Project project = e.getData(CommonDataKeys.PROJECT);
+    VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
+    if (project == null || virtualFile == null) return null;
+
+    GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile);
+    if (gitRepository == null || !GithubUtil.isRepositoryOnGitHub(gitRepository)) return null;
+
+    ChangeListManager changeListManager = ChangeListManager.getInstance(project);
+    if (changeListManager.isUnversioned(virtualFile)) return new CommitData(project, gitRepository);
+
+    Change change = changeListManager.getChange(virtualFile);
+    if (change != null && change.getType() == Change.Type.NEW) return new CommitData(project, gitRepository);
+
+    return new CommitData(project, gitRepository, virtualFile);
+  }
+
+  @Nullable
+  private static String getCurrentFileRevisionHash(@NotNull final Project project, @NotNull final VirtualFile file) {
+    final Ref<GitRevisionNumber> ref = new Ref<>();
+    ProgressManager.getInstance().run(new Task.Modal(project, "Getting Last Revision", true) {
+      @Override
+      public void run(@NotNull ProgressIndicator indicator) {
+        try {
+          ref.set((GitRevisionNumber)GitHistoryUtils.getCurrentRevision(project, VcsUtil.getFilePath(file), "HEAD"));
+        }
+        catch (VcsException e) {
+          LOG.warn(e);
+        }
+      }
+
+      @Override
+      public void onCancel() {
+        throw new ProcessCanceledException();
+      }
+    });
+    if (ref.isNull()) return null;
+    return ref.get().getRev();
   }
 
   @Nullable
@@ -165,26 +245,32 @@ public class GithubOpenInBrowserAction extends DumbAwareAction {
     return builder.toString();
   }
 
-  @Nullable
-  private static String getCurrentFileRevisionHash(@NotNull final Project project, @NotNull final VirtualFile file) {
-    final Ref<GitRevisionNumber> ref = new Ref<>();
-    ProgressManager.getInstance().run(new Task.Modal(project, "Getting Last Revision", true) {
-      @Override
-      public void run(@NotNull ProgressIndicator indicator) {
-        try {
-          ref.set((GitRevisionNumber)GitHistoryUtils.getCurrentRevision(project, VcsUtil.getFilePath(file), "HEAD"));
-        }
-        catch (VcsException e) {
-          LOG.warn(e);
-        }
-      }
+  protected static class CommitData {
+    @NotNull private final Project project;
+    @NotNull private final GitRepository repository;
+    @Nullable private final String revisionHash;
+    @Nullable private final VirtualFile virtualFile;
 
-      @Override
-      public void onCancel() {
-        throw new ProcessCanceledException();
-      }
-    });
-    if (ref.isNull()) return null;
-    return ref.get().getRev();
+    public CommitData(@NotNull Project project, @NotNull GitRepository repository) {
+      this.project = project;
+      this.repository = repository;
+      this.revisionHash = null;
+      this.virtualFile = null;
+    }
+
+
+    public CommitData(@NotNull Project project, @NotNull GitRepository repository, @Nullable String revisionHash) {
+      this.project = project;
+      this.repository = repository;
+      this.revisionHash = revisionHash;
+      this.virtualFile = null;
+    }
+
+    public CommitData(@NotNull Project project, @NotNull GitRepository repository, @Nullable VirtualFile virtualFile) {
+      this.project = project;
+      this.repository = repository;
+      this.revisionHash = null;
+      this.virtualFile = virtualFile;
+    }
   }
-}
\ No newline at end of file
+}
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserAction.java
deleted file mode 100644 (file)
index 117d533..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2000-2012 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 org.jetbrains.plugins.github;
-
-import com.intellij.ide.BrowserUtil;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.CommonDataKeys;
-import com.intellij.openapi.project.DumbAwareAction;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vcs.FilePath;
-import com.intellij.openapi.vcs.VcsDataKeys;
-import com.intellij.openapi.vcs.history.VcsFileRevision;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.vcs.log.CommitId;
-import com.intellij.vcs.log.VcsLog;
-import com.intellij.vcs.log.VcsLogDataKeys;
-import git4idea.GitFileRevision;
-import git4idea.GitUtil;
-import git4idea.repo.GitRepository;
-import icons.GithubIcons;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.github.api.GithubFullPath;
-import org.jetbrains.plugins.github.util.GithubNotifications;
-import org.jetbrains.plugins.github.util.GithubUrlUtil;
-import org.jetbrains.plugins.github.util.GithubUtil;
-
-import java.util.List;
-
-public class GithubShowCommitInBrowserAction extends DumbAwareAction {
-  public GithubShowCommitInBrowserAction() {
-    super("Open on GitHub", "Open selected commit in browser", GithubIcons.Github_icon);
-  }
-
-  @Override
-  public void update(AnActionEvent e) {
-    CommitData data = getData(e);
-    e.getPresentation().setEnabled(data != null && data.revisionHash != null);
-    e.getPresentation().setVisible(data != null);
-  }
-
-  @Override
-  public void actionPerformed(AnActionEvent e) {
-    CommitData data = getData(e);
-    assert data != null && data.revisionHash != null;
-    openInBrowser(data.project, data.repository, data.revisionHash);
-  }
-
-  protected static void openInBrowser(@NotNull Project project, @NotNull GitRepository repository, @NotNull String revisionHash) {
-    String url = GithubUtil.findGithubRemoteUrl(repository);
-    if (url == null) {
-      GithubUtil.LOG.info(String.format("Repository is not under GitHub. Root: %s, Remotes: %s", repository.getRoot(),
-                                        GitUtil.getPrintableRemotes(repository.getRemotes())));
-      return;
-    }
-    GithubFullPath userAndRepository = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(url);
-    if (userAndRepository == null) {
-      GithubNotifications
-        .showError(project, GithubOpenInBrowserAction.CANNOT_OPEN_IN_BROWSER, "Can't extract info about repository: " + url);
-      return;
-    }
-
-    String githubUrl = GithubUrlUtil.getGithubHost() + '/' + userAndRepository.getUser() + '/'
-                       + userAndRepository.getRepository() + "/commit/" + revisionHash;
-    BrowserUtil.browse(githubUrl);
-  }
-
-  @Nullable
-  protected CommitData getData(AnActionEvent e) {
-    CommitData data = getDataFromHistory(e);
-    if (data == null) data = getDataFromLog(e);
-    return data;
-  }
-
-  @Nullable
-  private static CommitData getDataFromHistory(AnActionEvent e) {
-    Project project = e.getData(CommonDataKeys.PROJECT);
-    FilePath filePath = e.getData(VcsDataKeys.FILE_PATH);
-    VcsFileRevision fileRevision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
-    if (project == null || filePath == null || fileRevision == null) return null;
-
-    if (!(fileRevision instanceof GitFileRevision)) return null;
-
-    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForFile(filePath);
-    if (repository == null || !GithubUtil.isRepositoryOnGitHub(repository)) return null;
-
-    return new CommitData(project, repository, fileRevision.getRevisionNumber().asString());
-  }
-
-  @Nullable
-  private static CommitData getDataFromLog(AnActionEvent e) {
-    Project project = e.getData(CommonDataKeys.PROJECT);
-    VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
-    if (project == null || log == null) return null;
-
-    List<CommitId> selectedCommits = log.getSelectedCommits();
-    if (selectedCommits.size() != 1) return null;
-
-    CommitId commit = ContainerUtil.getFirstItem(selectedCommits);
-    if (commit == null) return null;
-
-    GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(commit.getRoot());
-    if (repository == null || !GithubUtil.isRepositoryOnGitHub(repository)) return null;
-
-    return new CommitData(project, repository, commit.getHash().asString());
-  }
-
-  protected static class CommitData {
-    @NotNull private final Project project;
-    @NotNull private final GitRepository repository;
-    @Nullable private final String revisionHash;
-
-    public CommitData(@NotNull Project project, @NotNull GitRepository repository, @Nullable String revisionHash) {
-      this.project = project;
-      this.repository = repository;
-      this.revisionHash = revisionHash;
-    }
-  }
-}
index 06a3e8bbf752b3365d0acea0c9bdc9f262ef8e74..d435318462523aaf7476c9b9e3b5cb52d14d964b 100644 (file)
@@ -19,7 +19,7 @@ import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.vcs.annotate.AnnotationGutterActionProvider;
 import com.intellij.openapi.vcs.annotate.FileAnnotation;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.github.GithubShowCommitInBrowserFromAnnotateAction;
+import org.jetbrains.plugins.github.GithubOpenCommitInBrowserFromAnnotateAction;
 
 /**
  * @author Kirill Likhodedov
@@ -29,7 +29,7 @@ public class GithubAnnotationGutterActionProvider implements AnnotationGutterAct
   @NotNull
   @Override
   public AnAction createAction(@NotNull FileAnnotation annotation) {
-    return new GithubShowCommitInBrowserFromAnnotateAction(annotation);
+    return new GithubOpenCommitInBrowserFromAnnotateAction(annotation);
   }
 
 }
index 5880ebffc0b5537fd6108adddda2b21d573dc454..dc3ddfe4a47cbc6d3b0e55e6855c8c638c906982 100644 (file)
@@ -9,6 +9,6 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
-    <orderEntry type="library" scope="TEST" name="hamcrest" level="project" />
+    <orderEntry type="library" name="assertJ" level="project" />
   </component>
 </module>
\ No newline at end of file
index 58f6db088e1a50c94f45d86c54632d5ab9862c62..16211421279bfbc2c00b6830066fa15f32b9d696 100644 (file)
@@ -15,7 +15,6 @@
  */
 package org.jetbrains.java.decompiler;
 
-import org.hamcrest.Matchers;
 import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler;
 import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences;
 import org.jetbrains.java.decompiler.util.InterpreterUtil;
@@ -26,8 +25,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
 import static org.junit.Assert.assertTrue;
 
 public class DecompilerTestFixture {
@@ -37,7 +35,7 @@ public class DecompilerTestFixture {
   private ConsoleDecompiler decompiler;
 
   public void setUp(String... optionPairs) throws IOException {
-    assertEquals(0, optionPairs.length % 2);
+    assertThat(optionPairs.length % 2).isEqualTo(0);
 
     testDataDir = new File("testData");
     if (!isTestDataDir(testDataDir)) testDataDir = new File("community/plugins/java-decompiler/engine/testData");
@@ -49,10 +47,10 @@ public class DecompilerTestFixture {
 
     //noinspection SSBasedInspection
     tempDir = File.createTempFile("decompiler_test_", "_dir");
-    assertTrue(tempDir.delete());
+    assertThat(tempDir.delete()).isTrue();
 
     targetDir = new File(tempDir, "decompiled");
-    assertTrue(targetDir.mkdirs());
+    assertThat(targetDir.mkdirs()).isTrue();
 
     Map<String, Object> options = new HashMap<String, Object>();
     options.put(IFernflowerPreferences.LOG_LEVEL, "warn");
@@ -106,13 +104,13 @@ public class DecompilerTestFixture {
   public static void assertFilesEqual(File expected, File actual) {
     if (expected.isDirectory()) {
       String[] children = Objects.requireNonNull(expected.list());
-      assertThat(actual.list(), Matchers.arrayContainingInAnyOrder(children));
+      assertThat(actual.list()).contains(children);
       for (String name : children) {
         assertFilesEqual(new File(expected, name), new File(actual, name));
       }
     }
     else {
-      assertEquals(getContent(expected), getContent(actual));
+      assertThat(getContent(actual)).isEqualTo(getContent(expected));
     }
   }
 
diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/LoggerConfigPropertyUsageProvider.java b/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/LoggerConfigPropertyUsageProvider.java
new file mode 100644 (file)
index 0000000..57aea2a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2016 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.codeInspection.unused;
+
+import com.intellij.lang.properties.psi.Property;
+
+public class LoggerConfigPropertyUsageProvider extends ImplicitPropertyUsageProvider {
+  private final static String[] LOGGER_PROPERTIES_KEYWORDS = new String[]{"log4j", "commons-logging", "logging"};
+
+  @Override
+  protected boolean isUsed(Property property) {
+    final String propertiesFileName = property.getPropertiesFile().getName();
+    for (String keyword : LOGGER_PROPERTIES_KEYWORDS) {
+      if (propertiesFileName.startsWith(keyword)) {
+        return true;
+      }
+    }
+    return false;
+  }
+}
index 16e00fd96200750e8897252fff6ae35caf9564d2..39790e977e6732eff1d59460f0bce34914d85bac 100644 (file)
 
     <definitionsScopedSearch implementation="com.intellij.lang.properties.editor.PropertiesInheritorsSearcher"/>
     <gotoDeclarationHandler implementation="com.intellij.lang.properties.editor.GotoPropertyParentDeclarationHandler"/>
+
+    <properties.implicitPropertyUsageProvider implementation="com.intellij.codeInspection.unused.LoggerConfigPropertyUsageProvider"/>
   </extensions>
 
   <project-components>
index b866eee4aee6b7718fe3fdd7e75ef704be83b667..b3dffec82fd964fdf6fa40cea6391d52d267747c 100644 (file)
@@ -208,11 +208,9 @@ class IcsManager(dir: Path) {
 
     fun doSave(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType) = repositoryManager.write(toRepositoryPath(fileSpec, roamingType, projectId), content, size)
 
-    protected open fun isAutoCommit(fileSpec: String, roamingType: RoamingType): Boolean = true
+    protected open fun isAutoCommit(fileSpec: String, roamingType: RoamingType) = true
 
-    override fun read(fileSpec: String, roamingType: RoamingType): InputStream? {
-      return repositoryManager.read(toRepositoryPath(fileSpec, roamingType, projectId))
-    }
+    override fun read(fileSpec: String, roamingType: RoamingType) = repositoryManager.read(toRepositoryPath(fileSpec, roamingType, projectId))
 
     override fun delete(fileSpec: String, roamingType: RoamingType) {
     }
index a6f25f194b666450d188467d5612f3ffd412e085..7a01075e9d7d26c539af838ee7bc41fca2aeb7a4 100644 (file)
@@ -54,7 +54,7 @@ internal class GitTest : GitTestCase() {
           mergeSession.conflictResolvedForFile(file, MergeSession.Resolution.AcceptedTheirs)
         }
         else if (Arrays.equals(mergeData.LAST, AM.MARKER_ACCEPT_MY)) {
-          file.setBinaryContent(mergeData.LAST!!)
+          file.setBinaryContent(mergeData.LAST)
           mergeProvider.conflictResolvedForFile(file)
         }
         else {
@@ -363,7 +363,7 @@ internal class GitTest : GitTestCase() {
     if (syncType != SyncType.OVERWRITE_LOCAL) {
       fs.file(path, data)
     }
-    restoreRemoteAfterPush();
+    restoreRemoteAfterPush()
     fs.compare()
   }
 }
\ No newline at end of file
index fed8cc4ab07ddcc97294f56b5f6b8e19ad32aac1..6c6bf51f6d20555ab40cbd8278de5a0594e660f5 100644 (file)
@@ -11,7 +11,7 @@
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="gson" level="project" />
     <orderEntry type="module" module-name="lang-impl" />
-    <orderEntry type="library" name="guava-tools" level="project" />
     <orderEntry type="module" module-name="student" />
+    <orderEntry type="library" name="Guava" level="project" />
   </component>
 </module>
\ No newline at end of file
index db3c0d053eeb3dc56473b65a0593c74ad3e5b598..3395638400cbeac28b4e49c0fed33ce9e727c649 100644 (file)
@@ -26,26 +26,17 @@ public class CCCreateAnswerPlaceholderDialog extends DialogWrapper {
   public CCCreateAnswerPlaceholderDialog(@NotNull final Project project,
                                          @NotNull final AnswerPlaceholder answerPlaceholder) {
     super(project, true);
-    setTitle(ourTitle);
+    
     myAnswerPlaceholder = answerPlaceholder;
-    myPanel = new CCCreateAnswerPlaceholderPanel();
-    if (!answerPlaceholder.getHints().isEmpty()) {
-      setHintText(answerPlaceholder);
-    }
     myProject = project;
-    String answerPlaceholderTaskText = answerPlaceholder.getTaskText();
-    myPanel.setAnswerPlaceholderText(answerPlaceholderTaskText != null ? answerPlaceholderTaskText : "");
+    myPanel = new CCCreateAnswerPlaceholderPanel(answerPlaceholder);
+    myPanel.showAnswerPlaceholderText(StringUtil.notNullize(answerPlaceholder.getTaskText()));
+    
+    setTitle(ourTitle);
     init();
     initValidation();
   }
 
-  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
-  private void setHintText(AnswerPlaceholder answerPlaceholder) {
-    List<String> hintTexts = answerPlaceholder.getHints();
-    myPanel.setHintText(hintTexts.get(0));
-    myPanel.setHints(hintTexts);
-  }
-
   @Override
   protected void doOKAction() {
     String answerPlaceholderText = myPanel.getAnswerPlaceholderText();
index f2a479d2fa1b03bd4306ad3491af080d82d8b416..e13f6d6e260b5c7b179079125be576ae0e363c64 100644 (file)
@@ -5,10 +5,12 @@ import com.intellij.openapi.actionSystem.ActionManager;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.ui.ColorUtil;
 import com.intellij.ui.JBColor;
 import com.intellij.ui.components.JBLabel;
-import com.intellij.uiDesigner.core.GridLayoutManager;
 import com.intellij.util.ui.UIUtil;
+import com.jetbrains.edu.learning.courseFormat.AnswerPlaceholder;
+import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
 import java.awt.*;
@@ -19,30 +21,38 @@ import java.util.List;
 
 public class CCCreateAnswerPlaceholderPanel {
   private static String ourFirstHintText = "Type here to add hint";
-  
+
   private JPanel myPanel;
   private JTextArea myHintTextArea;
+  private JPanel myHintsPanel;
   private JBLabel myHintLabel;
   private JPanel actionsPanel;
-  private JPanel myHintsPanel;
   private JTextArea myPlaceholderTextArea;
+  private List<String> myHints = new ArrayList<String>() {
+  };
   private int myShownHintNumber = 0;
 
-  private List<String> myHints = new ArrayList<String>() {{
-    add(ourFirstHintText);
-  }};
+  public CCCreateAnswerPlaceholderPanel(@NotNull final AnswerPlaceholder answerPlaceholder) {
+    if (answerPlaceholder.getHints().isEmpty()) {
+      myHints.add(ourFirstHintText);
+    }
+    else {
+      myHints.addAll(answerPlaceholder.getHints());
+    }
 
-  public CCCreateAnswerPlaceholderPanel() {
-    myHintTextArea.setLineWrap(true);
-    myHintTextArea.setWrapStyleWord(true);
     myPlaceholderTextArea.setBorder(BorderFactory.createLineBorder(JBColor.border()));
     myHintsPanel.setBorder(BorderFactory.createLineBorder(JBColor.border()));
+
     myHintTextArea.setFont(myPlaceholderTextArea.getFont());
-    if (myHints.get(myShownHintNumber).equals(ourFirstHintText)) {
-      myHintTextArea.setForeground(UIUtil.getInactiveTextColor());
-    }
-    myHintTextArea.setText(myHints.get(myShownHintNumber));
-    myHintTextArea.addFocusListener(new FocusAdapter() {
+    myHintTextArea.addFocusListener(createFocusListenerToSetDefaultHintText());
+
+    actionsPanel.add(createHintToolbarComponent(), BorderLayout.WEST);
+    showHint(myHints.get(myShownHintNumber));
+  }
+
+  @NotNull
+  private FocusAdapter createFocusListenerToSetDefaultHintText() {
+    return new FocusAdapter() {
       @Override
       public void focusGained(FocusEvent e) {
         if (myHintTextArea.getText().equals(ourFirstHintText)) {
@@ -50,35 +60,47 @@ public class CCCreateAnswerPlaceholderPanel {
           myHintTextArea.setText("");
         }
       }
-    });
-
-    myPlaceholderTextArea.grabFocus();
-    updateHintNumberLabel();
 
-    ((GridLayoutManager)myHintsPanel.getLayout()).setHGap(1);
+      @Override
+      public void focusLost(FocusEvent e) {
+        if (myShownHintNumber == 0 && myHintTextArea.getText().isEmpty()) {
+          myHintTextArea.setForeground(UIUtil.getInactiveTextColor());
+          myHintTextArea.setText(ourFirstHintText);
+        }
+      }
+    };
+  }
 
+  private JComponent createHintToolbarComponent() {
     final DefaultActionGroup addRemoveGroup = new DefaultActionGroup();
-    addRemoveGroup.addAll(new AddHint(), new RemoveHint(), new GoForward(), new GoBackward());
-    final JComponent addRemoveComponent = ActionManager.getInstance().createActionToolbar("Hint", addRemoveGroup, false).getComponent();
-    actionsPanel.add(addRemoveComponent, BorderLayout.WEST);
+    addRemoveGroup.addAll(new AddHint(), new RemoveHint(), new ShowNext(), new ShowPrevious());
+    return ActionManager.getInstance().createActionToolbar("Hint", addRemoveGroup, false).getComponent();
   }
 
   private void updateHintNumberLabel() {
     if (myHints.size() > 1) {
-      myHintLabel.setText("Hint" + "(" + (myShownHintNumber + 1) + "/" + myHints.size() + "):");
+      final String color = String.valueOf(ColorUtil.toHex(UIUtil.getHeaderInactiveColor()));
+      myHintLabel.setText(UIUtil.toHtml("Hint" + " <font color=\"" + color + "\">(" + (myShownHintNumber + 1) + "/" + myHints.size() + ")</font>:"));
     }
     else {
       myHintLabel.setText("Hint: ");
     }
   }
 
-  public void setAnswerPlaceholderText(String answerPlaceholderText) {
+  public void showAnswerPlaceholderText(String answerPlaceholderText) {
     myPlaceholderTextArea.setText(answerPlaceholderText);
   }
 
-  public void setHintText(String hintTextField) {
-    myHintTextArea.setForeground(UIUtil.getActiveTextColor());
-    myHintTextArea.setText(hintTextField);
+  public void showHint(String hintText) {
+    if (myHints.get(myShownHintNumber).equals(ourFirstHintText)) {
+      myHintTextArea.setForeground(UIUtil.getInactiveTextColor());
+    }
+    else {
+      myHintTextArea.setForeground(UIUtil.getActiveTextColor());
+    }
+
+    myHintTextArea.setText(hintText);
+    updateHintNumberLabel();
   }
 
   public String getAnswerPlaceholderText() {
@@ -101,26 +123,20 @@ public class CCCreateAnswerPlaceholderPanel {
     return myPlaceholderTextArea;
   }
 
-  public void setHints(List<String> hints) {
-    myHints = hints;
-    updateHintNumberLabel();
-  }
-
   public JPanel getMailPanel() {
     return myPanel;
   }
 
-  private class GoForward extends AnAction {
+  private class ShowNext extends AnAction {
 
-    public GoForward() {
-      super("Forward", "Forward", AllIcons.Actions.Forward);
+    public ShowNext() {
+      super("Next", "Next", AllIcons.Actions.Forward);
     }
 
     @Override
     public void actionPerformed(AnActionEvent e) {
       myHints.set(myShownHintNumber, myHintTextArea.getText());
-      setHintText(myHints.get(++myShownHintNumber));
-      updateHintNumberLabel();
+      showHint(myHints.get(++myShownHintNumber));
     }
 
     @Override
@@ -129,17 +145,16 @@ public class CCCreateAnswerPlaceholderPanel {
     }
   }
 
-  private class GoBackward extends AnAction {
+  private class ShowPrevious extends AnAction {
 
-    public GoBackward() {
-      super("Back", "Back", AllIcons.Actions.Back);
+    public ShowPrevious() {
+      super("Previous", "Previous", AllIcons.Actions.Back);
     }
 
     @Override
     public void actionPerformed(AnActionEvent e) {
       myHints.set(myShownHintNumber, myHintTextArea.getText());
-      setHintText(myHints.get(--myShownHintNumber));
-      updateHintNumberLabel();
+      showHint(myHints.get(--myShownHintNumber));
     }
 
     @Override
@@ -151,15 +166,14 @@ public class CCCreateAnswerPlaceholderPanel {
   private class AddHint extends AnAction {
 
     public AddHint() {
-      super("Add New Hint", "Add New Hint", AllIcons.General.Add);
+      super("Add Hint", "Add Hint", AllIcons.General.Add);
     }
 
     @Override
     public void actionPerformed(AnActionEvent e) {
       myHints.add("");
-      setHintText("");
       myShownHintNumber++;
-      updateHintNumberLabel();
+      showHint("");
     }
   }
 
@@ -172,14 +186,8 @@ public class CCCreateAnswerPlaceholderPanel {
     @Override
     public void actionPerformed(AnActionEvent e) {
       myHints.remove(myShownHintNumber);
-      if (myHints.size() == 1) {
-        myShownHintNumber = 0;
-      }
-      else {
-        myShownHintNumber += myShownHintNumber + 1 < myHints.size() ? 1 : -1;
-      }
-      setHintText(myHints.get(myShownHintNumber));
-      updateHintNumberLabel();
+      myShownHintNumber += myShownHintNumber < myHints.size() ? 0 : -1;
+      showHint(myHints.get(myShownHintNumber));
     }
 
     @Override
index 24db1b1575aa8009467424f94859047751388882..8bf7fc09f16fb3993c0ab92644cb96b905759a1e 100644 (file)
@@ -10,6 +10,7 @@ import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.progress.util.ProgressIndicatorBase;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.ui.JBColor;
 import com.intellij.util.ui.UIUtil;
 import com.jetbrains.edu.learning.StudyUtils;
 import com.jetbrains.edu.learning.courseFormat.StudyStatus;
@@ -173,7 +174,7 @@ public class StepicAdaptiveReactionsPanel extends JPanel {
       public void mouseEntered(MouseEvent e) {
         final com.jetbrains.edu.learning.courseFormat.Task task = StudyUtils.getCurrentTask(myProject);
         if (task != null && task.getStatus() != StudyStatus.Solved && myPanel.isEnabled()) {
-          setBackground(UIUtil.getButtonSelectColor());
+          setBackground(JBColor.GRAY);
         }
       }
 
index 6126168486e4757d3bdde3ed06ffed7863e1d72e..7502481940eeb7d9fe28ec33607dd3a844a958c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@ import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.util.Optional;
+
 import static com.jetbrains.python.PyNames.*;
 
 /**
@@ -37,6 +39,7 @@ import static com.jetbrains.python.PyNames.*;
  * Inspection to warn if call to super constructor in class is missed
  */
 public class PyMissingConstructorInspection extends PyInspection {
+
   @Nls
   @NotNull
   @Override
@@ -46,140 +49,180 @@ public class PyMissingConstructorInspection extends PyInspection {
 
   @NotNull
   @Override
-  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder,
-                                        boolean isOnTheFly,
-                                        @NotNull LocalInspectionToolSession session) {
+  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) {
     return new Visitor(holder, session);
   }
 
   private static class Visitor extends PyInspectionVisitor {
+
     public Visitor(@Nullable ProblemsHolder holder, @NotNull LocalInspectionToolSession session) {
       super(holder, session);
     }
 
     @Override
-    public void visitPyClass(final PyClass node) {
-      PsiElement[] superClasses = node.getSuperClassExpressions();
-      if (superClasses.length == 0 || (superClasses.length == 1 && OBJECT.equals(superClasses[0].getText())))
+    public void visitPyClass(@NotNull PyClass node) {
+      final PsiElement[] superClasses = node.getSuperClassExpressions();
+
+      if (superClasses.length == 0 ||
+          superClasses.length == 1 && OBJECT.equals(superClasses[0].getText()) ||
+          !superHasConstructor(node, myTypeEvalContext)) {
         return;
+      }
 
-      if (!superHasConstructor(node)) return;
-      PyFunction initMethod = node.findMethodByName(INIT, false, null);
-      if (initMethod != null) {
-        if (isExceptionClass(node, myTypeEvalContext) || hasConstructorCall(node, initMethod)) {
-          return;
-        }
-        if (superClasses.length == 1 || node.isNewStyleClass(null))
-          registerProblem(initMethod.getNameIdentifier(), PyBundle.message("INSP.missing.super.constructor.message"),
-                          new AddCallSuperQuickFix());
-        else
-          registerProblem(initMethod.getNameIdentifier(), PyBundle.message("INSP.missing.super.constructor.message"));
+      final PyFunction initMethod = node.findMethodByName(INIT, false, myTypeEvalContext);
+
+      if (initMethod == null || isExceptionClass(node, myTypeEvalContext) || hasConstructorCall(node, initMethod, myTypeEvalContext)) {
+        return;
+      }
+
+      if (superClasses.length == 1 || node.isNewStyleClass(myTypeEvalContext)) {
+        registerProblem(initMethod.getNameIdentifier(), PyBundle.message("INSP.missing.super.constructor.message"),
+                        new AddCallSuperQuickFix());
+      }
+      else {
+        registerProblem(initMethod.getNameIdentifier(), PyBundle.message("INSP.missing.super.constructor.message"));
       }
     }
 
-    private boolean superHasConstructor(@NotNull PyClass cls) {
+    private static boolean superHasConstructor(@NotNull PyClass cls, @NotNull TypeEvalContext context) {
       final String className = cls.getName();
-      for (PyClass c : cls.getAncestorClasses(myTypeEvalContext)) {
-        final String name = c.getName();
-        if (!PyUtil.isObjectClass(c) && !Comparing.equal(className, name) && c.findMethodByName(INIT, false, null) != null) {
+
+      for (PyClass baseClass : cls.getAncestorClasses(context)) {
+        if (!PyUtil.isObjectClass(baseClass) &&
+            !Comparing.equal(className, baseClass.getName()) &&
+            baseClass.findMethodByName(INIT, false, context) != null) {
           return true;
         }
       }
+
       return false;
     }
 
-    private boolean isExceptionClass(@NotNull PyClass cls, @NotNull TypeEvalContext context) {
+    private static boolean isExceptionClass(@NotNull PyClass cls, @NotNull TypeEvalContext context) {
       if (PyBroadExceptionInspection.equalsException(cls, context)) {
         return true;
       }
-      for (PyClass baseClass : cls.getAncestorClasses(myTypeEvalContext)) {
-        if (PyBroadExceptionInspection.equalsException(baseClass, context)) {
-          return true;
-        }
-      }
-      return false;
+
+      return cls.getAncestorClasses(context)
+        .stream()
+        .filter(baseClass -> PyBroadExceptionInspection.equalsException(baseClass, context))
+        .findAny()
+        .isPresent();
     }
 
-    private boolean hasConstructorCall(PyClass node, PyFunction initMethod) {
-      PyStatementList statementList = initMethod.getStatementList();
-      CallVisitor visitor = new CallVisitor(node);
-      if (statementList != null) {
-        statementList.accept(visitor);
-        return visitor.myHasConstructorCall;
-      }
-      return false;
+    private static boolean hasConstructorCall(@NotNull PyClass cls, @NotNull PyFunction initMethod, @NotNull TypeEvalContext context) {
+      final CallVisitor visitor = new CallVisitor(cls, context);
+      initMethod.getStatementList().accept(visitor);
+      return visitor.myHasConstructorCall;
     }
 
-    private class CallVisitor extends PyRecursiveElementVisitor {
+    private static class CallVisitor extends PyRecursiveElementVisitor {
+
+      @NotNull
+      private final PyClass myClass;
+
+      @NotNull
+      private final TypeEvalContext myContext;
+
       private boolean myHasConstructorCall = false;
-      private PyClass myClass;
-      CallVisitor(PyClass node) {
-        myClass = node;
+
+      public CallVisitor(@NotNull PyClass cls, @NotNull TypeEvalContext context) {
+        myClass = cls;
+        myContext = context;
       }
 
       @Override
-      public void visitPyCallExpression(PyCallExpression node) {
-        if (isConstructorCall(node, myClass))
+      public void visitPyCallExpression(@NotNull PyCallExpression node) {
+        if (isConstructorCall(node, myClass, myContext)) {
           myHasConstructorCall = true;
+        }
       }
 
-      private boolean isConstructorCall(PyCallExpression expression, PyClass cl) {
-        PyExpression callee = expression.getCallee();
-        if (callee instanceof PyQualifiedExpression) {
-          PyExpression qualifier = ((PyQualifiedExpression)callee).getQualifier();
-          if (qualifier != null) {
-            String tmp = "";
-            if (qualifier instanceof PyCallExpression) {
-              PyExpression innerCallee = ((PyCallExpression)qualifier).getCallee();
-              if (innerCallee != null) {
-                tmp = innerCallee.getName();
-              }
-              if (SUPER.equals(tmp) && (INIT.equals(callee.getName()))) {
-                PyExpression[] args = ((PyCallExpression)qualifier).getArguments();
-                if (args.length > 0) {
-                  String firstArg = args[0].getText();
-                  final String qualifiedName = cl.getQualifiedName();
-                  if (firstArg.equals(cl.getName()) || firstArg.equals(CANONICAL_SELF+"."+ __CLASS__) ||
-                      (qualifiedName != null && qualifiedName.endsWith(firstArg)))
-                      return true;
-                  for (PyClass s : cl.getAncestorClasses(myTypeEvalContext)) {
-                    if (firstArg.equals(s.getName()))
-                      return true;
-                  }
-                }
-                else
-                  return true;
-              }
-            }
-            if (INIT.equals(callee.getName())) {
-              return isSuperClassCall(cl, qualifier);
-            }
-          }
+      private static boolean isConstructorCall(@NotNull PyCallExpression call, @NotNull PyClass cls, @NotNull TypeEvalContext context) {
+        final PyExpression callee = call.getCallee();
+
+        if (callee == null || !INIT.equals(callee.getName())) {
+          return false;
         }
-        return false;
+
+        final PyExpression calleeQualifier = Optional
+          .of(callee)
+          .filter(PyQualifiedExpression.class::isInstance)
+          .map(PyQualifiedExpression.class::cast)
+          .map(PyQualifiedExpression::getQualifier)
+          .orElse(null);
+
+        return calleeQualifier != null && (isSuperCall(calleeQualifier, cls, context) || isSuperClassCall(calleeQualifier, cls, context));
       }
 
-      private boolean isSuperClassCall(PyClass cl, PyExpression qualifier) {
-        PsiElement callingClass = null;
-        if (qualifier instanceof PyCallExpression) {
-          PyExpression innerCallee = ((PyCallExpression)qualifier).getCallee();
-          if (innerCallee != null) {
-            PsiReference ref = innerCallee.getReference();
-            if (ref != null)
-              callingClass = ref.resolve();
-          }
+      private static boolean isSuperCall(@NotNull PyExpression calleeQualifier,
+                                         @NotNull PyClass cls,
+                                         @NotNull TypeEvalContext context) {
+        final String prevCalleeName = Optional
+          .of(calleeQualifier)
+          .filter(PyCallExpression.class::isInstance)
+          .map(PyCallExpression.class::cast)
+          .map(PyCallExpression::getCallee)
+          .map(PyExpression::getName)
+          .orElse(null);
+
+        if (!SUPER.equals(prevCalleeName)) {
+          return false;
         }
-        else {
-          PsiReference ref = qualifier.getReference();
-          if (ref != null)
-            callingClass = ref.resolve();
+
+        final PyExpression[] args = ((PyCallExpression)calleeQualifier).getArguments();
+
+        if (args.length == 0) {
+          return true;
+        }
+
+        final String firstArg = args[0].getText();
+        final String classQName = cls.getQualifiedName();
+
+        if (firstArg.equals(cls.getName()) ||
+            firstArg.equals(CANONICAL_SELF + "." + __CLASS__) ||
+            classQName != null && classQName.endsWith(firstArg) ||
+            firstArg.equals(__CLASS__) && LanguageLevel.forElement(cls).isAtLeast(LanguageLevel.PYTHON30)) {
+          return true;
         }
-        for (PyClass s : cl.getAncestorClasses(myTypeEvalContext)) {
-          if (s.equals(callingClass)) {
-            return true;
-          }
+
+        return cls.getAncestorClasses(context)
+          .stream()
+          .map(PyClass::getName)
+          .filter(firstArg::equals)
+          .findAny()
+          .isPresent();
+      }
+
+      private static boolean isSuperClassCall(@NotNull PyExpression calleeQualifier,
+                                              @NotNull PyClass cls,
+                                              @NotNull TypeEvalContext context) {
+        final PsiElement callingClass = resolveCallingClass(calleeQualifier);
+
+        return callingClass != null &&
+               cls.getAncestorClasses(context)
+                 .stream()
+                 .filter(callingClass::equals)
+                 .findAny()
+                 .isPresent();
+      }
+
+      @Nullable
+      private static PsiElement resolveCallingClass(@NotNull PyExpression calleeQualifier) {
+        if (calleeQualifier instanceof PyCallExpression) {
+          return Optional
+            .of((PyCallExpression)calleeQualifier)
+            .map(PyCallExpression::getCallee)
+            .map(PyExpression::getReference)
+            .map(PsiReference::resolve)
+            .orElse(null);
+        }
+        else {
+          return Optional
+            .ofNullable(calleeQualifier.getReference())
+            .map(PsiReference::resolve)
+            .orElse(null);
         }
-        return false;
       }
     }
   }
diff --git a/python/testData/inspections/PyMissingConstructorInspection/implicitDunderClass.py b/python/testData/inspections/PyMissingConstructorInspection/implicitDunderClass.py
new file mode 100644 (file)
index 0000000..a635c91
--- /dev/null
@@ -0,0 +1,9 @@
+class First:
+    def __init__(self):
+        print('First inited')
+
+
+class Second(First):
+    def __init__(self):
+        super(__class__, self).__init__()
+        print('Second inited')
\ No newline at end of file
index 374e317bb097bdecbe451201559c68d97a9141af..468437e305a12d8de49dab699fd7c7ff2a30869a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2016 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.
@@ -23,42 +23,53 @@ import com.jetbrains.python.psi.LanguageLevel;
  */
 public class PyMissingConstructorTest extends PyTestCase {
   private static final String TEST_DIRECTORY = "inspections/PyMissingConstructorInspection/";
-  
+
   public void testBasic() {
     doTest();
   }
-  
-  public void testQualifiedName() { // PY-3278
+
+  // PY-3278
+  public void testQualifiedName() {
     doTest();
   }
-  
-  public void testNoConstructor() {  // PY-3238
+
+  // PY-3238
+  public void testNoConstructor() {
     doTest();
   }
-  
-  public void testDeepInheritance() {  // PY-3313
+
+  // PY-3313
+  public void testDeepInheritance() {
     doTest();
   }
-  
-  public void testInheritFromSelf() {  // PY-3395
+
+  // PY-3395
+  public void testInheritFromSelf() {
     doTest();
   }
 
-  public void testDunderClass() {  // PY-4038
+  // PY-4038
+  public void testExplicitDunderClass() {
     doTest();
   }
 
-  public void testException() { // PY-7176
+  // PY-20038
+  public void testImplicitDunderClass() {
+    runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest);
+  }
+
+  // PY-7176
+  public void testException() {
     doTest();
   }
 
-  public void testInnerClass() { //PY-7699
+  // PY-7699
+  public void testInnerClass() {
     doTest();
   }
-  
+
   public void testPy3k() {
-    setLanguageLevel(LanguageLevel.PYTHON30);
-    doTest();
+    runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest);
   }
 
   private void doTest() {
index 5765a9f3665a7b4dbf53d2ddd669e89c4425a2cd..2a57b8d38886994fe3cfb18373286f8512e0d57d 100644 (file)
@@ -9,7 +9,6 @@
         <element id="module-output" name="launcher-generator" />
       </element>
       <element id="library" level="project" name="sanselan-0.98-snapshot" />
-      <element id="library" level="project" name="guava" />
       <element id="library" level="project" name="jdom" />
     </root>
   </artifact>
diff --git a/tools/launcher-generator/.idea/libraries/guava.xml b/tools/launcher-generator/.idea/libraries/guava.xml
deleted file mode 100644 (file)
index d0bf7ef..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<component name="libraryTable">
-  <library name="guava">
-    <CLASSES>
-      <root url="jar://$PROJECT_DIR$/../../lib/guava-17.0.jar!/" />
-    </CLASSES>
-    <JAVADOC />
-    <SOURCES />
-  </library>
-</component>
\ No newline at end of file
index 97320410eec7c442fd59cbe9061ac38d1ce2955f..19b9b1bb1c2e1810b735a6c2555b955404c5c907 100644 (file)
@@ -3,8 +3,7 @@
   <component name="EntryPointsManager">
     <entry_points version="2.0" />
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>
-</project>
-
+</project>
\ No newline at end of file
index 1767e2dd63d0e5875fe5d02e5ea7996171e8894d..9fce306bcb4cad0bbede7bd61a356d1830f7491a 100644 (file)
@@ -11,7 +11,5 @@
     <orderEntry type="library" name="jdom" level="project" />
     <orderEntry type="library" name="sanselan-0.98-snapshot" level="project" />
     <orderEntry type="module" module-name="icons" />
-    <orderEntry type="library" name="guava" level="project" />
   </component>
-</module>
-
+</module>
\ No newline at end of file
index 673bc5afc2c1bb58e0552a231e67822b61e8b99b..d72e3a5e427a5a7ca6a64f687c3d291810ffaceb 100644 (file)
@@ -17,8 +17,6 @@
 
 package com.pme.launcher;
 
-import com.google.common.io.Files;
-import com.google.common.io.InputSupplier;
 import com.pme.exe.ExeFormat;
 import com.pme.exe.ExeReader;
 import com.pme.exe.SectionReader;
@@ -32,6 +30,9 @@ import com.pme.exe.res.vi.VersionInfo;
 import com.pme.util.OffsetTrackingInputStream;
 
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
 
 /**
  * Date: May 6, 2006
@@ -134,15 +135,14 @@ public class LauncherGenerator {
   }
 
   public void injectIcon(int id, final InputStream iconStream) throws IOException {
-    File f = File.createTempFile("launcher", "ico");
-    Files.copy(new InputSupplier<InputStream>() {
-      @Override
-      public InputStream getInput() throws IOException {
-        return iconStream;
-      }
-    }, f);
-    IconResourceInjector iconInjector = new IconResourceInjector();
-    iconInjector.injectIcon(f, myRoot, "IRD" + id);
+    Path f = Files.createTempFile("launcher", "ico");
+    try {
+      Files.copy(iconStream, f, StandardCopyOption.REPLACE_EXISTING);
+    }
+    finally {
+      iconStream.close();
+    }
+    new IconResourceInjector().injectIcon(f.toFile(), myRoot, "IRD" + id);
   }
 
   public void setVersionNumber(int majorVersion, int minorVersion, int bugfixVersion) {
index 44ca9feb2a9fb6987b2c963b9ba5221ac3c845ea..fe4af46e45e4f0d61deb5b90dea21e90b1dee9e2 100644 (file)
@@ -53,8 +53,8 @@ import com.intellij.psi.*;
 import com.intellij.psi.impl.PsiDocumentManagerBase;
 import com.intellij.psi.impl.source.tree.TreeUtil;
 import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
+import com.intellij.psi.templateLanguages.TemplateLanguage;
 import com.intellij.psi.xml.XmlTokenType;
-import com.intellij.util.Function;
 import com.intellij.util.SmartList;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.xml.util.HtmlUtil;
@@ -69,9 +69,9 @@ import java.util.Set;
  */
 public class XmlTagNameSynchronizer extends CommandAdapter implements NamedComponent {
   private static final Logger LOG = Logger.getInstance(XmlTagNameSynchronizer.class);
-  private static final Set<String> SUPPORTED_LANGUAGES = ContainerUtil.set(HTMLLanguage.INSTANCE.getID(),
-                                                                           XMLLanguage.INSTANCE.getID(),
-                                                                           XHTMLLanguage.INSTANCE.getID());
+  private static final Set<Language> SUPPORTED_LANGUAGES = ContainerUtil.set(HTMLLanguage.INSTANCE,
+                                                                             XMLLanguage.INSTANCE,
+                                                                             XHTMLLanguage.INSTANCE);
 
   private static final Key<TagNameSynchronizer> SYNCHRONIZER_KEY = Key.create("tag_name_synchronizer");
   private final FileDocumentManager myFileDocumentManager;
@@ -101,8 +101,10 @@ public class XmlTagNameSynchronizer extends CommandAdapter implements NamedCompo
     final PsiFile psiFile = file != null && file.isValid() ? PsiManager.getInstance(project).findFile(file) : null;
     if (psiFile != null) {
       for (Language language : psiFile.getViewProvider().getLanguages()) {
-        if ( SUPPORTED_LANGUAGES.contains(language.getID()) ||
-             HtmlUtil.supportsXmlTypedHandlers(psiFile)) return language;
+        if ((ContainerUtil.find(SUPPORTED_LANGUAGES, language::isKindOf) != null || HtmlUtil.supportsXmlTypedHandlers(psiFile)) &&
+            !(language instanceof TemplateLanguage)) {
+          return language;
+        }
       }
     }
     return null;