diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index ba22ca404a99..fca3be9c9fbb 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -628,13 +628,12 @@ binding.setVariable("zipSources", { String home, String targetDir -> notifyArtifactBuilt(sources) }) -binding.setVariable("zipSourcesOfModules", { String home, String targetDir, Collection modules -> - String sources = "$targetDir/sources.zip" - projectBuilder.stage("zip sources of ${modules.size()} modules to $sources") +binding.setVariable("zipSourcesOfModules", { String home, String targetFilePath, Collection modules -> + projectBuilder.stage("zip sources of ${modules.size()} modules to $targetFilePath") - ant.mkdir(dir: targetDir) - ant.delete(file: sources) - ant.zip(destfile: sources) { + ant.mkdir(dir: new File(targetFilePath).getParent()) + ant.delete(file: targetFilePath) + ant.zip(destfile: targetFilePath) { modules.each { JpsModule module = findModule(it) module.getSourceRoots(JavaSourceRootType.SOURCE).flatten().collect {it.file}.each { File srcRoot -> @@ -643,7 +642,7 @@ binding.setVariable("zipSourcesOfModules", { String home, String targetDir, Coll } } - notifyArtifactBuilt(sources) + notifyArtifactBuilt(targetFilePath) }) /** diff --git a/images/src/org/intellij/images/thumbnail/actions/EnterAction.java b/images/src/org/intellij/images/thumbnail/actions/EnterAction.java index b608b82f97c7..d0cb098f33a4 100644 --- a/images/src/org/intellij/images/thumbnail/actions/EnterAction.java +++ b/images/src/org/intellij/images/thumbnail/actions/EnterAction.java @@ -57,7 +57,7 @@ public final class EnterAction extends AnAction { if (selection.length > 0) { if (selection.length == 1 && selection[0].isDirectory()) { presentation.setVisible(true); - } else if (selection.length > 0) { + } else { boolean notImages = false; ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance(); for (VirtualFile file : selection) { @@ -65,9 +65,6 @@ public final class EnterAction extends AnAction { } presentation.setEnabled(!notImages); presentation.setVisible(false); - } else { - presentation.setVisible(false); - presentation.setEnabled(false); } } else { presentation.setVisible(false); diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/ViewAsGroup.java b/java/debugger/impl/src/com/intellij/debugger/actions/ViewAsGroup.java index c4217a179f0f..8c884fdef1f2 100644 --- a/java/debugger/impl/src/com/intellij/debugger/actions/ViewAsGroup.java +++ b/java/debugger/impl/src/com/intellij/debugger/actions/ViewAsGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,15 +75,23 @@ public class ViewAsGroup extends ActionGroup implements DumbAware { final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext()); final List values = getSelectedValues(e); + final List selectedNodes = XDebuggerTreeActionBase.getSelectedNodes(e.getDataContext()); LOG.assertTrue(debuggerContext != null && !values.isEmpty()); - debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) { + DebugProcessImpl process = debuggerContext.getDebugProcess(); + if (process == null) { + return; + } + + process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) { public void threadAction() { - for (JavaValue value : values) { - value.getDescriptor().setRenderer(myNodeRenderer); + for (final XValueNodeImpl node : selectedNodes) { + final XValue container = node.getValueContainer(); + if (container instanceof JavaValue) { + ((JavaValue)container).setRenderer(myNodeRenderer, node); + } } - DebuggerAction.refreshViews(e); } } ); @@ -106,6 +114,9 @@ public class ViewAsGroup extends ActionGroup implements DumbAware { boolean allApp = true; for (JavaValue value : values) { + if (value instanceof JavaReferringObjectsValue) { // disable for any referrers at all + return AnAction.EMPTY_ARRAY; + } ValueDescriptorImpl valueDescriptor = value.getDescriptor(); anyValueDescriptor = true; if (!valueDescriptor.isValueValid() || !nodeRenderer.isApplicable(valueDescriptor.getType())) { diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java index 45166acce45d..b325a696ec14 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java @@ -288,7 +288,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV return myValueDescriptor.getValueText(); } - private int currentStart = 0; + private int myCurrentChildrenStart = 0; @Override public void computeChildren(@NotNull final XCompositeNode node) { @@ -326,9 +326,9 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV @Override public void initChildrenArrayRenderer(ArrayRenderer renderer) { - renderer.START_INDEX = currentStart; - renderer.END_INDEX = currentStart + XCompositeNode.MAX_CHILDREN_TO_SHOW - 1; - currentStart += XCompositeNode.MAX_CHILDREN_TO_SHOW; + renderer.START_INDEX = myCurrentChildrenStart; + renderer.END_INDEX = myCurrentChildrenStart + XCompositeNode.MAX_CHILDREN_TO_SHOW - 1; + myCurrentChildrenStart += XCompositeNode.MAX_CHILDREN_TO_SHOW; } @Override @@ -456,14 +456,14 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV public String getEvaluationExpression() { if (evaluationExpression == null) { // TODO: change API to allow to calculate it asynchronously - myEvaluationContext.getManagerThread().invokeAndWait(new DebuggerCommandImpl() { + myEvaluationContext.getManagerThread().invokeAndWait(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) { @Override public Priority getPriority() { return Priority.HIGH; } @Override - protected void action() throws Exception { + public void contextAction() throws Exception { evaluationExpression = ApplicationManager.getApplication().runReadAction(new Computable() { @Override public String compute() { @@ -536,4 +536,17 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV } }; } + + public void setRenderer(NodeRenderer nodeRenderer, final XValueNodeImpl node) { + DebuggerManagerThreadImpl.assertIsManagerThread(); + myValueDescriptor.setRenderer(nodeRenderer); + myCurrentChildrenStart = 0; + node.getTree().getLaterInvocator().offer(new Runnable() { + @Override + public void run() { + node.clearChildren(); + computePresentation(node, XValuePlace.TREE); + } + }); + } } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiElementFinder.java b/java/java-psi-api/src/com/intellij/psi/PsiElementFinder.java index 8ae3ca80e175..85b5cf1b6e42 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiElementFinder.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiElementFinder.java @@ -20,6 +20,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.Processor; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.Predicate; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -99,6 +100,37 @@ public abstract class PsiElementFinder { return PsiClass.EMPTY_ARRAY; } + /** + * Returns a list of children (classes, subpackages and possibly other elements) belonging to the specified package. + * + * @param psiPackage the package to return the list of children for. + * @param scope the scope in which children are searched. + * @return the list of children. + * @since 14.1 + */ + @NotNull + public PsiNamedElement[] getChildren(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { + Set children = new HashSet(); + Collections.addAll(children, getSubPackages(psiPackage, scope)); + Collections.addAll(children, getClasses(psiPackage, scope)); + return children.toArray(new PsiNamedElement[children.size()]); + } + + /** + * Returns the filter to use for filtering the list of children for a given package produced by other PsiElementFinder + * implementations. (For example, the list of children for a Kotlin package includes files directly, rather than classes, + * so the classes located by the standard Java package children finder need to be excluded.) + * + * @param psiPackage the package to return the list of children for. + * @param scope the scope in which children are searched. + * @return the filter to use, or null if no additional filtering is necessary. + * @since 14.1 + */ + @Nullable + public Predicate getPackageChildrenFilter(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { + return null; + } + /** * A method to optimize resolve (to only search classes in a package which might be there) */ diff --git a/java/java-psi-api/src/com/intellij/psi/PsiPackage.java b/java/java-psi-api/src/com/intellij/psi/PsiPackage.java index 65e0af8265ad..cab1728ad650 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiPackage.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiPackage.java @@ -83,6 +83,14 @@ public interface PsiPackage extends PsiCheckedRenameElement, NavigationItem, Psi @NotNull PsiClass[] getClasses(@NotNull GlobalSearchScope scope); + /** + * Returns the list of all elements (classes, subpackages and potentially other elements) belonging to this package + * (non-recursively), restricted by the specified scope. + * + * @since 14.1 + */ + PsiElement[] getChildren(@NotNull GlobalSearchScope scope); + /** * Returns the list of package-level annotations for the package. * diff --git a/java/java-psi-api/src/com/intellij/psi/augment/PsiAugmentProvider.java b/java/java-psi-api/src/com/intellij/psi/augment/PsiAugmentProvider.java index 98df2e44e4c7..3a0824a3f114 100644 --- a/java/java-psi-api/src/com/intellij/psi/augment/PsiAugmentProvider.java +++ b/java/java-psi-api/src/com/intellij/psi/augment/PsiAugmentProvider.java @@ -57,6 +57,8 @@ public abstract class PsiAugmentProvider { * @param typeElement place where inference takes place, * also nested PsiTypeElement-s (e.g. for List PsiTypeElements corresponding to both List and String would be suggested) * @return inferred type or null, if inference is not applicable + * + * @since 14.1 */ @Nullable protected PsiType inferType(PsiTypeElement typeElement) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java index bf75430563ed..028e067666fc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaPsiFacadeImpl.java @@ -16,16 +16,11 @@ package com.intellij.psi.impl; import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.ReadActionProcessor; import com.intellij.openapi.progress.ProgressIndicatorProvider; -import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.FileIndexFacade; -import com.intellij.openapi.roots.PackageIndex; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileFilter; import com.intellij.psi.*; import com.intellij.psi.impl.file.impl.JavaFileManager; @@ -34,15 +29,14 @@ import com.intellij.psi.impl.source.JavaDummyHolder; import com.intellij.psi.impl.source.JavaDummyHolderFactory; import com.intellij.psi.impl.source.resolve.FileContextUtil; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.stubs.StubTreeLoader; import com.intellij.psi.util.PsiModificationTracker; -import com.intellij.psi.util.PsiUtilCore; import com.intellij.reference.SoftReference; import com.intellij.util.ConcurrencyUtil; import com.intellij.util.Processor; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashMap; +import com.intellij.util.containers.Predicate; import com.intellij.util.messages.MessageBus; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; @@ -94,7 +88,7 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) { ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly - if (DumbService.getInstance(getProject()).isDumb()) { + if (shouldUseSlowResolve()) { PsiClass[] classes = findClassesInDumbMode(qualifiedName, scope); if (classes.length != 0) { return classes[0]; @@ -134,7 +128,7 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { @Override @NotNull public PsiClass[] findClasses(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { - if (DumbService.getInstance(getProject()).isDumb()) { + if (shouldUseSlowResolve()) { return findClassesInDumbMode(qualifiedName, scope); } @@ -147,6 +141,11 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { return classes.toArray(new PsiClass[classes.size()]); } + private boolean shouldUseSlowResolve() { + DumbService dumbService = DumbService.getInstance(getProject()); + return dumbService.isDumb() && dumbService.isAlternativeResolveEnabled(); + } + @NotNull private PsiElementFinder[] finders() { PsiElementFinder[] answer = myElementFinders; @@ -161,7 +160,6 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { @NotNull private PsiElementFinder[] calcFinders() { List elementFinders = new ArrayList(); - elementFinders.add(new PsiElementFinderImpl()); ContainerUtil.addAll(elementFinders, myProject.getExtensions(PsiElementFinder.EP_NAME)); return elementFinders.toArray(new PsiElementFinder[elementFinders.size()]); } @@ -245,6 +243,56 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { return result == null ? PsiClass.EMPTY_ARRAY : result.toArray(new PsiClass[result.size()]); } + private static class AndPredicate implements Predicate { + private final List> myComponents = new SmartList>(); + + public AndPredicate(Predicate filter1, Predicate filter2) { + myComponents.add(filter1); + myComponents.add(filter2); + } + + @Override + public boolean apply(@Nullable PsiNamedElement input) { + for (Predicate component : myComponents) { + if (!component.apply(input)) { + return false; + } + } + return true; + } + } + + @NotNull + public PsiElement[] getPackageChildren(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { + Map result = new HashMap(); + Predicate filter = null; + + for (PsiElementFinder finder : filteredFinders()) { + Predicate finderFilter = finder.getPackageChildrenFilter(psiPackage, scope); + if (finderFilter != null) { + if (filter == null) { + filter = finderFilter; + } + else if (filter instanceof AndPredicate) { + ((AndPredicate) filter).myComponents.add(finderFilter); + } + else { + filter = new AndPredicate(filter, finderFilter); + } + } + } + + for (PsiElementFinder finder : filteredFinders()) { + PsiNamedElement[] children = finder.getChildren(psiPackage, scope); + for (PsiNamedElement child : children) { + if (!result.containsKey(child.getName()) && (filter == null || filter.apply(child))) { + result.put(child.getName(), child); + } + } + } + return result.values().toArray(new PsiElement[result.size()]); + } + public boolean processPackageDirectories(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope, @NotNull Processor consumer, @@ -274,146 +322,6 @@ public class JavaPsiFacadeImpl extends JavaPsiFacadeEx { return result.values().toArray(new PsiPackage[result.size()]); } - public PsiClass[] findClassByShortName(String name, PsiPackage psiPackage, GlobalSearchScope scope) { - List result = null; - for (PsiElementFinder finder : filteredFinders()) { - PsiClass[] classes = finder.getClasses(name, psiPackage, scope); - if (classes.length == 0) continue; - if (result == null) result = new ArrayList(); - ContainerUtil.addAll(result, classes); - } - - return result == null ? PsiClass.EMPTY_ARRAY : result.toArray(new PsiClass[result.size()]); - } - - private class PsiElementFinderImpl extends PsiElementFinder implements DumbAware { - @Override - public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { - return myFileManager.findClass(qualifiedName, scope); - } - - @Override - @NotNull - public PsiClass[] findClasses(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { - return myFileManager.findClasses(qualifiedName, scope); - } - - @Override - public PsiPackage findPackage(@NotNull String qualifiedName) { - return myFileManager.findPackage(qualifiedName); - } - - @Override - @NotNull - public PsiPackage[] getSubPackages(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { - final Map packagesMap = new HashMap(); - final String qualifiedName = psiPackage.getQualifiedName(); - for (PsiDirectory dir : psiPackage.getDirectories(scope)) { - PsiDirectory[] subDirs = dir.getSubdirectories(); - for (PsiDirectory subDir : subDirs) { - final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(subDir); - if (aPackage != null) { - final String subQualifiedName = aPackage.getQualifiedName(); - if (subQualifiedName.startsWith(qualifiedName) && !packagesMap.containsKey(subQualifiedName)) { - packagesMap.put(aPackage.getQualifiedName(), aPackage); - } - } - } - } - - packagesMap.remove(qualifiedName); // avoid SOE caused by returning a package as a subpackage of itself - return packagesMap.values().toArray(new PsiPackage[packagesMap.size()]); - } - - @Override - @NotNull - public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull final GlobalSearchScope scope) { - return getClasses(null, psiPackage, scope); - } - - @Override - @NotNull - public PsiClass[] getClasses(@Nullable String shortName, @NotNull PsiPackage psiPackage, @NotNull final GlobalSearchScope scope) { - List list = null; - String packageName = psiPackage.getQualifiedName(); - for (PsiDirectory dir : psiPackage.getDirectories(scope)) { - PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(dir); - if (classes.length == 0) continue; - if (list == null) list = new ArrayList(); - for (PsiClass aClass : classes) { - // class file can be located in wrong place inside file system - String qualifiedName = aClass.getQualifiedName(); - if (qualifiedName != null) qualifiedName = StringUtil.getPackageName(qualifiedName); - if (Comparing.strEqual(qualifiedName, packageName)) { - if (shortName == null || shortName.equals(aClass.getName())) list.add(aClass); - } - } - } - if (list == null) { - return PsiClass.EMPTY_ARRAY; - } - - if (list.size() > 1) { - ContainerUtil.quickSort(list, new Comparator() { - @Override - public int compare(PsiClass o1, PsiClass o2) { - VirtualFile file1 = PsiUtilCore.getVirtualFile(o1); - VirtualFile file2 = PsiUtilCore.getVirtualFile(o2); - return file1 == null ? file2 == null ? 0 : -1 : file2 == null ? 1 : scope.compare(file2, file1); - } - }); - } - - return list.toArray(new PsiClass[list.size()]); - } - - @NotNull - @Override - public Set getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { - Set names = null; - FileIndexFacade facade = FileIndexFacade.getInstance(myProject); - for (PsiDirectory dir : psiPackage.getDirectories(scope)) { - for (PsiFile file : dir.getFiles()) { - if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) { - VirtualFile vFile = file.getVirtualFile(); - if (vFile != null && - !(file instanceof PsiCompiledElement) && - !facade.isInSourceContent(vFile) && - (!scope.isForceSearchingInLibrarySources() || - !StubTreeLoader.getInstance().canHaveStub(vFile))) { - continue; - } - - Set inFile = file instanceof PsiClassOwnerEx ? ((PsiClassOwnerEx)file).getClassNames() : getClassNames(((PsiClassOwner)file).getClasses()); - - if (inFile.isEmpty()) continue; - if (names == null) names = new HashSet(); - names.addAll(inFile); - } - } - - } - return names == null ? Collections.emptySet() : names; - } - - @Override - public boolean processPackageDirectories(@NotNull PsiPackage psiPackage, - @NotNull final GlobalSearchScope scope, - @NotNull final Processor consumer, - boolean includeLibrarySources) { - final PsiManager psiManager = PsiManager.getInstance(getProject()); - return PackageIndex.getInstance(getProject()).getDirsByPackageName(psiPackage.getQualifiedName(), includeLibrarySources) - .forEach(new ReadActionProcessor() { - @Override - public boolean processInReadAction(final VirtualFile dir) { - if (!scope.contains(dir)) return true; - PsiDirectory psiDir = psiManager.findDirectory(dir); - return psiDir == null || consumer.process(psiDir); - } - }); - } - } - @Override public boolean isPartOfPackagePrefix(@NotNull String packageName) { final Collection packagePrefixes = myFileManager.getNonTrivialPackagePrefixes(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFinderImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFinderImpl.java new file mode 100644 index 000000000000..2c482367abd6 --- /dev/null +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiElementFinderImpl.java @@ -0,0 +1,177 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl; + +import com.intellij.openapi.application.ReadActionProcessor; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.FileIndexFacade; +import com.intellij.openapi.roots.PackageIndex; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.*; +import com.intellij.psi.impl.file.impl.JavaFileManager; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.psi.stubs.StubTreeLoader; +import com.intellij.psi.util.PsiUtilCore; +import com.intellij.util.Processor; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.HashMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; + +/** + * Created by kosyakov on 05.12.14. + */ +public class PsiElementFinderImpl extends PsiElementFinder implements DumbAware { + + private final Project myProject; + private final JavaFileManager myFileManager; + + public PsiElementFinderImpl(Project project, JavaFileManager javaFileManager) { + this.myProject = project; + this.myFileManager = javaFileManager; + } + + @Override + public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { + return myFileManager.findClass(qualifiedName, scope); + } + + @Override + @NotNull + public PsiClass[] findClasses(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) { + return myFileManager.findClasses(qualifiedName, scope); + } + + @Override + public PsiPackage findPackage(@NotNull String qualifiedName) { + return myFileManager.findPackage(qualifiedName); + } + + @Override + @NotNull + public PsiPackage[] getSubPackages(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { + final Map packagesMap = new HashMap(); + final String qualifiedName = psiPackage.getQualifiedName(); + for (PsiDirectory dir : psiPackage.getDirectories(scope)) { + PsiDirectory[] subDirs = dir.getSubdirectories(); + for (PsiDirectory subDir : subDirs) { + final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(subDir); + if (aPackage != null) { + final String subQualifiedName = aPackage.getQualifiedName(); + if (subQualifiedName.startsWith(qualifiedName) && !packagesMap.containsKey(subQualifiedName)) { + packagesMap.put(aPackage.getQualifiedName(), aPackage); + } + } + } + } + + packagesMap.remove(qualifiedName); // avoid SOE caused by returning a package as a subpackage of itself + return packagesMap.values().toArray(new PsiPackage[packagesMap.size()]); + } + + @Override + @NotNull + public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull final GlobalSearchScope scope) { + return getClasses(null, psiPackage, scope); + } + + @Override + @NotNull + public PsiClass[] getClasses(@Nullable String shortName, @NotNull PsiPackage psiPackage, @NotNull final GlobalSearchScope scope) { + List list = null; + String packageName = psiPackage.getQualifiedName(); + for (PsiDirectory dir : psiPackage.getDirectories(scope)) { + PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(dir); + if (classes.length == 0) continue; + if (list == null) list = new ArrayList(); + for (PsiClass aClass : classes) { + // class file can be located in wrong place inside file system + String qualifiedName = aClass.getQualifiedName(); + if (qualifiedName != null) qualifiedName = StringUtil.getPackageName(qualifiedName); + if (Comparing.strEqual(qualifiedName, packageName)) { + if (shortName == null || shortName.equals(aClass.getName())) list.add(aClass); + } + } + } + if (list == null) { + return PsiClass.EMPTY_ARRAY; + } + + if (list.size() > 1) { + ContainerUtil.quickSort(list, new Comparator() { + @Override + public int compare(PsiClass o1, PsiClass o2) { + VirtualFile file1 = PsiUtilCore.getVirtualFile(o1); + VirtualFile file2 = PsiUtilCore.getVirtualFile(o2); + return file1 == null ? file2 == null ? 0 : -1 : file2 == null ? 1 : scope.compare(file2, file1); + } + }); + } + + return list.toArray(new PsiClass[list.size()]); + } + + @NotNull + @Override + public Set getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { + Set names = null; + FileIndexFacade facade = FileIndexFacade.getInstance(myProject); + for (PsiDirectory dir : psiPackage.getDirectories(scope)) { + for (PsiFile file : dir.getFiles()) { + if (file instanceof PsiClassOwner && file.getViewProvider().getLanguages().size() == 1) { + VirtualFile vFile = file.getVirtualFile(); + if (vFile != null && + !(file instanceof PsiCompiledElement) && + !facade.isInSourceContent(vFile) && + (!scope.isForceSearchingInLibrarySources() || !StubTreeLoader.getInstance().canHaveStub(vFile))) { + continue; + } + + Set inFile = + file instanceof PsiClassOwnerEx ? ((PsiClassOwnerEx)file).getClassNames() : getClassNames(((PsiClassOwner)file).getClasses()); + + if (inFile.isEmpty()) continue; + if (names == null) names = new HashSet(); + names.addAll(inFile); + } + } + + } + return names == null ? Collections.emptySet() : names; + } + + @Override + public boolean processPackageDirectories(@NotNull PsiPackage psiPackage, + @NotNull final GlobalSearchScope scope, + @NotNull final Processor consumer, + boolean includeLibrarySources) { + final PsiManager psiManager = PsiManager.getInstance(myProject); + return PackageIndex.getInstance(myProject).getDirsByPackageName(psiPackage.getQualifiedName(), includeLibrarySources) + .forEach(new ReadActionProcessor() { + @Override + public boolean processInReadAction(final VirtualFile dir) { + if (!scope.contains(dir)) return true; + PsiDirectory psiDir = psiManager.findDirectory(dir); + return psiDir == null || consumer.process(psiDir); + } + }); + } +} diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java index f0862c14ab79..d1b0a3553a13 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/file/PsiPackageImpl.java @@ -153,6 +153,17 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya return getFacade().getClasses(this, scope); } + @NotNull + @Override + public PsiElement[] getChildren() { + return getChildren(allScope()); + } + + @Override + public PsiElement[] getChildren(@NotNull GlobalSearchScope scope) { + return getFacade().getPackageChildren(this, scope); + } + @Override @Nullable public PsiModifierList getAnnotationList() { diff --git a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java index ed5bf0270f5f..c880924ea232 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java +++ b/jps/jps-builders/src/org/jetbrains/jps/javac/JavacMain.java @@ -193,8 +193,7 @@ public class JavacMain { private static boolean canUseOptimizedFileManager(JavaCompilingTool compilingTool) { // since java 9 internal API's used by the optimizedFileManager have changed - return compilingTool instanceof JavacCompilerTool && - (JAVA_VERSION.contains("1.6") || JAVA_VERSION.contains("1.7") || JAVA_VERSION.contains("1.8")); + return compilingTool instanceof JavacCompilerTool && !SystemInfo.isJavaVersionAtLeast("1.9"); } private static void handleCancelException(DiagnosticOutputConsumer diagnosticConsumer) { diff --git a/platform/core-api/src/com/intellij/openapi/project/DumbService.java b/platform/core-api/src/com/intellij/openapi/project/DumbService.java index a0f5b43ce308..ac3edf55d890 100644 --- a/platform/core-api/src/com/intellij/openapi/project/DumbService.java +++ b/platform/core-api/src/com/intellij/openapi/project/DumbService.java @@ -34,7 +34,7 @@ import java.util.List; /** * A service managing IDEA's 'dumb' mode: when indices are updated in background and the functionality is very much limited. - * Only the explicitly allowed functionality is available. Usually it's allowed by implementing {@link com.intellij.openapi.project.DumbAware} interface. + * Only the explicitly allowed functionality is available. Usually it's allowed by implementing {@link DumbAware} interface. * * If you want to register a toolwindow, which will be enabled during the dumb mode, please use {@link com.intellij.openapi.wm.ToolWindowManager}'s * registration methods which have 'canWorkInDumMode' parameter. @@ -45,7 +45,7 @@ public abstract class DumbService { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.project.DumbService"); /** - * @see com.intellij.openapi.project.Project#getMessageBus() + * @see Project#getMessageBus() */ public static final Topic DUMB_MODE = new Topic("dumb mode", DumbModeListener.class); @@ -210,6 +210,26 @@ public abstract class DumbService { return o instanceof DumbAware; } + /** + * Enables or disables alternative resolve strategies for the current thread.

+ * + * Normally reference resolution uses index, and hence is not available in dumb mode. In some cases, alternative ways + * of performing resolve are available, although much slower. It's impractical to always use these ways because it'll + * lead to overloaded CPU (especially given there's also indexing in progress). But for some explicit user actions + * (e.g. explicit Goto Declaration) turning these slower methods is beneficial.

+ * + * A typical usage would involve try-finally, where the alternative resolution is first enabled, then an action is performed, + * and then alternative resolution is turned off in the finally block. + */ + public abstract void setAlternativeResolveEnabled(boolean enabled); + + /** + * @return whether alternative resolution is enabled for the current thread. + * + * @see #setAlternativeResolveEnabled(boolean) + */ + public abstract boolean isAlternativeResolveEnabled(); + /** * @see #DUMB_MODE */ diff --git a/platform/core-impl/src/com/intellij/mock/MockDumbService.java b/platform/core-impl/src/com/intellij/mock/MockDumbService.java index 1e1179cc5ee8..b1fe7ae2a727 100644 --- a/platform/core-impl/src/com/intellij/mock/MockDumbService.java +++ b/platform/core-impl/src/com/intellij/mock/MockDumbService.java @@ -74,6 +74,15 @@ public class MockDumbService extends DumbService { return myProject; } + @Override + public void setAlternativeResolveEnabled(boolean enabled) { + } + + @Override + public boolean isAlternativeResolveEnabled() { + return false; + } + public void smartInvokeLater(@NotNull final Runnable runnable) { runnable.run(); } diff --git a/platform/icons/src/javaee/JavaeeAppModule.png b/platform/icons/src/javaee/JavaeeAppModule.png old mode 100644 new mode 100755 index 0a67d9245605..ba55aac029e7 Binary files a/platform/icons/src/javaee/JavaeeAppModule.png and b/platform/icons/src/javaee/JavaeeAppModule.png differ diff --git a/platform/icons/src/javaee/JavaeeAppModule@2x.png b/platform/icons/src/javaee/JavaeeAppModule@2x.png new file mode 100755 index 000000000000..92f2fb06bc93 Binary files /dev/null and b/platform/icons/src/javaee/JavaeeAppModule@2x.png differ diff --git a/platform/icons/src/javaee/JavaeeAppModule@2x_dark.png b/platform/icons/src/javaee/JavaeeAppModule@2x_dark.png new file mode 100755 index 000000000000..79201c60b52b Binary files /dev/null and b/platform/icons/src/javaee/JavaeeAppModule@2x_dark.png differ diff --git a/platform/icons/src/javaee/JavaeeAppModule_dark.png b/platform/icons/src/javaee/JavaeeAppModule_dark.png new file mode 100755 index 000000000000..d96b25349409 Binary files /dev/null and b/platform/icons/src/javaee/JavaeeAppModule_dark.png differ diff --git a/platform/icons/src/javaee/WebService.png b/platform/icons/src/javaee/WebService.png old mode 100644 new mode 100755 index 9961daa5c00f..6e6a16253bb9 Binary files a/platform/icons/src/javaee/WebService.png and b/platform/icons/src/javaee/WebService.png differ diff --git a/platform/icons/src/javaee/WebService2.png b/platform/icons/src/javaee/WebService2.png new file mode 100755 index 000000000000..590f3a50d1db Binary files /dev/null and b/platform/icons/src/javaee/WebService2.png differ diff --git a/platform/icons/src/javaee/WebService2@2x.png b/platform/icons/src/javaee/WebService2@2x.png new file mode 100755 index 000000000000..2e7a3bc9bd8e Binary files /dev/null and b/platform/icons/src/javaee/WebService2@2x.png differ diff --git a/platform/icons/src/javaee/WebService2@2x_dark.png b/platform/icons/src/javaee/WebService2@2x_dark.png new file mode 100755 index 000000000000..46daeb438595 Binary files /dev/null and b/platform/icons/src/javaee/WebService2@2x_dark.png differ diff --git a/platform/icons/src/javaee/WebService@2x.png b/platform/icons/src/javaee/WebService@2x.png new file mode 100755 index 000000000000..516a1b7d2927 Binary files /dev/null and b/platform/icons/src/javaee/WebService@2x.png differ diff --git a/platform/icons/src/javaee/WebServiceClient.png b/platform/icons/src/javaee/WebServiceClient.png old mode 100644 new mode 100755 index 63df7e02a0c7..a5a951aec840 Binary files a/platform/icons/src/javaee/WebServiceClient.png and b/platform/icons/src/javaee/WebServiceClient.png differ diff --git a/platform/icons/src/javaee/WebServiceClient2.png b/platform/icons/src/javaee/WebServiceClient2.png new file mode 100755 index 000000000000..114cddaa64d4 Binary files /dev/null and b/platform/icons/src/javaee/WebServiceClient2.png differ diff --git a/platform/icons/src/javaee/WebServiceClient2@2x.png b/platform/icons/src/javaee/WebServiceClient2@2x.png new file mode 100755 index 000000000000..839131bffa1b Binary files /dev/null and b/platform/icons/src/javaee/WebServiceClient2@2x.png differ diff --git a/platform/icons/src/javaee/WebServiceClient2@2x_dark.png b/platform/icons/src/javaee/WebServiceClient2@2x_dark.png new file mode 100755 index 000000000000..c4734599e65a Binary files /dev/null and b/platform/icons/src/javaee/WebServiceClient2@2x_dark.png differ diff --git a/platform/icons/src/javaee/WebServiceClient2_dark.png b/platform/icons/src/javaee/WebServiceClient2_dark.png new file mode 100755 index 000000000000..eaad4178f109 Binary files /dev/null and b/platform/icons/src/javaee/WebServiceClient2_dark.png differ diff --git a/platform/icons/src/javaee/WebServiceClient@2x.png b/platform/icons/src/javaee/WebServiceClient@2x.png new file mode 100755 index 000000000000..30a584a1ea72 Binary files /dev/null and b/platform/icons/src/javaee/WebServiceClient@2x.png differ diff --git a/platform/icons/src/javaee/WebService_dark.png b/platform/icons/src/javaee/WebService_dark.png new file mode 100755 index 000000000000..118fb9b0cd28 Binary files /dev/null and b/platform/icons/src/javaee/WebService_dark.png differ diff --git a/platform/icons/src/javaee/application_xml.png b/platform/icons/src/javaee/application_xml.png old mode 100644 new mode 100755 index 8bd86a3211ce..c7772fed3f1d Binary files a/platform/icons/src/javaee/application_xml.png and b/platform/icons/src/javaee/application_xml.png differ diff --git a/platform/icons/src/javaee/application_xml@2x.png b/platform/icons/src/javaee/application_xml@2x.png new file mode 100755 index 000000000000..d41ea772cffe Binary files /dev/null and b/platform/icons/src/javaee/application_xml@2x.png differ diff --git a/platform/icons/src/javaee/application_xml@2x_dark.png b/platform/icons/src/javaee/application_xml@2x_dark.png new file mode 100755 index 000000000000..f2c6e6159465 Binary files /dev/null and b/platform/icons/src/javaee/application_xml@2x_dark.png differ diff --git a/platform/icons/src/javaee/application_xml_dark.png b/platform/icons/src/javaee/application_xml_dark.png new file mode 100755 index 000000000000..0d20c5b29a1b Binary files /dev/null and b/platform/icons/src/javaee/application_xml_dark.png differ diff --git a/platform/icons/src/javaee/buildOnFrameDeactivation.png b/platform/icons/src/javaee/buildOnFrameDeactivation.png old mode 100644 new mode 100755 diff --git a/platform/icons/src/javaee/dataSourceImport.png b/platform/icons/src/javaee/dataSourceImport.png old mode 100644 new mode 100755 index 417055dba923..b882c72b9024 Binary files a/platform/icons/src/javaee/dataSourceImport.png and b/platform/icons/src/javaee/dataSourceImport.png differ diff --git a/platform/icons/src/javaee/dataSourceImport@2x.png b/platform/icons/src/javaee/dataSourceImport@2x.png new file mode 100755 index 000000000000..1e9697c8aaa5 Binary files /dev/null and b/platform/icons/src/javaee/dataSourceImport@2x.png differ diff --git a/platform/icons/src/javaee/databaseSchemaImportLegend.png b/platform/icons/src/javaee/databaseSchemaImportLegend.png old mode 100644 new mode 100755 diff --git a/platform/icons/src/javaee/dbSchemaImportBig.png b/platform/icons/src/javaee/dbSchemaImportBig.png old mode 100644 new mode 100755 index e7b85f70f6ce..1e9697c8aaa5 Binary files a/platform/icons/src/javaee/dbSchemaImportBig.png and b/platform/icons/src/javaee/dbSchemaImportBig.png differ diff --git a/platform/icons/src/javaee/dbSchemaImportBig@2x.png b/platform/icons/src/javaee/dbSchemaImportBig@2x.png new file mode 100755 index 000000000000..af5281303f1b Binary files /dev/null and b/platform/icons/src/javaee/dbSchemaImportBig@2x.png differ diff --git a/platform/icons/src/javaee/ejb-jar_xml.png b/platform/icons/src/javaee/ejb-jar_xml.png old mode 100644 new mode 100755 index 4fa3a36c91e6..a2761bf29bf8 Binary files a/platform/icons/src/javaee/ejb-jar_xml.png and b/platform/icons/src/javaee/ejb-jar_xml.png differ diff --git a/platform/icons/src/javaee/ejb-jar_xml@2x.png b/platform/icons/src/javaee/ejb-jar_xml@2x.png new file mode 100755 index 000000000000..471aa6c016ef Binary files /dev/null and b/platform/icons/src/javaee/ejb-jar_xml@2x.png differ diff --git a/platform/icons/src/javaee/ejbClass.png b/platform/icons/src/javaee/ejbClass.png old mode 100644 new mode 100755 index 5b3ab2957b50..c296e7b447da Binary files a/platform/icons/src/javaee/ejbClass.png and b/platform/icons/src/javaee/ejbClass.png differ diff --git a/platform/icons/src/javaee/ejbClass@2x.png b/platform/icons/src/javaee/ejbClass@2x.png new file mode 100755 index 000000000000..a7e22c53bf34 Binary files /dev/null and b/platform/icons/src/javaee/ejbClass@2x.png differ diff --git a/platform/icons/src/javaee/ejbModule.png b/platform/icons/src/javaee/ejbModule.png old mode 100644 new mode 100755 index 03ec8e1f06aa..95dc2bec229f Binary files a/platform/icons/src/javaee/ejbModule.png and b/platform/icons/src/javaee/ejbModule.png differ diff --git a/platform/icons/src/javaee/ejbModule@2x.png b/platform/icons/src/javaee/ejbModule@2x.png new file mode 100755 index 000000000000..da59cea45b75 Binary files /dev/null and b/platform/icons/src/javaee/ejbModule@2x.png differ diff --git a/platform/icons/src/javaee/embeddedAttributeOverlay.png b/platform/icons/src/javaee/embeddedAttributeOverlay.png old mode 100644 new mode 100755 index e2d0da45a470..475c2ed43d46 Binary files a/platform/icons/src/javaee/embeddedAttributeOverlay.png and b/platform/icons/src/javaee/embeddedAttributeOverlay.png differ diff --git a/platform/icons/src/javaee/embeddedAttributeOverlay@2x.png b/platform/icons/src/javaee/embeddedAttributeOverlay@2x.png new file mode 100755 index 000000000000..e7fb7f3da11c Binary files /dev/null and b/platform/icons/src/javaee/embeddedAttributeOverlay@2x.png differ diff --git a/platform/icons/src/javaee/embeddedAttributeOverlay@2x_dark.png b/platform/icons/src/javaee/embeddedAttributeOverlay@2x_dark.png new file mode 100755 index 000000000000..942f4cbddb5a Binary files /dev/null and b/platform/icons/src/javaee/embeddedAttributeOverlay@2x_dark.png differ diff --git a/platform/icons/src/javaee/embeddedAttributeOverlay_dark.png b/platform/icons/src/javaee/embeddedAttributeOverlay_dark.png new file mode 100755 index 000000000000..e59fa89a420b Binary files /dev/null and b/platform/icons/src/javaee/embeddedAttributeOverlay_dark.png differ diff --git a/platform/icons/src/javaee/entityBean.png b/platform/icons/src/javaee/entityBean.png old mode 100644 new mode 100755 index 6bd91f219a5e..fa15277c5576 Binary files a/platform/icons/src/javaee/entityBean.png and b/platform/icons/src/javaee/entityBean.png differ diff --git a/platform/icons/src/javaee/entityBean@2x.png b/platform/icons/src/javaee/entityBean@2x.png new file mode 100755 index 000000000000..3b527da79f30 Binary files /dev/null and b/platform/icons/src/javaee/entityBean@2x.png differ diff --git a/platform/icons/src/javaee/entityBean@2x_dark.png b/platform/icons/src/javaee/entityBean@2x_dark.png new file mode 100755 index 000000000000..0a946c280b2b Binary files /dev/null and b/platform/icons/src/javaee/entityBean@2x_dark.png differ diff --git a/platform/icons/src/javaee/entityBeanBig.png b/platform/icons/src/javaee/entityBeanBig.png old mode 100644 new mode 100755 index fa59d640d448..4d81661e0778 Binary files a/platform/icons/src/javaee/entityBeanBig.png and b/platform/icons/src/javaee/entityBeanBig.png differ diff --git a/platform/icons/src/javaee/entityBeanBig@2x.png b/platform/icons/src/javaee/entityBeanBig@2x.png new file mode 100755 index 000000000000..6f5a16f229e6 Binary files /dev/null and b/platform/icons/src/javaee/entityBeanBig@2x.png differ diff --git a/platform/icons/src/javaee/entityBeanBig@2x_dark.png b/platform/icons/src/javaee/entityBeanBig@2x_dark.png new file mode 100755 index 000000000000..67628940b6af Binary files /dev/null and b/platform/icons/src/javaee/entityBeanBig@2x_dark.png differ diff --git a/platform/icons/src/javaee/entityBeanBig_dark.png b/platform/icons/src/javaee/entityBeanBig_dark.png new file mode 100755 index 000000000000..5edeaaa54c37 Binary files /dev/null and b/platform/icons/src/javaee/entityBeanBig_dark.png differ diff --git a/platform/icons/src/javaee/entityBean_dark.png b/platform/icons/src/javaee/entityBean_dark.png new file mode 100755 index 000000000000..e62a2ecf5973 Binary files /dev/null and b/platform/icons/src/javaee/entityBean_dark.png differ diff --git a/platform/icons/src/javaee/home.png b/platform/icons/src/javaee/home.png old mode 100644 new mode 100755 index 5ab0f925cf2d..5d6e70ee7e0a Binary files a/platform/icons/src/javaee/home.png and b/platform/icons/src/javaee/home.png differ diff --git a/platform/icons/src/javaee/home@2x.png b/platform/icons/src/javaee/home@2x.png new file mode 100755 index 000000000000..bbdc01b56665 Binary files /dev/null and b/platform/icons/src/javaee/home@2x.png differ diff --git a/platform/icons/src/javaee/inheritedAttributeOverlay.png b/platform/icons/src/javaee/inheritedAttributeOverlay.png old mode 100644 new mode 100755 index dd829d5d4a0b..8e04255cd9d9 Binary files a/platform/icons/src/javaee/inheritedAttributeOverlay.png and b/platform/icons/src/javaee/inheritedAttributeOverlay.png differ diff --git a/platform/icons/src/javaee/inheritedAttributeOverlay@2x.png b/platform/icons/src/javaee/inheritedAttributeOverlay@2x.png new file mode 100755 index 000000000000..2cb2c2774d08 Binary files /dev/null and b/platform/icons/src/javaee/inheritedAttributeOverlay@2x.png differ diff --git a/platform/icons/src/javaee/inheritedAttributeOverlay@2x_dark.png b/platform/icons/src/javaee/inheritedAttributeOverlay@2x_dark.png new file mode 100755 index 000000000000..f61fe9571bd4 Binary files /dev/null and b/platform/icons/src/javaee/inheritedAttributeOverlay@2x_dark.png differ diff --git a/platform/icons/src/javaee/inheritedAttributeOverlay_dark.png b/platform/icons/src/javaee/inheritedAttributeOverlay_dark.png new file mode 100755 index 000000000000..398e25c21499 Binary files /dev/null and b/platform/icons/src/javaee/inheritedAttributeOverlay_dark.png differ diff --git a/platform/icons/src/javaee/interceptorClass.png b/platform/icons/src/javaee/interceptorClass.png old mode 100644 new mode 100755 index cee608187841..f543e2787238 Binary files a/platform/icons/src/javaee/interceptorClass.png and b/platform/icons/src/javaee/interceptorClass.png differ diff --git a/platform/icons/src/javaee/interceptorClass@2x.png b/platform/icons/src/javaee/interceptorClass@2x.png new file mode 100755 index 000000000000..01837fbc8746 Binary files /dev/null and b/platform/icons/src/javaee/interceptorClass@2x.png differ diff --git a/platform/icons/src/javaee/interceptorMethod.png b/platform/icons/src/javaee/interceptorMethod.png old mode 100644 new mode 100755 index 689653e68f49..146cefb39413 Binary files a/platform/icons/src/javaee/interceptorMethod.png and b/platform/icons/src/javaee/interceptorMethod.png differ diff --git a/platform/icons/src/javaee/interceptorMethod@2x.png b/platform/icons/src/javaee/interceptorMethod@2x.png new file mode 100755 index 000000000000..ca01ef3f5ba1 Binary files /dev/null and b/platform/icons/src/javaee/interceptorMethod@2x.png differ diff --git a/platform/icons/src/javaee/jpaFacet.png b/platform/icons/src/javaee/jpaFacet.png old mode 100644 new mode 100755 index 5bc6a74fc625..b96a2d29aae3 Binary files a/platform/icons/src/javaee/jpaFacet.png and b/platform/icons/src/javaee/jpaFacet.png differ diff --git a/platform/icons/src/javaee/jpaFacet@2x.png b/platform/icons/src/javaee/jpaFacet@2x.png new file mode 100755 index 000000000000..d317d01a1edd Binary files /dev/null and b/platform/icons/src/javaee/jpaFacet@2x.png differ diff --git a/platform/icons/src/javaee/local.png b/platform/icons/src/javaee/local.png old mode 100644 new mode 100755 index ed4ace42f02b..36754143ef8a Binary files a/platform/icons/src/javaee/local.png and b/platform/icons/src/javaee/local.png differ diff --git a/platform/icons/src/javaee/local@2x.png b/platform/icons/src/javaee/local@2x.png new file mode 100755 index 000000000000..477284ed3ef4 Binary files /dev/null and b/platform/icons/src/javaee/local@2x.png differ diff --git a/platform/icons/src/javaee/local@2x_dark.png b/platform/icons/src/javaee/local@2x_dark.png new file mode 100755 index 000000000000..d067e38282be Binary files /dev/null and b/platform/icons/src/javaee/local@2x_dark.png differ diff --git a/platform/icons/src/javaee/localHome.png b/platform/icons/src/javaee/localHome.png old mode 100644 new mode 100755 index 87c66c4721f7..9889c0aa2eb1 Binary files a/platform/icons/src/javaee/localHome.png and b/platform/icons/src/javaee/localHome.png differ diff --git a/platform/icons/src/javaee/localHome@2x.png b/platform/icons/src/javaee/localHome@2x.png new file mode 100755 index 000000000000..fe5706fe056b Binary files /dev/null and b/platform/icons/src/javaee/localHome@2x.png differ diff --git a/platform/icons/src/javaee/localHome@2x_dark.png b/platform/icons/src/javaee/localHome@2x_dark.png new file mode 100755 index 000000000000..44d95fe500c0 Binary files /dev/null and b/platform/icons/src/javaee/localHome@2x_dark.png differ diff --git a/platform/icons/src/javaee/localHome_dark.png b/platform/icons/src/javaee/localHome_dark.png new file mode 100755 index 000000000000..684bfdfdde2b Binary files /dev/null and b/platform/icons/src/javaee/localHome_dark.png differ diff --git a/platform/icons/src/javaee/local_dark.png b/platform/icons/src/javaee/local_dark.png new file mode 100755 index 000000000000..f42e1ed57917 Binary files /dev/null and b/platform/icons/src/javaee/local_dark.png differ diff --git a/platform/icons/src/javaee/messageBean.png b/platform/icons/src/javaee/messageBean.png old mode 100644 new mode 100755 index 37f84fc29e04..a249445a785a Binary files a/platform/icons/src/javaee/messageBean.png and b/platform/icons/src/javaee/messageBean.png differ diff --git a/platform/icons/src/javaee/messageBean@2x.png b/platform/icons/src/javaee/messageBean@2x.png new file mode 100755 index 000000000000..b5e73fec8ba8 Binary files /dev/null and b/platform/icons/src/javaee/messageBean@2x.png differ diff --git a/platform/icons/src/javaee/persistenceAttribute.png b/platform/icons/src/javaee/persistenceAttribute.png old mode 100644 new mode 100755 index d77b78007e6b..293f978d9422 Binary files a/platform/icons/src/javaee/persistenceAttribute.png and b/platform/icons/src/javaee/persistenceAttribute.png differ diff --git a/platform/icons/src/javaee/persistenceAttribute@2x.png b/platform/icons/src/javaee/persistenceAttribute@2x.png new file mode 100755 index 000000000000..58ffb227039b Binary files /dev/null and b/platform/icons/src/javaee/persistenceAttribute@2x.png differ diff --git a/platform/icons/src/javaee/persistenceEmbeddable.png b/platform/icons/src/javaee/persistenceEmbeddable.png old mode 100644 new mode 100755 index e8ada102599b..03f46d92bc53 Binary files a/platform/icons/src/javaee/persistenceEmbeddable.png and b/platform/icons/src/javaee/persistenceEmbeddable.png differ diff --git a/platform/icons/src/javaee/persistenceEmbeddable@2x.png b/platform/icons/src/javaee/persistenceEmbeddable@2x.png new file mode 100755 index 000000000000..0d4858bbc100 Binary files /dev/null and b/platform/icons/src/javaee/persistenceEmbeddable@2x.png differ diff --git a/platform/icons/src/javaee/persistenceEmbeddable@2x_dark.png b/platform/icons/src/javaee/persistenceEmbeddable@2x_dark.png new file mode 100755 index 000000000000..85dd10a3a5d8 Binary files /dev/null and b/platform/icons/src/javaee/persistenceEmbeddable@2x_dark.png differ diff --git a/platform/icons/src/javaee/persistenceEmbeddable_dark.png b/platform/icons/src/javaee/persistenceEmbeddable_dark.png new file mode 100755 index 000000000000..94a876d7aeb8 Binary files /dev/null and b/platform/icons/src/javaee/persistenceEmbeddable_dark.png differ diff --git a/platform/icons/src/javaee/persistenceEntity.png b/platform/icons/src/javaee/persistenceEntity.png old mode 100644 new mode 100755 index cf9264f27386..9f942f970782 Binary files a/platform/icons/src/javaee/persistenceEntity.png and b/platform/icons/src/javaee/persistenceEntity.png differ diff --git a/platform/icons/src/javaee/persistenceEntity@2x.png b/platform/icons/src/javaee/persistenceEntity@2x.png new file mode 100755 index 000000000000..8da8fa567716 Binary files /dev/null and b/platform/icons/src/javaee/persistenceEntity@2x.png differ diff --git a/platform/icons/src/javaee/persistenceEntity@2x_dark.png b/platform/icons/src/javaee/persistenceEntity@2x_dark.png new file mode 100755 index 000000000000..830e28ea190d Binary files /dev/null and b/platform/icons/src/javaee/persistenceEntity@2x_dark.png differ diff --git a/platform/icons/src/javaee/persistenceEntityListener.png b/platform/icons/src/javaee/persistenceEntityListener.png old mode 100644 new mode 100755 index cee608187841..f543e2787238 Binary files a/platform/icons/src/javaee/persistenceEntityListener.png and b/platform/icons/src/javaee/persistenceEntityListener.png differ diff --git a/platform/icons/src/javaee/persistenceEntityListener@2x.png b/platform/icons/src/javaee/persistenceEntityListener@2x.png new file mode 100755 index 000000000000..01837fbc8746 Binary files /dev/null and b/platform/icons/src/javaee/persistenceEntityListener@2x.png differ diff --git a/platform/icons/src/javaee/persistenceEntity_dark.png b/platform/icons/src/javaee/persistenceEntity_dark.png new file mode 100755 index 000000000000..10c8b599bd00 Binary files /dev/null and b/platform/icons/src/javaee/persistenceEntity_dark.png differ diff --git a/platform/icons/src/javaee/persistenceId.png b/platform/icons/src/javaee/persistenceId.png old mode 100644 new mode 100755 index b1e9983904d6..f4d960e10e90 Binary files a/platform/icons/src/javaee/persistenceId.png and b/platform/icons/src/javaee/persistenceId.png differ diff --git a/platform/icons/src/javaee/persistenceId@2x.png b/platform/icons/src/javaee/persistenceId@2x.png new file mode 100755 index 000000000000..a19c74f3f9a9 Binary files /dev/null and b/platform/icons/src/javaee/persistenceId@2x.png differ diff --git a/platform/icons/src/javaee/persistenceId@2x_dark.png b/platform/icons/src/javaee/persistenceId@2x_dark.png new file mode 100755 index 000000000000..21ada9090f86 Binary files /dev/null and b/platform/icons/src/javaee/persistenceId@2x_dark.png differ diff --git a/platform/icons/src/javaee/persistenceIdRelationship.png b/platform/icons/src/javaee/persistenceIdRelationship.png old mode 100644 new mode 100755 index 8889522ffbd6..565399d12b92 Binary files a/platform/icons/src/javaee/persistenceIdRelationship.png and b/platform/icons/src/javaee/persistenceIdRelationship.png differ diff --git a/platform/icons/src/javaee/persistenceIdRelationship@2x.png b/platform/icons/src/javaee/persistenceIdRelationship@2x.png new file mode 100755 index 000000000000..0b37bf06d49c Binary files /dev/null and b/platform/icons/src/javaee/persistenceIdRelationship@2x.png differ diff --git a/platform/icons/src/javaee/persistenceIdRelationship@2x_dark.png b/platform/icons/src/javaee/persistenceIdRelationship@2x_dark.png new file mode 100755 index 000000000000..9dd16bd357dc Binary files /dev/null and b/platform/icons/src/javaee/persistenceIdRelationship@2x_dark.png differ diff --git a/platform/icons/src/javaee/persistenceIdRelationship_dark.png b/platform/icons/src/javaee/persistenceIdRelationship_dark.png new file mode 100755 index 000000000000..2b0a5db7f0d9 Binary files /dev/null and b/platform/icons/src/javaee/persistenceIdRelationship_dark.png differ diff --git a/platform/icons/src/javaee/persistenceId_dark.png b/platform/icons/src/javaee/persistenceId_dark.png new file mode 100755 index 000000000000..1be9a7b226ba Binary files /dev/null and b/platform/icons/src/javaee/persistenceId_dark.png differ diff --git a/platform/icons/src/javaee/persistenceMappedSuperclass.png b/platform/icons/src/javaee/persistenceMappedSuperclass.png old mode 100644 new mode 100755 index f51d41d3c4f2..c65f565a1cf5 Binary files a/platform/icons/src/javaee/persistenceMappedSuperclass.png and b/platform/icons/src/javaee/persistenceMappedSuperclass.png differ diff --git a/platform/icons/src/javaee/persistenceMappedSuperclass@2x.png b/platform/icons/src/javaee/persistenceMappedSuperclass@2x.png new file mode 100755 index 000000000000..84231ab9ac4f Binary files /dev/null and b/platform/icons/src/javaee/persistenceMappedSuperclass@2x.png differ diff --git a/platform/icons/src/javaee/persistenceRelationship.png b/platform/icons/src/javaee/persistenceRelationship.png old mode 100644 new mode 100755 index 39537283d2e3..6ce6b653e2e3 Binary files a/platform/icons/src/javaee/persistenceRelationship.png and b/platform/icons/src/javaee/persistenceRelationship.png differ diff --git a/platform/icons/src/javaee/persistenceRelationship@2x.png b/platform/icons/src/javaee/persistenceRelationship@2x.png new file mode 100755 index 000000000000..71494e4ad1c4 Binary files /dev/null and b/platform/icons/src/javaee/persistenceRelationship@2x.png differ diff --git a/platform/icons/src/javaee/persistenceUnit.png b/platform/icons/src/javaee/persistenceUnit.png old mode 100644 new mode 100755 index 4198f3f2e53d..6e7c376533e5 Binary files a/platform/icons/src/javaee/persistenceUnit.png and b/platform/icons/src/javaee/persistenceUnit.png differ diff --git a/platform/icons/src/javaee/persistenceUnit@2x.png b/platform/icons/src/javaee/persistenceUnit@2x.png new file mode 100755 index 000000000000..b8fea6480ac9 Binary files /dev/null and b/platform/icons/src/javaee/persistenceUnit@2x.png differ diff --git a/platform/icons/src/javaee/remote.png b/platform/icons/src/javaee/remote.png old mode 100644 new mode 100755 index 7261ae432449..20a16df76c93 Binary files a/platform/icons/src/javaee/remote.png and b/platform/icons/src/javaee/remote.png differ diff --git a/platform/icons/src/javaee/remote@2x.png b/platform/icons/src/javaee/remote@2x.png new file mode 100755 index 000000000000..134bce3bc8b3 Binary files /dev/null and b/platform/icons/src/javaee/remote@2x.png differ diff --git a/platform/icons/src/javaee/remote@2x_dark.png b/platform/icons/src/javaee/remote@2x_dark.png new file mode 100755 index 000000000000..e697b4f1acf8 Binary files /dev/null and b/platform/icons/src/javaee/remote@2x_dark.png differ diff --git a/platform/icons/src/javaee/remote_dark.png b/platform/icons/src/javaee/remote_dark.png new file mode 100755 index 000000000000..520a42de5499 Binary files /dev/null and b/platform/icons/src/javaee/remote_dark.png differ diff --git a/platform/icons/src/javaee/sessionBean.png b/platform/icons/src/javaee/sessionBean.png old mode 100644 new mode 100755 index 2b3cc8d12366..61a450918959 Binary files a/platform/icons/src/javaee/sessionBean.png and b/platform/icons/src/javaee/sessionBean.png differ diff --git a/platform/icons/src/javaee/sessionBean@2x.png b/platform/icons/src/javaee/sessionBean@2x.png new file mode 100755 index 000000000000..a5a1fd22750b Binary files /dev/null and b/platform/icons/src/javaee/sessionBean@2x.png differ diff --git a/platform/icons/src/javaee/updateRunningApplication.png b/platform/icons/src/javaee/updateRunningApplication.png old mode 100644 new mode 100755 index b7f806f47818..92651293a5d5 Binary files a/platform/icons/src/javaee/updateRunningApplication.png and b/platform/icons/src/javaee/updateRunningApplication.png differ diff --git a/platform/icons/src/javaee/updateRunningApplication@2x.png b/platform/icons/src/javaee/updateRunningApplication@2x.png old mode 100644 new mode 100755 index 6c5e3f732f04..5acea70c114f Binary files a/platform/icons/src/javaee/updateRunningApplication@2x.png and b/platform/icons/src/javaee/updateRunningApplication@2x.png differ diff --git a/platform/icons/src/javaee/webModule.png b/platform/icons/src/javaee/webModule.png old mode 100644 new mode 100755 index 7e93bfff0f5e..0263085a2ab4 Binary files a/platform/icons/src/javaee/webModule.png and b/platform/icons/src/javaee/webModule.png differ diff --git a/platform/icons/src/javaee/webModule@2x.png b/platform/icons/src/javaee/webModule@2x.png new file mode 100755 index 000000000000..14a4980ebc26 Binary files /dev/null and b/platform/icons/src/javaee/webModule@2x.png differ diff --git a/platform/icons/src/javaee/webModuleGroup.png b/platform/icons/src/javaee/webModuleGroup.png old mode 100644 new mode 100755 index 6e81e1ec6dc3..61fa40474877 Binary files a/platform/icons/src/javaee/webModuleGroup.png and b/platform/icons/src/javaee/webModuleGroup.png differ diff --git a/platform/icons/src/javaee/webModuleGroup@2x.png b/platform/icons/src/javaee/webModuleGroup@2x.png new file mode 100755 index 000000000000..b204e4ebf10f Binary files /dev/null and b/platform/icons/src/javaee/webModuleGroup@2x.png differ diff --git a/platform/icons/src/javaee/web_xml.png b/platform/icons/src/javaee/web_xml.png old mode 100644 new mode 100755 index fc32397ca6fc..b750aaf45da9 Binary files a/platform/icons/src/javaee/web_xml.png and b/platform/icons/src/javaee/web_xml.png differ diff --git a/platform/icons/src/javaee/web_xml@2x.png b/platform/icons/src/javaee/web_xml@2x.png old mode 100644 new mode 100755 index 1b9d1582e236..2b2bf2d22daf Binary files a/platform/icons/src/javaee/web_xml@2x.png and b/platform/icons/src/javaee/web_xml@2x.png differ diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java index 1c3d265e4c86..cb2c3225e83f 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java +++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java @@ -23,6 +23,7 @@ import com.intellij.execution.process.ProcessNotCreatedException; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.ide.DataManager; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.notification.Notification; import com.intellij.notification.NotificationGroup; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; @@ -34,7 +35,6 @@ import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.ui.content.Content; -import com.intellij.util.ObjectUtils; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -124,7 +124,12 @@ public class ExecutionUtil { else { Messages.showErrorDialog(project, UIUtil.toHtml(fullMessage), ""); } - NotificationListener notificationListener = ObjectUtils.tryCast(finalListener, NotificationListener.class); + NotificationListener notificationListener = finalListener == null ? null : new NotificationListener() { + @Override + public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) { + finalListener.hyperlinkUpdate(event); + } + }; ourNotificationGroup.createNotification(title, finalDescription, NotificationType.ERROR, notificationListener).notify(project); } }); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/AbstractLayoutCodeProcessor.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/AbstractLayoutCodeProcessor.java index bddf88f7d7e6..5fd44fe874ac 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/AbstractLayoutCodeProcessor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/AbstractLayoutCodeProcessor.java @@ -68,7 +68,7 @@ public abstract class AbstractLayoutCodeProcessor { private final String myProgressText; private final String myCommandName; private final Runnable myPostRunnable; - private final boolean myProcessChangedTextOnly; + private boolean myProcessChangedTextOnly; protected AbstractLayoutCodeProcessor myPreviousCodeProcessor; private List myFilters = ContainerUtil.newArrayList(); @@ -179,6 +179,9 @@ public abstract class AbstractLayoutCodeProcessor { myFilters.add(filter); } + protected void setProcessChangedTextOnly(boolean value) { + myProcessChangedTextOnly = value; + } /** * Ensures that given file is ready to reformatting and prepares it if necessary. * diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java index 91dca0b669b5..b34fcb858108 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/RearrangeCodeProcessor.java @@ -40,13 +40,10 @@ public class RearrangeCodeProcessor extends AbstractLayoutCodeProcessor { public static final String COMMAND_NAME = "Rearrange code"; public static final String PROGRESS_TEXT = "Rearranging code..."; - @Nullable private Condition myAcceptCondition; @Nullable private SelectionModel mySelectionModel; - public RearrangeCodeProcessor(@NotNull AbstractLayoutCodeProcessor previousProcessor, - @Nullable Condition acceptCondition) { + public RearrangeCodeProcessor(@NotNull AbstractLayoutCodeProcessor previousProcessor) { super(previousProcessor, COMMAND_NAME, PROGRESS_TEXT); - myAcceptCondition = acceptCondition; } public RearrangeCodeProcessor(@NotNull Project project, @@ -63,19 +60,15 @@ public class RearrangeCodeProcessor extends AbstractLayoutCodeProcessor { super(project, files, PROGRESS_TEXT, commandName, postRunnable, false); } - public boolean shouldRearrangeFile(@NotNull PsiFile file) { - return myAcceptCondition == null || myAcceptCondition.value(file); - } - @NotNull @Override - protected FutureTask prepareTask(@NotNull final PsiFile file, boolean processChangedTextOnly) { + protected FutureTask prepareTask(@NotNull final PsiFile file, final boolean processChangedTextOnly) { return new FutureTask(new Callable() { @Override public Boolean call() throws Exception { - if (!shouldRearrangeFile(file)) return true; + Collection ranges = processChangedTextOnly ? FormatChangedTextUtil.getChangedTextRanges(myProject, file) + : getRangesToFormat(file); - Collection ranges = getRangesToFormat(file); RearrangeCommand rearranger = new RearrangeCommand(myProject, file, COMMAND_NAME, ranges); if (rearranger.couldRearrange()) { rearranger.run(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java index 9ec010fcf543..bcbd0fd6738d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeAction.java @@ -103,7 +103,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { processor = new OptimizeImportsProcessor(processor); } if (selectedFlags.isRearrangeEntries()) { - processor = new RearrangeCodeProcessor(processor, null); + processor = new RearrangeCodeProcessor(processor); } processor.run(); @@ -183,16 +183,20 @@ public class ReformatCodeAction extends AnAction implements DumbAware { range = null; } + AbstractLayoutCodeProcessor processor; if (optimizeImports && range == null) { - new OptimizeImportsProcessor(new ReformatCodeProcessor(project, file, null, processChangedTextOnly)).run(); + processor = new OptimizeImportsProcessor(project, file); + processor = new ReformatCodeProcessor(processor, processChangedTextOnly); } else { - new ReformatCodeProcessor(project, file, range, !processSelectedText && processChangedTextOnly).run(); + processor = new ReformatCodeProcessor(project, file, range, !processSelectedText && processChangedTextOnly); } if (rearrangeEntries && editor != null) { - new RearrangeCodeProcessor(project, file, editor.getSelectionModel()).run(); + processor = new RearrangeCodeProcessor(processor); } + + processor.run(); } private static boolean isChangeNotTrackedForFile(@NotNull Project project, @NotNull PsiFile file) { @@ -245,7 +249,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { processor = new OptimizeImportsProcessor(processor); } if (options.isRearrangeEntries()) { - processor = new RearrangeCodeProcessor(processor, null); + processor = new RearrangeCodeProcessor(processor); } processor.run(); @@ -272,7 +276,7 @@ public class ReformatCodeAction extends AnAction implements DumbAware { } if (selectedFlags.isRearrangeEntries()) { - processor = new RearrangeCodeProcessor(processor, null); + processor = new RearrangeCodeProcessor(processor); } processor.run(); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeProcessor.java b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeProcessor.java index 270f2f92f3cf..4ebe9274c1ca 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeProcessor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/actions/ReformatCodeProcessor.java @@ -53,6 +53,11 @@ public class ReformatCodeProcessor extends AbstractLayoutCodeProcessor { super(project, COMMAND_NAME, PROGRESS_TEXT, processChangedTextOnly); } + public ReformatCodeProcessor(AbstractLayoutCodeProcessor processor, boolean processChangedTextOnly) { + super(processor, COMMAND_NAME, PROGRESS_TEXT); + setProcessChangedTextOnly(processChangedTextOnly); + } + public ReformatCodeProcessor(Project project, Module module, boolean processChangedTextOnly) { super(project, module, COMMAND_NAME, PROGRESS_TEXT, processChangedTextOnly); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java index a64917f88e4e..d923262be097 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/AbstractExternalFilter.java @@ -37,7 +37,6 @@ import org.jetbrains.annotations.Nullable; import java.io.*; import java.net.URL; -import java.net.URLConnection; import java.util.Locale; import java.util.concurrent.Future; import java.util.jar.JarFile; @@ -243,34 +242,27 @@ public abstract class AbstractExternalFilter { }); } + @Nullable private static String guessEncoding(URL url) { - String result = null; - BufferedReader reader = null; - try { - URLConnection connection = url.openConnection(); - result = connection.getContentEncoding(); - if (result != null) return result; - //noinspection IOResourceOpenedButNotSafelyClosed - reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - for (String htmlLine = reader.readLine(); htmlLine != null; htmlLine = reader.readLine()) { - result = parseContentEncoding(htmlLine); - if (result != null) { - break; - } - } - } - catch (IOException ignored) { - } - finally { - if (reader != null) { + return HttpRequests.request(url.toExternalForm()).connect(new HttpRequests.RequestProcessor() { + @Override + public String process(@NotNull HttpRequests.Request request) throws IOException { + String result = request.getConnection().getContentEncoding(); + BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream())); try { + for (String htmlLine = reader.readLine(); htmlLine != null; htmlLine = reader.readLine()) { + result = parseContentEncoding(htmlLine); + if (result != null) { + break; + } + } + } + finally { reader.close(); } - catch (IOException ignored) { - } + return result; } - } - return result; + }, null, null); } @Nullable @@ -475,11 +467,9 @@ public abstract class AbstractExternalFilter { if (!htmlLine.contains("charset")) { return null; } - final Matcher matcher = CHARSET_META_PATTERN.matcher(htmlLine); - if (matcher.find()) { - return matcher.group(1); - } - return null; + + Matcher matcher = CHARSET_META_PATTERN.matcher(htmlLine); + return matcher.find() ? matcher.group(1) : null; } private static void appendLine(StringBuilder buffer, final String read) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java index d34cbf4cfa09..a633b302c969 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java @@ -76,6 +76,7 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiDocumentManager.getInstance(project).commitAllDocuments(); + DumbService.getInstance(project).setAlternativeResolveEnabled(true); try { int offset = editor.getCaretModel().getOffset(); PsiElement[] elements = findAllTargetElements(project, editor, offset); @@ -105,6 +106,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code catch (IndexNotReadyException e) { DumbService.getInstance(project).showDumbModeNotification("Navigation is not available here during index update"); } + finally { + DumbService.getInstance(project).setAlternativeResolveEnabled(false); + } } public static PsiNameIdentifierOwner findElementToShowUsagesOf(@NotNull Editor editor, @NotNull PsiFile file, int offset) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java index 190ce1d913bd..eb4861f733ff 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoTypeDeclarationAction.java @@ -27,6 +27,8 @@ import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -64,14 +66,23 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiDocumentManager.getInstance(project).commitAllDocuments(); - int offset = editor.getCaretModel().getOffset(); - PsiElement[] symbolTypes = findSymbolTypes(editor, offset); - if (symbolTypes == null || symbolTypes.length == 0) return; - if (symbolTypes.length == 1) { - navigate(project, symbolTypes[0]); + DumbService.getInstance(project).setAlternativeResolveEnabled(true); + try { + int offset = editor.getCaretModel().getOffset(); + PsiElement[] symbolTypes = findSymbolTypes(editor, offset); + if (symbolTypes == null || symbolTypes.length == 0) return; + if (symbolTypes.length == 1) { + navigate(project, symbolTypes[0]); + } + else { + NavigationUtil.getPsiElementPopup(symbolTypes, CodeInsightBundle.message("choose.type.popup.title")).showInBestPositionFor(editor); + } } - else { - NavigationUtil.getPsiElementPopup(symbolTypes, CodeInsightBundle.message("choose.type.popup.title")).showInBestPositionFor(editor); + catch (IndexNotReadyException e) { + DumbService.getInstance(project).showDumbModeNotification("Navigation is not available here during index update"); + } + finally { + DumbService.getInstance(project).setAlternativeResolveEnabled(false); } } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index 5a181694c5db..8e43717da3cc 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -33,6 +33,7 @@ import com.intellij.ui.BrowserHyperlinkListener; import com.intellij.ui.DocumentAdapter; import com.intellij.ui.InsertPathAction; import com.intellij.ui.ScrollPaneFactory; +import com.intellij.ui.MessageException; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.mac.MacMessages; import com.intellij.ui.mac.foundation.MacUtil; @@ -485,6 +486,9 @@ public class Messages { return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, null, doNotAskOption); } } + catch (MessageException messageException) { + // just show a dialog instead + } catch (Exception exception) { LOG.error(exception); } diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacMessageException.java b/platform/platform-api/src/com/intellij/ui/MessageException.java similarity index 82% rename from platform/platform-impl/src/com/intellij/ui/mac/MacMessageException.java rename to platform/platform-api/src/com/intellij/ui/MessageException.java index a6609cda40de..8e3da8b693b5 100644 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacMessageException.java +++ b/platform/platform-api/src/com/intellij/ui/MessageException.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.intellij.ui.mac; +package com.intellij.ui; /** * Created by denis on 28/01/14. */ -public class MacMessageException extends RuntimeException { - public MacMessageException(final String message) { +public class MessageException extends RuntimeException { + public MessageException(final String message) { super(message); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 061fc5bb07a8..52cdc8c558e2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -134,7 +134,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private static final boolean HONOR_CAMEL_HUMPS_ON_TRIPLE_CLICK = Boolean.parseBoolean(System.getProperty("idea.honor.camel.humps.on.triple.click")); private static final Key BUFFER = Key.create("buffer"); - public static final JBColor CURSOR_FOREGROUND = new JBColor(Gray._255, Gray._0); + public static final Color CURSOR_FOREGROUND_LIGHT = Gray._255; + public static final Color CURSOR_FOREGROUND_DARK = Gray._0; @NotNull private final DocumentEx myDocument; private final JPanel myPanel; @@ -4747,7 +4748,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi //todo[kb] //in case of italic style we paint out of the cursor block. Painting the symbol to a dedicated buffered image //solves the problem, but still looks weird because it leaves colored pixels at right. - g.setColor(CURSOR_FOREGROUND); + g.setColor(ColorUtil.isDark(caretColor) ? CURSOR_FOREGROUND_LIGHT : CURSOR_FOREGROUND_DARK); g.drawChars(new char[]{ch}, 0, 1, x, y + getAscent()); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 7b3bd2198cf9..42d88cf5a4a0 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -63,6 +63,7 @@ public class DumbServiceImpl extends DumbService implements Disposable { private final Queue myRunWhenSmartQueue = new Queue(5); private final Project myProject; + private ThreadLocal myAlternativeResolution = new ThreadLocal(); public DumbServiceImpl(Project project) { myProject = project; @@ -104,6 +105,17 @@ public class DumbServiceImpl extends DumbService implements Disposable { return myProject; } + @Override + public boolean isAlternativeResolveEnabled() { + return Boolean.TRUE.equals(myAlternativeResolution.get()); + } + + @Override + public void setAlternativeResolveEnabled(boolean enabled) { + assert isAlternativeResolveEnabled() != enabled : "Nested alternative resolution mode is not supported"; + myAlternativeResolution.set(enabled); + } + @Override public boolean isDumb() { return myDumb; diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java index 1ffa4e261858..ce1d3b51407a 100644 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacMessagesImpl.java @@ -24,6 +24,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.impl.ModalityHelper; +import com.intellij.ui.MessageException; import com.intellij.ui.mac.foundation.ID; import com.intellij.ui.mac.foundation.MacUtil; import com.intellij.util.ui.UIUtil; @@ -332,7 +333,7 @@ public class MacMessagesImpl extends MacMessages { method.invoke(theQueue, event); } } - catch (MacMessageException mme) { + catch (MessageException mme) { throw mme; } catch (Throwable e) { @@ -428,7 +429,7 @@ public class MacMessagesImpl extends MacMessages { private ID getParamsAsID() { if (window == null) { - throw new MacMessageException("Window should be in the list."); + throw new MessageException("Window should be in the list."); } params.put(COMMON_DIALOG_PARAM_TYPE.nativeFocusedWindow, window); @@ -598,7 +599,7 @@ public class MacMessagesImpl extends MacMessages { //} queuesFromDocumentRoot.remove(documentRoot); if (blockedDocumentRoots.remove(documentRoot) != null) { - throw new MacMessageException("Owner window has been removed"); + throw new MessageException("Owner window has been removed"); } } }); @@ -732,7 +733,7 @@ public class MacMessagesImpl extends MacMessages { if (SystemInfo.isAppleJvm && MacUtil.getWindowTitle(_window) == null) { // With Apple JDK we cannot find a window if it does not have a title // Let's show a dialog instead of the message. - throw new MacMessageException("MacMessage parent does not have a title."); + throw new MessageException("MacMessage parent does not have a title."); } while (_window != null && MacUtil.getWindowTitle(_window) == null) { _window = _window.getOwner(); diff --git a/platform/platform-impl/src/com/intellij/ui/messages/JBMacMessages.java b/platform/platform-impl/src/com/intellij/ui/messages/JBMacMessages.java index fcc0d5667ec4..b1ca220609aa 100644 --- a/platform/platform-impl/src/com/intellij/ui/messages/JBMacMessages.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/JBMacMessages.java @@ -22,7 +22,7 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.impl.ModalityHelper; -import com.intellij.ui.mac.MacMessageException; +import com.intellij.ui.MessageException; import com.intellij.ui.mac.MacMessagesEmulation; import com.intellij.ui.mac.foundation.MacUtil; import com.intellij.util.ui.UIUtil; @@ -149,7 +149,7 @@ public class JBMacMessages extends MacMessagesEmulation { if (SystemInfo.isAppleJvm && MacUtil.getWindowTitle(_window) == null) { // With Apple JDK we cannot find a window if it does not have a title // Let's show a dialog instead of the message. - throw new MacMessageException("MacMessage parent does not have a title."); + throw new MessageException("MacMessage parent does not have a title."); } while (_window != null && MacUtil.getWindowTitle(_window) == null) { _window = _window.getOwner(); diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java index 0f1f5e388dd5..ab3ad1779546 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetController.java @@ -36,7 +36,9 @@ import java.awt.event.*; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.IOException; +import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; /** * Created by Denis Fokin @@ -274,7 +276,12 @@ public class SheetController { if(he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if(Desktop.isDesktopSupported()) { try { - Desktop.getDesktop().browse(he.getURL().toURI()); + URL url = he.getURL(); + if (url != null) { + Desktop.getDesktop().browse(url.toURI()); + } else { + LOG.warn("URL is null; HyperlinkEvent: " + he.toString()); + } } catch (IOException e) { LOG.error(e); @@ -287,7 +294,7 @@ public class SheetController { } }); - FontMetrics fontMetrics = mySheetMessage.getFontMetrics(regularFont); + FontMetrics fontMetrics = sheetPanel.getFontMetrics(regularFont); int widestWordWidth = 250; diff --git a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java index 40b7ed6a4c6f..7837b48ab3fa 100755 --- a/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java +++ b/platform/platform-impl/src/com/intellij/ui/messages/SheetMessage.java @@ -259,11 +259,6 @@ public class SheetMessage { } }); } - - FontMetrics getFontMetrics(final Font f) { - final Component c = (myParent == null) ? WindowManagerEx.getInstanceEx().getMostRecentFocusedWindow() : myParent; - return c.getGraphics().getFontMetrics(f); - } } diff --git a/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java b/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java index 799e924c587d..e586093aad93 100644 --- a/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java +++ b/platform/platform-tests/testSrc/com/intellij/codeInsight/actions/ReformatFilesWithFiltersTest.java @@ -1,8 +1,6 @@ - package com.intellij.codeInsight.actions; import com.intellij.lang.LanguageFormatting; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileTypes.PlainTextLanguage; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; @@ -11,13 +9,11 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.testFramework.LightPlatformTestCase; import com.intellij.testFramework.PlatformTestCase; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.picocontainer.MutablePicoContainer; import java.io.IOException; -import java.util.Collection; import java.util.Set; import static com.intellij.psi.search.GlobalSearchScopesCore.directoryScope; @@ -246,7 +242,7 @@ public class ReformatFilesWithFiltersTest extends LightPlatformTestCase { AbstractLayoutCodeProcessor processor = new ReformatCodeProcessor(getProject(), directory, true, false); ReformatCodeAction.registerScopeFilter(processor, scope); - processor = new RearrangeCodeProcessor(processor, null); + processor = new RearrangeCodeProcessor(processor); processor.run(); } diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java index 47b5b7144fa5..1c6f87a98e92 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java @@ -10,7 +10,6 @@ import com.intellij.lang.Language; import com.intellij.lang.LanguageUtil; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.Result; -import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; @@ -176,13 +175,19 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { - if (!isValid()) { - getOKAction().setEnabled(false); - } - else { - getOKAction().setEnabled(true); - reportMessage(null, null); - } + final boolean valid = isValid(); + ApplicationManager.getApplication().invokeLater(new Runnable() { + @Override + public void run() { + if (!valid) { + getOKAction().setEnabled(false); + } + else { + getOKAction().setEnabled(true); + reportMessage(null, null); + } + } + }); } }); } @@ -835,11 +840,7 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator } catch (MalformedPatternException ex) { if (myRunFindActionOnClose) { - reportMessage( - "this.pattern.is.malformed.message", - searchCriteriaEdit, - ex.getMessage() != null ? ex.getMessage() : "" - ); + reportMessage("this.pattern.is.malformed.message", searchCriteriaEdit, (ex.getMessage() != null) ? ex.getMessage() : ""); result = false; } } @@ -848,16 +849,20 @@ public class SearchDialog extends DialogWrapper implements ConfigurationCreator result = false; } - //getOKAction().setEnabled(result); return result; } - protected void reportMessage(@NonNls String messageId, Editor editor, Object... params) { - final String message = messageId != null ? SSRBundle.message(messageId, params) : ""; - status.setText(message); - status.setToolTipText(message); - status.revalidate(); - statusText.setLabelFor(editor != null ? editor.getContentComponent() : null); + protected void reportMessage(@NonNls final String messageId, final Editor editor, final Object... params) { + com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + final String message = messageId != null ? SSRBundle.message(messageId, params) : ""; + status.setText(message); + status.setToolTipText(message); + status.revalidate(); + statusText.setLabelFor(editor != null ? editor.getContentComponent() : null); + } + }); } protected void setValuesToConfig(Configuration config) { diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java index 7521b9bbc014..7e0ae86516c1 100644 --- a/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java +++ b/platform/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java @@ -146,17 +146,34 @@ public class UIUtil { append(buf, SSRBundle.message("target.tooltip.message")); } if (constraint.getRegExp() != null && constraint.getRegExp().length() > 0) { - append(buf, SSRBundle.message("text.tooltip.message", constraint.isInvertRegExp() ? SSRBundle.message("not.tooltip.message") : "", - constraint.getRegExp(), - constraint.isWithinHierarchy() || constraint.isStrictlyWithinHierarchy() ? - SSRBundle.message("within.hierarchy.tooltip.message") : "")); + append(buf, SSRBundle.message("text.tooltip.message", + constraint.isInvertRegExp() ? SSRBundle.message("not.tooltip.message") : "", constraint.getRegExp())); + } + if (constraint.isWithinHierarchy() || constraint.isStrictlyWithinHierarchy()) { + append(buf, SSRBundle.message("within.hierarchy.tooltip.message")); + } + + if (constraint.isReadAccess()) { + append(buf, SSRBundle.message("value.read.tooltip.message", + constraint.isInvertReadAccess() ? SSRBundle.message("not.tooltip.message") : "")); + } + if (constraint.isWriteAccess()) { + append(buf, SSRBundle.message("value.written.tooltip.message", + constraint.isInvertWriteAccess() ? SSRBundle.message("not.tooltip.message") : "")); } if (constraint.getNameOfExprType() != null && constraint.getNameOfExprType().length() > 0) { append(buf, SSRBundle.message("exprtype.tooltip.message", constraint.isInvertExprType() ? SSRBundle.message("not.tooltip.message") : "", constraint.getNameOfExprType(), - constraint.isExprTypeWithinHierarchy() ? SSRBundle.message("within.hierarchy.tooltip.message") : "")); + constraint.isExprTypeWithinHierarchy() ? SSRBundle.message("supertype.tooltip.message") : "")); + } + + if (constraint.getNameOfFormalArgType() != null && constraint.getNameOfFormalArgType().length() > 0) { + append(buf, SSRBundle.message("expected.type.tooltip.message", + constraint.isInvertFormalType() ? SSRBundle.message("not.tooltip.message") : "", + constraint.getNameOfFormalArgType(), + constraint.isFormalArgTypeWithinHierarchy() ? SSRBundle.message("supertype.tooltip.message") : "")); } if (constraint.getMinCount() == constraint.getMaxCount()) { diff --git a/platform/structuralsearch/source/messages/SSRBundle.properties b/platform/structuralsearch/source/messages/SSRBundle.properties index 5087bf2716d0..03e22b45699a 100644 --- a/platform/structuralsearch/source/messages/SSRBundle.properties +++ b/platform/structuralsearch/source/messages/SSRBundle.properties @@ -169,10 +169,14 @@ script.option.text=Script text\: occurs.tooltip.message=occurs: {0} min.occurs.tooltip.message=min occurs: {0}, max occurs: {1} target.tooltip.message=target -text.tooltip.message={0} like: {1}{2} -exprtype.tooltip.message={0} like: {1}{2} -not.tooltip.message=not -within.hierarchy.tooltip.message=\ within hierarchy +text.tooltip.message=text{0} like: {1} +exprtype.tooltip.message=type{2}{0} like: {1} +supertype.tooltip.message=\ or supertype +expected.type.tooltip.message=expected type{2}{0} like: {1} +value.read.tooltip.message=value is{0} read +value.written.tooltip.message=value is{0} written +not.tooltip.message=\ not +within.hierarchy.tooltip.message=search in supers script.tooltip.message=script: {0} replacement.variable.is.not.defined.message=Replacement variable {0} is not defined. replacement.variable.is.not.valid=Replacement variable {0} has script code problem {1} diff --git a/platform/util/src/com/intellij/icons/AllIcons.java b/platform/util/src/com/intellij/icons/AllIcons.java index b34b7bd4aeab..2e3233570e37 100644 --- a/platform/util/src/com/intellij/icons/AllIcons.java +++ b/platform/util/src/com/intellij/icons/AllIcons.java @@ -700,7 +700,9 @@ public class AllIcons { public static final Icon WebModule = IconLoader.getIcon("/javaee/webModule.png"); // 16x16 public static final Icon WebModuleGroup = IconLoader.getIcon("/javaee/webModuleGroup.png"); // 16x16 public static final Icon WebService = IconLoader.getIcon("/javaee/WebService.png"); // 16x16 + public static final Icon WebService2 = IconLoader.getIcon("/javaee/WebService2.png"); // 16x16 public static final Icon WebServiceClient = IconLoader.getIcon("/javaee/WebServiceClient.png"); // 16x16 + public static final Icon WebServiceClient2 = IconLoader.getIcon("/javaee/WebServiceClient2.png"); // 16x16 } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 779260b26f0d..73334983a268 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -142,9 +142,27 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj private final MyUpdateButtonsRunnable myUpdateButtonsRunnable = new MyUpdateButtonsRunnable(this); - public static boolean commitChanges(final Project project, final List changes, final LocalChangeList initialSelection, - final List executors, final boolean showVcsCommit, final String comment, - @Nullable CommitResultHandler customResultHandler, boolean cancelIfNoChanges) { + public static boolean commitChanges(final Project project, + final List changes, + final LocalChangeList initialSelection, + final List executors, + final boolean showVcsCommit, + final String comment, + @Nullable CommitResultHandler customResultHandler, + boolean cancelIfNoChanges) { + return commitChanges(project, changes, initialSelection, executors, showVcsCommit, null, comment, customResultHandler, + cancelIfNoChanges); + } + + public static boolean commitChanges(final Project project, + final List changes, + final LocalChangeList initialSelection, + final List executors, + final boolean showVcsCommit, + @Nullable final AbstractVcs singleVcs, + final String comment, + @Nullable CommitResultHandler customResultHandler, + boolean cancelIfNoChanges) { if (cancelIfNoChanges && changes.isEmpty() && !ApplicationManager.getApplication().isUnitTestMode()) { Messages.showInfoMessage(project, VcsBundle.message("commit.dialog.no.changes.detected.text"), VcsBundle.message("commit.dialog.no.changes.detected.title")); @@ -159,8 +177,10 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj } final ChangeListManager manager = ChangeListManager.getInstance(project); - CommitChangeListDialog dialog = new CommitChangeListDialog(project, changes, initialSelection, executors, showVcsCommit, manager.getDefaultChangeList(), manager.getChangeListsCopy(), null, - false, comment, customResultHandler); + CommitChangeListDialog dialog = + new CommitChangeListDialog(project, changes, initialSelection, executors, showVcsCommit, manager.getDefaultChangeList(), + manager.getChangeListsCopy(), singleVcs, + false, comment, customResultHandler); if (!ApplicationManager.getApplication().isUnitTestMode()) { dialog.show(); } @@ -990,7 +1010,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj if (myIsAlien) { helper.doAlienCommit(myVcs); } else { - helper.doCommit(); + helper.doCommit(myVcs); } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java index 3f0747e80b30..b64d5ac1997c 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java @@ -101,7 +101,11 @@ public class CommitHelper { } public boolean doCommit() { - return doCommit(new CommitProcessor()); + return doCommit((AbstractVcs)null); + } + + public boolean doCommit(@Nullable AbstractVcs vcs) { + return doCommit(new CommitProcessor(vcs)); } public boolean doAlienCommit(final AbstractVcs vcs) { @@ -374,8 +378,10 @@ public class CommitHelper { private LocalHistoryAction myAction; private ChangeListsModificationAfterCommit myAfterVcsRefreshModification; private boolean myCommitSuccess; + @Nullable private final AbstractVcs myVcs; - private CommitProcessor() { + private CommitProcessor(@Nullable AbstractVcs vcs) { + myVcs = vcs; myAfterVcsRefreshModification = ChangeListsModificationAfterCommit.NOTHING; if (myChangeList instanceof LocalChangeList) { final LocalChangeList localList = (LocalChangeList) myChangeList; @@ -391,6 +397,9 @@ public class CommitHelper { } public void callSelf() { + if (myVcs != null && myIncludedChanges.isEmpty()) { + process(myVcs, myIncludedChanges); + } ChangesUtil.processChangesByVcs(myProject, myIncludedChanges, this); } diff --git a/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java b/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java index acef8806f89f..44f5ab941613 100644 --- a/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java +++ b/plugins/coverage/src/com/intellij/coverage/JavaCoverageEngineExtension.java @@ -7,6 +7,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiNamedElement; import com.intellij.rt.coverage.data.LineData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -78,4 +79,26 @@ public abstract class JavaCoverageEngineExtension { public boolean isSourceMapNeeded(RunConfigurationBase runConfiguration) { return false; } + + /** + * Returns the summary information for the specified object (other than a class or a file) shown in the coverage view. + */ + @Nullable + public PackageAnnotator.ClassCoverageInfo getSummaryCoverageInfo(JavaCoverageAnnotator coverageAnnotator, PsiNamedElement element) { + return null; + } + + /** + * Returns true if the class coverage info for the specified .class file, for which it wasn't possible to find a corresponding + * source file, needs to be preserved and made available as {@link JavaCoverageAnnotator#getClassCoverageInfo(String)}. + * The qualified name under which the data will be available is calculated by replacing slashes with dots in the path of the + * .class file relative to the class output root. The statistics for such classes will be included in the statistics for + * the package with the corresponding qualified name but will not be included in the statistics of any directories. + * + * @param bundle the coverage suites bundle being indexed. + * @param classFile the class file. + */ + public boolean keepCoverageInfoForClassWithoutSource(CoverageSuitesBundle bundle, File classFile) { + return false; + } } diff --git a/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java b/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java index b4a935fc1ee3..c60df2461fca 100644 --- a/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java +++ b/plugins/coverage/src/com/intellij/coverage/PackageAnnotator.java @@ -97,6 +97,15 @@ public class PackageAnnotator { public int getCoveredLineCount() { return coveredLineCount; } + + public void append(SummaryCoverageInfo info) { + totalClassCount += info.totalClassCount; + totalLineCount += info.totalLineCount; + coveredClassCount += info.coveredClassCount; + coveredLineCount += info.getCoveredLineCount(); + coveredMethodCount += info.coveredMethodCount; + totalMethodCount += info.totalMethodCount; + } } public static class DirCoverageInfo extends PackageCoverageInfo { @@ -251,6 +260,7 @@ public class PackageAnnotator { dirs.add(new DirCoverageInfo(relativeSrcRoot)); } } + final PackageCoverageInfo classWithoutSourceCoverageInfo = new PackageCoverageInfo(); final File[] children = packageOutputRoot.listFiles(); @@ -300,15 +310,29 @@ public class PackageAnnotator { && (trackTestFolders || !fileIndex.isInTestSourceContent(containingFileRef.get())); } }); + PackageCoverageInfo coverageInfoForClass = null; if (isInSource != null && isInSource.booleanValue()) { for (DirCoverageInfo dirCoverageInfo : dirs) { if (dirCoverageInfo.sourceRoot != null && VfsUtil.isAncestor(dirCoverageInfo.sourceRoot, containingFileRef.get(), false)) { - collectClassCoverageInformation(child, psiClassRef.get(), dirCoverageInfo, projectInfo, toplevelClassCoverage, - classFqVMName.replace("/", "."), toplevelClassSrcFQName); + coverageInfoForClass = dirCoverageInfo; break; } } } + String classCoverageKey = toplevelClassSrcFQName; + if (coverageInfoForClass == null) { + for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { + if (extension.keepCoverageInfoForClassWithoutSource(myCoverageManager.getCurrentSuitesBundle(), child)) { + classCoverageKey = classFqVMName.replace('/', '.'); + coverageInfoForClass = classWithoutSourceCoverageInfo; + break; + } + } + } + if (coverageInfoForClass != null) { + collectClassCoverageInformation(child, psiClassRef.get(), coverageInfoForClass, projectInfo, toplevelClassCoverage, + classFqVMName.replace("/", "."), classCoverageKey); + } } } } @@ -322,24 +346,12 @@ public class PackageAnnotator { PackageCoverageInfo flattenPackageCoverageInfo = getOrCreateCoverageInfo(flattenPackageCoverageMap, packageVMName); for (Map.Entry entry : toplevelClassCoverage.entrySet()) { final ClassCoverageInfo coverageInfo = entry.getValue(); - flattenPackageCoverageInfo.coveredClassCount += coverageInfo.coveredClassCount; - flattenPackageCoverageInfo.totalClassCount += coverageInfo.totalClassCount; - - flattenPackageCoverageInfo.coveredLineCount += coverageInfo.fullyCoveredLineCount + coverageInfo.partiallyCoveredLineCount; - flattenPackageCoverageInfo.totalLineCount += coverageInfo.totalLineCount; - - flattenPackageCoverageInfo.coveredMethodCount += coverageInfo.coveredMethodCount; - flattenPackageCoverageInfo.totalMethodCount += coverageInfo.totalMethodCount; + flattenPackageCoverageInfo.append(coverageInfo); } PackageCoverageInfo packageCoverageInfo = getOrCreateCoverageInfo(packageCoverageMap, packageVMName); for (DirCoverageInfo dir : dirs) { - packageCoverageInfo.totalClassCount += dir.totalClassCount; - packageCoverageInfo.totalLineCount += dir.totalLineCount; - packageCoverageInfo.coveredClassCount += dir.coveredClassCount; - packageCoverageInfo.coveredLineCount += dir.coveredLineCount; - packageCoverageInfo.coveredMethodCount += dir.coveredMethodCount; - packageCoverageInfo.totalMethodCount += dir.totalMethodCount; + packageCoverageInfo.append(dir); if (isTestHierarchy) { annotator.annotateTestDirectory(dir.sourceRoot, dir, module); @@ -348,6 +360,7 @@ public class PackageAnnotator { annotator.annotateSourceDirectory(dir.sourceRoot, dir, module); } } + packageCoverageInfo.append(classWithoutSourceCoverageInfo); return dirs.toArray(new DirCoverageInfo[dirs.size()]); } @@ -370,7 +383,8 @@ public class PackageAnnotator { return coverageInfo; } - private void collectClassCoverageInformation(final File classFile, final PsiClass psiClass, final PackageCoverageInfo packageCoverageInfo, + private void collectClassCoverageInformation(final File classFile, + @Nullable final PsiClass psiClass, final PackageCoverageInfo packageCoverageInfo, final ProjectData projectInfo, final Map toplevelClassCoverage, final String className, @@ -440,14 +454,17 @@ public class PackageAnnotator { * Checks if the method is a default constructor generated by the compiler. Such constructors are not marked as synthetic * in the bytecode, so we need to look at the PSI to see if the class defines such a constructor. */ - private static boolean isGeneratedDefaultConstructor(final PsiClass aClass, String nameAndSig) { + private static boolean isGeneratedDefaultConstructor(@Nullable final PsiClass aClass, String nameAndSig) { if (DEFAULT_CONSTRUCTOR_NAME_SIGNATURE.equals(nameAndSig)) { return hasGeneratedConstructor(aClass); } return false; } - private static boolean hasGeneratedConstructor(final PsiClass aClass) { + private static boolean hasGeneratedConstructor(@Nullable final PsiClass aClass) { + if (aClass == null) { + return false; + } return ApplicationManager.getApplication().runReadAction(new Computable() { public Boolean compute() { return aClass.getConstructors().length == 0; @@ -480,7 +497,7 @@ public class PackageAnnotator { return true if there is executable code in the class */ private boolean collectNonCoveredClassInfo(final File classFile, - PsiClass psiClass, + @Nullable PsiClass psiClass, final ClassCoverageInfo classCoverageInfo, final PackageCoverageInfo packageCoverageInfo) { final byte[] content = myCoverageManager.doInReadActionIfProjectOpen(new Computable() { diff --git a/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java b/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java index e7f780a99967..c4ccc66e30cf 100644 --- a/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java +++ b/plugins/coverage/src/com/intellij/coverage/view/JavaCoverageViewExtension.java @@ -79,18 +79,25 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { } public PackageAnnotator.SummaryCoverageInfo getSummaryCoverageForNodeValue(Object value) { - PackageAnnotator.SummaryCoverageInfo info = null; if (value instanceof PsiClass) { //no coverage gathered if (!((PsiClass)value).isInterface()) { final String qualifiedName = ((PsiClass)value).getQualifiedName(); - info = myAnnotator.getClassCoverageInfo(qualifiedName); + return myAnnotator.getClassCoverageInfo(qualifiedName); } } if (value instanceof PsiPackage) { - info = myAnnotator.getPackageCoverageInfo((PsiPackage)value, myStateBean.myFlattenPackages); + return myAnnotator.getPackageCoverageInfo((PsiPackage)value, myStateBean.myFlattenPackages); } - return info; + if (value instanceof PsiNamedElement) { + for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { + PackageAnnotator.SummaryCoverageInfo info = extension.getSummaryCoverageInfo(myAnnotator, (PsiNamedElement)value); + if (info != null) { + return info; + } + } + } + return null; } @Override @@ -157,12 +164,11 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { for (PsiPackage aPackage : packages) { final GlobalSearchScope searchScope = mySuitesBundle.getSearchScope(myProject); - if (aPackage.getDirectories(searchScope).length == 0) continue; if (aPackage.getClasses(searchScope).length != 0) { final CoverageListNode node = new CoverageListNode(myProject, aPackage, mySuitesBundle, myStateBean); topLevelNodes.add(node); } - collectSubPackages(topLevelNodes, aPackage, mySuitesBundle, myStateBean); + collectSubPackages(topLevelNodes, aPackage); } for (PsiClass aClass : classes) { @@ -172,44 +178,34 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { return topLevelNodes; } - private static void collectSubPackages(List children, - final PsiPackage rootPackage, - final CoverageSuitesBundle data, - final CoverageViewManager.StateBean stateBean) { - final GlobalSearchScope searchScope = data.getSearchScope(rootPackage.getProject()); + private void collectSubPackages(List children, final PsiPackage rootPackage) { + final GlobalSearchScope searchScope = mySuitesBundle.getSearchScope(rootPackage.getProject()); final PsiPackage[] subPackages = ApplicationManager.getApplication().runReadAction(new Computable() { public PsiPackage[] compute() { return rootPackage.getSubPackages(searchScope); } }); for (final PsiPackage aPackage : subPackages) { - final PsiDirectory[] directories = ApplicationManager.getApplication().runReadAction(new Computable() { - public PsiDirectory[] compute() { - return aPackage.getDirectories(searchScope); - } - }); - if (directories.length == 0 && !ApplicationManager.getApplication().runReadAction(new Computable() { - public Boolean compute() { - return JavaPsiFacade.getInstance(aPackage.getProject()).isPartOfPackagePrefix(aPackage.getQualifiedName()); - } - })) continue; - if (ApplicationManager.getApplication().runReadAction(new Computable() { - public Boolean compute() { - return isInCoverageScope(aPackage, data); - } - })) { - final CoverageListNode node = new CoverageListNode(rootPackage.getProject(), aPackage, data, stateBean); - children.add(node); - } - else if (!stateBean.myFlattenPackages) { - collectSubPackages(children, aPackage, data, stateBean); - } - if (stateBean.myFlattenPackages) { - collectSubPackages(children, aPackage, data, stateBean); - } + processSubPackage(aPackage, children); } } + private void processSubPackage(final PsiPackage aPackage, List children) { + if (ApplicationManager.getApplication().runReadAction(new Computable() { + public Boolean compute() { + return isInCoverageScope(aPackage); + } + })) { + final CoverageListNode node = new CoverageListNode(aPackage.getProject(), aPackage, mySuitesBundle, myStateBean); + children.add(node); + } + else if (!myStateBean.myFlattenPackages) { + collectSubPackages(children, aPackage); + } + if (myStateBean.myFlattenPackages) { + collectSubPackages(children, aPackage); + } + } @Override public List getChildrenNodes(final AbstractTreeNode node) { @@ -220,24 +216,34 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { //append package classes if (val instanceof PsiPackage) { - if (!myStateBean.myFlattenPackages) { - collectSubPackages(children, (PsiPackage)val, mySuitesBundle, myStateBean); - } + final PsiPackage psiPackage = (PsiPackage) val; if (ApplicationManager.getApplication().runReadAction(new Computable() { public Boolean compute() { - return isInCoverageScope((PsiPackage)val, mySuitesBundle); + return isInCoverageScope(psiPackage); } })) { - final PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable() { - public PsiClass[] compute() { - return ((PsiPackage)val).getClasses(mySuitesBundle.getSearchScope(node.getProject())); + final PsiElement[] childElements = ApplicationManager.getApplication().runReadAction(new Computable() { + public PsiElement[] compute() { + return psiPackage.getChildren(mySuitesBundle.getSearchScope(node.getProject())); } }); - for (PsiClass aClass : classes) { - if (!(node instanceof CoverageListRootNode) && getClassCoverageInfo(aClass) == null) continue; - children.add(new CoverageListNode(myProject, aClass, mySuitesBundle, myStateBean)); + for (PsiElement element : childElements) { + if (element instanceof PsiClass) { + PsiClass aClass = (PsiClass) element; + if (!(node instanceof CoverageListRootNode) && getClassCoverageInfo(aClass) == null) continue; + children.add(new CoverageListNode(myProject, aClass, mySuitesBundle, myStateBean)); + } + else if (element instanceof PsiPackage) { + processSubPackage((PsiPackage) element, children); + } + else if (element instanceof PsiNamedElement) { + children.add(new CoverageListNode(myProject, (PsiNamedElement) element, mySuitesBundle, myStateBean)); + } } } + else if (!myStateBean.myFlattenPackages) { + collectSubPackages(children, (PsiPackage)val); + } } if (node instanceof CoverageListRootNode) { for (CoverageSuite suite : mySuitesBundle.getSuites()) { @@ -273,11 +279,11 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { }; } - private static boolean isInCoverageScope(PsiElement element, CoverageSuitesBundle suitesBundle) { + private boolean isInCoverageScope(PsiElement element) { if (element instanceof PsiPackage) { final PsiPackage psiPackage = (PsiPackage)element; final String qualifiedName = psiPackage.getQualifiedName(); - for (CoverageSuite suite : suitesBundle.getSuites()) { + for (CoverageSuite suite : mySuitesBundle.getSuites()) { if (((JavaCoverageSuite)suite).isPackageFiltered(qualifiedName)) return true; } } @@ -289,10 +295,10 @@ public class JavaCoverageViewExtension extends CoverageViewExtension { final PsiFile psiFile = object instanceof VirtualFile ? PsiManager.getInstance(myProject).findFile((VirtualFile)object) : null; if (psiFile instanceof PsiClassOwner) { final String packageName = ((PsiClassOwner)psiFile).getPackageName(); - return isInCoverageScope(JavaPsiFacade.getInstance(myProject).findPackage(packageName), mySuitesBundle); + return isInCoverageScope(JavaPsiFacade.getInstance(myProject).findPackage(packageName)); } if (object instanceof PsiPackage) { - return isInCoverageScope((PsiElement)object, mySuitesBundle); + return isInCoverageScope((PsiElement)object); } return false; } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/GroovyDocLexer.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/GroovyDocLexer.java index 128e8498ea5a..1c86d5ab3589 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/GroovyDocLexer.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/groovydoc/lexer/GroovyDocLexer.java @@ -16,10 +16,7 @@ package org.jetbrains.plugins.groovy.lang.groovydoc.lexer; -import com.intellij.lexer.Lexer; -import com.intellij.lexer.LexerBase; -import com.intellij.lexer.LookAheadLexer; -import com.intellij.lexer.MergingLexerAdapter; +import com.intellij.lexer.*; import com.intellij.psi.TokenType; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; @@ -100,7 +97,7 @@ public class GroovyDocLexer extends MergingLexerAdapter { @Override public int getState() { - return myState; + return getTokenStart() == 0 ? 0 : myState; } @Override diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyActionsTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyActionsTest.groovy index dff034d87443..31b20cd633e3 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyActionsTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyActionsTest.groovy @@ -13,17 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy; +package org.jetbrains.plugins.groovy - -import com.intellij.ide.DataManager import com.intellij.openapi.actionSystem.IdeActions -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.editor.actionSystem.EditorActionHandler -import com.intellij.openapi.editor.actionSystem.EditorActionManager import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase import org.jetbrains.plugins.groovy.util.TestUtils - /** * @author peter */ @@ -117,6 +111,22 @@ this.allOptions = [:]; ''') } + public void "test hippie completion in groovydoc"() { + myFixture.configureByText 'a.groovy', ''' +class A { + + /** long + */ + void longName() {} + void example() {} +} +''' + performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION) + assert myFixture.editor.document.text.contains('** longName\n') + performEditorAction(IdeActions.ACTION_HIPPIE_COMPLETION) + assert myFixture.editor.document.text.contains('** longName\n') + } + void testSWforMemberWithDoc() { doTestForSelectWord(4, '''\ class A { @@ -159,9 +169,7 @@ class A { } private void performEditorAction(final String actionId) { - final EditorActionHandler handler = EditorActionManager.instance.getActionHandler(actionId); - final Editor editor = myFixture.editor; - handler.execute(editor, DataManager.instance.getDataContext(editor.contentComponent)); + myFixture.performEditorAction(actionId) } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java index 02655cffa3ae..9c496969a3bb 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java @@ -53,6 +53,7 @@ import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.provider.*; import org.zmlx.hg4idea.provider.annotate.HgAnnotationProvider; import org.zmlx.hg4idea.provider.commit.HgCheckinEnvironment; +import org.zmlx.hg4idea.provider.commit.HgCloseBranchExecutor; import org.zmlx.hg4idea.provider.commit.HgCommitAndPushExecutor; import org.zmlx.hg4idea.provider.update.HgUpdateEnvironment; import org.zmlx.hg4idea.roots.HgIntegrationEnabler; @@ -104,7 +105,8 @@ public class HgVcs extends AbstractVcs { private HgExecutableValidator myExecutableValidator; private final Object myExecutableValidatorLock = new Object(); private File myPromptHooksExtensionFile; - private CommitExecutor myCommitAndPushExecutor; + private final CommitExecutor myCommitAndPushExecutor; + private final HgCloseBranchExecutor myCloseBranchExecutor; private HgRemoteStatusUpdater myHgRemoteStatusUpdater; private HgStatusWidget myStatusWidget; @@ -130,6 +132,7 @@ public class HgVcs extends AbstractVcs { committedChangesProvider = new HgCachingCommittedChangesProvider(project, this); myMergeProvider = new HgMergeProvider(myProject); myCommitAndPushExecutor = new HgCommitAndPushExecutor(checkinEnvironment); + myCloseBranchExecutor = new HgCloseBranchExecutor(checkinEnvironment); } public String getDisplayName() { @@ -396,6 +399,11 @@ public class HgVcs extends AbstractVcs { return Collections.singletonList(myCommitAndPushExecutor); } + @NotNull + public HgCloseBranchExecutor getCloseBranchExecutor() { + return myCloseBranchExecutor; + } + public static VcsKey getKey() { return ourKey; } @@ -468,13 +476,11 @@ public class HgVcs extends AbstractVcs { final String reason = (e.getCause() != null ? e.getCause() : e).getMessage(); String message = HgVcsMessages.message("hg4idea.unable.to.run.hg", executable); vcsNotifier.notifyError(message, - String.format( - reason + - "
Please check your hg executable path in settings " - ), - linkAdapter + reason + + "
Please check your hg executable path in settings ", + linkAdapter ); } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java index 3dcaf6dee161..dc73c36ee503 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopup.java @@ -81,6 +81,7 @@ public class HgBranchPopup extends DvcsBranchPopup { List allRepositories = repositoryManager.getRepositories(); popupGroup.add(new HgBranchPopupActions.HgNewBranchAction(myProject, allRepositories, myCurrentRepository)); popupGroup.addAction(new HgBranchPopupActions.HgNewBookmarkAction(allRepositories, myCurrentRepository)); + popupGroup.addAction(new HgBranchPopupActions.HgCloseBranchAction(allRepositories, myCurrentRepository)); popupGroup.addAction(new HgBranchPopupActions.HgShowUnnamedHeadsForCurrentBranchAction(myCurrentRepository)); popupGroup.addAll(createRepositoriesActions()); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java index 633fe1cf87d9..9de49d560b65 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/branch/HgBranchPopupActions.java @@ -23,9 +23,15 @@ import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.VcsBundle; +import com.intellij.openapi.vcs.changes.*; +import com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.PlatformIcons; @@ -35,15 +41,19 @@ import com.intellij.vcs.log.impl.HashImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgNameWithHashInfo; +import org.zmlx.hg4idea.HgVcs; import org.zmlx.hg4idea.action.HgCommandResultNotifier; import org.zmlx.hg4idea.command.HgBookmarkCommand; import org.zmlx.hg4idea.command.HgBranchCreateCommand; import org.zmlx.hg4idea.execution.HgCommandException; import org.zmlx.hg4idea.execution.HgCommandResult; import org.zmlx.hg4idea.execution.HgCommandResultHandler; +import org.zmlx.hg4idea.provider.commit.HgCloseBranchExecutor; import org.zmlx.hg4idea.repo.HgRepository; +import org.zmlx.hg4idea.repo.HgRepositoryManager; import org.zmlx.hg4idea.ui.HgBookmarkDialog; import org.zmlx.hg4idea.util.HgErrorUtil; +import org.zmlx.hg4idea.util.HgUtil; import java.util.*; @@ -64,6 +74,7 @@ public class HgBranchPopupActions { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgNewBookmarkAction(Collections.singletonList(myRepository), myRepository)); + popupGroup.addAction(new HgBranchPopupActions.HgCloseBranchAction(Collections.singletonList(myRepository), myRepository)); popupGroup.addAction(new HgShowUnnamedHeadsForCurrentBranchAction(myRepository)); if (toInsert != null) { popupGroup.addAll(toInsert); @@ -129,6 +140,60 @@ public class HgBranchPopupActions { } } + public static class HgCloseBranchAction extends DumbAwareAction { + @NotNull private final List myRepositories; + @NotNull final HgRepository myPreselectedRepo; + + HgCloseBranchAction(@NotNull List repositories, @NotNull HgRepository preselectedRepo) { + super("Close " + StringUtil.pluralize("branch", repositories.size()), + "Close current " + StringUtil.pluralize("branch", repositories.size()), AllIcons.Actions.Delete); + myRepositories = repositories; + myPreselectedRepo = preselectedRepo; + } + + @Override + public void actionPerformed(AnActionEvent e) { + final Project project = myPreselectedRepo.getProject(); + ApplicationManager.getApplication().saveAll(); + ChangeListManager.getInstance(project).invokeAfterUpdate(new Runnable() { + @Override + public void run() { + commitAndCloseBranch(project); + } + }, InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE, VcsBundle + .message("waiting.changelists.update.for.show.commit.dialog.message"), + ModalityState.current()); + } + + private void commitAndCloseBranch(@NotNull final Project project) { + final LocalChangeList activeChangeList = ChangeListManager.getInstance(project).getDefaultChangeList(); + HgVcs vcs = HgVcs.getInstance(project); + assert vcs != null; + final HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project); + List changesForRepositories = ContainerUtil.filter(activeChangeList.getChanges(), new Condition() { + @Override + public boolean value(Change change) { + return myRepositories.contains(repositoryManager.getRepositoryForFile(ChangesUtil.getFilePath(change))); + } + }); + HgCloseBranchExecutor closeBranchExecutor = vcs.getCloseBranchExecutor(); + closeBranchExecutor.setRepositories(myRepositories); + CommitChangeListDialog.commitChanges(project, changesForRepositories, activeChangeList, + Collections.singletonList(closeBranchExecutor), + false, vcs, "Close Branch", null, false); + } + + @Override + public void update(AnActionEvent e) { + e.getPresentation().setEnabledAndVisible(ContainerUtil.and(myRepositories, new Condition() { + @Override + public boolean value(HgRepository repository) { + return repository.getOpenedBranches().contains(repository.getCurrentBranch()); + } + })); + } + } + public static class HgNewBookmarkAction extends DumbAwareAction { @NotNull protected final List myRepositories; @NotNull final HgRepository myPreselectedRepo; diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java index 794c7096d207..4ba12ee4add0 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgCommitCommand.java @@ -12,6 +12,7 @@ // limitations under the License. package org.zmlx.hg4idea.command; +import com.intellij.dvcs.repo.Repository; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; @@ -28,6 +29,7 @@ import org.zmlx.hg4idea.HgVcs; import org.zmlx.hg4idea.HgVcsMessages; import org.zmlx.hg4idea.execution.HgCommandException; import org.zmlx.hg4idea.execution.HgCommandExecutor; +import org.zmlx.hg4idea.repo.HgRepository; import org.zmlx.hg4idea.repo.HgRepositoryManager; import org.zmlx.hg4idea.util.HgEncodingUtil; import org.zmlx.hg4idea.util.HgUtil; @@ -51,16 +53,22 @@ public class HgCommitCommand { private final String myMessage; @NotNull private final Charset myCharset; private final boolean myAmend; + private final boolean myCloseBranch; private Set myFiles = Collections.emptySet(); @NotNull private List mySubrepos = Collections.emptyList(); - public HgCommitCommand(Project project, @NotNull VirtualFile root, String message, boolean amend) { + public HgCommitCommand(@NotNull Project project, @NotNull VirtualFile root, String message, boolean amend, boolean closeBranch) { myProject = project; myRoot = root; myMessage = message; myCharset = HgEncodingUtil.getDefaultCharset(myProject); myAmend = amend; + myCloseBranch = closeBranch; + } + + public HgCommitCommand(@NotNull Project project, @NotNull VirtualFile root, String message, boolean amend) { + this(project, root, message, amend, false); } public HgCommitCommand(Project project, @NotNull VirtualFile root, String message) { @@ -80,9 +88,9 @@ public class HgCommitCommand { throw new HgCommandException(HgVcsMessages.message("hg4idea.commit.error.messageEmpty")); } //if it's merge commit, so myFiles is Empty. Need to commit all files in changeList. - // see HgCheckinEnviroment->commit() method + // see HgCheckinEnvironment->commit() method if (myFiles.isEmpty()) { - commitChunkFiles(Collections.emptyList(), myAmend); + commitChunkFiles(Collections.emptyList(), myAmend, myCloseBranch); } else { List relativePaths = ContainerUtil.map2List(myFiles, new Function() { @@ -94,12 +102,12 @@ public class HgCommitCommand { List> chunkedCommits = VcsFileUtil.chunkRelativePaths(relativePaths); int size = chunkedCommits.size(); // commit with subrepo should be first, because it's not possible to amend with --subrepos argument; - commitChunkFiles(chunkedCommits.get(0), myAmend, !mySubrepos.isEmpty()); + commitChunkFiles(chunkedCommits.get(0), myAmend, !mySubrepos.isEmpty(), myCloseBranch && size == 1); HgVcs vcs = HgVcs.getInstance(myProject); boolean amendCommit = vcs != null && vcs.getVersion().isAmendSupported(); for (int i = 1; i < size; i++) { List chunk = chunkedCommits.get(i); - commitChunkFiles(chunk, amendCommit); + commitChunkFiles(chunk, amendCommit, false, myCloseBranch && i == size - 1); } } if (!myProject.isDisposed()) { @@ -111,11 +119,14 @@ public class HgCommitCommand { messageBus.syncPublisher(HgVcs.BRANCH_TOPIC).update(myProject, null); } - private void commitChunkFiles(@NotNull List chunk, boolean amendCommit) throws VcsException { - commitChunkFiles(chunk, amendCommit, false); + private void commitChunkFiles(@NotNull List chunk, boolean amendCommit, boolean closeBranch) throws VcsException { + commitChunkFiles(chunk, amendCommit, false, closeBranch); } - private void commitChunkFiles(@NotNull List chunk, boolean amendCommit, boolean withSubrepos) throws VcsException { + private void commitChunkFiles(@NotNull List chunk, boolean amendCommit, boolean withSubrepos, boolean closeBranch) + throws VcsException { + HgRepository repository = HgUtil.getRepositoryForFile(myProject, myRoot); + assert repository != null; List parameters = new LinkedList(); parameters.add("--logfile"); parameters.add(saveCommitMessage().getAbsolutePath()); @@ -127,6 +138,14 @@ public class HgCommitCommand { else if (amendCommit) { parameters.add("--amend"); } + if (closeBranch) { + if (chunk.isEmpty() && repository.getState() != Repository.State.MERGING) { + //if there are changed files but nothing selected -> need to exclude all; if merge commit then nothing excluded + parameters.add("-X"); + parameters.add("\"**\""); + } + parameters.add("--close-branch"); + } parameters.addAll(chunk); HgCommandExecutor executor = new HgCommandExecutor(myProject); executor.setCharset(myCharset); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java index 4cfe72f121f9..f64b923959bb 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgUpdateCommand.java @@ -103,7 +103,6 @@ public class HgUpdateCommand { DvcsUtil.workingTreeChangeFinished(project, token); } - project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null); VfsUtil.markDirtyAndRefresh(true, true, false, repo); return result; } @@ -120,28 +119,28 @@ public class HgUpdateCommand { return exitCode.get(); } - public static void updateTo(@NotNull final String taskName, @NotNull List repos, @Nullable final Runnable callInAwtLater) { + public static void updateTo(@NotNull final String targetRevision, @NotNull List repos, @Nullable final Runnable callInAwtLater) { FileDocumentManager.getInstance().saveAllDocuments(); for (HgRepository repo : repos) { final VirtualFile repository = repo.getRoot(); Project project = repo.getProject(); - updateRepoTo(project, repository, taskName, callInAwtLater); + updateRepoTo(project, repository, targetRevision, callInAwtLater); } } public static void updateRepoTo(@NotNull final Project project, @NotNull final VirtualFile repository, - @NotNull final String taskName, + @NotNull final String targetRevision, @Nullable final Runnable callInAwtLater) { - updateRepoTo(project, repository, taskName, false, callInAwtLater); + updateRepoTo(project, repository, targetRevision, false, callInAwtLater); } public static void updateRepoTo(@NotNull final Project project, @NotNull final VirtualFile repository, - @NotNull final String taskName, + @NotNull final String targetRevision, final boolean clean, @Nullable final Runnable callInAwtLater) { - new Task.Backgroundable(project, HgVcsMessages.message("action.hg4idea.updateTo.description", taskName)) { + new Task.Backgroundable(project, HgVcsMessages.message("action.hg4idea.updateTo.description", targetRevision)) { @Override public void onSuccess() { if (callInAwtLater != null) { @@ -151,17 +150,17 @@ public class HgUpdateCommand { @Override public void run(@NotNull ProgressIndicator indicator) { - updateRepoToInCurrentThread(project, repository, taskName, clean); + updateRepoToInCurrentThread(project, repository, targetRevision, clean); } }.queue(); } public static boolean updateRepoToInCurrentThread(@NotNull final Project project, @NotNull final VirtualFile repository, - @NotNull final String taskName, + @NotNull final String targetRevision, final boolean clean) { final HgUpdateCommand hgUpdateCommand = new HgUpdateCommand(project, repository); - hgUpdateCommand.setRevision(taskName); + hgUpdateCommand.setRevision(targetRevision); hgUpdateCommand.setClean(clean); HgCommandResult result = hgUpdateCommand.execute(); new HgConflictResolver(project).resolve(repository); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java index cd46452f96f1..fe13294ef8ab 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCheckinEnvironment.java @@ -60,6 +60,8 @@ public class HgCheckinEnvironment implements CheckinEnvironment { private boolean myNextCommitIsPushed; private boolean myNextCommitAmend; // If true, the next commit is amended private boolean myShouldCommitSubrepos; + private boolean myCloseBranch; + @Nullable private Collection myRepos; public HgCheckinEnvironment(Project project) { myProject = project; @@ -67,8 +69,15 @@ public class HgCheckinEnvironment implements CheckinEnvironment { public RefreshableOnComponent createAdditionalOptionsPanel(CheckinProjectPanel panel, PairConsumer additionalDataConsumer) { + reset(); + return new HgCommitAdditionalComponent(myProject, panel); + } + + public void reset() { myNextCommitIsPushed = false; - return new HgCommitAdditionalComponent(myProject,panel); + myShouldCommitSubrepos = false; + myCloseBranch = false; + myRepos = null; } public String getDefaultMessageFor(FilePath[] filesToCheckin) { @@ -83,19 +92,19 @@ public class HgCheckinEnvironment implements CheckinEnvironment { return HgVcsMessages.message("hg4idea.commit"); } - @SuppressWarnings({"ThrowableInstanceNeverThrown"}) public List commit(List changes, String preparedComment, @NotNull NullableFunction parametersHolder, Set feedback) { List exceptions = new LinkedList(); Map> repositoriesMap = getFilesByRepository(changes); + addRepositoriesWithoutChanges(repositoriesMap); for (Map.Entry> entry : repositoriesMap.entrySet()) { HgRepository repo = entry.getKey(); Set selectedFiles = entry.getValue(); HgCommitCommand command = - new HgCommitCommand(myProject, repo.getRoot(), preparedComment, myNextCommitAmend); + new HgCommitCommand(myProject, repo.getRoot(), preparedComment, myNextCommitAmend, myCloseBranch); if (isMergeCommit(repo.getRoot())) { //partial commits are not allowed during merges @@ -255,7 +264,7 @@ public class HgCheckinEnvironment implements CheckinEnvironment { private void addFile(Map> result, ContentRevision contentRevision) { FilePath filePath = contentRevision.getFile(); - // try to find repository from hgFile from change + // try to find repository from hgFile from change: to be able commit sub repositories as expected HgRepository repo = HgUtil.getRepositoryForFile(myProject, contentRevision instanceof HgCurrentBinaryContentRevision ? ((HgCurrentBinaryContentRevision)contentRevision).getRepositoryRoot() : ChangesUtil.findValidParentAccurately(filePath)); @@ -276,6 +285,23 @@ public class HgCheckinEnvironment implements CheckinEnvironment { myNextCommitIsPushed = true; } + public void setCloseBranch(boolean closeBranch) { + myCloseBranch = closeBranch; + } + + public void setRepos(@NotNull Collection repos) { + myRepos = repos; + } + + private void addRepositoriesWithoutChanges(@NotNull Map> repositoryMap) { + if (myRepos == null) return; + for (HgRepository repository : myRepos) { + if (!repositoryMap.keySet().contains(repository)) { + repositoryMap.put(repository, Collections.emptySet()); + } + } + } + /** * Commit options for hg */ diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCloseBranchExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCloseBranchExecutor.java new file mode 100644 index 000000000000..3aac41d2b394 --- /dev/null +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/commit/HgCloseBranchExecutor.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zmlx.hg4idea.provider.commit; + +import com.intellij.openapi.vcs.changes.CommitExecutorBase; +import com.intellij.openapi.vcs.changes.CommitSession; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; +import org.zmlx.hg4idea.repo.HgRepository; + +import java.util.Collection; + +public class HgCloseBranchExecutor extends CommitExecutorBase { + + @NotNull private final HgCheckinEnvironment myCheckinEnvironment; + @NotNull private static final String CLOSE_BRANCH_TITLE = "Commit And &Close" ; + + + public HgCloseBranchExecutor(@NotNull HgCheckinEnvironment environment) { + myCheckinEnvironment = environment; + } + + @Override + public boolean areChangesRequired() { + return false; + } + + @Nls + @Override + public String getActionText() { + return CLOSE_BRANCH_TITLE; + } + + @NotNull + @Override + public CommitSession createCommitSession() { + myCheckinEnvironment.setCloseBranch(true); + return CommitSession.VCS_COMMIT; + } + + public void setRepositories(@NotNull Collection repositories) { + myCheckinEnvironment.setRepos(repositories); + } +} diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java b/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java index 5c4e5f6ce0cf..01c553f32d03 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/actions/RunningTestTracker.java @@ -60,13 +60,18 @@ class RunningTestTracker extends JUnitAdapter implements TestFrameworkPropertyLi public void onTestChanged(final TestEvent event) { if (event instanceof StateChangedEvent) { final TestProxy proxy = event.getSource(); - if (proxy == myLastRan && !isRunningState(proxy)) { - if (myLastSelected == proxy){ + final boolean isRunning = isRunningState(proxy); + if (isRunning) { + if (proxy.isLeaf()) { + myLastRan = proxy; + } + if (myLastSelected == proxy) { myLastSelected = null; } + } + else if (proxy == myLastRan) { myLastRan = null; } - if (proxy.isLeaf() && isRunningState(proxy)) myLastRan = proxy; myTrackingPolicy.applyTo(proxy); } } diff --git a/plugins/terminal/resources/icons/OpenTerminal_13x13@2x_dark.png b/plugins/terminal/resources/icons/OpenTerminal_13x13@2x_dark.png index 382b1e728685..3abc58e0740d 100644 Binary files a/plugins/terminal/resources/icons/OpenTerminal_13x13@2x_dark.png and b/plugins/terminal/resources/icons/OpenTerminal_13x13@2x_dark.png differ diff --git a/plugins/terminal/resources/icons/OpenTerminal_13x13_dark.png b/plugins/terminal/resources/icons/OpenTerminal_13x13_dark.png index d9ceedc74ae0..1a08ae5a7778 100644 Binary files a/plugins/terminal/resources/icons/OpenTerminal_13x13_dark.png and b/plugins/terminal/resources/icons/OpenTerminal_13x13_dark.png differ diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java index a30ff9b42828..868cccf4ca17 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/AbstractTerminalRunner.java @@ -9,6 +9,7 @@ import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.ui.actions.CloseAction; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -176,15 +177,30 @@ public abstract class AbstractTerminalRunner { public abstract String runningTargetName(); - public void openSessionInDirectory(@NotNull TerminalWidget terminalWidget, @Nullable String directory) { + public void openSessionInDirectory(final @NotNull TerminalWidget terminalWidget, final @Nullable String directory) { // Create Server process - try { - final T process = createProcess(directory); + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + try { + final T process = createProcess(directory); - createAndStartSession(terminalWidget, createTtyConnector(process)); - } - catch (Exception e) { - Messages.showErrorDialog(e.getMessage(), "Can't Open " + runningTargetName()); - } + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + createAndStartSession(terminalWidget, createTtyConnector(process)); + } + }); + } + catch (final Exception e) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + Messages.showErrorDialog(e.getMessage(), "Can't Open " + runningTargetName()); + } + }); + } + } + }); } } diff --git a/python/helpers/pydev/_pydev_imps/_pydev_django_oscar_patch.py b/python/helpers/pydev/_pydev_imps/_pydev_django_oscar_patch.py deleted file mode 100644 index e0a82f7dcb9c..000000000000 --- a/python/helpers/pydev/_pydev_imps/_pydev_django_oscar_patch.py +++ /dev/null @@ -1,38 +0,0 @@ - -import sys -import traceback - - -def _import_module_patched(module_label, classnames): - """ - Imports the module with the given name. - Returns None if the module doesn't exist, but propagates any import errors. - """ - try: - return __import__(module_label, fromlist=classnames) - except ImportError: - # There are 2 reasons why there could be an ImportError: - # - # 1. Module does not exist. In that case, we ignore the import and - # return None - # 2. Module exists but another ImportError occurred when trying to - # import the module. In that case, it is important to propagate the - # error. - # - # ImportError does not provide easy way to distinguish those two cases. - # Fortunately, the traceback of the ImportError starts at __import__ - # statement. If the traceback has more than one frame, it means that - # application was found and ImportError originates within the local app - # - # Changes in patch: change 1 to 2 frames because of the frame, added by - # plugin_import. - # - __, __, exc_traceback = sys.exc_info() - frames = traceback.extract_tb(exc_traceback) - if len(frames) > 2: - raise - - -def patch_oscar_loading(): - module = sys.modules['oscar.core.loading'] - setattr(module, '_import_module', _import_module_patched) diff --git a/python/helpers/pydev/_pydev_imps/_pydev_pluginbase.py b/python/helpers/pydev/_pydev_imps/_pydev_pluginbase.py index dc1ab05907a1..41ece7191f62 100644 --- a/python/helpers/pydev/_pydev_imps/_pydev_pluginbase.py +++ b/python/helpers/pydev/_pydev_imps/_pydev_pluginbase.py @@ -12,7 +12,7 @@ import os import sys -from pydevd_constants import IS_PY24, IS_PY3K, IS_JYTHON, DictContains, DictPop +from pydevd_constants import IS_PY24, IS_PY3K, IS_JYTHON if IS_PY24: from _pydev_imps._pydev_uuid_old import uuid4 @@ -405,16 +405,6 @@ class _ImportHook(ModuleType): ModuleType.__init__(self, name) self._system_import = system_import self.enabled = True - self._modules_to_patch = {} - self._add_modules_for_patching() - - def _add_modules_for_patching(self): - try: - from _pydev_imps._pydev_django_oscar_patch import \ - patch_oscar_loading - self._modules_to_patch['oscar.core.loading'] = patch_oscar_loading - except: - sys.stderr.write("Adding modules to patch in pluginbase failed\n") def enable(self): """Enables the import hook which drives the plugin base system. @@ -458,26 +448,29 @@ class _ImportHook(ModuleType): level = -1 if IS_JYTHON: import_name = name - - activate_func = None - if name == import_name and DictContains(self._modules_to_patch, name): - activate_func = DictPop(self._modules_to_patch, name) - - module = self._system_import(import_name, globals, locals, fromlist, level) - try: - if activate_func: - activate_func() #call activate function - except: - sys.stderr.write("Patching modules in pluginbase failed\n") - return module - + return self._system_import(import_name, globals, locals, + fromlist, level) try: import __builtin__ as builtins except ImportError: import builtins + import_hook = _ImportHook(__name__ + '.import_hook', builtins.__import__) builtins.__import__ = import_hook.plugin_import sys.modules[import_hook.__name__] = import_hook del builtins + + +def patched_exc_info(): + type, value, traceback = sys.system_exc_info() + if type == ImportError: + #we should not show frame added by plugin_import call + return type, value, traceback.tb_next + return type, value, traceback + + +system_exc_info = sys.exc_info +sys.exc_info = patched_exc_info +sys.system_exc_info = system_exc_info diff --git a/python/helpers/pydev/pydev_monkey_qt.py b/python/helpers/pydev/pydev_monkey_qt.py index 06a3f47b65ad..2da5655f5dff 100644 --- a/python/helpers/pydev/pydev_monkey_qt.py +++ b/python/helpers/pydev/pydev_monkey_qt.py @@ -57,10 +57,20 @@ def _patch_import_to_patch_pyqt_on_import(patch_qt_on_import): dotted = patch_qt_on_import + '.' original_import = __import__ + import sys + original_exc_info = sys.exc_info + + def patched_exc_info(): + type, value, traceback = original_exc_info() + if type == ImportError: + #we should not show frame added by patched_import call + return type, value, traceback.tb_next + return type, value, traceback def patched_import(name, *args, **kwargs): if patch_qt_on_import == name or name.startswith(dotted): builtins.__import__ = original_import + sys.exc_info = original_exc_info _internal_patch_qt() # Patch it only when the user would import the qt module return original_import(name, *args, **kwargs) @@ -68,7 +78,8 @@ def _patch_import_to_patch_pyqt_on_import(patch_qt_on_import): import builtins except ImportError: import __builtin__ as builtins - builtins.__import__ = patched_import + builtins.__import__ = patched_import + sys.exc_info = patched_exc_info def _internal_patch_qt(): diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index 5aadbe1a1983..5c0106d4cbd1 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -122,7 +122,6 @@ DONT_TRACE = { '_pydev_pluginbase.py':1, '_pydev_pkgutil_old.py':1, '_pydev_uuid_old.py':1, - '_pydev_django_oscar_patch.py':1, #things from pydev that we don't want to trace '_pydev_execfile.py':1, diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index e4ed2ce70673..d51427bbd001 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -1,3 +1,18 @@ + com.intellij IDEA CORE @@ -1506,6 +1521,7 @@ +