diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index 5e026618265b..757bc4affa66 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -394,7 +394,7 @@ public class CreateFromUsageUtils { final String name, final PsiManager manager, @NotNull final PsiElement contextElement, - @NotNull final PsiFile sourceFile, + final PsiFile sourceFile, final String superClassName) { final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); final PsiElementFactory factory = facade.getElementFactory(); diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java index 1ded5de895f6..77ed6ed70fd6 100644 --- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodOrClassStaticProcessor.java @@ -51,9 +51,7 @@ import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; +import java.util.*; public abstract class MakeMethodOrClassStaticProcessor extends BaseRefactoringProcessor { private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.makeMethodStatic.MakeMethodStaticProcessor"); @@ -111,16 +109,16 @@ public abstract class MakeMethodOrClassStaticProcessor toMakeStatic = new ArrayList(); + final Set toMakeStatic = new LinkedHashSet(); refUsages.set(filterOverriding(usagesIn, toMakeStatic)); if (!findAdditionalMembers(toMakeStatic)) return false; prepareSuccessful(); return true; } - protected boolean findAdditionalMembers(ArrayList toMakeStatic) {return true;} + protected boolean findAdditionalMembers(Set toMakeStatic) {return true;} - private static UsageInfo[] filterOverriding(UsageInfo[] usages, List suggestToMakeStatic) { + private static UsageInfo[] filterOverriding(UsageInfo[] usages, Set suggestToMakeStatic) { ArrayList result = new ArrayList(); for (UsageInfo usage : usages) { if (usage instanceof ChainedCallUsageInfo) { diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodStaticProcessor.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodStaticProcessor.java index d5b7b84ab161..ec8c635d496e 100644 --- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodStaticProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeMethodStaticProcessor.java @@ -16,7 +16,6 @@ package com.intellij.refactoring.makeStatic; import com.intellij.codeInsight.TestFrameworks; -import com.intellij.lang.Language; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -37,10 +36,8 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.VisibilityUtil; import com.intellij.util.containers.MultiMap; import com.intellij.util.ui.tree.TreeUtil; -import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; /** * @author dsl @@ -54,7 +51,7 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor< } @Override - protected boolean findAdditionalMembers(final ArrayList toMakeStatic) { + protected boolean findAdditionalMembers(final Set toMakeStatic) { if (!toMakeStatic.isEmpty()) { myAdditionalMethods = new ArrayList(); if (ApplicationManager.getApplication().isUnitTestMode()) { @@ -71,7 +68,7 @@ public class MakeMethodStaticProcessor extends MakeMethodOrClassStaticProcessor< }) { @Override protected ArrayList getTopLevelItems() { - return toMakeStatic; + return new ArrayList(toMakeStatic); } }; TreeUtil.expand(chooser.getTree(), 2); diff --git a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java index 1245f04103cd..682d5824e008 100644 --- a/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java +++ b/java/java-impl/src/com/intellij/unscramble/UnscrambleDialog.java @@ -318,8 +318,8 @@ public class UnscrambleDialog extends DialogWrapper { builder.append(" ").append(trimSuffix(line)); continue; } - if (!first && mustHaveNewLineBefore(line)) { - builder.append("\n"); + if (!first && (mustHaveNewLineBefore(line) || StringUtil.endsWith(builder, ")"))) { + if (!StringUtil.endsWith(builder, "\n")) builder.append("\n"); if (line.startsWith("\"")) builder.append("\n"); // Additional line break for thread names } first = false; diff --git a/java/java-runtime/src/com/intellij/rt/execution/application/AppMain.java b/java/java-runtime/src/com/intellij/rt/execution/application/AppMain.java index 3673a930d742..ec26d7c5ae1e 100644 --- a/java/java-runtime/src/com/intellij/rt/execution/application/AppMain.java +++ b/java/java-runtime/src/com/intellij/rt/execution/application/AppMain.java @@ -38,33 +38,34 @@ public class AppMain { private static native void triggerControlBreak(); + private static boolean ourHasSecurityProblem = false; static { - String binPath = System.getProperty(PROPERTY_BINPATH) + File.separator; - final String osName = System.getProperty("os.name").toLowerCase(); - String arch = System.getProperty("os.arch").toLowerCase(); - String libPath = null; - if (osName.startsWith("windows")) { - if (arch.equals("amd64")) { - libPath = binPath + "breakgen64.dll"; - } - else { - libPath = binPath + "breakgen.dll"; - } - } else if (osName.startsWith("linux")) { - if (arch.equals("amd64")) { - libPath = binPath + "libbreakgen64.so"; - } else { - libPath = binPath + "libbreakgen.so"; - } - } else if (osName.startsWith("mac")) { - if (arch.endsWith("64")) { - libPath = binPath + "libbreakgen64.jnilib"; - } else { - libPath = binPath + "libbreakgen.jnilib"; - } - } - try { + String binPath = System.getProperty(PROPERTY_BINPATH) + File.separator; + final String osName = System.getProperty("os.name").toLowerCase(); + String arch = System.getProperty("os.arch").toLowerCase(); + String libPath = null; + if (osName.startsWith("windows")) { + if (arch.equals("amd64")) { + libPath = binPath + "breakgen64.dll"; + } + else { + libPath = binPath + "breakgen.dll"; + } + } else if (osName.startsWith("linux")) { + if (arch.equals("amd64")) { + libPath = binPath + "libbreakgen64.so"; + } else { + libPath = binPath + "libbreakgen.so"; + } + } else if (osName.startsWith("mac")) { + if (arch.endsWith("64")) { + libPath = binPath + "libbreakgen64.jnilib"; + } else { + libPath = binPath + "libbreakgen.jnilib"; + } + } + if (libPath != null) { System.load(libPath); } @@ -72,41 +73,46 @@ public class AppMain { catch (UnsatisfiedLinkError e) { //Do nothing, unknown os or some other error => no ctrl-break is available } + catch (SecurityException e) { + ourHasSecurityProblem = true; + System.out.println("break in console is not supported due to security permissions: " + e.getMessage()); + } } public static void main(String[] args) throws Throwable { + if (!ourHasSecurityProblem) { + final int portNumber = Integer.getInteger(PROPERTY_PORT_NUMBER).intValue(); + Thread t = new Thread( + new Runnable() { + public void run() { + try { + ServerSocket socket = new ServerSocket(portNumber); + Socket client = socket.accept(); + BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream())); + while (true) { + String msg = reader.readLine(); - final int portNumber = Integer.getInteger(PROPERTY_PORT_NUMBER).intValue(); - Thread t = new Thread( - new Runnable() { - public void run() { - try { - ServerSocket socket = new ServerSocket(portNumber); - Socket client = socket.accept(); - BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream())); - while (true) { - String msg = reader.readLine(); - - if ("TERM".equals(msg)){ - return; - } - else if ("BREAK".equals(msg)) { - triggerControlBreak(); - } - else if ("STOP".equals(msg)) { - System.exit(1); + if ("TERM".equals(msg)){ + return; + } + else if ("BREAK".equals(msg)) { + triggerControlBreak(); + } + else if ("STOP".equals(msg)) { + System.exit(1); + } } + } catch (IOException ignored) { + } catch (IllegalArgumentException ignored) { + } catch (SecurityException ignored) { } - } catch (IOException ignored) { - } catch (IllegalArgumentException ignored) { - } catch (SecurityException ignored) { } - } - }, "Monitor Ctrl-Break"); - try { - t.setDaemon(true); - t.start(); - } catch (Exception ignored) {} + }, "Monitor Ctrl-Break"); + try { + t.setDaemon(true); + t.start(); + } catch (Exception ignored) {} + } String mainClass = args[0]; String[] parms = new String[args.length - 1]; diff --git a/java/java-tests/testSrc/com/intellij/unscramble/NormalizeTextTest.java b/java/java-tests/testSrc/com/intellij/unscramble/NormalizeTextTest.java index e00b46d40241..a65e823fdd7c 100644 --- a/java/java-tests/testSrc/com/intellij/unscramble/NormalizeTextTest.java +++ b/java/java-tests/testSrc/com/intellij/unscramble/NormalizeTextTest.java @@ -109,6 +109,18 @@ public class NormalizeTextTest extends TestCase { "at org.apache.velocity.Template.merge(Template.java:256)"); } + public void testWithoutAt() { + doTest(" java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)\n" + + " java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)\n" + + " java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:400)\n" + + " java.util.concurrent.ForkJoinTask.invokeAll(ForkJoinTask.java:837)\n", + + " java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)\n" + + " java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)\n" + + " java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:400)\n" + + " java.util.concurrent.ForkJoinTask.invokeAll(ForkJoinTask.java:837)"); + } + private static void doTest(@NonNls String stackTrace, @NonNls String expected) { String normalized = UnscrambleDialog.normalizeText(stackTrace); assertEquals(expected, normalized); diff --git a/platform/core-api/src/com/intellij/psi/search/GlobalSearchScope.java b/platform/core-api/src/com/intellij/psi/search/GlobalSearchScope.java index 96a03d492d72..fd751074860c 100644 --- a/platform/core-api/src/com/intellij/psi/search/GlobalSearchScope.java +++ b/platform/core-api/src/com/intellij/psi/search/GlobalSearchScope.java @@ -159,7 +159,8 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw @NotNull public GlobalSearchScope uniteWith(@NotNull GlobalSearchScope scope) { if (scope == this) return scope; - return new UnionScope(this, scope, null); + + return new UnionScope(this, scope); } @NotNull @@ -403,22 +404,24 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw private static class UnionScope extends GlobalSearchScope { private final GlobalSearchScope myScope1; private final GlobalSearchScope myScope2; - private final String myDisplayName; + private final int myNestingLevel; - private UnionScope(@NotNull GlobalSearchScope scope1, @NotNull GlobalSearchScope scope2, String displayName) { + private UnionScope(@NotNull GlobalSearchScope scope1, @NotNull GlobalSearchScope scope2) { super(scope1.getProject() == null ? scope2.getProject() : scope1.getProject()); myScope1 = scope1; myScope2 = scope2; - myDisplayName = displayName; + myNestingLevel = 1 + + Math.max(scope1 instanceof UnionScope ? ((UnionScope)scope1).myNestingLevel : 0, + scope2 instanceof UnionScope ? ((UnionScope)scope2).myNestingLevel : 0); + if (myNestingLevel > 1000) { + throw new IllegalStateException("Too many scopes combined: " + myNestingLevel); + } } @NotNull @Override public String getDisplayName() { - if (myDisplayName == null) { - return PsiBundle.message("psi.search.scope.union", myScope1.getDisplayName(), myScope2.getDisplayName()); - } - return myDisplayName; + return PsiBundle.message("psi.search.scope.union", myScope1.getDisplayName(), myScope2.getDisplayName()); } @Override diff --git a/platform/editor-ui-ex/src/com/intellij/codeStyle/AbstractConvertLineSeparatorsAction.java b/platform/editor-ui-ex/src/com/intellij/codeStyle/AbstractConvertLineSeparatorsAction.java index 8f54a068385a..c0541d66bd57 100644 --- a/platform/editor-ui-ex/src/com/intellij/codeStyle/AbstractConvertLineSeparatorsAction.java +++ b/platform/editor-ui-ex/src/com/intellij/codeStyle/AbstractConvertLineSeparatorsAction.java @@ -16,7 +16,8 @@ package com.intellij.codeStyle; import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; @@ -34,8 +35,6 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.IOException; - /** * @author Nikolai Matveev */ @@ -155,17 +154,11 @@ public abstract class AbstractConvertLineSeparatorsAction extends AnAction { LineSeparator.fromString(currentSeparator), LineSeparator.fromString(newSeparator)); } - CommandProcessor commandProcessor = CommandProcessor.getInstance(); - commandProcessor.executeCommand(project, new Runnable() { + new WriteCommandAction(project, commandText) { @Override - public void run() { - try { - LoadTextUtil.changeLineSeparators(project, virtualFile, newSeparator, this); - } - catch (IOException e) { - LOG.warn(e); - } + protected void run(@NotNull Result result) throws Throwable { + LoadTextUtil.changeLineSeparators(project, virtualFile, newSeparator, this); } - }, commandText, null); + }.execute(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java index 7eebc674c8b0..4c4f7598b1ef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ContentTabLabel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -20,11 +20,11 @@ import com.intellij.ui.Gray; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentManager; import com.intellij.util.ui.BaseButtonBehavior; +import com.intellij.util.ui.JBUI; import com.intellij.util.ui.TimedDeadzone; import com.intellij.util.ui.UIUtil; import javax.swing.*; -import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.MouseEvent; @@ -58,7 +58,7 @@ class ContentTabLabel extends BaseLabel { setBorder(null); } else { setHorizontalAlignment(SwingConstants.CENTER); - setBorder(new EmptyBorder(0, 8, 0, 8)); + setBorder(JBUI.Borders.empty(0, 8)); } updateTextAndIcon(myContent, isSelected()); @@ -96,7 +96,7 @@ class ContentTabLabel extends BaseLabel { @Override protected Graphics _getGraphics(Graphics2D g) { if (isSelected() && contentManager().getContentCount() > 1) { - return new EngravedTextGraphics(g, 1, 1, myUi.myWindow.isActive() ? new Color(0, 0, 0, 120) : new Color(0, 0, 0, 130)); + return new EngravedTextGraphics(g, 1, 1, Gray._0.withAlpha(myUi.myWindow.isActive() ? 120 : 130)); } return super._getGraphics(g); diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index b8847bbb1730..3a7e12cafcad 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -522,6 +522,6 @@ ide.find.show.preview=true ide.remove.help.button.from.dialogs=false ide.remove.help.button.from.dialogs.description=Removes help button from dialogs -mysql.native.loading.description=Enables native loader for MySQL data sources -mysql.native.loading=false +sql.native.loading.description=Enables native loader for SQL data sources +sql.native.loading=false git.status.write=true diff --git a/xml/openapi/src/com/intellij/ide/browsers/OpenInBrowserRequest.java b/xml/openapi/src/com/intellij/ide/browsers/OpenInBrowserRequest.java index 10d84ccf05cd..c4119d10c8c0 100644 --- a/xml/openapi/src/com/intellij/ide/browsers/OpenInBrowserRequest.java +++ b/xml/openapi/src/com/intellij/ide/browsers/OpenInBrowserRequest.java @@ -1,5 +1,7 @@ package com.intellij.ide.browsers; +import com.intellij.openapi.application.AccessToken; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; @@ -23,9 +25,16 @@ public abstract class OpenInBrowserRequest { @Nullable public static OpenInBrowserRequest create(@NotNull final PsiElement element) { - PsiFile psiFile = element.isValid() ? element.getContainingFile() : null; - if (psiFile == null || psiFile.getVirtualFile() == null) { - return null; + PsiFile psiFile; + AccessToken token = ReadAction.start(); + try { + psiFile = element.isValid() ? element.getContainingFile() : null; + if (psiFile == null || psiFile.getVirtualFile() == null) { + return null; + } + } + finally { + token.finish(); } return new OpenInBrowserRequest(psiFile) {