Merge branch 'master' of git@git.labs.intellij.net:idea/community
authorEugene Kudelevsky <Eugene.Kudelevsky@jetbrains.com>
Mon, 15 Mar 2010 13:14:12 +0000 (16:14 +0300)
committerEugene Kudelevsky <Eugene.Kudelevsky@jetbrains.com>
Mon, 15 Mar 2010 13:14:12 +0000 (16:14 +0300)
51 files changed:
java/compiler/impl/src/com/intellij/compiler/impl/rmiCompiler/RmicCompiler.java
java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/daemon/ProjectStructureProblemsHolderImpl.java
java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java
java/java-impl/src/com/intellij/lang/java/JavaDocumentationProvider.java
java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportHelper.java
platform/lang-api/src/com/intellij/codeInsight/completion/DummyIdentifierPatcher.java
platform/lang-api/src/com/intellij/psi/search/PsiSearchHelper.java
platform/lang-api/src/com/intellij/psi/stubs/StubIndex.java
platform/lang-api/src/com/intellij/psi/util/PsiTreeUtil.java
platform/lang-impl/src/com/intellij/execution/impl/SingleConfigurationConfigurable.form
platform/lang-impl/src/com/intellij/injected/editor/DocumentWindowImpl.java
platform/lang-impl/src/com/intellij/packageDependencies/DefaultScopesProvider.java
platform/lang-impl/src/com/intellij/psi/impl/search/PsiSearchHelperImpl.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java
platform/platform-api/src/com/intellij/openapi/fileTypes/FileTypeManager.java
platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java
platform/platform-api/src/com/intellij/openapi/vfs/newvfs/ManagingFS.java
platform/platform-impl/src/com/intellij/ide/ui/search/SearchUtil.java
platform/platform-impl/src/com/intellij/openapi/vfs/impl/VirtualFilePointerImpl.java
platform/platform-resources-en/src/messages/IdeBundle.properties
platform/platform-resources-en/src/messages/RefactoringBundle.properties
platform/util/src/com/intellij/openapi/util/text/StringUtil.java
platform/util/src/com/intellij/util/ui/UIUtil.java
platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java
platform/vcs-api/src/com/intellij/openapi/vcs/VcsShowConfirmationOption.java
platform/vcs-api/src/com/intellij/openapi/vcs/changes/ChangeListListener.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangeListManagerImpl.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsConfirmationDialog.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DiffRequestPresentableProxy.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/FilePatchInProgress.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/shelf/DiffShelvedChangesAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.form
platform/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsGeneralConfigurationPanel.java
plugins/InspectionGadgets/src/com/siyeh/ig/abstraction/StaticMethodOnlyUsedInOneClassInspection.java
plugins/InspectionGadgets/src/com/siyeh/ig/j2me/InterfaceWithOnlyOneDirectInheritorInspection.java
plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplatesFactory.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypesSemilattice.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureSignatureUtil.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFieldImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClosureSignatureImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyPropertyUtils.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
plugins/groovy/testdata/highlighting/ByteArrayArgument.groovy [new file with mode: 0644]
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.java
plugins/properties/src/com/intellij/lang/properties/UnusedPropertyInspection.java
plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceDetailsAction.java

index 75aef5a38dbf4a6f25dd557039485e0a3c68130e..04972a1e68f313fd3fb5666b753ab2c6d1bbb713 100644 (file)
@@ -110,7 +110,7 @@ public class RmicCompiler implements ClassPostProcessingCompiler{
             }
 
             if (!VfsUtil.isAncestor(outputDir, outputClassFile, true)) {
-              LOG.assertTrue(false, outputClassFile.getPath() + " should be located under the output root " + outputDir.getPath());
+              LOG.error(outputClassFile.getPath() + " should be located under the output root " + outputDir.getPath());
             }
 
             final ProcessingItem item = createProcessingItem(module, outputClassFile, outputDir,
index 60cc936ced237a45468a6afce0dadabe1d2bf28b..82cb561b8fd85d09efadd45cea950abdfc161d8b 100644 (file)
@@ -46,8 +46,14 @@ public class ProjectStructureProblemsHolderImpl implements ProjectStructureProbl
     try {
       buf.append("<html><body>");
       if (myProblemDescriptions != null) {
+        int problems = 0;
         for (ProjectStructureProblemDescription problemDescription : myProblemDescriptions) {
           buf.append(problemDescription.getMessage()).append("<br>");
+          problems++;
+          if (problems >= 10 && myProblemDescriptions.size() > 12) {
+            buf.append(myProblemDescriptions.size() - problems).append(" more problems...<br>");
+            break;
+          }
         }
       }
       buf.append("</body></html>");
index 7c60ae78f1fbe95a8deba506a0ab954a17090327..b4e59b8238af40e174a5e410d0c71a6f25a5b549 100644 (file)
@@ -55,11 +55,11 @@ import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.impl.PsiClassImplUtil;
-import com.intellij.psi.impl.search.PsiSearchHelperImpl;
 import com.intellij.psi.impl.source.jsp.jspJava.JspxImportStatement;
 import com.intellij.psi.jsp.JspFile;
 import com.intellij.psi.jsp.JspSpiUtil;
 import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.PsiSearchHelper;
 import com.intellij.psi.search.SearchScope;
 import com.intellij.psi.search.searches.MethodReferencesSearch;
 import com.intellij.psi.search.searches.OverridingMethodsSearch;
@@ -525,12 +525,12 @@ public class PostHighlightingPass extends TextEditorHighlightingPass {
     // some classes may have references from within XML outside dependent modules, e.g. our actions
     if (member instanceof PsiClass) scope = scope.uniteWith(GlobalSearchScope.projectScope(myProject));
 
-    PsiSearchHelperImpl.Result cheapEnough = ((PsiSearchHelperImpl)myFile.getManager().getSearchHelper()).isItCheapEnoughToSearch(myFile, name, scope);
-    if (cheapEnough == PsiSearchHelperImpl.Result.TOO_MANY_OCCURRENCES) return false;
+    PsiSearchHelper.SearchCostResult cheapEnough = myFile.getManager().getSearchHelper().isCheapEnoughToSearch(name, scope, myFile);
+    if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return false;
 
     //search usages if it cheap
     //if count is 0 there is no usages since we've called myRefCountHolder.isReferenced() before
-    if (cheapEnough == PsiSearchHelperImpl.Result.ZERO_OCCURRENCES && !canbeReferencedViaWeirdNames(member)) return true;
+    if (cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES && !canbeReferencedViaWeirdNames(member)) return true;
 
     Query<PsiReference> query = member instanceof PsiMethod
                                 ? MethodReferencesSearch.search((PsiMethod)member, scope, true)
index df905629b7035e7eb9e83b5e35d828fff07083a7..4cb54acf4a6b886824fa65551c6abfb7890f3725 100644 (file)
@@ -549,18 +549,16 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
 
 
   @Nullable
-  private static String generateExternalJavadoc(final PsiElement element, String fromUrl, boolean checkCompiled, JavaDocExternalFilter filter) {
-    if (!checkCompiled || element instanceof PsiCompiledElement) {
-      try {
-        String externalDoc = filter.getExternalDocInfoForElement(fromUrl, element);
-        if (externalDoc != null && externalDoc.length() > 0) {
-          return externalDoc;
-        }
-      }
-      catch (Exception e) {
-        //try to generate some javadoc
+  private static String fetchExternalJavadoc(final PsiElement element, String fromUrl, JavaDocExternalFilter filter) {
+    try {
+      String externalDoc = filter.getExternalDocInfoForElement(fromUrl, element);
+      if (externalDoc != null && externalDoc.length() > 0) {
+        return externalDoc;
       }
     }
+    catch (Exception e) {
+      //try to generate some javadoc
+    }
     return null;
   }
 
@@ -762,7 +760,7 @@ public class JavaDocumentationProvider implements CodeDocumentationProvider, Ext
     if (docURLs != null) {
       for (String docURL : docURLs) {
         try {
-          final String javadoc = generateExternalJavadoc(element, docURL, true, docFilter);
+          final String javadoc = fetchExternalJavadoc(element, docURL, docFilter);
           if (javadoc != null) return javadoc;
         }
         catch (IndexNotReadyException e) {
index 7168c8a5213bfa6cd693fdcb55d22d29d767c834..aeca7ad6406551dedba5d23a09a2982a5bb74b6f 100644 (file)
@@ -671,7 +671,10 @@ public class ImportHelper{
 
         PsiElement currentFileResolveScope = resolveResult.getCurrentFileResolveScope();
         if (!(currentFileResolveScope instanceof PsiImportStatementBase)) continue;
-        if (context != null && currentFileResolveScope instanceof JspxImportStatement && context != ((JspxImportStatement)currentFileResolveScope).getDeclarationFile()) {
+        if (context != null &&
+            (!currentFileResolveScope.isValid() ||
+            currentFileResolveScope instanceof JspxImportStatement &&
+            context != ((JspxImportStatement)currentFileResolveScope).getDeclarationFile())) {
           continue;
         }
 
index b2d38b8f14b6aa08a390b23571a8e48ee89091f4..5f058270a5fb9f7f1c1c0918706d0d5c5e22be9d 100644 (file)
@@ -32,8 +32,9 @@ public class DummyIdentifierPatcher extends FileCopyPatcher {
 
   public void patchFileCopy(@NotNull final PsiFile fileCopy, @NotNull final Document document, @NotNull final OffsetMap map) {
     if (StringUtil.isEmpty(myDummyIdentifier)) return;
-    document.replaceString(map.getOffset(CompletionInitializationContext.START_OFFSET), map.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET),
-                           myDummyIdentifier);
+    int startOffset = map.getOffset(CompletionInitializationContext.START_OFFSET);
+    int endOffset = map.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET);
+    document.replaceString(startOffset, endOffset, myDummyIdentifier);
   }
 
   @Override
index a3d1183f9f907373aaccfd011504e5589a396dc9..341b8206908f836285b3992247a1d01b8bad82eb 100644 (file)
@@ -179,4 +179,10 @@ public interface PsiSearchHelper {
                                   @NotNull String text,
                                   short searchContext,
                                   boolean caseSensitive);
+
+  SearchCostResult isCheapEnoughToSearch(@NotNull String name, @NotNull GlobalSearchScope scope, @Nullable PsiFile fileToIgnoreOccurencesIn);
+
+  enum SearchCostResult {
+    ZERO_OCCURRENCES, FEW_OCCURRENCES, TOO_MANY_OCCURRENCES
+  }
 }
index 4b4034f373d691365b978ee77f2bd884117a6e54..c331e6e9441dfd1c8fd0c777b2b3d0e2979873d5 100644 (file)
@@ -29,13 +29,13 @@ import org.jetbrains.annotations.NotNull;
 import java.util.Collection;
 
 public abstract class StubIndex {
-  private static StubIndex ourInstance = CachedSingletonsRegistry.markCachedField(StubIndex.class);
+
+  private static class StubIndexHolder {
+    private static final StubIndex ourInstance = ApplicationManager.getApplication().getComponent(StubIndex.class);
+  }
 
   public static StubIndex getInstance() {
-    if (ourInstance == null) {
-      ourInstance = ApplicationManager.getApplication().getComponent(StubIndex.class);
-    }
-    return ourInstance;
+    return StubIndexHolder.ourInstance;
   }
 
   public abstract <Key, Psi extends PsiElement> Collection<Psi> get(
index bbbea29c8583787cc99fcddad84679964510da94..b47dc9f8958f70a70c0ced179cc4ce7322fcc37d 100644 (file)
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 public class PsiTreeUtil {
@@ -49,8 +50,8 @@ public class PsiTreeUtil {
   public static boolean isAncestor(@Nullable PsiElement ancestor, @NotNull PsiElement element, boolean strict) {
     if (ancestor == null) return false;
     // fast path to avoid loading tree
-    if ((ancestor instanceof StubBasedPsiElement && (((StubBasedPsiElement)ancestor).getStub() != null)) ||
-        (element instanceof StubBasedPsiElement && ((StubBasedPsiElement)element).getStub() != null)) {
+    if (ancestor instanceof StubBasedPsiElement && ((StubBasedPsiElement)ancestor).getStub() != null ||
+        element instanceof StubBasedPsiElement && ((StubBasedPsiElement)element).getStub() != null) {
       if (ancestor.getContainingFile() != element.getContainingFile()) return false;
     }
 
@@ -345,7 +346,7 @@ public class PsiTreeUtil {
 
   @NotNull
   public static PsiElement[] collectElements(@Nullable PsiElement element, @NotNull PsiElementFilter filter) {
-    PsiElementProcessor.CollectFilteredElements processor = new PsiElementProcessor.CollectFilteredElements(filter);
+    PsiElementProcessor.CollectFilteredElements<PsiElement> processor = new PsiElementProcessor.CollectFilteredElements<PsiElement>(filter);
     processElements(element, processor);
     return processor.toArray();
   }
@@ -551,7 +552,8 @@ public class PsiTreeUtil {
     return false;
   }
 
-  public static PsiElement[] filterAncestors(PsiElement[] elements) {
+  @NotNull
+  public static PsiElement[] filterAncestors(@NotNull PsiElement[] elements) {
     if (LOG.isDebugEnabled()) {
       for (PsiElement element : elements) {
         LOG.debug("element = " + element);
@@ -559,9 +561,7 @@ public class PsiTreeUtil {
     }
 
     ArrayList<PsiElement> filteredElements = new ArrayList<PsiElement>();
-    for (PsiElement element : elements) {
-      filteredElements.add(element);
-    }
+    filteredElements.addAll(Arrays.asList(elements));
 
     int previousSize;
     do {
index 3be743de1a37e737749e6f7eb672bc5b63a447fa..12ac18a596a455f17a8406ebce2d0e8fde0f7f85 100644 (file)
@@ -3,7 +3,7 @@
   <grid id="cae26" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
-      <xy x="13" y="24" width="615" height="128"/>
+      <xy x="13" y="24" width="615" height="165"/>
     </constraints>
     <properties/>
     <border type="none"/>
         </constraints>
         <properties/>
       </component>
-      <xy id="49cf" binding="myComponentPlace" layout-manager="XYLayout" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="2" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children/>
-      </xy>
       <xy id="ceb6c" binding="myOutlinePanel" layout-manager="XYLayout" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
           <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
         </constraints>
       </vspacer>
+      <scrollpane id="9da09">
+        <constraints>
+          <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+        <border type="none"/>
+        <children>
+          <xy id="49cf" binding="myComponentPlace" layout-manager="XYLayout" hgap="-1" vgap="-1">
+            <margin top="0" left="0" bottom="0" right="0"/>
+            <constraints/>
+            <properties/>
+            <border type="none"/>
+            <children/>
+          </xy>
+        </children>
+      </scrollpane>
     </children>
   </grid>
 </form>
index df80a4c384e5780152f324146df5c82a06ea4223..7ea0829403abceffd4e3b1aaf86b8ea76ecc9c63 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.openapi.editor.ex.*;
 import com.intellij.openapi.editor.impl.DocumentImpl;
 import com.intellij.openapi.editor.markup.MarkupModel;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.ProperTextRange;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.UserDataHolderBase;
@@ -40,8 +41,8 @@ import org.jetbrains.annotations.Nullable;
 
 import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Collections;
+import java.util.List;
 
 /**
  * @author Alexey
@@ -254,9 +255,47 @@ public class DocumentWindowImpl extends UserDataHolderBase implements Disposable
     startOffset += perfixLength;
     endOffset -= suffixLength;
     s = s.subSequence(perfixLength, s.length() - suffixLength);
-    
-    deleteString(startOffset, endOffset);
-    insertString(startOffset, s);
+
+    doReplaceString(startOffset, endOffset, s);
+  }
+
+  private void doReplaceString(int startOffset, int endOffset, CharSequence s) {
+    assert intersectWithEditable(new TextRange(startOffset, startOffset)) != null;
+    assert intersectWithEditable(new TextRange(endOffset, endOffset)) != null;
+
+    List<Pair<TextRange,CharSequence>> hostRangesToModify = new ArrayList<Pair<TextRange, CharSequence>>(myShreds.size());
+
+    int offset = startOffset;
+    int curRangeStart = 0;
+    for (int i = 0; i < myShreds.size(); i++) {
+      PsiLanguageInjectionHost.Shred shred = myShreds.get(i);
+      curRangeStart += shred.prefix.length();
+      if (offset < curRangeStart) offset = curRangeStart;
+      RangeMarker hostRange = shred.getHostRangeMarker();
+      if (!hostRange.isValid()) continue;
+      int hostRangeLength = hostRange.getEndOffset() - hostRange.getStartOffset();
+      TextRange range = TextRange.from(curRangeStart, hostRangeLength);
+      if (range.contains(offset) || range.getEndOffset() == offset/* in case of inserting at the end*/) {
+        TextRange rangeToModify = new TextRange(offset, Math.min(range.getEndOffset(), endOffset));
+        TextRange hostRangeToModify = rangeToModify.shiftRight(hostRange.getStartOffset() - curRangeStart);
+        CharSequence toReplace = i == myShreds.size() - 1 ? s : s.subSequence(0, Math.min(hostRangeToModify.getLength(), s.length()));
+        s = s.subSequence(toReplace.length(), s.length());
+        hostRangesToModify.add(Pair.create(hostRangeToModify, toReplace));
+        offset = rangeToModify.getEndOffset();
+      }
+      curRangeStart += hostRangeLength;
+      curRangeStart += shred.suffix.length();
+      if (curRangeStart >= endOffset) break;
+    }
+
+    int delta = 0;
+    for (Pair<TextRange, CharSequence> pair : hostRangesToModify) {
+      TextRange hostRange = pair.getFirst();
+      CharSequence replace = pair.getSecond();
+
+      myDelegate.replaceString(hostRange.getStartOffset() + delta, hostRange.getEndOffset() + delta, replace);
+      delta -= hostRange.getLength() - replace.length();
+    }
   }
 
   public boolean isWritable() {
index 1e1f0d67afb520f45dcf19f736dbf6170f56a026..6a080f33fed47cdcc321cccbcf645dd00cf05995 100644 (file)
@@ -32,7 +32,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class DefaultScopesProvider implements CustomScopesProvider {
-  private static NamedScope myAllScope;
   private NamedScope myProblemsScope;
   private final Project myProject;
 
@@ -55,27 +54,28 @@ public class DefaultScopesProvider implements CustomScopesProvider {
     return list;
   }
 
-  public static NamedScope getAllScope() {
-    if (myAllScope == null) {
-      myAllScope = new NamedScope("All", new PackageSet() {
-        public boolean contains(final PsiFile file, final NamedScopesHolder holder) {
-          return true;
-        }
+  private static class NamedScopeHolder {
+    private static final NamedScope myAllScope = new NamedScope("All", new PackageSet() {
+      public boolean contains(final PsiFile file, final NamedScopesHolder holder) {
+        return true;
+      }
 
-        public PackageSet createCopy() {
-          return this;
-        }
+      public PackageSet createCopy() {
+        return this;
+      }
 
-        public String getText() {
-          return FilePatternPackageSet.SCOPE_FILE + ":*//*";
-        }
+      public String getText() {
+        return FilePatternPackageSet.SCOPE_FILE + ":*//*";
+      }
 
-        public int getNodePriority() {
-          return 0;
-        }
-      });
-    }
-    return myAllScope;
+      public int getNodePriority() {
+        return 0;
+      }
+    });
+  }
+
+  public static NamedScope getAllScope() {
+    return NamedScopeHolder.myAllScope;
   }
 
    public NamedScope getProblemsScope() {
@@ -100,4 +100,4 @@ public class DefaultScopesProvider implements CustomScopesProvider {
     }
     return myProblemsScope;
   }
-}
\ No newline at end of file
+}
index e24fdb3b6ad7fe893179748fc02a8d0a2742f8ab..e5747b88b7e11f1ff831695ad4575ebcb371fa2e 100644 (file)
@@ -158,11 +158,11 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
     return processElementsWithWord(occurenceProcessor, searchScope, identifier, UsageSearchContext.IN_COMMENTS, true);
   }
 
-  public boolean processElementsWithWord(@NotNull TextOccurenceProcessor processor,
+  public boolean processElementsWithWord(@NotNull final TextOccurenceProcessor processor,
                                           @NotNull SearchScope searchScope,
-                                          @NotNull String text,
+                                          @NotNull final String text,
                                           short searchContext,
-                                          boolean caseSensitively) {
+                                          final boolean caseSensitively) {
     if (text.length() == 0) {
       throw new IllegalArgumentException("Cannot search for elements with empty text");
     }
@@ -179,10 +179,11 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
       PsiElement[] scopeElements = scope.getScope();
       final boolean ignoreInjectedPsi = scope.isIgnoreInjectedPsi();
 
-      for (final PsiElement scopeElement : scopeElements) {
-        if (!processElementsWithWordInScopeElement(scopeElement, processor, text, caseSensitively, ignoreInjectedPsi)) return false;
-      }
-      return true;
+      return JobUtil.invokeConcurrentlyUnderMyProgress(Arrays.asList(scopeElements), new Processor<PsiElement>() {
+        public boolean process(PsiElement scopeElement) {
+          return processElementsWithWordInScopeElement(scopeElement, processor, text, caseSensitively, ignoreInjectedPsi);
+        }
+      }, "textsearch");
     }
   }
 
@@ -200,7 +201,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
     }).booleanValue();
   }
 
-  private boolean processElementsWithTextInGlobalScope(final TextOccurenceProcessor processor,
+  private boolean processElementsWithTextInGlobalScope(@NotNull final TextOccurenceProcessor processor,
                                                        final GlobalSearchScope scope,
                                                        final StringSearcher searcher,
                                                        final short searchContext,
@@ -424,10 +425,7 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
     myManager.getCacheManager().processFilesWithWord(processor, word, UsageSearchContext.IN_STRINGS, scope, true);
   }
 
-  public static enum Result {
-    ZERO_OCCURRENCES, FEW_OCCURRENCES, TOO_MANY_OCCURRENCES
-  }
-  public Result isItCheapEnoughToSearch(@Nullable final PsiFile fileToIgnoreOccurencesIn, @NotNull String name, @NotNull GlobalSearchScope scope) {
+  public SearchCostResult isCheapEnoughToSearch(@NotNull String name, @NotNull GlobalSearchScope scope, @Nullable final PsiFile fileToIgnoreOccurencesIn) {
     final int[] count = {0};
     if (!processFilesWithText(scope, UsageSearchContext.ANY, true, name, new Processor<PsiFile>() {
       public boolean process(PsiFile file) {
@@ -438,11 +436,11 @@ public class PsiSearchHelperImpl implements PsiSearchHelper {
         }
       }
     })) {
-      return Result.TOO_MANY_OCCURRENCES;
+      return SearchCostResult.TOO_MANY_OCCURRENCES;
     }
 
     synchronized (count) {
-      return count[0] == 0 ? Result.ZERO_OCCURRENCES : Result.FEW_OCCURRENCES;
+      return count[0] == 0 ? SearchCostResult.ZERO_OCCURRENCES : SearchCostResult.FEW_OCCURRENCES;
     }
   }
 }
index 61dbf0e6387977396170f7316790da12967fbe0f..4de538b569499f8eee0676cda8361bd748352509 100644 (file)
@@ -287,13 +287,12 @@ public class FileBasedIndex implements ApplicationComponent {
     }
   }
 
-  private static FileBasedIndex ourInstance = CachedSingletonsRegistry.markCachedField(FileBasedIndex.class);
-  public static FileBasedIndex getInstance() {
-    if (ourInstance == null) {
-      ourInstance = ApplicationManager.getApplication().getComponent(FileBasedIndex.class);
-    }
+  private static class FileBasedIndexHolder {
+    private static final FileBasedIndex ourInstance = ApplicationManager.getApplication().getComponent(FileBasedIndex.class);
+  }
 
-    return ourInstance;
+  public static FileBasedIndex getInstance() {
+    return FileBasedIndexHolder.ourInstance;
   }
 
   /**
index 9b8400aa8a1097c3e740940a0932b875aeb3d489..873acb6bbcc40acd800591c2b094287c4206b9c4 100644 (file)
@@ -17,7 +17,6 @@ package com.intellij.openapi.fileTypes;
 
 import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.CachedSingletonsRegistry;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -31,18 +30,22 @@ import java.util.List;
  */
 
 public abstract class FileTypeManager{
-  private static FileTypeManager ourInstance = CachedSingletonsRegistry.markCachedField(FileTypeManager.class);
+  private static class FileTypeManagerHolder {
+    private static final FileTypeManager ourInstance = createFileTypeManager();
+  }
+
   /**
    * Returns the singleton instance of the FileTypeManager component.
    *
    * @return the instace of FileTypeManager
    */
   public static FileTypeManager getInstance() {
-    if (ourInstance == null) {
-      Application app = ApplicationManager.getApplication();
-      ourInstance = app != null ? app.getComponent(FileTypeManager.class) : new MockFileTypeManager();
-    }
-    return ourInstance;
+    return FileTypeManagerHolder.ourInstance;
+  }
+
+  private static FileTypeManager createFileTypeManager() {
+    Application app = ApplicationManager.getApplication();
+    return app == null ? new MockFileTypeManager() : app.getComponent(FileTypeManager.class);
   }
 
   public abstract void registerFileType(@NotNull FileType type, @NotNull List<FileNameMatcher> defaultAssociations);
index a1f8687aefda24b6643bfa9ebd8e2f7ccfd28c50..7707e58c53d45380ee932c0b94c2462a9cb54836 100644 (file)
@@ -777,6 +777,10 @@ public abstract class MasterDetailsComponent implements Configurable, Persistent
     public boolean isDisplayInBold() {
       return myDisplayInBold;
     }
+
+    public void setDisplayInBold(boolean displayInBold) {
+      myDisplayInBold = displayInBold;
+    }
   }
 
   @SuppressWarnings({"ConstantConditions"})
index bc3122889a535acb5c0f6fc905f8919e05207b68..9793edf8447dae5c439c7ff6356ca59a8ac07c13 100644 (file)
@@ -30,13 +30,13 @@ import java.io.DataOutputStream;
 import java.util.List;
 
 public abstract class ManagingFS implements FileSystemInterface {
-  private static ManagingFS ourInstance = CachedSingletonsRegistry.markCachedField(ManagingFS.class);
+
+  private static class ManagingFSHolder {
+    private static final ManagingFS ourInstance = ApplicationManager.getApplication().getComponent(ManagingFS.class);
+  }
 
   public static ManagingFS getInstance() {
-    if (ourInstance == null) {
-      ourInstance = ApplicationManager.getApplication().getComponent(ManagingFS.class);
-    }
-    return ourInstance;
+    return ManagingFSHolder.ourInstance;
   }
 
   @Nullable
index cb28a0720c59b323a4361871cf239be7a99d948d..f2642492b77c0b40e180c2ff5977f1c43a38e93f 100644 (file)
 
 package com.intellij.ide.ui.search;
 
-import com.intellij.openapi.application.Application;
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.ConfigurableGroup;
 import com.intellij.openapi.options.MasterDetails;
 import com.intellij.openapi.options.SearchableConfigurable;
-import com.intellij.openapi.options.ConfigurableGroup;
 import com.intellij.openapi.options.ex.GlassPanel;
+import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
+import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.openapi.ui.popup.JBPopupFactory;
@@ -62,11 +62,8 @@ public class SearchUtil {
   }
 
   public static void processProjectConfigurables(Project project, HashMap<SearchableConfigurable, TreeSet<OptionDescription>> options) {
-    processConfigurables(project.getExtensions(Configurable.PROJECT_CONFIGURABLES), options);
-    processConfigurables(project.getComponents(Configurable.class), options);
-    final Application app = ApplicationManager.getApplication();
-    processConfigurables(app.getExtensions(Configurable.APPLICATION_CONFIGURABLES), options);
-    processConfigurables(app.getComponents(Configurable.class), options);
+    processConfigurables(new ProjectConfigurablesGroup(project, false).getConfigurables(), options);
+    processConfigurables(new IdeConfigurablesGroup().getConfigurables(), options);
   }
 
   private static void processConfigurables(final Configurable[] configurables,
index 697ce7a7cc9b1bf304ae14b6fffd735822424d51..85a52d461d70064afe9877d42251a4f179e3a9d7 100644 (file)
@@ -152,7 +152,7 @@ public class VirtualFilePointerImpl extends UserDataHolderBase implements Virtua
     myLastUpdated = fsModCount;
 
     if (myFile == null) {
-      LOG.assertTrue(myUrl != null);
+      LOG.assertTrue(myUrl != null, "Both file & url are null");
       myFile = myVirtualFileManager.findFileByUrl(myUrl);
       if (myFile != null) {
         myUrl = null;
index e45a14fc682fde58a6e3c1a225682a1b92efe939..c0cf915bbdad27e92be2df5f7a6d5f1f47713b02 100644 (file)
@@ -1,4 +1,3 @@
-error.cannot.show.in.external.browser=Cannot show \"{0}\" in external browser
 title.cannot.start.browser=Cannot start browser
 error.malformed.url=Malformed url: {0}
 error.cannot.start.browser=Cannot start browser: {0}
@@ -20,19 +19,15 @@ checkbox.transparent.native.to.ascii.conversion=Transparent native-to-ascii conv
 checkbox.autodetect.utf=Autodetect UTF-encoded files
 group.http.proxy=HTTP Proxy
 group.web.browser=Web Browser
-radio.use.system.default.browser=Use system default browser
-radio.use.specified.browser=Use
 group.general.options=General Options
 editbox.ignore.files.and.folders=Ignore files and folders:
 checkbox.confirm.application.exit=Confirm application exit
-checkbox.use.cyclic.buffer.in.console=Limit run/debug consoles output to:
 label.inactive.timeout.sec= sec.
 search.in.the.background=Search in the background
 checkbox.save.files.automatically=Save files automatically if application is idle for
 checkbox.save.files.on.frame.deactivation=Save files on frame deactivation
 checkbox.synchronize.files.on.frame.activation=Synchronize files on frame activation
 checkbox.reopen.last.project.on.startup=Reopen last project on startup
-label.kb= Kb.
 treenode.loading= loading...
 action.clear.list=_Clear List
 action.descriptor.action=Action: {0}
@@ -59,17 +54,11 @@ button.remove=&Remove
 button.remove.all=Remove &All
 button.move.up=Move &Up
 button.move.down=Move &Down
-column.bookmark=Bookmark
 column.description=Description
-title.project.elements.bookmarks=Project Elements Bookmarks
 bookmark.file.X.line.Y={0}, line {1}
 button.view.source=&View Source
-title.editor.bookmarks=Editor Bookmarks
-bookmark.method.at.line={0}, {1}{2}, line {3}
-action.show.bookmarks=_Show Bookmarks
 action.toggle.bookmark=Toggle _Bookmark
 action.toggle.bookmark.mnemonic=Toggle Bookmark With Mnemonic
-action.set.bookmark=Set _Bookmark
 progress.deleting=Deleting
 select.in.commander=Commander
 errortree.information=Information:
@@ -255,10 +244,7 @@ label.text.project.has.older.format=<html><body>The project ''{0}'' has an older
   Old versions of project files will be saved to: ''{1}''</body></html>
 message.text.unlock.read.only.files=<html><body>The following files are read only. IDEA will unlock them.<br>{0}</body></html>
 error.message.cannot.make.files.writable=Cannot make the following files writable:\n{0}
-label.text.project.was.succesfully.converted.old.version.was.saved.to.0=<html><body>Your project was succesfully converted. \
-  <br>Old versions of project files were saved to: ''{0}''</body></html>
 error.cannot.convert.project=Cannot convert project: {0}
-error.some.file.is.corrupted.message=<html><body>File ''{0}'' is corrupted: <br> {1} </body></html>
 message.files.doesn.t.exists.0.so.the.corresponding.modules.won.t.be.converted.do.you.want.to.continue=<html><body>The following files doesn''t exists: <br>\
   {0}The corresponding modules won''t be converted. Do you want to continue?</body></html>
 
@@ -273,7 +259,6 @@ message.purchase.or.upgrade=To purchase {0}, refer to {1}.<br>To upgrade from a
 message.expiration.date=Expiration date: {0}
 message.educational.license=1-Year Educational License. {0}
 message.open.source.project.license=Open Source Project License. {0}
-message.evaluation.expires=Evaluation expires: {0}
 message.non.commercial.use.only=Non-commercial use only
 message.personal.license=Personal License
 aboutbox.build.number=Build #{0}
@@ -281,7 +266,6 @@ aboutbox.build.date=Built on {0}
 aboutbox.jdk=JDK: {0}
 aboutbox.vm=VM: {0}
 aboutbox.vendor=Vendor: {0}
-message.license.you.will.need.upgrade=Your license key will expire on {0}.<br>You will need an upgrade to run {1}.<br>To learn more about upgrades, visit {2}
 title.warning=Warning
 message.upgrade.from.previous.required={0} requires an upgrade from previous versions.<br>You can purchase a license key from the JetBrains website at<br>{1}
 title.upgrade.needed=Upgrade Needed
@@ -305,7 +289,6 @@ title.unable.to.save.data=Unable to Save Data
 link.click.here.to.license.server.info=More info
 link.purchase.commercial.license=To purchase a commercial license, please visit
 license.panel.current.license.description=The license will expire on {0,date,MMMM dd, yyyy}
-license.panel.autodescovered.license.server.tile=Default license server
 license.panel.buildit.evaluation.expires.in=Remains {0} day(s)
 editbox.license.user.name=User name:
 editbox.license.license.key=License key:
@@ -314,7 +297,6 @@ radio.license.data=Enter license &data
 radio.evaluate=&Evaluate for free for 30 days
 radio.default.license.server=&Default License Server
 action.activate.tool.window=Activate {0} window
-action.change.splitter.orientations=Change Splitter O_rientations
 error.checkforupdates.connection.failed=Connection failed. Please check your network connection and try again.
 title.connection.error=Connection Error
 editbox.export.settings.to=Export settings to:
@@ -336,7 +318,6 @@ action.create.annotation.type=Create @interface
 prompt.enter.annotation.type.name=Enter a new @interface name:
 title.new.annotation.type=New @interface
 title.cannot.create.annotation.type=Cannot Create @interface
-progress.creating.annotation.type=Creating @interface {0}.{1}
 action.create.new.class=Create New Class
 action.create.new.filetype=Create New {0}
 action.description.create.new.file=Create New {0}
@@ -363,10 +344,8 @@ progress.creating.package=Creating package {0}.{1}
 command.create.directory=Create directory
 command.create.package=Create package
 action.create.new.enum=Create New Enum
-prompt.enter.new.enum.name=Enter a new enum name:
 title.new.enum=New Enum
 title.cannot.create.enum=Cannot Create Enum
-progress.creating.enum=Creating enum {0}.{1}
 command.create.enum=Create enum
 action.create.new.file=Create New File
 prompt.enter.new.file.name=Enter a new file name:
@@ -432,7 +411,6 @@ command.find.previous=Find Previous
 command.select.all=Select All
 message.no.targets.available=No targets available in this context
 title.popup.select.target=Select Target
-title.popup.select.subtarget=Select in {0}
 title.popup.recent.files=Recent Files
 action.split.vertically=Split _Vertically
 action.split.horizontally=Split Hori_zontally
@@ -452,8 +430,6 @@ action.toolwindow.hierarchy=Hierarch&y
 action.toolwindow.todo=TODO
 action.toolwindow.inspection=I&nspection
 action.toolwindow.favorites=Favorites
-action.unsplit=Un_split
-action.unsplit.all=U_nsplit All
 macro.classpath.entry=Entry in the classpath the element belongs to
 macro.project.classpath=Project's classpath
 macro.column.number=Column number
@@ -633,7 +609,6 @@ node.todo.found.items={0} (found {1} {1,choice,1#item|2#items})
 node.todo.items={0} ({1} {1, choice, 1#item|2#items})
 title.appearance=Appearance
 group.window.options= Window Options
-checkox.show.buttons.for.disabled.tool.windows=Show buttons for disabled tool windows
 checkbox.show.memory.indicator=Show memory indicator
 checkbox.show.tool.window.bars=Show tool window bars
 checkbox.show.tool.window.numbers=Show tool window numbers
@@ -656,10 +631,6 @@ checkbox.use.antialiased.font.in.editor=Use antialiased font
 # this string must start with "IDEA"
 idea.default.look.and.feel=IDEA (4.5 default)
 error.cannot.set.look.and.feel=Cannot set {0} look and feel
-action.add.customization.schema=Add customization scheme
-customizations.schema.default=default
-action.copy.customization.schema=Copy scheme
-action.remove.customization.schema=Remove customization scheme
 error.adding.action.without.icon.to.toolbar=You are adding an action without icon to the toolbar. The default icon will be added to this action.
 title.unable.to.add.action.without.icon.to.toolbar=Unable to add action without icon to the toolbar
 error.please.specify.new.name.for.schema=Please, specify new name for scheme ''{0}''.
@@ -670,13 +641,10 @@ action.choose.actions.to.add=Choose Actions To Add
 button.set.icon=&Set icon
 label.icon.path=Icon Path:
 button.edit.action.icon=Edit Action &Icon
-editbox.schema.name=Scheme Name:
-editbox.schema.description=Description:
 button.add.separator=Add &Separator
 button.move.up.u=Move &Up
 button.move.down.d=Move &Down
 button.add.action.after=Add a&fter...
-customization.schema.default.description=Default unmodified customization scheme
 title.custom.actions.schemas=Custom Actions Schemes
 title.customizations=Menus and Toolbars
 label.choosebyname.no.matches.found=(no matches found)
@@ -873,21 +841,12 @@ element.of.interface=of interface
 element.of.class=of class
 prompt.do.you.want.to.action_verb.the.method.from_class=Do you want to {0} the base {1,choice,1#method|2#methods}?
 jar.no.java.modules.in.project.error=There are no Java modules found in the project.\nOnly Java modules can be jarred.
-jar.no.java.modules.in.project.title=No Modules To Jar Found
 jar.build.progress=Building jar {0}...
-jar.build.success.message=Jar has been built in {0}
-jar.build.cancelled=Jar creation has been cancelled
 jar.build.error.title=Error Creating Jar
 jar.build.progress.title=Building Jar
-jar.build.processing.file.progress=Processing file {0} ...
-error.message.jar.build.cannot.create.temporary.file.in.0=Cannot create temporary file in ''{0}''
-jar.build.cannot.overwrite.error=Cannot overwrite file ''{0}''. Copy has been saved to ''{1}''.
-jar.build.module.presentable.name=Build Jars for module ''{0}''
 jar.build.path=Jar file &path:
 jar.build.main.class=Main &class:
 jar.build.dialog.title=Build Jars
-jar.build.save.title=Save Jar File
-jar.build.main.class.title=Choose Main Class
 jar.build.class.not.found=Class ''{0}'' not found
 help.not.found.error=Help not found for {0}
 help.not.found.title=Help Not Found
@@ -918,7 +877,6 @@ updates.check.period.on.startup=On every start
 updates.check.period.daily=Daily
 updates.check.period.weekly=Weekly
 updates.check.period.monthly=Monthly
-updates.current.build.unknown=N/A
 updates.last.check.never=Never
 updates.settings.caption.1=<html>$PRODUCT$ can automatically check for new and updated versions of itself, using your internet connection (when active).<html>
 updates.settings.check.now.button=Check  Now
@@ -942,14 +900,11 @@ jar.build.on.make=Build jars on &make
 jar.build.modules.to.jar=Choose Modules to Jar
 jar.build.module.0.jar.settings=Module ''{0}'' Jar Settings
 jar.build.include.in.jar.file=Include in jar file:
-jar.build.button=&Build
 search.textfield.title=&Search:
 select.in.scope=Scope
 scope.view.title=Scope
 select.in.title.project.view=Project View
 several.plugins.depend.on.0.continue.to.remove=Several plugins depend on {0}. Continue to remove?
-project.view.combo.label=View &as:
-
 child.tag.0.should.be.defined=''{0}'' child tag should be defined
 attribute.0.should.be.defined=''{0}'' attribute should be defined
 value.must.not.be.empty=Value must not be empty
@@ -1060,7 +1015,6 @@ plugin.deleted.status.tooltip=Plugin will be deleted on next startup
 plugin.outdated.version.status.tooltip=Plugin has newer version
 plugin.download.status.tooltip=Plugin will be activated on next startup
 plugin.is.already.installed.status.tooltip=Plugin is installed
-update.plugins.shutdown.action=Update and &Shutdown
 update.plugins.update.action=&Update
 fail.open.project.message=Unable to open project from ''{0}''
 disabled.plugins.warning.message=<li>Plugin <b>\"{0}\"</b> won''t be able to load because required {2, choice, 1#plugin|2#plugins} {1} {2, choice, 1#is|2#are} disabled.</li>
index 2ce788085ef2fae7e23455d687156388d6d4cd49..909d679b0513b5ed60cb17c5b119482916aefca0 100644 (file)
@@ -80,7 +80,7 @@ parameter.name.prompt=Pa&rameter name:
 no.class.name.specified=No class name specified
 no.parameter.name.specified=No parameter name specified
 pass.outer.class.instance.as.parameter=Pass &outer class' instance as a parameter
-pull.up.members.to=&Pull up members of {0} to:
+pull.up.members.to=P&ull up members of {0} to:
 members.to.be.pulled.up=Members to be pulled up
 make.abstract=Make abstract
 javadoc.for.abstracts=JavaDoc for abstracts
index c5f438560ed2a281807a8961f44b89646430629a..ed99449c231aaf72e3d571958bba43018ad55ccf 100644 (file)
@@ -34,13 +34,11 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.*;
 
+//TeamCity inherits StringUtil: do not add private constructors!!!
 public class StringUtil {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.text.StringUtil");
   @NonNls private static final String VOWELS = "aeiouy";
 
-  private StringUtil() {
-  }
-
   public static String replace(@NonNls @NotNull String text, @NonNls @NotNull String oldS, @NonNls @Nullable String newS) {
     return replace(text, oldS, newS, false);
   }
index a70d4b8ab392df24c6a693b7ded64e3df9a041c3..84fdb70b15815e87f3d9038438a3d8993ec66445 100644 (file)
@@ -42,10 +42,8 @@ import java.awt.*;
 import java.awt.event.*;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.regex.Pattern;
@@ -1064,5 +1062,28 @@ public class UIUtil {
     return g instanceof PrintGraphics;
   }
 
+  public static int getSelectedButton(ButtonGroup group) {
+    Enumeration<AbstractButton> enumeration = group.getElements();
+    int i = 0;
+    while (enumeration.hasMoreElements()) {
+      AbstractButton button = enumeration.nextElement();
+      if (group.isSelected(button.getModel())) {
+        return i;
+      }
+      i++;
+    }
+    return -1;
+  }
+
+  public static void setSelectedButton(ButtonGroup group, int index) {
+    Enumeration<AbstractButton> enumeration = group.getElements();
+    int i = 0;
+    while (enumeration.hasMoreElements()) {
+      AbstractButton button = enumeration.nextElement();
+      group.setSelected(button.getModel(), index == i);
+      i++;
+    }
+  }
+
 }
 
index 63159e43c35c61282498ca98436b5a0921579977..59dc044c95c547dbb930f85c2e80a08f2d1f8e46 100644 (file)
@@ -63,6 +63,7 @@ public final class VcsConfiguration implements PersistentStateComponent<Element>
   public boolean PERFORM_ROLLBACK_IN_BACKGROUND = false;
   public volatile boolean CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND = false;
   public VcsShowConfirmationOption.Value MOVE_TO_FAILED_COMMIT_CHANGELIST = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+  public VcsShowConfirmationOption.Value REMOVE_EMPTY_INACTIVE_CHANGELISTS = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
   public boolean ENABLE_BACKGROUND_PROCESSES = false;
   public int CHANGED_ON_SERVER_INTERVAL = 60;
 
index 4c43ad78a904b492a09c2bf7e156019ed67de93b..d077e7621ee482488f83e84894b6a5a13e131d89 100644 (file)
@@ -27,7 +27,10 @@ public interface VcsShowConfirmationOption {
       myId = id;
     }
 
-
+    public int getId() {
+      return myId;
+    }
+    
     public String toString() {
       return String.valueOf(myId);
     }
index 3c5398f44f580b40025084068aec37ef133f9557..3d30fcc55261210ec31eb8b47357b5503a79ea1b 100644 (file)
@@ -21,6 +21,9 @@ import java.util.Collection;
 
 /**
  * @author max
+ *
+ * @see com.intellij.openapi.vcs.changes.ChangeListManager#addChangeListListener(ChangeListListener)
+ * @see com.intellij.openapi.vcs.changes.ChangeListManager#removeChangeListListener(ChangeListListener)  
  */
 public interface ChangeListListener extends EventListener {
   void changeListAdded(ChangeList list);
index 6a201f6dda929553c617d49c0daa33bdf74a4179..fdb3459ee10b1dc77b3e392b17471cb9c1af4f41 100644 (file)
@@ -107,7 +107,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
     return (ChangeListManagerImpl) project.getComponent(ChangeListManager.class);
   }
 
-  public ChangeListManagerImpl(final Project project) {
+  public ChangeListManagerImpl(Project project, final VcsConfiguration config) {
     myProject = project;
     myChangesViewManager = ChangesViewManager.getInstance(myProject);
     myFileStatusManager = FileStatusManager.getInstance(myProject);
@@ -120,6 +120,45 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
     myModifier = new Modifier(myWorker, myDelayedNotificator);
 
     myConflictTracker = new ChangelistConflictTracker(project, this, myFileStatusManager, EditorNotifications.getInstance(project));
+
+    myListeners.addListener(new ChangeListAdapter() {
+      @Override
+      public void defaultListChanged(final ChangeList oldDefaultList, ChangeList newDefaultList) {
+        if (!ApplicationManager.getApplication().isUnitTestMode() &&
+          oldDefaultList instanceof LocalChangeList &&
+          oldDefaultList.getChanges().isEmpty()) {
+
+          SwingUtilities.invokeLater(new Runnable() {
+            public void run() {
+              switch (config.REMOVE_EMPTY_INACTIVE_CHANGELISTS) {
+
+                case SHOW_CONFIRMATION:
+                  VcsConfirmationDialog dialog = new VcsConfirmationDialog(myProject, new VcsShowConfirmationOption() {
+                    public Value getValue() {
+                      return config.REMOVE_EMPTY_INACTIVE_CHANGELISTS;
+                    }
+
+                    public void setValue(Value value) {
+                      config.REMOVE_EMPTY_INACTIVE_CHANGELISTS = value;
+                    }
+                  }, "<html>The empty changelist is no longer active.<br>" +
+                     "Do you want to remove it?</html>", "Remember my choice");
+                  dialog.show();
+                  if (!dialog.isOK()) {
+                    return;
+                  }
+                  break;
+                case DO_NOTHING_SILENTLY:
+                  return;
+                case DO_ACTION_SILENTLY:
+                  break;
+              }
+              removeChangeList((LocalChangeList)oldDefaultList);
+            }
+          });
+        }
+      }
+    });
   }
 
   public void projectOpened() {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsConfirmationDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsConfirmationDialog.java
new file mode 100644 (file)
index 0000000..def7696
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2000-2010 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.vcs.changes;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.vcs.VcsShowConfirmationOption;
+import com.intellij.util.ui.OptionsDialog;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+
+/**
+ * @author Dmitry Avdeev
+ */
+public class VcsConfirmationDialog extends OptionsDialog {
+
+  private final VcsShowConfirmationOption myOption;
+  private final String myMessage;
+  private final String myDoNotShowMessage;
+
+  protected VcsConfirmationDialog(Project project, VcsShowConfirmationOption option, String message, String doNotShowMessage) {
+    super(project);
+    myOption = option;
+    myMessage = message;
+    myDoNotShowMessage = doNotShowMessage;
+
+    init();
+  }
+
+  @Override
+  protected boolean isToBeShown() {
+    return myOption.getValue() == VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+  }
+
+  @Override
+  protected void setToBeShown(boolean value, boolean onOk) {
+    myOption.setValue(value ? VcsShowConfirmationOption.Value.SHOW_CONFIRMATION : onOk ? VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY : VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY);
+  }
+
+  @Override
+  protected boolean shouldSaveOptionsOnCancel() {
+    return true;
+  }
+
+  @Override
+  protected JComponent createCenterPanel() {
+    JPanel panel = new JPanel(new BorderLayout());
+    panel.add(new JLabel(myMessage));
+    panel.add(new JLabel(Messages.getQuestionIcon()));
+    return panel;
+  }
+
+  @Override
+  protected String getDoNotShowMessage() {
+    return myDoNotShowMessage;
+  }
+
+  @Override
+  protected Action[] createActions() {
+    return new Action[] {
+      new AbstractAction("Yes") {
+        public void actionPerformed(ActionEvent e) {
+          doOKAction();
+        }
+    }, new AbstractAction("No") {
+        public void actionPerformed(ActionEvent e) {
+          doCancelAction();
+        }
+      }};
+  }
+}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DiffRequestPresentableProxy.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/DiffRequestPresentableProxy.java
new file mode 100644 (file)
index 0000000..74c6886
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2000-2010 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.vcs.changes.actions;
+
+import com.intellij.openapi.actionSystem.AnAction;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+public abstract class DiffRequestPresentableProxy implements DiffRequestPresentable {
+  private DiffRequestPresentable myDelegate;
+  private List<? extends AnAction> myCachedActions;
+  private MyResult myStepResult;
+
+  @Nullable
+  protected abstract DiffRequestPresentable init();
+
+  @Nullable
+  private DiffRequestPresentable initRequest() {
+    if (myDelegate == null) {
+      myDelegate = init();
+    }
+    return myDelegate;
+  }
+
+  public List<? extends AnAction> createActions(ShowDiffAction.DiffExtendUIFactory uiFactory) {
+    if (myCachedActions == null) {
+      myCachedActions = initRequest().createActions(uiFactory);
+    }
+    return myCachedActions;
+  }
+
+  public MyResult step() {
+    final DiffRequestPresentable request = initRequest();
+    if (request == null) {
+      return new MyResult(null, DiffPresentationReturnValue.removeFromList);
+    }
+    myStepResult = request.step();
+    return myStepResult;
+  }
+
+  public boolean haveStuff() {
+    final DiffRequestPresentable request = initRequest();
+    if (request == null) {
+      return false;
+    }
+    return request.haveStuff();
+  }
+}
index 9b68b9efec02298cecb82e8517f1dd9a7db9ed0c..1a840a924823a9fe5acd19217d77e72d39c568d0 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.vcs.changes.patch;
 
+import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.diff.impl.patch.FilePatch;
 import com.intellij.openapi.diff.impl.patch.PatchReader;
@@ -817,8 +818,10 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
   }
 
   private class MyShowDiff extends AnAction {
+    private final MyChangeComparator myMyChangeComparator;
     private MyShowDiff() {
       super("Show Diff", "Show Diff", IconLoader.getIcon("/actions/diff.png"));
+      myMyChangeComparator = new MyChangeComparator();
     }
 
     public void update(AnActionEvent e) {
@@ -828,7 +831,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
     public void actionPerformed(AnActionEvent e) {
       if (myPatches.isEmpty() || (! myContainBasedChanges)) return;
       final List<FilePatchInProgress.PatchChange> changes = getAllChanges();
-      Collections.sort(changes, MyChangeComparator.getInstance());
+      Collections.sort(changes, myMyChangeComparator);
       final List<FilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
 
       int selectedIdx = 0;
@@ -852,14 +855,11 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
     }
   }
 
-  private static class MyChangeComparator implements Comparator<FilePatchInProgress.PatchChange> {
-    private static final MyChangeComparator ourInstance = new MyChangeComparator();
-
-    public static MyChangeComparator getInstance() {
-      return ourInstance;
-    }
-
+  private class MyChangeComparator implements Comparator<FilePatchInProgress.PatchChange> {
     public int compare(FilePatchInProgress.PatchChange o1, FilePatchInProgress.PatchChange o2) {
+      if (PropertiesComponent.getInstance(myProject).isTrueValue("ChangesBrowser.SHOW_FLATTEN")) {
+        return o1.getPatchInProgress().getIoCurrentBase().getName().compareTo(o2.getPatchInProgress().getIoCurrentBase().getName());
+      }
       return o1.getPatchInProgress().getIoCurrentBase().compareTo(o2.getPatchInProgress().getIoCurrentBase());
     }
   }
index a785c66343d6758f8b48c8eb9567815a50e39788..780784f9e2871c5bbf166f48433f8d062c619265 100644 (file)
@@ -32,6 +32,7 @@ import com.intellij.openapi.vcs.changes.CurrentContentRevision;
 import com.intellij.openapi.vcs.changes.SimpleContentRevision;
 import com.intellij.openapi.vcs.changes.actions.ChangeDiffRequestPresentable;
 import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentable;
+import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentableProxy;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.vcsUtil.VcsUtil;
 import org.jetbrains.annotations.NotNull;
@@ -220,19 +221,24 @@ public class FilePatchInProgress implements Strippable {
 
     @Nullable
     public DiffRequestPresentable createDiffRequestPresentable(final Project project) {
-      if (myPatchInProgress.isConflictingChange()) {
-        final ApplyPatchForBaseRevisionTexts texts = ApplyPatchForBaseRevisionTexts
-          .create(project, myPatchInProgress.getCurrentBase(), new FilePathImpl(myPatchInProgress.getCurrentBase()),
-                  myPatchInProgress.getPatch());
-        if ((texts != null) &&
-            (ApplyPatchStatus.SUCCESS.equals(texts.getStatus()) || ApplyPatchStatus.ALREADY_APPLIED.equals(texts.getStatus()))) {
-          return new MergedDiffRequestPresentable(project, texts,
-                  myPatchInProgress.getCurrentBase(), myPatchInProgress.getPatch().getAfterVersionId());
+      return new DiffRequestPresentableProxy() {
+        @Override
+        protected DiffRequestPresentable init() {
+          if (myPatchInProgress.isConflictingChange()) {
+            final ApplyPatchForBaseRevisionTexts texts = ApplyPatchForBaseRevisionTexts
+              .create(project, myPatchInProgress.getCurrentBase(), new FilePathImpl(myPatchInProgress.getCurrentBase()),
+                      myPatchInProgress.getPatch());
+            if ((texts != null) &&
+                (ApplyPatchStatus.SUCCESS.equals(texts.getStatus()) || ApplyPatchStatus.ALREADY_APPLIED.equals(texts.getStatus()))) {
+              return new MergedDiffRequestPresentable(project, texts,
+                      myPatchInProgress.getCurrentBase(), myPatchInProgress.getPatch().getAfterVersionId());
+            }
+            return null;
+          } else {
+            return new ChangeDiffRequestPresentable(project, PatchChange.this);
+          }
         }
-        return null;
-      } else {
-        return new ChangeDiffRequestPresentable(project, this);
-      }
+      };
     }
   }
 
index 8133ecc3c6b2ea77f3ab86010d64a6e2baf72574..850be87689997a2957ffed920e545c4015924786 100644 (file)
@@ -29,6 +29,7 @@ import com.intellij.openapi.vcs.changes.Change;
 import com.intellij.openapi.vcs.changes.ContentRevision;
 import com.intellij.openapi.vcs.changes.actions.ChangeDiffRequestPresentable;
 import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentable;
+import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentableProxy;
 import com.intellij.openapi.vcs.changes.actions.ShowDiffAction;
 import com.intellij.openapi.vcs.changes.patch.ApplyPatchForBaseRevisionTexts;
 import com.intellij.openapi.vcs.changes.patch.MergedDiffRequestPresentable;
@@ -51,7 +52,7 @@ public class DiffShelvedChangesAction extends AnAction implements DumbAware {
   }
 
   public static void showShelvedChangesDiff(final DataContext dc) {
-    Project project = PlatformDataKeys.PROJECT.getData(dc);
+    final Project project = PlatformDataKeys.PROJECT.getData(dc);
     ShelvedChangeList[] changeLists = ShelvedChangesViewManager.SHELVED_CHANGELIST_KEY.getData(dc);
     if (changeLists == null) {
       changeLists = ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY.getData(dc);
@@ -68,7 +69,7 @@ public class DiffShelvedChangesAction extends AnAction implements DumbAware {
 
     int toSelectIdx = 0;
     final ArrayList<DiffRequestPresentable> diffRequestPresentables = new ArrayList<DiffRequestPresentable>();
-    ApplyPatchContext context = new ApplyPatchContext(project.getBaseDir(), 0, false, false);
+    final ApplyPatchContext context = new ApplyPatchContext(project.getBaseDir(), 0, false, false);
     final PatchesPreloader preloader = new PatchesPreloader();
 
     final List<String> missing = new LinkedList<String>();
@@ -76,7 +77,7 @@ public class DiffShelvedChangesAction extends AnAction implements DumbAware {
       final Change change = shelvedChange.getChange(project);
       final String beforePath = shelvedChange.getBeforePath();
       try {
-        VirtualFile f = FilePatch.findPatchTarget(context, beforePath, shelvedChange.getAfterPath(), beforePath == null);
+        final VirtualFile f = FilePatch.findPatchTarget(context, beforePath, shelvedChange.getAfterPath(), beforePath == null);
         if ((f == null) || (! f.exists())) {
           if (beforePath != null) {
             missing.add(beforePath);
@@ -84,22 +85,27 @@ public class DiffShelvedChangesAction extends AnAction implements DumbAware {
           continue;
         }
 
-        if (isConflictingChange(change)) {
-          TextFilePatch patch = preloader.getPatch(shelvedChange);
-          if (patch == null) continue;
-
-          final FilePath pathBeforeRename = context.getPathBeforeRename(f);
-
-          final ApplyPatchForBaseRevisionTexts threeTexts = ApplyPatchForBaseRevisionTexts.create(project, f, pathBeforeRename, patch);
-          if ((threeTexts == null) || (threeTexts.getStatus() == null) || (ApplyPatchStatus.FAILURE.equals(threeTexts.getStatus()))) {
-            continue;
+        diffRequestPresentables.add(new DiffRequestPresentableProxy() {
+          @Override
+          protected DiffRequestPresentable init() {
+            if (isConflictingChange(change)) {
+              TextFilePatch patch = preloader.getPatch(shelvedChange);
+              if (patch == null) return null;
+
+              final FilePath pathBeforeRename = context.getPathBeforeRename(f);
+
+              final ApplyPatchForBaseRevisionTexts threeTexts = ApplyPatchForBaseRevisionTexts.create(project, f, pathBeforeRename, patch);
+              if ((threeTexts == null) || (threeTexts.getStatus() == null) || (ApplyPatchStatus.FAILURE.equals(threeTexts.getStatus()))) {
+                return null;
+              }
+
+              return new MergedDiffRequestPresentable(project, threeTexts, f, "Shelved Version");
+            }
+            else {
+              return new ChangeDiffRequestPresentable(project, change);
+            }
           }
-
-          diffRequestPresentables.add(new MergedDiffRequestPresentable(project, threeTexts, f, "Shelved Version"));
-        }
-        else {
-          diffRequestPresentables.add(new ChangeDiffRequestPresentable(project, change));
-        }
+        });
       }
       catch (IOException e) {
         continue;
@@ -114,7 +120,7 @@ public class DiffShelvedChangesAction extends AnAction implements DumbAware {
       ChangesViewBalloonProblemNotifier.showMe(project, "Show Diff: Cannot find base for: " + StringUtil.join(missing, ",\n"), MessageType.WARNING);
     }
 
-    ShowDiffAction.showDiffImpl(project, diffRequestPresentables, toSelectIdx, ShowDiffAction.DiffExtendUIFactory.NONE, true);
+    ShowDiffAction.showDiffImpl(project, diffRequestPresentables, toSelectIdx, ShowDiffAction.DiffExtendUIFactory.NONE, false);
   }
 
   private static class PatchesPreloader {
index 21e3f625ca9fad25c66d5edd999921cf4b906a27..6167748fc95ac724f82ac24d159819a95fc852c9 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.vcs.configurable.VcsGeneralConfigurationPanel">
-  <grid id="7e224" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+  <grid id="7e224" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
       <xy x="7" y="16" width="868" height="558"/>
@@ -8,24 +8,15 @@
     <properties/>
     <border type="none"/>
     <children>
-      <grid id="ec55" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
-        </constraints>
-        <properties/>
-        <border type="none"/>
-        <children/>
-      </grid>
       <vspacer id="5b902">
         <constraints>
-          <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
         </constraints>
       </vspacer>
       <grid id="e714c" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
         <border type="none"/>
           </grid>
         </children>
       </grid>
-      <grid id="a5aa5" binding="myPromptsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+      <grid id="4ec1c" binding="myAddConfirmationPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
-            <minimum-size width="300" height="-1"/>
-          </grid>
-        </constraints>
-        <properties/>
-        <border type="etched" title-resource-bundle="messages/VcsBundle" title-key="border.display.dialog.when.commands.invoked"/>
-        <children/>
-      </grid>
-      <hspacer id="308c6">
-        <constraints>
-          <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
-        </constraints>
-      </hspacer>
-      <grid id="8145c" binding="myRemoveConfirmationPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
-        <constraints>
-          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
-        <border type="etched" title="Files Deletion"/>
+        <border type="etched" title="When files are created"/>
         <children>
-          <component id="ca721" class="javax.swing.JLabel" binding="myRemoveConfirmationLabel">
+          <component id="61373" class="javax.swing.JRadioButton" binding="myShowDialogOnAddingFile">
             <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <text resource-bundle="messages/VcsBundle" key="label.after.deletion.group"/>
+              <margin top="2" left="2" bottom="2" right="2"/>
+              <text resource-bundle="messages/VcsBundle" key="radio.after.creation.show.options"/>
             </properties>
           </component>
-          <component id="1256b" class="javax.swing.JRadioButton" binding="myShowDialogOnRemovingFile">
+          <component id="3cc74" class="javax.swing.JRadioButton" binding="myPerformActionOnAddingFile">
             <constraints>
               <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <margin top="2" left="2" bottom="2" right="2"/>
-              <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.show.options"/>
+              <text resource-bundle="messages/VcsBundle" key="radio.after.creation.add.silently"/>
             </properties>
           </component>
-          <component id="f0ee1" class="javax.swing.JRadioButton" binding="myPerformActionOnRemovingFile">
+          <component id="7fc5c" class="javax.swing.JRadioButton" binding="myDoNothingOnAddingFile">
             <constraints>
               <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <margin top="2" left="2" bottom="2" right="2"/>
-              <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.remove.silently"/>
+              <text resource-bundle="messages/VcsBundle" key="radio.after.creation.do.not.add"/>
             </properties>
           </component>
-          <component id="daddb" class="javax.swing.JRadioButton" binding="myDoNothingOnRemovingFile">
+        </children>
+      </grid>
+      <grid id="19911" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+        <margin top="0" left="0" bottom="0" right="0"/>
+        <constraints>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+        <border type="etched" title="When empty changelist becomes inactive"/>
+        <children>
+          <component id="7b546" class="javax.swing.JRadioButton">
             <constraints>
-              <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
-                <preferred-size width="97" height="23"/>
-              </grid>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <margin top="2" left="2" bottom="2" right="2"/>
-              <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.do.not.remove"/>
+              <text value="Show options before removing"/>
+            </properties>
+          </component>
+          <component id="59f74" class="javax.swing.JRadioButton">
+            <constraints>
+              <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <text value="Remove silently"/>
+            </properties>
+          </component>
+          <component id="49213" class="javax.swing.JRadioButton">
+            <constraints>
+              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <text value="Do not remove"/>
             </properties>
           </component>
         </children>
       </grid>
-      <grid id="4ec1c" binding="myAddConfirmationPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+      <grid id="8145c" binding="myRemoveConfirmationPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
-        <border type="etched" title="Files Creation"/>
+        <border type="etched" title="When files are deleted"/>
         <children>
-          <component id="5d24" class="javax.swing.JLabel" binding="myAddConfirmationLabel">
+          <component id="1256b" class="javax.swing.JRadioButton" binding="myShowDialogOnRemovingFile">
             <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
-              <text resource-bundle="messages/VcsBundle" key="label.after.creation."/>
+              <margin top="2" left="2" bottom="2" right="2"/>
+              <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.show.options"/>
             </properties>
           </component>
-          <component id="61373" class="javax.swing.JRadioButton" binding="myShowDialogOnAddingFile">
+          <component id="f0ee1" class="javax.swing.JRadioButton" binding="myPerformActionOnRemovingFile">
             <constraints>
               <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <margin top="2" left="2" bottom="2" right="2"/>
-              <text resource-bundle="messages/VcsBundle" key="radio.after.creation.show.options"/>
-            </properties>
-          </component>
-          <component id="3cc74" class="javax.swing.JRadioButton" binding="myPerformActionOnAddingFile">
-            <constraints>
-              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
-            </constraints>
-            <properties>
-              <text resource-bundle="messages/VcsBundle" key="radio.after.creation.add.silently"/>
+              <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.remove.silently"/>
             </properties>
           </component>
-          <component id="7fc5c" class="javax.swing.JRadioButton" binding="myDoNothingOnAddingFile">
+          <component id="daddb" class="javax.swing.JRadioButton" binding="myDoNothingOnRemovingFile">
             <constraints>
-              <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+              <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
+                <preferred-size width="97" height="23"/>
+              </grid>
             </constraints>
             <properties>
-              <text resource-bundle="messages/VcsBundle" key="radio.after.creation.do.not.add"/>
+              <margin top="2" left="2" bottom="2" right="2"/>
+              <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.do.not.remove"/>
             </properties>
           </component>
         </children>
       </grid>
+      <grid id="a5aa5" binding="myPromptsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+        <margin top="0" left="0" bottom="0" right="0"/>
+        <constraints>
+          <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
+            <minimum-size width="300" height="-1"/>
+          </grid>
+        </constraints>
+        <properties/>
+        <border type="etched" title-resource-bundle="messages/VcsBundle" title-key="border.display.dialog.when.commands.invoked"/>
+        <children/>
+      </grid>
+      <hspacer id="308c6">
+        <constraints>
+          <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+        </constraints>
+      </hspacer>
     </children>
   </grid>
   <buttonGroups>
       <member id="f0ee1"/>
       <member id="daddb"/>
     </group>
+    <group name="myEmptyChangelistRemovingGroup" bound="true">
+      <member id="7b546"/>
+      <member id="59f74"/>
+      <member id="49213"/>
+    </group>
   </buttonGroups>
 </form>
index 0ccc62d5fad620bb0399145c52a06b216ad3ba69..fcfa0d99a237d10be9609d9377c7995f3da32392 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.openapi.vcs.configurable;
 
-import com.intellij.openapi.application.ApplicationNamesInfo;
 import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.project.Project;
@@ -60,8 +59,7 @@ public class VcsGeneralConfigurationPanel implements Configurable {
   private JPanel myAddConfirmationPanel;
   private JCheckBox myCbOfferToMoveChanges;
   private JComboBox myFailedCommitChangelistCombo;
-  private JLabel myRemoveConfirmationLabel;
-  private JLabel myAddConfirmationLabel;
+  private ButtonGroup myEmptyChangelistRemovingGroup;
 
   public VcsGeneralConfigurationPanel(final Project project) {
 
@@ -93,8 +91,6 @@ public class VcsGeneralConfigurationPanel implements Configurable {
 
     myPromptsPanel.setSize(myPromptsPanel.getPreferredSize());
 
-    myAddConfirmationLabel.setText(VcsBundle.message("add.confirmation.label.text", ApplicationNamesInfo.getInstance().getProductName()));
-    myRemoveConfirmationLabel.setText(VcsBundle.message("remove.confirmation.label.text", ApplicationNamesInfo.getInstance().getProductName()));
   }
 
   public void apply() throws ConfigurationException {
@@ -103,6 +99,7 @@ public class VcsGeneralConfigurationPanel implements Configurable {
 
     settings.FORCE_NON_EMPTY_COMMENT = myForceNonEmptyComment.isSelected();
     settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT = myCbOfferToMoveChanges.isSelected();
+    settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS = getSelected(myEmptyChangelistRemovingGroup);
     settings.MOVE_TO_FAILED_COMMIT_CHANGELIST = getFailedCommitConfirm();
 
     for (VcsShowOptionsSettingImpl setting : myPromptOptions.keySet()) {
@@ -141,6 +138,15 @@ public class VcsGeneralConfigurationPanel implements Configurable {
     return VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY;
   }
 
+  private static VcsShowConfirmationOption.Value getSelected(ButtonGroup group) {
+    switch (UIUtil.getSelectedButton(group)) {
+      case 0:
+        return VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+      case 1:
+        return VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY;
+    }
+    return VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY;
+  }
 
   private ReadonlyStatusHandlerImpl getReadOnlyStatusHandler() {
     return ((ReadonlyStatusHandlerImpl)ReadonlyStatusHandler.getInstance(myProject));
@@ -155,6 +161,9 @@ public class VcsGeneralConfigurationPanel implements Configurable {
     if (settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT != myCbOfferToMoveChanges.isSelected()){
       return true;
     }
+    if (settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS != getSelected(myEmptyChangelistRemovingGroup)){
+      return true;
+    }
 
     if (!Comparing.equal(getFailedCommitConfirm(), settings.MOVE_TO_FAILED_COMMIT_CHANGELIST)) {
       return true;
@@ -178,6 +187,8 @@ public class VcsGeneralConfigurationPanel implements Configurable {
     VcsConfiguration settings = VcsConfiguration.getInstance(myProject);
     myForceNonEmptyComment.setSelected(settings.FORCE_NON_EMPTY_COMMENT);
     myCbOfferToMoveChanges.setSelected(settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT);
+    int id = settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS.getId();
+    UIUtil.setSelectedButton(myEmptyChangelistRemovingGroup, id == 0 ? 0 : id == 1 ? 2 : 1);
     myShowReadOnlyStatusDialog.setSelected(getReadOnlyStatusHandler().getState().SHOW_DIALOG);
     if (settings.MOVE_TO_FAILED_COMMIT_CHANGELIST == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
       myFailedCommitChangelistCombo.setSelectedIndex(0);
index 7713f9969ef84e0a35e66dd85771c857077d87f6..d63719f8ecbf819de25c97f68af1447e6b805161 100644 (file)
@@ -39,7 +39,7 @@ import com.siyeh.ig.psiutils.ClassUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
 
 public class StaticMethodOnlyUsedInOneClassInspection
         extends BaseInspection {
@@ -105,10 +105,10 @@ public class StaticMethodOnlyUsedInOneClassInspection
     }
 
     public BaseInspectionVisitor buildVisitor() {
-        return new StaticmethodOnlyUsedInOneClassVisitor();
+        return new StaticMethodOnlyUsedInOneClassVisitor();
     }
 
-    private static class StaticmethodOnlyUsedInOneClassVisitor
+    private static class StaticMethodOnlyUsedInOneClassVisitor
             extends BaseInspectionVisitor {
 
         @Override public void visitMethod(PsiMethod method) {
@@ -151,23 +151,16 @@ public class StaticMethodOnlyUsedInOneClassInspection
     }
 
     private static class UsageProcessor implements Processor<PsiReference> {
-
-        private PsiClass usageClass = null;
+        private final AtomicReference<PsiClass> foundClass = new AtomicReference<PsiClass>();
 
         public boolean process(PsiReference reference) {
             ProgressManager.checkCanceled();
             final PsiElement element = reference.getElement();
-            final PsiClass usageClass =
-                    ClassUtils.getContainingClass(element);
-          synchronized (this) {
-            if (this.usageClass != null &&
-                    !this.usageClass.equals(usageClass)) {
-                this.usageClass = null;
-                return false;
-            }
-            this.usageClass = usageClass;
-          }
-          return true;
+            PsiClass usageClass = ClassUtils.getContainingClass(element);
+          if (usageClass == null) return true;
+          if (foundClass.compareAndSet(null, usageClass)) return true;
+          PsiClass aClass = foundClass.get();
+          return usageClass.getManager().areElementsEquivalent(aClass, usageClass);
         }
 
         /**
@@ -183,42 +176,18 @@ public class StaticMethodOnlyUsedInOneClassInspection
             final String name = method.getName();
             final GlobalSearchScope scope =
                     GlobalSearchScope.allScope(method.getProject());
-            final FindUsagesCostProcessor costProcessor =
-                    new FindUsagesCostProcessor();
-            searchHelper.processAllFilesWithWord(name, scope,
-                    costProcessor, true);
-            if (costProcessor.isCostTooHigh()) {
-                return null;
-            }
+            if (searchHelper.isCheapEnoughToSearch(name, scope, null)
+                == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return null;
             progressManager.runProcess(new Runnable() {
                 public void run() {
                     final Query<PsiReference> query =
                             MethodReferencesSearch.search(method);
-                    query.forEach(UsageProcessor.this);
+                    if (!query.forEach(UsageProcessor.this)) {
+                      foundClass.set(null);
+                    }
                 }
             }, null);
-          synchronized (this) {
-            return usageClass;
-          }
-        }
-
-        private static class FindUsagesCostProcessor
-                implements Processor<PsiFile> {
-
-            private final AtomicInteger counter = new AtomicInteger();
-            private volatile boolean costTooHigh = false;
-
-            public boolean process(PsiFile psiFile) {
-              if (counter.incrementAndGet() >= 10) {
-                costTooHigh = true;
-                return false;
-              }
-                return true;
-            }
-
-            public boolean isCostTooHigh() {
-                return costTooHigh;
-            }
+            return foundClass.get();
         }
     }
 }
index 00b0c57e7f0a5a75a1980b387e3f5da4de4fce8c..42d104d3009625fdc20e8b4dadeb3227202f4542 100644 (file)
@@ -26,8 +26,6 @@ import com.siyeh.ig.BaseInspection;
 import com.siyeh.ig.BaseInspectionVisitor;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.Collection;
-
 public class InterfaceWithOnlyOneDirectInheritorInspection
         extends BaseInspection {
 
@@ -71,8 +69,7 @@ public class InterfaceWithOnlyOneDirectInheritorInspection
                   ClassInheritorsSearch.search(aClass, searchScope, false).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
                 }
             }, null);
-            final Collection<PsiClass> collection = processor.getCollection();
-            return collection.size() == 1;
+          return !processor.isOverflow();
         }
     }
 }
index 228fbddfeb8363d629be47caf7b82011a9cef472..960e458a0424404aa0359fd0b73212aeb44a46a2 100644 (file)
@@ -40,13 +40,12 @@ public class GroovyTemplatesFactory implements FileTemplateGroupDescriptorFactor
     }
   }
 
-  private static GroovyTemplatesFactory myInstance = null;
+  private static class GroovyTemplatesFactoryHolder {
+    private static final GroovyTemplatesFactory myInstance = new GroovyTemplatesFactory();
+  }
 
   public static GroovyTemplatesFactory getInstance() {
-    if (myInstance == null) {
-      myInstance = new GroovyTemplatesFactory();
-    }
-    return myInstance;
+    return GroovyTemplatesFactoryHolder.myInstance;
   }
 
   private final ArrayList<String> myCustomTemplates = new ArrayList<String>();
index f3f788d6616a6058bc9676f9661d004315b1bd10..c4b445113d5f5b865c6408a949bac639fd47e913 100644 (file)
@@ -315,7 +315,14 @@ public class GroovyParameterInfoHandler implements ParameterInfoHandler<GroovyPs
       buffer.append("no parameters");
     }
     else if (element instanceof GrVariable) {
-      final PsiType type = ((GrVariable)element).getTypeGroovy();
+      final PsiElement parent = context.getParameterOwner().getParent();
+      final PsiType type;
+      if (parent instanceof GrMethodCallExpression) {
+        type = ((GrMethodCallExpression)parent).getInvokedExpression().getType();
+      }
+      else {
+        type = ((GrVariable)element).getTypeGroovy();
+      }
       if (type instanceof GrClosureType) {
         GrClosureParameter[] parameters = ((GrClosureType)type).getSignature().getParameters();
         if (parameters.length > 0) {
index c6ae0505d6b3a12c1064a3e3069db1220d2f7cd2..c85d8486118f57fdf3034e5e857e5722c33f39c6 100644 (file)
@@ -36,7 +36,7 @@ public class TypesSemilattice implements Semilattice<Map<String, PsiType>> {
 
   public Map<String, PsiType> join(ArrayList<Map<String, PsiType>> ins) {
     if (ins.size() == 0) return new HashMap<String, PsiType>();
-    
+
     Map<String, PsiType> result = new HashMap<String, PsiType>(ins.get(0));
 
     for (int i = 1; i < ins.size(); i++) {
@@ -48,10 +48,9 @@ public class TypesSemilattice implements Semilattice<Map<String, PsiType>> {
         if (result.containsKey(name)) {
           final PsiType t2 = result.get(name);
           if (t1 != null && t2 != null) {
-            if (t1.isAssignableFrom(t2)) result.put(name, t1);
-            else if (t2.isAssignableFrom(t1)) result.put(name, t2);
-            else result.put(name, TypesUtil.getLeastUpperBound(t1, t2, myManager));
-          } else {
+            result.put(name, TypesUtil.getLeastUpperBound(t1, t2, myManager));
+          }
+          else {
             result.put(name, null);
           }
         }
@@ -71,7 +70,8 @@ public class TypesSemilattice implements Semilattice<Map<String, PsiType>> {
       final PsiType t2 = e2.get(name);
       if (t1 == null || t2 == null) {
         if (t1 != null || t2 != null) return false;
-      } else {
+      }
+      else {
         if (!t1.equals(t2)) return false;
       }
     }
index 39d508ae4c76045fdf5cbe88d6f9f9f7365eb357..1a1ceda96e20f8caacf913b6ef6b5f1b5362ab85 100644 (file)
@@ -56,9 +56,10 @@ public class GrClosureSignatureUtil {
 
     if (signature.isVarargs()) {
       if (isApplicable(params, args, params.length - 1, args.length, manager, scope)) return true;
-
       PsiType lastType = params[params.length - 1].getType();
       assert lastType instanceof PsiArrayType;
+      if (TypesUtil.isAssignableByMethodCallConversion(lastType, args[args.length - 1], manager, scope)) return true;
+      
       PsiType varargType = ((PsiArrayType)lastType).getComponentType();
 
       for (int argCount = args.length - 1; argCount >= notOptional; argCount--) {
index e40babd90f568f0708a99d9ef4ce31f28d6f5cee..10ef8c47d9bfd94b5c00fd8eea212d17d7d08905 100644 (file)
@@ -190,26 +190,20 @@ public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrFi
       final PsiClass clazz = getContainingClass();
       name = GroovyPropertyUtils.capitalize(name);
       GrAccessorMethod getter1 = new GrAccessorMethodImpl(this, false, "get" + name);
-      if (hasContradictingMethods(getter1, clazz)) getter1 = null;
-
-      GrAccessorMethod getter2 = null;
-      if (PsiType.BOOLEAN.equals(getDeclaredType())) {
-        getter2 = new GrAccessorMethodImpl(this, false, "is" + name);
-        if (hasContradictingMethods(getter2, clazz)) getter2 = null;
-      }
+      if (!hasContradictingMethods(getter1, clazz)) {
+        GrAccessorMethod getter2 = null;
+        if (PsiType.BOOLEAN.equals(getDeclaredType())) {
+          getter2 = new GrAccessorMethodImpl(this, false, "is" + name);
+          if (hasContradictingMethods(getter2, clazz)) getter2 = null;
+        }
 
-      if (getter1 != null || getter2 != null) {
-        if (getter1 != null && getter2 != null) {
+        if (getter2 != null) {
           myGetters = new GrAccessorMethod[]{getter1, getter2};
         }
-        else if (getter1 != null) {
-          myGetters = new GrAccessorMethod[]{getter1};
-        }
         else {
-          myGetters = new GrAccessorMethod[]{getter2};
+          myGetters = new GrAccessorMethod[]{getter1};
         }
       }
-
     }
 
     myGettersInitialized = true;
index 8f19b418b1f18fc13239a8385217c879697bf10f..36b6584c70ed4ec23f754424f54dd1f6cb553ae1 100644 (file)
@@ -443,13 +443,12 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl implements
         final boolean isLValue = PsiUtil.isLValue(refExpr);
         String[] names;
         names = isLValue ? GroovyPropertyUtils.suggestSettersName(name) : GroovyPropertyUtils.suggestGettersName(name);
-        List<GroovyResolveResult> list = new ArrayList<GroovyResolveResult>();
         for (String getterName : names) {
           AccessorResolverProcessor accessorResolver = new AccessorResolverProcessor(getterName, refExpr, !isLValue);
           resolveImpl(refExpr, accessorResolver);
-          list.addAll(Arrays.asList(accessorResolver.getCandidates()));
+          final GroovyResolveResult[] candidates = accessorResolver.getCandidates();
+          if (candidates.length > 0) return candidates;
         }
-        if (list.size() > 0) return list.toArray(new GroovyResolveResult[list.size()]);
         if (fieldCandidates.length > 0) return fieldCandidates;
 
         EnumSet<ClassHint.ResolveKind> kinds = refExpr.getParent() instanceof GrReferenceExpression
index 15384571999deeaa61d9bb0111769bdf4207c083..64ffa0d45b51d4fd536acc4f3c90f767f0166c65 100644 (file)
@@ -154,7 +154,7 @@ public abstract class GrMethodBaseImpl<T extends NamedStub> extends GroovyBaseEl
   private static final Function<GrMethod, PsiType> ourTypesCalculator = new NullableFunction<GrMethod, PsiType>() {
     public PsiType fun(GrMethod method) {
       PsiType nominal = getNominalType(method);
-      if (nominal != null && nominal.equals(PsiType.VOID)) return nominal;
+      if (PsiType.VOID.equals(nominal)) return nominal;
       PsiType inferred = getInferredType(method);
       if (nominal == null) {
         if (inferred == null) {
index d3e06d35bcec598975a6266cd734f26e697c0c1b..9f1e46289497f93b858e855838782511e19bbfd1 100644 (file)
@@ -40,7 +40,7 @@ public class GrClosureSignatureImpl implements GrClosureSignature {
       myParameters[i] = new GrClosureParameterImpl(parameters[i], substitutor);
     }
     if (length > 0) {
-      myIsVarargs = parameters[length - 1].isVarArgs() || myParameters[length - 1].getType() instanceof PsiArrayType;
+      myIsVarargs = /*parameters[length - 1].isVarArgs() ||*/ myParameters[length - 1].getType() instanceof PsiArrayType;
     }
     else {
       myIsVarargs = false;
index e8ede41cdbda824f499d5c699cb3daaeac02a05d..2cf7df077a28441bde19fe7b7ae4432c8f1e9c9a 100644 (file)
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 
 import java.beans.Introspector;
 
@@ -31,6 +32,9 @@ import java.beans.Introspector;
  * @author ilyas
  */
 public class GroovyPropertyUtils {
+  private static final String IS_PREFIX = "is";
+  private static final String GET_PREFIX = "get";
+
   private GroovyPropertyUtils() {
   }
 
@@ -112,6 +116,11 @@ public class GroovyPropertyUtils {
     if (method == null || method.isConstructor()) return false;
     if (method.getParameterList().getParametersCount() != 0) return false;
     if (!isGetterName(method.getName())) return false;
+    if (method.getName().startsWith(IS_PREFIX) &&
+        !CommonClassNames.JAVA_LANG_BOOLEAN
+          .equals(TypesUtil.boxPrimitiveType(method.getReturnType(), method.getManager(), method.getResolveScope()).getCanonicalText())) {
+      return false;
+    }
     return (propertyName == null || propertyName.equals(getPropertyNameByGetter(method))) && method.getReturnType() != PsiType.VOID;
   }
 
@@ -132,10 +141,13 @@ public class GroovyPropertyUtils {
     }
 
     @NonNls String methodName = getterMethod.getName();
-    if (methodName.startsWith("get") && methodName.length() > 3) {
+    if (methodName.startsWith(GET_PREFIX) && methodName.length() > 3) {
       return decapitalize(methodName.substring(3));
     }
-    else if (methodName.startsWith("is") && methodName.length() > 2 && PsiType.BOOLEAN.equals(getterMethod.getReturnType())) {
+    else if (methodName.startsWith(IS_PREFIX) &&
+             methodName.length() > 2 &&
+             CommonClassNames.JAVA_LANG_BOOLEAN.equals(TypesUtil.boxPrimitiveType(getterMethod.getReturnType(), getterMethod.getManager(),
+                                                                                  getterMethod.getResolveScope()).getCanonicalText())) {
       return decapitalize(methodName.substring(2));
     }
     return methodName;
@@ -163,13 +175,18 @@ public class GroovyPropertyUtils {
   }
 
   public static boolean isGetterName(@NotNull String name) {
-    if (name.startsWith("get") && name.length() > 3 && isUpperCase(name.charAt(3))) return true;
-    if (name.startsWith("is") && name.length() > 2 && isUpperCase(name.charAt(2))) return true;
+    if (name.startsWith(GET_PREFIX) && name.length() > 3 && isUpperCase(name.charAt(3))) return true;
+    if (name.startsWith(IS_PREFIX) && name.length() > 2 && isUpperCase(name.charAt(2))) return true;
     return false;
   }
 
+  /**
+   * Returns getter names in priority order
+   * @param name property name
+   * @return getter names
+   */
   public static String[] suggestGettersName(@NotNull String name) {
-    return new String[]{"get"+capitalize(name), "is"+capitalize(name)};
+    return new String[]{IS_PREFIX + capitalize(name), GET_PREFIX + capitalize(name)};
   }
 
   public static String[] suggestSettersName(@NotNull String name) {
index eb385138a5f98140ad933e64c5a9e4fb12f18e18..f38280c2924c28efb2d50b579e0bbd1ed76978a2 100644 (file)
@@ -205,6 +205,7 @@ public class GroovyHighlightingTest extends LightCodeInsightFixtureTestCase {
   public void testStringAndGStringUpperBound() throws Exception {doTest();}
 
   public void testWithMethod() throws Exception {doTest();}
+  public void testByteArrayArgument() throws Exception {doTest();}
 
   public void testForLoopWithNestedEndlessLoop() throws Exception {doTest(new UnassignedVariableAccessInspection());}
   public void testIfIncrementElseReturn() throws Exception {doTest(new UnusedDefInspection()); }
index a9a472839db601f5e747558c9028b7d118d1c0e3..eabeba791a07da915dde367e0ad5b3e08fa712cb 100644 (file)
@@ -326,4 +326,27 @@ print ba<caret>r
     PsiElement resolved = ref.resolve();
     assertTrue(resolved instanceof GrReferenceExpression);
   }
+
+  public void testBooleanProperty() throws Exception {
+    myFixture.configureByText("Abc.groovy", """class A{
+    boolean getFoo(){return true}
+ boolean isFoo(){return false}
+ }
+ print new A().f<caret>oo""");
+    def ref = findReference()
+    def resolved = ref.resolve();
+    assertNotNull resolved
+    assertEquals resolved.getName(), "isFoo"
+  }
+
+  public void testExplicitBooleanProperty() throws Exception {
+    myFixture.configureByText("Abc.groovy", """class A{
+    boolean foo
+ }
+ print new A().f<caret>oo""");
+    def ref = findReference()
+    def resolved = ref.resolve();
+    assertNotNull resolved
+    assertEquals resolved.getName(), "isFoo"
+  }
 }
\ No newline at end of file
diff --git a/plugins/groovy/testdata/highlighting/ByteArrayArgument.groovy b/plugins/groovy/testdata/highlighting/ByteArrayArgument.groovy
new file mode 100644 (file)
index 0000000..e20f290
--- /dev/null
@@ -0,0 +1,5 @@
+def foo(byte[] b) {}
+def bar(byte[] b) {
+  foo(b)
+  foo<warning descr="'foo' in 'ByteArrayArgument' cannot be applied to '(java.lang.Integer)'">(239)</warning>
+}
\ No newline at end of file
index 57f87ecdd220e98f9e1aff8e8c6b3baa164385aa..ed546a5843d0719c6f599bc6f7e6aa77305c2034 100644 (file)
@@ -353,7 +353,7 @@ public class MavenParentCompletionAndResolutionTest extends MavenDomWithIndicesT
                      "  <relativePath><caret>xxx</relativePath>" +
                      "</parent>");
 
-    IntentionAction i = getIntentionAtCaret("Fix relative path");
+    IntentionAction i = getIntentionAtCaret("Fix Relative Path");
     assertNotNull(i);
 
     myFixture.launchAction(i);
index 63720e08e1ec5bc6311c6e3b1fd8f07431d7b464..c04f20f2333e9a865d5320bd4a9783c0a7ff232e 100644 (file)
@@ -29,8 +29,8 @@ import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiReference;
-import com.intellij.psi.impl.search.PsiSearchHelperImpl;
 import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.PsiSearchHelper;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.util.Processor;
 import com.intellij.util.SmartList;
@@ -68,23 +68,26 @@ public class UnusedPropertyInspection extends PropertySuppressableInspectionBase
           original.setText(PropertiesBundle.message("searching.for.property.key.progress.text", property.getUnescapedKey()));
         }
 
-        PsiSearchHelperImpl.Result cheapEnough = ((PsiSearchHelperImpl)file.getManager().getSearchHelper()).isItCheapEnoughToSearch(file, property.getName(), searchScope);
-        if (cheapEnough == PsiSearchHelperImpl.Result.TOO_MANY_OCCURRENCES) return true;
+        String name = property.getName();
+        if (name == null) return true;
+        PsiSearchHelper.SearchCostResult cheapEnough = file.getManager().getSearchHelper().isCheapEnoughToSearch(name, searchScope, file);
+        if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return true;
 
-        final PsiReference usage = cheapEnough == PsiSearchHelperImpl.Result.ZERO_OCCURRENCES ? null :
+        final PsiReference usage = cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES ? null :
                                    ReferencesSearch.search(property, searchScope, false).findFirst();
-        if (usage == null) {
-          final ASTNode propertyNode = property.getNode();
-          assert propertyNode != null;
+        if (usage != null) {
+          return true;
+        }
+        final ASTNode propertyNode = property.getNode();
+        assert propertyNode != null;
 
-          ASTNode[] nodes = propertyNode.getChildren(null);
-          PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi();
-          String description = PropertiesBundle.message("unused.property.problem.descriptor.name");
-          ProblemDescriptor descriptor = manager.createProblemDescriptor(key, description, RemovePropertyLocalFix.INSTANCE, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
-                                                                         isOnTheFly);
-          synchronized (descriptors) {
-            descriptors.add(descriptor);
-          }
+        ASTNode[] nodes = propertyNode.getChildren(null);
+        PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi();
+        String description = PropertiesBundle.message("unused.property.problem.descriptor.name");
+        ProblemDescriptor descriptor = manager.createProblemDescriptor(key, description, RemovePropertyLocalFix.INSTANCE, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+                                                                       isOnTheFly);
+        synchronized (descriptors) {
+          descriptors.add(descriptor);
         }
 
         return true;
index e5a3dd32cebc7529aff5adf6a7e4aac7b2e8d1f1..3eba3a97499f6fc55fcc6b38c876b122142ccca4 100644 (file)
@@ -30,7 +30,6 @@ import javax.swing.*;
 import java.awt.event.KeyEvent;
 
 public class MergeSourceDetailsAction extends AnAction implements DumbAware {
-  private static Icon myIcon;
 
   @Override
   public void update(AnActionEvent e) {
@@ -39,11 +38,12 @@ public class MergeSourceDetailsAction extends AnAction implements DumbAware {
     e.getPresentation().setEnabled(enabled(e));
   }
 
+  private static class IconHolder {
+    private static final Icon myIcon = IconLoader.getIcon("/icons/mergeSourcesDetails.png");
+  }
+
   private Icon getIcon() {
-    if (myIcon == null) {
-      myIcon = IconLoader.getIcon("/icons/mergeSourcesDetails.png");
-    }
-    return myIcon;
+    return IconHolder.myIcon;
   }
 
   public void registerSelf(final JComponent comp) {