Merge remote-tracking branch 'origin/master'
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 3 Sep 2014 18:44:35 +0000 (22:44 +0400)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 3 Sep 2014 18:44:35 +0000 (22:44 +0400)
195 files changed:
java/debugger/impl/src/com/intellij/debugger/actions/JavaMarkObjectActionHandler.java
java/debugger/impl/src/com/intellij/debugger/actions/ObjectMarkupPropertiesDialog.java
java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java
java/debugger/impl/src/com/intellij/debugger/impl/DebuggerUtilsEx.java
java/debugger/impl/src/com/intellij/debugger/impl/PositionUtil.java
java/debugger/impl/src/com/intellij/debugger/settings/DebuggerDataViewsConfigurable.java
java/debugger/impl/src/com/intellij/debugger/ui/DebuggerEditorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/EvaluationDialog.java
java/debugger/impl/src/com/intellij/debugger/ui/ValueHint.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/EvaluationDescriptor.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/UserExpressionDescriptorImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/WatchItemDescriptor.java
java/debugger/impl/src/org/jetbrains/java/debugger/JavaDebuggerEditorsProvider.java
java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java
java/java-analysis-api/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java
java/java-analysis-impl/src/com/intellij/codeInspection/RedundantLambdaCodeBlockInspection.java
java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
java/java-impl/src/com/intellij/refactoring/extractMethod/AbstractExtractDialog.java
java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java
java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java [new file with mode: 0644]
java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectDialog.java
java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectHandler.java
java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractMethodObjectProcessor.java
java/java-psi-api/src/com/intellij/psi/LambdaUtil.java
java/java-psi-api/src/com/intellij/psi/util/PsiUtil.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLambdaExpressionImpl.java
java/java-psi-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/highlighting/EffectiveFinal.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr/beforeVoidValueChanged.java [new file with mode: 0644]
java/java-tests/testData/refactoring/extractMethodObject4Debugger/SimpleGeneration.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ConstraintsInferenceMiscTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Diamond8HighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/ExceptionVariablesInferenceTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalExpressionIncompleteHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/FunctionalTypeWildcardParameterizationTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GenericsHighlighting8Test.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaInferenceTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaParamsTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LambdaRedundantCastTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/LightAdvHighlightingJdk8Test.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MethodRefHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/MostSpecificResolutionTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java
java/testFramework/src/com/intellij/codeInsight/daemon/LightDaemonAnalyzerTestCase.java
platform/core-api/src/com/intellij/openapi/vfs/ex/http/HttpFileSystem.java
platform/core-impl/src/com/intellij/openapi/util/JDOMExternalizableAdapter.java
platform/core-impl/src/com/intellij/openapi/vfs/impl/http/HttpVirtualFile.java
platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java
platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java [new file with mode: 0644]
platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchSync.java [moved from plugins/git4idea/src/git4idea/ui/branch/GitBranchSyncSetting.java with 80% similarity]
platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsMultiRootBranchConfig.java [new file with mode: 0644]
platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsSyncBranchSettings.java [moved from platform/platform-impl/src/com/intellij/openapi/components/impl/stores/RoamingTypeExtensionPointBean.java with 58% similarity]
platform/lang-api/src/com/intellij/ide/util/projectWizard/ModuleBuilder.java
platform/lang-api/src/com/intellij/openapi/projectRoots/ui/PathEditor.java
platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsCustomizable.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/WrappingAndBracesPanel.java
platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java
platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarListener.java
platform/lang-impl/src/com/intellij/ide/navigationToolbar/ui/AbstractNavBarUI.java
platform/lang-impl/src/com/intellij/ide/scratch/CreateScratchFileAction.java
platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoActionModel.java
platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ProjectWithModulesStoreImpl.java
platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java
platform/lang-impl/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectSdksModel.java
platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooser.java
platform/platform-api/src/com/intellij/openapi/options/ConfigurableEP.java
platform/platform-api/src/com/intellij/openapi/options/ConfigurableProvider.java
platform/platform-api/src/com/intellij/openapi/options/CurrentUserHolder.java
platform/platform-api/src/com/intellij/openapi/options/SearchableConfigurable.java
platform/platform-api/src/com/intellij/util/ui/Animator.java
platform/platform-api/src/com/intellij/util/ui/AsyncProcessIcon.java
platform/platform-impl/src/com/intellij/ide/RecentDirectoryProjectsManager.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ChameleonAction.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ApplicationStoreImpl.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/CompoundSaveSession.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DefaultProjectStoreImpl.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/DirectoryBasedStorage.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/FileBasedStorage.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/IComponentStore.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/OldStreamProviderAdapter.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManager.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StateStorageManagerImpl.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java
platform/platform-impl/src/com/intellij/openapi/components/impl/stores/XmlElementStorage.java
platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditor.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/HttpFileEditorProvider.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/http/RemoteFilePanel.java
platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableExtensionPointUtil.java
platform/platform-impl/src/com/intellij/openapi/options/ex/ConfigurableWrapper.java
platform/platform-impl/src/com/intellij/openapi/options/ex/MixedConfigurableGroup.java
platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java
platform/platform-impl/src/org/jetbrains/io/ChannelRegistrar.java
platform/platform-resources-en/src/messages/ApplicationBundle.properties
platform/platform-resources/src/META-INF/PlatformExtensions.xml
platform/platform-resources/src/META-INF/VcsExtensions.xml
platform/platform-resources/src/META-INF/xdebugger.xml
platform/platform-resources/src/componentSets/Platform.xml
platform/platform-tests/testSrc/com/intellij/openapi/components/impl/XmlElementStorageTest.java
platform/projectModel-api/src/com/intellij/openapi/application/PathMacros.java
platform/projectModel-api/src/com/intellij/openapi/components/State.java
platform/projectModel-api/src/com/intellij/openapi/components/StateStorage.java
platform/projectModel-api/src/com/intellij/openapi/components/Storage.java
platform/projectModel-api/src/com/intellij/openapi/components/StorageAnnotationsDefaultValues.java [deleted file]
platform/projectModel-api/src/com/intellij/openapi/project/ProjectTypeService.java
platform/projectModel-impl/src/com/intellij/application/options/PathMacrosImpl.java
platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/DirectoryStorageData.java
platform/projectModel-impl/src/com/intellij/openapi/components/impl/stores/StorageData.java
platform/util-rt/src/com/intellij/util/containers/ContainerUtilRt.java
platform/util-rt/src/com/intellij/util/containers/HashMap.java
platform/util/src/com/intellij/execution/configurations/CommandLineTokenizer.java
platform/util/src/com/intellij/openapi/util/JDOMExternalizer.java
platform/util/src/com/intellij/util/containers/ContainerUtil.java
platform/util/testSrc/com/intellij/execution/configurations/CommandLineTokenizerTest.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsManagerConfigurableProvider.java [new file with mode: 0644]
platform/vcs-log/graph-api/src/com/intellij/vcs/log/graph/RowInfo.java
platform/vcs-log/graph-api/src/com/intellij/vcs/log/graph/RowType.java [new file with mode: 0644]
platform/vcs-log/graph/src/com/intellij/vcs/log/graph/impl/facade/AbstractVisibleGraph.java
platform/vcs-log/impl/src/com/intellij/vcs/log/data/EmptyVisibleGraph.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/handlers/XMarkObjectActionHandler.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/quick/common/DebuggerTreeWithHistoryPopup.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DebuggerConfigurable.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/settings/DebuggerConfigurableProvider.java [new file with mode: 0644]
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/ValueMarkerPresentationDialog.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/ValueMarkerPresentationDialogBase.java
plugins/ShortcutPromoter/src/com/intellij/promoter/ShortcutPromoterManager.java
plugins/devkit/src/projectRoots/IdeaJdk.java
plugins/devkit/src/testAssistant/TestLocationDataRule.java
plugins/git4idea/src/git4idea/config/GitVcsPanel.java
plugins/git4idea/src/git4idea/config/GitVcsSettings.java
plugins/git4idea/src/git4idea/repo/GitRepositoryImpl.java
plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java
plugins/git4idea/src/git4idea/ui/branch/GitMultiRootBranchConfig.java
plugins/git4idea/tests/git4idea/log/GitRefManagerTest.java
plugins/github/src/org/jetbrains/plugins/github/api/GithubApiUtil.java
plugins/github/src/org/jetbrains/plugins/github/api/GithubChangeIssueStateRequest.java [new file with mode: 0644]
plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepository.java
plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryType.java
plugins/hg4idea/src/META-INF/plugin.xml
plugins/hg4idea/src/org/zmlx/hg4idea/HgProjectSettings.java
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgAbstractGlobalAction.java
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java [deleted file]
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgCommonBranchActions.java [deleted file]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchAbstractAction.java [moved from plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchAbstractAction.java with 83% similarity]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java [moved from plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java with 77% similarity]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchUtil.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchesAction.java [moved from plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchesAction.java with 92% similarity]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgCommonBranchActions.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgMultiRootBranchConfig.java [new file with mode: 0644]
plugins/hg4idea/src/org/zmlx/hg4idea/push/HgPushSupport.java
plugins/hg4idea/src/org/zmlx/hg4idea/repo/HgRepositoryImpl.java
plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java
plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgConfigurationProjectPanel.form
plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgConfigurationProjectPanel.java
plugins/hg4idea/src/org/zmlx/hg4idea/util/HgUtil.java
python/edu/build/pycharm_edu_build.gant
python/edu/course-creator/resources/META-INF/plugin.xml
python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/CCProjectService.java
python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/CCRunTests.java [new file with mode: 0644]
python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/RunTestsLineMarker.java [new file with mode: 0644]
python/edu/course-creator/src/org/jetbrains/plugins/coursecreator/actions/CreateCourseArchive.java
python/edu/learn-python/resources/META-INF/plugin.xml
python/helpers/pycharm/_bdd_utils.py
python/helpers/pycharm/behave_runner.py
python/helpers/pycharm/lettuce_runner.py
python/helpers/pydev/pydev_monkey_qt.py
python/helpers/pydev/pydev_run_in_console.py
python/helpers/pydev/pydevconsole.py
python/helpers/pydev/pydevd.py
python/helpers/pydev/pydevd_utils.py
python/helpers/pydev/tests_python/_debugger_case_qthread3.py
python/src/META-INF/python-core.xml
xml/xml-psi-impl/src/com/intellij/javaee/ExternalResourceManagerExImpl.java
xml/xml-psi-impl/src/com/intellij/javaee/ProjectResources.java
xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java

index dcd0454c16aa9f2cfce4aaccf816134da50a55b2..87476cfd2ac3cd821d7a0373a4bff97730d5ff85 100644 (file)
@@ -71,7 +71,8 @@ public class JavaMarkObjectActionHandler extends MarkObjectActionHandler {
     
     final DebuggerTree tree = node.getTree();
     tree.saveState(node);
-    
+
+    final Component parent = event.getInputEvent().getComponent();
     final ValueDescriptorImpl valueDescriptor = ((ValueDescriptorImpl)descriptor);
     final DebuggerContextImpl debuggerContext = tree.getDebuggerContext();
     final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
@@ -93,7 +94,7 @@ public class JavaMarkObjectActionHandler extends MarkObjectActionHandler {
               final boolean suggestAdditionalMarkup = canSuggestAdditionalMarkup(debugProcess, valueDescriptor.getValue());
               SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
-                  ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(defaultText, suggestAdditionalMarkup);
+                  ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(parent, defaultText, suggestAdditionalMarkup);
                   dialog.show();
                   if (dialog.isOK()) {
                     result.set(Pair.create(dialog.getConfiguredMarkup(), dialog.isMarkAdditionalFields()));
index cd4aa14b770318de3fd33e77eeb87979e475ace3..454b130307cfe612500f208e85faeabb438d95bd 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.ui.ex.MultiLineLabel;
 import com.intellij.xdebugger.impl.ui.tree.ValueMarkerPresentationDialogBase;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.awt.*;
@@ -35,8 +36,8 @@ public class ObjectMarkupPropertiesDialog extends ValueMarkerPresentationDialogB
   private JPanel myAdditionalPropertiesPanel;
   private MultiLineLabel myDescriptionLabel;
 
-  public ObjectMarkupPropertiesDialog(@NotNull final String defaultText, boolean suggestAdditionalMarkup) {
-    super(defaultText);
+  public ObjectMarkupPropertiesDialog(@Nullable Component parent, @NotNull final String defaultText, boolean suggestAdditionalMarkup) {
+    super(parent, defaultText);
     mySuggestAdditionalMarkup = suggestAdditionalMarkup;
     myDescriptionLabel.setText("If the value is referenced by a constant field of an abstract class,\n" +
                                "IDEA could additionally mark all values referenced from this class with the names of referencing fields.");
index 83ad91b4e27d3a2094ad68a8d9263284cb1637e1..a5716cc1642a20c9574b349e76375e34b3d8c60a 100644 (file)
@@ -31,7 +31,7 @@ import com.intellij.debugger.engine.DebuggerUtils;
 import com.intellij.debugger.engine.JVMName;
 import com.intellij.debugger.engine.JVMNameUtil;
 import com.intellij.debugger.engine.evaluation.*;
-import com.intellij.debugger.ui.DebuggerEditorImpl;
+import com.intellij.debugger.impl.DebuggerUtilsEx;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
@@ -66,8 +66,8 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
 
     final Project project = contextElement.getProject();
 
-    CodeFragmentFactory factory = DebuggerEditorImpl.findAppropriateFactory(text, contextElement);
-    PsiCodeFragment codeFragment = new CodeFragmentFactoryContextWrapper(factory).createCodeFragment(text, contextElement, project);
+    CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, contextElement);
+    PsiCodeFragment codeFragment = factory.createCodeFragment(text, contextElement, project);
     if (codeFragment == null) {
       throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.expression", text.getText()));
     }
index 026b7111d18fb382e508e347b0906d6ba8f285dd..ae6bb5dd7b27b739816bc7b51f77edc518d37928 100644 (file)
@@ -37,6 +37,7 @@ import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.*;
@@ -403,17 +404,25 @@ public abstract class DebuggerUtilsEx extends DebuggerUtils {
 
   public abstract CompletionEditor createEditor(Project project, PsiElement context, @NonNls String recentsId);
 
-  @Nullable
-  public static CodeFragmentFactory getEffectiveCodeFragmentFactory(final PsiElement psiContext) {
-    final CodeFragmentFactory factory = ApplicationManager.getApplication().runReadAction(new Computable<CodeFragmentFactory>() {
+  @NotNull
+  public static CodeFragmentFactory findAppropriateCodeFragmentFactory(final TextWithImports text, final PsiElement context) {
+    CodeFragmentFactory factory = ApplicationManager.getApplication().runReadAction(new Computable<CodeFragmentFactory>() {
       @Override
       public CodeFragmentFactory compute() {
-        final List<CodeFragmentFactory> codeFragmentFactories = getCodeFragmentFactories(psiContext);
-        // the list always contains at least DefaultCodeFragmentFactory
-        return codeFragmentFactories.get(0);
+        final FileType fileType = text.getFileType();
+        final List<CodeFragmentFactory> factories = getCodeFragmentFactories(context);
+        if (fileType == null) {
+          return factories.get(0);
+        }
+        for (CodeFragmentFactory factory : factories) {
+          if (factory.getFileType().equals(fileType)) {
+            return factory;
+          }
+        }
+        return DefaultCodeFragmentFactory.getInstance();
       }
     });
-    return factory != null? new CodeFragmentFactoryContextWrapper(factory) : null;
+    return new CodeFragmentFactoryContextWrapper(factory);
   }
 
   private static class SigReader {
index 2b23f371f5287b315bc45325b89c721533286ddf..47558e8c4da8f85eab7a720eb0cd150ab02361a3 100644 (file)
@@ -41,6 +41,7 @@ public class PositionUtil extends ContextUtil {
     return ContextUtil.getSourcePosition(context);
   }
 
+  @Nullable
   public static PsiElement getContextElement(final StackFrameContext context) {
     if(context instanceof DebuggerContextImpl) return ((DebuggerContextImpl) context).getContextElement();
 
index 452a924aed004cb85e5e3c1b8dac2682c1156733..8785e687eff3818bd6677351ac28f85a860db9d5 100644 (file)
@@ -53,7 +53,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
   private JCheckBox myCbShowObjectId;
 
   private StateRestoringCheckBox myCbShowStaticFinalFields;
-  private final ArrayRendererConfigurable myArrayRendererConfigurable;
+  //private final ArrayRendererConfigurable myArrayRendererConfigurable;
   private JCheckBox myCbEnableAlternateViews;
 
   private JCheckBox myCbEnableToString;
@@ -66,12 +66,12 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
 
   public DebuggerDataViewsConfigurable(@Nullable Project project) {
     myProject = project;
-    myArrayRendererConfigurable = new ArrayRendererConfigurable(NodeRendererSettings.getInstance().getArrayRenderer());
+    //myArrayRendererConfigurable = new ArrayRendererConfigurable(NodeRendererSettings.getInstance().getArrayRenderer());
   }
 
   @Override
   public void disposeUIResources() {
-    myArrayRendererConfigurable.disposeUIResources();
+    //myArrayRendererConfigurable.disposeUIResources();
     myToStringFilterEditor = null;
     myProject = null;
   }
@@ -165,13 +165,14 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
 
     panel.add(showPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 0, 0, 0), 0, 0));
 
-    final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
-    final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
-    assert arraysComponent != null;
-    arraysPanel.add(arraysComponent, BorderLayout.CENTER);
-    arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
-    arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
-    panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
+    //final JPanel arraysPanel = new JPanel(new BorderLayout(0, UIUtil.DEFAULT_VGAP));
+    //final JComponent arraysComponent = myArrayRendererConfigurable.createComponent();
+    //assert arraysComponent != null;
+    //arraysPanel.add(arraysComponent, BorderLayout.CENTER);
+    //arraysPanel.add(myCbHideNullArrayElements, BorderLayout.SOUTH);
+    //arraysPanel.setBorder(IdeBorderFactory.createTitledBorder("Arrays", true));
+    //panel.add(arraysPanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
+    panel.add(myCbHideNullArrayElements, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
 
     panel.add(myCbEnableAlternateViews, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 0, 0, 10), 0, 0));
     // starting 4-th row
@@ -209,7 +210,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
 
     myAutoTooltip.save();
 
-    myArrayRendererConfigurable.apply();
+    //myArrayRendererConfigurable.apply();
 
     rendererSettings.fireRenderersChanged();
   }
@@ -250,7 +251,7 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
     myRbFromList.setEnabled(toStringEnabled);
     myRbAllThatOverride.setEnabled(toStringEnabled);
 
-    myArrayRendererConfigurable.reset();
+    //myArrayRendererConfigurable.reset();
   }
 
   @Override
@@ -266,9 +267,9 @@ public class DebuggerDataViewsConfigurable implements SearchableConfigurable {
   }
 
   private boolean areDefaultRenderersModified() {
-    if (myArrayRendererConfigurable.isModified()) {
-      return true;
-    }
+    //if (myArrayRendererConfigurable.isModified()) {
+    //  return true;
+    //}
 
     final NodeRendererSettings rendererSettings = NodeRendererSettings.getInstance();
 
index deff5fbd2ae57e2beff2d196230f318aeca28466..8805341c5c461627a30ffc4187a1766dc2e95571 100644 (file)
@@ -294,7 +294,7 @@ public abstract class DebuggerEditorImpl extends CompletionEditor{
   }
 
   @NotNull
-  public static CodeFragmentFactory findAppropriateFactory(@NotNull TextWithImports text, @NotNull PsiElement context) {
+  private static CodeFragmentFactory findAppropriateFactory(@NotNull TextWithImports text, @Nullable PsiElement context) {
     for (CodeFragmentFactory factory : DebuggerUtilsEx.getCodeFragmentFactories(context)) {
       if (factory.getFileType().equals(text.getFileType())) {
         return factory;
index 6359af31e5a375dc6f43c6026db4cf3c0ca3daad..0acaf8779e1f60fcde1733961141c2f35f2b2c21 100644 (file)
@@ -30,7 +30,6 @@ import com.intellij.debugger.ui.impl.ValueNodeDnD;
 import com.intellij.debugger.ui.impl.WatchDebuggerTree;
 import com.intellij.debugger.ui.impl.WatchPanel;
 import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
-import com.intellij.debugger.ui.impl.watch.EvaluationDescriptor;
 import com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
@@ -110,10 +109,10 @@ public abstract class EvaluationDialog extends DialogWrapper {
     try {
       setOKActionEnabled(false);
       NodeDescriptorImpl descriptor = myEvaluationPanel.getWatchTree().addWatch(codeToEvaluate, "result").getDescriptor();
-      if (descriptor instanceof EvaluationDescriptor) {
-        final EvaluationDescriptor evalDescriptor = (EvaluationDescriptor)descriptor;
-        evalDescriptor.setCodeFragmentFactory(myEditor.getCurrentFactory());
-      }
+      //if (descriptor instanceof EvaluationDescriptor) {
+      //  final EvaluationDescriptor evalDescriptor = (EvaluationDescriptor)descriptor;
+      //  evalDescriptor.setCodeFragmentFactory(myEditor.getCurrentFactory());
+      //}
       myEvaluationPanel.getWatchTree().rebuild(getDebuggerContext());
       descriptor.myIsExpanded = true;
     }
index 8a0877273335c0752c3512222e6487057cba6f29..9034e5c82b131e8d0491e39497ed50d8f0789181 100644 (file)
@@ -94,9 +94,8 @@ public class ValueHint extends AbstractValueHint {
       return EvaluatorBuilderImpl.getInstance().build(myCurrentExpression, debuggerContext.getSourcePosition());
     }
 
-    CodeFragmentFactory factory = DebuggerUtilsEx.getEffectiveCodeFragmentFactory(myCurrentExpression);
     TextWithImportsImpl textWithImports = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, myCurrentExpression.getText());
-    if (factory == null) return null;
+    CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(textWithImports, myCurrentExpression);
     JavaCodeFragment codeFragment = factory.createCodeFragment(textWithImports, myCurrentExpression.getContext(), getProject());
     codeFragment.forceResolveScope(GlobalSearchScope.allScope(getProject()));
     return factory.getEvaluatorBuilder().build(codeFragment, debuggerContext.getSourcePosition());
index 510a74e9e5792c0a8ee68d5b6ae08a467bbb772d..56c4c165388130fab13632064ad74151777312ae 100644 (file)
@@ -21,7 +21,10 @@ import com.intellij.debugger.DebuggerInvocationUtil;
 import com.intellij.debugger.EvaluatingComputable;
 import com.intellij.debugger.engine.ContextUtil;
 import com.intellij.debugger.engine.StackFrameContext;
-import com.intellij.debugger.engine.evaluation.*;
+import com.intellij.debugger.engine.evaluation.EvaluateException;
+import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
+import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
+import com.intellij.debugger.engine.evaluation.TextWithImports;
 import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
 import com.intellij.debugger.engine.evaluation.expression.Modifier;
 import com.intellij.debugger.impl.DebuggerUtilsEx;
@@ -34,11 +37,10 @@ import com.intellij.psi.PsiCodeFragment;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiExpression;
 import com.intellij.psi.PsiExpressionCodeFragment;
+import com.intellij.psi.search.GlobalSearchScope;
 import com.sun.jdi.ObjectCollectedException;
 import com.sun.jdi.ObjectReference;
 import com.sun.jdi.Value;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * @author lex
@@ -46,7 +48,6 @@ import org.jetbrains.annotations.Nullable;
 public abstract class EvaluationDescriptor extends ValueDescriptorImpl{
   private Modifier myModifier;
   protected TextWithImports myText;
-  private CodeFragmentFactory myCodeFragmentFactory = null; // used to force specific context, e.g. from evaluation
 
   protected EvaluationDescriptor(TextWithImports text, Project project, Value value) {
     super(project, value);
@@ -59,26 +60,18 @@ public abstract class EvaluationDescriptor extends ValueDescriptorImpl{
     myText = text;
   }
 
-  public final void setCodeFragmentFactory(CodeFragmentFactory codeFragmentFactory) {
-    myCodeFragmentFactory = codeFragmentFactory != null? new CodeFragmentFactoryContextWrapper(codeFragmentFactory) : null;
-  }
-
-  @Nullable
-  public final CodeFragmentFactory getCodeFragmentFactory() {
-    return myCodeFragmentFactory;
-  }
-
-  protected final @NotNull CodeFragmentFactory getEffectiveCodeFragmentFactory(final PsiElement psiContext) {
-    if (myCodeFragmentFactory != null) {
-      return myCodeFragmentFactory;
-    }
-    return DebuggerUtilsEx.getEffectiveCodeFragmentFactory(psiContext);
-  }
-
   protected abstract EvaluationContextImpl getEvaluationContext (EvaluationContextImpl evaluationContext);
 
   protected abstract PsiCodeFragment getEvaluationCode(StackFrameContext context) throws EvaluateException;
 
+  protected PsiCodeFragment createCodeFragment(PsiElement context) {
+    TextWithImports text = getEvaluationText();
+    final PsiCodeFragment fragment =
+      DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context).createCodeFragment(text, context, myProject);
+    fragment.forceResolveScope(GlobalSearchScope.allScope(myProject));
+    return fragment;
+  }
+
   public final Value calcValue(final EvaluationContextImpl evaluationContext) throws EvaluateException {
     try {
       final EvaluationContextImpl thisEvaluationContext = getEvaluationContext(evaluationContext);
@@ -91,9 +84,8 @@ public abstract class EvaluationDescriptor extends ValueDescriptorImpl{
         evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, new EvaluatingComputable<ExpressionEvaluator>() {
           public ExpressionEvaluator compute() throws EvaluateException {
             final PsiElement psiContext = PositionUtil.getContextElement(evaluationContext);
-            return getEffectiveCodeFragmentFactory(psiContext).getEvaluatorBuilder().build(getEvaluationCode(thisEvaluationContext),
-                                                                                           ContextUtil
-                                                                                             .getSourcePosition(thisEvaluationContext));
+            return DebuggerUtilsEx.findAppropriateCodeFragmentFactory(getEvaluationText(), psiContext).getEvaluatorBuilder()
+              .build(getEvaluationCode(thisEvaluationContext), ContextUtil.getSourcePosition(thisEvaluationContext));
           }
         });
       }
index c3dbed6c7fbbe3669a6037ec268924e41cb71216..35e73c2b637805eca0e0d37dbd333f511741b6e6 100644 (file)
 package com.intellij.debugger.ui.impl.watch;
 
 import com.intellij.debugger.DebuggerBundle;
+import com.intellij.debugger.engine.DebuggerUtils;
 import com.intellij.debugger.engine.StackFrameContext;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
 import com.intellij.debugger.engine.evaluation.TextWithImports;
-import com.intellij.debugger.impl.DebuggerUtilsEx;
 import com.intellij.debugger.settings.NodeRendererSettings;
 import com.intellij.debugger.ui.tree.UserExpressionDescriptor;
 import com.intellij.debugger.ui.tree.render.ClassRenderer;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiCodeFragment;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.util.StringBuilderSpinAllocator;
 import com.sun.jdi.ObjectReference;
 import com.sun.jdi.Value;
@@ -78,16 +77,13 @@ public class UserExpressionDescriptorImpl extends EvaluationDescriptor implement
     if(value instanceof ObjectReference) {
       final String typeName = value.type().name();
 
-      final PsiClass psiClass = DebuggerUtilsEx.findClass(myTypeName, myProject, context.getDebugProcess().getSearchScope());
+      final PsiClass psiClass = DebuggerUtils.findClass(myTypeName, myProject, context.getDebugProcess().getSearchScope());
 
       if (psiClass == null) {
         throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.invalid.type.name", typeName));
       }
 
-      final PsiCodeFragment fragment =
-        getEffectiveCodeFragmentFactory(psiClass).createCodeFragment(getEvaluationText(), psiClass, myProject);
-      fragment.forceResolveScope(GlobalSearchScope.allScope(myProject));
-      return fragment;
+      return createCodeFragment(psiClass);
     }
     else {
       throw EvaluateExceptionUtil.createEvaluateException(
index 30f5169fbd1e1dcb4d6b11941d00235ce3cd5db1..f60825cee24cca54d6a4ab99636ff5261e325632 100644 (file)
@@ -28,8 +28,6 @@ import com.intellij.debugger.impl.PositionUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.psi.PsiCodeFragment;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.sun.jdi.Value;
 import org.jetbrains.annotations.Nullable;
 
@@ -85,9 +83,6 @@ public class WatchItemDescriptor extends EvaluationDescriptor {
   }
 
   protected PsiCodeFragment getEvaluationCode(StackFrameContext context) throws EvaluateException {
-    final PsiElement psiContext = PositionUtil.getContextElement(context);
-    final PsiCodeFragment fragment = getEffectiveCodeFragmentFactory(psiContext).createCodeFragment(getEvaluationText(), psiContext, myProject);
-    fragment.forceResolveScope(GlobalSearchScope.allScope(myProject));
-    return fragment;
+    return createCodeFragment(PositionUtil.getContextElement(context));
   }
 }
\ No newline at end of file
index 8c85e494dea22df772839220fb64562b4447a248..c3b19470e6a4430ce2661bfd5b4dfec09ff37342 100644 (file)
@@ -1,11 +1,9 @@
 package org.jetbrains.java.debugger;
 
 import com.intellij.debugger.engine.evaluation.CodeFragmentFactory;
-import com.intellij.debugger.engine.evaluation.CodeFragmentFactoryContextWrapper;
 import com.intellij.debugger.engine.evaluation.TextWithImports;
 import com.intellij.debugger.engine.evaluation.TextWithImportsImpl;
 import com.intellij.debugger.impl.DebuggerUtilsEx;
-import com.intellij.debugger.ui.DebuggerEditorImpl;
 import com.intellij.ide.highlighter.JavaFileType;
 import com.intellij.lang.Language;
 import com.intellij.openapi.editor.Document;
@@ -73,16 +71,15 @@ public class JavaDebuggerEditorsProvider extends XDebuggerEditorsProviderBase {
                                                  boolean isPhysical) {
     TextWithImports text = TextWithImportsImpl.fromXExpression(expression);
     if (text != null && context != null) {
-      CodeFragmentFactory factory = new CodeFragmentFactoryContextWrapper(DebuggerEditorImpl.findAppropriateFactory(text, context));
+      CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context);
       JavaCodeFragment codeFragment = factory.createPresentationCodeFragment(text, context, project);
       codeFragment.forceResolveScope(GlobalSearchScope.allScope(project));
-      if (context != null) {
-        final PsiClass contextClass = PsiTreeUtil.getNonStrictParentOfType(context, PsiClass.class);
-        if (contextClass != null) {
-          final PsiClassType contextType =
-            JavaPsiFacade.getInstance(codeFragment.getProject()).getElementFactory().createType(contextClass);
-          codeFragment.setThisType(contextType);
-        }
+
+      final PsiClass contextClass = PsiTreeUtil.getNonStrictParentOfType(context, PsiClass.class);
+      if (contextClass != null) {
+        final PsiClassType contextType =
+          JavaPsiFacade.getInstance(codeFragment.getProject()).getElementFactory().createType(contextClass);
+        codeFragment.setThisType(contextType);
       }
       return codeFragment;
     }
index 3d497b829d50840df72c6e880f70c893aeddffad..3f087a9983045f9f768e3fa72b82fc4f82478960 100644 (file)
@@ -116,7 +116,7 @@ public class ImportModuleAction extends AnAction {
     if (lastLocation != null) {
       toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
     }
-    VirtualFile[] files = chooser.choose(toSelect, project);
+    VirtualFile[] files = chooser.choose(project, toSelect);
     if (files.length == 0) {
       return null;
     }
index 10df2939f6e75471122b4ce00500be92a28dc21a..b3de63ee0f7b455325c046ebbb0a0edfe2e2fd1e 100644 (file)
@@ -206,7 +206,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
       myEditors.add(new ModuleConfigurableWrapper(moduleConfigurable));
     }
     for(ModuleConfigurableEP extension : myModule.getExtensions(MODULE_CONFIGURABLES)) {
-      myEditors.add(new ModuleConfigurableWrapper(extension.createConfigurable()));
+      if (extension.isConfigurableProvided()) {
+        myEditors.add(new ModuleConfigurableWrapper(extension.createConfigurable()));
+      }
     }
   }
 
index 76ab3643cb79928aeaf3244ccbb44c2850518b4b..c7068ec43482eda97db1ad80bdd0e6276c83d88d 100644 (file)
@@ -76,6 +76,9 @@ public class LanguageLevelModuleExtension extends ModuleExtension<LanguageLevelM
         //bad value was stored
       }
     }
+    else {
+      myLanguageLevel = null;
+    }
   }
 
   @Override
index 0dfa5df979bc7f5d4dfd15dfb2b99e8663784a58..4216bb80051894c4a821dc38e282f92b441c4899 100644 (file)
@@ -67,6 +67,9 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
         if (body instanceof PsiCodeBlock) {
           PsiExpression psiExpression = getExpression((PsiCodeBlock)body);
           if (psiExpression != null) {
+            if (!expression.isVoidCompatible() && LambdaUtil.isExpressionStatementExpression(psiExpression)) {
+              return;
+            }
             final PsiElement errorElement;
             final PsiElement parent = psiExpression.getParent();
             if (parent instanceof PsiReturnStatement) {
index 6b5c1fe87e643f3bd195cb190e38d7e3cc5ecdda..90c4f630df1c3fd31a04775d4b34ae1bcdc162af 100644 (file)
@@ -58,8 +58,8 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
 
   @Override
   public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
-    consumer.showAllStandardOptions();
     if (settingsType == SettingsType.SPACING_SETTINGS) {
+      consumer.showAllStandardOptions();
       consumer.showCustomOption(JavaCodeStyleSettings.class, "SPACES_WITHIN_ANGLE_BRACKETS", "Angle brackets",CodeStyleSettingsCustomizable.SPACES_WITHIN);
 
       String groupName = CodeStyleSettingsCustomizable.SPACES_IN_TYPE_ARGUMENTS;
@@ -71,9 +71,87 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
       consumer.showCustomOption(JavaCodeStyleSettings.class, "SPACE_AROUND_TYPE_BOUNDS_IN_TYPE_PARAMETERS", "Around type bounds", groupName);
     }
     else if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
+      consumer.showStandardOptions("RIGHT_MARGIN",
+                                   "KEEP_LINE_BREAKS",
+                                   "KEEP_FIRST_COLUMN_COMMENT",
+                                   "KEEP_CONTROL_STATEMENT_IN_ONE_LINE",
+                                   "KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE",
+                                   "KEEP_SIMPLE_BLOCKS_IN_ONE_LINE",
+                                   "KEEP_SIMPLE_METHODS_IN_ONE_LINE",
+                                   "KEEP_SIMPLE_CLASSES_IN_ONE_LINE",
+                                   "WRAP_LONG_LINES",
+                                   "CLASS_BRACE_STYLE",
+                                   "METHOD_BRACE_STYLE",
+                                   "BRACE_STYLE",
+                                   "EXTENDS_LIST_WRAP",
+                                   "ALIGN_MULTILINE_EXTENDS_LIST",
+                                   "EXTENDS_KEYWORD_WRAP",
+                                   "THROWS_LIST_WRAP",
+                                   "ALIGN_MULTILINE_THROWS_LIST",
+                                   "ALIGN_THROWS_KEYWORD",
+                                   "THROWS_KEYWORD_WRAP",
+                                   "METHOD_PARAMETERS_WRAP",
+                                   "ALIGN_MULTILINE_PARAMETERS",
+                                   "METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
+                                   "METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
+                                   "CALL_PARAMETERS_WRAP",
+                                   "ALIGN_MULTILINE_PARAMETERS_IN_CALLS",
+                                   "PREFER_PARAMETERS_WRAP",
+                                   "CALL_PARAMETERS_LPAREN_ON_NEXT_LINE",
+                                   "CALL_PARAMETERS_RPAREN_ON_NEXT_LINE",
+                                   "ALIGN_MULTILINE_METHOD_BRACKETS",
+                                   "METHOD_CALL_CHAIN_WRAP",
+                                   "ALIGN_MULTILINE_CHAINED_METHODS",
+                                   "ALIGN_GROUP_FIELD_DECLARATIONS",
+                                   "IF_BRACE_FORCE",
+                                   "ELSE_ON_NEW_LINE",
+                                   "SPECIAL_ELSE_IF_TREATMENT",
+                                   "FOR_STATEMENT_WRAP",
+                                   "ALIGN_MULTILINE_FOR",
+                                   "FOR_STATEMENT_LPAREN_ON_NEXT_LINE",
+                                   "FOR_STATEMENT_RPAREN_ON_NEXT_LINE",
+                                   "FOR_BRACE_FORCE",
+                                   "WHILE_BRACE_FORCE",
+                                   "DOWHILE_BRACE_FORCE",
+                                   "WHILE_ON_NEW_LINE",
+                                   "INDENT_CASE_FROM_SWITCH",
+                                   "RESOURCE_LIST_WRAP",
+                                   "ALIGN_MULTILINE_RESOURCES",
+                                   "RESOURCE_LIST_LPAREN_ON_NEXT_LINE",
+                                   "RESOURCE_LIST_RPAREN_ON_NEXT_LINE",
+                                   "CATCH_ON_NEW_LINE",
+                                   "FINALLY_ON_NEW_LINE",
+                                   "BINARY_OPERATION_WRAP",
+                                   "ALIGN_MULTILINE_BINARY_OPERATION",
+                                   "BINARY_OPERATION_SIGN_ON_NEXT_LINE",
+                                   "ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION",
+                                   "PARENTHESES_EXPRESSION_LPAREN_WRAP",
+                                   "PARENTHESES_EXPRESSION_RPAREN_WRAP",
+                                   "ASSIGNMENT_WRAP",
+                                   "ALIGN_MULTILINE_ASSIGNMENT",
+                                   "PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE",
+                                   "TERNARY_OPERATION_WRAP",
+                                   "ALIGN_MULTILINE_TERNARY_OPERATION",
+                                   "TERNARY_OPERATION_SIGNS_ON_NEXT_LINE",
+                                   "ARRAY_INITIALIZER_WRAP",
+                                   "ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION",
+                                   "ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE",
+                                   "ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE",
+                                   "MODIFIER_LIST_WRAP",
+                                   "ASSERT_STATEMENT_WRAP",
+                                   "ASSERT_STATEMENT_COLON_ON_NEXT_LINE",
+                                   "CLASS_ANNOTATION_WRAP",
+                                   "METHOD_ANNOTATION_WRAP",
+                                   "FIELD_ANNOTATION_WRAP",
+                                   "PARAMETER_ANNOTATION_WRAP",
+                                   "VARIABLE_ANNOTATION_WRAP",
+                                   "ENUM_CONSTANTS_WRAP");
       String groupName = ApplicationBundle.message("wrapping.fields.annotation");
       consumer.showCustomOption(JavaCodeStyleSettings.class, "DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION", "Do not wrap after single annotation", groupName);
     }
+    else {
+      consumer.showAllStandardOptions();
+    }
   }
 
   @Override
index 7e49181472b042060fcc664aaa55c0d122b28d9e..9f83b6ed080be1ed251fdbcf1c164052a5512029 100644 (file)
  */
 package com.intellij.refactoring.extractMethod;
 
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.psi.PsiModifier;
 import com.intellij.refactoring.util.VariableData;
 
-public abstract class AbstractExtractDialog extends DialogWrapper {
-  protected AbstractExtractDialog(Project project) {
-    super(project, true);
-  }
-
-
-  public abstract String getChosenMethodName();
-
-  public abstract VariableData[] getChosenParameters();
+public interface AbstractExtractDialog {
 
+  String getChosenMethodName();
+  VariableData[] getChosenParameters();
   @PsiModifier.ModifierConstant
-  public abstract String getVisibility();
-
-  public abstract boolean isMakeStatic();
+  String getVisibility();
+  boolean isMakeStatic();
+  boolean isChainedConstructor();
 
-  public abstract boolean isChainedConstructor();
+  void show();
+  boolean isOK();
 }
\ No newline at end of file
index f4cfccb496ada1c8c228f5127365955506f0f971..fc933de2b80ee0842148be3ef0e9cfdd77217459 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Splitter;
 import com.intellij.openapi.ui.VerticalFlowLayout;
 import com.intellij.openapi.util.text.StringUtil;
@@ -59,7 +60,7 @@ import java.awt.event.*;
  * @author Konstantin Bulenkov
  */
 @SuppressWarnings("MethodMayBeStatic")
-public class ExtractMethodDialog extends AbstractExtractDialog {
+public class ExtractMethodDialog extends DialogWrapper implements AbstractExtractDialog {
   public static final String EXTRACT_METHOD_DEFAULT_VISIBILITY = "extract.method.default.visibility";
   private final Project myProject;
   private final PsiType myReturnType;
@@ -96,7 +97,7 @@ public class ExtractMethodDialog extends AbstractExtractDialog {
                              String title,
                              String helpId,
                              final PsiElement[] elementsToExtract) {
-    super(project);
+    super(project, true);
     myProject = project;
     myTargetClass = targetClass;
     myReturnType = returnType;
index c61c29c58ff978aee8382f739fc54326b54ebb1a..e63b3751e425d74e02df4473ab0d4d30da88cf6c 100644 (file)
@@ -463,14 +463,14 @@ public class ExtractMethodProcessor implements MatchProvider {
   protected void apply(final AbstractExtractDialog dialog) {
     myMethodName = dialog.getChosenMethodName();
     myVariableDatum = dialog.getChosenParameters();
-    myStatic |= dialog.isMakeStatic();
+    myStatic = isStatic() | dialog.isMakeStatic();
     myIsChainedConstructor = dialog.isChainedConstructor();
     myMethodVisibility = dialog.getVisibility();
   }
 
   protected AbstractExtractDialog createExtractMethodDialog(final boolean direct) {
-    return new ExtractMethodDialog(myProject, myTargetClass, myInputVariables, myReturnType, myTypeParameterList,
-                                                         myThrownExceptions, myStatic, myCanBeStatic, myCanBeChainedConstructor,
+    return new ExtractMethodDialog(myProject, myTargetClass, myInputVariables, myReturnType, getTypeParameterList(),
+                                   getThrownExceptions(), isStatic(), isCanBeStatic(), myCanBeChainedConstructor,
                                                          suggestInitialMethodName(),
                                                          myRefactoringName, myHelpId, myElements) {
       protected boolean areTypesDirected() {
@@ -620,7 +620,7 @@ public class ExtractMethodProcessor implements MatchProvider {
 
   private void doExtract() throws IncorrectOperationException {
 
-    PsiMethod newMethod = generateEmptyMethod(myThrownExceptions, myStatic);
+    PsiMethod newMethod = generateEmptyMethod(getThrownExceptions(), isStatic());
 
     myExpression = myInputVariables.replaceWrappedReferences(myElements, myExpression);
     renameInputVariables();
@@ -991,6 +991,10 @@ public class ExtractMethodProcessor implements MatchProvider {
     return myTargetClass;
   }
 
+  public PsiType getReturnType() {
+    return myReturnType;
+  }
+
   private PsiMethod generateEmptyMethod(PsiClassType[] exceptions, boolean isStatic) throws IncorrectOperationException {
     PsiMethod newMethod;
     if (myIsChainedConstructor) {
@@ -1001,8 +1005,8 @@ public class ExtractMethodProcessor implements MatchProvider {
       PsiUtil.setModifierProperty(newMethod, PsiModifier.STATIC, isStatic);
     }
     PsiUtil.setModifierProperty(newMethod, myMethodVisibility, true);
-    if (myTypeParameterList != null) {
-      newMethod.getTypeParameterList().replace(myTypeParameterList);
+    if (getTypeParameterList() != null) {
+      newMethod.getTypeParameterList().replace(getTypeParameterList());
     }
     PsiCodeBlock body = newMethod.getBody();
     LOG.assertTrue(body != null);
@@ -1400,4 +1404,28 @@ public class ExtractMethodProcessor implements MatchProvider {
   public InputVariables getInputVariables() {
     return myInputVariables;
   }
+
+  public PsiTypeParameterList getTypeParameterList() {
+    return myTypeParameterList;
+  }
+
+  public PsiClassType[] getThrownExceptions() {
+    return myThrownExceptions;
+  }
+
+  public boolean isStatic() {
+    return myStatic;
+  }
+
+  public boolean isCanBeStatic() {
+    return myCanBeStatic;
+  }
+
+  public PsiElement[] getElements() {
+    return myElements;
+  }
+
+  public PsiVariable[] getOutputVariables() {
+    return myOutputVariables;
+  }
 }
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethodObject/ExtractLightMethodObjectHandler.java
new file mode 100644 (file)
index 0000000..c5ee560
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.refactoring.extractMethodObject;
+
+import com.intellij.codeInsight.CodeInsightUtil;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.RangeMarker;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.*;
+import com.intellij.refactoring.extractMethod.AbstractExtractDialog;
+import com.intellij.refactoring.extractMethod.InputVariables;
+import com.intellij.refactoring.util.VariableData;
+import org.jetbrains.annotations.Nullable;
+
+public class ExtractLightMethodObjectHandler {
+  private static final Logger LOG = Logger.getInstance("#" + ExtractLightMethodObjectHandler.class.getName());
+
+  public static class ExtractedData {
+    private String myGeneratedCallText;
+    private PsiClass myGeneratedInnerClass;
+
+    public ExtractedData(String generatedCallText, PsiClass generatedInnerClass) {
+      myGeneratedCallText = generatedCallText;
+      myGeneratedInnerClass = generatedInnerClass;
+    }
+
+    public String getGeneratedCallText() {
+      return myGeneratedCallText;
+    }
+
+    public PsiClass getGeneratedInnerClass() {
+      return myGeneratedInnerClass;
+    }
+  }
+
+  @Nullable
+  public static ExtractedData extractLightMethodObject(final Project project,
+                                                       final Editor editor,
+                                                       final PsiFile file,
+                                                       final PsiElement[] elements,
+                                                       final String methodName) {
+    if (elements == null || elements.length == 0) {
+      return null;
+    }
+
+    final PsiFile copy = PsiFileFactory.getInstance(project)
+      .createFileFromText(file.getName(), file.getFileType(), file.getText(), file.getModificationStamp(), true);
+
+    final PsiElement[] elementsCopy = new PsiElement[elements.length];
+    for (int i = 0; i < elements.length; i++) {
+      PsiElement element = elements[i];
+      final TextRange textRange = element.getTextRange();
+      elementsCopy[i] = CodeInsightUtil.findElementInRange(copy, textRange.getStartOffset(), textRange.getEndOffset(), element.getClass());
+    }
+
+    final Document document = PsiDocumentManager.getInstance(project).getDocument(copy);
+    LOG.assertTrue(document != null);
+
+    final int startOffset = elements[0].getTextRange().getStartOffset();
+    final int endOffset = elements[elements.length - 1].getTextRange().getEndOffset();
+
+    final RangeMarker callSiteMarker = document.createRangeMarker(startOffset, endOffset);
+    callSiteMarker.setGreedyToLeft(true);
+    callSiteMarker.setGreedyToRight(true);
+
+    try {
+      final ExtractMethodObjectProcessor extractMethodObjectProcessor = new ExtractMethodObjectProcessor(project, editor, elementsCopy, "") {
+        @Override
+        protected AbstractExtractDialog createExtractMethodObjectDialog(MyExtractMethodProcessor processor) {
+          return new LightExtractMethodObjectDialog(this, methodName);
+        }
+      };
+      extractMethodObjectProcessor.getExtractProcessor().setShowErrorDialogs(false);
+
+      ExtractMethodObjectHandler.extractMethodObject(project, editor, file, extractMethodObjectProcessor);
+
+      final String generatedCall = document.getText(new TextRange(callSiteMarker.getStartOffset(), callSiteMarker.getEndOffset()));
+      return new ExtractedData(generatedCall, extractMethodObjectProcessor.getInnerClass());
+    }
+    finally {
+      callSiteMarker.dispose();
+    }
+  }
+
+  private static class LightExtractMethodObjectDialog implements AbstractExtractDialog {
+    private final ExtractMethodObjectProcessor myProcessor;
+    private final String myMethodName;
+
+    public LightExtractMethodObjectDialog(ExtractMethodObjectProcessor processor, String methodName) {
+      myProcessor = processor;
+      myMethodName = methodName;
+    }
+
+    @Override
+    public String getChosenMethodName() {
+      return myMethodName;
+    }
+
+    @Override
+    public VariableData[] getChosenParameters() {
+      final InputVariables inputVariables = myProcessor.getExtractProcessor().getInputVariables();
+      return inputVariables.getInputVariables().toArray(new VariableData[inputVariables.getInputVariables().size()]);
+    }
+
+    @Override
+    public String getVisibility() {
+      return PsiModifier.PUBLIC;
+    }
+
+    @Override
+    public boolean isMakeStatic() {
+      return false;
+    }
+
+    @Override
+    public boolean isChainedConstructor() {
+      return false;
+    }
+
+    @Override
+    public void show() {}
+
+    @Override
+    public boolean isOK() {
+      return true;
+    }
+  }
+}
index fddd19bb463055a7153c0fbb1f5ccdb1385df6b6..f79280fd1365f06032fa36722f6b2ae7c23ef74f 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
 import com.intellij.openapi.help.HelpManager;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.IdeFocusManager;
 import com.intellij.psi.*;
@@ -44,7 +45,7 @@ import java.awt.event.ActionListener;
 import java.util.Enumeration;
 
 
-public class ExtractMethodObjectDialog extends AbstractExtractDialog {
+public class ExtractMethodObjectDialog extends DialogWrapper implements AbstractExtractDialog {
   private final Project myProject;
   private final PsiType myReturnType;
   private final PsiTypeParameterList myTypeParameterList;
@@ -86,7 +87,7 @@ public class ExtractMethodObjectDialog extends AbstractExtractDialog {
   public ExtractMethodObjectDialog(Project project, PsiClass targetClass, final InputVariables inputVariables, PsiType returnType,
                                    PsiTypeParameterList typeParameterList, PsiType[] exceptions, boolean isStatic, boolean canBeStatic,
                                    final PsiElement[] elementsToExtract, final boolean multipleExitPoints) {
-    super(project);
+    super(project, true);
     myProject = project;
     myTargetClass = targetClass;
     myReturnType = returnType;
index d8fb3fd6ef87ca31611a8f6c424ea36ffede4d4c..b09a02cfd56158980f067d800f756de3e1702417 100644 (file)
  */
 package com.intellij.refactoring.extractMethodObject;
 
+import com.intellij.codeInsight.CodeInsightUtil;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.editor.ScrollType;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pass;
 import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiDocumentManager;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
+import com.intellij.psi.*;
 import com.intellij.psi.impl.source.PostprocessReformattingAspect;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringActionHandler;
 import com.intellij.refactoring.RefactoringBundle;
+import com.intellij.refactoring.extractMethod.AbstractExtractDialog;
 import com.intellij.refactoring.extractMethod.ExtractMethodHandler;
+import com.intellij.refactoring.extractMethod.InputVariables;
 import com.intellij.refactoring.extractMethod.PrepareFailedException;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
+import com.intellij.refactoring.util.VariableData;
 import com.intellij.refactoring.util.duplicates.DuplicatesImpl;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
@@ -55,7 +58,10 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
     });
   }
 
-  private void invokeOnElements(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull PsiElement[] elements) {
+  private static void invokeOnElements(@NotNull final Project project,
+                                       @NotNull final Editor editor,
+                                       @NotNull PsiFile file,
+                                       @NotNull PsiElement[] elements) {
     if (elements.length == 0) {
         String message = RefactoringBundle
           .getCannotRefactorMessage(RefactoringBundle.message("selected.block.should.represent.a.set.of.statements.or.an.expression"));
@@ -63,7 +69,10 @@ public class ExtractMethodObjectHandler implements RefactoringActionHandler {
       return;
     }
 
-    final ExtractMethodObjectProcessor processor = new ExtractMethodObjectProcessor(project, editor, elements, "");
+    extractMethodObject(project, editor, file, new ExtractMethodObjectProcessor(project, editor, elements, ""));
+  }
+
+  static void extractMethodObject(Project project, Editor editor, PsiFile file, ExtractMethodObjectProcessor processor) {
     final ExtractMethodObjectProcessor.MyExtractMethodProcessor extractProcessor = processor.getExtractProcessor();
     try {
       if (!extractProcessor.prepare()) return;
index 7f95c49c65b3a3662f9aad69e82c71da71676a98..20c536bb5a1d507ddea424a3994cd5f6c4bfcb59 100644 (file)
@@ -37,10 +37,13 @@ import com.intellij.psi.codeStyle.VariableKind;
 import com.intellij.psi.controlFlow.ControlFlowUtil;
 import com.intellij.psi.impl.source.PsiImmediateClassType;
 import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.LocalSearchScope;
+import com.intellij.psi.search.SearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.PropertyUtil;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.refactoring.BaseRefactoringProcessor;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor;
@@ -52,6 +55,7 @@ import com.intellij.refactoring.ui.MemberSelectionPanel;
 import com.intellij.refactoring.util.RefactoringUtil;
 import com.intellij.refactoring.util.classMembers.MemberInfo;
 import com.intellij.refactoring.util.duplicates.Match;
+import com.intellij.testFramework.LightVirtualFile;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
 import com.intellij.usageView.UsageViewUtil;
@@ -100,8 +104,12 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
   @NotNull
   protected UsageInfo[] findUsages() {
     final ArrayList<UsageInfo> result = new ArrayList<UsageInfo>();
+    final PsiClass containingClass = getMethod().getContainingClass();
+    final SearchScope scope = PsiUtilCore.getVirtualFile(containingClass) instanceof LightVirtualFile
+                              ? new LocalSearchScope(containingClass)
+                              : GlobalSearchScope.projectScope(myProject);
     PsiReference[] refs =
-        ReferencesSearch.search(getMethod(), GlobalSearchScope.projectScope(myProject), false).toArray(PsiReference.EMPTY_ARRAY);
+        ReferencesSearch.search(getMethod(), scope, false).toArray(PsiReference.EMPTY_ARRAY);
     for (PsiReference ref : refs) {
       final PsiElement element = ref.getElement();
       if (element != null && element.isValid()) {
@@ -320,7 +328,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
         for (PsiElement declaredElement : declaredElements) {
           if (declaredElement instanceof PsiVariable) {
             for (PsiVariable variable : outputVariables) {
-              PsiLocalVariable var = (PsiLocalVariable)declaredElement;
+              PsiVariable var = (PsiVariable)declaredElement;
               if (Comparing.strEqual(var.getName(), variable.getName())) {
                 final PsiExpression initializer = var.getInitializer();
                 if (initializer == null) {
@@ -400,8 +408,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
 
   private String getPureName(PsiVariable var) {
     final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(myProject);
-    final VariableKind kind = var instanceof PsiLocalVariable ? VariableKind.LOCAL_VARIABLE : VariableKind.PARAMETER;
-    return styleManager.variableNameToPropertyName(var.getName(), kind);
+    return styleManager.variableNameToPropertyName(var.getName(), styleManager.getVariableKind(var));
   }
 
   public  PsiExpression processMethodDeclaration( PsiExpressionList expressionList) throws IncorrectOperationException {
@@ -517,7 +524,7 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
     LOG.assertTrue(methodBody != null);
     replacedMethodBody.replace(methodBody);
     PsiUtil.setModifierProperty(newMethod, PsiModifier.STATIC, myInnerClass.hasModifierProperty(PsiModifier.STATIC) && notHasGeneratedFields());
-    myInnerMethod = (PsiMethod)myInnerClass.add(newMethod);
+    myInnerMethod = (PsiMethod)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(myInnerClass.add(newMethod));
   }
 
   private boolean notHasGeneratedFields() {
@@ -624,6 +631,22 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
     return myExtractProcessor;
   }
 
+  protected AbstractExtractDialog createExtractMethodObjectDialog(final MyExtractMethodProcessor processor) {
+    return new ExtractMethodObjectDialog(myProject, processor.getTargetClass(), processor.getInputVariables(), processor.getReturnType(),
+                                         processor.getTypeParameterList(),
+                                         processor.getThrownExceptions(), processor.isStatic(), processor.isCanBeStatic(),
+                                         processor.getElements(), myMultipleExitPoints){
+      @Override
+      protected boolean isUsedAfter(PsiVariable variable) {
+        return ArrayUtil.find(processor.getOutputVariables(), variable) != -1;
+      }
+    };
+  }
+
+  public PsiClass getInnerClass() {
+    return myInnerClass;
+  }
+
   public class MyExtractMethodProcessor extends ExtractMethodProcessor {
 
     public MyExtractMethodProcessor(Project project,
@@ -640,19 +663,13 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
     @Override
     protected void apply(final AbstractExtractDialog dialog) {
       super.apply(dialog);
-      myCreateInnerClass = ((ExtractMethodObjectDialog)dialog).createInnerClass();
+      myCreateInnerClass = !(dialog instanceof ExtractMethodObjectDialog) || ((ExtractMethodObjectDialog)dialog).createInnerClass();
       myInnerClassName = myCreateInnerClass ? StringUtil.capitalize(dialog.getChosenMethodName()) : dialog.getChosenMethodName();
     }
 
     @Override
     protected AbstractExtractDialog createExtractMethodDialog(final boolean direct) {
-      return new ExtractMethodObjectDialog(myProject, myTargetClass, myInputVariables, myReturnType, myTypeParameterList,
-                                           myThrownExceptions, myStatic, myCanBeStatic, myElements, myMultipleExitPoints){
-        @Override
-        protected boolean isUsedAfter(PsiVariable variable) {
-          return ArrayUtil.find(myOutputVariables, variable) != -1;
-        }
-      };
+      return createExtractMethodObjectDialog(this);
     }
 
     @Override
index fcf5e8945e7a953c240966ce8ab9b7a3e655242c..8ff42ca085a03c145659cf85211de12ca29a43f4 100644 (file)
@@ -477,6 +477,17 @@ public class LambdaUtil {
     return true;
   }
 
+  //JLS 14.8 Expression Statements
+  public static boolean isExpressionStatementExpression(PsiElement body) {
+    return body instanceof PsiAssignmentExpression ||
+           body instanceof PsiPrefixExpression &&
+           (((PsiPrefixExpression)body).getOperationTokenType() == JavaTokenType.PLUSPLUS ||
+            ((PsiPrefixExpression)body).getOperationTokenType() == JavaTokenType.MINUSMINUS) ||
+           body instanceof PsiPostfixExpression ||
+           body instanceof PsiCallExpression ||
+           body instanceof PsiReferenceExpression && !body.isPhysical();
+  }
+
   public static class TypeParamsChecker extends PsiTypeVisitor<Boolean> {
     private PsiMethod myMethod;
     private final PsiClass myClass;
index b38bb494c1e726be9d90514729349f29b23c6400..a7f92056a195ff94ddb342e26fa4e4cc73820819 100644 (file)
@@ -1108,8 +1108,11 @@ public final class PsiUtil extends PsiUtilCore {
   }
 
   public static PsiReturnStatement[] findReturnStatements(PsiMethod method) {
+    return findReturnStatements(method.getBody());
+  }
+
+  public static PsiReturnStatement[] findReturnStatements(PsiCodeBlock body) {
     ArrayList<PsiReturnStatement> vector = new ArrayList<PsiReturnStatement>();
-    PsiCodeBlock body = method.getBody();
     if (body != null) {
       addReturnStatements(vector, body);
     }
index 556bf7152b688b69102ca0438311a4408422b394..a27dfe5adb83187ee7157482c792abce8995f06e 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.psi.impl.source.resolve;
 
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
@@ -211,16 +210,8 @@ public class PsiResolveHelperImpl implements PsiResolveHelper {
       .getSubstitutionForTypeParameter(typeParam, param, arg, isContraVariantPosition, languageLevel);
   }
 
-  private PsiInferenceHelper myTestHelper;
-
-  public void setTestHelper(PsiInferenceHelper testHelper) {
-    myTestHelper = testHelper;
-  }
-
-  public PsiInferenceHelper getInferenceHelper(LanguageLevel languageLevel) {
-    if (ApplicationManager.getApplication().isUnitTestMode() && myTestHelper != null) {
-      return myTestHelper;
-    }
+  @NotNull
+  public PsiInferenceHelper getInferenceHelper(@NotNull LanguageLevel languageLevel) {
     if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
       return new PsiGraphInferenceHelper(myManager);
     }
index 15ea2af284cb95c04a5183445e204a301ed7ab41..e3c6d2341dc812cd9362df594f3e17cb177646ab 100644 (file)
@@ -174,7 +174,6 @@ public class InferenceSession {
           }
         }
       }
-      return true;
     }
     if (expr instanceof PsiLambdaExpression) {
       if (!((PsiLambdaExpression)expr).hasFormalParameterTypes()) {
@@ -278,8 +277,7 @@ public class InferenceSession {
         if (arg instanceof PsiCallExpression) {
           //If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12), 
           //the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
-          final JavaResolveResult resolveResult = getMethodResult((PsiCallExpression)arg);
-          final PsiMethod calledMethod = resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
+          final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)arg);
           if (PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
             collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)arg);
           }
@@ -290,6 +288,20 @@ public class InferenceSession {
     }
   }
 
+  private static PsiMethod getCalledMethod(PsiCallExpression arg) {
+    final PsiExpressionList argumentList = arg.getArgumentList();
+    if (argumentList == null || argumentList.getExpressions().length == 0) {
+      return null;
+    }
+
+    MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
+    if (properties != null) {
+      return properties.getMethod();
+    }
+    final JavaResolveResult resolveResult = getMethodResult(arg);
+    return resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
+  }
+
   private void collectLambdaReturnExpression(Set<ConstraintFormula> additionalConstraints,
                                              PsiLambdaExpression lambdaExpression,
                                              PsiType parameterType) {
@@ -306,8 +318,7 @@ public class InferenceSession {
                                        PsiExpression returnExpression,
                                        PsiType functionalType) {
     if (returnExpression instanceof PsiCallExpression) {
-      final JavaResolveResult resolveResult = getMethodResult((PsiCallExpression)returnExpression);
-      final PsiMethod calledMethod = resolveResult instanceof MethodCandidateInfo ? (PsiMethod)resolveResult.getElement() : null;
+      final PsiMethod calledMethod = getCalledMethod((PsiCallExpression)returnExpression);
       if (PsiPolyExpressionUtil.isMethodCallPolyExpression(returnExpression, calledMethod)) {
         collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)returnExpression);
       }
index 069f667d92cf7b0378c15aa0efce4b4e5c10f0b4..6a71014cba01bb7e5eb44d5061a2f5b5e7400f42 100644 (file)
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
+import java.util.List;
 
 public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements PsiLambdaExpression {
 
@@ -78,16 +79,11 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
   @Override
   public boolean isVoidCompatible() {
     final PsiElement body = getBody();
-    if (body != null) {
-      try {
-        ControlFlow controlFlow = ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy
-          .getInstance());
-        int startOffset = controlFlow.getStartOffset(body);
-        int endOffset = controlFlow.getEndOffset(body);
-        return startOffset != -1 && endOffset != -1 && !ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset);
-      }
-      catch (AnalysisCanceledException e) {
-        return true;
+    if (body instanceof PsiCodeBlock) {
+      for (PsiReturnStatement statement : PsiUtil.findReturnStatements((PsiCodeBlock)body)) {
+        if (statement.getReturnValue() != null) {
+          return false;
+        }
       }
     }
     return true;
@@ -96,18 +92,25 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
   @Override
   public boolean isValueCompatible() {
     final PsiElement body = getBody();
-    if (body != null) {
+    if (body instanceof PsiCodeBlock) {
       try {
-        final ControlFlow controlFlow =
-          ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance(), false);
-        if (ControlFlowUtil.findExitPointsAndStatements(controlFlow, 0, controlFlow.getSize(), new IntArrayList(),
-                                                        PsiReturnStatement.class,
-                                                        PsiThrowStatement.class).isEmpty()) {
+        ControlFlow controlFlow =
+          ControlFlowFactory.getInstance(getProject()).getControlFlow(body, LocalsOrMyInstanceFieldsControlFlowPolicy
+            .getInstance());
+        int startOffset = controlFlow.getStartOffset(body);
+        int endOffset = controlFlow.getEndOffset(body);
+        if (startOffset != -1 && endOffset != -1 && ControlFlowUtil.canCompleteNormally(controlFlow, startOffset, endOffset)) {
           return false;
         }
       }
       catch (AnalysisCanceledException e) {
-        return true;
+        return false;
+      }
+
+      for (PsiReturnStatement statement : PsiUtil.findReturnStatements((PsiCodeBlock)body)) {
+        if (statement.getReturnValue() == null) {
+          return false;
+        }
       }
     }
     return true;
@@ -200,17 +203,36 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
       }
     }
 
+
+    //A lambda expression (§15.27) is potentially compatible with a functional interface type (§9.8) if all of the following are true:
+    //   The arity of the target type's function type is the same as the arity of the lambda expression.
+    //   If the target type's function type has a void return, then the lambda body is either a statement expression (§14.8) or a void-compatible block (§15.27.2).
+    //   If the target type's function type has a (non-void) return type, then the lambda body is either an expression or a value-compatible block (§15.27.2).
+    PsiType methodReturnType = interfaceMethod.getReturnType();
     if (checkReturnType) {
       final String uniqueVarName = JavaCodeStyleManager.getInstance(getProject()).suggestUniqueVariableName("l", this, true);
       final String canonicalText = toArray(leftType).getCanonicalText();
       final PsiStatement assignmentFromText = JavaPsiFacade.getElementFactory(getProject())
         .createStatementFromText(canonicalText + " " + uniqueVarName + " = " + getText(), this);
       final PsiLocalVariable localVariable = (PsiLocalVariable)((PsiDeclarationStatement)assignmentFromText).getDeclaredElements()[0];
-      PsiType methodReturnType = interfaceMethod.getReturnType();
       if (methodReturnType != null) {
         return LambdaHighlightingUtil.checkReturnTypeCompatible((PsiLambdaExpression)localVariable.getInitializer(),
                                                                 substitutor.substitute(methodReturnType)) == null;
       }
+    } else {
+      final PsiElement body = getBody();
+      if (methodReturnType == PsiType.VOID) {
+        if (body instanceof PsiCodeBlock) {
+          return isVoidCompatible();
+        } else {
+          return LambdaUtil.isExpressionStatementExpression(body);
+        }
+      } else {
+        if (body instanceof PsiCodeBlock) {
+          return isValueCompatible();
+        }
+        return body instanceof PsiExpression;
+      }
     }
     return true;
   }
index 3d9ea08125a8fbefc455da1c6edadb3c34c79104..16c3c8dd871212c909d6a139ea194cd4723ccdee 100644 (file)
@@ -158,7 +158,8 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
       // A lambda expression or a method reference expression is potentially compatible with a type variable if the type variable is a type parameter of the candidate method.
       final PsiClass paramClass = PsiUtil.resolveClassInType(paramType);
       if (paramClass instanceof PsiTypeParameter && ((PsiTypeParameter)paramClass).getOwner() == method) continue;
-      if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType), lambdaExpression.hasFormalParameterTypes())) {
+      if (!lambdaExpression.isAcceptable(((MethodCandidateInfo)conflict).getSubstitutor(false).substitute(paramType),
+                                         InferenceSession.isPertinentToApplicability(lambdaExpression, method))) {
         iterator.remove();
       }
     }
index 92b268394994940ba75c600a91a5e80ae2cf6940..001b1f39c4942cc5e37daebf21b3b79023b15c21 100644 (file)
@@ -142,3 +142,37 @@ class IDEA128196 {
     new Thread(() -> System.out.println(value));
   }
 }
+
+class FinalAssignmentInInitializer {
+  private final String x;
+  {
+    Runnable r = () -> <error descr="Cannot assign a value to final variable 'x'">x</error> = "";
+    x = "";
+  }
+}
+
+class AssignmentToFinalInsideLambda {
+  boolean isTrue() {
+    return true;
+  }
+
+  Runnable r = () -> {
+    final int i;
+    if (isTrue()) {
+      i = 1;
+    } else {
+      i = 0;
+    }
+  };
+
+  void a() {
+    Runnable r = () -> {
+      final int i;
+      if (isTrue()) {
+        i = 1;
+      } else {
+        i = 0;
+      }
+    };
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/PertinentToApplicabilityOfExplicitlyTypedLambda.java
new file mode 100644 (file)
index 0000000..348108f
--- /dev/null
@@ -0,0 +1,17 @@
+abstract class PertinentToApplicabilityOfExplicitlyTypedLambdaTest {
+
+  interface A {
+    B m(int a);
+  }
+
+  interface B {
+    int m(int b);
+  }
+
+  abstract void foo(A a);
+  abstract void foo(B b);
+
+  {
+    foo<error descr="Ambiguous method call: both 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(A)' and 'PertinentToApplicabilityOfExplicitlyTypedLambdaTest.foo(B)' match">(x -> y -> 42)</error>;
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution/VoidValueCompatibilityOfImplicitlyTypedLambda.java
new file mode 100644 (file)
index 0000000..1188a95
--- /dev/null
@@ -0,0 +1,23 @@
+interface A {
+  int m(int x);
+}
+
+interface B {
+  void m(boolean x);
+}
+
+abstract class Test {
+  abstract void foo(A j);
+  abstract void foo(B i);
+
+  void bar(Object o) {
+    foo(x -> {
+      return x += 1;
+    });
+    foo(x -> <error descr="Incompatible types. Found: 'int', required: '<lambda parameter>'">x += 1</error>);
+    foo(x -> 1);
+    foo(x -> <error descr="Operator '!' cannot be applied to 'int'">!x</error>);
+    foo(x -> <error descr="Operator '++' cannot be applied to '<lambda parameter>'">++x</error>);
+    foo(x -> o instanceof String ? 1 : 0);
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr/beforeVoidValueChanged.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr/beforeVoidValueChanged.java
new file mode 100644 (file)
index 0000000..20a6c0b
--- /dev/null
@@ -0,0 +1,19 @@
+// "Replace with expression lambda" "false"
+interface A {
+  int m(int x);
+}
+
+interface B {
+  void m(boolean x);
+}
+
+abstract class X {
+  abstract void foo(A j);
+  abstract void foo(B i);
+
+  void bar(Object o) {
+    foo(x -> {
+      retu<caret>rn x += 1;
+    });
+  }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/extractMethodObject4Debugger/SimpleGeneration.java b/java/java-tests/testData/refactoring/extractMethodObject4Debugger/SimpleGeneration.java
new file mode 100644 (file)
index 0000000..178a484
--- /dev/null
@@ -0,0 +1,7 @@
+class Sample {
+  void foo() {
+    <selection>int i = 0;
+    int j = 0;</selection>
+    System.out.println(i + j);
+  }
+}
\ No newline at end of file
index eb3c4c4577b614d2145a03581e49dd4342c2c40c..68aba5eca978dacb16aafe2df0b228c705f8281c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,6 @@ package com.intellij.codeInsight.completion;
 
 import com.intellij.JavaTestUtil;
 import com.intellij.codeInsight.lookup.Lookup;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
 import com.intellij.testFramework.LightProjectDescriptor;
 import org.jetbrains.annotations.NotNull;
 
@@ -117,16 +114,9 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
   }
 
   public void testInferFromRawType() throws Exception {
-    final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
-    helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
-    try {
-      configureByFile("/" + getTestName(false) + ".java");
-      assertNotNull(myItems);
-      assertTrue(myItems.length == 0);
-    }
-    finally {
-      helper.setTestHelper(null);
-    }
+    configureByFile("/" + getTestName(false) + ".java");
+    assertNotNull(myItems);
+    assertTrue(myItems.length == 0);
   }
 
   public void testDiamondsInsideMethodCall() throws Exception {
index 42433d327e2d3cb371de3aeccf1d8aab7b9c2fd4..9ab0ba5fae37d4cdce3a1df41727acd62229c10d 100644 (file)
@@ -55,7 +55,7 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
   }
 
   private void doTest(final boolean checkWarnings) {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
   }
 
   @Override
index eb73906a5f15a2a354b47f72a6cf158590f6fdef..62c96e148ea1b902f0d7e0174ff1a62e2fc263bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
   }
 
   private void doTest() throws Exception {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
   }
 
   @Override
index 0384c0f074db2c5f28a7d76f74015dc3d0764f21..c55c6ae2e77560d7916b8a0fbb496ee2566ee586 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +54,6 @@ public class ExceptionVariablesInferenceTest extends LightDaemonAnalyzerTestCase
   }
 
   private void doTest(final boolean checkWarnings) throws Exception {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
   }
 }
index e47f6acc9afc74a19890cfb2ef9eebb5b0669a0e..5e34b963e3213555c18cc70facd1fdcea2ceb21c 100644 (file)
@@ -47,7 +47,7 @@ public class FunctionalExpressionIncompleteHighlightingTest extends LightDaemonA
   }
 
   private void doTest(final boolean checkWarnings) {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
   }
 
   @Override
index 599ae74cd00ddfabe55ccf9d30b217763837b9ab..72f709a486976356d5d70600275b5fd2a916e93d 100644 (file)
@@ -38,7 +38,7 @@ public class FunctionalTypeWildcardParameterizationTest extends LightDaemonAnaly
 
   private void doTest() {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
   }
 
   @Override
index a66d999b283ca5f7e86c4d43841d05c15a53ab39..a919843a31644d548580b06aafba7b6685b935d0 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http:www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -24,9 +24,6 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.roots.LanguageLevelProjectExtension;
 import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
 import com.intellij.testFramework.IdeaTestUtil;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -772,14 +769,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
    private void doTest(boolean warnings) {
      LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
      IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), myTestRootDisposable);
-     final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
-     helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
-     try {
-       doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
-     }
-     finally {
-       helper.setTestHelper(null);
-     }
+     doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
    }
 
 
index 7585d661b28979e3db40d090ae99bdefff9539e4..e6e4534b656044ad3922520c07b77a4a84385d34 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -242,7 +242,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
 
   private void doTest(final boolean checkWarnings) throws Exception {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
   }
 
   @Override
index a3a326cfcf81bb11616d3233f28cf2efb34cea29..5ecab96d892653c757bbb63736b24756a408e59a 100644 (file)
@@ -112,7 +112,7 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
   }
 
   private void doTest(final boolean checkWarnings) {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
   }
 
   @Override
index 96e60587a22591aaa779c351c4d1cde630918bc3..b13cfbc22e02fc47354a1e816e2722524dd840b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,6 @@ public class LambdaInferenceTest extends LightDaemonAnalyzerTestCase {
   }
 
   private void doTest() throws Exception {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
   }
 }
index 94ca90df2d022fc2ac8d1b2926026f971c2529d6..faf1608c1cf0cea21f7d7ec3f08124ef5d7e27c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,6 @@ public class LambdaParamsTest extends LightDaemonAnalyzerTestCase {
   public void testInferFromFormal() { doTest(); }
 
   private void doTest() {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
   }
 }
index 36f98aa91cc64bcb0f9566178bda2f66a9bcc0e2..ae5a97933ca8042b9aa4955d02c5d5971412aa1e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,6 @@ public class LambdaRedundantCastTest extends LightDaemonAnalyzerTestCase {
   public void testIntersection() { doTest(); }
   public void testSer() { doTest(); }
   private void doTest() {
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
   }
 }
index 630acb0404b7a88b810fa0c8bd2c2f08c61b3a73..08a2b63550ffeb3e4fcb3cdd1a3214f3c20aabe4 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.lambda;
 import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
 import com.intellij.codeInspection.LocalInspectionTool;
 import com.intellij.codeInspection.compiler.JavacQuirksInspection;
-import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
 import com.intellij.openapi.projectRoots.JavaSdkVersion;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.testFramework.IdeaTestUtil;
@@ -42,7 +41,7 @@ public class LightAdvHighlightingJdk8Test extends LightDaemonAnalyzerTestCase {
 
   private void doTest() {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
   }
 
   @Override
index 156aac5613c13f9168b9d879a012f96bf46a7726..d0bed5e9d5df9a1957f93e7989c10aa4ab788553 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -116,7 +116,7 @@ public class MethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
 
   private void doTest(boolean warnings) {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
   }
 
   @Override
index 9bb7d4801944aece4b4ae4beb369968a91e2216e..294a3cc8a4f615de48af6f3f67b395b38eed2678 100644 (file)
@@ -121,7 +121,7 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
 
   private void doTest(boolean warnings) {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
   }
 
   @Override
index 5307493a745526deeb1e8f589ed7a75c2d270309..1b56554333b03bcdb1934ffcee5e063f54e19721 100644 (file)
@@ -87,6 +87,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
   public void testLiftedIntersectionType() { doTest(); }
   public void testInferenceFromReturnStatements() { doTest(); }
   public void testDownUpThroughLambdaReturnStatements() { doTest(); }
+  @Bombed(day = 30, month = Calendar.SEPTEMBER)
   public void testIDEA124547() { doTest(); }
   public void testIDEA118362() { doTest(); }
   public void testIDEA126056() { doTest(); }
@@ -126,6 +127,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest();
   }
 
+  @Bombed(day = 30, month = Calendar.SEPTEMBER)
   public void testIDEA126778() throws Exception {
     doTest();
   }
@@ -136,7 +138,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
 
   private void doTest(boolean warnings) {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
   }
 
   @Override
index 437159d1646ee92ad7fee0764e2c0d6340e64c9c..3d5bcdecd0e59da6764c7990f32fac8e6723797f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -319,7 +319,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
 
   private void doTest(boolean warnings) {
     IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
-    doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
   }
 
   @Override
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/OverloadResolutionTest.java
new file mode 100644 (file)
index 0000000..3ccc97d
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.lambda;
+
+import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.testFramework.IdeaTestUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
+  @NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/overloadResolution";
+
+  @NotNull
+  @Override
+  protected LocalInspectionTool[] configureLocalInspectionTools() {
+    return new LocalInspectionTool[]{
+      new UnusedSymbolLocalInspection(),
+    };
+  }
+
+  public void testPertinentToApplicabilityOfExplicitlyTypedLambda() throws Exception {
+    doTest();
+  }
+
+  public void testVoidValueCompatibilityOfImplicitlyTypedLambda() throws Exception {
+    doTest();
+  }
+
+  private void doTest() {
+    doTest(true);
+  }
+
+  private void doTest(boolean warnings) {
+    IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
+    doTest(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
+  }
+
+  @Override
+  protected Sdk getProjectJDK() {
+    return IdeaTestUtil.getMockJdk18();
+  }
+}
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractMethodObject4DebuggerTest.java
new file mode 100644 (file)
index 0000000..64e3551
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * User: anna
+ * Date: 06-May-2008
+ */
+package com.intellij.refactoring;
+
+import com.intellij.JavaTestUtil;
+import com.intellij.codeInsight.CodeInsightUtil;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import com.intellij.refactoring.extractMethodObject.ExtractLightMethodObjectHandler;
+import com.intellij.testFramework.IdeaTestUtil;
+import org.jetbrains.annotations.NotNull;
+
+public class ExtractMethodObject4DebuggerTest extends LightRefactoringTestCase {
+  @NotNull
+  @Override
+  protected String getTestDataPath() {
+    return JavaTestUtil.getJavaTestDataPath();
+  }
+
+  private void doTest(String expectedCallSite, String expectedClass) throws Exception {
+    final String testName = getTestName(false);
+    configureByFile("/refactoring/extractMethodObject4Debugger/" + testName + ".java");
+    int startOffset = getEditor().getSelectionModel().getSelectionStart();
+    int endOffset = getEditor().getSelectionModel().getSelectionEnd();
+    PsiElement[] elements = CodeInsightUtil.findStatementsInRange(getFile(), startOffset, endOffset);
+    assertTrue(elements.length > 0);
+
+    final ExtractLightMethodObjectHandler.ExtractedData extractedData =
+      ExtractLightMethodObjectHandler.extractLightMethodObject(getProject(), getEditor(), getFile(), elements, "test");
+    assertNotNull(extractedData);
+    assertEquals(expectedCallSite, extractedData.getGeneratedCallText());
+    final PsiClass innerClass = extractedData.getGeneratedInnerClass();
+    assertEquals(expectedClass, innerClass.getText());
+  }
+
+  public void testSimpleGeneration() throws Exception {
+    doTest("  Test test = new Test().invoke();\n" +
+           "      int i = test.getI();\n" +
+           "      int j = test.getJ();",
+
+           "public class Test {\n" +
+           "        private int i;\n" +
+           "        private int j;\n" +
+           "\n" +
+           "        public int getI() {\n" +
+           "            return i;\n" +
+           "        }\n" +
+           "\n" +
+           "        public int getJ() {\n" +
+           "            return j;\n" +
+           "        }\n" +
+           "\n" +
+           "        public Test invoke() {\n" +
+           "            i = 0;\n" +
+           "            j = 0;\n" +
+           "            return this;\n" +
+           "        }\n" +
+           "    }");
+  }
+
+  @Override
+  protected Sdk getProjectJDK() {
+    return IdeaTestUtil.getMockJdk18();
+  }
+}
index 34745372977e60124b01f7b15ed4c7c4f93ba6f3..6ef80d01903e6dd5f8af160c8b985011d82823a7 100644 (file)
@@ -18,9 +18,10 @@ package com.intellij.refactoring;
 import com.intellij.JavaTestUtil;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
+import com.intellij.psi.CommonClassNames;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiExpression;
+import com.intellij.psi.PsiType;
 import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
 import com.intellij.refactoring.introduceVariable.InputValidator;
 import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
@@ -95,15 +96,8 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
   }
 
   public void testExpectedType8Inference() {
-    final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
-    helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
-    try {
-      doTest(new MockIntroduceVariableHandler("temp", true, false, false,
-                                              "java.util.Map<java.lang.String,java.util.List<java.lang.String>>"));
-    }
-    finally {
-      helper.setTestHelper(null);
-    }
+    doTest(new MockIntroduceVariableHandler("temp", true, false, false,
+                                            "java.util.Map<java.lang.String,java.util.List<java.lang.String>>"));
   }
 
   public void testMethodCall() {
index 680ae8f744ce876c492dc77e1b1aee84b95aa810..c912e57999dd32c8aa5e2da5030d850141d49fa7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,18 +48,6 @@ public class ExceptionWorker {
   private static final String AT_PREFIX = AT + " ";
   private static final String STANDALONE_AT = " " + AT + " ";
 
-  private static final TextAttributes HYPERLINK_ATTRIBUTES;
-  private static final TextAttributes LIBRARY_HYPERLINK_ATTRIBUTES;
-  
-  static {
-    HYPERLINK_ATTRIBUTES = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
-    
-    LIBRARY_HYPERLINK_ATTRIBUTES = HYPERLINK_ATTRIBUTES.clone();
-    Color libTextColor = UIUtil.getInactiveTextColor();
-    LIBRARY_HYPERLINK_ATTRIBUTES.setForegroundColor(libTextColor);
-    LIBRARY_HYPERLINK_ATTRIBUTES.setEffectColor(libTextColor);
-  }
-
   private final Project myProject;
   private Filter.Result myResult;
   private PsiClass[] myClasses = PsiClass.EMPTY_ARRAY;
@@ -129,13 +117,16 @@ public class ExceptionWorker {
     }
 
     List<VirtualFile> virtualFiles;
-    TextAttributes attributes;
+    TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
     if (virtualFilesInContent.isEmpty()) {
-      attributes = LIBRARY_HYPERLINK_ATTRIBUTES;
+      Color libTextColor = UIUtil.getInactiveTextColor();
+      attributes = attributes.clone();
+      attributes.setForegroundColor(libTextColor);
+      attributes.setEffectColor(libTextColor);
+
       virtualFiles = virtualFilesInLibraries;
     }
     else {
-      attributes = HYPERLINK_ATTRIBUTES;
       virtualFiles = virtualFilesInContent;
     }
     HyperlinkInfo linkInfo = HyperlinkInfoFactory.getInstance().createMultipleFilesHyperlinkInfo(virtualFiles, lineNumber - 1, myProject);
index ff98bd23b8589388d5dc2de0163a8dfdc681ad0b..d2b25c6d3d0435ef2dff9e927bc8dc9e322514c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,11 +24,8 @@ import com.intellij.lang.injection.InjectedLanguageManager;
 import com.intellij.openapi.command.CommandProcessor;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.vfs.VirtualFileFilter;
-import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
-import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
-import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
 import com.intellij.testFramework.ExpectedHighlightingData;
 import com.intellij.testFramework.FileTreeAccessFilter;
 import com.intellij.testFramework.HighlightTestInfo;
@@ -83,18 +80,6 @@ public abstract class LightDaemonAnalyzerTestCase extends LightCodeInsightTestCa
     doTestConfiguredFile(checkWarnings, checkInfos, filePath);
   }
 
-  protected void doTestNewInference(@NonNls String filePath, boolean checkWarnings, boolean checkInfos) {
-    final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
-    helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
-    try {
-      configureByFile(filePath);
-      doTestConfiguredFile(checkWarnings, checkInfos, filePath);
-    }
-    finally {
-      helper.setTestHelper(null);
-    }
-  }
-
   protected void doTest(@NonNls String filePath, boolean checkWarnings, boolean checkWeakWarnings, boolean checkInfos) {
     configureByFile(filePath);
     doTestConfiguredFile(checkWarnings, checkWeakWarnings, checkInfos, filePath);
index a42441fe49deed396a8465c9e0b8562882db5d3b..af6c670ab22a9e8f8c61c95cddf0ec0b73273186 100644 (file)
@@ -23,13 +23,6 @@ import com.intellij.util.io.URLUtil;
 import org.jetbrains.annotations.NotNull;
 
 public abstract class HttpFileSystem extends DeprecatedVirtualFileSystem {
-  @Deprecated
-  @SuppressWarnings("UnusedDeclaration")
-  /**
-   * @deprecated use {@link com.intellij.util.io.URLUtil#HTTP_PROTOCOL}
-   */
-  public static final String PROTOCOL = URLUtil.HTTP_PROTOCOL;
-
   public static HttpFileSystem getInstance() {
     return (HttpFileSystem)VirtualFileManager.getInstance().getFileSystem(URLUtil.HTTP_PROTOCOL);
   }
@@ -43,4 +36,4 @@ public abstract class HttpFileSystem extends DeprecatedVirtualFileSystem {
   public abstract void removeFileListener(@NotNull HttpVirtualFileListener listener);
 
   public abstract VirtualFile createChild(@NotNull VirtualFile parent, @NotNull String name, boolean isDirectory);
-}
\ No newline at end of file
+}
index 5248f4a0e5352a6b3c0fc252f253fda61a2b27db..8ba56e77f160c1eec035da5cff38e1be01207398 100644 (file)
@@ -20,8 +20,10 @@ import com.intellij.openapi.components.PersistentStateComponent;
 import com.intellij.openapi.diagnostic.Logger;
 import org.jdom.Element;
 
+@Deprecated
 /**
  * @author Dmitry Avdeev
+ * @deprecated to remove in IDEA 14
  */
 public class JDOMExternalizableAdapter implements PersistentStateComponent<Element> {
 
index 990418dc9c518bb8fa2e8719f5a45eb513c1fbf1..1e0f0bcd68b5f91d7ccb7678bb74182c3b730ed1 100644 (file)
 package com.intellij.openapi.vfs.impl.http;
 
 import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * @author nik
  */
 public abstract class HttpVirtualFile extends VirtualFile {
+  @Nullable
   public abstract RemoteFileInfo getFileInfo();
 }
index 47cc17866c08962acc6ba585d3d80c23d106fcfc..c269d7ba993ed12029ef66daa5f36a8119cb086f 100644 (file)
@@ -54,6 +54,8 @@ import org.jetbrains.annotations.Nullable;
 public interface Repository extends Disposable {
 
 
+
+
   /**
    * Current state of the repository.
    */
@@ -83,9 +85,8 @@ public interface Repository extends Disposable {
     /**
      * Detached HEAD state, but not during rebase (for example, manual checkout of a commit hash).
      */
-    DETACHED
+    DETACHED;
   }
-
   @NotNull
   VirtualFile getRoot();
 
@@ -98,6 +99,9 @@ public interface Repository extends Disposable {
   @NotNull
   State getState();
 
+  @Nullable
+  String getCurrentBranchName();
+
   @Nullable
   AbstractVcs getVcs();
 
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java b/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchPopup.java
new file mode 100644 (file)
index 0000000..a98cf27
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.dvcs.branch;
+
+import com.intellij.dvcs.DvcsUtil;
+import com.intellij.dvcs.repo.AbstractRepositoryManager;
+import com.intellij.dvcs.repo.Repository;
+import com.intellij.dvcs.ui.BranchActionGroupPopup;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationListener;
+import com.intellij.openapi.actionSystem.ActionGroup;
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.options.ShowSettingsUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.ListPopup;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.openapi.vcs.VcsNotifier;
+import com.intellij.ui.popup.list.ListPopupImpl;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import java.util.List;
+
+public abstract class DvcsBranchPopup<Repo extends Repository> {
+  @NotNull protected final Project myProject;
+  @NotNull protected final AbstractRepositoryManager<Repo> myRepositoryManager;
+  @NotNull protected final DvcsSyncBranchSettings myVcsSettings;
+  @NotNull protected final AbstractVcs myVcs;
+  @NotNull protected final DvcsMultiRootBranchConfig<Repo> myMultiRootBranchConfig;
+
+  @NotNull protected final Repo myCurrentRepository;
+  @NotNull protected final ListPopupImpl myPopup;
+
+  protected DvcsBranchPopup(@NotNull Repo currentRepository,
+                            @NotNull AbstractRepositoryManager<Repo> repositoryManager,
+                            @NotNull DvcsMultiRootBranchConfig<Repo> multiRootBranchConfig,
+                            @NotNull DvcsSyncBranchSettings vcsSettings,
+                            @NotNull Condition<AnAction> preselectActionCondition) {
+    myProject = currentRepository.getProject();
+    myCurrentRepository = currentRepository;
+    myRepositoryManager = repositoryManager;
+    myVcs = currentRepository.getVcs();
+    myVcsSettings = vcsSettings;
+    myMultiRootBranchConfig = multiRootBranchConfig;
+    String title = createPopupTitle(currentRepository);
+    myPopup = new BranchActionGroupPopup(title, myProject, preselectActionCondition, createActions());
+
+    initBranchSyncPolicyIfNotInitialized();
+    setCurrentBranchInfo();
+    warnThatBranchesDivergedIfNeeded();
+  }
+
+  public ListPopup asListPopup() {
+    return myPopup;
+  }
+
+  private void initBranchSyncPolicyIfNotInitialized() {
+    if (myRepositoryManager.moreThanOneRoot() && myVcsSettings.getSyncSetting() == DvcsBranchSync.NOT_DECIDED) {
+      if (!myMultiRootBranchConfig.diverged()) {
+        notifyAboutSyncedBranches();
+        myVcsSettings.setSyncSetting(DvcsBranchSync.SYNC);
+      }
+      else {
+        myVcsSettings.setSyncSetting(DvcsBranchSync.DONT);
+      }
+    }
+  }
+
+  @NotNull
+  private String createPopupTitle(@NotNull Repo currentRepository) {
+    String title = myVcs.getDisplayName() + " Branches";
+    if (myRepositoryManager.moreThanOneRoot() &&
+        (myMultiRootBranchConfig.diverged() || myVcsSettings.getSyncSetting() == DvcsBranchSync.DONT)) {
+      title += " in " + DvcsUtil.getShortRepositoryName(currentRepository);
+    }
+    return title;
+  }
+
+  protected void setCurrentBranchInfo() {
+    String branchText = "Current branch : ";
+    myPopup.setAdText(branchText + myCurrentRepository.getCurrentBranchName(), SwingConstants.CENTER);
+  }
+
+  private void notifyAboutSyncedBranches() {
+    String description =
+      "You have several " + myVcs.getDisplayName() + "roots in the project and they all are checked out at the same branch. " +
+      "We've enabled synchronous branch control for the project. <br/>" +
+      "If you wish to control branches in different roots separately, " +
+      "you may <a href='settings'>disable</a> the setting.";
+    NotificationListener listener = new NotificationListener() {
+      @Override
+      public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
+        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+          ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName());
+          if (myVcsSettings.getSyncSetting() == DvcsBranchSync.DONT) {
+            notification.expire();
+          }
+        }
+      }
+    };
+    VcsNotifier.getInstance(myProject).notifyImportantInfo("Synchronous branch control enabled", description, listener);
+  }
+
+  @NotNull
+  private ActionGroup createActions() {
+    DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
+    AbstractRepositoryManager<Repo> repositoryManager = myRepositoryManager;
+    if (repositoryManager.moreThanOneRoot()) {
+      if (userWantsSyncControl()) {
+        fillWithCommonRepositoryActions(popupGroup, repositoryManager);
+      }
+      else {
+        fillPopupWithCurrentRepositoryActions(popupGroup, createRepositoriesActions());
+      }
+    }
+    else {
+      fillPopupWithCurrentRepositoryActions(popupGroup, null);
+    }
+    popupGroup.addSeparator();
+    return popupGroup;
+  }
+
+  private boolean userWantsSyncControl() {
+    return (myVcsSettings.getSyncSetting() != DvcsBranchSync.DONT);
+  }
+
+  protected abstract void fillWithCommonRepositoryActions(@NotNull DefaultActionGroup popupGroup,
+                                                          @NotNull AbstractRepositoryManager<Repo> repositoryManager);
+
+  @NotNull
+  protected List<Repo> filterRepositoriesNotOnThisBranch(@NotNull final String branch,
+                                                         @NotNull List<Repo> allRepositories) {
+    return ContainerUtil.filter(allRepositories, new Condition<Repo>() {
+      @Override
+      public boolean value(Repo repository) {
+        return !branch.equals(repository.getCurrentBranchName());
+      }
+    });
+  }
+
+  private void warnThatBranchesDivergedIfNeeded() {
+    if (myRepositoryManager.moreThanOneRoot() && myMultiRootBranchConfig.diverged() && userWantsSyncControl()) {
+      myPopup.setWarning("Branches have diverged");
+    }
+  }
+
+  @NotNull
+  protected abstract DefaultActionGroup createRepositoriesActions();
+
+  protected boolean highlightCurrentRepo() {
+    return !userWantsSyncControl() || myMultiRootBranchConfig.diverged();
+  }
+
+  protected abstract void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup,
+                                                                @Nullable DefaultActionGroup actions);
+}
similarity index 80%
rename from plugins/git4idea/src/git4idea/ui/branch/GitBranchSyncSetting.java
rename to platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsBranchSync.java
index bb9c7592f02869657935a2fdc2f2cf75d62f0463..9fab273be2e1fdc3d240cfeb8da28f0f3cd4dfbc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package git4idea.ui.branch;
+package com.intellij.dvcs.branch;
 
-/**
- * @author Kirill Likhodedov
- */
-public enum GitBranchSyncSetting {
+public enum DvcsBranchSync {
   SYNC,
   DONT,
   NOT_DECIDED
diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsMultiRootBranchConfig.java b/platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsMultiRootBranchConfig.java
new file mode 100644 (file)
index 0000000..ee24209
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.dvcs.branch;
+
+import com.intellij.dvcs.repo.Repository;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+public abstract class DvcsMultiRootBranchConfig<Repo extends Repository> {
+  @NotNull protected final Collection<Repo> myRepositories;
+
+  public DvcsMultiRootBranchConfig(@NotNull Collection<Repo> repositories) {
+    myRepositories = repositories;
+  }
+
+  public boolean diverged() {
+    return getCurrentBranch() == null;
+  }
+
+  @Nullable
+  public String getCurrentBranch() {
+    String commonBranch = null;
+    for (Repo repository : myRepositories) {
+      String branchName = repository.getCurrentBranchName();
+      if (branchName == null) {
+        return null;
+      }
+      // NB: if all repositories are in the rebasing state on the same branches, this branch is returned
+      if (commonBranch == null) {
+        commonBranch = branchName;
+      }
+      else if (!commonBranch.equals(branchName)) {
+        return null;
+      }
+    }
+    return commonBranch;
+  }
+
+  @Nullable
+  public Repository.State getState() {
+    Repository.State commonState = null;
+    for (Repo repository : myRepositories) {
+      Repository.State state = repository.getState();
+      if (commonState == null) {
+        commonState = state;
+      }
+      else if (!commonState.equals(state)) {
+        return null;
+      }
+    }
+    return commonState;
+  }
+
+  @NotNull
+  public abstract Collection<String> getLocalBranchNames();
+}
similarity index 58%
rename from platform/platform-impl/src/com/intellij/openapi/components/impl/stores/RoamingTypeExtensionPointBean.java
rename to platform/dvcs-impl/src/com/intellij/dvcs/branch/DvcsSyncBranchSettings.java
index ff5d16361228fa28e470b594e69ccb9d1359b446..115872a6655296a0fd2d997a6b01d048a3498176 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.intellij.openapi.components.impl.stores;
+package com.intellij.dvcs.branch;
 
-import com.intellij.util.xmlb.annotations.Attribute;
+import org.jetbrains.annotations.NotNull;
 
-/**
- * @deprecated use {@link com.intellij.openapi.components.RoamingType#DISABLED}
- */
-@Deprecated
-public class RoamingTypeExtensionPointBean {
-  @Attribute("component")
-  public String componentName;
-  @Attribute("type")
-  public String roamingType;
+public interface DvcsSyncBranchSettings {
+  @NotNull
+  DvcsBranchSync getSyncSetting();
+
+  void setSyncSetting(@NotNull DvcsBranchSync syncSetting);
 }
index fddb2b2f50b73d94b782cec8ac8999182de5aa1a..861123ab78395ac147706b4ab768cff51536bda2 100644 (file)
@@ -25,6 +25,8 @@ import com.intellij.openapi.module.*;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.DumbAwareRunnable;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectType;
+import com.intellij.openapi.project.ProjectTypeService;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.roots.ContentEntry;
 import com.intellij.openapi.roots.ModifiableRootModel;
@@ -56,12 +58,12 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
   public static final ExtensionPointName<ModuleBuilderFactory> EP_NAME = ExtensionPointName.create("com.intellij.moduleBuilder");
 
   private static final Logger LOG = Logger.getInstance("#com.intellij.ide.util.projectWizard.ModuleBuilder");
+  private final Set<ModuleConfigurationUpdater> myUpdaters = new HashSet<ModuleConfigurationUpdater>();
+  private final EventDispatcher<ModuleBuilderListener> myDispatcher = EventDispatcher.create(ModuleBuilderListener.class);
   protected Sdk myJdk;
   private String myName;
   @NonNls private String myModuleFilePath;
   private String myContentEntryPath;
-  private final Set<ModuleConfigurationUpdater> myUpdaters = new HashSet<ModuleConfigurationUpdater>();
-  private final EventDispatcher<ModuleBuilderListener> myDispatcher = EventDispatcher.create(ModuleBuilderListener.class);
 
   @NotNull
   public static List<ModuleBuilder> getAllBuilders() {
@@ -81,6 +83,17 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
     });
   }
 
+  public static void deleteModuleFile(String moduleFilePath) {
+    final File moduleFile = new File(moduleFilePath);
+    if (moduleFile.exists()) {
+      FileUtil.delete(moduleFile);
+    }
+    final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(moduleFile);
+    if (file != null) {
+      file.refresh(false, false);
+    }
+  }
+
   protected boolean isAvailable() {
     return true;
   }
@@ -94,6 +107,11 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
     return myName;
   }
 
+  @Override
+  public void setName(String name) {
+    myName = acceptParameter(name);
+  }
+
   @Override
   @Nullable
   public String getBuilderId() {
@@ -167,24 +185,19 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
     return Collections.emptyList();
   }
 
-  @Override
-  public void setName(String name) {
-    myName = acceptParameter(name);
-  }
-
   public String getModuleFilePath() {
     return myModuleFilePath;
   }
 
-  public void addModuleConfigurationUpdater(ModuleConfigurationUpdater updater) {
-    myUpdaters.add(updater);
-  }
-
   @Override
   public void setModuleFilePath(@NonNls String path) {
     myModuleFilePath = acceptParameter(path);
   }
 
+  public void addModuleConfigurationUpdater(ModuleConfigurationUpdater updater) {
+    myUpdaters.add(updater);
+  }
+
   @Nullable
   public String getContentEntryPath() {
     if (myContentEntryPath == null) {
@@ -259,6 +272,7 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
       updater.update(module, modifiableModel);
     }
     modifiableModel.commit();
+    setProjectType(module);
   }
 
   private void onModuleInitialized(final Module module) {
@@ -269,6 +283,17 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
 
   public abstract ModuleType getModuleType();
 
+  protected ProjectType getProjectType() {
+    return null;
+  }
+
+  protected void setProjectType(Module module) {
+    ProjectType projectType = getProjectType();
+    if (projectType != null && ProjectTypeService.getProjectType(module.getProject()) == null) {
+      ProjectTypeService.setProjectType(module.getProject(), projectType);
+    }
+  }
+
   @NotNull
   public Module createAndCommitIfNeeded(@NotNull Project project, @Nullable ModifiableModuleModel model, boolean runFromProjectWizard)
     throws InvalidDataException, ConfigurationException, IOException, JDOMException, ModuleWithNameAlreadyExists {
@@ -295,7 +320,6 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
     return module;
   }
 
-
   public void addListener(ModuleBuilderListener listener) {
     myDispatcher.addListener(listener);
   }
@@ -340,17 +364,6 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
     return null;
   }
 
-  public static void deleteModuleFile(String moduleFilePath) {
-    final File moduleFile = new File(moduleFilePath);
-    if (moduleFile.exists()) {
-      FileUtil.delete(moduleFile);
-    }
-    final VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(moduleFile);
-    if (file != null) {
-      file.refresh(false, false);
-    }
-  }
-
   public Icon getBigIcon() {
     return getModuleType().getBigIcon();
   }
@@ -396,14 +409,14 @@ public abstract class ModuleBuilder extends AbstractModuleBuilder {
     myModuleFilePath = from.getModuleFilePath();
   }
 
-  public void setModuleJdk(Sdk jdk) {
-    myJdk = jdk;
-  }
-
   public Sdk getModuleJdk() {
     return myJdk;
   }
 
+  public void setModuleJdk(Sdk jdk) {
+    myJdk = jdk;
+  }
+
   @NotNull
   public FrameworkRole getDefaultAcceptableRole() {
     return getModuleType().getDefaultAcceptableRole();
index ecebb9db73f3bed8e6a64ee9d3bcbf431549c540..ae9f0142f246d90fce3314156e372a3880125172 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileChooser.FileChooser;
 import com.intellij.openapi.fileChooser.FileChooserDescriptor;
-import com.intellij.openapi.fileChooser.FileChooserDialog;
 import com.intellij.openapi.fileTypes.FileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Computable;
@@ -67,7 +66,6 @@ public class PathEditor {
 
   public PathEditor(final FileChooserDescriptor descriptor) {
     myDescriptor = descriptor;
-    myDescriptor.putUserData(FileChooserDialog.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE);
     myModel = createListModel();
   }
 
@@ -176,12 +174,8 @@ public class PathEditor {
   }
 
   protected VirtualFile[] doAdd() {
-    VirtualFile baseDir = myAddBaseDir;
     Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
-    if (baseDir == null && project != null) {
-      baseDir = project.getBaseDir();
-    }
-    VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myPanel, project, baseDir);
+    VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myPanel, project, myAddBaseDir);
     files = adjustAddedFileSet(myPanel, files);
     List<VirtualFile> added = new ArrayList<VirtualFile>(files.length);
     for (VirtualFile vFile : files) {
index 290078e39aa921181ae762c949e31cc541cddd12..2ef2c998b3b4d19f63cc98453845a80b22af4a7a 100644 (file)
@@ -214,6 +214,7 @@ public interface CodeStyleSettingsCustomizable {
 
   String WRAPPING_KEEP = ApplicationBundle.message("wrapping.keep.when.reformatting");
   String WRAPPING_BRACES = ApplicationBundle.message("wrapping.brace.placement");
+  String WRAPPING_COMMENTS = ApplicationBundle.message("wrapping.comments");
   String WRAPPING_METHOD_PARAMETERS = ApplicationBundle.message("wrapping.method.parameters");
   String WRAPPING_METHOD_PARENTHESES = ApplicationBundle.message("wrapping.method.parentheses");
   String WRAPPING_METHOD_ARGUMENTS_WRAPPING = ApplicationBundle.message("wrapping.method.arguments");
index 653f6b51e8bd52de88e81cc9bec4c6a23b9ae1de..282f44d04a604b79c13750cbbde2452d6f57dae4 100644 (file)
@@ -214,7 +214,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
             return !file.isDirectory() && importer.getSourceExtension().equals(file.getExtension());
           }
         }, null, myContentPane);
-      VirtualFile[] selection = fileChooser.choose(CodeStyleSchemesUIConfiguration.Util.getRecentImportFile(), null);
+      VirtualFile[] selection = fileChooser.choose(null, CodeStyleSchemesUIConfiguration.Util.getRecentImportFile());
       if (selection.length == 1) {
         VirtualFile selectedFile = selection[0];
         selectedFile.refresh(false, false);
index c192d0e2893af4f74f81acaf4419bc512ed8be18..2972dacf2ceb8446c1f792d0ed2765cdc9564f18 100644 (file)
@@ -43,6 +43,7 @@ public class WrappingAndBracesPanel extends OptionTableWithPreviewPanel {
     addOption("KEEP_SIMPLE_CLASSES_IN_ONE_LINE", ApplicationBundle.message("wrapping.keep.simple.classes.in.one.line"), WRAPPING_KEEP);
 
     addOption("WRAP_LONG_LINES", ApplicationBundle.message("wrapping.long.lines"), null);
+    addOption("WRAP_COMMENTS", ApplicationBundle.message("wrapping.comments.wrap.at.right.margin"), WRAPPING_COMMENTS);
 
     addOption("CLASS_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.class.declaration"), WRAPPING_BRACES, BRACE_PLACEMENT_OPTIONS, BRACE_PLACEMENT_VALUES);
     addOption("METHOD_BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.method.declaration"), WRAPPING_BRACES, BRACE_PLACEMENT_OPTIONS, BRACE_PLACEMENT_VALUES);
index 63484f890225f7e964763154629682aa09a72dde..319ce54196da4abc41e22fc8f7ce061457403758 100644 (file)
@@ -378,6 +378,8 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
                                  final PsiElement originalElement,
                                  @Nullable final Runnable closeCallback) {
     Project project = getProject(element);
+    if (!project.isOpen()) return;
+
     storeOriginalElement(project, originalElement, element);
 
     myPreviouslyFocused = WindowManagerEx.getInstanceEx().getFocusedComponent(project);
index 3fe38cea2ed35c775a25b76ea31477828b3513cc..e0a0d946c9c5bc5c0a55f09e4d3fcf7e61f71f54 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package com.intellij.ide.navigationToolbar;
 import com.intellij.ProjectTopics;
 import com.intellij.ide.actions.CopyAction;
 import com.intellij.ide.actions.CutAction;
+import com.intellij.ide.ui.LafManager;
+import com.intellij.ide.ui.LafManagerListener;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.actionSystem.ex.AnActionListener;
@@ -57,7 +59,8 @@ import java.util.List;
  */
 public class NavBarListener extends WolfTheProblemSolver.ProblemListener
   implements ActionListener, FocusListener, FileStatusListener, AnActionListener, FileEditorManagerListener,
-             PsiTreeChangeListener, ModuleRootListener, NavBarModelListener, PropertyChangeListener, KeyListener, WindowFocusListener {
+             PsiTreeChangeListener, ModuleRootListener, NavBarModelListener, PropertyChangeListener, KeyListener, WindowFocusListener,
+             LafManagerListener {
   private static final String LISTENER = "NavBarListener";
   private static final String BUS = "NavBarMessageBus";
   private final NavBarPanel myPanel;
@@ -89,6 +92,8 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
       if (window != null) {
         window.addWindowFocusListener(listener);
       }
+    } else {
+      LafManager.getInstance().addLafManagerListener(listener);
     }
   }
 
@@ -107,6 +112,7 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
       if (connection != null) {
         connection.disconnect();
       }
+      LafManager.getInstance().removeLafManagerListener(listener);
     }
   }
 
@@ -356,15 +362,19 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
   }
 
   @Override
-  public void windowLostFocus(WindowEvent e) {
-    final Window window = e.getWindow();
-    final Window oppositeWindow = e.getOppositeWindow();
+  public void lookAndFeelChanged(LafManager source) {
+    myPanel.getNavBarUI().clearItems();
+    myPanel.revalidate();
+    myPanel.repaint();
   }
 
+
   //---- Ignored
   @Override
-  public void windowGainedFocus(WindowEvent e) {
-  }
+  public void windowLostFocus(WindowEvent e) {}
+
+  @Override
+  public void windowGainedFocus(WindowEvent e) {}
 
   @Override
   public void keyTyped(KeyEvent e) {}
index 1201e146869d9f47dbfc7b9436ef5861be2b19a5..5e0f6e58d10696d47948ea5c4b55cb90dd117fec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ import java.util.Map;
  */
 public abstract class AbstractNavBarUI implements NavBarUI {
 
-  private final Map<NavBarItem, Map<ImageType, BufferedImage>> myCache = new THashMap<NavBarItem, Map<ImageType, BufferedImage>>();
+  private final static Map<NavBarItem, Map<ImageType, BufferedImage>> myCache = new THashMap<NavBarItem, Map<ImageType, BufferedImage>>();
 
   private enum ImageType {
     INACTIVE, NEXT_ACTIVE, ACTIVE, INACTIVE_FLOATING, NEXT_ACTIVE_FLOATING, ACTIVE_FLOATING,
index 024c3feabe5ec48f93dc2f548f32e6b35d2de359..7a190f6be71c35b7123d6b49c8c746b50cf131ea 100644 (file)
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.ContainerUtilRt;
 import com.intellij.util.ui.EmptyIcon;
 import org.jetbrains.annotations.NotNull;
 
@@ -136,7 +137,7 @@ public class CreateScratchFileAction extends AnAction implements DumbAware {
 
   @NotNull
   public static List<Language> getLanguages() {
-    Set<Language> result = ContainerUtil.newTreeSet(new Comparator<Language>() {
+    Set<Language> result = ContainerUtilRt.newTreeSet(new Comparator<Language>() {
       @Override
       public int compare(@NotNull Language l1, @NotNull Language l2) {
         return l1.getDisplayName().compareTo(l2.getDisplayName());
index 348283dc38854f4e8fb1a7310ed5317869c03b0b..05d9bb771978ba3bde7d49fbfa10b4f6664f3f68 100644 (file)
@@ -40,6 +40,7 @@ import com.intellij.ui.components.JBLabel;
 import com.intellij.ui.speedSearch.SpeedSearchUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.ContainerUtilRt;
 import com.intellij.util.ui.EmptyIcon;
 import com.intellij.util.ui.UIUtil;
 import org.apache.oro.text.regex.*;
@@ -492,7 +493,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
   @NotNull
   @Override
   public SortedSet<Object> sort(@NotNull Set<Object> elements) {
-    TreeSet<Object> objects = ContainerUtil.newTreeSet(this);
+    TreeSet<Object> objects = ContainerUtilRt.newTreeSet(this);
     objects.addAll(elements);
     return objects;
   }
index eb03fa86fdab1e161b6c1ad5c290612a73d79fd3..c109c8c0e14d2e8c7d7a15fd1494b9ef23a81938 100644 (file)
@@ -25,10 +25,10 @@ import com.intellij.openapi.module.impl.ModuleImpl;
 import com.intellij.openapi.project.impl.ProjectImpl;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.io.fs.IFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -102,15 +102,13 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFiles(final boolean includingSubStructures) {
-      final List<IFile> result = super.getAllStorageFiles(includingSubStructures);
-
+    public List<File> getAllStorageFiles(final boolean includingSubStructures) {
+      List<File> result = super.getAllStorageFiles(includingSubStructures);
       if (includingSubStructures) {
         for (SaveSession moduleSaveSession : myModuleSaveSessions) {
           result.addAll(moduleSaveSession.getAllStorageFiles(true));
         }
       }
-
       return result;
     }
 
@@ -172,10 +170,9 @@ public class ProjectWithModulesStoreImpl extends ProjectStoreImpl {
     }
 
     @Override
-    protected void collectSubfilesToSave(final List<IFile> result) throws IOException {
+    protected void collectSubFilesToSave(final List<File> result) throws IOException {
       for (SaveSession moduleSaveSession : myModuleSaveSessions) {
-        final List<IFile> moduleFiles = moduleSaveSession.getAllStorageFilesToSave(true);
-        result.addAll(moduleFiles);
+        result.addAll(moduleSaveSession.getAllStorageFilesToSave(true));
       }
     }
   }
index b1f034d2dcb2004411253a6f611504f21f39d9ba..8f197a4950f8fd2c77e8930220f5ea587dabeea1 100644 (file)
@@ -39,8 +39,6 @@ import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.*;
 import com.intellij.openapi.vfs.tracker.VirtualFileTracker;
 import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.io.fs.FileSystem;
-import com.intellij.util.io.fs.IFile;
 import com.intellij.util.messages.MessageBus;
 import org.jdom.Element;
 import org.jetbrains.annotations.Nls;
@@ -192,10 +190,9 @@ public class ClasspathStorage implements StateStorage {
     return session;
   }
 
-  private static void convert2Io(List<IFile> list, ArrayList<VirtualFile> virtualFiles) {
+  private static void convert2Io(List<File> list, ArrayList<VirtualFile> virtualFiles) {
     for (VirtualFile virtualFile : virtualFiles) {
-      final File ioFile = VfsUtilCore.virtualToIoFile(virtualFile);
-      list.add(FileSystem.FILE_SYSTEM.createFile(ioFile.getAbsolutePath()));
+      list.add(VfsUtilCore.virtualToIoFile(virtualFile));
     }
   }
 
@@ -384,12 +381,12 @@ public class ClasspathStorage implements StateStorage {
         }
 
         @Override
-        public Set<String> getClasspath(final ModifiableRootModel model, final Element element) throws IOException, InvalidDataException {
+        public Set<String> getClasspath(final ModifiableRootModel model, final Element element) throws InvalidDataException {
           throw new InvalidDataException(getDescription());
         }
 
         @Override
-        public void setClasspath(ModuleRootModel model) throws IOException, WriteExternalException {
+        public void setClasspath(ModuleRootModel model) throws WriteExternalException {
           throw new WriteExternalException(getDescription());
         }
       };
@@ -426,9 +423,9 @@ public class ClasspathStorage implements StateStorage {
 
     @NotNull
     @Override
-    public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
+    public Collection<File> getStorageFilesToSave() throws StateStorageException {
       if (needsSave()) {
-        final List<IFile> list = new ArrayList<IFile>();
+        final List<File> list = new ArrayList<File>();
         final ArrayList<VirtualFile> virtualFiles = new ArrayList<VirtualFile>();
         getFileSet().listModifiedFiles(virtualFiles);
         convert2Io(list, virtualFiles);
@@ -441,9 +438,9 @@ public class ClasspathStorage implements StateStorage {
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFiles() {
-      final List<IFile> list = new ArrayList<IFile>();
-      final ArrayList<VirtualFile> virtualFiles = new ArrayList<VirtualFile>();
+    public List<File> getAllStorageFiles() {
+      List<File> list = new ArrayList<File>();
+      ArrayList<VirtualFile> virtualFiles = new ArrayList<VirtualFile>();
       getFileSet().listFiles(virtualFiles);
       convert2Io(list, virtualFiles);
       return list;
index e4c690ec05edcc48e2cd3d7afe1657dee827643e..87df147a745f1e8761a474b491d29a436eed2cbb 100644 (file)
@@ -86,6 +86,15 @@ public class ProjectSdksModel implements SdkModel {
   }
 
   public void reset(@Nullable Project project) {
+    resetSdkModel();
+    if (project != null) {
+      myProjectSdk = findSdk(ProjectRootManager.getInstance(project).getProjectSdkName());
+    }
+    myModified = false;
+    myInitialized = true;
+  }
+
+  private void resetSdkModel() {
     myProjectSdks.clear();
     final Sdk[] projectSdks = ProjectJdkTable.getInstance().getAllJdks();
     for (Sdk sdk : projectSdks) {
@@ -96,11 +105,6 @@ public class ProjectSdksModel implements SdkModel {
         LOG.error(e);
       }
     }
-    if (project != null) {
-      myProjectSdk = findSdk(ProjectRootManager.getInstance(project).getProjectSdkName());
-    }
-    myModified = false;
-    myInitialized = true;
   }
 
   public void disposeUIResources() {
@@ -154,6 +158,7 @@ public class ProjectSdksModel implements SdkModel {
         for (Sdk originalJdk : itemsInTable) {
           final Sdk modifiedJdk = myProjectSdks.get(originalJdk);
           LOG.assertTrue(modifiedJdk != null);
+          LOG.assertTrue(originalJdk != modifiedJdk);
           jdkTable.updateJdk(originalJdk, modifiedJdk);
         }
         // Add new items to table
@@ -166,6 +171,7 @@ public class ProjectSdksModel implements SdkModel {
         }
       }
     });
+    resetSdkModel();
     myModified = false;
   }
 
index 9e0bf738a7cfc863294bdcd646bc2d93c21092b9..fee268813d1440b3f52966fd04a6c89551b71d35 100644 (file)
@@ -52,7 +52,7 @@ public class FileChooser {
                                           @Nullable final Project project,
                                           @Nullable final VirtualFile toSelect) {
     final FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, parent);
-    return chooser.choose(toSelect, project);
+    return chooser.choose(project, toSelect);
   }
 
   @Nullable
index 78a4c1ece130fbc91f8dbe906784b781664f4420..3f9bc9d241f2b4ff4e9791c67f14043a1342d14f 100644 (file)
@@ -175,9 +175,25 @@ public class ConfigurableEP<T extends UnnamedConfigurable> extends AbstractExten
     return getDisplayName();
   }
 
+  public boolean isConfigurableProvided() {
+    if (providerClass == null) {
+      return implementationClass != null || instanceClass != null;
+    }
+    try {
+      ConfigurableProvider provider = instantiate(providerClass, myPicoContainer);
+      return provider.isConfigurableProvided(); // do not load heavy configurables
+    }
+    catch (Exception ignored) {
+      return true; // see InstanceFromProviderFactory#compute
+    }
+  }
+
   private class InstanceFromProviderFactory extends AtomicNotNullLazyValue<ConfigurableProvider> implements NullableFactory<T> {
     public T create() {
-      return (T)getValue().createConfigurable();
+      ConfigurableProvider provider = getValue();
+      return provider.isConfigurableProvided()
+             ? (T)provider.createConfigurable()
+             : null;
     }
 
     @NotNull
index 5a71ffa7305037df268a3813eecd7ef943805e5c..f0389cf83649a8d23a0d634ecf5b8e66ea1027c0 100644 (file)
@@ -29,4 +29,15 @@ public abstract class ConfigurableProvider {
   @Nullable
   public abstract Configurable createConfigurable();
 
+  /**
+   * Defines whether this provider creates a configurable or not.
+   * Note that the {@code createConfigurable} method will be called
+   * if this method returns {@code true}.
+   *
+   * @return {@code true} if this provider creates configurable,
+   *         {@code false} otherwise
+   */
+  public boolean isConfigurableProvided() {
+    return true;
+  }
 }
index 473dce3dda6cd7cc0358f364f70f1fedad18b12c..2395fa27f4c115f791560b98f1bb5c099457083d 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.options;
 
+@Deprecated
 public interface CurrentUserHolder {
   String getCurrentUserName();
 }
index e98bb05aba99de3b49acf3da8f438d63987b27d3..4f1d0dd4eaf92b1618c9bfcb6851311c77240fe0 100644 (file)
@@ -34,6 +34,12 @@ public interface SearchableConfigurable extends Configurable {
 
   interface Parent extends SearchableConfigurable, Composite {
     boolean hasOwnContent();
+
+    /**
+     * @deprecated use {@link ConfigurableProvider#isConfigurableProvided()} instead
+     *             to specify configurables which should not be visible
+     */
+    @Deprecated
     boolean isVisible();
 
     abstract class Abstract implements Parent {
index 94da2b15ba7a0bbf821911d5977fb0e37212a96b..55578fe8d9942a8620896f24c9ff59c2f9dabc4a 100644 (file)
@@ -64,7 +64,7 @@ public abstract class Animator implements Disposable {
 
     reset();
 
-    if (ApplicationManager.getApplication() == null) {
+    if (noApplication()) {
       animationDone();
     }
   }
@@ -133,8 +133,7 @@ public abstract class Animator implements Disposable {
   }
 
   public void resume() {
-    final Application app = ApplicationManager.getApplication();
-    if (app == null || app.isUnitTestMode()) {
+    if (noApplication()) {
       animationDone();
       return;
     }
@@ -164,6 +163,11 @@ public abstract class Animator implements Disposable {
     }
   }
 
+  protected boolean noApplication() {
+    Application app = ApplicationManager.getApplication();
+    return app == null || app.isUnitTestMode();
+  }
+
   public abstract void paintNow(int frame, int totalFrames, int cycle);
 
   @Override
index 3d467232b3e3fe325c24b46ec70d2b3282416921..194c001be35fd3e0b261e53c8f70a7c0c6bc726d 100644 (file)
@@ -28,7 +28,7 @@ public class AsyncProcessIcon extends AnimatedIcon {
   public static final int COUNT = 12;
   public static final int CYCLE_LENGTH = 800;
 
-  private static final Icon[] SMALL_ICONS = findIcons("/process/step_", "/process/step_mask.png");
+  public static final Icon[] SMALL_ICONS = findIcons("/process/step_", "/process/step_mask.png");
   private boolean myUseMask;
 
   public AsyncProcessIcon(@NonNls String name) {
index 4189b6adf98b1e89ba2876bcd27b2929dd6b1e8b..cf10681f82a554a7fbad97cfd03d43a428c38954 100644 (file)
@@ -36,15 +36,15 @@ import org.jetbrains.annotations.Nullable;
   name = "RecentDirectoryProjectsManager",
   roamingType = RoamingType.DISABLED,
   storages = {
-    @Storage(
-      file = StoragePathMacros.APP_CONFIG + "/other.xml"
-    )}
+    @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml")
+  }
 )
 public class RecentDirectoryProjectsManager extends RecentProjectsManagerBase {
   public RecentDirectoryProjectsManager(MessageBus messageBus) {
     super(messageBus);
   }
 
+  @Override
   @Nullable
   protected String getProjectPath(@NotNull Project project) {
     final ProjectBaseDirectory baseDir = ProjectBaseDirectory.getInstance(project);
@@ -52,6 +52,7 @@ public class RecentDirectoryProjectsManager extends RecentProjectsManagerBase {
     return baseDirVFile != null ? FileUtil.toSystemDependentName(baseDirVFile.getPath()) : null;
   }
 
+  @Override
   protected void doOpenProject(@NotNull String projectPath, Project projectToClose, boolean forceOpenInNewFrame) {
     final VirtualFile projectDir = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(projectPath));
     if (projectDir != null) {
index c5b79637ca407e36a0234cff59a56c8e7c923584..27124d464d96eae05d3d89277900d69e6cc1440a 100644 (file)
@@ -360,7 +360,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
   }
 
   private static void assertActionIsGroupOrStub(final AnAction action) {
-    if (!(action instanceof ActionGroup || action instanceof ActionStub)) {
+    if (!(action instanceof ActionGroup || action instanceof ActionStub || action instanceof ChameleonAction)) {
       LOG.error("Action : " + action + "; class: " + action.getClass());
     }
   }
@@ -520,11 +520,9 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
     LOG.assertTrue(action.equals(stub));
 
     AnAction anAction = convertStub(stub);
-
-    addToMap(stub.getId(), anAction, stub.getPluginId(), stub.getProjectType());
     myAction2Id.put(anAction, stub.getId());
 
-    return anAction;
+    return addToMap(stub.getId(), anAction, stub.getPluginId(), stub.getProjectType());
   }
 
   @Override
@@ -996,7 +994,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
 
   public void registerAction(@NotNull String actionId, @NotNull AnAction action, @Nullable PluginId pluginId, @Nullable String projectType) {
     synchronized (myLock) {
-      if (!addToMap(actionId, action, pluginId, projectType)) return;
+      if (addToMap(actionId, action, pluginId, projectType) == null) return;
       if (myAction2Id.containsKey(action)) {
         reportActionError(pluginId, "action was already registered for another ID. ID is " + myAction2Id.get(action) +
                                     getPluginInfo(pluginId));
@@ -1016,32 +1014,42 @@ public final class ActionManagerImpl extends ActionManagerEx implements Applicat
     }
   }
 
-  public boolean addToMap(String actionId, AnAction action, PluginId pluginId, String projectType) {
-    if (myId2Action.containsKey(actionId)) {
-      ProjectType type = projectType == null ? null : new ProjectType(projectType);
-      // make sure id+projectType is unique
-      AnAction o = myId2Action.get(actionId);
-      ChameleonAction chameleonAction;
-      if (o instanceof ChameleonAction) {
-        chameleonAction = (ChameleonAction)o;
-      }
-      else {
-        chameleonAction = new ChameleonAction(o, type);
-        myId2Action.put(actionId, chameleonAction);
-      }
-      AnAction old = chameleonAction.addAction(action, type);
-      if (old != null) {
-        reportActionError(pluginId,
-                          "action with the ID \"" + actionId + "\" was already registered. Action being registered is " + action +
-                          "; Registered action is " +
-                          myId2Action.get(actionId) + getPluginInfo(pluginId));
-        return false;
-      }
+  private AnAction addToMap(String actionId, AnAction action, PluginId pluginId, String projectType) {
+    if (projectType != null || myId2Action.containsKey(actionId)) {
+      return registerChameleon(actionId, action, pluginId, projectType);
     }
     else {
       myId2Action.put(actionId, action);
+      return action;
     }
-    return true;
+  }
+
+  private AnAction registerChameleon(String actionId, AnAction action, PluginId pluginId, String projectType) {
+    ProjectType type = projectType == null ? null : new ProjectType(projectType);
+    // make sure id+projectType is unique
+    AnAction o = myId2Action.get(actionId);
+    ChameleonAction chameleonAction;
+    if (o == null) {
+      chameleonAction = new ChameleonAction(action, type);
+      myId2Action.put(actionId, chameleonAction);
+      return chameleonAction;
+    }
+    if (o instanceof ChameleonAction) {
+      chameleonAction = (ChameleonAction)o;
+    }
+    else {
+      chameleonAction = new ChameleonAction(o, type);
+      myId2Action.put(actionId, chameleonAction);
+    }
+    AnAction old = chameleonAction.addAction(action, type);
+    if (old != null) {
+      reportActionError(pluginId,
+                        "action with the ID \"" + actionId + "\" was already registered. Action being registered is " + action +
+                        "; Registered action is " +
+                        myId2Action.get(actionId) + getPluginInfo(pluginId));
+      return null;
+    }
+    return chameleonAction;
   }
 
   @Override
index edfd0975f9783b6809e133f2c3932f63a98ae2b7..f4e92f7eae0234f6dddbb050c31c82772ec3f6c6 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectType;
 import com.intellij.openapi.project.ProjectTypeService;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.annotations.TestOnly;
 
 import java.util.HashMap;
@@ -47,24 +48,30 @@ public class ChameleonAction extends AnAction {
   }
 
   @Override
-  public void actionPerformed(AnActionEvent e) {
-    getAction(e).actionPerformed(e);
+  public void actionPerformed(@NotNull AnActionEvent e) {
+    AnAction action = getAction(e);
+    assert action != null;
+    action.actionPerformed(e);
   }
 
   @Override
-  public void update(AnActionEvent e) {
+  public void update(@NotNull AnActionEvent e) {
     AnAction action = getAction(e);
-    action.update(e);
-    getTemplatePresentation().setEnabled(e.getPresentation().isEnabled());
-    getTemplatePresentation().setVisible(e.getPresentation().isVisible());
+    if (action != null) {
+      e.getPresentation().setVisible(true);
+      action.update(e);
+    }
+    else {
+      e.getPresentation().setVisible(false);
+    }
   }
 
+  @Nullable
   private AnAction getAction(AnActionEvent e) {
     Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
     ProjectType projectType = ProjectTypeService.getProjectType(project);
     AnAction action = myActions.get(projectType);
     if (action == null) action = myActions.get(null);
-    if (action == null) action = myActions.values().iterator().next();
     return action;
   }
 
index a00533d3244b01e9a3272594369b7a660a4d907f..86ccd77be20df5607d964130b5211b20608e950e 100644 (file)
@@ -36,7 +36,6 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
 
   private static final String XML_EXTENSION = ".xml";
   private static final String DEFAULT_STORAGE_SPEC = StoragePathMacros.APP_CONFIG + "/" + PathManager.DEFAULT_OPTIONS_FILE_NAME + XML_EXTENSION;
-  private static final String OPTIONS_MACRO = "OPTIONS";
   private static final String ROOT_ELEMENT_NAME = "application";
 
   private final ApplicationImpl myApplication;
@@ -95,7 +94,6 @@ class ApplicationStoreImpl extends ComponentStoreImpl implements IApplicationSto
   @Override
   public void setOptionsPath(final String path) {
     myStateStorageManager.addMacro(StoragePathMacros.getMacroName(StoragePathMacros.APP_CONFIG), path);
-    myStateStorageManager.addMacro(OPTIONS_MACRO, path);
   }
 
   @Override
index dac48586b70da7cc678f34c7b481f58e907267a4..ed63bf12d4c492d18fdd907c4ebaf13ff8607132 100644 (file)
@@ -29,12 +29,12 @@ import com.intellij.openapi.util.*;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.ReflectionUtil;
-import com.intellij.util.io.fs.IFile;
 import gnu.trove.THashMap;
 import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Type;
 import java.util.*;
@@ -46,12 +46,6 @@ public abstract class ComponentStoreImpl implements IComponentStore {
   private final List<SettingsSavingComponent> mySettingsSavingComponents = Collections.synchronizedList(new ArrayList<SettingsSavingComponent>());
   @Nullable private SaveSessionImpl mySession;
 
-  @Deprecated
-  @Nullable
-  private StateStorage getStateStorage(@NotNull final Storage storageSpec) throws StateStorageException {
-    return getStateStorageManager().getStateStorage(storageSpec);
-  }
-
   @Nullable
   protected abstract StateStorage getDefaultsStorage();
 
@@ -255,9 +249,10 @@ public abstract class ComponentStoreImpl implements IComponentStore {
 
     Storage[] storageSpecs = getComponentStorageSpecs(component, StateStorageOperation.READ);
     for (Storage storageSpec : storageSpecs) {
-      StateStorage stateStorage = getStateStorage(storageSpec);
-      if (stateStorage == null || !stateStorage.hasState(component, name, stateClass, reloadData)) continue;
-      state = stateStorage.getState(component, name, stateClass, state);
+      StateStorage stateStorage = getStateStorageManager().getStateStorage(storageSpec);
+      if (stateStorage != null && stateStorage.hasState(component, name, stateClass, reloadData)) {
+        state = stateStorage.getState(component, name, stateClass, state);
+      }
     }
 
     if (state != null) {
@@ -320,15 +315,10 @@ public abstract class ComponentStoreImpl implements IComponentStore {
     }
     assert storages.length > 0;
 
-    final Class<StorageAnnotationsDefaultValues.NullStateStorageChooser> defaultClass =
-        StorageAnnotationsDefaultValues.NullStateStorageChooser.class;
-
     final Class<? extends StateStorageChooser> storageChooserClass = stateSpec.storageChooser();
-    final StateStorageChooser<PersistentStateComponent<?>> defaultStateStorageChooser = getDefaultStateStorageChooser();
-    assert storageChooserClass != defaultClass || defaultStateStorageChooser != null : "State chooser not specified for: " +
-                                                                                       persistentStateComponent.getClass();
-
-    if (storageChooserClass == defaultClass) {
+    if (storageChooserClass == StateStorageChooser.class) {
+      StateStorageChooser<PersistentStateComponent<?>> defaultStateStorageChooser = getDefaultStateStorageChooser();
+      assert defaultStateStorageChooser != null : "State chooser not specified for: " + persistentStateComponent.getClass();
       return defaultStateStorageChooser.selectStorages(storages, persistentStateComponent, operation);
     }
     else if (storageChooserClass == LastStorageChooserForWrite.class) {
@@ -364,7 +354,7 @@ public abstract class ComponentStoreImpl implements IComponentStore {
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
+    public List<File> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
       try {
         return myStorageManagerSaveSession.getAllStorageFilesToSave();
       }
@@ -453,10 +443,9 @@ public abstract class ComponentStoreImpl implements IComponentStore {
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFiles(final boolean includingSubStructures) {
+    public List<File> getAllStorageFiles(final boolean includingSubStructures) {
       return myStorageManagerSaveSession.getAllStorageFiles();
     }
-
   }
 
   @Override
index 51cc717726f38d37599de97dc8d8cbd0e02bdf20..aacdb58aeeeca6283599d6e64800a65c21e4ca4d 100644 (file)
@@ -18,9 +18,9 @@ package com.intellij.openapi.components.impl.stores;
 import com.intellij.openapi.components.StateStorage;
 import com.intellij.openapi.components.StateStorageException;
 import com.intellij.util.SmartList;
-import com.intellij.util.io.fs.IFile;
 import gnu.trove.THashMap;
 
+import java.io.File;
 import java.util.List;
 import java.util.Map;
 
@@ -36,8 +36,8 @@ public class CompoundSaveSession {
     }
   }
 
-  public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
-    List<IFile> result = new SmartList<IFile>();
+  public List<File> getAllStorageFilesToSave() throws StateStorageException {
+    List<File> result = new SmartList<File>();
     for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
       result.addAll(saveSession.getStorageFilesToSave());
     }
@@ -70,8 +70,8 @@ public class CompoundSaveSession {
     return mySaveSessions.get(storage);
   }
 
-  public List<IFile> getAllStorageFiles() {
-    List<IFile> result = new SmartList<IFile>();
+  public List<File> getAllStorageFiles() {
+    List<File> result = new SmartList<File>();
     for (StateStorage.SaveSession saveSession : mySaveSessions.values()) {
       result.addAll(saveSession.getAllStorageFiles());
     }
index 3944f5086e2cc501991be15b6789736a01630084..aa3635dd09c299fb5fefe8357f88e0f168f5b68f 100644 (file)
@@ -21,12 +21,12 @@ import com.intellij.openapi.project.impl.ProjectImpl;
 import com.intellij.openapi.project.impl.ProjectManagerImpl;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.io.fs.IFile;
 import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Collections;
@@ -101,13 +101,13 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
 
         @NotNull
         @Override
-        public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
+        public Collection<File> getStorageFilesToSave() throws StateStorageException {
           return Collections.emptyList();
         }
 
         @NotNull
         @Override
-        public List<IFile> getAllStorageFiles() {
+        public List<File> getAllStorageFiles() {
           return Collections.emptyList();
         }
       }
@@ -186,6 +186,7 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
         throw new UnsupportedOperationException("Method getStreamProviders not implemented in " + getClass());
       }
 
+      @NotNull
       @Override
       public Collection<String> getStorageFileNames() {
         throw new UnsupportedOperationException("Method getStorageFileNames not implemented in " + getClass());
@@ -238,13 +239,13 @@ public class DefaultProjectStoreImpl extends ProjectStoreImpl {
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
+    public List<File> getAllStorageFilesToSave() throws StateStorageException {
       return Collections.emptyList();
     }
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFiles() {
+    public List<File> getAllStorageFiles() {
       return Collections.emptyList();
     }
 
index 8a210c321c3c026db755c0fe5343ef11a3116ab2..9774271e61c726b069ab5696ff9b99a8895e020f 100644 (file)
@@ -26,7 +26,8 @@ import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.*;
 import com.intellij.openapi.vfs.tracker.VirtualFileTracker;
-import com.intellij.util.io.fs.IFile;
+import com.intellij.util.SmartList;
+import com.intellij.util.containers.SmartHashSet;
 import com.intellij.util.messages.MessageBus;
 import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
@@ -37,16 +38,13 @@ import java.io.File;
 import java.io.IOException;
 import java.util.*;
 
-import static com.intellij.util.io.fs.FileSystem.FILE_SYSTEM;
-
 //todo: support missing plugins
 //todo: support storage data
 public class DirectoryBasedStorage implements StateStorage, Disposable {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.components.impl.stores.DirectoryBasedStorage");
-  private static final IFile[] EMPTY_FILES = new IFile[0];
 
   private final TrackingPathMacroSubstitutor myPathMacroSubstitutor;
-  private final IFile myDir;
+  private final File myDir;
   private final StateSplitter mySplitter;
   private final FileTypeManager myFileTypeManager;
 
@@ -59,7 +57,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
                                @NotNull Disposable parentDisposable,
                                @NotNull PicoContainer picoContainer) {
     myPathMacroSubstitutor = pathMacroSubstitutor;
-    myDir = FILE_SYSTEM.createFile(dir);
+    myDir = new File(dir);
     mySplitter = splitter;
     Disposer.register(parentDisposable, this);
 
@@ -180,31 +178,27 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
     @Override
     public void save() throws StateStorageException {
       assert mySession == this;
-      final Set<String> currentNames = new HashSet<String>();
-
-      IFile[] children = myDir.exists() ? myDir.listFiles() : EMPTY_FILES;
-      for (IFile child : children) {
-        final String fileName = child.getName();
-        if (!myFileTypeManager.isFileIgnored(fileName) && StringUtil.endsWithIgnoreCase(fileName, ".xml")) {
-          currentNames.add(fileName);
+      final Set<String> currentNames = new SmartHashSet<String>();
+      File[] children = myDir.listFiles();
+      if (children != null) {
+        for (File child : children) {
+          final String fileName = child.getName();
+          if (!myFileTypeManager.isFileIgnored(fileName) && StringUtil.endsWithIgnoreCase(fileName, ".xml")) {
+            currentNames.add(fileName);
+          }
         }
       }
 
       myStorageData.process(new DirectoryStorageData.StorageDataProcessor() {
         @Override
-        public void process(final String componentName, final IFile file, final Element element) {
+        public void process(final String componentName, final File file, final Element element) {
           currentNames.remove(file.getName());
 
           if (myPathMacroSubstitutor != null) {
             myPathMacroSubstitutor.collapsePaths(element);
           }
 
-          if (file.getTimeStamp() <= myStorageData.getLastTimeStamp()) {
-            if (!myDir.exists()) {
-              myDir.createParentDirs();
-              myDir.mkDir();
-            }
-
+          if (file.lastModified() <= myStorageData.getLastTimeStamp()) {
             StorageUtil.save(file, element, MySaveSession.this, false);
             myStorageData.updateLastTimestamp(file);
           }
@@ -217,9 +211,8 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
         public void run() {
           if (myDir.exists()) {
             for (String name : currentNames) {
-              IFile child = myDir.getChild(name);
-
-              if (child.getTimeStamp() > myStorageData.getLastTimeStamp()) {
+              File child = new File(myDir, name);
+              if (child.lastModified() > myStorageData.getLastTimeStamp()) {
                 // do not touch new files during VC update (which aren't read yet)
                 // now got an opposite problem: file is recreated if was removed by VC during update.
                 return;
@@ -272,23 +265,26 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
 
     @Override
     @NotNull
-    public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
+    public Collection<File> getStorageFilesToSave() throws StateStorageException {
       assert mySession == this;
 
       if (!myDir.exists()) return getAllStorageFiles();
       assert myDir.isDirectory() : myDir.getPath();
 
-      final List<IFile> filesToSave = new ArrayList<IFile>();
-
-      IFile[] children = myDir.listFiles();
-      final Set<String> currentChildNames = new HashSet<String>();
-      for (IFile child : children) {
-        if (!myFileTypeManager.isFileIgnored(child.getName())) currentChildNames.add(child.getName());
+      final List<File> filesToSave = new ArrayList<File>();
+      final Set<String> currentChildNames = new SmartHashSet<String>();
+      File[] children = myDir.listFiles();
+      if (children != null) {
+        for (File child : children) {
+          if (!myFileTypeManager.isFileIgnored(child.getName())) {
+            currentChildNames.add(child.getName());
+          }
+        }
       }
 
       myStorageData.process(new DirectoryStorageData.StorageDataProcessor() {
         @Override
-        public void process(final String componentName, final IFile file, final Element element) {
+        public void process(final String componentName, final File file, final Element element) {
           if (currentChildNames.contains(file.getName())) {
             currentChildNames.remove(file.getName());
 
@@ -305,8 +301,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
       });
 
       for (String childName : currentChildNames) {
-        final IFile child = myDir.getChild(childName);
-        filesToSave.add(child);
+        filesToSave.add(new File(myDir, childName));
       }
 
       return filesToSave;
@@ -314,8 +309,8 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
 
     @Override
     @NotNull
-    public List<IFile> getAllStorageFiles() {
-      return new ArrayList<IFile>(myStorageData.getAllStorageFiles().keySet());
+    public List<File> getAllStorageFiles() {
+      return new SmartList<File>(myStorageData.getAllStorageFiles().keySet());
     }
   }
 
@@ -327,13 +322,12 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
     }
 
     @Override
-    public void setState(@NotNull final Object component, final String componentName, @NotNull final Object state, final Storage storageSpec)
-      throws StateStorageException {
+    public void setState(@NotNull final Object component, final String componentName, @NotNull final Object state, final Storage storageSpec) {
       assert mySession == this;
       setState(componentName, state, storageSpec);
     }
 
-    private void setState(final String componentName, @NotNull Object state, final Storage storageSpec) throws StateStorageException {
+    private void setState(final String componentName, @NotNull Object state, final Storage storageSpec) {
       try {
         final Element element = DefaultStateSerializer.serializeState(state, storageSpec);
         if (element != null) {
@@ -345,7 +339,7 @@ public class DirectoryBasedStorage implements StateStorage, Disposable {
             statePart.setAttribute(StorageData.NAME, componentName);
             statePart.addContent(e.detach());
 
-            myStorageData.put(componentName, myDir.getChild(name), statePart, false);
+            myStorageData.put(componentName, new File(myDir, name), statePart, false);
           }
         }
       }
index 757d174f86d2d3f2a79548d0fd3b6332bbabb2cc..88a227168e5ea5469f69215993b1f994a913d3e6 100644 (file)
@@ -33,8 +33,6 @@ import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.*;
 import com.intellij.openapi.vfs.tracker.VirtualFileTracker;
-import com.intellij.util.io.fs.FileSystem;
-import com.intellij.util.io.fs.IFile;
 import com.intellij.util.messages.MessageBus;
 import org.jdom.Document;
 import org.jdom.Element;
@@ -52,12 +50,12 @@ import java.util.Collections;
 import java.util.List;
 
 public class FileBasedStorage extends XmlElementStorage {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.components.impl.stores.FileBasedStorage");
+  private static final Logger LOG = Logger.getInstance(FileBasedStorage.class);
 
   private static boolean ourConfigDirectoryRefreshed = false;
 
   private final String myFilePath;
-  private final IFile myFile;
+  private final File myFile;
   private final String myRootElementName;
   private volatile VirtualFile myCachedVirtualFile;
 
@@ -76,16 +74,13 @@ public class FileBasedStorage extends XmlElementStorage {
 
     myRootElementName = rootElementName;
     myFilePath = filePath;
-    myFile = FileSystem.FILE_SYSTEM.createFile(myFilePath);
+    myFile = new File(filePath);
 
     VirtualFileTracker virtualFileTracker = ServiceManager.getService(VirtualFileTracker.class);
     MessageBus messageBus = (MessageBus)picoContainer.getComponentInstanceOfType(MessageBus.class);
     if (virtualFileTracker != null && messageBus != null) {
-      final String path = myFile.getAbsolutePath();
-      final String fileUrl = LocalFileSystem.PROTOCOL_PREFIX + path.replace(File.separatorChar, '/');
-
       final Listener listener = messageBus.syncPublisher(STORAGE_TOPIC);
-      virtualFileTracker.addTracker(fileUrl, new VirtualFileAdapter() {
+      virtualFileTracker.addTracker(LocalFileSystem.PROTOCOL_PREFIX + myFile.getAbsolutePath().replace(File.separatorChar, '/'), new VirtualFileAdapter() {
         @Override
         public void fileMoved(@NotNull VirtualFileMoveEvent event) {
           myCachedVirtualFile = null;
@@ -178,7 +173,7 @@ public class FileBasedStorage extends XmlElementStorage {
 
     @NotNull
     @Override
-    public Collection<IFile> getStorageFilesToSave() {
+    public Collection<File> getStorageFilesToSave() {
       if (needsSave()) {
         if (LOG.isDebugEnabled()) {
           LOG.info("File " + myFileSpec + " needs save; hash=" + myUpToDateHash + "; currentHash=" + calcHash() + "; " +
@@ -193,7 +188,7 @@ public class FileBasedStorage extends XmlElementStorage {
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFiles() {
+    public List<File> getAllStorageFiles() {
       return Collections.singletonList(myFile);
     }
   }
@@ -243,7 +238,7 @@ public class FileBasedStorage extends XmlElementStorage {
   }
 
   public File getFile() {
-    return new File(myFile.getPath());
+    return myFile;
   }
 
   @Override
@@ -324,7 +319,7 @@ public class FileBasedStorage extends XmlElementStorage {
   public File updateFileExternallyFromStreamProviders() throws IOException {
     Element element = getElement(loadData(true, null));
     if (element == null) {
-      myFile.delete();
+      FileUtil.delete(myFile);
       return null;
     }
 
index 0427a8be15ab9aab87ba2d06be7b3689e1d413ba..93a65a2eb50b7ad1f90cf4be7478a4a2b0f8b6dd 100644 (file)
@@ -19,10 +19,10 @@ import com.intellij.openapi.components.StateStorage;
 import com.intellij.openapi.components.StateStorageException;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.io.fs.IFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.Set;
@@ -54,17 +54,19 @@ public interface IComponentStore {
 
   interface SaveSession {
     @NotNull
-    List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException;
+    List<File> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException;
+
     @NotNull
     SaveSession save() throws IOException;
+
     void finishSave();
+
     void reset();
 
     @Nullable
-    Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles);
+    Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile, StateStorage>> changedFiles);
 
     @NotNull
-    List<IFile> getAllStorageFiles(final boolean includingSubStructures);
+    List<File> getAllStorageFiles(final boolean includingSubStructures);
   }
-
 }
index 70925688005974b584c89c96206fe18ff6620dc5..ac7bf84f6b3e020a2573cb5b476f514c4bcbc566 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+@SuppressWarnings("deprecation")
 final class OldStreamProviderAdapter extends StreamProvider implements CurrentUserHolder {
   final com.intellij.openapi.options.StreamProvider myProvider;
   private final RoamingType myRoamingType;
@@ -64,4 +65,4 @@ final class OldStreamProviderAdapter extends StreamProvider implements CurrentUs
   public String getCurrentUserName() {
     return myProvider instanceof CurrentUserHolder ? ((CurrentUserHolder)myProvider).getCurrentUserName() : null;
   }
-}
\ No newline at end of file
+}
index c4c801c735dc8b7fbad1b29274a7c4bf3d00f8e2..e73814ed5a315c5b0870756c8d1f78308e45216b 100644 (file)
@@ -39,9 +39,8 @@ import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.*;
+import com.intellij.util.SmartList;
 import com.intellij.util.containers.OrderedSet;
-import com.intellij.util.io.fs.FileSystem;
-import com.intellij.util.io.fs.IFile;
 import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jetbrains.annotations.NonNls;
@@ -67,7 +66,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
 
   protected ProjectImpl myProject;
   private StorageScheme myScheme = StorageScheme.DEFAULT;
-  private String myCachedLocation;
   private String myPresentableUrl;
 
   ProjectStoreImpl(final ProjectImpl project) {
@@ -202,7 +200,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
       }, ModalityState.defaultModalityState());
     }
 
-    myCachedLocation = null;
     myPresentableUrl = null;
   }
 
@@ -479,19 +476,16 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
 
     @NotNull
     @Override
-    public List<IFile> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
-      List<IFile> result = new ArrayList<IFile>();
-
+    public List<File> getAllStorageFilesToSave(final boolean includingSubStructures) throws IOException {
+      List<File> result = new SmartList<File>();
       if (includingSubStructures) {
-        collectSubfilesToSave(result);
+        collectSubFilesToSave(result);
       }
-
       result.addAll(super.getAllStorageFilesToSave(false));
-
       return result;
     }
 
-    protected void collectSubfilesToSave(final List<IFile> result) throws IOException { }
+    protected void collectSubFilesToSave(final List<File> result) throws IOException { }
 
     @NotNull
     @Override
@@ -523,10 +517,10 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
       return ApplicationManager.getApplication().runReadAction(new Computable<ReadonlyStatusHandler.OperationStatus>() {
         @Override
         public ReadonlyStatusHandler.OperationStatus compute() {
-          final List<IFile> filesToSave;
+          final List<File> filesToSave;
           try {
             filesToSave = getAllStorageFilesToSave(true);
-            final Iterator<IFile> iterator = filesToSave.iterator();
+            final Iterator<File> iterator = filesToSave.iterator();
             while (iterator.hasNext()) {
               if (!iterator.next().exists()) {
                 iterator.remove();
@@ -543,14 +537,12 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
           if (myProject.isToSaveProjectName()) {
             final VirtualFile baseDir = getProjectBaseDir();
             if (baseDir != null && baseDir.isValid()) {
-              filesToSave.add(FileSystem.FILE_SYSTEM
-                                .createFile(new File(new File(baseDir.getPath(), Project.DIRECTORY_STORE_FOLDER), ProjectImpl.NAME_FILE).getPath()));
+              filesToSave.add(new File(new File(baseDir.getPath(), Project.DIRECTORY_STORE_FOLDER), ProjectImpl.NAME_FILE));
             }
           }
 
-          for (IFile file : filesToSave) {
+          for (File file : filesToSave) {
             final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
-
             if (virtualFile != null) {
               virtualFile.refresh(false, false);
               if (virtualFile.isValid() && !virtualFile.isWritable()) {
@@ -680,14 +672,15 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
 
     @Override
     public Class<? extends StateStorage> storageClass() {
-      return StorageAnnotationsDefaultValues.NullStateStorage.class;
+      return StateStorage.class;
     }
 
     @Override
     public Class<? extends StateSplitter> stateSplitter() {
-      return StorageAnnotationsDefaultValues.NullStateSplitter.class;
+      return StateSplitter.class;
     }
 
+    @NotNull
     @Override
     public Class<? extends Annotation> annotationType() {
       throw new UnsupportedOperationException("Method annotationType not implemented in " + getClass());
index 92560821612b9107c15d605edc7cbacb8dcf1279..79e079303281bf0f571653da6eae3cc49c17ef85 100644 (file)
@@ -19,10 +19,10 @@ import com.intellij.openapi.components.*;
 import com.intellij.openapi.options.StreamProvider;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.io.fs.IFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -82,11 +82,11 @@ public interface StateStorageManager {
     Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile, StateStorage>> files);
 
     @NotNull
-    List<IFile> getAllStorageFilesToSave() throws StateStorageException;
+    List<File> getAllStorageFilesToSave() throws StateStorageException;
 
     @NotNull
-    List<IFile> getAllStorageFiles();
+    List<File> getAllStorageFiles();
 
     void save() throws StateStorageException;
   }
-}
\ No newline at end of file
+}
index df53261ccc03e475e28f49b0b8867bf0bfd0f93c..4c935059cd39e5547da1c37b495de7d4c4d26fae 100644 (file)
@@ -28,8 +28,8 @@ import com.intellij.openapi.util.io.FileUtilRt;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.ObjectUtils;
+import com.intellij.util.PathUtilRt;
 import com.intellij.util.SmartList;
-import com.intellij.util.io.fs.IFile;
 import gnu.trove.THashMap;
 import gnu.trove.THashSet;
 import gnu.trove.TObjectLongHashMap;
@@ -140,6 +140,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
     }
   }
 
+  @NotNull
   @Override
   public Collection<String> getStorageFileNames() {
     myStorageLock.lock();
@@ -176,19 +177,19 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
 
   @Nullable
   private StateStorage createStateStorage(Storage storageSpec) throws StateStorageException {
-    if (!storageSpec.storageClass().equals(StorageAnnotationsDefaultValues.NullStateStorage.class)) {
+    if (!storageSpec.storageClass().equals(StateStorage.class)) {
       String key = UUID.randomUUID().toString();
       ((MutablePicoContainer)myPicoContainer).registerComponentImplementation(key, storageSpec.storageClass());
       return (StateStorage)myPicoContainer.getComponentInstance(key);
     }
-    if (!storageSpec.stateSplitter().equals(StorageAnnotationsDefaultValues.NullStateSplitter.class)) {
+    if (!storageSpec.stateSplitter().equals(StateSplitter.class)) {
       return createDirectoryStateStorage(storageSpec.file(), storageSpec.stateSplitter());
     }
     return createFileStateStorage(storageSpec.file());
   }
 
   private static String getStorageSpecId(Storage storageSpec) {
-    if (!storageSpec.storageClass().equals(StorageAnnotationsDefaultValues.NullStateStorage.class)) {
+    if (!storageSpec.storageClass().equals(StateStorage.class)) {
       return storageSpec.storageClass().getName();
     }
     else {
@@ -237,8 +238,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
       return null;
     }
 
-    String extension = FileUtilRt.getExtension(new File(expandedFile).getName());
-    if (!ourHeadlessEnvironment && extension.isEmpty()) {
+    if (!ourHeadlessEnvironment && PathUtilRt.getFileName(expandedFile).lastIndexOf('.') < 0) {
       throw new IllegalArgumentException("Extension is missing for storage file: " + expandedFile);
     }
 
@@ -424,7 +424,8 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
   @Override
   @Nullable
   public StateStorage getOldStorage(Object component, String componentName, StateStorageOperation operation) throws StateStorageException {
-    return getFileStateStorage(getOldStorageSpec(component, componentName, operation));
+    String oldStorageSpec = getOldStorageSpec(component, componentName, operation);
+    return oldStorageSpec == null ? null : getFileStateStorage(oldStorageSpec);
   }
 
   @Nullable
@@ -440,14 +441,14 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
 
     @Override
     @NotNull
-    public List<IFile> getAllStorageFilesToSave() throws StateStorageException {
+    public List<File> getAllStorageFilesToSave() throws StateStorageException {
       assert mySession == this;
       return myCompoundSaveSession.getAllStorageFilesToSave();
     }
 
     @Override
     @NotNull
-    public List<IFile> getAllStorageFiles() {
+    public List<File> getAllStorageFiles() {
       return myCompoundSaveSession.getAllStorageFiles();
     }
 
@@ -506,10 +507,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
     if (!isDirty) return;
     String filePath = getNotNullVersionsFilePath();
     if (filePath != null) {
-      File dir = new File(filePath).getParentFile();
-      if (!dir.isDirectory() && !dir.mkdirs()) {
-        LOG.warn("Unable to create: " + dir);
-      }
+      FileUtilRt.createParentDirs(new File(filePath));
       try {
         JDOMUtil.writeDocument(new Document(createComponentVersionsXml(getComponentVersions())), filePath, "\n");
         isDirty = false;
@@ -546,6 +544,7 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
     return root;
   }
 
+  @SuppressWarnings("deprecation")
   private static class OldStreamProviderManager extends StreamProvider implements CurrentUserHolder {
     private final List<OldStreamProviderAdapter> myStreamProviders = new SmartList<OldStreamProviderAdapter>();
 
index 477176dbb9fc207725803eac797913fea3c508a8..ba8029f5bef6f05114f636f5df05f8ddbe760d47 100644 (file)
@@ -37,7 +37,6 @@ import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.SystemProperties;
 import com.intellij.util.UniqueFileNamesProvider;
 import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.io.fs.IFile;
 import com.intellij.util.ui.UIUtil;
 import org.jdom.Document;
 import org.jdom.Element;
@@ -128,9 +127,9 @@ public class StorageUtil {
    * Due to historical reasons files in ROOT_CONFIG don’t wrapped into document (xml prolog) opposite to files in APP_CONFIG
    */
   @Nullable
-  static VirtualFile save(@NotNull IFile file, @Nullable Parent element, Object requestor, boolean wrapAsDocument) throws StateStorageException {
+  static VirtualFile save(@NotNull File file, @Nullable Parent element, Object requestor, boolean wrapAsDocument) throws StateStorageException {
     if (isEmpty(element)) {
-      file.delete();
+      FileUtil.delete(file);
       return null;
     }
 
@@ -145,7 +144,7 @@ public class StorageUtil {
         }
       }
       else {
-        file.createParentDirs();
+        FileUtil.createParentDirs(file);
         byteOut = writeToBytes(document, SystemProperties.getLineSeparator());
       }
 
@@ -179,28 +178,26 @@ public class StorageUtil {
   }
 
   @NotNull
-  static VirtualFile getOrCreateVirtualFile(final Object requestor, final IFile ioFile) throws IOException {
-    VirtualFile vFile = getVirtualFile(ioFile);
-
-    if (vFile == null) {
-      vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
+  static VirtualFile getOrCreateVirtualFile(@Nullable Object requestor, @NotNull File ioFile) throws IOException {
+    VirtualFile virtualFile = getVirtualFile(ioFile);
+    if (virtualFile == null) {
+      virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
     }
 
-    if (vFile == null) {
-      final IFile parentFile = ioFile.getParentFile();
-      final VirtualFile parentVFile =
-        LocalFileSystem.getInstance().refreshAndFindFileByIoFile(parentFile); // need refresh if the directory has just been created
-      if (parentVFile == null) {
-        throw new IOException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile.getPath()));
+    if (virtualFile == null) {
+      File parentFile = ioFile.getParentFile();
+      // need refresh if the directory has just been created
+      VirtualFile parentVirtualFile = parentFile == null ? null : LocalFileSystem.getInstance().refreshAndFindFileByIoFile(parentFile);
+      if (parentVirtualFile == null) {
+        throw new IOException(ProjectBundle.message("project.configuration.save.file.not.found", parentFile == null ? "" : parentFile.getPath()));
       }
-      vFile = parentVFile.createChildData(requestor, ioFile.getName());
+      virtualFile = parentVirtualFile.createChildData(requestor, ioFile.getName());
     }
-
-    return vFile;
+    return virtualFile;
   }
 
   @Nullable
-  static VirtualFile getVirtualFile(final IFile ioFile) {
+  static VirtualFile getVirtualFile(@NotNull File ioFile) {
     return LocalFileSystem.getInstance().findFileByIoFile(ioFile);
   }
 
index ba7be36613e6506a641ccb94dc9b2d8ab1cdf300..c75e99dc1806a5cffe735e63f26a85e54f7e53d1 100644 (file)
@@ -19,27 +19,30 @@ import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
 import com.intellij.openapi.Disposable;
 import com.intellij.openapi.components.*;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.options.CurrentUserHolder;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.JDOMUtil;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.openapi.vfs.SafeWriteRequestor;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.io.fs.IFile;
 import gnu.trove.THashMap;
 import gnu.trove.THashSet;
 import gnu.trove.TObjectLongHashMap;
 import org.jdom.Document;
 import org.jdom.Element;
+import org.jdom.JDOMException;
 import org.jdom.filter.ElementFilter;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.*;
 
 public abstract class XmlElementStorage implements StateStorage, Disposable {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.components.impl.stores.XmlElementStorage");
+  private static final Logger LOG = Logger.getInstance(XmlElementStorage.class);
 
   private static final String ATTR_NAME = "name";
   private static final String VERSION_FILE_SUFFIX = ".ver";
@@ -139,18 +142,24 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
     StorageData result = createStorageData();
 
     if (useProvidersData && myStreamProvider != null && myStreamProvider.isEnabled()) {
+      boolean wasLoaded = false;
       try {
         if (roamingType == null) {
-          loadDataFromStreamProvider(result, RoamingType.PER_USER);
-          loadDataFromStreamProvider(result, RoamingType.PER_PLATFORM);
+          wasLoaded = loadDataFromStreamProvider(result, RoamingType.PER_USER) || loadDataFromStreamProvider(result, RoamingType.PER_PLATFORM);
         }
         else if (roamingType != RoamingType.DISABLED) {
-          loadDataFromStreamProvider(result, roamingType);
+          wasLoaded = loadDataFromStreamProvider(result, roamingType);
         }
       }
       catch (Exception e) {
         LOG.warn(e);
       }
+
+      //noinspection deprecation
+      if (wasLoaded && !myStreamProvider.isVersioningRequired() && !(myStreamProvider instanceof OldStreamProviderAdapter || myStreamProvider instanceof CurrentUserHolder)) {
+        // we don't use local data if stream provider has one (to preserve backward compatibility, we don't use this logic for old stream providers)
+        return result;
+      }
     }
 
     Element element = loadLocalData();
@@ -161,13 +170,17 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
     return result;
   }
 
-  private void loadDataFromStreamProvider(@NotNull StorageData result, @NotNull RoamingType roamingType) throws IOException {
+  private boolean loadDataFromStreamProvider(@NotNull StorageData result, @NotNull RoamingType roamingType) throws IOException, JDOMException {
     assert myStreamProvider != null;
-    Document sharedDocument = StorageUtil.loadDocument(myStreamProvider.loadContent(myFileSpec, roamingType));
-    if (sharedDocument != null) {
-      filterOutOfDate(sharedDocument.getRootElement());
-      loadState(result, sharedDocument.getRootElement());
+    InputStream inputStream = myStreamProvider.loadContent(myFileSpec, roamingType);
+    if (inputStream == null) {
+      return false;
     }
+
+    Document sharedDocument = JDOMUtil.loadDocument(inputStream);
+    filterOutOfDate(sharedDocument.getRootElement());
+    loadState(result, sharedDocument.getRootElement());
+    return true;
   }
 
   protected void loadState(@NotNull StorageData result, @NotNull Element element) {
@@ -222,13 +235,13 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
 
       @NotNull
       @Override
-      public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
+      public Collection<File> getStorageFilesToSave() throws StateStorageException {
         return Collections.emptySet();
       }
 
       @NotNull
       @Override
-      public List<IFile> getAllStorageFiles() {
+      public List<File> getAllStorageFiles() {
         return Collections.emptyList();
       }
     };
@@ -563,7 +576,7 @@ public abstract class XmlElementStorage implements StateStorage, Disposable {
     myLoadedData = storageData;
   }
 
-  private void filterOutOfDate(Element element) {
+  private void filterOutOfDate(@NotNull Element element) {
     if (myRemoteVersionProvider == null) {
       return;
     }
index d2ea19bc403def31eac23ab2258196ccd8d8069d..2938f419909ca5226d8b8446614338e55b21641a 100644 (file)
@@ -122,6 +122,9 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
     if (toSelect.length == 1) {
       restoreSelection(toSelect[0]);
     }
+    else if (toSelect.length == 0) {
+      restoreSelection(null); // select last opened file
+    }
     else {
       selectInTree(toSelect, true);
     }
index 00f333ef4002431950018bdee257886eb6d350cc..a676023b6590b684cf76f8fbab83ebd3bec7911c 100644 (file)
@@ -20,6 +20,7 @@ import com.intellij.openapi.fileEditor.TextEditor;
 import com.intellij.openapi.fileEditor.impl.BaseRemoteFileEditor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.vfs.impl.http.HttpVirtualFile;
+import com.intellij.openapi.vfs.impl.http.RemoteFileInfo;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -28,14 +29,16 @@ import javax.swing.*;
 /**
  * @author nik
  */
-public class HttpFileEditor extends BaseRemoteFileEditor {
+class HttpFileEditor extends BaseRemoteFileEditor {
   private final RemoteFilePanel myPanel;
 
   public HttpFileEditor(@NotNull Project project, @NotNull HttpVirtualFile virtualFile) {
     super(project);
 
     myPanel = new RemoteFilePanel(project, virtualFile, this);
-    virtualFile.getFileInfo().download().doWhenDone(new Runnable() {
+    RemoteFileInfo fileInfo = virtualFile.getFileInfo();
+    assert fileInfo != null;
+    fileInfo.download().doWhenDone(new Runnable() {
       @Override
       public void run() {
         ApplicationManager.getApplication().invokeLater(new Runnable() {
index 17354c7f48553c45fc32048020cc162374e889e3..22234ab66a7444054ff9aaa5ec49788622fb24d7 100644 (file)
@@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
 /**
  * @author nik
  */
-public class HttpFileEditorProvider implements FileEditorProvider, DumbAware {
+class HttpFileEditorProvider implements FileEditorProvider, DumbAware {
   @Override
   public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file) {
     return file instanceof HttpVirtualFile && !file.isDirectory();
index 076d29e64bbeac5b0536fda53c58e12733c74274..4bd5549d85ffb5935426e0c1306f79b5a003ee6e 100644 (file)
@@ -83,6 +83,7 @@ public class RemoteFilePanel {
 
     final RemoteFileInfo remoteFileInfo = virtualFile.getFileInfo();
     myDownloadingListener = new MyDownloadingListener();
+    assert remoteFileInfo != null;
     remoteFileInfo.addDownloadingListener(myDownloadingListener);
     myCancelButton.addActionListener(new ActionListener() {
       @Override
index 429a55b2b8097ee943d48b5ea93f4e37c5cc42f0..2b5428411e47047ec55ea41f6163314f1e842ac2 100644 (file)
@@ -164,7 +164,7 @@ public class ConfigurableExtensionPointUtil {
   @NotNull
   private static <T extends Configurable> T findConfigurable(ConfigurableEP<Configurable>[] extensions, Class<T> configurableClass) {
     for (ConfigurableEP<Configurable> extension : extensions) {
-      if (extension.providerClass != null || extension.instanceClass != null || extension.implementationClass != null) {
+      if (extension.isConfigurableProvided()) {
         final Configurable configurable = extension.createConfigurable();
         if (configurableClass.isInstance(configurable)) {
           return configurableClass.cast(configurable);
index b5a62f8ae39553efd365f386028281452930feb0..cca07555054bbf76497f3f478fac234161dfb32e 100644 (file)
@@ -47,6 +47,9 @@ public class ConfigurableWrapper implements SearchableConfigurable {
 
   @Nullable
   public static <T extends UnnamedConfigurable> T wrapConfigurable(ConfigurableEP<T> ep) {
+    if (!ep.isConfigurableProvided()) {
+      return null;
+    }
     if (ep.displayName != null || ep.key != null || ep.groupId != null) {
       T configurable = null;
       if (ep.providerClass != null) {
@@ -196,7 +199,7 @@ public class ConfigurableWrapper implements SearchableConfigurable {
     return configurable instanceof SearchableConfigurable ? ((SearchableConfigurable)configurable).enableSearch(option) : null;
   }
 
-  private static class CompositeWrapper extends ConfigurableWrapper implements SearchableConfigurable.Parent {
+  private static class CompositeWrapper extends ConfigurableWrapper implements Configurable.Composite {
 
     private Configurable[] myKids;
 
@@ -241,42 +244,6 @@ public class ConfigurableWrapper implements SearchableConfigurable {
       myKids = ArrayUtil.append(myKids, configurable);
       return this;
     }
-
-    @Override
-    public boolean hasOwnContent() {
-      UnnamedConfigurable configurable = getConfigurable();
-      if (configurable instanceof SearchableConfigurable.Parent) {
-        SearchableConfigurable.Parent parent = (SearchableConfigurable.Parent)configurable;
-        return parent.hasOwnContent();
-      }
-      return false;
-    }
-
-    @Override
-    public boolean isVisible() {
-      if (super.myConfigurable == null) {
-        String name = super.myEp.instanceClass;
-        if (name == null) {
-          name = super.myEp.implementationClass;
-        }
-        if (name != null) {
-          try {
-            if (!SearchableConfigurable.Parent.class.isAssignableFrom(super.myEp.findClass(name))) {
-              return true; // do not instantiate wrapped configurable if not needed
-            }
-          }
-          catch (ClassNotFoundException exception) {
-            return true; // ignore unexpected exception from findClass
-          }
-        }
-      }
-      UnnamedConfigurable configurable = getConfigurable();
-      if (configurable instanceof SearchableConfigurable.Parent) {
-        SearchableConfigurable.Parent parent = (SearchableConfigurable.Parent)configurable;
-        return parent.isVisible();
-      }
-      return true;
-    }
   }
 
   private static final class GroupWrapper extends CompositeWrapper implements ConfigurableGroup {
index ee12807ed9e1b41cb3b9db34d754d0f7aa2aae99..bf81c7b17cbedcc544013c4845ab5c3df52c1582 100644 (file)
@@ -97,12 +97,6 @@ public final class MixedConfigurableGroup implements SearchableConfigurable, Con
     ArrayList<ConfigurableGroup> groups = new ArrayList<ConfigurableGroup>();
     HashMap<String, ArrayList<Configurable>> map = new HashMap<String, ArrayList<Configurable>>();
     for (Configurable configurable : configurables) {
-      if (configurable instanceof SearchableConfigurable.Parent) {
-        SearchableConfigurable.Parent parent = (SearchableConfigurable.Parent)configurable;
-        if (!parent.isVisible()) {
-          continue;
-        }
-      }
       if (configurable instanceof ConfigurableGroup) {
         groups.add((ConfigurableGroup)configurable);
       }
index e7b20959369e397945cd45af8c4cb47b432fcb58..b5243e7c7ec99dd6614689d292d75694f2a93451 100644 (file)
@@ -57,7 +57,6 @@ import com.intellij.util.ArrayUtil;
 import com.intellij.util.TimeoutUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashMap;
-import com.intellij.util.io.fs.IFile;
 import com.intellij.util.messages.MessageBus;
 import com.intellij.util.messages.MessageBusConnection;
 import com.intellij.util.ui.UIUtil;
@@ -922,9 +921,9 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
         IProjectStore projectStore = projectImpl.getStateStore();
         final String location = projectImpl.getPresentableUrl();
 
-        final List<IFile> original;
+        final List<File> original;
         try {
-          final IComponentStore.SaveSession saveSession = projectStore.startSave();
+          IComponentStore.SaveSession saveSession = projectStore.startSave();
           original = saveSession.getAllStorageFiles(true);
           saveSession.finishSave();
         }
@@ -937,7 +936,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
           application.runWriteAction(new Runnable() {
             @Override
             public void run() {
-              for (final IFile originalFile : original) {
+              for (File originalFile : original) {
                 restoreCopy(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(originalFile));
               }
             }
index 5565e77a8cfb5d62b3455ab0a462ed4d74394820..179d2db5cf81a3738c879bc5079544b8397d147a 100644 (file)
@@ -49,8 +49,8 @@ public final class ChannelRegistrar extends ChannelInboundHandlerAdapter {
     }
     finally {
       if (eventLoopGroup != null) {
-        eventLoopGroup.shutdownGracefully();
+        eventLoopGroup.shutdownGracefully(1, 2, TimeUnit.NANOSECONDS);
       }
     }
   }
-}
\ No newline at end of file
+}
index c09c1fc51ca3bbfe1eef4f8d2375f91639dd0219..983f0212e31e49b9ba90dd1be1d1c3f3036c169c 100644 (file)
@@ -212,6 +212,8 @@ wrapping.parameters.annotation=Parameter annotations
 wrapping.local.variables.annotation=Local variable annotations
 wrapping.enum.constants=Enum constants
 wrapping.long.lines=Ensure right margin is not exceeded
+wrapping.comments=Comments
+wrapping.comments.wrap.at.right.margin=Wrap at right margin
 
 checkbox.align.multiline.chained.methods=Chained methods
 checkbox.align.multiline.method.parameters=Method parameters
index 51028d93edac0a15f9a460fd76c4a56776da8697..29dcf0645cef4a37abd3cb9eabe70794c6be2ff4 100644 (file)
 
     <applicationService serviceImplementation="com.intellij.internal.statistic.UsageTrigger"/>
 
+    <applicationService serviceInterface="com.intellij.openapi.application.PathMacros"
+                        serviceImplementation="com.intellij.application.options.PathMacrosImpl"/>
+
     <projectService serviceInterface="com.intellij.openapi.vfs.ReadonlyStatusHandler"
                     serviceImplementation="com.intellij.openapi.vcs.readOnlyHandler.ReadonlyStatusHandlerImpl"/>
     <projectService serviceInterface="com.intellij.openapi.startup.StartupManager"
index 9aa86cfb9a018d19acb4dae3c45f8a87c005a211..8c416e6df4101583a80455b4ac38a68d1ed0caa9 100644 (file)
@@ -25,7 +25,8 @@
 
     <selectInTarget implementation="com.intellij.openapi.vcs.changes.SelectInChangesViewTarget"/>
 
-    <projectConfigurable groupId="itself" groupWeight="110" dynamic="true" key="version.control.main.configurable.name" bundle="messages.VcsBundle" instance="com.intellij.openapi.vcs.configurable.VcsManagerConfigurable" id="vcs"/>
+    <projectConfigurable groupId="itself" groupWeight="110" dynamic="true" key="version.control.main.configurable.name" bundle="messages.VcsBundle"
+                         provider="com.intellij.openapi.vcs.configurable.VcsManagerConfigurableProvider" id="vcs"/>
 
     <changesViewContent tabName="Repository" className="com.intellij.openapi.vcs.changes.committed.CommittedChangesViewManager"
                         predicateClassName="com.intellij.openapi.vcs.changes.committed.CommittedChangesVisibilityPredicate"/>
index d28921d17ba6fa0e8a1ce4a0fa01ac0cef6cca57..821cb528b6a9516a0aa855f837a64d5e973ec958 100644 (file)
@@ -30,7 +30,8 @@
     <projectService serviceInterface="com.intellij.xdebugger.impl.XDebuggerHistoryManager"
                     serviceImplementation="com.intellij.xdebugger.impl.XDebuggerHistoryManager"/>
 
-    <applicationConfigurable groupId="build" dynamic="true" key="debugger.configurable.display.name" bundle="messages.XDebuggerBundle" instance="com.intellij.xdebugger.impl.settings.DebuggerConfigurable"/>
+    <applicationConfigurable groupId="build" dynamic="true" key="debugger.configurable.display.name" bundle="messages.XDebuggerBundle"
+                             provider="com.intellij.xdebugger.impl.settings.DebuggerConfigurableProvider"/>
 
     <customizableActionGroupProvider implementation="com.intellij.xdebugger.impl.ui.XDebugTabCustomizableActionGroupProvider"/>
 
index 0e2e60d64fd726e423581ae443b27d9b20cbe0ea..9dd7590ac09e22da689002d15b7b5ccff1c06f94 100644 (file)
       <implementation-class>com.intellij.openapi.command.impl.DocumentReferenceManagerImpl</implementation-class>
     </component>
 
-    <component>
-      <interface-class>com.intellij.openapi.application.PathMacros</interface-class>
-      <implementation-class>com.intellij.application.options.PathMacrosImpl</implementation-class>
-    </component>
-
     <component>
       <interface-class>com.intellij.ide.ui.LafManager</interface-class>
       <implementation-class>com.intellij.ide.ui.laf.LafManagerImpl</implementation-class>
index 5900b67db6bd6916d0edb9294a9ee80133aef124..e5b586022ec4f26bac93cdf37f3693d3c8196bbe 100644 (file)
@@ -24,11 +24,11 @@ import com.intellij.openapi.components.impl.stores.ComponentVersionProvider;
 import com.intellij.openapi.components.impl.stores.XmlElementStorage;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.testFramework.LightPlatformLangTestCase;
-import com.intellij.util.io.fs.IFile;
 import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -108,16 +108,15 @@ public class XmlElementStorageTest extends LightPlatformLangTestCase {
 
         @NotNull
         @Override
-        public Collection<IFile> getStorageFilesToSave() throws StateStorageException {
-          return needsSave() ? getAllStorageFiles() : Collections.<IFile>emptyList();
+        public Collection<File> getStorageFilesToSave() throws StateStorageException {
+          return needsSave() ? getAllStorageFiles() : Collections.<File>emptyList();
         }
 
         @NotNull
         @Override
-        public List<IFile> getAllStorageFiles() {
+        public List<File> getAllStorageFiles() {
           throw new UnsupportedOperationException("Method getAllStorageFiles not implemented in " + getClass());
         }
-
       };
     }
   }
index 160aed545b0373bc1d352209c7fccbb52bcfeed5..fac4e5e9edb14ec2d5ec88bf91b7df37661255fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package com.intellij.openapi.application;
 
+import com.intellij.openapi.components.ServiceManager;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collection;
 import java.util.Set;
 
 public abstract class PathMacros {
-
   public static PathMacros getInstance() {
-    return ApplicationManager.getApplication().getComponent(PathMacros.class);
+    return ServiceManager.getService(PathMacros.class);
   }
 
   public abstract Set<String> getAllMacroNames();
@@ -33,9 +33,7 @@ public abstract class PathMacros {
   public abstract void setMacro(String name, String value);
 
   /**
-   * Obsolete macros that are to be removed gently from the project files. They can be read, but not written again. Not persisted.
-   * @param name
-   * @param value
+   * Obsolete macros that are to be removed gently from the project files. They can be read, but not written again. Not persisted
    */
   public abstract void addLegacyMacro(@NotNull String name, @NotNull String value);
 
index 5b234d133e40314956e3f780c67ceeb8533e0e23..191e0294305b2f985b2214ec37fcb5b21273141f 100644 (file)
@@ -32,7 +32,7 @@ public @interface State {
 
   Storage[] storages();
 
-  Class<? extends StateStorageChooser> storageChooser() default StorageAnnotationsDefaultValues.NullStateStorageChooser.class;
+  Class<? extends StateStorageChooser> storageChooser() default StateStorageChooser.class;
 
   boolean reloadable() default true;
-}
\ No newline at end of file
+}
index 36112e5dc02816f2cec621e0e18e5a4450d41a15..e6c51699806f652ec06debcaa5b504e2287a36f2 100644 (file)
@@ -19,11 +19,11 @@ package com.intellij.openapi.components;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileEvent;
-import com.intellij.util.io.fs.IFile;
 import com.intellij.util.messages.Topic;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -33,12 +33,15 @@ public interface StateStorage {
 
   @Nullable
   <T> T getState(final Object component, final String componentName, Class<T> stateClass, @Nullable T mergeInto) throws StateStorageException;
+
   boolean hasState(final Object component, final String componentName, final Class<?> aClass, final boolean reloadData) throws StateStorageException;
 
   @NotNull
   ExternalizationSession startExternalization();
+
   @NotNull
   SaveSession startSave(@NotNull ExternalizationSession externalizationSession);
+
   void finishSave(@NotNull SaveSession saveSession);
 
   void reload(@NotNull Set<String> changedComponents) throws StateStorageException;
@@ -51,13 +54,13 @@ public interface StateStorage {
     void save() throws StateStorageException;
 
     @Nullable
-    Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile,StateStorage>> changedFiles);
+    Set<String> analyzeExternalChanges(@NotNull Set<Pair<VirtualFile, StateStorage>> changedFiles);
 
     @NotNull
-    Collection<IFile> getStorageFilesToSave() throws StateStorageException;
+    Collection<File> getStorageFilesToSave() throws StateStorageException;
 
     @NotNull
-    List<IFile> getAllStorageFiles();
+    List<File> getAllStorageFiles();
   }
 
   interface Listener {
index e10b97755d3a2ecc99ac7a8e1d7afd2050d2f508..d01f1f89f1f7cdeeb4a877b6b64fdc191cd7b7aa 100644 (file)
@@ -28,6 +28,6 @@ public @interface Storage {
   @NonNls String file() default "";
   StorageScheme scheme() default StorageScheme.DEFAULT;
 
-  Class<? extends StateStorage> storageClass() default StorageAnnotationsDefaultValues.NullStateStorage.class;
-  Class<? extends StateSplitter> stateSplitter() default StorageAnnotationsDefaultValues.NullStateSplitter.class;
+  Class<? extends StateStorage> storageClass() default StateStorage.class;
+  Class<? extends StateSplitter> stateSplitter() default StateSplitter.class;
 }
diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/StorageAnnotationsDefaultValues.java b/platform/projectModel-api/src/com/intellij/openapi/components/StorageAnnotationsDefaultValues.java
deleted file mode 100644 (file)
index 5105105..0000000
+++ /dev/null
@@ -1,87 +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 com.intellij.openapi.components;
-
-import com.intellij.openapi.util.Pair;
-import org.jdom.Element;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-import java.util.Set;
-
-public interface StorageAnnotationsDefaultValues {
-  class NullStateStorage implements StateStorage {
-    @Override
-    @Nullable
-    public <T> T getState(final Object component, final String componentName, Class<T> stateClass, @Nullable T mergeInto)
-    throws StateStorageException {
-      throw new UnsupportedOperationException("Method getState is not supported in " + getClass());
-    }
-
-    @Override
-    public boolean hasState(final Object component, final String componentName, final Class<?> aClass, final boolean reloadData) throws StateStorageException {
-      throw new UnsupportedOperationException("Method hasState not implemented in " + getClass());
-    }
-
-    public void save() throws StateStorageException {
-      throw new UnsupportedOperationException("Method save is not supported in " + getClass());
-    }
-
-    @Override
-    @NotNull
-    public ExternalizationSession startExternalization() {
-      throw new UnsupportedOperationException("Method startExternalization not implemented in " + getClass());
-    }
-
-    @Override
-    @NotNull
-    public SaveSession startSave(@NotNull ExternalizationSession externalizationSession) {
-      throw new UnsupportedOperationException("Method startSave not implemented in " + getClass());
-    }
-
-    @Override
-    public void finishSave(@NotNull SaveSession saveSession) {
-      throw new UnsupportedOperationException("Method finishSave not implemented in " + getClass());
-    }
-
-    @Override
-    public void reload(@NotNull final Set<String> changedComponents) throws StateStorageException {
-      throw new UnsupportedOperationException("Method reload not implemented in " + getClass());
-    }
-
-  }
-
-  class NullStateStorageChooser implements StateStorageChooser {
-    @Override
-    public Storage[] selectStorages(Storage[] storages, Object component, final StateStorageOperation operation) {
-      throw new UnsupportedOperationException("Method selectStorages is not supported in " + getClass());
-    }
-  }
-
-  class NullStateSplitter implements StateSplitter {
-    @Override
-    public List<Pair<Element, String>> splitState(Element e) {
-      throw new UnsupportedOperationException("Method splitState not implemented in " + getClass());
-    }
-
-    @Override