Merge remote branch 'origin/master'

This commit is contained in:
irengrig
2012-03-27 19:22:38 +04:00
20 changed files with 165 additions and 74 deletions
@@ -245,7 +245,7 @@ public class MarkerType {
}
@Override
public void run(@NotNull ProgressIndicator indicator) {
public void run(@NotNull final ProgressIndicator indicator) {
super.run(indicator);
ClassInheritorsSearch.search(myClass, ApplicationManager.getApplication().runReadAction(new Computable<SearchScope>() {
@Override
@@ -255,7 +255,10 @@ public class MarkerType {
}), true).forEach(new CommonProcessors.CollectProcessor<PsiClass>() {
@Override
public boolean process(final PsiClass o) {
updateComponent(o, myRenderer.getComparator());
if (!updateComponent(o, myRenderer.getComparator())) {
indicator.cancel();
}
indicator.checkCanceled();
return super.process(o);
}
});
@@ -281,13 +284,16 @@ public class MarkerType {
}
@Override
public void run(@NotNull ProgressIndicator indicator) {
public void run(@NotNull final ProgressIndicator indicator) {
super.run(indicator);
OverridingMethodsSearch.search(myMethod, true).forEach(
new CommonProcessors.CollectProcessor<PsiMethod>() {
@Override
public boolean process(PsiMethod psiMethod) {
updateComponent(psiMethod, myRenderer.getComparator());
if (!updateComponent(psiMethod, myRenderer.getComparator())) {
indicator.cancel();
}
indicator.checkCanceled();
return super.process(psiMethod);
}
});
@@ -335,13 +335,16 @@ public class ShowImplementationsAction extends AnAction implements PopupAction {
}
@Override
public void run(@NotNull ProgressIndicator indicator) {
public void run(final @NotNull ProgressIndicator indicator) {
super.run(indicator);
myElements =
getSelfAndImplementations(myEditor, myElement, new ImplementationSearcher.BackgroundableImplementationSearcher() {
@Override
protected void processElement(PsiElement element) {
updateComponent(element, null);
if (!updateComponent(element, null)) {
indicator.cancel();
}
indicator.checkCanceled();
}
@Override
@@ -83,12 +83,12 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
return canceled;
}
public void updateComponent(PsiElement element, @Nullable final Comparator comparator) {
if (myCanceled) return;
if (myPopup.isDisposed()) return;
public boolean updateComponent(PsiElement element, @Nullable final Comparator comparator) {
if (myCanceled) return false;
if (myPopup.isDisposed()) return false;
synchronized (lock) {
if (myData.contains(element)) return;
if (myData.contains(element)) return true;
myData.add(element);
}
@@ -110,6 +110,7 @@ public abstract class BackgroundUpdaterTask<T> extends Task.Backgroundable {
myPopup.pack(true, true);
}
}, 200, ModalityState.stateForComponent(myPopup.getContent()));
return true;
}
public int getCurrentSize() {
@@ -78,16 +78,21 @@ public class GotoImplementationHandler extends GotoTargetHandler {
}
@Override
public void run(@NotNull ProgressIndicator indicator) {
public void run(final @NotNull ProgressIndicator indicator) {
super.run(indicator);
for (PsiElement element : myGotoData.targets) {
updateComponent(element, createComparator(renderers, myGotoData));
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
return;
}
}
new ImplementationSearcher.BackgroundableImplementationSearcher() {
protected void processElement(PsiElement element) {
if (myGotoData.addTarget(element)) {
updateComponent(element, createComparator(renderers, myGotoData));
if (!updateComponent(element, createComparator(renderers, myGotoData))) {
indicator.cancel();
}
}
indicator.checkCanceled();
}
}.searchImplementations(myEditor, myGotoData.source, myOffset);
}
@@ -426,11 +426,15 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
}
public void disableToolByDefault(String toolId) {
getTools(toolId).getDefaultState().setEnabled(false);
getToolDefaultState(toolId).setEnabled(false);
}
public ScopeToolState getToolDefaultState(String toolId) {
return getTools(toolId).getDefaultState();
}
public void enableToolByDefault(String toolId) {
getTools(toolId).getDefaultState().setEnabled(true);
getToolDefaultState(toolId).setEnabled(true);
}
public boolean wasInitialized() {
@@ -82,7 +82,15 @@ public class RootModelImpl implements ModifiableRootModel {
@NonNls private static final String ROOT_ELEMENT = "root";
private final ProjectRootManagerImpl myProjectRootManager;
// have to register all child disposables using this fake object since all clients call just ModifiableModel.dispose()
private final Disposable myDisposable = Disposer.newDisposable();
private final List<Disposable> myModelComponents = Collections.synchronizedList(new ArrayList<Disposable>());
private final Disposable myDisposable = new Disposable() {
@Override
public void dispose() {
for (Disposable component : myModelComponents) {
Disposer.dispose(component);
}
}
};
RootModelImpl(@NotNull ModuleRootManagerImpl moduleRootManager, ProjectRootManagerImpl projectRootManager, VirtualFilePointerManager filePointerManager) {
myModuleRootManager = moduleRootManager;
@@ -96,7 +104,7 @@ public class RootModelImpl implements ModifiableRootModel {
for (ModuleExtension extension : Extensions.getExtensions(ModuleExtension.EP_NAME, moduleRootManager.getModule())) {
ModuleExtension model = extension.getModifiableModel(false);
Disposer.register(myDisposable, model);
registerOnDispose(model);
myExtensions.add(model);
}
myConfigurationAccessor = new RootConfigurationAccessor();
@@ -162,7 +170,7 @@ public class RootModelImpl implements ModifiableRootModel {
for (ModuleExtension extension : originalRootModel.myExtensions) {
ModuleExtension model = extension.getModifiableModel(false);
model.readExternal(element);
Disposer.register(myDisposable, model);
registerOnDispose(model);
myExtensions.add(model);
}
myConfigurationAccessor = new RootConfigurationAccessor();
@@ -207,7 +215,7 @@ public class RootModelImpl implements ModifiableRootModel {
for (ModuleExtension extension : rootModel.myExtensions) {
ModuleExtension model = extension.getModifiableModel(writable);
Disposer.register(myDisposable, model);
registerOnDispose(model);
myExtensions.add(model);
}
}
@@ -912,6 +920,7 @@ public class RootModelImpl implements ModifiableRootModel {
myExtensions.clear();
myWritable = false;
myDisposed = true;
myModelComponents.clear();
}
@Override
@@ -1139,6 +1148,6 @@ public class RootModelImpl implements ModifiableRootModel {
}
void registerOnDispose(@NotNull Disposable disposable) {
Disposer.register(myDisposable, disposable);
myModelComponents.add(disposable);
}
}
@@ -1048,29 +1048,13 @@ public class SingleInspectionProfilePanel extends JPanel {
for (int i = 0; rows != null && i < rows.length; i++) {
final InspectionConfigTreeNode node = (InspectionConfigTreeNode)myTree.getPathForRow(rows[i]).getLastPathComponent();
final InspectionConfigTreeNode parent = (InspectionConfigTreeNode)node.getParent();
if (node.getUserObject() instanceof Descriptor) {
final Object userObject = node.getUserObject();
if (userObject instanceof Descriptor && (node.getScopeName() != null || node.isLeaf())) {
updateErrorLevel(node, showOptionsAndDescriptorPanels, level);
updateUpHierarchy(node, parent);
}
else {
node.isProperSetting = false;
for (int j = 0; j < node.getChildCount(); j++) {
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j);
if (child.getUserObject() instanceof Descriptor) { //group node
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
}
else { //root node
child.isProperSetting = false;
for (int k = 0; k < child.getChildCount(); k++) {
final InspectionConfigTreeNode descriptorNode = (InspectionConfigTreeNode)child.getChildAt(k);
if (descriptorNode.getUserObject() instanceof Descriptor) {
updateErrorLevel(descriptorNode, showOptionsAndDescriptorPanels, level);
}
child.isProperSetting |= descriptorNode.isProperSetting;
}
}
node.isProperSetting |= child.isProperSetting;
}
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, node);
updateUpHierarchy(node, parent);
}
}
@@ -1083,6 +1067,23 @@ public class SingleInspectionProfilePanel extends JPanel {
repaintTableData();
}
private void updateErrorLevelUpInHierarchy(HighlightDisplayLevel level,
boolean showOptionsAndDescriptorPanels,
InspectionConfigTreeNode node) {
node.isProperSetting = false;
for (int j = 0; j < node.getChildCount(); j++) {
final InspectionConfigTreeNode child = (InspectionConfigTreeNode)node.getChildAt(j);
final Object userObject = child.getUserObject();
if (userObject instanceof Descriptor && (child.getScopeName() != null || child.isLeaf())) {
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
}
else {
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, child);
}
node.isProperSetting |= child.isProperSetting;
}
}
private void updateErrorLevel(final InspectionConfigTreeNode child,
final boolean showOptionsAndDescriptorPanels, final HighlightDisplayLevel level) {
final HighlightDisplayKey key = child.getDesriptor().getKey();
@@ -59,13 +59,11 @@ public abstract class AddScopeAction extends AnAction {
if (getSelectedProfile() == null) return;
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
if (project == null) return;
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
if (selectedNodes == null) return;
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
for (InspectionConfigTreeNode node : nodes) {
final Descriptor descriptor = node.getDesriptor();
if (descriptor != null && node.getScopeName() == null) {
descriptors.add(descriptor);
}
for (InspectionConfigTreeNode node : selectedNodes) {
collect(descriptors, new ArrayList<InspectionConfigTreeNode>(), node);
}
presentation.setEnabled(!getAvailableScopes(project, descriptors).isEmpty());
@@ -73,13 +71,13 @@ public abstract class AddScopeAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
final InspectionConfigTreeNode[] nodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
List<Descriptor> descriptors = new ArrayList<Descriptor>();
for (InspectionConfigTreeNode node : nodes) {
final Descriptor descriptor = node.getDesriptor();
if (node.getScopeName() == null && descriptor != null) {
descriptors.add(descriptor);
}
final List<Descriptor> descriptors = new ArrayList<Descriptor>();
final InspectionConfigTreeNode[] selectedNodes = myTree.getSelectedNodes(InspectionConfigTreeNode.class, null);
LOG.assertTrue(selectedNodes != null);
final List<InspectionConfigTreeNode> nodes = new ArrayList<InspectionConfigTreeNode>(Arrays.asList(selectedNodes));
for (InspectionConfigTreeNode node : selectedNodes) {
collect(descriptors, nodes, node);
}
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
@@ -97,7 +95,7 @@ public abstract class AddScopeAction extends AnAction {
getSelectedProfile().isToolEnabled(descriptor.getKey()));
final Descriptor addedDescriptor = new Descriptor(scopeToolState, getSelectedProfile());
if (node.getChildCount() == 0) {
node.add(new InspectionConfigTreeNode(descriptor, scopeToolState, true, true, false));
node.add(new InspectionConfigTreeNode(descriptor, getSelectedProfile().getToolDefaultState(descriptor.getKey().getID()), true, true, false));
}
node.insert(new InspectionConfigTreeNode(addedDescriptor, scopeToolState, false, true, false), 0);
node.setInspectionNode(false);
@@ -108,6 +106,23 @@ public abstract class AddScopeAction extends AnAction {
myTree.revalidate();
}
private static void collect(List<Descriptor> descriptors,
List<InspectionConfigTreeNode> nodes,
InspectionConfigTreeNode node) {
final Descriptor descriptor = node.getDesriptor();
if (descriptor != null) {
if (node.getScopeName() == null) {
descriptors.add(descriptor);
}
} else if (node.getUserObject() instanceof String) {
for(int i = 0; i < node.getChildCount(); i++) {
final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode)node.getChildAt(i);
nodes.add(childNode);
collect(descriptors, nodes, childNode);
}
}
}
private List<String> getAvailableScopes(Project project, List<Descriptor> descriptors) {
final ArrayList<NamedScope> scopes = new ArrayList<NamedScope>();
for (NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(project)) {
@@ -22,10 +22,10 @@ import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper;
import com.intellij.ide.passwordSafe.impl.providers.EncryptionUtil;
import com.intellij.ide.passwordSafe.impl.providers.masterKey.windows.WindowsCryptUtils;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.WaitForProgressToShow;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
@@ -182,7 +182,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
}
if (key.get() == null) {
final Ref<PasswordSafeException> ex = new Ref<PasswordSafeException>();
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(new Runnable() {
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
public void run() {
if (key.get() == null) {
try {
@@ -207,7 +207,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
}
}
}
});
}, ModalityState.NON_MODAL);
//noinspection ThrowableResultOfMethodCallIgnored
if (ex.get() != null) {
throw ex.get();
@@ -18,6 +18,8 @@ package com.intellij.ide.passwordSafe.ui;
import com.intellij.ide.passwordSafe.PasswordSafe;
import com.intellij.ide.passwordSafe.PasswordSafeException;
import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
@@ -271,7 +273,7 @@ public class PasswordSafePromptDialog extends DialogWrapper {
}
}
final AtomicReference<String> pw = new AtomicReference<String>(null);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
public void run() {
final PasswordSafePromptDialog d = new PasswordSafePromptDialog(project, ps, title, message);
if (promptLabel != null) {
@@ -299,7 +301,7 @@ public class PasswordSafePromptDialog extends DialogWrapper {
}
}
}
});
}, ModalityState.NON_MODAL);
return pw.get();
}
}
@@ -129,6 +129,10 @@ public class DuringChangeListManagerUpdateTestScheme {
}
public static void checkFilesAreInList(final VirtualFile[] files, final String listName, final ChangeListManager manager) {
checkFilesAreInList(listName, manager, files);
}
public static void checkFilesAreInList(final String listName, final ChangeListManager manager, final VirtualFile... files) {
System.out.println("Checking files for list: " + listName);
assert manager.findChangeList(listName) != null;
final LocalChangeList list = manager.findChangeList(listName);
@@ -144,22 +144,21 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
// note: we are not calling this method during the project startup - it is called anyway by the GitRootTracker
private void updateRepositoriesCollection() {
try {
REPO_LOCK.writeLock().lock();
Map<VirtualFile, GitRepository> repositories = new HashMap<VirtualFile, GitRepository>(myRepositories);
final VirtualFile[] roots = myVcsManager.getRootsUnderVcs(myVcs);
// remove repositories that are not in the roots anymore
for (Iterator<Map.Entry<VirtualFile, GitRepository>> iterator = myRepositories.entrySet().iterator(); iterator.hasNext(); ) {
for (Iterator<Map.Entry<VirtualFile, GitRepository>> iterator = repositories.entrySet().iterator(); iterator.hasNext(); ) {
if (!ArrayUtil.contains(iterator.next().getValue().getRoot(), roots)) {
iterator.remove();
}
}
// add GitRepositories for all roots that don't have correspondent GitRepositories yet.
for (VirtualFile root : roots) {
if (!myRepositories.containsKey(root)) {
if (!repositories.containsKey(root)) {
if (gitRootOK(root)) {
try {
GitRepository repository = createGitRepository(root);
myRepositories.put(root, repository);
repositories.put(root, repository);
}
catch (GitRepoStateException e) {
LOG.error("Couldn't initialize GitRepository in " + root.getPresentableUrl(), e);
@@ -170,6 +169,11 @@ public class GitRepositoryManagerImpl extends AbstractProjectComponent implement
}
}
}
REPO_LOCK.writeLock().lock();
try {
myRepositories.clear();
myRepositories.putAll(repositories);
}
finally {
REPO_LOCK.writeLock().unlock();
@@ -333,14 +333,17 @@ public class GroovyMarkerTypes {
}
@Override
public void run(@NotNull ProgressIndicator indicator) {
public void run(final @NotNull ProgressIndicator indicator) {
super.run(indicator);
for (PsiMethod method : PsiImplUtil.getMethodOrReflectedMethods(myMethod)) {
OverridingMethodsSearch.search(method, true).forEach(
new CommonProcessors.CollectProcessor<PsiMethod>() {
@Override
public boolean process(PsiMethod psiMethod) {
updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator());
if (!updateComponent(com.intellij.psi.impl.PsiImplUtil.handleMirror(psiMethod), myRenderer.getComparator())) {
indicator.cancel();
}
indicator.checkCanceled();
return true;
}
});
@@ -43,6 +43,7 @@ import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
@@ -312,9 +313,10 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
}
return blockPsi instanceof GrParameterList && mySettings.ALIGN_MULTILINE_PARAMETERS ||
blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION;
blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION ||
blockPsi instanceof GrListOrMap && myGroovySettings.ALIGN_MULTILINE_LIST_OR_MAP;
}
private static boolean isListLikeClause(PsiElement blockPsi) {
@@ -323,7 +325,8 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
blockPsi instanceof GrAssignmentExpression ||
blockPsi instanceof GrConditionalExpression ||
blockPsi instanceof GrExtendsClause ||
blockPsi instanceof GrThrowsClause;
blockPsi instanceof GrThrowsClause ||
blockPsi instanceof GrListOrMap;
}
private static boolean isKeyword(ASTNode node) {
@@ -42,6 +42,7 @@ public class GroovyCodeStyleSettings extends CustomCodeStyleSettings {
public boolean USE_FLYING_GEESE_BRACES = false;
public boolean SPACE_IN_NAMED_ARGUMENT = true;
public boolean ALIGN_MULTILINE_LIST_OR_MAP = false;
public GroovyCodeStyleSettings(CodeStyleSettings container) {
super("GroovyCodeStyleSettings", container);
@@ -44,6 +44,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe
if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
consumer.showAllStandardOptions();
consumer.showCustomOption(GroovyCodeStyleSettings.class, "USE_FLYING_GEESE_BRACES", "Use flying geese braces", CodeStyleSettingsCustomizable.WRAPPING_BRACES);
consumer.showCustomOption(GroovyCodeStyleSettings.class, "ALIGN_MULTILINE_LIST_OR_MAP", "Align when multiple", "List and map literals");
return;
}
if (settingsType == SettingsType.SPACING_SETTINGS) {
@@ -133,9 +133,14 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes {
// For arguments
if (psiParent instanceof GrArgumentList) {
if (child.getElementType() != mLPAREN &&
child.getElementType() != mRPAREN) {
return Indent.getContinuationIndent();
if (child.getElementType() != mLPAREN && child.getElementType() != mRPAREN /*&& child.getElementType() != mCOMMA*/) {
return Indent.getContinuationWithoutFirstIndent();
}
}
if (psiParent instanceof GrListOrMap) {
if (child.getElementType() != mLBRACK && child.getElementType() != mRBRACK /*&& child.getElementType() != mCOMMA*/) {
return Indent.getContinuationWithoutFirstIndent();
}
}
@@ -17,6 +17,7 @@
package org.jetbrains.plugins.groovy.lang.editor;
import com.intellij.codeInsight.editorActions.MultiCharQuoteHandler;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
import com.intellij.openapi.util.TextRange;
@@ -64,7 +65,9 @@ public class GroovyQuoteHandler implements MultiCharQuoteHandler {
@Override
public CharSequence getClosingQuote(HighlighterIterator iterator, int offset) {
if (offset >= 3) {
String quote = iterator.getDocument().getText(new TextRange(offset - 3, offset));
Document document = iterator.getDocument();
if (document == null) return null;
String quote = document.getText(new TextRange(offset - 3, offset));
if ("'''".equals(quote)) return quote;
if ("\"\"\"".equals(quote)) return quote;
}
@@ -380,7 +380,11 @@ public class StubGenerator implements ClassItemGenerator {
return eval.toString() + "f";
}
else if (eval instanceof Character) {
return "'" + ((Character)eval).charValue() + "'";
StringBuilder buffer = new StringBuilder();
buffer.append('\'');
StringUtil.escapeStringCharacters(1, Character.toString(((Character)eval).charValue()), buffer);
buffer.append('\'');
return buffer.toString();
}
if (eval instanceof Number || eval instanceof Boolean) {
return eval.toString();
@@ -241,6 +241,23 @@ new Runnable() {
}
}
void testEvalInStaticMethod() {
myFixture.addFileToProject('Foo.groovy', '''\
static def foo() {
int x = 5
print x
}
foo()
''')
addBreakpoint 'Foo.groovy', 2
runDebugger 'Foo', {
waitForBreakpoint()
eval 'x', '5'
}
}
private def addBreakpoint(String fileName, int line) {
VirtualFile file = null
edt {