diff --git a/platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java b/platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java index bd92a55295a0..68ddb1a2436f 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java @@ -84,7 +84,7 @@ public abstract class SuppressIntentionAction implements Iconable, IntentionActi @Override public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { - if (file == null) return false; + if (file == null || editor == null) return false; PsiElement element = getElement(editor, file); return element != null && isAvailable(project, editor, element); } diff --git a/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java b/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java index a84326c6cf12..6c12bd827bb6 100644 --- a/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java +++ b/platform/indexing-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.openapi.roots.impl; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.impl.scopes.JdkScope; import com.intellij.openapi.module.impl.scopes.LibraryRuntimeClasspathScope; import com.intellij.openapi.project.Project; @@ -28,6 +29,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.ConcurrencyUtil; import com.intellij.util.containers.ConcurrentFactoryMap; import com.intellij.util.containers.ContainerUtil; +import gnu.trove.THashSet; import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -195,12 +197,21 @@ public class LibraryScopeCache { return scope; } - private GlobalSearchScope calcLibraryUseScope(List entries) { + @NotNull + private GlobalSearchScope calcLibraryUseScope(@NotNull List entries) { List united = ContainerUtil.newArrayList(); united.add(getLibrariesOnlyScope()); + Set modulesInvolved = new THashSet<>(entries.size()); for (OrderEntry entry : entries) { - united.add(GlobalSearchScope.moduleWithDependentsScope(entry.getOwnerModule())); + Module ownerModule = entry.getOwnerModule(); + united.add(GlobalSearchScope.moduleWithDependentsScope(ownerModule)); + modulesInvolved.add(ownerModule); } + // optimisation: if the library attached to all modules (often the case with JDK) then replace the 'union of all modules' scope with just 'project' + if (modulesInvolved.size() == ModuleManager.getInstance(myProject).getModules().length) { + return GlobalSearchScope.allScope(myProject); + } + return GlobalSearchScope.union(united.toArray(new GlobalSearchScope[united.size()])); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/WatchInplaceEditor.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/WatchInplaceEditor.java index 62392df9eb30..44079cf33b96 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/WatchInplaceEditor.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/WatchInplaceEditor.java @@ -16,6 +16,7 @@ package com.intellij.xdebugger.impl.frame; import com.intellij.ui.AppUIUtil; +import com.intellij.util.ui.tree.TreeUtil; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XDebugSessionListener; import com.intellij.xdebugger.XExpression; @@ -36,13 +37,15 @@ import javax.swing.*; public class WatchInplaceEditor extends XDebuggerTreeInplaceEditor { private final WatchesRootNode myRootNode; private final XWatchesView myWatchesView; - @Nullable private final WatchNode myOldNode; + private final WatchNode myOldNode; private WatchEditorSessionListener mySessionListener; public WatchInplaceEditor(@NotNull WatchesRootNode rootNode, - @Nullable XDebugSession session, XWatchesView watchesView, final WatchNode node, - @NonNls final String historyId, - final @Nullable WatchNode oldNode) { + @Nullable XDebugSession session, + XWatchesView watchesView, + WatchNode node, + @NonNls String historyId, + @Nullable WatchNode oldNode) { super((XDebuggerTreeNode)node, historyId); myRootNode = rootNode; myWatchesView = watchesView; @@ -66,7 +69,7 @@ public class WatchInplaceEditor extends XDebuggerTreeInplaceEditor { if (myOldNode == null && index != -1) { myRootNode.removeChildNode(getNode()); } - getTree().setSelectionRow(index); + TreeUtil.selectNode(myTree, getNode()); } @Override @@ -78,7 +81,7 @@ public class WatchInplaceEditor extends XDebuggerTreeInplaceEditor { if (!XDebuggerUtilImpl.isEmptyExpression(expression) && index != -1) { myWatchesView.addWatchExpression(expression, index, false); } - getTree().setSelectionRow(index); + TreeUtil.selectNode(myTree, getNode()); } @Override diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java index ed082c5fab4c..65811b365e88 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java @@ -573,9 +573,10 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver @Nullable String debuggerSetup, @NotNull Consumer initScriptConsumer) { if (!StringUtil.isEmpty(debuggerSetup)) { + final String names = "[\"" + StringUtil.join(taskNames, "\", \"") + "\"]"; final String[] lines = { "gradle.taskGraph.beforeTask { Task task ->", - " if (task instanceof JavaForkOptions) {", + " if (task instanceof JavaForkOptions && (" + names + ".contains(task.name) || " + names + ".contains(task.path))) {", " def jvmArgs = task.jvmArgs.findAll{!it?.startsWith('-agentlib') && !it?.startsWith('-Xrunjdwp')}", " jvmArgs << '" + debuggerSetup.trim() + '\'', " task.jvmArgs jvmArgs", diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java index 0e2e5d0a6485..29d3f570776c 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspection.java @@ -191,6 +191,7 @@ public class InvalidPropertyKeyInspection extends BaseJavaLocalInspectionTool { } private void visitPropertyKeyAnnotationParameter(PsiExpression expression, String key) { + if (!(expression.getParent() instanceof PsiExpressionList)) return; Ref resourceBundleName = new Ref(); if (!JavaI18nUtil.isValidPropertyReference(myManager.getProject(), expression, key, resourceBundleName)) { String bundleName = resourceBundleName.get(); diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java index 916e7c2cbaae..d66f7dfdba4d 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java @@ -429,17 +429,22 @@ public class ResourceBundleEditor extends UserDataHolderBase implements Document if (oldEditor != null) { EditorFactory.getInstance().releaseEditor(oldEditor); } + final Boolean[] isViewer = new Boolean[1]; ((EditorEx) editor).addFocusListener(new FocusChangeListener() { @Override public void focusGained(final Editor editor) { mySelectedEditor = editor; final EditorEx editorEx = (EditorEx)editor; - editorEx.setViewer(ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(propertiesFile.getVirtualFile()).hasReadonlyFiles()); + if (isViewer[0] == null) { + final boolean readOnly = ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(propertiesFile.getVirtualFile()).hasReadonlyFiles(); + editorEx.setViewer(readOnly); + isViewer[0] = readOnly; + } } @Override public void focusLost(final Editor eventEditor) { - if (propertiesFile.getContainingFile().isValid()) { + if (Boolean.FALSE.equals(isViewer[0]) && propertiesFile.getContainingFile().isValid()) { writeEditorPropertyValue(null, editor, propertiesFile); } } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java index a7a52bac3030..d216128cc619 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundlePropertiesUpdateManager.java @@ -21,6 +21,7 @@ import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.lang.properties.psi.Property; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Pair; import com.intellij.psi.PsiComment; import com.intellij.psi.PsiElement; @@ -71,8 +72,11 @@ public class ResourceBundlePropertiesUpdateManager { public void insertOrUpdateTranslation(String key, String value, final PropertiesFile propertiesFile) throws IncorrectOperationException { final IProperty property = propertiesFile.findPropertyByKey(key); if (property != null) { - property.setValue(value); - myCodeStyleManager.reformat(property.getPsiElement()); + final String oldValue = property.getValue(); + if (!Comparing.equal(oldValue, value)) { + property.setValue(value); + myCodeStyleManager.reformat(property.getPsiElement()); + } return; } diff --git a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleRenameUtil.java b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleRenameUtil.java index 869be96b5b1b..7bf5c719e33b 100644 --- a/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleRenameUtil.java +++ b/plugins/properties/src/com/intellij/lang/properties/refactoring/rename/ResourceBundleRenameUtil.java @@ -80,7 +80,7 @@ public class ResourceBundleRenameUtil { @Override public boolean checkInput(final String inputString) { - return inputString.indexOf('.') < 0; + return true; } @Override diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxSymbolIndex.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxSymbolIndex.java index 483527c8fce5..3150092190a8 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxSymbolIndex.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxSymbolIndex.java @@ -65,9 +65,31 @@ public class RelaxSymbolIndex extends ScalarIndexExtension { public static NavigationItem[] getSymbolsByName(final String name, Project project, boolean includeNonProjectItems) { final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project); - final SymbolCollector processor = new SymbolCollector(name, project, scope); - FileBasedIndex.getInstance().processValues(NAME, name, null, processor, scope); - return processor.getResult(); + final Collection result = new ArrayList(); + PsiManager psiManager = PsiManager.getInstance(project); + + for(VirtualFile file:FileBasedIndex.getInstance().getContainingFiles(NAME, name, scope)) { + final PsiFile psiFile = psiManager.findFile(file); + + if (psiFile instanceof XmlFile) { + final Grammar grammar = GrammarFactory.getGrammar((XmlFile)psiFile); + + if (grammar != null) { + grammar.acceptChildren(new CommonElement.Visitor() { + @Override + public void visitDefine(Define define) { + if (name.equals(define.getName())) { + final PsiElement psi = define.getPsiElement(); + if (psi != null) { + MyNavigationItem.add((NavigationItem)define.getPsiElement(), result); + } + } + } + }); + } + } + } + return result.toArray(new NavigationItem[result.size()]); } @NotNull @@ -171,48 +193,6 @@ public class RelaxSymbolIndex extends ScalarIndexExtension { return 0; } - private static class SymbolCollector implements FileBasedIndex.ValueProcessor { - private final GlobalSearchScope myScope; - private final PsiManager myMgr; - private final String myName; - - private final Collection myResult = new ArrayList(); - - public SymbolCollector(String name, Project project, GlobalSearchScope scope) { - myMgr = PsiManager.getInstance(project); - myScope = scope; - myName = name; - } - - @Override - public boolean process(VirtualFile file, Void kind) { - if (myScope.contains(file)) { - final PsiFile psiFile = myMgr.findFile(file); - if (psiFile instanceof XmlFile) { - final Grammar grammar = GrammarFactory.getGrammar((XmlFile)psiFile); - if (grammar != null) { - grammar.acceptChildren(new CommonElement.Visitor() { - @Override - public void visitDefine(Define define) { - if (myName.equals(define.getName())) { - final PsiElement psi = define.getPsiElement(); - if (psi != null) { - MyNavigationItem.add((NavigationItem)define.getPsiElement(), myResult); - } - } - } - }); - } - } - } - return true; - } - - public NavigationItem[] getResult() { - return myResult.toArray(new NavigationItem[myResult.size()]); - } - } - private static class MyNavigationItem implements PsiElementNavigationItem, ItemPresentation { private final NavigationItem myItem; private final ItemPresentation myPresentation;